Anonymous avatar Anonymous committed 37f149c

Added events

Comments (0)

Files changed (2)

tailog/src/magmax/tailog/gui/MainWindow.java

 	private JFrame mainFrame;
 	private JTable mainTable;
 	private ModelChangedLines mainModel;
+	private ModelFileTree modelFiles;
 
 	private MainWindow() {
 		createMainFrame();
 	}
 
 	private void createMenu() {
-		JMenuBar menubar = new JMenuBar();
-
-		menubar.add(getMenuFile());
-		menubar.add(getWindowFile());
-
+		MenuBar menubar = new MenuBar();
 		menubar.setVisible(true);
 		mainFrame.getContentPane().add(menubar, BorderLayout.PAGE_START);
 		mainFrame.pack();
 	}
 
-	private JMenu getWindowFile() {
-		JMenu result = new JMenu("Window");
+	private void createFileBar() {
 
-		JMenuItem open = new JMenuItem("Tile");
-		open.setAction(new TileWindowsAction());
-		result.add(open);
-
-		return result;
-	}
-
-	private class TileWindowsAction extends AbstractAction {
-
-		@Override
-		public void actionPerformed(ActionEvent arg0) {
-
-		}
-
-	}
-
-	private void createFileBar() {
-		JTree tree = new JTree();
+		modelFiles = new ModelFileTree();
+		JTable tree = new JTable(modelFiles);
 
 		tree.setVisible(true);
 		mainFrame.getContentPane().add(tree, BorderLayout.WEST);
 		mainFrame.pack();
 	}
 
-	private class OpenWatcherWindowAction extends AbstractAction {
+	class MenuBar extends JMenuBar {
 		private static final long serialVersionUID = 1L;
 
-		public OpenWatcherWindowAction() {
-			super("Open");
+		public MenuBar() {
+			super();
+			add(getMenuFile());
+			add(getMenuEvents());
 		}
 
-		@Override
-		public void actionPerformed(ActionEvent e) {
-			JFileChooser chooser = new JFileChooser();
-			if (chooser.showOpenDialog(mainFrame) == JFileChooser.APPROVE_OPTION) {
-				File file = chooser.getSelectedFile();
-				try {
-					mainModel.addFile(file);
-				} catch (IOException e1) {
-					// TODO Auto-generated catch block
-					e1.printStackTrace();
+		private JMenu getMenuEvents() {
+			JMenu result = new JMenu("Events");
+
+			JMenuItem open = new JMenuItem("Set Date Mark");
+			open.setAction(new SetDateMarkAction());
+			result.add(open);
+			
+			JSeparator sep = new JSeparator();
+			result.add(sep);
+
+			JMenuItem clear = new JMenuItem("Clear");
+			clear.setAction(new ClearAction());
+			result.add(clear);
+			return result;
+		}
+
+		private class ClearAction extends AbstractAction {
+			private static final long serialVersionUID = 1L;
+
+			@Override
+			public void actionPerformed(ActionEvent e) {
+				mainModel.clear();
+			}
+		}
+
+		
+		private class SetDateMarkAction extends AbstractAction {
+			private static final long serialVersionUID = 1L;
+
+			@Override
+			public void actionPerformed(ActionEvent e) {
+				mainModel.addDateLine();
+			}
+		}
+
+		private class OpenWatcherWindowAction extends AbstractAction {
+			private static final long serialVersionUID = 1L;
+
+			public OpenWatcherWindowAction() {
+				super("Open");
+			}
+
+			@Override
+			public void actionPerformed(ActionEvent e) {
+				JFileChooser chooser = new JFileChooser();
+				if (chooser.showOpenDialog(mainFrame) == JFileChooser.APPROVE_OPTION) {
+					File file = chooser.getSelectedFile();
+					try {
+						modelFiles.addFile(file);
+						mainModel.addFile(file);
+					} catch (IOException e1) {
+						// TODO Auto-generated catch block
+						e1.printStackTrace();
+					}
 				}
 			}
 		}
-	}
 
-	private class CloseAction extends AbstractAction {
-		private static final long serialVersionUID = 1L;
+		private class CloseAction extends AbstractAction {
+			private static final long serialVersionUID = 1L;
 
-		public CloseAction() {
-			super("Close");
+			public CloseAction() {
+				super("Close");
+			}
+
+			@Override
+			public void actionPerformed(ActionEvent e) {
+				mainFrame.setVisible(false);
+				mainFrame.dispose();
+			}
 		}
 
-		@Override
-		public void actionPerformed(ActionEvent e) {
-			mainFrame.setVisible(false);
-			mainFrame.dispose();
+		private JMenu getMenuFile() {
+			JMenu result = new JMenu("File");
+
+			JMenuItem open = new JMenuItem("Open");
+			open.setAction(new OpenWatcherWindowAction());
+			result.add(open);
+
+			JSeparator sep = new JSeparator();
+			result.add(sep);
+
+			JMenuItem close = new JMenuItem("Close");
+			close.setAction(new CloseAction());
+			result.add(close);
+			return result;
 		}
 	}
-
-	private JMenu getMenuFile() {
-		JMenu result = new JMenu("File");
-
-		JMenuItem open = new JMenuItem("Open");
-		open.setAction(new OpenWatcherWindowAction());
-		result.add(open);
-
-		JSeparator sep = new JSeparator();
-		result.add(sep);
-
-		JMenuItem close = new JMenuItem("Close");
-		close.setAction(new CloseAction());
-		result.add(close);
-		return result;
-	}
-
 }

tailog/src/magmax/tailog/gui/ModelChangedLines.java

 
 	public void clear() {
 		lines.clear();
+		fireTableDataChanged();
 	}
 
 	public void addFile(File file) throws IOException {
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.