Skip to content
Snippets Groups Projects
Commit 75fa4b46 authored by Anian Bühler's avatar Anian Bühler
Browse files

added help html files

parent 4ed881a8
No related branches found
No related tags found
1 merge request!1dev_prefereences to master
......@@ -6,7 +6,6 @@ import java.awt.Cursor;
import java.awt.Desktop;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.Insets;
import java.awt.event.ActionEvent;
......@@ -27,7 +26,6 @@ import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
......@@ -35,7 +33,6 @@ import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.KeyStroke;
import javax.swing.ToolTipManager;
import javax.swing.UIManager;
import javax.swing.filechooser.FileFilter;
import javax.swing.filechooser.FileNameExtensionFilter;
......@@ -43,6 +40,7 @@ import com.ardublock.core.Context;
import com.ardublock.ui.listener.ArdublockWorkspaceListener;
import com.ardublock.ui.listener.ButtonMouseListener;
import com.ardublock.ui.listener.GenerateCodeButtonListener;
import com.ardublock.ui.listener.HelpButtonListener;
import com.ardublock.ui.listener.CopyButtonListener;
import com.ardublock.ui.listener.NewButtonListener;
import com.ardublock.ui.listener.OpenButtonListener;
......@@ -61,6 +59,8 @@ import com.ardublock.ui.listener.ZoomInButtonListener;
import com.ardublock.ui.listener.ZoomOutButtonListener;
import edu.mit.blocks.controller.WorkspaceController;
import edu.mit.blocks.workspace.SearchBar;
import edu.mit.blocks.workspace.SearchableContainer;
import edu.mit.blocks.workspace.Workspace;
//import edu.mit.blocks.workspace.ZoomSlider;
import tec.letsgoing.ardublock.simulator.view.GUI;
......@@ -87,6 +87,8 @@ public class OpenblocksFrame extends JFrame
JButton modeProButton = null;
JButton modeSimButton = null;
SearchBar searchBar = null;
public void addListener(OpenblocksFrameListener ofl)
{
context.registerOpenblocksFrameListener(ofl);
......@@ -144,6 +146,8 @@ public class OpenblocksFrame extends JFrame
//display ToolTips for 10 seconds
ToolTipManager.sharedInstance().setDismissDelay(TOOLTIP_DISMISS_DELAY);
searchBar = new SearchBar(uiMessageBundle.getString("ardublock.ui.search"), uiMessageBundle.getString("ardublock.ui.search.tooltip"), workspace);
addSearchableBlocks(workspace);
//NEW
//**********
......@@ -315,7 +319,15 @@ public class OpenblocksFrame extends JFrame
JMenuItem simulatorHelpMenuItem = new JMenuItem(uiMessageBundle.getString("ardublock.ui.simulatorHelp"));
simulatorHelpMenuItem.addActionListener(simulatorHelpButtonListener);
simulatorHelpMenuItem.setToolTipText(uiMessageBundle.getString("ardublock.ui.simulatorHelp.tooltip"));
simulatorHelpMenuItem.setVisible(false); //hide on startUp
//simulatorHelpMenuItem.setVisible(false); //hide on startUp
//HELP
//**************
ActionListener helpButtonListener = new HelpButtonListener(this);
JMenuItem helpMenuItem = new JMenuItem(uiMessageBundle.getString("ardublock.ui.help"));
helpMenuItem.addActionListener(helpButtonListener);
helpMenuItem.setToolTipText(uiMessageBundle.getString("ardublock.ui.help.tooltip"));
//SERIAL MONITOR
......@@ -508,8 +520,10 @@ public class OpenblocksFrame extends JFrame
//TODO: check why blocks are rearranged while changing WS
double currentWorkspaceZoom = workspace.getCurrentWorkspaceZoom();
try {
removeSearchableBlocks(workspace);
WorkspaceController workspaceController = context.getWorkspaceController();
workspaceController.loadProject(getArduBlockString(), null , "default");
addSearchableBlocks(workspace);
generateButton.setVisible(true);
generateMenuItem.setVisible(true);
generateMenuItem.registerKeyboardAction(generateButtonListener, ctrluKeyStroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
......@@ -573,8 +587,10 @@ public class OpenblocksFrame extends JFrame
//TODO: check why blocks are rearanged while changing WS
double currentWorkspaceZoom = workspace.getCurrentWorkspaceZoom();
try {
removeSearchableBlocks(workspace);
WorkspaceController workspaceController = context.getWorkspaceController();
workspaceController.loadProject(getArduBlockString(), null , "custom");
addSearchableBlocks(workspace);
generateButton.setVisible(true);
generateMenuItem.setVisible(true);
generateMenuItem.registerKeyboardAction(generateButtonListener, ctrluKeyStroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
......@@ -636,9 +652,11 @@ public class OpenblocksFrame extends JFrame
double currentWorkspaceZoom = workspace.getCurrentWorkspaceZoom();
try {
removeSearchableBlocks(workspace);
WorkspaceController workspaceController = context.getWorkspaceController();
//TODO check if reduced sim-blockset is necessary
workspaceController.loadProject(getArduBlockString(), null , "page");
addSearchableBlocks(workspace);
generateButton.setVisible(false);
generateMenuItem.setVisible(false);
generateMenuItem.unregisterKeyboardAction(ctrluKeyStroke);
......@@ -776,6 +794,7 @@ public class OpenblocksFrame extends JFrame
JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
JPanel menuePanel = new JPanel(new BorderLayout());//new FlowLayout(FlowLayout.LEFT));
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
JComponent searchBarComponent = searchBar.getComponent();
bottomPanel.setBackground(new Color(40, 76, 102));
buttonPanel.setBackground(new Color(40, 76, 102));
......@@ -787,12 +806,14 @@ public class OpenblocksFrame extends JFrame
JMenu toolsMenu = new JMenu(uiMessageBundle.getString("ardublock.ui.menu.tools"));
JMenu blocksMenu = new JMenu(uiMessageBundle.getString("ardublock.ui.menu.blocks"));
JMenu aboutMenu = new JMenu(uiMessageBundle.getString("ardublock.ui.menu.about"));
JMenu helpMenu = new JMenu(uiMessageBundle.getString("ardublock.ui.menu.help"));
menuBar.add(fileMenu);
menuBar.add(programMenu);
menuBar.add(toolsMenu);
menuBar.add(blocksMenu);
menuBar.add(aboutMenu);
menuBar.add(helpMenu);
fileMenu.add(newMenuItem);
fileMenu.add(openMenuItem);
......@@ -819,9 +840,12 @@ public class OpenblocksFrame extends JFrame
blocksMenu.add(blockreferenceMenuItem);
aboutMenu.add(websiteButtonMenuItem);
aboutMenu.add(simulatorHelpMenuItem);
//aboutMenu.add(simulatorHelpMenuItem);
aboutMenu.add(versionMenuItem);
helpMenu.add(helpMenuItem);
helpMenu.add(simulatorHelpMenuItem);
menuePanel.add(menuBar, BorderLayout.CENTER );
topPanel.add(menuePanel, BorderLayout.NORTH); //TEST
topPanel.add(buttonPanel, BorderLayout.CENTER); //TEST
......@@ -837,12 +861,14 @@ public class OpenblocksFrame extends JFrame
buttonPanel.add(simulatorHelpButton);
buttonPanel.add(serialMonitorButton);
buttonPanel.add(serialPlotterButton);
//buttonPanel.add(Box.createRigidArea(new Dimension(30, 0))); //std value 30,0
bottomPanel.add(modeBasicButton);
bottomPanel.add(modeProButton);
bottomPanel.add(modeSimButton);
bottomPanel.add(Box.createRigidArea(new Dimension(30, 0))); //std value 30,0
bottomPanel.add(context.getWorkspaceController().getSearchBar(uiMessageBundle.getString("ardublock.ui.search"), uiMessageBundle.getString("ardublock.ui.search.tooltip")));
bottomPanel.add(searchBarComponent);
//bottomPanel.add(blockreferenceButton);
//bottomPanel.add(Box.createRigidArea(new Dimension(5, 0))); //std value 30,0
......@@ -1136,6 +1162,22 @@ public class OpenblocksFrame extends JFrame
}
}
private void removeSearchableBlocks(Workspace workspace) {
for (SearchableContainer con : getAllSearchableContainers(workspace)) {
searchBar.removeSearchableContainer(con);
}
}
private void addSearchableBlocks(Workspace workspace) {
for (SearchableContainer con : getAllSearchableContainers(workspace)) {
searchBar.addSearchableContainer(con);
}
}
private Iterable<SearchableContainer> getAllSearchableContainers(Workspace workspace) {
return workspace.getAllSearchableContainers();
}
public void saveProgramAsImage() {
Workspace workspace = context.getWorkspace();
......
package com.ardublock.ui.listener;
import java.awt.Desktop;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.ResourceBundle;
import javax.swing.ImageIcon;
......@@ -26,19 +34,139 @@ public class SimulatorHelpButtonListener implements ActionListener
public void actionPerformed(ActionEvent e) {
//System.out.println("Help is pressed");
ImageIcon icon = new ImageIcon(openBlocksFrame.getToolkit().getImage(GUI.class.getResource("/com/ardublock/block/SimHelp.png")));
/* ImageIcon icon = new ImageIcon(openBlocksFrame.getToolkit().getImage(GUI.class.getResource("/com/ardublock/block/SimHelp.png")));
JOptionPane.showMessageDialog(
null,
uiMessageBundle.getString("ardublock.ui.simulatorHelp.text"),
uiMessageBundle.getString("ardublock.ui.simulatorHelp.title"), JOptionPane.INFORMATION_MESSAGE,
icon);
*/
/*
* JOptionPane.showMessageDialog( null, new JLabel("Hello world", icon,
* JLabel.LEFT), "Hello", JOptionPane.INFORMATION_MESSAGE);
*/
File cssFile = null;
File helpFile = null;
File imageFile = null;
File logoFile = null;
//TODO: add css
String cssResource ="/com/ardublock/reference/_seitenformatierung.css";
String helpResource ="/com/ardublock/reference/simHelp.html";
String logoResource ="/com/ardublock/reference/_Logo_LGI_page.png";
String imageResource ="/com/ardublock/block/SimHelp.png";
String tempPath = "";
//get current .jar path for temp files
try {
tempPath = new File(URLDecoder.decode(getClass().getProtectionDomain().getCodeSource().getLocation().getFile(), "UTF-8")).getParentFile().getPath();
} catch (UnsupportedEncodingException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
//copy css File to tmp files
try {
InputStream input = getClass().getResourceAsStream(cssResource);
if(input != null) {
cssFile = new File(tempPath +"/"+ "_seitenformatierung.css");
OutputStream out = new FileOutputStream(cssFile);
int read;
byte[] bytes = new byte[1024];
while ((read = input.read(bytes)) != -1) {
out.write(bytes, 0, read);
}
out.close();
cssFile.deleteOnExit();
} else {
//TODO: use resources
System.out.println("Sorry, css stylesheet was not found in reference.");
//TODO: open 404-page
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!
}
} catch (IOException ex) {
ex.printStackTrace();
}
//copy help File to tmp files
try {
InputStream input = getClass().getResourceAsStream(helpResource);
if(input != null) {
helpFile = new File(tempPath +"/"+ "simHelp.html");
OutputStream out = new FileOutputStream(helpFile);
int read;
byte[] bytes = new byte[1024];
while ((read = input.read(bytes)) != -1) {
out.write(bytes, 0, read);
}
out.close();
helpFile.deleteOnExit();
} else {
//TODO: use resources
System.out.println("Sorry, help file was not found.");
//TODO: open 404-page
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!
}
} catch (IOException ex) {
ex.printStackTrace();
}
//copy logo to tmp files
try {
InputStream input = getClass().getResourceAsStream(logoResource);
if(input != null) {
logoFile = new File(tempPath +"/_Logo_LGI_page.png");
OutputStream out = new FileOutputStream(logoFile);
int read;
byte[] bytes = new byte[10000];
while ((read = input.read(bytes)) != -1) {
out.write(bytes, 0, read);
}
out.close();
logoFile.deleteOnExit();
} else {
//TODO: use resources
System.out.println("Sorry, logo image was not found.");
}
} catch (IOException ex) {
ex.printStackTrace();
}
//copy block-image to tmp files
try {
InputStream input = getClass().getResourceAsStream(imageResource);
if(input != null) {
imageFile = new File(tempPath +"/simHelp.png");
OutputStream out = new FileOutputStream(imageFile);
int read;
byte[] bytes = new byte[10000];
while ((read = input.read(bytes)) != -1) {
out.write(bytes, 0, read);
}
out.close();
imageFile.deleteOnExit();
} else {
//TODO: use resources
System.out.println("Sorry, image for help was not found in reference.");
}
} catch (IOException ex) {
ex.printStackTrace();
}
//open file in standard browser
if (helpFile != null && !helpFile.exists() && cssFile != null && !cssFile.exists() && imageFile != null && !imageFile.exists() && !logoFile.exists() ) {
throw new RuntimeException("Error: Resource not found!");
}else {
try {
Desktop.getDesktop().browse(helpFile.toURI());
} catch (IOException e1) {
// TODO Auto-generated catch block
//e.printStackTrace();
} catch (NullPointerException e2) {
// TODO Auto-generated catch block
//e.printStackTrace();
}
}
}
}
......@@ -14,6 +14,7 @@ ardublock.ui.menu.program=Program
ardublock.ui.menu.tools=Tools
ardublock.ui.menu.blocks=Blocks
ardublock.ui.menu.about=About
ardublock.ui.menu.help=?
ardublock.ui.new=New
ardublock.ui.new.tooltip=new program
......@@ -73,9 +74,11 @@ ardublock.ui.copy=copy
ardublock.ui.copy.tooltip=copy program to clipboard
ardublock.ui.paste=paste
ardublock.ui.paste.tooltip=paste program from
ardublock.ui.help=Help ArduBlock
ardublock.ui.help.tooltip=Help ArduBlock
ardublock.ui.simulation=simulate
ardublock.ui.simulation.tooltip=start simulation with basic block-set and letsgoING modules
ardublock.ui.simulatorHelp=help
ardublock.ui.simulatorHelp=Help Simulator
ardublock.ui.simulatorHelp.tooltip=About the letsgoING-simulator
ardublock.ui.simulatorHelp.title=About the letsgoING-simulator
ardublock.ui.simulatorHelp.text=
......
......@@ -14,6 +14,7 @@ ardublock.ui.menu.program=Programm
ardublock.ui.menu.tools=Werkzeuge
ardublock.ui.menu.blocks=Blcke
ardublock.ui.menu.about=ber
ardublock.ui.menu.help=?
ardublock.ui.new=Neu
ardublock.ui.new.tooltip=Neues Programm erstellen
......@@ -75,9 +76,11 @@ ardublock.ui.copy=Programm kopieren
ardublock.ui.copy.tooltip=kopiere gesamtes Programm in Zwischenablage
ardublock.ui.paste=Programm einfgen
ardublock.ui.paste.tooltip=fge gesamtes Programm aus Zwischenablage ein
ardublock.ui.help=Hilfe zu ArduBlock
ardublock.ui.help.tooltip=Hilfe zu ArduBlock
ardublock.ui.simulation=Hochladen auf den Simulator
ardublock.ui.simulation.tooltip=Starte den Simulator und lade das Programm hoch
ardublock.ui.simulatorHelp=Hilfe
ardublock.ui.simulatorHelp=Hilfe zum Simulator
ardublock.ui.simulatorHelp.tooltip=Infos zum letsgoING-Simulator
ardublock.ui.simulatorHelp.title=Infos zum letsgoING-Simulator
ardublock.ui.simulatorHelp.text=TASTER\n**********************\nlinke Maustaste -> Taster-Funktion\nrechte oder mittlere Maustaste -> Schalterfunktion (bleibt aktiv)\n\n\n\nPOTI\n**********************\nSlider ziehen oder mit Mausrad verstellen (Mauszeiger ber Slider)\n\n\nSERIALMONITOR\n**********************\nHier werden die Nachrichten vom "Serial.Print"-Block ausgegeben\nAutoscroll:\n an -> neueste Nachrichten werden angezeigt\n aus -> Ausgabe kann manuell ausgewhlt werden\nReset SerialMonitor: bisherige Ausgabe wird gelscht\n\n\n\RESET ARDUINO\n**********************\nTaster startet das Programm neu\n\n\n\ONBOARD LED\n**********************\nLED kann ber Pin13 angesteuert werden
......
......@@ -15,6 +15,8 @@
font-weight: 200;
}
#uebersichtbutton{
float: left;
font-weight: 200;
......@@ -68,6 +70,10 @@
;
}
article li {
float: none;
}
#beschreibung{
padding: 18px;
background-color: #284a66;
......@@ -103,3 +109,4 @@
border-top: 1px solid #000;
display: block;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment