Skip to content

Commit

Permalink
Help methods moved to a new Help.java class. A help button was added …
Browse files Browse the repository at this point in the history
…to the file chooser.
  • Loading branch information
mpyat2 committed Nov 12, 2023
1 parent a01a716 commit 593e0e1
Show file tree
Hide file tree
Showing 16 changed files with 196 additions and 96 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
import org.aavso.tools.vstar.ui.dialog.MessageBox;
import org.aavso.tools.vstar.ui.dialog.TextArea;
import org.aavso.tools.vstar.ui.dialog.TextField;
import org.aavso.tools.vstar.ui.mediator.Mediator;
import org.aavso.tools.vstar.util.Pair;
import org.aavso.tools.vstar.util.help.Help;

public class GAIADR2XformObSource extends GaiaObSourceBase {

Expand Down Expand Up @@ -331,7 +331,7 @@ public void run() {
*/
@Override
protected void helpAction() {
Mediator.openPluginHelp(getDocName());
Help.openPluginHelp(getDocName());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

Expand All @@ -39,6 +38,7 @@
import org.aavso.tools.vstar.util.Pair;
import org.aavso.tools.vstar.util.coords.DecInfo;
import org.aavso.tools.vstar.util.coords.RAInfo;
import org.aavso.tools.vstar.util.help.Help;

/**
* Converts currently loaded observations to HJD if they are not already
Expand Down Expand Up @@ -162,7 +162,7 @@ private JPanel createMessagePane(String msg) {
*/
@Override
protected void helpAction() {
Mediator.openPluginHelp(helpTopic);
Help.openPluginHelp(helpTopic);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
import org.aavso.tools.vstar.ui.mediator.Mediator;
import org.aavso.tools.vstar.ui.mediator.DocumentManager;
import org.aavso.tools.vstar.util.date.YMD;
import org.aavso.tools.vstar.util.help.Help;
import org.aavso.tools.vstar.util.prefs.NumericPrecisionPrefs;
import org.aavso.tools.vstar.util.date.AbstractDateUtil;

Expand Down Expand Up @@ -349,7 +350,7 @@ public void actionPerformed(ActionEvent e) {
protected ActionListener createHelpButtonListener() {
return new ActionListener() {
public void actionPerformed(ActionEvent e) {
Mediator.openPluginHelp(getDocName());
Help.openPluginHelp(getDocName());
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
import org.aavso.tools.vstar.ui.dialog.NumberFieldBase;
import org.aavso.tools.vstar.ui.mediator.StarInfo;
import org.aavso.tools.vstar.util.Pair;
import org.aavso.tools.vstar.util.help.Help;
import org.aavso.tools.vstar.util.locale.LocaleProps;
import org.aavso.tools.vstar.util.prefs.NumericPrecisionPrefs;
import org.aavso.tools.vstar.vela.Operand;
Expand Down Expand Up @@ -723,7 +724,7 @@ private Document getVelaXML() throws ParserConfigurationException {
*/
@Override
protected void helpAction() {
Mediator.openPluginHelp(getDocName());
Help.openPluginHelp(getDocName());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@
import org.aavso.tools.vstar.ui.dialog.MessageBox;
import org.aavso.tools.vstar.ui.dialog.TextArea;
import org.aavso.tools.vstar.ui.dialog.TextField;
import org.aavso.tools.vstar.ui.mediator.Mediator;
import org.aavso.tools.vstar.ui.mediator.StarInfo;
import org.aavso.tools.vstar.util.Pair;
import org.aavso.tools.vstar.util.help.Help;
import org.aavso.tools.vstar.util.locale.NumberParser;

/**
Expand Down Expand Up @@ -406,7 +406,7 @@ public void showDialog() {
*/
@Override
protected void helpAction() {
Mediator.openPluginHelp(getDocName());
Help.openPluginHelp(getDocName());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
//12/02/2018 C. Kotnik added name to observations so they can be
//saved and reloaded from a file.
import org.aavso.tools.vstar.util.Pair;
import org.aavso.tools.vstar.util.help.Help;

/**
* The base class for URL based AAVSO photometry observation source plugins.
Expand Down Expand Up @@ -589,7 +590,7 @@ public String getVelaFilterStr() {
*/
@Override
protected void helpAction() {
Mediator.openPluginHelp(getDocName());
Help.openPluginHelp(getDocName());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.aavso.tools.vstar.ui.dialog.StarSelectorDialog;
import org.aavso.tools.vstar.ui.mediator.NewStarType;
import org.aavso.tools.vstar.ui.mediator.StarInfo;
import org.aavso.tools.vstar.util.help.Help;
import org.aavso.tools.vstar.util.locale.LocaleProps;

public abstract class AIDWebServiceObservationSourcePluginBase extends
Expand Down Expand Up @@ -204,6 +205,11 @@ public String getDescription() {
return LocaleProps.get("DATABASE_OBS_SOURCE");
}

@Override
public String getDocName() {
return Help.getAIDWebServiceHelpPage();
}

@Override
public InputType getInputType() {
return InputType.URL;
Expand All @@ -215,6 +221,7 @@ public List<URL> getURLs() throws Exception {
List<URL> urls = new ArrayList<URL>();

starSelector = StarSelectorDialog.getInstance();
starSelector.setPluginDocName(getDocName());

// Ask for object information.
starSelector.showDialog();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.aavso.tools.vstar.plugin.InputType;
import org.aavso.tools.vstar.plugin.ObservationSourcePluginBase;
import org.aavso.tools.vstar.ui.mediator.NewStarType;
import org.aavso.tools.vstar.util.help.Help;
import org.aavso.tools.vstar.util.locale.LocaleProps;

/**
Expand All @@ -54,6 +55,11 @@ public String getDescription() {
return "Observation source for AAVSO download and simple formats";
}

@Override
public String getDocName() {
return Help.getAAVSOtextFormatHelpPage();
}

@Override
public InputType getInputType() {
return InputType.FILE_OR_URL;
Expand Down
10 changes: 3 additions & 7 deletions src/org/aavso/tools/vstar/ui/MenuBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -79,8 +75,8 @@
import org.aavso.tools.vstar.ui.mediator.message.ZoomType;
import org.aavso.tools.vstar.ui.model.plot.ObservationAndMeanPlotModel;
import org.aavso.tools.vstar.ui.resources.PluginLoader;
import org.aavso.tools.vstar.ui.resources.ResourceAccessor;
import org.aavso.tools.vstar.ui.vela.VeLaDialog;
import org.aavso.tools.vstar.util.help.Help;
import org.aavso.tools.vstar.util.locale.LocaleProps;
import org.aavso.tools.vstar.util.notification.Listener;

Expand Down Expand Up @@ -1288,7 +1284,7 @@ public void actionPerformed(ActionEvent e) {
public ActionListener createHelpContentsListener() {
return new ActionListener() {
public void actionPerformed(ActionEvent e) {
Mediator.openHelpURLInWebBrowser("https://github.com/AAVSO/VStar/blob/master/doc/user_manual/VStarUserManual.pdf");
Help.openVStarManual();
}
};
}
Expand All @@ -1299,7 +1295,7 @@ public void actionPerformed(ActionEvent e) {
public ActionListener createVStarOnlineListener() {
return new ActionListener() {
public void actionPerformed(ActionEvent e) {
Mediator.openHelpURLInWebBrowser("https://www.aavso.org/vstar-overview");
Help.openVStarWebPage();
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.aavso.tools.vstar.ui.dialog.plugin.manager.PluginManager;
import org.aavso.tools.vstar.ui.resources.PluginLoader;
import org.aavso.tools.vstar.util.Pair;
import org.aavso.tools.vstar.util.help.Help;
import org.aavso.tools.vstar.util.locale.LocaleProps;

/**
Expand Down Expand Up @@ -172,6 +173,8 @@ public void actionPerformed(ActionEvent e) {
private JPanel createPluginsList() {
JPanel pane = new JPanel();

pane.setBorder(BorderFactory.createTitledBorder("Source"));

for (ObservationSourcePluginBase plugin : PluginLoader
.getObservationSourcePlugins()) {

Expand All @@ -196,7 +199,7 @@ private JPanel createPluginsList() {
pluginChooser = new JComboBox<String>(plugins.keySet().toArray(
new String[0]));
pluginChooser.setSelectedItem(LocaleProps.get("TEXT_FORMAT_FILE"));
pluginChooser.setBorder(BorderFactory.createTitledBorder("Source"));
//pluginChooser.setBorder(BorderFactory.createTitledBorder("Source"));

pluginChooser
.addActionListener(e -> {
Expand All @@ -216,6 +219,18 @@ private JPanel createPluginsList() {

pane.add(pluginChooser);

JButton helpButton = new JButton("?");

helpButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Optional<ObservationSourcePluginBase> plugin = getSelectedPlugin();
Help.openPluginHelp(!plugin.isEmpty() ? plugin.get().getDocName() : null);
}
});

pane.add(helpButton);

return pane;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import javax.swing.JPanel;

import org.aavso.tools.vstar.ui.mediator.Mediator;
import org.aavso.tools.vstar.util.help.Help;

/**
* This dialog class permits multiple named, ranged, numeric (double) values to
Expand Down Expand Up @@ -168,7 +169,7 @@ private JPanel createParameterPane() {
*/
@Override
protected void helpAction() {
Mediator.openPluginHelp(helpTopic);
Help.openPluginHelp(helpTopic);
}

/**
Expand Down
14 changes: 13 additions & 1 deletion src/org/aavso/tools/vstar/ui/dialog/StarSelectorDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import org.aavso.tools.vstar.ui.mediator.Mediator;
import org.aavso.tools.vstar.util.Pair;
import org.aavso.tools.vstar.util.date.AbstractDateUtil;
import org.aavso.tools.vstar.util.help.Help;
import org.aavso.tools.vstar.util.locale.LocaleProps;
import org.aavso.tools.vstar.util.locale.NumberParser;
import org.aavso.tools.vstar.util.prefs.NumericPrecisionPrefs;
Expand Down Expand Up @@ -86,6 +87,8 @@ public class StarSelectorDialog extends AbstractOkCancelDialog {
private static Pattern auidPattern = Pattern
.compile("^\\d{3}\\-\\w{3}\\-\\d{3}$");

private String pluginDocName = null;

/**
* Constructor (singleton)
*/
Expand Down Expand Up @@ -142,7 +145,8 @@ private StarSelectorDialog() {
// Default layout manager of content pane is BorderLayout
contentPane.add(leftPane, BorderLayout.LINE_START);
contentPane.add(rightPane, BorderLayout.LINE_END);
contentPane.add(createButtonPane(), BorderLayout.PAGE_END);
//contentPane.add(createButtonPane(), BorderLayout.PAGE_END);
contentPane.add(createButtonPane2(), BorderLayout.PAGE_END);

// this.addWindowListener(this.createWindowListener());

Expand Down Expand Up @@ -269,6 +273,10 @@ public void setStarField(String text) {
starField.setText(text);
}

public void setPluginDocName(String pluginDocName) {
this.pluginDocName = pluginDocName;
}

// GUI components

private JPanel createStarFieldPane() {
Expand Down Expand Up @@ -539,6 +547,10 @@ private String sanitise(String str) {
return str.replace("\'", "");
}

protected void helpAction() {
Help.openPluginHelp(pluginDocName);
}

protected void cancelAction() {
// Nothing to do.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

import org.aavso.tools.vstar.ui.dialog.AbstractOkCancelDialog;
import org.aavso.tools.vstar.ui.mediator.Mediator;
import org.aavso.tools.vstar.util.help.Help;
import org.aavso.tools.vstar.util.model.Harmonic;

/**
Expand Down Expand Up @@ -179,7 +180,7 @@ public List<Harmonic> getHarmonics() {
*/
@Override
protected void helpAction() {
Mediator.openPluginHelp(helpTopic);
Help.openPluginHelp(helpTopic);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import org.aavso.tools.vstar.ui.mediator.DocumentManager;
import org.aavso.tools.vstar.ui.mediator.Mediator;
import org.aavso.tools.vstar.ui.resources.PluginLoader;
import org.aavso.tools.vstar.util.help.Help;

/**
* The plugin management dialog.
Expand Down Expand Up @@ -475,7 +476,7 @@ public void actionPerformed(ActionEvent e) {
String description = (String)(pluginListModel.get(index));
plugin_doc_name = manager.getPluginDocName(description);
}
Mediator.openPluginHelp(plugin_doc_name);
Help.openPluginHelp(plugin_doc_name);
}
};
}
Expand Down
Loading

0 comments on commit 593e0e1

Please sign in to comment.