소스 검색

Improves Help Menu (adds Links to the Wiki)

Refactors and Comments the old Help Menu.
4 new Help MenuItems, opening a Wiki page in the browser.
Andreas T. Meyer-Berg 7 년 전
부모
커밋
12019323b2
1개의 변경된 파일94개의 추가작업 그리고 4개의 파일을 삭제
  1. 94 4
      src/ui/view/GUI.java

+ 94 - 4
src/ui/view/GUI.java

@@ -31,6 +31,8 @@ import java.awt.datatransfer.UnsupportedFlavorException;
 import java.awt.event.*;
 import java.io.File;
 import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Timer;
@@ -43,14 +45,43 @@ import java.util.stream.Collectors;
  * @author Gruppe14
  */
 public class GUI implements CategoryListener {
-
-	private final AlgorithmMenu algorithmMenu;
+	
+	/**
+	 * Menu on the Top containing File, Edit View Help etc
+	 */
 	private final JMenuBar menuBar = new JMenuBar();
+	
 	private final JMenu mnNewMenu = new JMenu("File");
 	private final JMenu mnNewMenuEdit = new JMenu("Edit");
 	private final JMenu mnNewMenuOptions = new JMenu("Options");
 	private final JMenu mnNewMenuView = new JMenu("View");
+	private final AlgorithmMenu algorithmMenu;
+	
+	/** Help Menu containing helpful Informations and the AboutUs Popup */
 	private final JMenu mnHelp = new JMenu("Help");
+	
+	/** 
+	 * Help -> Introduction
+	 * A small Introduction of the Application, SmartGrids and Holons 
+	 */
+	private final JMenuItem mntmIntroduction = new JMenuItem("Introduction");
+
+	/** 
+	 * Help -> UserManual
+	 */
+	private final JMenuItem mntmUserManual = new JMenuItem("User Manual");
+	
+	/** Help -> Algorithm Help Menu */
+	private final JMenuItem mntmAlgorithmHelp = new JMenuItem("Algorithm Introduction");
+	
+	/** Help -> CodeDocumentation */
+	private final JMenuItem mntmCodeDoc = new JMenuItem("Code Documentation");
+	
+	/** Help -> AboutUs */
+	private final JMenuItem mntmAboutUs = new JMenuItem("About Us");
+	
+	
+	
 	private final JCheckBox consoleLogCheckBox = new JCheckBox(
 			"Show program console log");
 	private final JCheckBox useFlexibleDevicesCheckBox = new JCheckBox(
@@ -69,7 +100,6 @@ public class GUI implements CategoryListener {
 	private final JMenuItem mntmOpen = new JMenuItem("Open");
 	private final JMenuItem mntmNew = new JMenuItem("New");
 	private final JMenuItem mntmSave = new JMenuItem("Save");
-	private final JMenuItem mntmAboutUs = new JMenuItem("About Us");
 	private final JMenuItem mntmCanvasSize = new JMenuItem("View Size");
 	private final JMenuItem mntmBackground = new JMenuItem("Background Image");
 	private final JMenuItem mntmSplitView = new JMenuItem("Split View");
@@ -935,8 +965,14 @@ public class GUI implements CategoryListener {
 
 		menuBar.add(algorithmMenu);
 
+		/**
+		 * add Help Menu and its items
+		 */
 		menuBar.add(mnHelp);
-
+		mnHelp.add(mntmIntroduction); 
+		mnHelp.add(mntmUserManual); 
+		mnHelp.add(mntmAlgorithmHelp); 
+		mnHelp.add(mntmCodeDoc);
 		mnHelp.add(mntmAboutUs);
 
 		tabbedPaneOriginal.addChangeListener(changeEvent -> {
@@ -1920,6 +1956,48 @@ public class GUI implements CategoryListener {
 			}
 			tree.repaint();
 		});
+		
+		/**
+		 * Help Menu Action Listeners
+		 */
+		
+		/**
+		 * URL of the telecommunication git Wiki
+		 */
+		String tkWikiWebpage = "https://git.tk.informatik.tu-darmstadt.de/carlos.garcia/praktikum-holons/wiki/";
+		
+		/** open Introduction Web Page */
+		mntmIntroduction.addMouseListener(new MouseAdapter() {
+			@Override
+			public void mousePressed(MouseEvent e){
+				openWebpage(tkWikiWebpage + "Introduction+V2.1");
+			}
+		});
+		
+		/** open UserManual WebPage */
+		mntmUserManual.addMouseListener(new MouseAdapter() {
+			@Override
+			public void mousePressed(MouseEvent e){
+				openWebpage(tkWikiWebpage + "User+Manual+V2.1");
+			}
+		});
+		
+		/** open Algorithm Help Web Page*/
+		mntmAlgorithmHelp.addMouseListener(new MouseAdapter() {
+			@Override
+			public void mousePressed(MouseEvent e){
+				openWebpage(tkWikiWebpage + "Algorithms+V2.1");
+			}
+		});
+		
+		/** open Code Documentation Web Page */
+		mntmCodeDoc.addMouseListener(new MouseAdapter() {
+			@Override
+			public void mousePressed(MouseEvent e){
+				openWebpage(tkWikiWebpage + "Code+documentation+V2.1");
+			}
+		});
+		
 		/**
 		 * Pop up - About Us with some important information about the
 		 * developers, source and programming stuff
@@ -2885,4 +2963,16 @@ public class GUI implements CategoryListener {
 	public void updateIterations() {
 		this.statSplitPane.updateIterations();
 	}
+	
+	private void openWebpage(String URL){
+		try {
+			java.awt.Desktop.getDesktop().browse(new URI(URL));
+		} catch (IOException e1) {
+			// TODO Auto-generated catch block
+			e1.printStackTrace();
+		} catch (URISyntaxException e1) {
+			// TODO Auto-generated catch block
+			e1.printStackTrace();
+		}
+	}
 }