Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

2.0.0 update 10

  • Loading branch information...
commit 787e016c1ce570d5e6d5e6520eae7e6e441582db 1 parent d2c414b
@anarchivist authored
View
46 src/org/archiviststoolkit/ApplicationFrame.java
@@ -120,6 +120,11 @@
public static String URL_DOWNLOAD = "http://www.archiviststoolkit.org/atDistribution/install.shtml";
public static SimpleDateFormat applicationDateFormat = new SimpleDateFormat(Constants.DEFAULT_DATE_FORMAT);
+ // This specifies whether to enable the spell check function
+ // and highlighting. The default is to have it enable
+ public static boolean enableSpellCheck = true;
+ public static boolean enableSpellCheckHighlight = true;
+
private MyTimer timer;
private String startupLog;
@@ -177,6 +182,12 @@
private ConcreteAction admin_RDE = null;
private ConcreteAction admin_RDE_DO = null;
private ConcreteAction admin_Font = null;
+ private ConcreteAction admin_Spellcheck = null;
+ private ConcreteAction admin_SpellcheckHiglight = null;
+
+ // add the global checkbox menu item
+ private JCheckBoxMenuItem spellCheckMenuItem = null; // this needs to be global v
+ private JCheckBoxMenuItem spellCheckHighlightMenuItem = null; // this needs to be global v
/**
* The tools menu action.
@@ -226,7 +237,7 @@
private Hashtable<Class, DomainTableWorkSurface> worksurfaces = new Hashtable<Class, DomainTableWorkSurface>();
- private ApplicationFrame() {
+ private ApplicationFrame() {
super();
atVersionNumber = resourceBundle.getString("archiviststoolkit.releasenumber");
String releaseType = resourceBundle.getString("archiviststoolkit.releaseType");
@@ -506,6 +517,9 @@ public void makeActions() {
admin_Font = new ConcreteAction("Configure Font");
admin_Font.addActionListener(this);
+ admin_Spellcheck = new ConcreteAction("Enable");
+ admin_SpellcheckHiglight = new ConcreteAction("Highlight");
+
assessmentAction = new ConcreteAction("Assessment Records");
assessmentAction.addActionListener(this);
}
@@ -650,6 +664,22 @@ private JMenuBar makeMenuBar() {
// add the menu to configure system font
setupMenu.add(admin_Font);
+ // add the submenu to enable or disable the spell check function
+ JMenu spellCheckMenu = new JMenu("Spell Check");
+
+ spellCheckMenuItem = new JCheckBoxMenuItem(admin_Spellcheck);
+ spellCheckMenuItem.setSelected(enableSpellCheck);
+ admin_Spellcheck.addActionListener(this);
+ spellCheckMenu.add(spellCheckMenuItem);
+
+ spellCheckHighlightMenuItem = new JCheckBoxMenuItem(admin_SpellcheckHiglight);
+ spellCheckHighlightMenuItem.setSelected(enableSpellCheckHighlight);
+ spellCheckHighlightMenuItem.setEnabled(enableSpellCheck);
+ admin_SpellcheckHiglight.addActionListener(this);
+ spellCheckMenu.add(spellCheckHighlightMenuItem);
+
+ setupMenu.add(spellCheckMenu);
+
menuBar.add(setupMenu);
JMenu reportMenu = new JMenu("Reports");
@@ -1011,6 +1041,20 @@ public void run() {
SwingUtilities.updateComponentTreeUI(this);
}
+ } else if (actionEvent.getSource() == this.admin_Spellcheck || actionEvent.getSource() == this.admin_SpellcheckHiglight) {
+ // get the user preferences and save the state check spell enable
+ UserPreferences userPref = UserPreferences.getInstance();
+ userPref.setEnableSpellCheck(spellCheckMenuItem.isSelected());
+ userPref.setEnableSpellCheckHighlight(spellCheckHighlightMenuItem.isSelected());
+ userPref.saveToPreferences();
+
+ // see whether to disable the highlighting check box
+ if(!spellCheckMenuItem.isSelected()) {
+ spellCheckHighlightMenuItem.setEnabled(false);
+ } else {
+ spellCheckHighlightMenuItem.setEnabled(true);
+ }
+
} else if (actionEvent.getSource() == this.import_Subject) {
ATFileChooser filechooser = new ATFileChooser();
filechooser.setSize(600, 400);
View
107 src/org/archiviststoolkit/Main.java
@@ -21,11 +21,14 @@
// Import Declarations
//==============================================================================
+import com.inet.jortho.FileUserDictionary;
+import com.inet.jortho.SpellChecker;
import org.archiviststoolkit.dialog.ErrorDialog;
import org.archiviststoolkit.dialog.SplashScreen;
import org.archiviststoolkit.hibernate.SessionFactory;
import org.archiviststoolkit.model.*;
import org.archiviststoolkit.mydomain.*;
+import org.archiviststoolkit.plugin.ATPlugin;
import org.archiviststoolkit.structure.ATFieldInfo;
import org.archiviststoolkit.structure.DefaultValues;
import org.archiviststoolkit.util.*;
@@ -41,6 +44,8 @@
import javax.swing.plaf.FontUIResource;
import javax.swing.text.JTextComponent;
import javax.swing.text.DefaultEditorKit;
+import java.io.File;
+import java.net.URL;
import java.util.Date;
import java.util.ResourceBundle;
import java.sql.*;
@@ -106,6 +111,13 @@ public static void main(final String[] args) {
UserPreferences userPrefs = UserPreferences.getInstance();
userPrefs.populateFromPreferences();
+ // set the directory containing the dictionary files if
+ // spell check is enable
+ if(userPrefs.getEnableSpellCheck()) {
+ mainFrame.enableSpellCheck = loadSpellCheckerDictionary();
+ mainFrame.enableSpellCheckHighlight = userPrefs.getEnableSpellCheckHighlighting();
+ }
+
// set properties of UI components including fonts
UIDefaults uiDefaults = UIManager.getDefaults();
uiDefaults.put("TextArea.background", Color.white);
@@ -193,6 +205,10 @@ public static void main(final String[] args) {
System.exit(1);
}
+ // load any plugins that are found here
+ fSplashScreen.setMessageText("Loading plugins");
+ org.archiviststoolkit.plugin.ATPluginFactory.getInstance().parsePluginDirectory();
+
fSplashScreen.setMessageText("User logon");
if (skipLogon) {
Users currentUser = new Users();
@@ -202,7 +218,7 @@ public static void main(final String[] args) {
ApplicationFrame.getInstance().setCurrentUser(currentUser);
} else {
try {
- ApplicationFrame.getInstance().setCurrentUser(diaplayLoginAndRetrunUser(userPrefs));
+ ApplicationFrame.getInstance().setCurrentUser(displayLoginAndReturnUser(userPrefs));
} catch (UnsupportedDatabaseType unsupportedDatabaseType) {
new ErrorDialog("Error connecting to database", unsupportedDatabaseType).showDialog();
}
@@ -259,10 +275,6 @@ public static void main(final String[] args) {
fSplashScreen.setMessageText("Loading Reports");
ReportFactory.getInstance().ParseReportDirectory();
- // load any plugins that are found here
- fSplashScreen.setMessageText("Loading plugins");
- org.archiviststoolkit.plugin.ATPluginFactory.getInstance().parsePluginDirectory();
-
mainFrame.finishStartupLog(fSplashScreen);
mainFrame.initializeMainFrame(fSplashScreen);
logger.log(Level.INFO, "\nApplication Startup times\n" + ApplicationFrame.getInstance().getStartupLog());
@@ -299,19 +311,34 @@ private static void showPreferences(UserPreferences userPrefs) {
}
}
- private static Users diaplayLoginAndRetrunUser(UserPreferences userPrefs) throws UnsupportedDatabaseType {
+ private static Users displayLoginAndReturnUser(UserPreferences userPrefs) throws UnsupportedDatabaseType {
LoginDialog login = new LoginDialog(fSplashScreen);
boolean tryAgain = true;
Users user;
- int returnStatus;
+ // try loading any authentication plugin. this plugin would do authentication
+ // through LDPA for example
+ ATPlugin authPlugin = org.archiviststoolkit.plugin.ATPluginFactory.getInstance().getAuthenticationPlugin();
+
+ int returnStatus;
do {
returnStatus = login.showDialog();
if (returnStatus == JOptionPane.CANCEL_OPTION) {
System.exit(1);
} else if (returnStatus == JOptionPane.OK_OPTION) {
- user = Users.lookupUser(login.getUserName(), login.getPassword());
+ user = Users.lookupUser(login.getUserName(), login.getPassword());
+
+ // if an authentication plugin is being used the attempt to login
+ // through it if a valid user was not already returned from the database
+ if(authPlugin != null && user == null) {
+ String[] params = {login.getUserName(), login.getPasswordAsText()};
+
+ if(authPlugin.doTask("authenticate", params)) {
+ user = Users.lookupUser(login.getUserName());
+ }
+ }
+
if (user != null) {
tryAgain = false;
return user;
@@ -339,7 +366,7 @@ private static void shutdown() {
System.out.println("shutdown");
}
- private static class MyShutdownHook extends Thread {
+ private static class MyShutdownHook extends Thread {
public void run() {
shutdown();
}
@@ -405,7 +432,7 @@ private static void connectAndTest(UserPreferences userPrefs) throws Unsupported
// if (updateToNewVersion) {
// //make sure they are a superuser
// JOptionPane.showMessageDialog(fSplashScreen, "You must be a superuser to do this.");
-// Users user = diaplayLoginAndRetrunUser(userPrefs);
+// Users user = displayLoginAndReturnUser(userPrefs);
// if (user.getAccessClass() == Users.ACCESS_CLASS_SUPERUSER) {
// if (!Constants.updateOrCreateVersionRecord(versionString)) {
// System.exit(1);
@@ -502,4 +529,64 @@ public void run() {
}, "Record Lock Updater Thread");
performer.start();
}
+
+ /**
+ * Static method to load the spell checker dictionaries
+ * The spell checker use the JOrtho library
+ * http://jortho.sourceforge.net/
+ *
+ * @return boolean indicating whether the dictionary was loaded correctly
+ */
+ private static boolean loadSpellCheckerDictionary() {
+ File ATDirectory = new File (".");
+ try {
+ // check to see if the dictionary base directory exists
+ File dictionaryBase = new File(ATDirectory, "conf/dictionary/");
+
+ if(dictionaryBase.exists()) {
+ // create the directory which holds the user entries for the dictionaries
+ File userDictionaryDirectory = getUserDictionaryDirectory();
+ if(userDictionaryDirectory != null) {
+ FileUserDictionary userDictionary =
+ new FileUserDictionary(userDictionaryDirectory.getAbsolutePath());
+
+ SpellChecker.setUserDictionaryProvider(userDictionary);
+ }
+
+ URL dictionaryURL = new URL("file", null, dictionaryBase.getCanonicalPath() + "/");
+ SpellChecker.registerDictionaries(dictionaryURL, "en,de,es,fr,it", "");
+ SpellChecker.getOptions().setCaseSensitive(false);
+
+ return true;
+ } else {
+ return false;
+ }
+ } catch(Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ /**
+ * Method to create the directory to store user defined words for the
+ * dictionary if the directory doesn't exist. If it does then it just returns
+ * the directory
+ */
+ private static File getUserDictionaryDirectory() {
+ String directoryName = System.getProperty("user.home") + System.getProperty("file.separator") + "at_dictionary";
+
+ // see if to create the database directory
+ File directory = new File(directoryName);
+
+ try {
+ // attempt to make the directory where user dictionary files
+ if(!directory.exists()) {
+ directory.mkdir();
+ }
+
+ return directory;
+ } catch (Exception e) {
+ return null;
+ }
+ }
}
View
13 src/org/archiviststoolkit/dialog/QueryEditorBooleanPanel.java
@@ -1,5 +1,5 @@
/**
- * Archivists' Toolkit(TM) Copyright © 2005-2007 Regents of the University of California, New York University, & Five Colleges, Inc.
+ * Archivists' Toolkit(TM) Copyright 2005-2007 Regents of the University of California, New York University, & Five Colleges, Inc.
* All rights reserved.
*
* This software is free. You can redistribute it and / or modify it under the terms of the Educational Community License (ECL)
@@ -23,6 +23,7 @@
import com.jgoodies.forms.factories.*;
import com.jgoodies.forms.layout.*;
import org.hibernate.criterion.Criterion;
+import org.hibernate.criterion.Disjunction;
import org.hibernate.criterion.Expression;
import org.archiviststoolkit.hibernate.ATSearchCriterion;
@@ -90,7 +91,15 @@ public ATSearchCriterion getQueryCriterion(Class clazz, String field) {
criteria = Expression.eq(field, true);
humanReadableSearchString += "true";
} else {
- criteria = Expression.eq(field, false);
+ // a lot of the fields are set null and user expects them to be
+ // false then consider false as null or or actually false
+ Disjunction disjunction = Expression.disjunction();
+ disjunction.add(Expression.eq(field, false));
+ disjunction.add(Expression.isNull(field));
+
+ criteria = disjunction;
+ //criteria = Expression.eq(field, false);
+
humanReadableSearchString += "false";
}
View
118 src/org/archiviststoolkit/dialog/UserPreferencesDialog.java
@@ -222,26 +222,26 @@ private void initComponents() {
HeaderPanel.setOpaque(false);
HeaderPanel.setFont(new Font("Trebuchet MS", Font.PLAIN, 13));
HeaderPanel.setLayout(new FormLayout(
- new ColumnSpec[]{
- new ColumnSpec(Sizes.bounded(Sizes.MINIMUM, Sizes.dluX(100), Sizes.dluX(200))),
- new ColumnSpec(ColumnSpec.FILL, Sizes.DEFAULT, FormSpec.DEFAULT_GROW)
- },
- RowSpec.decodeSpecs("default")));
+ new ColumnSpec[] {
+ new ColumnSpec(Sizes.bounded(Sizes.MINIMUM, Sizes.dluX(100), Sizes.dluX(200))),
+ new ColumnSpec(ColumnSpec.FILL, Sizes.DEFAULT, FormSpec.DEFAULT_GROW)
+ },
+ RowSpec.decodeSpecs("default")));
//======== panel2 ========
{
panel2.setBackground(new Color(80, 69, 57));
panel2.setFont(new Font("Trebuchet MS", Font.PLAIN, 13));
panel2.setLayout(new FormLayout(
- new ColumnSpec[]{
- FormFactory.RELATED_GAP_COLSPEC,
- new ColumnSpec(ColumnSpec.FILL, Sizes.DEFAULT, FormSpec.DEFAULT_GROW)
- },
- new RowSpec[]{
- FormFactory.RELATED_GAP_ROWSPEC,
- FormFactory.DEFAULT_ROWSPEC,
- FormFactory.RELATED_GAP_ROWSPEC
- }));
+ new ColumnSpec[] {
+ FormFactory.RELATED_GAP_COLSPEC,
+ new ColumnSpec(ColumnSpec.FILL, Sizes.DEFAULT, FormSpec.DEFAULT_GROW)
+ },
+ new RowSpec[] {
+ FormFactory.RELATED_GAP_ROWSPEC,
+ FormFactory.DEFAULT_ROWSPEC,
+ FormFactory.RELATED_GAP_ROWSPEC
+ }));
//---- mainHeaderLabel ----
mainHeaderLabel.setText("Administration");
@@ -256,15 +256,15 @@ private void initComponents() {
panel3.setBackground(new Color(66, 60, 111));
panel3.setFont(new Font("Trebuchet MS", Font.PLAIN, 13));
panel3.setLayout(new FormLayout(
- new ColumnSpec[]{
- FormFactory.RELATED_GAP_COLSPEC,
- new ColumnSpec(ColumnSpec.FILL, Sizes.DEFAULT, FormSpec.DEFAULT_GROW)
- },
- new RowSpec[]{
- FormFactory.RELATED_GAP_ROWSPEC,
- FormFactory.DEFAULT_ROWSPEC,
- FormFactory.RELATED_GAP_ROWSPEC
- }));
+ new ColumnSpec[] {
+ FormFactory.RELATED_GAP_COLSPEC,
+ new ColumnSpec(ColumnSpec.FILL, Sizes.DEFAULT, FormSpec.DEFAULT_GROW)
+ },
+ new RowSpec[] {
+ FormFactory.RELATED_GAP_ROWSPEC,
+ FormFactory.DEFAULT_ROWSPEC,
+ FormFactory.RELATED_GAP_ROWSPEC
+ }));
//---- subHeaderLabel ----
subHeaderLabel.setText("Connection Settings");
@@ -281,36 +281,36 @@ private void initComponents() {
panel1.setOpaque(false);
panel1.setBorder(Borders.DIALOG_BORDER);
panel1.setLayout(new FormLayout(
- ColumnSpec.decodeSpecs("max(default;400px):grow"),
- new RowSpec[]{
- FormFactory.DEFAULT_ROWSPEC,
- FormFactory.LINE_GAP_ROWSPEC,
- FormFactory.DEFAULT_ROWSPEC
- }));
+ ColumnSpec.decodeSpecs("max(default;400px):grow"),
+ new RowSpec[] {
+ FormFactory.DEFAULT_ROWSPEC,
+ FormFactory.LINE_GAP_ROWSPEC,
+ FormFactory.DEFAULT_ROWSPEC
+ }));
//======== contentPanel ========
{
contentPanel.setBorder(new TitledBorder(null, "Database Properties", TitledBorder.LEADING, TitledBorder.TOP));
contentPanel.setOpaque(false);
contentPanel.setLayout(new FormLayout(
- new ColumnSpec[]{
- new ColumnSpec(ColumnSpec.FILL, Sizes.MINIMUM, 0.1),
- FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
- new ColumnSpec(ColumnSpec.FILL, Sizes.DEFAULT, FormSpec.DEFAULT_GROW)
- },
- new RowSpec[]{
- FormFactory.DEFAULT_ROWSPEC,
- FormFactory.LINE_GAP_ROWSPEC,
- FormFactory.DEFAULT_ROWSPEC,
- FormFactory.LINE_GAP_ROWSPEC,
- FormFactory.DEFAULT_ROWSPEC,
- FormFactory.LINE_GAP_ROWSPEC,
- FormFactory.DEFAULT_ROWSPEC
- }));
+ new ColumnSpec[] {
+ new ColumnSpec(ColumnSpec.FILL, Sizes.MINIMUM, 0.1),
+ FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
+ new ColumnSpec(ColumnSpec.FILL, Sizes.DEFAULT, FormSpec.DEFAULT_GROW)
+ },
+ new RowSpec[] {
+ FormFactory.DEFAULT_ROWSPEC,
+ FormFactory.LINE_GAP_ROWSPEC,
+ FormFactory.DEFAULT_ROWSPEC,
+ FormFactory.LINE_GAP_ROWSPEC,
+ FormFactory.DEFAULT_ROWSPEC,
+ FormFactory.LINE_GAP_ROWSPEC,
+ FormFactory.DEFAULT_ROWSPEC
+ }));
//---- label1 ----
label1.setText("Connection URL");
- contentPanel.add(label1, new CellConstraints(1, 1, 1, 1, CellConstraints.FILL, CellConstraints.DEFAULT, new Insets(0, 5, 0, 0)));
+ contentPanel.add(label1, new CellConstraints(1, 1, 1, 1, CellConstraints.FILL, CellConstraints.DEFAULT, new Insets( 0, 5, 0, 0)));
//---- connectionUrl ----
connectionUrl.setEditable(true);
@@ -319,21 +319,21 @@ public void itemStateChanged(ItemEvent e) {
updateConnectionUrlInformation();
}
});
- contentPanel.add(connectionUrl, new CellConstraints(3, 1, 1, 1, CellConstraints.DEFAULT, CellConstraints.DEFAULT, new Insets(0, 5, 0, 0)));
+ contentPanel.add(connectionUrl, new CellConstraints(3, 1, 1, 1, CellConstraints.DEFAULT, CellConstraints.DEFAULT, new Insets( 0, 5, 0, 0)));
//---- label2 ----
label2.setText("Username");
- contentPanel.add(label2, new CellConstraints(1, 3, 1, 1, CellConstraints.DEFAULT, CellConstraints.DEFAULT, new Insets(0, 5, 0, 0)));
- contentPanel.add(userName, new CellConstraints(3, 3, 1, 1, CellConstraints.DEFAULT, CellConstraints.DEFAULT, new Insets(0, 5, 0, 0)));
+ contentPanel.add(label2, new CellConstraints(1, 3, 1, 1, CellConstraints.DEFAULT, CellConstraints.DEFAULT, new Insets( 0, 5, 0, 0)));
+ contentPanel.add(userName, new CellConstraints(3, 3, 1, 1, CellConstraints.DEFAULT, CellConstraints.DEFAULT, new Insets( 0, 5, 0, 0)));
//---- label3 ----
label3.setText("Password");
- contentPanel.add(label3, new CellConstraints(1, 5, 1, 1, CellConstraints.DEFAULT, CellConstraints.DEFAULT, new Insets(0, 5, 0, 0)));
- contentPanel.add(password, new CellConstraints(3, 5, 1, 1, CellConstraints.DEFAULT, CellConstraints.DEFAULT, new Insets(0, 5, 0, 0)));
+ contentPanel.add(label3, new CellConstraints(1, 5, 1, 1, CellConstraints.DEFAULT, CellConstraints.DEFAULT, new Insets( 0, 5, 0, 0)));
+ contentPanel.add(password, new CellConstraints(3, 5, 1, 1, CellConstraints.DEFAULT, CellConstraints.DEFAULT, new Insets( 0, 5, 0, 0)));
//---- label4 ----
label4.setText("Database Type");
- contentPanel.add(label4, new CellConstraints(1, 7, 1, 1, CellConstraints.DEFAULT, CellConstraints.DEFAULT, new Insets(0, 5, 0, 0)));
+ contentPanel.add(label4, new CellConstraints(1, 7, 1, 1, CellConstraints.DEFAULT, CellConstraints.DEFAULT, new Insets( 0, 5, 0, 0)));
//---- databaseTypes ----
databaseTypes.setOpaque(false);
@@ -352,15 +352,15 @@ public void actionPerformed(ActionEvent e) {
buttonBar.setBackground(new Color(231, 188, 251));
buttonBar.setOpaque(false);
buttonBar.setLayout(new FormLayout(
- new ColumnSpec[]{
- FormFactory.GLUE_COLSPEC,
- FormFactory.DEFAULT_COLSPEC,
- FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
- FormFactory.BUTTON_COLSPEC,
- FormFactory.RELATED_GAP_COLSPEC,
- FormFactory.BUTTON_COLSPEC
- },
- RowSpec.decodeSpecs("pref")));
+ new ColumnSpec[] {
+ FormFactory.GLUE_COLSPEC,
+ FormFactory.DEFAULT_COLSPEC,
+ FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
+ FormFactory.BUTTON_COLSPEC,
+ FormFactory.RELATED_GAP_COLSPEC,
+ FormFactory.BUTTON_COLSPEC
+ },
+ RowSpec.decodeSpecs("pref")));
//---- saveButton ----
saveButton.setText("Save");
View
11 src/org/archiviststoolkit/exporter/MARCExport.java
@@ -999,8 +999,11 @@ private void setControlField(ObjectFactory obj, RecordType record,
else
controlFieldString.append(" ");
+ boolean aggregateResource = true; // specify if resource record is aggregated or not
+
if (resource.getLevel().equalsIgnoreCase("item")) {
controlFieldString.append("s");
+ aggregateResource = false;
} else
controlFieldString.append("i");
@@ -1009,7 +1012,7 @@ private void setControlField(ObjectFactory obj, RecordType record,
else
controlFieldString.append(" ");
- if (resource.getDateEnd() != null)
+ if (resource.getDateEnd() != null && (aggregateResource || !resource.getDateEnd().equals(resource.getDateBegin())))
controlFieldString.append(resource.getDateEnd());
else
controlFieldString.append(" ");
@@ -1106,9 +1109,11 @@ private void setControlFieldD(ObjectFactory obj, RecordType record,
else
controlFieldString.append(" ");
-
+ boolean aggregateResource = true; // specify if resource record is aggregated or not
+
if (dig.getDigitalInstance() != null && dig.getDigitalInstance().getResource()!=null && dig.getDigitalInstance().getResource().getLevel().equalsIgnoreCase("item")) {
controlFieldString.append("s");
+ aggregateResource = false;
} else
controlFieldString.append("i");
@@ -1117,7 +1122,7 @@ private void setControlFieldD(ObjectFactory obj, RecordType record,
else
controlFieldString.append(" ");
- if (dig.getDateEnd() != null)
+ if (dig.getDateEnd() != null && (aggregateResource || !dig.getDateEnd().equals(dig.getDateBegin())))
controlFieldString.append(dig.getDateEnd());
else
controlFieldString.append(" ");
View
10 src/org/archiviststoolkit/model/ArchDescriptionAnalogInstances.java
@@ -50,6 +50,10 @@
public static final String PROPERTYNAME_USER_DEFINED_STRING1 = "userDefinedString1";
public static final String PROPERTYNAME_USER_DEFINED_STRING2 = "userDefinedString2";
+ // Variable to match an alpha-numeric indicator which could be converted
+ // into a number i.e. 1d, 1.03D, or 1.0f etc ...
+ private static final String ALPHA_NUMERIC_REGEXP = "\\d+\\.*\\d*\\D+";
+
@StringLengthValidationRequried
@IncludeInApplicationConfiguration
private String container1Indicator = "";
@@ -354,7 +358,7 @@ public void setContainer1Indicator(String indicator) {
try {
// check to see if it is not a number with D on the end, which is a valid
// double value, but the user may actually want a D at the end of a number
- if(indicator.matches("\\d+\\.*\\d+[dD]")) {
+ if(indicator.matches(ALPHA_NUMERIC_REGEXP)) {
this.container1AlphaNumericIndicator = indicator;
this.container1NumericIndicator = null;
} else {
@@ -402,7 +406,7 @@ public void setContainer2Indicator(String indicator) {
try {
// check to see if it is not a number with D on the end, which is a valid
// double value, but the user may actually want a D at the end of a number
- if(indicator.matches("\\d+\\.*\\d+[dD]")) {
+ if(indicator.matches(ALPHA_NUMERIC_REGEXP)) {
this.container2AlphaNumericIndicator = indicator;
this.container2NumericIndicator = null;
} else {
@@ -450,7 +454,7 @@ public void setContainer3Indicator(String indicator) {
try {
// check to see if it is not a number with D on the end, which is a valid
// double value, but the user may actually want a D at the end of a number
- if(indicator.matches("\\d+\\.*\\d+[dD]")) {
+ if(indicator.matches(ALPHA_NUMERIC_REGEXP)) {
this.container3AlphaNumericIndicator = indicator;
this.container3NumericIndicator = null;
} else {
View
18 src/org/archiviststoolkit/model/ResourcesCommon.java
@@ -157,11 +157,19 @@ public ArchDescriptionInstances getInstance(int index) {
public Set getInstances(Class clazz) {
Set set = new HashSet();
- for (ArchDescriptionInstances instance : this.getInstances()) {
- if (clazz.getName().equals(instance.getClass().getName()))
- set.add(instance);
- }
- return set;
+
+ // put this code in a try block as a work around for
+ // This JIRA issue (https://jira.nyu.edu/jira/browse/ART-2359)
+ try {
+ for (ArchDescriptionInstances instance : this.getInstances()) {
+ if (clazz.getName().equals(instance.getClass().getName()))
+ set.add(instance);
+ }
+ } catch(NullPointerException ne) {
+ ne.printStackTrace();
+ }
+
+ return set;
}
public void setInstances(Set<ArchDescriptionInstances> instances) {
View
26 src/org/archiviststoolkit/model/Users.java
@@ -253,13 +253,37 @@ public static boolean doesUserHaveAccess(Users user, Integer level) {
}
}
+ public static Users lookupUser(String userName) {
+ return lookupUser(userName, null, false);
+ }
+
public static Users lookupUser(String userName, byte[] password) {
+ return lookupUser(userName, password, true);
+ }
+
+ /**
+ * Method to return a user object from the database.
+ * If use passPassword is true the the password is compared
+ * if false then it's not. Setting this to false is useful
+ * when a authentication plugin is used.
+ *
+ * @param userName
+ * @param password
+ * @param usePassword
+ * @return
+ */
+ public static Users lookupUser(String userName, byte[] password, boolean usePassword) {
Session session = SessionFactory.getInstance().openSession();
Criteria crit;
Collection collection;
+
crit = session.createCriteria(Users.class);
crit.add(Expression.eq("userName", userName));
- crit.add(Expression.eq("password", password));
+
+ if(usePassword) {
+ crit.add(Expression.eq("password", password));
+ }
+
collection = crit.list();
if (collection.size() == 1) {
return (Users) collection.iterator().next();
View
10 src/org/archiviststoolkit/mydomain/DomainEditorFields.java
@@ -104,8 +104,14 @@ public void convertComboBoxToNonEnterableTextField(JComboBox comboBox, String fi
parent.add(textField, cellConstraints);
}
- public void setBean(Object newBean) {
- detailsModel.setBean(newBean);
+ public void setBean(final Object newBean) {
+ // call this in the swing dispatch thread to prevent any
+ // locking problems when using the spell checker highlighter
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ detailsModel.setBean(newBean);
+ }
+ });
}
/**
View
37 src/org/archiviststoolkit/mydomain/DomainTableWorkSurface.java
@@ -74,6 +74,10 @@
private boolean done;
+ // boolean to say when a record is being open. This is to prevent a bug
+ // ART-2331 "Illegal access to loading collection" from occurring
+ private boolean recordOpening = false;
+
/**
* Variable to see if to display the confirm dialog that comes up on save button press
*/
@@ -706,8 +710,17 @@ public void run() {
public final void onUpdate() {
selectedRow = this.getTable().getSelectedRow();
+
+ // check to see if the record is currently being
+ // opened. A bug will be thrown if we try an open the record twice
+ if(recordOpening) {
+ return;
+ }
+
if (selectedRow != -1) {
- try {
+ recordOpening = true;
+
+ try {
access = DomainAccessObjectFactory.getInstance().getDomainAccessObject(clazz);
DomainObject domainObject = table.getFilteredList().get(selectedRow);
@@ -719,6 +732,7 @@ public final void onUpdate() {
Thread backgroundWorker = new Thread(runnable);
backgroundWorker.start();
} catch (PersistenceException e) {
+ recordOpening = false;
new ErrorDialog(dialog, "Error updating record", e).showDialog();
}
} else {
@@ -1515,15 +1529,15 @@ public DomainObject getCurrentDomainObjectFromDatabase() {
class LookupWorkerRunnable implements Runnable {
private DomainObject domainObject;
+ private InfiniteProgressPanel monitor;
LookupWorkerRunnable(DomainObject domainObject) {
this.domainObject = domainObject;
}
public void run() {
-
- InfiniteProgressPanel monitor = ATProgressUtil.createModalProgressMonitor(ApplicationFrame.getInstance(), 1000);
- monitor.start("Loading Record...");
+ final InfiniteProgressPanel monitor = ATProgressUtil.createModalProgressMonitor(ApplicationFrame.getInstance(), 1000);
+ monitor.start("Loading Record ...");
// see if to load a plugin editor instead of using the one built into the AT
if(usePluginDomainEditor(monitor, domainObject)) {
@@ -1550,19 +1564,28 @@ public void run() {
System.out.println("Total: " + MyTimer.toString(ApplicationFrame.getInstance().getTimer().elapsedTimeMillis()) + "\n");
}
monitor.close();
+ recordOpening = false;
} catch (UnsupportedTableModelException e) {
monitor.close();
+ recordOpening = false;
new ErrorDialog("", e).showDialog();
} catch (LookupException e) {
monitor.close();
+ recordOpening = false;
new ErrorDialog("", e).showDialog();
} finally {
// to ensure that progress dlg is closed in case of any exception
monitor.close();
+ recordOpening = false;
}
- finishOnUpdate();
- //dialog.setModel(currentDomainObject, monitor);
- //dialog.setRecordPositionText(selectedRow, table.getFilteredList().size());
+
+ // launch the GUI through the event dispatch thread to prevent
+ // any thread blocking when using the spell checker
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ finishOnUpdate();
+ }
+ });
}
}
View
6 src/org/archiviststoolkit/mydomain/ResourcesComponentsDAO.java
@@ -1,5 +1,5 @@
/**
- * Archivists' Toolkit(TM) Copyright © 2005-2007 Regents of the University of California, New York University, & Five Colleges, Inc.
+ * Archivists' Toolkit(TM) Copyright 2005-2007 Regents of the University of California, New York University, & Five Colleges, Inc.
* All rights reserved.
*
* This software is free. You can redistribute it and / or modify it under the terms of the Educational Community License (ECL)
@@ -153,10 +153,10 @@ public void deleteComponent(ResourcesComponents component, Session session) {
}
}
- // now delete the resource component
- session.delete(component);
for (ResourcesComponents child: component.getResourcesComponents()) {
deleteComponent(child, session);
}
+ // now delete the resource component
+ session.delete(component);
}
}
View
14 src/org/archiviststoolkit/plugin/ATPlugin.java
@@ -56,6 +56,9 @@
// plugin will be used with the command line interface of the AT. This functionality will require additional code
final String CLI_CATEGORY = "cli";
+ // plugin will be used for user authentication using an external authentication system
+ final String AUTHENTICATION_CATEGORY = "authentication";
+
/*
The list of editor types. They can be combined to specify a plugin that
supports viewing and editing multiple type of records. For example, a
@@ -204,6 +207,17 @@
public void doTask(String task);
/**
+ * Method to do a specific task which takes a list of parameters
+ * in a string array and returns a boolean indicating the
+ * status of the task
+ *
+ * @param task The task to do
+ * @param taskParams The parameters
+ * @return boolean indicating the status of the task
+ */
+ public boolean doTask(String task, String[] taskParams);
+
+ /**
* Method to get the list of specific task the plugin can perform.
* This task are displayed in submenus under either the import or
* plugin menu.
View
31 src/org/archiviststoolkit/plugin/ATPluginFactory.java
@@ -449,6 +449,37 @@ private ATPlugin getATPlugin(DomainObject domainObject, String category) {
}
/**
+ * Method to return any authentication plugins found
+ *
+ * @return The authentication plugin that was found
+ */
+ public ATPlugin getAuthenticationPlugin() {
+ ATPlugin foundPlugin = null;
+
+ try {
+ Iterator it = pluginManager.getRegistry().getPluginDescriptors().iterator();
+
+ while (it.hasNext()) {
+ PluginDescriptor pluginDescriptor = (PluginDescriptor) it.next();
+ String id = pluginDescriptor.getId();
+ ATPlugin plugin = (org.archiviststoolkit.plugin.ATPlugin) pluginManager.getPlugin(id);
+
+ String cat = plugin.getCategory();
+
+ // check to make sure that the plugin is of the right category
+ if (cat.indexOf(ATPlugin.AUTHENTICATION_CATEGORY) != -1) {
+ foundPlugin = plugin;
+ break;
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ return foundPlugin;
+ }
+
+ /**
* Method to return the editor type based on the domain object
*
* @param domainObject The domain object to find the editor type for
View
2  src/org/archiviststoolkit/resources/messages/messages.properties
@@ -1,5 +1,5 @@
archiviststoolkit.releasenumber=2.0.0
-archiviststoolkit.releaseupdate=9
+archiviststoolkit.releaseupdate=10
archiviststoolkit.releaseType=production
##archiviststoolkit.releaseType=update 1
archiviststoolkit.application.title=Archivists' Toolkit
View
16 src/org/archiviststoolkit/swing/ATBasicComponentFactory.java
@@ -20,6 +20,7 @@
package org.archiviststoolkit.swing;
+import com.inet.jortho.SpellChecker;
import com.jgoodies.binding.formatter.EmptyNumberFormatter;
import com.jgoodies.binding.formatter.EmptyDateFormatter;
import com.jgoodies.binding.PresentationModel;
@@ -423,7 +424,20 @@ public static JTextArea createUnboundedTextArea() {
private static JTextArea fixTabBehavior(JTextArea textArea) {
textArea.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, null);
textArea.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, null);
- return textArea;
+
+ // add support for spell checking here
+ // using Jortho spell checker library
+ if(ApplicationFrame.enableSpellCheck) {
+ try {
+ SpellChecker.register(textArea);
+ SpellChecker.enableAutoSpell(textArea, ApplicationFrame.enableSpellCheckHighlight);
+ } catch(Exception e) {
+ // just print the stack trace and do nothing
+ e.printStackTrace();
+ }
+ }
+
+ return textArea;
}
public static JTextField createTextField(ValueModel valueModel) {
View
5 src/org/archiviststoolkit/swing/LoginDialog.java
@@ -193,6 +193,11 @@ public String getUserName() {
return returnPassword;
}
+ public String getPasswordAsText() {
+ String password = new String(passwordField.getPassword());
+ return password;
+ }
+
public final int showDialog() {
//send to logger
View
84 src/org/archiviststoolkit/util/UserPreferences.java
@@ -40,6 +40,17 @@
public static final String FONT_FAMILY = "fontFamily";
public static final String FONT_STYLE = "fontStyle";
public static final String FONT_SIZE = "fontSize";
+ public static final String SPELLCHECK_ENABLE = "spellCheckEnable";
+ public static final String SPELLCHECK_HIGHLIGHT_ENABLE = "spellCheckHighlightEnable";
+
+ private String databaseUrl = "";
+ private String databaseUserName = "";
+ private String databasePassword = "";
+ private String savePath = "";
+ private String databaseType = "";
+ private Font font = null;
+ private boolean enableSpellCheck = false;
+ private boolean enableSpellCheckHighlight = true;
private static UserPreferences singleton = null;
@@ -54,13 +65,6 @@ public static UserPreferences getInstance() {
return singleton;
}
- private String databaseUrl = "";
- private String databaseUserName = "";
- private String databasePassword = "";
- private String savePath = "";
- private String databaseType = "";
- private Font font = null;
-
public String getDatabaseUrl() {
return databaseUrl;
}
@@ -81,6 +85,21 @@ public void populateFromPreferences() {
if(StringHelper.isNotEmpty(fontFamily.trim())) {
font = new Font(fontFamily, fontStyle, fontSize);
}
+
+ // set the spell check options
+ String spellCheck = userPrefs.get(SPELLCHECK_ENABLE, "");
+ if(spellCheck.equals("yes")) {
+ enableSpellCheck = true;
+ } else {
+ enableSpellCheck = false;
+ }
+
+ String spellCheckHighlight = userPrefs.get(SPELLCHECK_HIGHLIGHT_ENABLE, "");
+ if(spellCheckHighlight.equals("yes")) {
+ enableSpellCheckHighlight = true;
+ } else {
+ enableSpellCheckHighlight = false;
+ }
}
public void saveToPreferences() {
@@ -98,6 +117,19 @@ public void saveToPreferences() {
userPrefs.put(FONT_SIZE,"" + font.getSize());
}
+ // save the enable spell check option
+ if(enableSpellCheck) {
+ userPrefs.put(SPELLCHECK_ENABLE, "yes");
+ } else {
+ userPrefs.put(SPELLCHECK_ENABLE, "no");
+ }
+
+ if(enableSpellCheckHighlight) {
+ userPrefs.put(SPELLCHECK_HIGHLIGHT_ENABLE, "yes");
+ } else {
+ userPrefs.put(SPELLCHECK_HIGHLIGHT_ENABLE, "no");
+ }
+
try {
userPrefs.flush();
} catch (BackingStoreException e) {
@@ -205,4 +237,42 @@ public Font getFont() {
public void setFont(Font font) {
this.font = font;
}
+
+ /**
+ * Method use to specify whether to use the experimental spell check
+ * function
+ *
+ * @param enableSpellCheck
+ */
+ public void setEnableSpellCheck(boolean enableSpellCheck) {
+ this.enableSpellCheck = enableSpellCheck;
+ }
+
+ /**
+ * Method to get the boolean which indicates if spel checker is being used
+ *
+ * @return The enable spell check variable
+ */
+ public boolean getEnableSpellCheck() {
+ return enableSpellCheck;
+ }
+
+ /**
+ * Method to enable spell check highlighting
+ *
+ * @param enableSpellCheckHighlight
+ */
+ public void setEnableSpellCheckHighlight(boolean enableSpellCheckHighlight) {
+ this.enableSpellCheckHighlight = enableSpellCheckHighlight;
+ }
+
+ /**
+ * Method to return boolean that states whether to enable spellcheck
+ * highlighting
+ *
+ * @return boolean to specify whether to enable highlighting
+ */
+ public boolean getEnableSpellCheckHighlighting() {
+ return enableSpellCheckHighlight;
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.