Added instructions.
This commit is contained in:
parent
f541a994b9
commit
e606b8f9f4
|
@ -0,0 +1,36 @@
|
|||
package nl.andrewlalis.erme.control.actions;
|
||||
|
||||
import nl.andrewlalis.erme.EntityRelationMappingEditor;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
public class AboutAction extends AbstractAction {
|
||||
private static AboutAction instance;
|
||||
|
||||
public static AboutAction getInstance() {
|
||||
if (instance == null) instance = new AboutAction();
|
||||
return instance;
|
||||
}
|
||||
|
||||
public AboutAction() {
|
||||
super("About");
|
||||
this.putValue(SHORT_DESCRIPTION, "Show some information about this program.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
JOptionPane.showMessageDialog(
|
||||
(Component) e.getSource(),
|
||||
"Entity-Relation Mapping Editor\n" +
|
||||
"by Andrew Lalis\n" +
|
||||
"Version " + EntityRelationMappingEditor.VERSION + "\n" +
|
||||
"To report bugs or make suggestions, please visit the GitHub\n" +
|
||||
"repository for this application and create a new issue.\n\n" +
|
||||
"Thank you for using the ERME!",
|
||||
"About ERME",
|
||||
JOptionPane.INFORMATION_MESSAGE
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
package nl.andrewlalis.erme.control.actions;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.HyperlinkEvent;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.io.*;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.file.Files;
|
||||
|
||||
public class InstructionsAction extends AbstractAction {
|
||||
private static InstructionsAction instance;
|
||||
|
||||
public static InstructionsAction getInstance() {
|
||||
if (instance == null) instance = new InstructionsAction();
|
||||
return instance;
|
||||
}
|
||||
|
||||
public InstructionsAction() {
|
||||
super("Instructions");
|
||||
this.putValue(SHORT_DESCRIPTION, "Instructions for how to use this program.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
JDialog dialog = new JDialog(SwingUtilities.getWindowAncestor((Component) e.getSource()), "Instructions", Dialog.ModalityType.APPLICATION_MODAL);
|
||||
JTextPane textPane = new JTextPane();
|
||||
textPane.setEditable(false);
|
||||
textPane.setContentType("text/html");
|
||||
try {
|
||||
textPane.setText(this.readFile());
|
||||
textPane.addHyperlinkListener(event -> {
|
||||
if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
|
||||
if (!Desktop.isDesktopSupported()) {
|
||||
JOptionPane.showMessageDialog(dialog, "Desktop API not supported. You may still visit the link manually:\n" + event.getURL(), "Desktop API Not Supported", JOptionPane.WARNING_MESSAGE);
|
||||
} else {
|
||||
Desktop desktop = Desktop.getDesktop();
|
||||
try {
|
||||
desktop.browse(event.getURL().toURI());
|
||||
} catch (IOException | URISyntaxException ex) {
|
||||
ex.printStackTrace();
|
||||
JOptionPane.showMessageDialog(dialog, "An error occurred and the URL could not be opened:\n" + event.getURL(), "URL Could Not Open", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
JOptionPane.showMessageDialog(
|
||||
(Component) e.getSource(),
|
||||
"An error occured:\n" + ex.getMessage(),
|
||||
"Error",
|
||||
JOptionPane.ERROR_MESSAGE
|
||||
);
|
||||
textPane.setContentType("text/plain");
|
||||
textPane.setText("Unable to load content.");
|
||||
}
|
||||
JScrollPane scrollPane = new JScrollPane(textPane, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||||
dialog.setContentPane(scrollPane);
|
||||
dialog.setMaximumSize(new Dimension(600, 800));
|
||||
dialog.setPreferredSize(new Dimension(600, 800));
|
||||
dialog.pack();
|
||||
dialog.setLocationRelativeTo(null);
|
||||
dialog.setVisible(true);
|
||||
}
|
||||
|
||||
private String readFile() throws IOException {
|
||||
InputStream is = getClass().getClassLoader().getResourceAsStream("html/instructions.html");
|
||||
if (is == null) {
|
||||
throw new IOException("Could not get stream for instructions.html.");
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(is))) {
|
||||
String line = reader.readLine();
|
||||
while (line != null) {
|
||||
sb.append(line).append('\n');
|
||||
line = reader.readLine();
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
package nl.andrewlalis.erme.view;
|
||||
|
||||
import nl.andrewlalis.erme.EntityRelationMappingEditor;
|
||||
import nl.andrewlalis.erme.control.actions.*;
|
||||
import nl.andrewlalis.erme.control.actions.edits.AddAttributeAction;
|
||||
import nl.andrewlalis.erme.control.actions.edits.AddRelationAction;
|
||||
|
@ -8,9 +7,6 @@ import nl.andrewlalis.erme.control.actions.edits.RemoveAttributeAction;
|
|||
import nl.andrewlalis.erme.control.actions.edits.RemoveRelationAction;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
|
||||
/**
|
||||
* The menu bar that's visible atop the application.
|
||||
|
@ -48,28 +44,8 @@ public class EditorMenuBar extends JMenuBar {
|
|||
|
||||
private JMenu buildHelpMenu() {
|
||||
JMenu menu = new JMenu("Help");
|
||||
JMenuItem instructionsItem = new JMenuItem("GitHub (Instructions)");
|
||||
instructionsItem.addActionListener(e -> {
|
||||
try {
|
||||
Desktop.getDesktop().browse(URI.create("https://github.com/andrewlalis/EntityRelationMappingEditor"));
|
||||
} catch (IOException ioException) {
|
||||
ioException.printStackTrace();
|
||||
}
|
||||
});
|
||||
menu.add(instructionsItem);
|
||||
JMenuItem aboutItem = new JMenuItem("About");
|
||||
aboutItem.addActionListener(e -> JOptionPane.showMessageDialog(
|
||||
(Component) e.getSource(),
|
||||
"Entity-Relation Mapping Editor\n" +
|
||||
"by Andrew Lalis\n" +
|
||||
"Version " + EntityRelationMappingEditor.VERSION + "\n" +
|
||||
"To report bugs or make suggestions, please visit the GitHub\n" +
|
||||
"repository for this application and create a new issue.\n\n" +
|
||||
"Thank you for using the ERME!",
|
||||
"About ERME",
|
||||
JOptionPane.INFORMATION_MESSAGE
|
||||
));
|
||||
menu.add(aboutItem);
|
||||
menu.add(InstructionsAction.getInstance());
|
||||
menu.add(AboutAction.getInstance());
|
||||
return menu;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Instructions</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>Entity-Relation Mapping Editor</h1>
|
||||
<p>Created by <a href="https://github.com/andrewlalis">@andrewlalis</a></p>
|
||||
|
||||
<p><em>A simple UI for editing entity-relation mapping diagrams.</em></p>
|
||||
|
||||
<p>
|
||||
Have you noticed any unexpected behavior? Is there something you thing would make a good addition to this application?
|
||||
<a href="https://github.com/andrewlalis/EntityRelationMappingEditor/issues">Create a new issue on GitHub!</a>
|
||||
</p>
|
||||
|
||||
<h3>Instructions for Use</h3>
|
||||
<p>
|
||||
The interface and menus should be pretty self-explanatory, so they'll just be covered here in light detail.
|
||||
</p>
|
||||
<ul>
|
||||
<li>
|
||||
The <em>File</em> menu contains options for creating a new model, saving, loading or exporting a model, and finally an option to quit the program.
|
||||
</li>
|
||||
<li>
|
||||
The <em>Edit</em> menu contains options for making changes to the current model, such as adding or removing relations and attributes, or undoing/redoing actions.
|
||||
</li>
|
||||
<li>
|
||||
The <em>Help</em> menu contains some items with additional information about the application, like this help page and a simple <em>About</em> popup with version information.
|
||||
</li>
|
||||
</ul>
|
||||
<p>
|
||||
The main focus of the application is the <em>Diagram Panel</em> where all of the editing actually takes place. This is where any relations you create, or attributes you create, appear; this is what is rendered when you select the option to export your model to an image.
|
||||
</p>
|
||||
<ul>
|
||||
<li>
|
||||
Click on a relation to select it.
|
||||
</li>
|
||||
<li>
|
||||
CTRL+Click to select multiple relations at once.
|
||||
</li>
|
||||
<li>
|
||||
Drag relations to move them around the workspace.
|
||||
</li>
|
||||
<li>
|
||||
Right-click on different areas to access a context menu with some helpful actions.
|
||||
</li>
|
||||
<li>
|
||||
When exporting the model to an image, be sure to add the desired image file extension (.png, .jpg, .bmp, etc.), or the application will default to .png.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue