Development Guide

Guide

You can create simple HTML guides and register them to the Guide (F1) using GuiHelper in Extension.initGui().

You can use method loadHtmlResource() to load HTML code from resource file.

In order to create links that will open in user's browser, you have to use the following approach:

<a href="" onclick="petep.openLink('http://example.com/');return false;">Click here!</a></p>

Guide class

com.warxim.petep.gui.guide.Guide
/**
 * Guide base class.
 * (Guides are HTML pages that contain various tutorials, tips and tricks for extension modules and also PETEP core.)
 */
@PetepAPI
public abstract class Guide {
    protected Guide() {
    }

    /**
     * Gets title of the guide
     * @return Guide title
     */
    public abstract String getTitle();

    /**
     * Gets HTML of the guide
     * @return Guide content HTML
     */
    public abstract String getHtml();

    /**
     * Returns content of HTML file from resource path.
     * <p>If the resource does not exist, result will contain error message.</p>
     * @param path Path of HTML resource file to load into string
     */
    protected String loadHtmlResource(String path) {
        try (var in = getClass().getResourceAsStream(path)) {
            return new String(in.readAllBytes(), StandardCharsets.UTF_8);
        } catch (IOException e) {
            return "<p><b>Could not load " + getTitle() + " Guide:</b></p><p>" + e.getMessage() + "</p>";
        }
    }

    /**
     * Returns text displayed in list view in guide dialog.
     */
    public String toString() {
        return getTitle();
    }
}