|
[ jEdit-CVS ] plugins/Navigator/src/ise/plugin/nav Navigator.java,1.16,1.17 OptionPanel.java,1.5,1.6
From: Alan Ezust <ezust@us...> - 2005-12-28 17:37
|
Update of /cvsroot/jedit/plugins/Navigator/src/ise/plugin/nav
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19434/src/ise/plugin/nav
Modified Files:
Navigator.java OptionPanel.java
Log Message:
... and Code formatting.
Index: Navigator.java
===================================================================
RCS file: /cvsroot/jedit/plugins/Navigator/src/ise/plugin/nav/Navigator.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- Navigator.java 28 Dec 2005 17:36:06 -0000 1.16
+++ Navigator.java 28 Dec 2005 17:37:41 -0000 1.17
@@ -10,38 +10,44 @@
import org.gjt.sp.jedit.jEdit;
import org.gjt.sp.jedit.textarea.JEditTextArea;
-
/**
* NavigatorPlugin for keeping track of where we were and where.
+ *
* @author Dale Anson
* @author Alan Ezust
*
* @version $Id$
*/
-public class Navigator implements ActionListener
+public class Navigator implements ActionListener
{
- private class DontBother extends Exception {}
+ private class DontBother extends Exception
+ {
+ }
- /** Action command to go to the previous item. */
- public final static String BACK = "back";
- /** Action command to go to the next item. */
- public final static String FORWARD = "forward";
- /** Action command to indicate that it is okay to go back. */
- public final static String CAN_GO_BACK = "canGoBack";
- /** Action command to indicate that it is not okay to go back. */
- public final static String CANNOT_GO_BACK = "cannotGoBack";
- /** Action command to indicate that it is okay to go forward. */
- public final static String CAN_GO_FORWARD = "canGoForward";
- /** Action command to indicate that it is not okay to go forward. */
- public final static String CANNOT_GO_FORWARD = "cannotGoForward";
+ /** Action command to go to the previous item. */
+ public final static String BACK = "back";
+
+ /** Action command to go to the next item. */
+ public final static String FORWARD = "forward";
+
+ /** Action command to indicate that it is okay to go back. */
+ public final static String CAN_GO_BACK = "canGoBack";
+
+ /** Action command to indicate that it is not okay to go back. */
+ public final static String CANNOT_GO_BACK = "cannotGoBack";
+
+ /** Action command to indicate that it is okay to go forward. */
+ public final static String CAN_GO_FORWARD = "canGoForward";
+
+ /** Action command to indicate that it is not okay to go forward. */
+ public final static String CANNOT_GO_FORWARD = "cannotGoForward";
-
private Stack backStack;
private Stack forwardStack;
private DefaultButtonModel backButtonModel;
-
+
private DefaultButtonModel forwardButtonModel;
private Object currentNode = null;
@@ -52,12 +58,11 @@
private boolean ignoreUpdates;
-
public Navigator(View view)
{
this(view, "");
}
-
+
/**
* Constructor for Navigator
*
@@ -71,20 +76,22 @@
backButtonModel = new DefaultButtonModel();
forwardButtonModel = new DefaultButtonModel();
ignoreUpdates = false;
-
- backButtonModel.setActionCommand( Navigator.BACK );
- forwardButtonModel.setActionCommand( Navigator.FORWARD );
- backButtonModel.addActionListener( this );
- forwardButtonModel.addActionListener( this );
-
+
+ backButtonModel.setActionCommand(Navigator.BACK);
+ forwardButtonModel.setActionCommand(Navigator.FORWARD);
+ backButtonModel.addActionListener(this);
+ forwardButtonModel.addActionListener(this);
+
// set up the history stacks
backStack = new Stack();
forwardStack = new Stack();
clearStacks();
update();
- /* add a mouse listener to the view. Each mouse click on a text
- area in the view is stored */
+ /*
+ * add a mouse listener to the view. Each mouse click on a text
+ * area in the view is stored
+ */
view.getTextArea().getPainter().addMouseListener(new MouseAdapter()
{
@@ -93,46 +100,59 @@
update();
}
});
-
+
}
- public ButtonModel getBackModel() {
+ public ButtonModel getBackModel()
+ {
return backButtonModel;
}
-
- NavPosition currentPosition() throws DontBother {
+
+ NavPosition currentPosition() throws DontBother
+ {
Buffer b = view.getBuffer();
JEditTextArea ta = view.getTextArea();
- if (ta == null) throw new DontBother();
+ if (ta == null)
+ throw new DontBother();
int cp = ta.getCaretPosition();
if ((cp == 0) && b.getName().startsWith("Untitled"))
throw new DontBother();
NavPosition retval = new NavPosition(b, cp);
return retval;
}
-
+
/** push current position onto the forward stack */
- public void pushForward()
+ public void pushForward()
{
- try {
+ try
+ {
forwardStack.push(currentPosition());
- } catch (DontBother e) {}
+ }
+ catch (DontBother e)
+ {
+ }
}
-
- public void update() {
- if (ignoreUpdates) {
+
+ public void update()
+ {
+ if (ignoreUpdates)
+ {
return;
}
- try {
+ try
+ {
update(currentPosition());
- }
- catch (DontBother db) {}
+ }
+ catch (DontBother db)
+ {
+ }
}
-
- public ButtonModel getForwardModel() {
+
+ public ButtonModel getForwardModel()
+ {
return forwardButtonModel;
}
-
+
/**
* Updates the stacks and button state based on the given node. Pushes
* the node on to the "back" history, clears the "forward" history.
@@ -153,37 +173,42 @@
setButtonState();
}
- /**
- * The action handler for this class. Actions can be invoked by
- * calling this method and passing an ActionEvent with one of
- * the action commands defined in this class (BACK, FORWARD,
- * etc).
- *
- * @param ae
- * the action event to kick a response.
- */
- public void actionPerformed( ActionEvent ae ) {
- if ( ae.getActionCommand().equals( BACK ) ) {
- goBack();
- }
- else if ( ae.getActionCommand().equals( FORWARD ) ) {
- goForward();
- }
- else if ( ae.getActionCommand().equals( CAN_GO_BACK ) ) {
- backButtonModel.setEnabled( true );
- }
- else if ( ae.getActionCommand().equals( CANNOT_GO_BACK ) ) {
- backButtonModel.setEnabled( false );
- }
- else if ( ae.getActionCommand().equals( CAN_GO_FORWARD ) ) {
- forwardButtonModel.setEnabled( true );
- }
- else if ( ae.getActionCommand().equals( CANNOT_GO_FORWARD ) ) {
- forwardButtonModel.setEnabled( false );
- }
- }
+ /**
+ * The action handler for this class. Actions can be invoked by calling
+ * this method and passing an ActionEvent with one of the action
+ * commands defined in this class (BACK, FORWARD, etc).
+ *
+ * @param ae
+ * the action event to kick a response.
+ */
+ public void actionPerformed(ActionEvent ae)
+ {
+ if (ae.getActionCommand().equals(BACK))
+ {
+ goBack();
+ }
+ else if (ae.getActionCommand().equals(FORWARD))
+ {
+ goForward();
+ }
+ else if (ae.getActionCommand().equals(CAN_GO_BACK))
+ {
+ backButtonModel.setEnabled(true);
+ }
+ else if (ae.getActionCommand().equals(CANNOT_GO_BACK))
+ {
+ backButtonModel.setEnabled(false);
+ }
+ else if (ae.getActionCommand().equals(CAN_GO_FORWARD))
+ {
+ forwardButtonModel.setEnabled(true);
+ }
+ else if (ae.getActionCommand().equals(CANNOT_GO_FORWARD))
+ {
+ forwardButtonModel.setEnabled(false);
+ }
+ }
-
/**
* Removes an invalid node from the navigation history.
*
@@ -239,9 +264,10 @@
view.getTextArea().setCaretPosition(caret, true);
return;
}
-
- // Stop listening to EditBus events while we are changing buffers
- ignoreUpdates= true;
+
+ // Stop listening to EditBus events while we are changing
+ // buffers
+ ignoreUpdates = true;
// check if buffer is open
Buffer[] buffers = jEdit.getBuffers();
@@ -260,7 +286,7 @@
// buffer isn't open
String path = buffer.getPath();
buffer = jEdit.openFile(view, path);
-
+
// Now we can listen to events again
ignoreUpdates = false;
@@ -291,40 +317,48 @@
view.getTextArea().requestFocus();
}
+ /** Moves to the previous item in the "back" history. */
+ public void goBack()
+ {
+ if (!backStack.empty())
+ {
+ try
+ {
+ forwardStack.push(currentPosition());
+ }
+ catch (DontBother db)
+ {
+ }
- /** Moves to the previous item in the "back" history. */
- public void goBack() {
- if ( !backStack.empty() ) {
- try {
- forwardStack.push( currentPosition() );
- }
- catch (DontBother db) {}
-
- if (forwardStack.size() > maxStackSize)
- forwardStack.removeElementAt(0);
- currentNode = backStack.pop();
- setPosition( currentNode );
- setButtonState();
- }
-
- }
+ if (forwardStack.size() > maxStackSize)
+ forwardStack.removeElementAt(0);
+ currentNode = backStack.pop();
+ setPosition(currentNode);
+ setButtonState();
+ }
- /** Moves to the next item in the "forward" history. */
- public void goForward() {
-
- if ( !forwardStack.empty() ) {
- try {
- currentNode = currentPosition();
- backStack.push( currentNode );
- }
- catch (DontBother db) {}
+ }
- if (backStack.size() > maxStackSize)
- backStack.removeElementAt(0);
- currentNode = forwardStack.pop();
- setPosition ( currentNode );
- setButtonState();
- }
- }
-}
+ /** Moves to the next item in the "forward" history. */
+ public void goForward()
+ {
+
+ if (!forwardStack.empty())
+ {
+ try
+ {
+ currentNode = currentPosition();
+ backStack.push(currentNode);
+ }
+ catch (DontBother db)
+ {
+ }
+ if (backStack.size() > maxStackSize)
+ backStack.removeElementAt(0);
+ currentNode = forwardStack.pop();
+ setPosition(currentNode);
+ setButtonState();
+ }
+ }
+}
Index: OptionPanel.java
===================================================================
RCS file: /cvsroot/jedit/plugins/Navigator/src/ise/plugin/nav/OptionPanel.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- OptionPanel.java 28 Dec 2005 17:36:06 -0000 1.5
+++ OptionPanel.java 28 Dec 2005 17:37:41 -0000 1.6
@@ -8,31 +8,34 @@
/**
* @author Dale Anson
*/
-public class OptionPanel extends AbstractOptionPane {
+public class OptionPanel extends AbstractOptionPane
+{
- private JCheckBox showOnToolbar = null;
+ private JCheckBox showOnToolbar = null;
- public OptionPanel( String name ) {
- super( name );
- }
+ public OptionPanel(String name)
+ {
+ super(name);
+ }
- public void _init() {
- String[] stackChoices = new String[] {
- jEdit.getProperty("navigator.back.label"),
- jEdit.getProperty("navigator.forward.label") };
+ public void _init()
+ {
+ String[] stackChoices = new String[] { jEdit.getProperty("navigator.back.label"),
+ jEdit.getProperty("navigator.forward.label") };
- addComponent( new JLabel( "<html><h3>Navigator</h3>" ) );
- showOnToolbar = new JCheckBox( "Show Navigator on toolbar (buggy)" );
-
- }
-
+ addComponent(new JLabel("<html><h3>Navigator</h3>"));
+ showOnToolbar = new JCheckBox("Show Navigator on toolbar (buggy)");
- public void _save() {
- boolean useToolBars = showOnToolbar.isSelected();
- jEdit.setBooleanProperty( getName() + ".showOnToolbar", useToolBars );
- }
+ }
- public String getName() {
- return "navigator";
- }
+ public void _save()
+ {
+ boolean useToolBars = showOnToolbar.isSelected();
+ jEdit.setBooleanProperty(getName() + ".showOnToolbar", useToolBars);
+ }
+
+ public String getName()
+ {
+ return "navigator";
+ }
}
|
| Thread | Author | Date |
|---|---|---|
| [ jEdit-CVS ] plugins/Navigator/src/ise/plugin/nav Navigator.java,1.16,1.17 OptionPanel.java,1.5,1.6 | Alan Ezust <ezust@us...> |