[MOBY-guts] biomoby commit

Eddie Kawas kawas at dev.open-bio.org
Thu Jun 12 16:46:53 UTC 2008


kawas
Thu Jun 12 12:46:53 EDT 2008
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard
In directory dev.open-bio.org:/tmp/cvs-serv31989/src/main/org/biomoby/service/dashboard

Modified Files:
	PerlMoSeSPanel.java 
Log Message:
added a 'line:column' footer for the editor
moby-live/Java/src/main/org/biomoby/service/dashboard PerlMoSeSPanel.java,1.11,1.12
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/PerlMoSeSPanel.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/PerlMoSeSPanel.java	2008/06/05 19:48:13	1.11
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/PerlMoSeSPanel.java	2008/06/12 16:46:52	1.12
@@ -49,6 +49,8 @@
 import javax.swing.SwingConstants;
 import javax.swing.border.Border;
 import javax.swing.border.CompoundBorder;
+import javax.swing.event.CaretEvent;
+import javax.swing.event.CaretListener;
 import javax.swing.filechooser.FileFilter;
 import javax.swing.text.Document;
 import javax.swing.text.EditorKit;
@@ -138,7 +140,7 @@
 
     private CommonConsole console;
 
-    private JLabel aSelectedCount, sSelectedCount, currentlyEditing;
+    private JLabel aSelectedCount, sSelectedCount, currentlyEditing, currentPosition;
 
     private JButton editorSaveButton, editorCloseButton, editorOpenButton, scriptsBtn, generateBtn;
 
@@ -595,9 +597,26 @@
 			.createEmptyBorder(5, 5, 5, 5));
 	p.setBorder(compoundBorder);
 	
+	JPanel footer = new JPanel();
+	footer.setLayout(new BorderLayout());
 	currentlyEditing = new JLabel("");
-
+	currentPosition = new JLabel("");
+	footer.add(currentlyEditing, BorderLayout.WEST);
+	footer.add(currentPosition, BorderLayout.EAST);
+	
 	editorTextPane = new JTextPane();
+	editorTextPane.addCaretListener(new CaretListener(){
+	    public void caretUpdate(CaretEvent e) {
+		int dot = e.getDot();
+		//get current line
+		int line = ((JTextPane)e.getSource()).getDocument().getDefaultRootElement().getElementIndex(dot);
+		// get the position on the line
+		int pos = dot - ((JTextPane)e.getSource()).getDocument().getDefaultRootElement().getElement(line).getStartOffset();
+		//System.out.println("line: "+line + " column: "+ pos);
+		line++; pos++;
+		currentPosition.setText(line + ":"+ pos);
+		
+	    }});
 	
 	EditorKit editorKit = new StyledEditorKit() {
 	    private static final long serialVersionUID = 1L;
@@ -623,7 +642,7 @@
 	JScrollPane scrollPane = new JScrollPane(editorTextPane);
 	
 	p.add(getFontChooser(), BorderLayout.PAGE_START);
-	p.add(currentlyEditing, BorderLayout.PAGE_END);
+	p.add(footer, BorderLayout.PAGE_END);
 	p.add(scrollPane, BorderLayout.CENTER);
 	// set the default font
 	Font f = new Font(fonts.getSelectedItem().toString(), editorTextPane.getFont().getStyle(), editorTextPane.getFont().getSize());
@@ -1254,8 +1273,9 @@
 	    }
 	    propertyChannel.put(PM_FILE_CURRENT_CHECKSUM, getMD5Checksum(sb.toString()));
 	    editorTextPane.setText(sb.toString());
-	    editorTextPane.setCaretPosition(0);
 	    currentlyEditing.setText("Editing: " + f.getAbsolutePath());
+	    currentPosition.setText("");
+	    editorTextPane.setCaretPosition(0);
 	    editorTextPane.setEditable(true);
 	    editorCloseButton.setEnabled(true);
 	    editorSaveButton.setEnabled(true);
@@ -1279,6 +1299,7 @@
 	}
 	editorTextPane.setText("");
 	currentlyEditing.setText("");
+	currentPosition.setText("");
 	editorTextPane.setEditable(false);
 	editorCloseButton.setEnabled(false);
 	editorSaveButton.setEnabled(false);




More information about the MOBY-guts mailing list