Skip to content

Commit

Permalink
IPlugin.getDocName() may return a document file name (located in the …
Browse files Browse the repository at this point in the history
…plug-in doc library) or a full document URL.
  • Loading branch information
mpyat2 committed Nov 6, 2023
1 parent 517abf6 commit d8410e8
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public String getDisplayName() {
*/
@Override
public String getDocName() {
return "AAVSOUploadFileFormatObservationSource.pdf";
return "https://github.com/AAVSO/VStar/wiki/Observation-Source-Plug%E2%80%90ins#aavso-upload-file-visual-and-extended-format-reader";
}

class AAVSOUploadFileFormatRetriever extends AbstractObservationRetriever {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public String getDisplayName() {
*/
@Override
public String getDocName() {
return "ASAS-SN Plug-In.pdf";
return "AoV Period Analysis Plug-In.pdf";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public String getDescription() {
*/
@Override
public String getDocName() {
return "BMinusVObservationSource.pdf";
return "https://github.com/AAVSO/VStar/wiki/Observation-Source-Plug%E2%80%90ins#b-v-series-creator";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public String getDisplayName() {
*/
@Override
public String getDocName() {
return "DescStatsBySeries.pdf";
return "https://github.com/AAVSO/VStar/wiki/Observation-Tool-Plug%E2%80%90ins#descriptive-statistics-by-series";
}

// The calcMedian method can be moved to DescStats;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public String getDisplayName() {
*/
@Override
public String getDocName() {
return "JDToDateTool.pdf";
return("https://github.com/AAVSO/VStar/wiki/General-Tool-Plug%E2%80%90ins#name-convert-jd-to-calendar-date");
}

// Current Julian Day value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public String getDisplayName() {
*/
@Override
public String getDocName() {
return "JulianDateObservationsFilter.pdf";
return "https://github.com/AAVSO/VStar/wiki/Custom-Filter-Plug%E2%80%90ins#julian-date-observations-filter";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public String getDisplayName() {
*/
@Override
public String getDocName() {
return "Lightkurve_FITS_observation_source.pdf";
return "https://github.com/AAVSO/VStar/wiki/Observation-Source-Plug%E2%80%90ins#lightkurve-fits-file-reader";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public String getDisplayName() {
*/
@Override
public String getDocName() {
return "MeanTimeBetweenSelectionTool.pdf";
return "https://github.com/AAVSO/VStar/wiki/Observation-Tool-Plug%E2%80%90ins#mean-time-between-selections-accumulator";
}

@SuppressWarnings("serial")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public String getDisplayName() {
*/
@Override
public String getDocName() {
return "ObserverListFilter.pdf";
return "https://github.com/AAVSO/VStar/wiki/Custom-Filter-Plug%E2%80%90ins#filter-for-list-of-observers";
}

public String[] getObserverList() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public String getDisplayName() {
*/
@Override
public String getDocName() {
return "ObserversBySeries.pdf";
return "https://github.com/AAVSO/VStar/wiki/Observation-Tool-Plug%E2%80%90ins#observers-by-series";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLEncoder;
import java.util.HashSet;
import java.util.LinkedHashSet;
Expand Down Expand Up @@ -477,19 +481,41 @@ public void actionPerformed(ActionEvent e) {
String description = (String)(pluginListModel.get(index));
String plugin_doc_name = manager.getPluginDocName(description);
if (plugin_doc_name != null) {
try {
plugin_doc_name = URLEncoder.encode(plugin_doc_name, "UTF-8");
} catch (UnsupportedEncodingException ex) {
plugin_doc_name = "";
// plugin_doc_name can be a file name (without path) resided in the base plug-in doc directory.
// In this case it may contain spaces and other special characters.
// Or it can be a document URL, in this case, spaces and special characters must be properly encoded (i.e. %20 instead of space).
// First, we try to convert the string into URI.
// If the conversion was successful, the string is presumably a full document path.
// If not, consider it as a file name.
URI uri = getURIfromStringSafe(plugin_doc_name);
if (uri != null) {
urlStr = uri.toString();
}
else {
try {
plugin_doc_name = URLEncoder.encode(plugin_doc_name, "UTF-8").replace("+", "%20");
} catch (UnsupportedEncodingException ex) {
plugin_doc_name = "";
}
urlStr = urlStr += plugin_doc_name;
}
urlStr += plugin_doc_name.replace("+", "%20");
}
}
Mediator.openHelpURLInWebBrowser(urlStr);
}
};
}

private URI getURIfromStringSafe(String s) {
try {
return (new URL(s)).toURI();
} catch (MalformedURLException ex) {
return null;
} catch (URISyntaxException ex) {
return null;
}
}

// Return a listener for the "Close Program" button.
private ActionListener createCloseProgramButtonListener() {
return new ActionListener() {
Expand Down

0 comments on commit d8410e8

Please sign in to comment.