Skip to content

Commit

Permalink
Implement online help action
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan-kolb committed Jan 26, 2016
1 parent d3ff7bb commit c8b48e4
Show file tree
Hide file tree
Showing 238 changed files with 324 additions and 18,416 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import net.sf.jabref.gui.GUIGlobals;
import net.sf.jabref.gui.JabRefFrame;
import net.sf.jabref.gui.help.HelpAction;
import net.sf.jabref.gui.help.OnlineHelpAction;
import net.sf.jabref.gui.keyboard.KeyBinding;
import net.sf.jabref.gui.util.FocusRequester;
import net.sf.jabref.gui.util.PositionWindow;
Expand Down Expand Up @@ -126,7 +127,7 @@ public void actionPerformed(ActionEvent e) {
JButton close = new JButton(Localization.lang("Close"));
close.addActionListener(closeAction);

JButton help = new HelpAction(frame.helpDiag, GUIGlobals.exportCustomizationHelp).getIconButton();
JButton help = new OnlineHelpAction(GUIGlobals.exportCustomizationHelp).getIconButton();

DefaultEventTableModel<String[]> tableModel = new DefaultEventTableModel<>(
Globals.prefs.customExports.getSortedList(),
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/sf/jabref/groups/GroupSelector.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
import javax.swing.undo.CompoundEdit;

import net.sf.jabref.gui.*;
import net.sf.jabref.gui.help.OnlineHelpAction;
import net.sf.jabref.gui.worker.AbstractWorker;
import net.sf.jabref.model.entry.BibEntry;
import net.sf.jabref.Globals;
Expand Down Expand Up @@ -338,7 +339,7 @@ public void actionPerformed(ActionEvent e) {
newButton.setMinimumSize(butDim);
refresh.setPreferredSize(butDim);
refresh.setMinimumSize(butDim);
JButton helpButton = new HelpAction(frame.helpDiag, GUIGlobals.groupsHelp, Localization.lang("Help on groups"))
JButton helpButton = new OnlineHelpAction(Localization.lang("Help on groups"), GUIGlobals.groupsHelp)
.getIconButton();
helpButton.setPreferredSize(butDim);
helpButton.setMinimumSize(butDim);
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/sf/jabref/gui/ContentSelectorDialog2.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import net.sf.jabref.Globals;
import net.sf.jabref.MetaData;
import net.sf.jabref.gui.help.HelpAction;
import net.sf.jabref.gui.help.OnlineHelpAction;
import net.sf.jabref.gui.util.FocusRequester;
import net.sf.jabref.logic.l10n.Localization;
import org.apache.commons.logging.Log;
Expand Down Expand Up @@ -522,7 +523,7 @@ private void initLayout() {
bsb.addButton(apply);
bsb.addButton(cancel);
bsb.addRelatedGap();
bsb.addButton(new HelpAction(frame.helpDiag, GUIGlobals.contentSelectorHelp).getIconButton());
bsb.addButton(new OnlineHelpAction(GUIGlobals.contentSelectorHelp).getIconButton());
bsb.addGlue();

// Add panels to dialog:
Expand Down
43 changes: 21 additions & 22 deletions src/main/java/net/sf/jabref/gui/GUIGlobals.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,29 +87,28 @@ public class GUIGlobals {
public static HelpDialog helpDiag;

//Help files (in HTML format):
public static final String baseFrameHelp = "BaseFrameHelp.html";
public static final String entryEditorHelp = "EntryEditorHelp.html";
public static final String stringEditorHelp = "StringEditorHelp.html";
public static final String helpContents = "Contents.html";
public static final String searchHelp = "SearchHelp.html";
public static final String groupsHelp = "GroupsHelp.html";
public static final String contentSelectorHelp = "ContentSelectorHelp.html";
public static final String specialFieldsHelp = "SpecialFieldsHelp.html";
public static final String labelPatternHelp = "LabelPatterns.html";
public static final String ownerHelp = "OwnerHelp.html";
public static final String timeStampHelp = "TimeStampHelp.html";
public static final String exportCustomizationHelp = "CustomExports.html";
public static final String importCustomizationHelp = "CustomImports.html";
public static final String medlineHelp = "MedlineHelp.html";
public static final String generalFieldsHelp = "GeneralFields.html";
public static final String baseFrameHelp = "Contents";
public static final String entryEditorHelp = "EntryEditorHelp";
public static final String stringEditorHelp = "StringEditorHelp";
public static final String searchHelp = "SearchHelp";
public static final String groupsHelp = "GroupsHelp";
public static final String contentSelectorHelp = "ContentSelectorHelp";
public static final String specialFieldsHelp = "SpecialFieldsHelp";
public static final String labelPatternHelp = "LabelPatterns";
public static final String ownerHelp = "OwnerHelp";
public static final String timeStampHelp = "TimeStampHelp";
public static final String exportCustomizationHelp = "CustomExports";
public static final String importCustomizationHelp = "CustomImports";
public static final String medlineHelp = "MedlineHelp";
public static final String generalFieldsHelp = "GeneralFields";
public static final String aboutPage = "About.html";
public static final String importInspectionHelp = "ImportInspectionDialog.html";
public static final String remoteHelp = "RemoteHelp.html";
public static final String journalAbbrHelp = "JournalAbbreviations.html";
public static final String regularExpressionSearchHelp = "ExternalFiles.html#RegularExpressionSearch";
public static final String nameFormatterHelp = "CustomExports.html#NameFormatter";
public static final String previewHelp = "PreviewHelp.html";
public static final String autosaveHelp = "Autosave.html";
public static final String importInspectionHelp = "ImportInspectionDialog";
public static final String remoteHelp = "RemoteHelp";
public static final String journalAbbrHelp = "JournalAbbreviations";
public static final String regularExpressionSearchHelp = "ExternalFiles#RegularExpressionSearch";
public static final String nameFormatterHelp = "CustomExports#NameFormatter";
public static final String previewHelp = "PreviewHelp";
public static final String autosaveHelp = "Autosave";

// Colors.
public static final Color entryEditorLabelColor = new Color(100, 100, 150); // Empty field, blue.
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/sf/jabref/gui/GenFieldsCustomizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import net.sf.jabref.*;
import net.sf.jabref.gui.entryeditor.EntryEditorTabList;
import net.sf.jabref.gui.help.HelpAction;
import net.sf.jabref.gui.help.OnlineHelpAction;
import net.sf.jabref.gui.keyboard.KeyBinding;

import com.jgoodies.forms.builder.ButtonBarBuilder;
Expand Down Expand Up @@ -60,7 +61,7 @@ public class GenFieldsCustomizer extends JDialog {
public GenFieldsCustomizer(JabRefFrame frame/*, EntryCustomizationDialog diag*/) {
super(frame, Localization.lang("Set general fields"), false);
parent = frame;
helpBut = new HelpAction(parent.helpDiag, GUIGlobals.generalFieldsHelp).getIconButton();
helpBut = new OnlineHelpAction(GUIGlobals.generalFieldsHelp).getIconButton();
try {
jbInit();
setSize(new Dimension(650, 300));
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/sf/jabref/gui/ImportInspectionDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import javax.swing.table.TableModel;
import javax.swing.undo.AbstractUndoableEdit;

import net.sf.jabref.gui.help.OnlineHelpAction;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

Expand Down Expand Up @@ -305,7 +306,7 @@ public ImportInspectionDialog(JabRefFrame frame, BasePanel panel, String[] field
Localization.lang("Cancel"));
bb.addButton(cancel);
bb.addRelatedGap();
JButton help = new HelpAction(frame.helpDiag, GUIGlobals.importInspectionHelp).getIconButton();
JButton help = new OnlineHelpAction(GUIGlobals.importInspectionHelp).getIconButton();
bb.addButton(help);
bb.addGlue();
bb.getPanel().setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
Expand Down
13 changes: 4 additions & 9 deletions src/main/java/net/sf/jabref/gui/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import net.sf.jabref.exporter.*;
import net.sf.jabref.gui.actions.*;
import net.sf.jabref.gui.desktop.JabRefDesktop;
import net.sf.jabref.gui.help.OnlineHelpAction;
import net.sf.jabref.gui.keyboard.KeyBinding;
import net.sf.jabref.gui.keyboard.KeyBindingRepository;
import net.sf.jabref.gui.keyboard.KeyBindingsDialog;
Expand Down Expand Up @@ -247,15 +248,10 @@ void addJToogleButton(JToggleButton button) {
private final AbstractAction newSubDatabaseAction = new NewSubDatabaseAction(this);
private final AbstractAction forkMeOnGitHubAction = new ForkMeOnGitHubAction();
private final AbstractAction donationAction = new DonateAction();
private final AbstractAction help = new HelpAction(Localization.menuTitle("JabRef help"), helpDiag,
GUIGlobals.baseFrameHelp, Localization.lang("JabRef help"),
Globals.getKeyPrefs().getKey(KeyBinding.HELP));
private final AbstractAction contents = new HelpAction(Localization.menuTitle("Help contents"), helpDiag,
GUIGlobals.helpContents, Localization.lang("Help contents"),
IconTheme.JabRefIcon.HELP_CONTENTS.getIcon());
private final AbstractAction help = new OnlineHelpAction(Localization.menuTitle("JabRef help"), Localization.lang("JabRef help"),
GUIGlobals.baseFrameHelp, Globals.getKeyPrefs().getKey(KeyBinding.HELP));
private final AbstractAction about = new HelpAction(Localization.menuTitle("About JabRef"), helpDiag,
GUIGlobals.aboutPage, Localization.lang("About JabRef"),
IconTheme.getImage("about"));
GUIGlobals.aboutPage, Localization.lang("About JabRef"), IconTheme.getImage("about"));
private final AbstractAction editEntry = new GeneralAction(Actions.EDIT, Localization.menuTitle("Edit entry"),
Localization.lang("Edit entry"), Globals.getKeyPrefs().getKey(KeyBinding.EDIT_ENTRY), IconTheme.JabRefIcon.EDIT_ENTRY.getIcon());
private final AbstractAction focusTable = new GeneralAction(Actions.FOCUS_TABLE,
Expand Down Expand Up @@ -1335,7 +1331,6 @@ private void fillMenu() {
mb.add(options);

helpMenu.add(help);
helpMenu.add(contents);
helpMenu.addSeparator();
helpMenu.add(errorConsole);
helpMenu.addSeparator();
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/net/sf/jabref/gui/StringDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import net.sf.jabref.exporter.LatexFieldFormatter;
import net.sf.jabref.gui.actions.Actions;
import net.sf.jabref.gui.help.HelpAction;
import net.sf.jabref.gui.help.OnlineHelpAction;
import net.sf.jabref.gui.keyboard.KeyBinding;
import net.sf.jabref.model.database.KeyCollisionException;
import net.sf.jabref.gui.undo.UndoableInsertString;
Expand All @@ -69,7 +70,7 @@ class StringDialog extends JDialog {
private Object[] strings;

private final StringTable table;
private final HelpAction helpAction;
private final OnlineHelpAction helpAction;

private final PositionWindow pw;

Expand All @@ -81,7 +82,7 @@ public StringDialog(JabRefFrame frame, BasePanel panel, BibDatabase base) {

sortStrings();

helpAction = new HelpAction(frame.helpDiag, GUIGlobals.stringEditorHelp, Localization.lang("Help"));
helpAction = new OnlineHelpAction(Localization.lang("Help"), GUIGlobals.stringEditorHelp);

addWindowListener(new WindowAdapter() {

Expand Down
5 changes: 3 additions & 2 deletions src/main/java/net/sf/jabref/gui/entryeditor/EntryEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import net.sf.jabref.bibtex.EntryTypes;
import net.sf.jabref.gui.actions.Actions;
import net.sf.jabref.gui.fieldeditors.*;
import net.sf.jabref.gui.help.OnlineHelpAction;
import net.sf.jabref.gui.keyboard.KeyBinding;
import net.sf.jabref.gui.menus.ChangeEntryTypeMenu;
import net.sf.jabref.logic.autocompleter.AutoCompleter;
Expand Down Expand Up @@ -153,7 +154,7 @@ public class EntryEditor extends JPanel implements VetoableChangeListener, Entry

private final JabRefPreferences prefs;

final HelpAction helpAction;
final OnlineHelpAction helpAction;

private final UndoAction undoAction = new UndoAction();

Expand All @@ -172,7 +173,7 @@ public EntryEditor(JabRefFrame frame, BasePanel panel, BibEntry entry) {
this.entry.addPropertyChangeListener(this);
this.entry.addPropertyChangeListener(SpecialFieldUpdateListener.getInstance());

helpAction = new HelpAction(this.frame.helpDiag, GUIGlobals.entryEditorHelp, IconTheme.JabRefIcon.HELP.getIcon());
helpAction = new OnlineHelpAction(GUIGlobals.entryEditorHelp, IconTheme.JabRefIcon.HELP.getIcon());
closeAction = new CloseAction();
generateKeyAction = new GenerateKeyAction();
storeFieldAction = new StoreFieldAction();
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/net/sf/jabref/gui/help/HelpAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,23 @@

import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.io.IOException;

import javax.swing.*;

import net.sf.jabref.JabRef;
import net.sf.jabref.gui.IconTheme;
import net.sf.jabref.gui.actions.MnemonicAwareAction;
import net.sf.jabref.gui.desktop.JabRefDesktop;
import net.sf.jabref.logic.l10n.Localization;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
* This Action keeps a reference to a URL. When activated, it shows the help
* Dialog unless it is already visible, and shows the URL in it.
*/
public class HelpAction extends MnemonicAwareAction {

private final HelpDialog diag;

private Class<?> resourceOwner;
Expand Down
15 changes: 0 additions & 15 deletions src/main/java/net/sf/jabref/gui/help/HelpDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ public HelpDialog(JabRefFrame bf) {
tlb.add(back);
tlb.add(forward);
tlb.addSeparator();
ContentsAction contents = new ContentsAction();
tlb.add(contents);
tlb.setFloatable(false);

// Make ESC close dialog, and set shortkeys for back and forward.
Expand Down Expand Up @@ -155,17 +153,4 @@ public void actionPerformed(ActionEvent e) {
back.setEnabled(true);
}
}

class ContentsAction extends AbstractAction {

public ContentsAction() {
super("Contents", IconTheme.JabRefIcon.HELP_CONTENTS.getIcon());
}

@Override
public void actionPerformed(ActionEvent e) {
content.setPage(GUIGlobals.helpContents, JabRef.class);
back.setEnabled(true);
}
}
}
97 changes: 97 additions & 0 deletions src/main/java/net/sf/jabref/gui/help/OnlineHelpAction.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/* 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
(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.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package net.sf.jabref.gui.help;

import net.sf.jabref.Globals;
import net.sf.jabref.JabRef;
import net.sf.jabref.JabRefPreferences;
import net.sf.jabref.gui.IconTheme;
import net.sf.jabref.gui.actions.MnemonicAwareAction;
import net.sf.jabref.gui.desktop.JabRefDesktop;
import net.sf.jabref.logic.l10n.Localization;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.io.IOException;

/**
* This Action keeps a reference to a URL. When activated, it shows the help
* Dialog unless it is already visible, and shows the URL in it.
*/
public class OnlineHelpAction extends MnemonicAwareAction {
private static final Log LOGGER = LogFactory.getLog(OnlineHelpAction.class);

private String urlPart;

public OnlineHelpAction(String title, String tooltip, String urlPart, KeyStroke key) {
super(IconTheme.JabRefIcon.HELP.getSmallIcon());
this.urlPart = urlPart;
putValue(Action.NAME, title);
putValue(Action.SHORT_DESCRIPTION, tooltip);
putValue(Action.ACCELERATOR_KEY, key);
}

public OnlineHelpAction(String title, String tooltip, String urlPart, Icon icon) {
super(icon);
this.urlPart = urlPart;
putValue(Action.NAME, title);
putValue(Action.SHORT_DESCRIPTION, tooltip);
}

public OnlineHelpAction(String urlPart, Icon icon) {
this(Localization.lang("Help"), Localization.lang("Help"), urlPart, icon);
}

public OnlineHelpAction(String title, String tooltip, String urlPart) {
super(IconTheme.JabRefIcon.HELP.getSmallIcon());
this.urlPart = urlPart;
putValue(Action.NAME, title);
putValue(Action.SHORT_DESCRIPTION, tooltip);
}

public OnlineHelpAction(String urlPart) {
this(Localization.lang("Help"), Localization.lang("Help"), urlPart);
}

public OnlineHelpAction(String tooltip, String urlPart) {
this(Localization.lang("Help"), tooltip, urlPart);
}

public JButton getIconButton() {
JButton hlp = new JButton(this);
hlp.setText(null);
hlp.setPreferredSize(new Dimension(24, 24));
hlp.setToolTipText(getValue(Action.SHORT_DESCRIPTION).toString());
return hlp;
}

public void setHelpFile(String urlPart) {
this.urlPart = urlPart;
}

@Override
public void actionPerformed(ActionEvent e) {
try {
JabRefDesktop.openBrowser("http://help.jabref.org/" + Globals.prefs.get(JabRefPreferences.LANGUAGE) + "/" + urlPart);
} catch (IOException ex) {
LOGGER.warn("Could not open browser", ex);
JabRef.jrf.getCurrentBasePanel().output(Localization.lang("Could not open browser."));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import javax.swing.*;
import javax.swing.table.AbstractTableModel;

import net.sf.jabref.gui.help.OnlineHelpAction;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

Expand Down Expand Up @@ -150,8 +151,7 @@ public ManageJournalsPanel(final JabRefFrame frame) {
bb.addButton(cancel);
bb.addUnrelatedGap();

JButton help = new HelpAction(GUIGlobals.helpDiag, GUIGlobals.journalAbbrHelp,
IconTheme.JabRefIcon.HELP.getSmallIcon()).getIconButton();
JButton help = new OnlineHelpAction(GUIGlobals.journalAbbrHelp).getIconButton();
bb.addButton(help);
bb.addGlue();
bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
Expand Down
Loading

0 comments on commit c8b48e4

Please sign in to comment.