Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import net.sf.jabref.gui.undo.UndoableFieldChange;

import com.jgoodies.forms.builder.ButtonBarBuilder;
import com.jgoodies.forms.builder.DefaultFormBuilder;
import com.jgoodies.forms.builder.FormBuilder;
import com.jgoodies.forms.layout.FormLayout;

import net.sf.jabref.logic.util.io.FileUtil;
Expand All @@ -58,10 +58,13 @@ public class AutoSetExternalFileForEntries extends AbstractWorker {

private static final Log log = LogFactory.getLog(AutoSetExternalFileForEntries.class);

private final Object[] brokenLinkOptions =
{Localization.lang("Ignore"), Localization.lang("Assign new file"), Localization.lang("Clear field"),
private final Object[] brokenLinkOptions = {
// @formatter:off
Localization.lang("Ignore"),
Localization.lang("Assign new file"),
Localization.lang("Clear field"),
Localization.lang("Quit synchronization")};

// @formatter:on
private boolean goOn = true;
private boolean autoSet = true;
private boolean overWriteAllowed = true;
Expand Down Expand Up @@ -131,7 +134,7 @@ public void run() {

final String old = aSel.getField(fieldName);
// Check if a extension is already set, and if so, if we are allowed to overwrite it:
if (old != null && !old.equals("") && !overWriteAllowed) {
if ((old != null) && !old.equals("") && !overWriteAllowed) {
continue;
}
extPan.setEntry(aSel, panel.getDatabase());
Expand All @@ -154,11 +157,11 @@ public void run() {
panel.frame().setProgressBarValue(progress++);
final String old = aSel.getField(fieldName);
// Check if a extension is set:
if (old != null && !old.equals("")) {
if ((old != null) && !old.equals("")) {
// Get an absolute path representation:
File file = FileUtil.expandFilename(old, dirs);

if (file == null || !file.exists()) {
if ((file == null) || !file.exists()) {

int answer =
JOptionPane.showOptionDialog(panel.frame(),
Expand Down Expand Up @@ -200,7 +203,7 @@ public void run() {

//log brokenLinks if some were found
if (brokenLinks > 0) {
log.warn(Localization.lang("Found %0 broken links", brokenLinks + ""));
AutoSetExternalFileForEntries.log.warn(Localization.lang("Found %0 broken links", brokenLinks + ""));
}

if (entriesChanged > 0) {
Expand Down Expand Up @@ -278,33 +281,27 @@ public void actionPerformed(ActionEvent e) {
bg.add(autoSetUnset);
bg.add(autoSetNone);
bg.add(autoSetAll);
FormLayout layout = new FormLayout("fill:pref", "");
DefaultFormBuilder builder = new DefaultFormBuilder(layout);
FormLayout layout = new FormLayout("fill:pref", "pref, 2dlu, pref, 2dlu, pref, pref, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref");
FormBuilder builder = FormBuilder.create().layout(layout);
description = new JLabel("<HTML>" +
Localization.lang(//"This function helps you keep your external %0 links up-to-date." +
"Attempt to autoset %0 links for your entries. Autoset works if "
+ "a %0 file in your %0 directory or a subdirectory<BR>is named identically to an entry's BibTeX key, plus extension.", fn)
+ "</HTML>");
// name.setVerticalAlignment(JLabel.TOP);
builder.appendSeparator(Localization.lang("Autoset"));
builder.append(description);
builder.nextLine();
builder.append(autoSetUnset);
builder.nextLine();
builder.append(autoSetAll);
builder.nextLine();
builder.append(autoSetNone);
builder.nextLine();
builder.appendSeparator(Localization.lang("Check links"));

builder.addSeparator(Localization.lang("Autoset")).xy(1, 1);
builder.add(description).xy(1, 3);
builder.add(autoSetUnset).xy(1, 5);
builder.add(autoSetAll).xy(1, 6);
builder.add(autoSetNone).xy(1, 7);
builder.addSeparator(Localization.lang("Check links")).xy(1, 9);

description = new JLabel("<HTML>" +
Localization.lang("This makes JabRef look up each %0 link and check if the file exists. If not, you will be given options<BR>to resolve the problem.", fn)
+ "</HTML>");
builder.append(description);
builder.nextLine();
builder.append(checkLinks);
builder.nextLine();
builder.appendSeparator();
builder.add(description).xy(1, 11);
builder.add(checkLinks).xy(1, 13);
builder.addSeparator("").xy(1, 15);

JPanel main = builder.getPanel();
main.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
Expand Down
54 changes: 28 additions & 26 deletions src/main/java/net/sf/jabref/external/SynchronizeFileField.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2003-2011 JabRef contributors.
/* Copyright (C) 2003-2015 JabRef contributors.
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
Expand All @@ -16,7 +16,7 @@
package net.sf.jabref.external;

import com.jgoodies.forms.builder.ButtonBarBuilder;
import com.jgoodies.forms.builder.DefaultFormBuilder;
import com.jgoodies.forms.builder.FormBuilder;
import com.jgoodies.forms.layout.FormLayout;
import net.sf.jabref.*;
import net.sf.jabref.gui.*;
Expand Down Expand Up @@ -48,10 +48,14 @@ public class SynchronizeFileField extends AbstractWorker {
private BibtexEntry[] sel;
private SynchronizeFileField.OptionsDialog optDiag;

private final Object[] brokenLinkOptions =
{Localization.lang("Ignore"), Localization.lang("Assign new file"), Localization.lang("Remove link"),
private final Object[] brokenLinkOptions = {
// @formatter:off
Localization.lang("Ignore"),
Localization.lang("Assign new file"),
Localization.lang("Remove link"),
Localization.lang("Remove all broken links"),
Localization.lang("Quit synchronization")};
// @formatter:on

private boolean goOn = true;
private boolean autoSet = true;
Expand Down Expand Up @@ -147,7 +151,7 @@ public void run() {
panel.frame().setProgressBarValue(progress++);
final String old = aSel.getField(fieldName);
// Check if a extension is set:
if (old != null && !old.equals("")) {
if ((old != null) && !old.equals("")) {
FileListTableModel tableModel = new FileListTableModel();
tableModel.setContentDontGuessTypes(old);

Expand All @@ -173,7 +177,7 @@ public void run() {

// Get an absolute path representation:
File file = FileUtil.expandFilename(flEntry.getLink(), dirsS);
if (file == null || !file.exists()) {
if ((file == null) || !file.exists()) {
int answer;
if (!removeAllBroken) {
answer = JOptionPane.showOptionDialog(panel.frame(),
Expand Down Expand Up @@ -214,7 +218,7 @@ public void run() {
}

// Unless we deleted this link, see if its file type is recognized:
if (!deleted && flEntry.getType() instanceof UnknownExternalFileType) {
if (!deleted && (flEntry.getType() instanceof UnknownExternalFileType)) {
String[] options = new String[]
{Localization.lang("Define '%0'", flEntry.getType().getName()),
Localization.lang("Change file type"), Localization.lang("Cancel")};
Expand Down Expand Up @@ -294,6 +298,7 @@ public void update() {

static class OptionsDialog extends JDialog {

private static final long serialVersionUID = 1909919286125256934L;
final JRadioButton autoSetUnset;
final JRadioButton autoSetAll;
final JRadioButton autoSetNone;
Expand All @@ -320,6 +325,8 @@ public void actionPerformed(ActionEvent e) {

Action closeAction = new AbstractAction() {

private static final long serialVersionUID = -8834440705768095070L;

@Override
public void actionPerformed(ActionEvent e) {
dispose();
Expand All @@ -341,33 +348,28 @@ public void actionPerformed(ActionEvent e) {
bg.add(autoSetUnset);
bg.add(autoSetNone);
bg.add(autoSetAll);
FormLayout layout = new FormLayout("fill:pref", "");
DefaultFormBuilder builder = new DefaultFormBuilder(layout);

FormLayout layout = new FormLayout("fill:pref", "pref, 2dlu, pref, 2dlu, pref, pref, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref");
FormBuilder builder = FormBuilder.create().layout(layout);
description = new JLabel("<HTML>" +
Localization.lang(//"This function helps you keep your external %0 links up-to-date." +
"Attempt to autoset %0 links for your entries. Autoset works if "
+ "a %0 file in your %0 directory or a subdirectory<BR>is named identically to an entry's BibTeX key, plus extension.", fn)
+ "</HTML>");
// name.setVerticalAlignment(JLabel.TOP);
builder.appendSeparator(Localization.lang("Autoset"));
builder.append(description);
builder.nextLine();
builder.append(autoSetUnset);
builder.nextLine();
builder.append(autoSetAll);
builder.nextLine();
builder.append(autoSetNone);
builder.nextLine();
builder.appendSeparator(Localization.lang("Check links"));

builder.addSeparator(Localization.lang("Autoset")).xy(1, 1);
builder.add(description).xy(1, 3);
builder.add(autoSetUnset).xy(1, 5);
builder.add(autoSetAll).xy(1, 6);
builder.add(autoSetNone).xy(1, 7);
builder.addSeparator(Localization.lang("Check links")).xy(1, 9);

description = new JLabel("<HTML>" +
Localization.lang("This makes JabRef look up each %0 extension and check if the file exists. If not, you will be given options<BR>to resolve the problem.", fn)
Localization.lang("This makes JabRef look up each %0 link and check if the file exists. If not, you will be given options<BR>to resolve the problem.", fn)
+ "</HTML>");
builder.append(description);
builder.nextLine();
builder.append(checkLinks);
builder.nextLine();
builder.appendSeparator();
builder.add(description).xy(1, 11);
builder.add(checkLinks).xy(1, 13);
builder.addSeparator("").xy(1, 15);

JPanel main = builder.getPanel();
main.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
Expand Down
14 changes: 8 additions & 6 deletions src/main/java/net/sf/jabref/gui/BasePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
import ca.odell.glazedlists.event.ListEvent;
import ca.odell.glazedlists.event.ListEventListener;
import ca.odell.glazedlists.matchers.Matcher;
import com.jgoodies.forms.builder.DefaultFormBuilder;
import com.jgoodies.forms.builder.FormBuilder;
import com.jgoodies.forms.layout.FormLayout;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Expand Down Expand Up @@ -1423,9 +1423,11 @@ private boolean saveDatabase(File file, boolean selectedOnly, String encoding, F
}

} catch (UnsupportedCharsetException ex2) {
// @formatter:off
JOptionPane.showMessageDialog(frame, Localization.lang("Could not save file. "
+ "Character encoding '%0' is not supported.", encoding),
Localization.lang("Save database"), JOptionPane.ERROR_MESSAGE);
// @formatter:on
throw new SaveException("rt");
} catch (SaveException ex) {
if (ex.specificEntry()) {
Expand Down Expand Up @@ -1453,13 +1455,13 @@ private boolean saveDatabase(File file, boolean selectedOnly, String encoding, F

boolean commit = true;
if (!session.getWriter().couldEncodeAll()) {
DefaultFormBuilder builder = new DefaultFormBuilder(new FormLayout("left:pref, 4dlu, fill:pref", ""));
FormBuilder builder = FormBuilder.create().layout(new FormLayout("left:pref, 4dlu, fill:pref", "pref, 4dlu, pref"));
JTextArea ta = new JTextArea(session.getWriter().getProblemCharacters());
ta.setEditable(false);
builder.append(Localization.lang("The chosen encoding '%0' could not encode the following characters: ",
session.getEncoding()));
builder.append(ta);
builder.append(Localization.lang("What do you want to do?"));
builder.add(Localization.lang("The chosen encoding '%0' could not encode the following characters: ",
session.getEncoding())).xy(1, 1);
builder.add(ta).xy(3, 1);
builder.add(Localization.lang("What do you want to do?")).xy(1, 3);
String tryDiff = Localization.lang("Try different encoding");
int answer = JOptionPane.showOptionDialog(frame, builder.getPanel(), Localization.lang("Save database"),
JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null,
Expand Down
24 changes: 16 additions & 8 deletions src/main/java/net/sf/jabref/gui/ColorSetupPanel.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2003-2011 JabRef contributors.
/* Copyright (C) 2003-2015 JabRef contributors.
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
Expand All @@ -16,7 +16,7 @@
package net.sf.jabref.gui;

import com.jgoodies.forms.layout.FormLayout;
import com.jgoodies.forms.builder.DefaultFormBuilder;
import com.jgoodies.forms.builder.FormBuilder;

import javax.swing.*;
import java.awt.*;
Expand All @@ -36,6 +36,7 @@
*/
public class ColorSetupPanel extends JPanel {

private static final long serialVersionUID = -4634367444666144966L;
private static final int ICON_WIDTH = 30;
private static final int ICON_HEIGHT = 20;
private final ArrayList<ColorButton> buttons = new ArrayList<ColorButton>();
Expand All @@ -44,8 +45,9 @@ public class ColorSetupPanel extends JPanel {
public ColorSetupPanel() {

FormLayout layout = new FormLayout
("30dlu, 4dlu, fill:pref, 4dlu, fill:pref, 8dlu, 30dlu, 4dlu, fill:pref, 4dlu, fill:pref", "");
DefaultFormBuilder builder = new DefaultFormBuilder(layout);
("30dlu, 4dlu, fill:pref, 4dlu, fill:pref, 8dlu, 30dlu, 4dlu, fill:pref, 4dlu, fill:pref",
"pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref");
FormBuilder builder = FormBuilder.create().layout(layout);

buttons.add(new ColorButton("tableText", Localization.lang("Table text color")));
buttons.add(new ColorButton("markedEntryBackground0", Localization.lang("Marking color %0", "1")));
Expand All @@ -65,12 +67,17 @@ public ColorSetupPanel() {
buttons.add(new ColorButton("activeFieldEditorBackgroundColor", Localization.lang("Entry editor active background color")));
buttons.add(new ColorButton("invalidFieldBackgroundColor", Localization.lang("Entry editor invalid field color")));

int rowcnt = 0;
int col = 0;
int row;
for (ColorButton but : buttons) {
builder.append(but);
builder.append(but.getDefaultButton());
builder.append(but.getName());
row = (2*(rowcnt/2)) + 1; // == 2*floor(rowcnt/2) + 1
builder.add((JButton)but).xy((6*col)+1, row);
builder.add(but.getDefaultButton()).xy((6*col)+3, row);
builder.add(but.getName()).xy((6*col)+5, row);
but.addActionListener(new ColorButtonListener(but));

col = 1-col; // Change 0 -> 1 -> 0 ...
rowcnt++;
}

setLayout(new BorderLayout());
Expand Down Expand Up @@ -118,6 +125,7 @@ public void actionPerformed(ActionEvent e) {
*/
class ColorButton extends JButton implements Icon {

private static final long serialVersionUID = -1974112633706382299L;
private Color color = Color.white;
private final String key;
private final String name;
Expand Down
Loading