[Japi-cvs] SF.net SVN: japi:[728] progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca
Status: Beta
Brought to you by:
christianhujer
|
From: <chr...@us...> - 2008-11-30 18:04:37
|
Revision: 728
http://japi.svn.sourceforge.net/japi/?rev=728&view=rev
Author: christianhujer
Date: 2008-11-30 18:04:35 +0000 (Sun, 30 Nov 2008)
Log Message:
-----------
Removed code that is now redundant with the rest if JAPI.
Modified Paths:
--------------
progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/MCAnswerText.java
progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/MCQuestionText.java
progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/Program.java
progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/QuestionCollection.java
progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/QuestionText.java
progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/Settings.java
progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/gui/AnswerGUI.java
progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/gui/FirstSettingsModule.java
progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/gui/GUIOptionsSettingsModule.java
progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/gui/ProgramFrame.java
progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/gui/QuestionCollectionGUI.java
progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/gui/action.properties
progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/gui/action_de.properties
progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/io/AbstractJTestImport.java
progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/io/JTestV1.java
progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/swing/AbstractManager.java
progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/swing/OpenURLPane.java
progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/swing/io/AbstractCachingImporter.java
progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/swing/io/IOModuleProvider.java
progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/swing/io/Importer.java
progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/util/MimeData.java
progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/util/StringToTextComparatorAdapter.java
progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/util/Text.java
Added Paths:
-----------
progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/swing/io/IOUtilities.java
Removed Paths:
-------------
progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/swing/ISwingUtilities.java
progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/swing/io/EndingFileFilter.java
progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/swing/io/FilenameFileFilter.java
progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/swing/recent/
progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/swing/settings/
Modified: progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/MCAnswerText.java
===================================================================
--- progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/MCAnswerText.java 2008-11-30 18:00:40 UTC (rev 727)
+++ progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/MCAnswerText.java 2008-11-30 18:04:35 UTC (rev 728)
@@ -87,7 +87,7 @@
return checked;
}
- /** Get wether this answer has been checked correctly.
+ /** Get whether or not this answer has been checked correctly.
* @return true if checked correctly, false otherwise
*/
public boolean isCheckedCorrectly() {
Modified: progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/MCQuestionText.java
===================================================================
--- progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/MCQuestionText.java 2008-11-30 18:00:40 UTC (rev 727)
+++ progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/MCQuestionText.java 2008-11-30 18:04:35 UTC (rev 728)
@@ -191,8 +191,8 @@
return answerTexts;
}
- /** Get wether this question has been answered correctly.
- * @return true if this question has been answered correctly, false otherwise
+ /** Get whether or not this question has been answered correctly.
+ * @return <code>true</code> if this question has been answered correctly, <code>false</code> otherwise
*/
@Override public boolean isAnsweredCorrectly() {
boolean answeredCorrectly = true;
Modified: progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/Program.java
===================================================================
--- progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/Program.java 2008-11-30 18:00:40 UTC (rev 727)
+++ progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/Program.java 2008-11-30 18:04:35 UTC (rev 728)
@@ -26,7 +26,7 @@
import net.sf.japi.progs.jeduca.jtest.io.JTestV1;
import net.sf.japi.progs.jeduca.jtest.io.KEduca;
import net.sf.japi.progs.jeduca.swing.io.IOModuleProvider;
-import net.sf.japi.progs.jeduca.swing.recent.PrefsRecentURLs;
+import net.sf.japi.swing.recent.PrefsRecentURLs;
import org.xml.sax.SAXException;
/** The Program contains the basic references such as the current QuestionCollection and provides important main operations like loading and saving
Modified: progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/QuestionCollection.java
===================================================================
--- progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/QuestionCollection.java 2008-11-30 18:00:40 UTC (rev 727)
+++ progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/QuestionCollection.java 2008-11-30 18:04:35 UTC (rev 728)
@@ -102,7 +102,7 @@
}
/** Add a Question.
- * Because this method cannot know wether the QuestionText is or is not made solely for this QuestionCollection, the QuestionText is not cloned.
+ * Because this method cannot know whether or not the QuestionText is or is not made solely for this QuestionCollection, the QuestionText is not cloned.
* But it is generally a good idea to clone QuestionTexts coming from other QuestionCollections before adding them to this QuestionCollection,
* otherwise strange effects might occur if a user copies a QuestionText from one QuestionCollection to another and the copy is not a duplicate.
* @param question Question to add
Modified: progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/QuestionText.java
===================================================================
--- progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/QuestionText.java 2008-11-30 18:00:40 UTC (rev 727)
+++ progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/QuestionText.java 2008-11-30 18:04:35 UTC (rev 728)
@@ -125,8 +125,8 @@
this.marked = marked;
}
- /** Get wether this question has been answered correctly.
- * @return true if this question has been answered correctly, false otherwise
+ /** Get whether this question has been answered correctly.
+ * @return <code>true</code> if this question has been answered correctly, <code>false</code> otherwise
*/
public abstract boolean isAnsweredCorrectly();
Modified: progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/Settings.java
===================================================================
--- progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/Settings.java 2008-11-30 18:00:40 UTC (rev 727)
+++ progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/Settings.java 2008-11-30 18:04:35 UTC (rev 728)
@@ -23,9 +23,9 @@
import java.util.ArrayList;
import java.util.List;
import java.util.prefs.Preferences;
-import net.sf.japi.progs.jeduca.swing.recent.RecentURLs;
-import net.sf.japi.progs.jeduca.swing.recent.RecentURLsEvent;
-import net.sf.japi.progs.jeduca.swing.recent.RecentURLsListener;
+import net.sf.japi.swing.recent.RecentURLs;
+import net.sf.japi.swing.recent.RecentURLsEvent;
+import net.sf.japi.swing.recent.RecentURLsListener;
/** Class representing the settings for JTest.
* It also manages the list of recent URLs.
@@ -33,7 +33,7 @@
*/
public class Settings implements RecentURLs {
- /** Wether to show the solution for each question. */
+ /** Whether to show the solution for each question. */
private boolean showQuestionSolution;
/** How many files to show in the last opened list. */
@@ -81,15 +81,15 @@
}
}
- /** Tell wether to show the solution for each question.
+ /** Tell whether to show the solution for each question.
* @return boolean
*/
public boolean isShowQuestionSolution() {
return showQuestionSolution;
}
- /** Set wether to show the solution for each question
- * @param showQuestionSolution wether to show the solution for each question
+ /** Set whether to show the solution for each question
+ * @param showQuestionSolution whether to show the solution for each question
*/
public void setShowQuestionSolution(final boolean showQuestionSolution) {
this.showQuestionSolution = showQuestionSolution;
Modified: progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/gui/AnswerGUI.java
===================================================================
--- progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/gui/AnswerGUI.java 2008-11-30 18:00:40 UTC (rev 727)
+++ progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/gui/AnswerGUI.java 2008-11-30 18:04:35 UTC (rev 728)
@@ -82,7 +82,7 @@
add(button);
}
- /** Get wether this single answer has been checked correctly.
+ /** Get whether this single answer has been checked correctly.
* @return true if the user checked this answer in correct state, false otherwise
*/
public boolean isCorrectlyChecked() {
Modified: progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/gui/FirstSettingsModule.java
===================================================================
--- progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/gui/FirstSettingsModule.java 2008-11-30 18:00:40 UTC (rev 727)
+++ progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/gui/FirstSettingsModule.java 2008-11-30 18:04:35 UTC (rev 728)
@@ -20,28 +20,24 @@
package net.sf.japi.progs.jeduca.jtest.gui;
-import java.awt.Component;
import java.awt.GridBagConstraints;
import static java.awt.GridBagConstraints.HORIZONTAL;
import static java.awt.GridBagConstraints.NORTHWEST;
import static java.awt.GridBagConstraints.REMAINDER;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
-import java.net.URL;
import static javax.swing.BorderFactory.createTitledBorder;
import javax.swing.ButtonGroup;
-import javax.swing.Icon;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import net.sf.japi.progs.jeduca.jtest.Settings;
-import net.sf.japi.progs.jeduca.swing.settings.SettingsModule;
-import org.jetbrains.annotations.Nullable;
+import net.sf.japi.swing.prefs.AbstractPrefs;
/** Settings module.
* @author $Author: chris $
* @version $Id: FirstSettingsModule.java,v 1.2 2006/01/31 23:09:18 chris Exp $
*/
-public class FirstSettingsModule extends JPanel implements SettingsModule {
+public class FirstSettingsModule extends AbstractPrefs {
/** Serial Version. */
@SuppressWarnings({"AnalyzingVariableNaming"})
@@ -83,6 +79,9 @@
gbc.weighty = 1.0;
add(showSolutionPanel, gbc);
setSettings(settings);
+ setHelpURL(getClass().getClassLoader().getResource("help/FirstSettingsModule.html"));
+ setListLabelText("Dummy Auflösung");
+ setLabelText("Dummy Einstellungen zum Anzeigen der Auflösungen");
}
/** Returns the Settings.
@@ -108,26 +107,6 @@
}
/** {@inheritDoc} */
- public Component getSettingsPanel() {
- return this;
- }
-
- /** {@inheritDoc} */
- @Nullable public Icon getSettingsIcon() {
- return null; // TODO
- }
-
- /** {@inheritDoc} */
- public String getSettingsName() {
- return "Dummy Auflösung";
- }
-
- /** {@inheritDoc} */
- public String getSettingsTitle() {
- return "Dummy Einstellungen zum Anzeigen der Auflösungen";
- }
-
- /** {@inheritDoc} */
public String getSettingsId() {
return "displaySolution";
}
@@ -138,19 +117,18 @@
}
/** {@inheritDoc} */
- public void resetToDefaults() {
+ public void defaults() {
+ //To change body of implemented methods use File | Settings | File Templates.
// TODO
restore();
}
- /** {@inheritDoc} */
- public URL getHelpURL() {
- return getClass().getClassLoader().getResource("help/FirstSettingsModule.html");
+ public boolean isChanged() {
+ return false;//To change body of implemented methods use File | Settings | File Templates.
}
- /** {@inheritDoc} */
- public boolean isDefaults() {
- return false;
+ public void revert() {
+ //To change body of implemented methods use File | Settings | File Templates.
}
} // class FirstSettingsModule
Modified: progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/gui/GUIOptionsSettingsModule.java
===================================================================
--- progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/gui/GUIOptionsSettingsModule.java 2008-11-30 18:00:40 UTC (rev 727)
+++ progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/gui/GUIOptionsSettingsModule.java 2008-11-30 18:04:35 UTC (rev 728)
@@ -20,28 +20,24 @@
package net.sf.japi.progs.jeduca.jtest.gui;
-import java.awt.Component;
import java.awt.GridBagConstraints;
import static java.awt.GridBagConstraints.HORIZONTAL;
import static java.awt.GridBagConstraints.NORTHWEST;
import static java.awt.GridBagConstraints.REMAINDER;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
-import java.net.URL;
import static javax.swing.BorderFactory.createTitledBorder;
import javax.swing.ButtonGroup;
-import javax.swing.Icon;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import net.sf.japi.progs.jeduca.jtest.Settings;
-import net.sf.japi.progs.jeduca.swing.settings.SettingsModule;
-import org.jetbrains.annotations.Nullable;
+import net.sf.japi.swing.prefs.AbstractPrefs;
/** Settings module.
* @author $Author: chris $
* @version $Id: GUIOptionsSettingsModule.java,v 1.2 2006/01/31 23:09:18 chris Exp $
*/
-public class GUIOptionsSettingsModule extends JPanel implements SettingsModule {
+public class GUIOptionsSettingsModule extends AbstractPrefs {
/** Serial Version. */
@SuppressWarnings({"AnalyzingVariableNaming"})
@@ -76,6 +72,9 @@
gbc.weighty = 1.0;
add(askForQuitPanel, gbc);
setSettings(settings);
+ setHelpURL(getClass().getClassLoader().getResource("help/GUIOptionsSettingsModule.html")); // TODO localize this
+ setListLabelText("Dummy Auflösung2");
+ setLabelText("Dummy Einstellungen zum Anzeigen der Auflösungen");
}
/** Set the Settings Object to be attached.
@@ -93,26 +92,6 @@
}
/** {@inheritDoc} */
- public Component getSettingsPanel() {
- return this;
- }
-
- /** {@inheritDoc} */
- @Nullable public Icon getSettingsIcon() {
- return null; // TODO
- }
-
- /** {@inheritDoc} */
- public String getSettingsName() {
- return "Dummy Auflösung2";
- }
-
- /** {@inheritDoc} */
- public String getSettingsTitle() {
- return "Dummy Einstellungen zum Anzeigen der Auflösungen";
- }
-
- /** {@inheritDoc} */
public String getSettingsId() {
return "askForQuit";
}
@@ -123,19 +102,18 @@
}
/** {@inheritDoc} */
- public void resetToDefaults() {
+ public void defaults() {
+ //To change body of implemented methods use File | Settings | File Templates.
// TODO
restore();
}
- /** {@inheritDoc} */
- public URL getHelpURL() {
- return getClass().getClassLoader().getResource("help/GUIOptionsSettingsModule.html"); // localize this
+ public boolean isChanged() {
+ return false;//To change body of implemented methods use File | Settings | File Templates.
}
- /** {@inheritDoc} */
- public boolean isDefaults() {
- return false;
+ public void revert() {
+ //To change body of implemented methods use File | Settings | File Templates.
}
/** Returns the Settings.
Modified: progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/gui/ProgramFrame.java
===================================================================
--- progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/gui/ProgramFrame.java 2008-11-30 18:00:40 UTC (rev 727)
+++ progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/gui/ProgramFrame.java 2008-11-30 18:04:35 UTC (rev 728)
@@ -27,9 +27,6 @@
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.ResourceBundle;
import javax.swing.Action;
import javax.swing.JFileChooser;
import static javax.swing.JFileChooser.APPROVE_OPTION;
@@ -49,17 +46,18 @@
import net.sf.japi.progs.jeduca.swing.OpenURLPane;
import net.sf.japi.progs.jeduca.swing.ToolBarManager;
import net.sf.japi.progs.jeduca.swing.io.ImporterFileFilter;
-import net.sf.japi.progs.jeduca.swing.recent.RecentURLsMenu;
-import net.sf.japi.progs.jeduca.swing.settings.SettingsModule;
-import net.sf.japi.progs.jeduca.swing.settings.SettingsPane;
import net.sf.japi.swing.ActionBuilder;
import net.sf.japi.swing.ActionBuilderFactory;
-import net.sf.japi.swing.ComponentFactory;
+import net.sf.japi.swing.ActionMethod;
import net.sf.japi.swing.LookAndFeelManager;
import net.sf.japi.swing.ToolBarLayout;
import net.sf.japi.swing.about.AboutDialog;
+import net.sf.japi.swing.app.Document;
import net.sf.japi.swing.bookmarks.BookmarkManager;
import net.sf.japi.swing.bookmarks.Bookmarkable;
+import net.sf.japi.swing.prefs.PreferencesGroup;
+import net.sf.japi.swing.prefs.PreferencesPane;
+import net.sf.japi.swing.recent.RecentURLsMenu;
import org.jetbrains.annotations.NotNull;
/** Programmfenster.
@@ -74,9 +72,6 @@
/** Serial Version. */
private static final long serialVersionUID = 1L;
- /** The Resource bundle. */
- private static final ResourceBundle RES = ResourceBundle.getBundle("net.sf.japi.progs.jeduca.jtest.gui.action");
-
/** The Program this Frame displays. */
private transient Program program;
@@ -96,10 +91,10 @@
*/
private QuestionCollectionGUI questionCollectionGUI;
- /** The Settings modules.
+ /** The Preferences modules.
* @serial include
*/
- private List<SettingsModule> settingModules = new ArrayList<SettingsModule>();
+ private PreferencesGroup prefsGroup;
/** The URL of the current question collection.
* @serial include
@@ -118,8 +113,7 @@
/** Initialize GUI. */
private void initUI() {
setLayout(new ToolBarLayout());
- settingModules.add(new FirstSettingsModule(program.getSettings()));
- settingModules.add(new GUIOptionsSettingsModule(program.getSettings()));
+ prefsGroup = new PreferencesGroup("Dummy title", new FirstSettingsModule(program.getSettings()), new GUIOptionsSettingsModule(program.getSettings()));
fileChooser = new JFileChooser();
final JMenuBar menuBar = new JMenuBar();
final JMenu mView = new JMenu(view);
@@ -139,10 +133,11 @@
setTitle("JEduca");
add(questionCollectionGUI);
- final JToolBar menuToolBar = new JToolBar(RES.getString("menuToolBar.name")); menuToolBar.add(menuBar);
- //menuToolBar.putClientProperty(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(RES.getString("menuToolBar.accel"))); // FIXME #1
+ final JToolBar menuToolBar = new JToolBar(ACTION_BUILDER.getString("menuToolBar.name"));
+ menuToolBar.add(menuBar);
+ //menuToolBar.putClientProperty(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(ACTION_BUILDER.getString("menuToolBar.accel"))); // FIXME #1
final JToolBar bookmarkToolBar = bookmarkManager.createBookmarkToolBar();
- final JToolBar programToolBar = createProgramToolBar();
+ final JToolBar programToolBar = ACTION_BUILDER.createToolBar(this, "programToolBar");
final JToolBar navigationToolBar = questionCollectionGUI.createNavigationToolBar();
add(menuToolBar, NORTH);
add(programToolBar, NORTH);
@@ -189,6 +184,7 @@
}
/** Load Action. */
+ @ActionMethod
public void open() {
final String newUrl = OpenURLPane.showOpenURLDialog(this, fileChooser);
if (newUrl != null) {
@@ -221,58 +217,63 @@
}
/** {@inheritDoc} */
- public boolean load(@NotNull final String newUrl) {
+ // TODO Do not return null if loading was successful.
+ @NotNull
+ public Document<Object> load(@NotNull final String uri) {
boolean okay;
try {
// TODO: IOManager
// program.eduImport(url);
- program.load(newUrl);
+ program.load(uri);
questionCollectionGUI.setQuestionCollection(program.getQuestionCollection());
- setTitle("JEduca: " + program.getQuestionCollection().getTitle() + " (" + newUrl + ')');
- final String fragmentId = new URL(newUrl).getRef();
+ setTitle("JEduca: " + program.getQuestionCollection().getTitle() + " (" + uri + ')');
+ final String fragmentId = new URL(uri).getRef();
if (fragmentId != null && fragmentId.startsWith("question")) {
final String questionNumber = fragmentId.substring("question".length());
questionCollectionGUI.displayQuestion(Integer.parseInt(questionNumber));
}
okay = true;
- url = newUrl;
+ url = uri;
} catch (final Exception e) {
- JOptionPane.showMessageDialog(this, e, RES.getString("open.error.text") + ':', ERROR_MESSAGE);
+ JOptionPane.showMessageDialog(this, e, ACTION_BUILDER.getString("open.error.text") + ':', ERROR_MESSAGE);
System.err.println(e);
okay = false;
url = null;
}
bookmarkManager.setAddBookmarkEnabled(isBookmarkPossible());
- return okay;
+ return okay ? null : null;
}
/** Save Action. */
+ @ActionMethod
public void save() {
if (fileChooser.showSaveDialog(this) == APPROVE_OPTION) {
try {
program.eduExport(fileChooser.getSelectedFile());
// TOOD: JTest
} catch (IOException e) {
- JOptionPane.showMessageDialog(this, e, RES.getString("save.error.text") + ':', ERROR_MESSAGE);
+ JOptionPane.showMessageDialog(this, e, ACTION_BUILDER.getString("save.error.text") + ':', ERROR_MESSAGE);
System.err.println(e);
}
}
}
/** Print Action. */
+ @ActionMethod
public void print() {
// TODO
}
/** Prefs Action. */
+ @ActionMethod
public void config() {
- // TODO eventually change SettingsPane and its usage so a SettingsPane can't be displayed twice for the same application.
- SettingsPane.showSettingsDialog(this, "Dummy Title", settingModules);
+ PreferencesPane.showPreferencesDialog(this, prefsGroup, true);
}
/** Quit Action. */
+ @ActionMethod
public void quit() {
- if (JOptionPane.showConfirmDialog(this, RES.getString("quit.question"), RES.getString("quit.text"), YES_NO_OPTION) == YES_OPTION) {
+ if (JOptionPane.showConfirmDialog(this, ACTION_BUILDER.getString("quit.question"), ACTION_BUILDER.getString("quit.text"), YES_NO_OPTION) == YES_OPTION) {
dispose();
}
}
@@ -281,6 +282,7 @@
private final AboutDialog aboutDialog = new AboutDialog(ACTION_BUILDER);
/** About Action. */
+ @ActionMethod
public void about() {
aboutDialog.showAboutDialog(this);
}
@@ -335,13 +337,6 @@
*/
private Action about = ACTION_BUILDER.createAction(true, "about", this);
- /** Create Toolbar with essential program actions.
- * @return Toolbar with essential program actions
- */
- public JToolBar createProgramToolBar() {
- return ComponentFactory.createJToolBar(RES.getString("programToolBar.name"), open, save, print);
- }
-
/** Create Menu with essential program actions.
* @return Menu with essential program actions
*/
Modified: progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/gui/QuestionCollectionGUI.java
===================================================================
--- progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/gui/QuestionCollectionGUI.java 2008-11-30 18:00:40 UTC (rev 727)
+++ progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/gui/QuestionCollectionGUI.java 2008-11-30 18:04:35 UTC (rev 728)
@@ -36,7 +36,6 @@
import net.sf.japi.progs.jeduca.jtest.Settings;
import net.sf.japi.swing.ActionBuilder;
import net.sf.japi.swing.ActionBuilderFactory;
-import net.sf.japi.swing.ComponentFactory;
/** User Interface for a Collection of Questions.
* @author $Author: chris $
@@ -104,7 +103,7 @@
*/
private ReviewGUI reviewGUI;
- /** Wether currently showing a solution. */
+ /** Whether currently showing a solution. */
private transient boolean showingSolution;
/** The Settings.
@@ -118,16 +117,9 @@
public QuestionCollectionGUI(final Settings settings) {
this.settings = settings;
initUI();
+ updateButtonState();
}
- /** Create a GUI for a Collection of Questions.
- * @param col QuestionCollection to create GUI for
- */
- public QuestionCollectionGUI(final QuestionCollection col) {
- initUI();
- setQuestionCollection(col);
- }
-
/** Set the QuestionCollection to be displayed.
* @param col QuestionCollection to be displayed
*/
@@ -264,13 +256,19 @@
/** Update the state of the actions. */
public void updateButtonState() {
- first.setEnabled(index > 0);
- prev.setEnabled(index > 0 || showingSolution && index != -1);
- start.setEnabled(index == -1);
- next.setEnabled(index >= 0 && index < col.getSize() - 1);
- last.setEnabled(index >= 0 && index < col.getSize() - 1);
- review.setEnabled(index != -1);
- end.setEnabled(index != -1);
+ if (col == null) {
+ for (final Action action : navigationActions) {
+ action.setEnabled(false);
+ }
+ } else {
+ first.setEnabled(index > 0);
+ prev.setEnabled(index > 0 || showingSolution && index != -1);
+ start.setEnabled(index == -1);
+ next.setEnabled(index >= 0 && index < col.getSize() - 1);
+ last.setEnabled(index >= 0 && index < col.getSize() - 1);
+ review.setEnabled(index != -1);
+ end.setEnabled(index != -1);
+ }
}
/** Action for start test.
@@ -330,7 +328,7 @@
* @return Navigation Toolbar
*/
public JToolBar createNavigationToolBar() {
- return ComponentFactory.createJToolBar(res.getString("navigationToolBar.name"), navigationActions);
+ return ACTION_BUILDER.createToolBar(this, "navigationToolBar");
}
/** Get the index of the question currently being displayed.
Modified: progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/gui/action.properties
===================================================================
--- progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/gui/action.properties 2008-11-30 18:00:40 UTC (rev 727)
+++ progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/gui/action.properties 2008-11-30 18:04:35 UTC (rev 728)
@@ -74,7 +74,9 @@
menuToolBar.name=Menubar
menuToolBar.accel=ctrl pressed M
+programToolBar.toolbar=open save print
programToolBar.name=Program toolbar
+navigationToolBar.toolbar=start first prev next last review end
navigationToolBar.name=Navigation toolbar
menus.text=Menus
@@ -182,5 +184,5 @@
selectFile.icon=general/Open16
-about=<html><head><meta http-equiv='Content-Type' content='text/html'></meta><title>About</title></head><body><h1>About</h1><p>JEduca Version 1.0</p><p>\xA9 2004-2007 Chrsitian Hujer. All rights reserved.</p></body></html>
+about=<html><head><meta http-equiv='Content-Type' content='text/html'></meta><title>About</title></head><body><h1>About</h1><p>JEduca Version 1.0</p><p>\xA9 2004-2008 Chrsitian Hujer. All rights reserved.</p></body></html>
application.name=JEduca
Modified: progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/gui/action_de.properties
===================================================================
--- progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/gui/action_de.properties 2008-11-30 18:00:40 UTC (rev 727)
+++ progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/gui/action_de.properties 2008-11-30 18:04:35 UTC (rev 728)
@@ -181,5 +181,5 @@
delete.mnemonic=L
#selectFile.icon=
-about=<html><head><meta http-equiv='Content-Type' content='text/html'></meta><title>\xDCber</title></head><body><h1>\xDCber</h1><p>JEduca Version 1.0</p><p>\xA9 2004-2007 Chrsitian Hujer. Alle Rechte vorbehalten.</p></body></html>
+about=<html><head><meta http-equiv='Content-Type' content='text/html'></meta><title>\xDCber</title></head><body><h1>\xDCber</h1><p>JEduca Version 1.0</p><p>\xA9 2004-2008 Chrsitian Hujer. Alle Rechte vorbehalten.</p></body></html>
application.name=JEduca
Modified: progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/io/AbstractJTestImport.java
===================================================================
--- progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/io/AbstractJTestImport.java 2008-11-30 18:00:40 UTC (rev 727)
+++ progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/io/AbstractJTestImport.java 2008-11-30 18:04:35 UTC (rev 728)
@@ -20,14 +20,12 @@
package net.sf.japi.progs.jeduca.jtest.io;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.net.URLConnection;
import java.util.Map;
import java.util.WeakHashMap;
import net.sf.japi.progs.jeduca.swing.io.Importer;
+import net.sf.japi.progs.jeduca.swing.io.IOUtilities;
-/** Base implementation of JTestImport supplying an intelligent cache about wether a certain file can or cannot be loaded.
+/** Base implementation of JTestImport supplying an intelligent cache about whether or not a certain file can or cannot be loaded.
* Subclasses should implement {@link #canLoadImpl(String)} rather than implement {@link #canLoad(String)} directly because the interface method decorates
* the implementation with an intelligent caching mechanism.
* Subclasses cannot rely on {@link #canLoadImpl(String)} being invoked always, since if the stored information still is uptodate, calling the method
@@ -45,7 +43,7 @@
*/
private static class Uptodate {
- /** Wether the file can be loaded. */
+ /** Whether the file can be loaded. */
private boolean canLoad;
/** Timestamp of file. */
@@ -57,40 +55,22 @@
private Map<String, Uptodate> acceptable = new WeakHashMap<String, Uptodate>();
/** {@inheritDoc} */
- public final boolean canLoad(final String url) {
- Uptodate v = acceptable.get(url);
- if (v == null) { acceptable.put(url, v = new Uptodate()); }
- final long lastModified = lastMod(url);
+ public final boolean canLoad(final String uri) {
+ Uptodate v = acceptable.get(uri);
+ if (v == null) { acceptable.put(uri, v = new Uptodate()); }
+ final long lastModified = IOUtilities.lastMod(uri);
if (lastModified != v.lastModified) {
v.lastModified = lastModified;
- v.canLoad = canLoadImpl(url);
+ v.canLoad = canLoadImpl(uri);
}
return v.canLoad;
}
- /** Check wether a file can be loaded.
+ /** Check whether a file can be loaded.
* Subclasses must implement this method instead of {@link #canLoad(String)}
- * @param url URL to check wether it is loadable
+ * @param url URL to check whether it is loadable
* @return <code>true</code> if this import module supports loading a QuestionCollection from the supplied file, otherwise <code>false</code>
*/
protected abstract boolean canLoadImpl(final String url);
- /** Get the last modified value for a URL.
- * This method is a utility method provided for subclasses.
- * @param uri URL to get last modified value from
- * @return last modified value for <var>uri</var> or 0 if not found
- */
- protected static long lastMod(final String uri) {
- try {
- final URL url = new URL(uri);
- final URLConnection con = url.openConnection();
- if (con instanceof HttpURLConnection) {
- ((HttpURLConnection)con).setRequestMethod("HEAD");
- }
- return con.getLastModified();
- } catch (final Exception e) {
- return 0L;
- }
- }
-
} // class AbstractJTestImport
Modified: progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/io/JTestV1.java
===================================================================
--- progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/io/JTestV1.java 2008-11-30 18:00:40 UTC (rev 727)
+++ progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/io/JTestV1.java 2008-11-30 18:04:35 UTC (rev 728)
@@ -315,7 +315,7 @@
*/
private static class ErrorCapture implements ErrorHandler {
- /** Wether there were errors. */
+ /** Whether there were errors. */
private boolean errors;
/** Create a new ErrorCapture. */
@@ -335,7 +335,7 @@
errors = true;
}
- /** Get wether there were errors.
+ /** Get whether there were errors.
* @return errors
*/
public boolean hadErrors() {
Modified: progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/swing/AbstractManager.java
===================================================================
--- progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/swing/AbstractManager.java 2008-11-30 18:00:40 UTC (rev 727)
+++ progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/swing/AbstractManager.java 2008-11-30 18:04:35 UTC (rev 728)
@@ -20,14 +20,14 @@
package net.sf.japi.progs.jeduca.swing;
-import java.awt.Component;
+import java.awt.Component;import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Iterator;
-import java.util.List;
+import java.util.List;import java.util.Collection;
import javax.swing.AbstractAction;
import javax.swing.AbstractButton;
import javax.swing.Action;
@@ -80,7 +80,7 @@
protected List<SubAction<?>> actions = new ArrayList<SubAction<?>>();
/** The Menus created. */
- protected List<JMenu> cMenus = new ArrayList<JMenu>();
+ protected Collection<JMenu> cMenus = new ArrayList<JMenu>();
/** Action Builder. */
private static final ActionBuilder ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.japi.progs.jeduca.swing");
@@ -139,7 +139,7 @@
final Action action = findActionFor(comp);
final int index = actions.indexOf(action);
actions.remove(index);
- for (final JMenu mMenu : cMenus) {
+ for (final Container mMenu : cMenus) {
mMenu.remove(index);
}
}
@@ -148,7 +148,7 @@
* @param comp component to find Action for
* @return SubAction for the specified comp.
*/
- private SubAction<?> findActionFor(final T comp) {
+ private Action findActionFor(final T comp) {
for (final SubAction<?> action : actions) {
if (action.getComponent() == comp) {
return action;
@@ -292,7 +292,7 @@
/** Create a JCheckBoxMenuItem for this Action.
* @return JCheckBoxMenuItem for this Action.
*/
- JCheckBoxMenuItem createCheckBoxMenuItem() {
+ JMenuItem createCheckBoxMenuItem() {
final JCheckBoxMenuItem menuItem = new JCheckBoxMenuItem(this);
buttons.add(new WeakReference<AbstractButton>(menuItem));
menuItem.setSelected(comp.isVisible());
Deleted: progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/swing/ISwingUtilities.java
===================================================================
--- progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/swing/ISwingUtilities.java 2008-11-30 18:00:40 UTC (rev 727)
+++ progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/swing/ISwingUtilities.java 2008-11-30 18:04:35 UTC (rev 728)
@@ -1,54 +0,0 @@
-/* JAPI - (Yet another (hopefully) useful) Java API
- *
- * Copyright (C) 2004-2006 Christian Hujer
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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 net.sf.japi.progs.jeduca.swing;
-
-import java.awt.Component;
-import java.awt.Dialog;
-import java.awt.Frame;
-import java.awt.Window;
-import javax.swing.Action;
-import javax.swing.JButton;
-import javax.swing.JToolBar;
-
-/** JAPI Swing Utilities.
- */
-public class ISwingUtilities {
-
- /** Find the Window for a Component.
- * Searches for a Frame or a Dialog which is the parent component of the supplied argument.
- * Windows are treated like normal Components since in Java Windows can't stand for themselves but must have another Window as a parent.
- * So a real root ancestor can only be a Frame or a Dialog.
- * @param c Component to get Window for
- * @return Window for c, which is a Frame or a Dialog
- */
- public static Window getWindowForComponent(final Component c) {
- if (c == null) {
- return null;
- // TODO: implement handling of null
- // return getRootFrame();
- }
- if (c instanceof Frame || c instanceof Dialog) {
- return (Window) c;
- }
- return getWindowForComponent(c.getParent());
- }
-
-} // class ISwingUtilities
Modified: progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/swing/OpenURLPane.java
===================================================================
--- progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/swing/OpenURLPane.java 2008-11-30 18:00:40 UTC (rev 727)
+++ progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/swing/OpenURLPane.java 2008-11-30 18:04:35 UTC (rev 728)
@@ -206,7 +206,7 @@
/** Get the root frame to use if there is no owner frame.
* @return frame
*/
- private static Frame getRootFrame() {
+ private static synchronized Window getRootFrame() {
if (rootFrame == null) {
rootFrame = new JFrame();
}
Modified: progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/swing/io/AbstractCachingImporter.java
===================================================================
--- progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/swing/io/AbstractCachingImporter.java 2008-11-30 18:00:40 UTC (rev 727)
+++ progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/swing/io/AbstractCachingImporter.java 2008-11-30 18:04:35 UTC (rev 728)
@@ -20,13 +20,10 @@
package net.sf.japi.progs.jeduca.swing.io;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.net.URLConnection;
import java.util.Map;
import java.util.WeakHashMap;
-/** Base implementation of {@link Importer} supplying an intelligent cache about the information wether a certain file can or cannot be loaded.
+/** Base implementation of {@link Importer} supplying an intelligent cache about the information whether or not a certain file can be loaded.
* If you want to write your own implementation of {@link Importer}, this is a potential base class.
* Subclasses should implement {@link #canLoadImpl(String)} rather than implement {@link #canLoad(String)} directly because the interface method
* decorates the implementation with that intelligent caching mechanism.
@@ -43,7 +40,7 @@
*/
private static class Uptodate {
- /** Wether the file can be loaded. */
+ /** Whether the file can be loaded. */
boolean canLoad;
/** Timestamp of file. */
@@ -58,7 +55,7 @@
public final boolean canLoad(final String uri) {
Uptodate v = acceptable.get(uri);
if (v == null) { acceptable.put(uri, v = new Uptodate()); }
- final long lastModified = lastMod(uri);
+ final long lastModified = IOUtilities.lastMod(uri);
if (lastModified != v.lastModified) {
v.lastModified = lastModified;
v.canLoad = canLoadImpl(uri);
@@ -66,29 +63,11 @@
return v.canLoad;
}
- /** Check wether a file can be loaded.
+ /** Check whether a file can be loaded.
* Subclasses must implement this method instead of {@link #canLoad(String)}
- * @param url URL to check wether it is loadable
+ * @param url URL to check whether or not it is loadable
* @return <code>true</code> if this import module supports loading a QuestionCollection from the supplied file, otherwise <code>false</code>
*/
protected abstract boolean canLoadImpl(final String url);
- /** Get the last modified value for a URL.
- * This method is a utility method provided for subclasses.
- * @param uri URL to get last modified value from
- * @return last modified value for <var>uri</var> or 0 if not found
- */
- protected static long lastMod(final String uri) {
- try {
- final URL url = new URL(uri);
- final URLConnection con = url.openConnection();
- if (con instanceof HttpURLConnection) {
- ((HttpURLConnection)con).setRequestMethod("HEAD");
- }
- return con.getLastModified();
- } catch (final Exception e) {
- return 0L;
- }
- }
-
} // class AbstractCachingImport
Deleted: progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/swing/io/EndingFileFilter.java
===================================================================
--- progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/swing/io/EndingFileFilter.java 2008-11-30 18:00:40 UTC (rev 727)
+++ progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/swing/io/EndingFileFilter.java 2008-11-30 18:04:35 UTC (rev 728)
@@ -1,95 +0,0 @@
-/* JAPI - (Yet another (hopefully) useful) Java API
- *
- * Copyright (C) 2004-2006 Christian Hujer
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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 net.sf.japi.progs.jeduca.swing.io;
-
-import java.io.File;
-import javax.swing.filechooser.FileFilter;
-
-/** Swing FileFilter implementation that filters files with specified endings.
- * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
- * @todo find a convenient way for i18n/l10n of this class
- */
-public class EndingFileFilter extends FileFilter {
-
- /** Wether to accept directories. */
- private final boolean acceptDirectories;
-
- /** Wether to negate the endings. */
- private final boolean negate;
-
- /** The description text. */
- private String description;
-
- /** The fileendings to accept. */
- private final String[] endings;
-
- /** Create a DFileFilter.
- * <code>negate</code> is set to false on this file filter.
- * @param acceptDirectories pass <code>true</code> if this FileFilter should accept directories as well, <code>false</code> to deny directories
- * @param description The description to use for swing
- * @param endings The endings to accept
- */
- public EndingFileFilter(final boolean acceptDirectories, final String description, final String[] endings) {
- this(acceptDirectories, false, description, endings);
- }
-
- /** Create a DFileFilter.
- * @param acceptDirectories pass <code>true</code> if this FileFilter should accept directories as well, <code>false</code> to deny directories
- * @param negate pass <code>true</code> if the endings are to be negated, which means the filter will only accept files <em>not</em> ending on one
- * of the <var>endings</var>; usually you want to pass <code>false</code>
- * @param description The description to use for swing
- * @param endings The endings to accept
- */
- public EndingFileFilter(final boolean acceptDirectories, final boolean negate, final String description, final String[] endings) {
- this.acceptDirectories = acceptDirectories;
- this.negate = negate;
- this.description = description;
- this.endings = endings;
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean accept(final File f) {
- final String fileName = f.getName();
- boolean ret;
- if (negate) {
- ret = true;
- for (int i = 0, l = endings.length; ret && i < l; i++) {
- ret &= !fileName.endsWith(endings[i]);
- }
- ret |= acceptDirectories && f.isDirectory();
- } else {
- ret = acceptDirectories && f.isDirectory();
- for (int i = 0, l = endings.length; !ret && i < l; i++) {
- ret |= fileName.endsWith(endings[i]);
- }
- }
- return ret;
- }
-
- /** {@inheritDoc} */
- @Override
- public String getDescription() {
- return description;
- }
-
-} // class DFileFilter
Deleted: progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/swing/io/FilenameFileFilter.java
===================================================================
--- progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/swing/io/FilenameFileFilter.java 2008-11-30 18:00:40 UTC (rev 727)
+++ progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/swing/io/FilenameFileFilter.java 2008-11-30 18:04:35 UTC (rev 728)
@@ -1,94 +0,0 @@
-/* JAPI - (Yet another (hopefully) useful) Java API
- *
- * Copyright (C) 2004-2006 Christian Hujer
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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 net.sf.japi.progs.jeduca.swing.io;
-
-import java.io.File;
-import javax.swing.filechooser.FileFilter;
-
-/** Swing FileFilter implementation that filters files with specified names.
- * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
- * @todo find a convenient way for i18n/l10n of this class
- */
-public class FilenameFileFilter extends FileFilter {
-
- /** Wether to accept directories. */
- private final boolean acceptDirectories;
-
- /** Wether to negate the names. */
- private final boolean negate;
-
- /** The description text. */
- private String description;
-
- /** The filenames to accept. */
- private final String[] names;
-
- /** Create a DFileFilter.
- * <code>negate</code> is set to false on this file filter.
- * @param acceptDirectories pass <code>true</code> if this FileFilter should accept directories as well, <code>false</code> to deny directories
- * @param description The description to use for swing
- * @param names The names to accept
- */
- public FilenameFileFilter(final boolean acceptDirectories, final String description, final String[] names) {
- this(acceptDirectories, false, description, names);
- }
-
- /** Create a DFileFilter.
- * @param acceptDirectories pass <code>true</code> if this FileFilter should accept directories as well, <code>false</code> to deny directories
- * @param negate pass <code>true</code> if the names are to be negated, which means the filter will only accept files <em>not</em> names on one
- * of the <var>names</var>; usually you want to pass <code>false</code>
- * @param description The description to use for swing
- * @param names The names to accept
- */
- public FilenameFileFilter(final boolean acceptDirectories, final boolean negate, final String description, final String[] names) {
- this.acceptDirectories = acceptDirectories;
- this.negate = negate;
- this.description = description;
- this.names = names;
- }
-
- /** {@inheritDoc} */
- public boolean accept(final File f) {
- final String fileName = f.getName();
- boolean ret;
- if (negate) {
- ret = true;
- for (int i = 0, l = names.length; ret && i < l; i++) {
- ret &= !fileName.equals(names[i]);
- }
- ret |= acceptDirectories && f.isDirectory();
- } else {
- ret = acceptDirectories && f.isDirectory();
- for (int i = 0, l = names.length; !ret && i < l; i++) {
- ret |= fileName.equals(names[i]);
- }
- }
- return ret;
- }
-
- /** {@inheritDoc} */
- @Override
- public String getDescription() {
- return description;
- }
-
-} // class DFileFilter
Modified: progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/swing/io/IOModuleProvider.java
===================================================================
--- progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/swing/io/IOModuleProvider.java 2008-11-30 18:00:40 UTC (rev 727)
+++ progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/swing/io/IOModuleProvider.java 2008-11-30 18:04:35 UTC (rev 728)
@@ -151,9 +151,9 @@
}
/** {@inheritDoc} */
- public boolean canLoad(final String url) {
+ public boolean canLoad(final String uri) {
for (final Importer<T> module : importers) {
- if (module.canLoad(url)) {
+ if (module.canLoad(uri)) {
return true;
}
}
@@ -162,7 +162,7 @@
/** {@inheritDoc} */
public String getName() {
- return "Alle unterstützten Dateitypen";
+ return "Alle unterstützten Dateitypen"; // TODO i18n/l10n
}
/** {@inheritDoc} */
Added: progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/swing/io/IOUtilities.java
===================================================================
--- progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/swing/io/IOUtilities.java (rev 0)
+++ progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/swing/io/IOUtilities.java 2008-11-30 18:04:35 UTC (rev 728)
@@ -0,0 +1,31 @@
+package net.sf.japi.progs.jeduca.swing.io;
+
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.HttpURLConnection;
+import java.io.IOException;
+
+/**
+ * TODO
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+public class IOUtilities {
+
+ /** Get the last modified value for a URL.
+ * This method is a utility method provided for subclasses.
+ * @param uri URL to get last modified value from
+ * @return last modified value for <var>uri</var> or 0 if not found
+ */
+ public static long lastMod(final String uri) {
+ try {
+ final URL url = new URL(uri);
+ final URLConnection con = url.openConnection();
+ if (con instanceof HttpURLConnection) {
+ ((HttpURLConnection)con).setRequestMethod("HEAD");
+ }
+ return con.getLastModified();
+ } catch (final IOException e) {
+ return 0L;
+ }
+ }
+}
Property changes on: progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/swing/io/IOUtilities.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ LF
Modified: progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/swing/io/Importer.java
===================================================================
--- progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/swing/io/Importer.java 2008-11-30 18:00:40 UTC (rev 727)
+++ progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/swing/io/Importer.java 2008-11-30 18:04:35 UTC (rev 728)
@@ -28,13 +28,13 @@
*/
public interface Importer<T> extends IOBase<T> {
- /** Check wether a file can be loaded.
+ /** Check whether a file can be loaded.
* It is recommended to invoke this method mainly for file:/ and other local URL schemes to keep network traffic and user response time low.
* Also it is recommended that implementations use caching mechanisms.
- * @param url URL to load
+ * @param uri URL to load
* @return <code>true</code> if this Import instance is able to load the supplied url (file type is okay), otherwise <code>false</code>
*/
- boolean canLoad(String url);
+ boolean canLoad(String uri);
/** Load a Document from a URL.
* @param url URL to load
Modified: progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/util/MimeData.java
===================================================================
--- progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/util/MimeData.java 2008-11-30 18:00:40 UTC (rev 727)
+++ progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/util/MimeData.java 2008-11-30 18:04:35 UTC (rev 728)
@@ -23,6 +23,7 @@
/** Interface for classes that represent MIME Information like MIME Data.
* This interface makes no assumption about the mutability of its implementations.
* Implementations may or may not be mutable.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
public interface MimeData {
Modified: progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/util/StringToTextComparatorAdapter.java
===================================================================
--- progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/util/StringToTextComparatorAdapter.java 2008-11-30 18:00:40 UTC (rev 727)
+++ progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/util/StringToTextComparatorAdapter.java 2008-11-30 18:04:35 UTC (rev 728)
@@ -21,22 +21,25 @@
package net.sf.japi.progs.jeduca.util;
import java.util.Comparator;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
/** An adapter to be able to use String comparators for Text objects.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
public class StringToTextComparatorAdapter implements Comparator<Text> {
/** Mime Comparator. */
- private Comparator<String> mime;
+ @Nullable private final Comparator<String> mime;
/** String Comparator. */
- private Comparator<String> comp;
+ @NotNull private final Comparator<String> comp;
/** Create a <code>Comparator<Text></code> from a <code>Comparator<String></code>.
* @param mime <code>Comparator<String></code> to create from, used for the Mime Type (may be <code>null</code>)
* @param comp <code>Comparator<String></code> to create from, used for the text
*/
- public StringToTextComparatorAdapter(final Comparator<String> mime, final Comparator<String> comp) {
+ public StringToTextComparatorAdapter(@Nullable final Comparator<String> mime, @NotNull final Comparator<String> comp) {
this.mime = mime;
this.comp = comp;
}
@@ -45,7 +48,7 @@
* @param comp <code>Comparator<String></code> to create from, used for the text
*/
public StringToTextComparatorAdapter(final Comparator<String> comp) {
- this.comp = comp;
+ this(null, comp);
}
/** {@inheritDoc} */
@@ -61,8 +64,7 @@
}
/** {@inheritDoc} */
- @Override
- public boolean equals(final Object obj) {
+ @Override public boolean equals(final Object obj) {
if ((obj == null) || !(obj instanceof StringToTextComparatorAdapter)) {
return false;
}
@@ -71,8 +73,7 @@
}
/** {@inheritDoc} */
- @Override
- public int hashCode() {
+ @Override public int hashCode() {
int hc = 0;
if (mime != null) {
hc ^= mime.hashCode();
Modified: progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/util/Text.java
===================================================================
--- progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/util/Text.java 2008-11-30 18:00:40 UTC (rev 727)
+++ progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/util/Text.java 2008-11-30 18:04:35 UTC (rev 728)
@@ -21,6 +21,8 @@
package net.sf.japi.progs.jeduca.util;
import java.io.Serializable;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
/** Class for holding some text information of an arbitrary mime type.
* Mutable.
@@ -28,6 +30,7 @@
* Just a little String container.
* For convenience, this method implements some interfaces, especially <code>CharSequence</code>.
* Mutability is only possible by <code>String</code> exchange.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
public class Text implements Serializable, Comparable<Text>, CharSequence, MimeData {
@@ -35,16 +38,14 @@
private static final long serialVersionUID = 1L;
/** The Text.
- * not <code>null</code>.
* @serial include
*/
- private String text;
+ @NotNull private String text;
/** The MIME Type.
- * not <code>null</code>
* @serial include
*/
- private String type;
+ @NotNull private String type;
/** Create an empty text.
* The text is the empty String, the type is <code>text/plain</code>.
@@ -59,7 +60,7 @@
* @param type MIME Type
* @throws NullPointerException in case text or type is null
*/
- public Text(final String text, final String type) {
+ public Text(@NotNull final String text, @NotNull final String type) {
setText(text);
setType(type);
}
@@ -67,26 +68,32 @@
/** Get the Text.
* @return text
*/
- public String getText() {
+ @NotNull public String getText() {
return text;
}
/** Set the Text.
* @param text new text
*/
- public void setText(final String text) {
- if (text == null) { throw new NullPointerException("text for Text may not be null"); }
+ public void setText(@NotNull final String text) {
+ //noinspection ConstantConditions
+ if (text == null) {
+ throw new NullPointerException("text for Text may not be null");
+ }
this.text = text;
}
/** {@inheritDoc} */
- public String getType() {
+ @NotNull public String getType() {
return type;
}
/** {@inheritDoc} */
- public void setType(final String type) {
- if (ty...
[truncated message content] |