diff --git a/src/de/danielluedecke/zettelkasten/CAutoKorrekturEdit.java b/src/de/danielluedecke/zettelkasten/CAutoKorrekturEdit.java
index d918b47e..6189dfa6 100644
--- a/src/de/danielluedecke/zettelkasten/CAutoKorrekturEdit.java
+++ b/src/de/danielluedecke/zettelkasten/CAutoKorrekturEdit.java
@@ -30,7 +30,6 @@
* Sie sollten ein Exemplar der GNU General Public License zusammen mit diesem Programm
* erhalten haben. Falls nicht, siehe .
*/
-
package de.danielluedecke.zettelkasten;
import de.danielluedecke.zettelkasten.database.Settings;
@@ -57,7 +56,7 @@
/**
*
- * @author danielludecke
+ * @author danielludecke
*/
public class CAutoKorrekturEdit extends javax.swing.JDialog {
@@ -66,7 +65,7 @@ public class CAutoKorrekturEdit extends javax.swing.JDialog {
*/
private final AutoKorrektur autoKorrekt;
/**
- *
+ *
*/
private final Settings settingsObj;
/**
@@ -80,16 +79,15 @@ public class CAutoKorrekturEdit extends javax.swing.JDialog {
/**
* get the strings for file descriptions from the resource map
*/
- private final org.jdesktop.application.ResourceMap resourceMap =
- org.jdesktop.application.Application.getInstance(de.danielluedecke.zettelkasten.ZettelkastenApp.class).
- getContext().getResourceMap(CAutoKorrekturEdit.class);
+ private final org.jdesktop.application.ResourceMap resourceMap
+ = org.jdesktop.application.Application.getInstance(de.danielluedecke.zettelkasten.ZettelkastenApp.class).
+ getContext().getResourceMap(CAutoKorrekturEdit.class);
-
/**
- *
+ *
* @param parent
* @param ac
- * @param st
+ * @param st
*/
public CAutoKorrekturEdit(java.awt.Frame parent, AutoKorrektur ac, Settings st) {
super(parent);
@@ -99,13 +97,12 @@ public CAutoKorrekturEdit(java.awt.Frame parent, AutoKorrektur ac, Settings st)
initTheRest(null);
}
-
/**
- *
+ *
* @param parent
* @param ac
* @param st
- * @param wrongspelling
+ * @param wrongspelling
*/
public CAutoKorrekturEdit(java.awt.Frame parent, AutoKorrektur ac, Settings st, String wrongspelling) {
super(parent);
@@ -115,7 +112,6 @@ public CAutoKorrekturEdit(java.awt.Frame parent, AutoKorrektur ac, Settings st,
initTheRest(wrongspelling);
}
-
private void initTheRest(String initvalue) {
/*
* Constructor for Matte Border
@@ -140,11 +136,11 @@ public void actionPerformed(ActionEvent evt) {
// get the default fontsize for tables and lists
int defaultsize = settingsObj.getTableFontSize();
// only set new fonts, when fontsize differs from the initial value
- if (defaultsize>0) {
+ if (defaultsize > 0) {
// get current font
Font f = jTableAutoKorrektur.getFont();
// create new font, add fontsize-value
- f = new Font(f.getName(), f.getStyle(), f.getSize()+defaultsize);
+ f = new Font(f.getName(), f.getStyle(), f.getSize() + defaultsize);
// set new font
jTableAutoKorrektur.setFont(f);
}
@@ -152,7 +148,7 @@ public void actionPerformed(ActionEvent evt) {
jTableAutoKorrektur.setAutoCreateRowSorter(true);
jTableAutoKorrektur.setGridColor(settingsObj.getTableGridColor());
// make extra table-sorter for itunes-tables
- if (settingsObj.isMacStyle()) {
+ if (settingsObj.isMacAqua()) {
TableUtils.SortDelegate sortDelegate = new TableUtils.SortDelegate() {
@Override
public void sort(int columnModelIndex, TableUtils.SortDirection sortDirection) {
@@ -164,21 +160,23 @@ public void sort(int columnModelIndex, TableUtils.SortDirection sortDirection) {
jTableAutoKorrektur.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
}
// init the table, i.e. fill it with all existing data
- tm = (DefaultTableModel)jTableAutoKorrektur.getModel();
+ tm = (DefaultTableModel) jTableAutoKorrektur.getModel();
tm.setRowCount(0);
// add all spellchecking-entries to linked list
- for (int cnt=0; cnt=tm.getRowCount()) row--;
+ if (row >= tm.getRowCount()) {
+ row--;
+ }
// select new cell
jTableAutoKorrektur.setColumnSelectionInterval(col, col);
jTableAutoKorrektur.setRowSelectionInterval(row, row);
@@ -218,15 +222,14 @@ public void sort(int columnModelIndex, TableUtils.SortDirection sortDirection) {
jButtonApply.setEnabled(true);
}
};
- jTableAutoKorrektur.getActionMap().put("DeleteKeyPressed",a_delete);
+ jTableAutoKorrektur.getActionMap().put("DeleteKeyPressed", a_delete);
// check for os, and use appropriate controlKey
- KeyStroke ks = KeyStroke.getKeyStroke((System.getProperty("os.name").toLowerCase().startsWith("mac os"))?"meta BACK_SPACE":"ctrl DELETE");
+ KeyStroke ks = KeyStroke.getKeyStroke((System.getProperty("os.name").toLowerCase().startsWith("mac os")) ? "meta BACK_SPACE" : "ctrl DELETE");
jTableAutoKorrektur.getInputMap().put(ks, "DeleteKeyPressed");
// disable reordering of columns
jTableAutoKorrektur.getTableHeader().setReorderingAllowed(false);
}
-
@Action
public void cancel() {
modified = false;
@@ -239,43 +242,43 @@ public void applyChanges() {
// clear all synonyms
autoKorrekt.clear();
// retrieve all table rows
- for (int row=0; row.
*/
-
package de.danielluedecke.zettelkasten;
import de.danielluedecke.zettelkasten.database.Settings;
@@ -46,11 +45,12 @@
import java.util.Set;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
-import javax.swing.KeyStroke;import org.jdesktop.application.Action;
+import javax.swing.KeyStroke;
+import org.jdesktop.application.Action;
/**
*
- * @author danielludecke
+ * @author danielludecke
*/
public class CBiggerEditField extends javax.swing.JDialog {
@@ -65,13 +65,14 @@ public class CBiggerEditField extends javax.swing.JDialog {
/**
* Create a new bigger input dialog for editing new authors etc.
- *
+ *
* @param parent the parent window
* @param settings a reference to the settings class
* @param title the dialog's title
* @param val a default value which should be set to the textfield
- * @param textfieldval an optional value that should be set to the bibkey-textfield. Usually only used
- * when a new author is added / edited and the bibkey is set or changed
+ * @param textfieldval an optional value that should be set to the
+ * bibkey-textfield. Usually only used when a new author is added / edited
+ * and the bibkey is set or changed
* @param edittype indicates which kind of data is being edited.
*/
public CBiggerEditField(java.awt.Frame parent, Settings settings, String title, String val, String textfieldval, int edittype) {
@@ -89,12 +90,12 @@ public CBiggerEditField(java.awt.Frame parent, Settings settings, String title,
}
// bind our new forward focus traversal keys
Set newForwardKeys = new HashSet<>(1);
- newForwardKeys.add(AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_TAB,0));
- jTextAreaBigEdit.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,Collections.unmodifiableSet(newForwardKeys));
+ newForwardKeys.add(AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_TAB, 0));
+ jTextAreaBigEdit.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, Collections.unmodifiableSet(newForwardKeys));
// bind our new backward focus traversal keys
Set newBackwardKeys = new HashSet<>(1);
- newBackwardKeys.add(AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_TAB,KeyEvent.SHIFT_MASK+KeyEvent.SHIFT_DOWN_MASK));
- jTextAreaBigEdit.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS,Collections.unmodifiableSet(newBackwardKeys));
+ newBackwardKeys.add(AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_TAB, KeyEvent.SHIFT_MASK + KeyEvent.SHIFT_DOWN_MASK));
+ jTextAreaBigEdit.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, Collections.unmodifiableSet(newBackwardKeys));
// these codelines add an escape-listener to the dialog. so, when the user
// presses the escape-key, the same action is performed as if the user
// presses the cancel button...
@@ -107,21 +108,20 @@ public void actionPerformed(ActionEvent evt) {
};
getRootPane().registerKeyboardAction(cancelAction, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
// reset return value
- newValue=null;
- newBibKey=null;
+ newValue = null;
+ newBibKey = null;
// set dialog's title
setTitle(title);
// fill textarea with default value
- if (val!=null) {
+ if (val != null) {
jTextAreaBigEdit.setText(val);
}
switch (edittype) {
case Constants.EDIT_AUTHOR:
jPanel1.setVisible(true);
- if (textfieldval !=null) {
+ if (textfieldval != null) {
jTextFieldBibKey.setText(textfieldval);
- }
- else {
+ } else {
jTextFieldBibKey.setText("");
}
break;
@@ -130,7 +130,7 @@ public void actionPerformed(ActionEvent evt) {
jTextFieldBibKey.setText("");
break;
}
-
+
}
private void initBorders(Settings settingsObj) {
@@ -140,7 +140,7 @@ private void initBorders(Settings settingsObj) {
*/
jScrollPane1.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, ColorUtil.getBorderGray(settingsObj)));
}
-
+
@Action
public void okButton() {
// get the text and leave the dialog
@@ -149,24 +149,24 @@ public void okButton() {
setVisible(false);
dispose();
}
-
+
@Action
public void cancelButton() {
// reset the value and leave dialog
- newValue=null;
- newBibKey=null;
+ newValue = null;
+ newBibKey = null;
setVisible(false);
dispose();
}
-
-
+
/**
- *
- * @return
+ *
+ * @return
*/
public String getNewValue() {
return newValue;
}
+
public String getNewBibKey() {
return newBibKey;
}
diff --git a/src/de/danielluedecke/zettelkasten/CDesktopDisplayItems.java b/src/de/danielluedecke/zettelkasten/CDesktopDisplayItems.java
index e85bbbf1..94d0add6 100644
--- a/src/de/danielluedecke/zettelkasten/CDesktopDisplayItems.java
+++ b/src/de/danielluedecke/zettelkasten/CDesktopDisplayItems.java
@@ -30,8 +30,6 @@
* Sie sollten ein Exemplar der GNU General Public License zusammen mit diesem Programm
* erhalten haben. Falls nicht, siehe .
*/
-
-
package de.danielluedecke.zettelkasten;
import de.danielluedecke.zettelkasten.database.Settings;
@@ -45,17 +43,19 @@
/**
*
- * @author danielludecke
+ * @author danielludecke
*/
public class CDesktopDisplayItems extends javax.swing.JDialog {
/**
- * return value for the main window so we know whether we have to update the display
+ * return value for the main window so we know whether we have to update the
+ * display
*/
private boolean needsupdate = false;
+
/**
- *
- * @return
+ *
+ * @return
*/
public boolean isNeedsUpdate() {
return needsupdate;
@@ -64,9 +64,10 @@ public boolean isNeedsUpdate() {
*
*/
private boolean savesettingok = true;
+
/**
- *
- * @return
+ *
+ * @return
*/
public boolean isSaveSettingsOk() {
return savesettingok;
@@ -75,18 +76,19 @@ public boolean isSaveSettingsOk() {
* Reference to the settings class
*/
private final Settings settingsObj;
-
+
/**
- * wm,
+ * wm,
+ *
* @param parent
- * @param s
+ * @param s
*/
public CDesktopDisplayItems(java.awt.Frame parent, Settings s) {
super(parent);
initComponents();
// set application icon
setIconImage(Constants.zknicon.getImage());
-
+
settingsObj = s;
if (settingsObj.isSeaGlass()) {
jButtonApply.putClientProperty("JComponent.sizeVariant", "small");
@@ -102,30 +104,38 @@ public void actionPerformed(ActionEvent evt) {
cancelWindow();
}
};
- getRootPane().registerKeyboardAction(cancelAction, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
-
+ getRootPane().registerKeyboardAction(cancelAction, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
+
// init option-checkboxes
int items = settingsObj.getDesktopDisplayItems();
- jCheckBoxRemarks.setSelected((items&Constants.DESKTOP_SHOW_REMARKS)!=0);
- jCheckBoxAuthors.setSelected((items&Constants.DESKTOP_SHOW_AUTHORS)!=0);
- jCheckBoxAttachments.setSelected((items&Constants.DESKTOP_SHOW_ATTACHMENTS)!=0);
- jCheckBoxKeywords.setSelected((items&Constants.DESKTOP_SHOW_KEYWORDS)!=0);
+ jCheckBoxRemarks.setSelected((items & Constants.DESKTOP_SHOW_REMARKS) != 0);
+ jCheckBoxAuthors.setSelected((items & Constants.DESKTOP_SHOW_AUTHORS) != 0);
+ jCheckBoxAttachments.setSelected((items & Constants.DESKTOP_SHOW_ATTACHMENTS) != 0);
+ jCheckBoxKeywords.setSelected((items & Constants.DESKTOP_SHOW_KEYWORDS) != 0);
}
-
/**
- * Finally, when the user presses the apply-button, all settings are saved. this is done
- * in this method. when all changes have been saved, the window will be closed and disposed.
+ * Finally, when the user presses the apply-button, all settings are saved.
+ * this is done in this method. when all changes have been saved, the window
+ * will be closed and disposed.
*/
@Action(enabledProperty = "modified")
public void applyChanges() {
// reset indicator
int items = 0;
// check which items should be displayed
- if (jCheckBoxRemarks.isSelected()) items = items | Constants.DESKTOP_SHOW_REMARKS;
- if (jCheckBoxAuthors.isSelected()) items = items | Constants.DESKTOP_SHOW_AUTHORS;
- if (jCheckBoxAttachments.isSelected()) items = items | Constants.DESKTOP_SHOW_ATTACHMENTS;
- if (jCheckBoxKeywords.isSelected()) items = items | Constants.DESKTOP_SHOW_KEYWORDS;
+ if (jCheckBoxRemarks.isSelected()) {
+ items = items | Constants.DESKTOP_SHOW_REMARKS;
+ }
+ if (jCheckBoxAuthors.isSelected()) {
+ items = items | Constants.DESKTOP_SHOW_AUTHORS;
+ }
+ if (jCheckBoxAttachments.isSelected()) {
+ items = items | Constants.DESKTOP_SHOW_ATTACHMENTS;
+ }
+ if (jCheckBoxKeywords.isSelected()) {
+ items = items | Constants.DESKTOP_SHOW_KEYWORDS;
+ }
// save user settings
settingsObj.setDesktopDisplayItems(items);
// save the changes to the settings-file
@@ -134,30 +144,27 @@ public void applyChanges() {
needsupdate = true;
// close window
closeWindow();
- }
-
-
+ }
+
/**
* When the user presses the cancel button, no update needed, close window
*/
@Action
public void cancelWindow() {
- needsupdate=false;
+ needsupdate = false;
closeWindow();
}
-
-
+
/**
- * Occurs when the user closes the window or presses the
- * ok button. the settings-file is then saved and the window
- * disposed.
+ * Occurs when the user closes the window or presses the ok button. the
+ * settings-file is then saved and the window disposed.
*/
private void closeWindow() {
dispose();
setVisible(false);
}
-
+
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
diff --git a/src/de/danielluedecke/zettelkasten/CImportBibTex.java b/src/de/danielluedecke/zettelkasten/CImportBibTex.java
index 9e15d667..a647496c 100644
--- a/src/de/danielluedecke/zettelkasten/CImportBibTex.java
+++ b/src/de/danielluedecke/zettelkasten/CImportBibTex.java
@@ -276,7 +276,7 @@ private void initTable() {
jTableBibEntries.setFont(f);
}
// make extra table-sorter for itunes-tables
- if (settingsObj.isMacStyle()) {
+ if (settingsObj.isMacAqua()) {
// make extra table-sorter for itunes-tables
TableUtils.SortDelegate sortDelegate = new TableUtils.SortDelegate() {
@Override
diff --git a/src/de/danielluedecke/zettelkasten/CSetBibKey.java b/src/de/danielluedecke/zettelkasten/CSetBibKey.java
index da80e8fe..ece536b9 100644
--- a/src/de/danielluedecke/zettelkasten/CSetBibKey.java
+++ b/src/de/danielluedecke/zettelkasten/CSetBibKey.java
@@ -30,7 +30,6 @@
* Sie sollten ein Exemplar der GNU General Public License zusammen mit diesem Programm
* erhalten haben. Falls nicht, siehe .
*/
-
package de.danielluedecke.zettelkasten;
import de.danielluedecke.zettelkasten.database.Settings;
@@ -77,7 +76,7 @@ public class CSetBibKey extends javax.swing.JDialog {
private BibTex bibtexObj;
private Settings settingsObj;
private Daten dataObj;
-
+
private String currentAuthor = "";
private LinkedList selectedAuthors;
private ZettelkastenView mainframe;
@@ -100,20 +99,22 @@ public class CSetBibKey extends javax.swing.JDialog {
/**
* get the strings for file descriptions from the resource map
*/
- private org.jdesktop.application.ResourceMap resourceMap =
- org.jdesktop.application.Application.getInstance(de.danielluedecke.zettelkasten.ZettelkastenApp.class).
- getContext().getResourceMap(CSetBibKey.class);
+ private org.jdesktop.application.ResourceMap resourceMap
+ = org.jdesktop.application.Application.getInstance(de.danielluedecke.zettelkasten.ZettelkastenApp.class).
+ getContext().getResourceMap(CSetBibKey.class);
/**
- * This dialog sets or changed the bibkey of existing author-values. It is called from the mainframe's
- * tabbed pane, the jTableAuthors. When one or more authors are selected, they can be passed to this
- * dialog where the user has the chance to change or set a new bibkey-value for each of the selected
- * authors.
+ * This dialog sets or changed the bibkey of existing author-values. It is
+ * called from the mainframe's tabbed pane, the jTableAuthors. When one or
+ * more authors are selected, they can be passed to this dialog where the
+ * user has the chance to change or set a new bibkey-value for each of the
+ * selected authors.
*
* @param parent dialog's parent
* @param mf
* @param d a reference to the {@code CDaten}-class, the main dataclass
- * @param bt a reference to the {@code CBibTex}-class that handles the import/export of bibtex-files
+ * @param bt a reference to the {@code CBibTex}-class that handles the
+ * import/export of bibtex-files
* @param s a reference to the {@code CSettings}-class
*/
public CSetBibKey(java.awt.Frame parent, ZettelkastenView mf, Daten d, BibTex bt, Settings s) {
@@ -183,12 +184,12 @@ private void initBorders(Settings settingsObj) {
public void initTitleAndBibkey() {
initTitleAndBibkey(true);
}
-
-
+
/**
- * Since we probably have more that one value to change, this method sets the current author-value
- * to a jLabel, so the user knows which author-value is currently being edited. furthermore,
- * any existing bibkey of the current authorvalue is set to the textfield.
+ * Since we probably have more that one value to change, this method sets
+ * the current author-value to a jLabel, so the user knows which
+ * author-value is currently being edited. furthermore, any existing bibkey
+ * of the current authorvalue is set to the textfield.
*/
private void initTitleAndBibkey(boolean resetAuthors) {
// get currently edited author
@@ -196,52 +197,53 @@ private void initTitleAndBibkey(boolean resetAuthors) {
selectedAuthors = mainframe.getSelectedAuthors();
}
// check for valid value
- if (selectedAuthors!=null && selectedAuthors.size()>0) {
+ if (selectedAuthors != null && selectedAuthors.size() > 0) {
String author = currentAuthor = selectedAuthors.get(0);
// if the string is too long, truncate it.
- if (author.length()>50) author = author.substring(0, 50)+"...";
+ if (author.length() > 50) {
+ author = author.substring(0, 50) + "...";
+ }
// set title, so the user knows which author-value is currently being set...
jLabelTitle.setText(resourceMap.getString("authorTitle", author));
// retrieve authors bibkey, if any. since this attribute is optional,
// null might be returned
String bibkey = dataObj.getAuthorBibKey(currentAuthor);
// either set bibkey-value or empty string to textfield
- jTextFieldManualBibkey.setText((bibkey!=null)?bibkey:"");
+ jTextFieldManualBibkey.setText((bibkey != null) ? bibkey : "");
// en- or disable apply-button
if (jRadioButtonManualBibkey.isSelected()) {
// when manual option is selected, en- or disable depending on textinput
jButtonApply.setEnabled(!jTextFieldManualBibkey.getText().isEmpty());
- }
- else {
+ } else {
// else when file-option is selected, en- or disable depending on table-selection
- jButtonApply.setEnabled(jTablePreview.getSelectedRow()!=-1);
+ jButtonApply.setEnabled(jTablePreview.getSelectedRow() != -1);
}
- }
- else {
+ } else {
jLabelTitle.setText(resourceMap.getString("noAuthorValues"));
jTextFieldManualBibkey.setText("");
jButtonApply.setEnabled(false);
}
}
-
private void deleteBibtexEntry() {
// get the selected rows
int[] rows = jTablePreview.getSelectedRows();
// if we have no selected values, leave method
- if (rows.length<1) return;
+ if (rows.length < 1) {
+ return;
+ }
// ask whether bibtex entries really should be removed
int option = JOptionPane.showConfirmDialog(null, resourceMap.getString("removeBibtexEntryMsg"), resourceMap.getString("removeBibtexEntryTitle"), JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE);
// the user chose to cancel the operation, so return "null"
- if (JOptionPane.YES_OPTION==option) {
+ if (JOptionPane.YES_OPTION == option) {
// iterate all selected values
- for (int cnt=0; cnt0) {
+ if (linkedtablelist != null && linkedtablelist.size() > 0) {
// init the object-variable
Object[] o = new Object[2];
// fill object with values
@@ -252,15 +254,13 @@ private void deleteBibtexEntry() {
}
}
// check for filtered list
- if (linkedtablelist!=null && linkedtablelist.size()>0) {
+ if (linkedtablelist != null && linkedtablelist.size() > 0) {
refreshList();
- }
- else {
+ } else {
fillBibtexTable();
}
}
}
-
/**
* Init several listeners for the components.
@@ -271,7 +271,8 @@ private void initListeners() {
// presses the cancel button...
KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
ActionListener cancelAction = new java.awt.event.ActionListener() {
- @Override public void actionPerformed(ActionEvent evt) {
+ @Override
+ public void actionPerformed(ActionEvent evt) {
cancel();
}
};
@@ -279,7 +280,8 @@ private void initListeners() {
// when the radio.button for manual input is selected, we want to enable its related
// components and disable all the stuff for the file-selection-radio-button
jRadioButtonManualBibkey.addActionListener(new java.awt.event.ActionListener() {
- @Override public void actionPerformed(java.awt.event.ActionEvent evt) {
+ @Override
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
// disable all file-options
toggleOptions(false);
// set keyboard-focus to textfield
@@ -291,81 +293,100 @@ private void initListeners() {
// whenever the user changes the text of the textfield, en- or disable apply-button
// depending on whether we already have textinput or not
jTextFieldManualBibkey.getDocument().addDocumentListener(new DocumentListener() {
- @Override public void changedUpdate(DocumentEvent e) { jButtonApply.setEnabled(!jTextFieldManualBibkey.getText().isEmpty()); }
- @Override public void insertUpdate(DocumentEvent e) { jButtonApply.setEnabled(!jTextFieldManualBibkey.getText().isEmpty()); }
- @Override public void removeUpdate(DocumentEvent e) { jButtonApply.setEnabled(!jTextFieldManualBibkey.getText().isEmpty()); }
+ @Override
+ public void changedUpdate(DocumentEvent e) {
+ jButtonApply.setEnabled(!jTextFieldManualBibkey.getText().isEmpty());
+ }
+
+ @Override
+ public void insertUpdate(DocumentEvent e) {
+ jButtonApply.setEnabled(!jTextFieldManualBibkey.getText().isEmpty());
+ }
+
+ @Override
+ public void removeUpdate(DocumentEvent e) {
+ jButtonApply.setEnabled(!jTextFieldManualBibkey.getText().isEmpty());
+ }
});
// when the radio-button for file-input is selected, we want to enable its related
// components and disable all the stuff for the manual-selection-radio-button
jRadioButtonFileBibkey.addActionListener(new java.awt.event.ActionListener() {
- @Override public void actionPerformed(java.awt.event.ActionEvent evt) {
+ @Override
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
// disable all manual-options
toggleOptions(true);
// en- or disable apply-button depending on whether we have a selection or not
- jButtonApply.setEnabled(jTablePreview.getSelectedRow()!=1);
+ jButtonApply.setEnabled(jTablePreview.getSelectedRow() != 1);
// set keyboard-focus to the encoding-combobox, so the user can choose
// the input-format
jTablePreview.requestFocusInWindow();
}
});
jComboBoxShowBibTex.addActionListener(new java.awt.event.ActionListener() {
- @Override public void actionPerformed(java.awt.event.ActionEvent evt) {
+ @Override
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
fillBibtexTable();
}
});
jTextFieldFilterTable.addKeyListener(new java.awt.event.KeyAdapter() {
- @Override public void keyReleased(java.awt.event.KeyEvent evt) {
+ @Override
+ public void keyReleased(java.awt.event.KeyEvent evt) {
if (Tools.isNavigationKey(evt.getKeyCode())) {
// if user pressed navigation key, select next table entry
de.danielluedecke.zettelkasten.util.TableUtils.navigateThroughList(jTablePreview, evt.getKeyCode());
- }
- else {
+ } else {
// select table-entry live, while the user is typing...
- de.danielluedecke.zettelkasten.util.TableUtils.selectByTyping(jTablePreview,jTextFieldFilterTable,1);
+ de.danielluedecke.zettelkasten.util.TableUtils.selectByTyping(jTablePreview, jTextFieldFilterTable, 1);
}
}
});
// create action which should be executed when the user presses
// the enter-key
- AbstractAction a_enter = new AbstractAction(){
- @Override public void actionPerformed(ActionEvent e) {
- if (jTextFieldFilterTable==e.getSource()) filterList(false);
+ AbstractAction a_enter = new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ if (jTextFieldFilterTable == e.getSource()) {
+ filterList(false);
+ }
}
};
// put action to the textfield's actionmaps
- jTextFieldFilterTable.getActionMap().put("EnterKeyPressed",a_enter);
+ jTextFieldFilterTable.getActionMap().put("EnterKeyPressed", a_enter);
// associate enter-keystroke with that action
KeyStroke ks = KeyStroke.getKeyStroke("ENTER");
jTextFieldFilterTable.getInputMap().put(ks, "EnterKeyPressed");
// create action which should be executed when the user presses
// the alt+enter-key (reg ex filter)
- AbstractAction a_regex_enter = new AbstractAction(){
- @Override public void actionPerformed(ActionEvent e) {
- if (jTextFieldFilterTable==e.getSource()) filterList(true);
+ AbstractAction a_regex_enter = new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ if (jTextFieldFilterTable == e.getSource()) {
+ filterList(true);
+ }
}
};
// put action to the textfield's actionmaps
- jTextFieldFilterTable.getActionMap().put("RegExEnterKeyPressed",a_regex_enter);
+ jTextFieldFilterTable.getActionMap().put("RegExEnterKeyPressed", a_regex_enter);
// associate enter-keystroke with that action
ks = KeyStroke.getKeyStroke("alt ENTER");
jTextFieldFilterTable.getInputMap().put(ks, "RegExEnterKeyPressed");
// create action which should be executed when the user presses
// the delete/backspace-key
- AbstractAction a_delete = new AbstractAction(){
- @Override public void actionPerformed(ActionEvent e) {
- if (jTablePreview==e.getSource()) {
+ AbstractAction a_delete = new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ if (jTablePreview == e.getSource()) {
deleteBibtexEntry();
}
}
};
// put action to the tables' actionmaps
- jTablePreview.getActionMap().put("DeleteKeyPressed",a_delete);
+ jTablePreview.getActionMap().put("DeleteKeyPressed", a_delete);
// check for os, and use appropriate controlKey
- ks = KeyStroke.getKeyStroke((PlatformUtil.isMacOS())?"BACK_SPACE":"DELETE");
+ ks = KeyStroke.getKeyStroke((PlatformUtil.isMacOS()) ? "BACK_SPACE" : "DELETE");
jTablePreview.getInputMap().put(ks, "DeleteKeyPressed");
}
-
private void filterList(boolean regEx) {
// when we filter the table and want to restore it, we don't need to run the
// time-consuming task that creates the author-list and related author-frequencies.
@@ -377,15 +398,17 @@ private void filterList(boolean regEx) {
// convert to lowercase, we don't want case-sensitive search
String text = jTextFieldFilterTable.getText().toLowerCase();
// when we have no text, do nothing
- if (text.isEmpty()) return;
+ if (text.isEmpty()) {
+ return;
+ }
// get table model
- DefaultTableModel dtm = (DefaultTableModel)jTablePreview.getModel();
+ DefaultTableModel dtm = (DefaultTableModel) jTablePreview.getModel();
// if we haven't already stored the current complete table data, do this now
- if (null==linkedtablelist) {
+ if (null == linkedtablelist) {
// create new instance of list
linkedtablelist = new LinkedList<>();
// go through all table-data
- for (int cnt=0; cnt0);
+ jTextFieldFilterTable.setEnabled(jTablePreview.getRowCount() > 0);
// enable refresh button
jButtonRefreshView.setEnabled(true);
}
-
/**
- * Inits the jTable, i.e. sets up comparers, sorters, and selection listeners.
+ * Inits the jTable, i.e. sets up comparers, sorters, and selection
+ * listeners.
*/
private void initTable() {
// create new table sorter
@@ -415,14 +438,13 @@ private void initTable() {
// tell tgis jtable that it has an own sorter
jTablePreview.setRowSorter(sorter);
// and tell the sorter, which table model to sort.
- sorter.setModel((DefaultTableModel)jTablePreview.getModel());
+ sorter.setModel((DefaultTableModel) jTablePreview.getModel());
// in this table, the first column needs a custom comparator.
try {
- sorter.setComparator(0,new Comparer());
- sorter.setComparator(1,new Comparer());
- }
- catch (IndexOutOfBoundsException e) {
- Constants.zknlogger.log(Level.WARNING,e.getLocalizedMessage());
+ sorter.setComparator(0, new Comparer());
+ sorter.setComparator(1, new Comparer());
+ } catch (IndexOutOfBoundsException e) {
+ Constants.zknlogger.log(Level.WARNING, e.getLocalizedMessage());
}
// noe header re-ordering
jTablePreview.getTableHeader().setReorderingAllowed(false);
@@ -432,16 +454,16 @@ private void initTable() {
jTablePreview.setShowVerticalLines(settingsObj.getShowGridVertical());
jTablePreview.setIntercellSpacing(settingsObj.getCellSpacing());
// clear table
- DefaultTableModel dtm = (DefaultTableModel)jTablePreview.getModel();
+ DefaultTableModel dtm = (DefaultTableModel) jTablePreview.getModel();
dtm.setRowCount(0);
// get the default fontsize for tables and lists
int defaultsize = settingsObj.getTableFontSize();
// only set new fonts, when fontsize differs from the initial value
- if (defaultsize>0) {
+ if (defaultsize > 0) {
// get current font
Font f = jTablePreview.getFont();
// create new font, add fontsize-value
- f = new Font(f.getName(), f.getStyle(), f.getSize()+defaultsize);
+ f = new Font(f.getName(), f.getStyle(), f.getSize() + defaultsize);
// set new font
jTablePreview.setFont(f);
}
@@ -452,9 +474,9 @@ private void initTable() {
jTablePreview.getColumnModel().getSelectionModel().addListSelectionListener(listener);
}
-
/**
* En- or disables the components that are related to the choice of bibkeys
+ *
* @param value
*/
private void toggleOptions(boolean value) {
@@ -462,14 +484,13 @@ private void toggleOptions(boolean value) {
jTablePreview.setEnabled(value);
jComboBoxShowBibTex.setEnabled(value);
jLabel1.setEnabled(value);
- jButtonRefreshView.setEnabled((value)?linkedtablelist!=null:false);
- jTextFieldFilterTable.setEnabled((value)?jTablePreview.getRowCount()>0:false);
+ jButtonRefreshView.setEnabled((value) ? linkedtablelist != null : false);
+ jTextFieldFilterTable.setEnabled((value) ? jTablePreview.getRowCount() > 0 : false);
// toggle manual options
jTextFieldManualBibkey.setEnabled(!value);
jLabelManualBibkey.setEnabled(!value);
}
-
/**
* Closes the window
*/
@@ -481,7 +502,6 @@ public void cancel() {
setVisible(false);
}
-
@Action
public void applyChanges() {
settingsObj.setLastUsedSetBibyKeyChoice((jRadioButtonFileBibkey.isSelected()) ? CHOOSE_BIBKEY_FROM_DB : CHOOSE_BIBKEY_MANUAL);
@@ -493,14 +513,13 @@ public void applyChanges() {
if (jRadioButtonManualBibkey.isSelected()) {
// select user-input from textfield
selectedbibkey = jTextFieldManualBibkey.getText();
- }
- else {
+ } else {
// else retrieve selected row
int row = jTablePreview.getSelectedRow();
// if we have any valid selection...
- if (row!=-1) {
+ if (row != -1) {
// get table model
- DefaultTableModel dtm = (DefaultTableModel)jTablePreview.getModel();
+ DefaultTableModel dtm = (DefaultTableModel) jTablePreview.getModel();
// retrieve row-index from the model
int rowindex = jTablePreview.convertRowIndexToModel(row);
// retrieve bibkey-value and author from row
@@ -509,7 +528,7 @@ public void applyChanges() {
// and delete table-row, so already used values don't appear anymore
dtm.removeRow(rowindex);
// check whether to delete from filtered table list
- if (linkedtablelist!=null) {
+ if (linkedtablelist != null) {
try {
Iterator