edu.mit.csail.sdg.alloy4
Class OurTabbedSyntaxWidget

java.lang.Object
  extended by edu.mit.csail.sdg.alloy4.OurTabbedSyntaxWidget

public final class OurTabbedSyntaxWidget
extends java.lang.Object

Graphical multi-tabbed syntax-highlighting editor.

Thread Safety: Can be called only by the AWT event thread.

Invariant: each tab has distinct file name.


Field Summary
 Listeners listeners
          The current list of listeners; possible events are { STATUS_CHANGE, FOCUSED, CARET_MOVED }.
 
Constructor Summary
OurTabbedSyntaxWidget(java.lang.String fontName, int fontSize, int tabSize)
          Constructs a tabbed editor pane.
 
Method Summary
 void addTo(javax.swing.JComponent newParent, java.lang.Object constraint)
          Add this object into the given container.
 void clearShade()
          Removes all highlights from every text buffer, then adjust the TAB LABEL COLOR if necessary.
 void close()
          Close the current tab (then create a new empty tab if there were no tabs remaining)
 boolean closeAll()
          Close every tab then create a new empty tab; returns true iff success.
 int count()
          Returns the number of tabs.
 void enableSyntax(boolean flag)
          Enables or disables syntax highlighting.
 OurSyntaxWidget get()
          Returns the JTextArea of the current text buffer.
 java.util.List<java.lang.String> getFilenames()
          Returns the list of filenames corresponding to each text buffer.
 boolean modified(int i)
          True if the i-th text buffer has been modified since it was last loaded/saved
 boolean newtab(java.lang.String filename)
          Create a new tab with the given filename (if filename==null, we'll create a blank tab instead)
 void next()
          Switches to the next tab.
 void prev()
          Switches to the previous tab.
 void reloadAll()
          Refresh all tabs.
 java.lang.String save(boolean alwaysPickNewName)
          Save the current tab content to the file system.
 void setFont(java.lang.String name, int size, int tabSize)
          Changes the font name, font size, and tabsize of every text buffer.
 void shade(java.lang.Iterable<Pos> set, java.awt.Color color, boolean clearOldHighlightsFirst)
          Highlights the text editor, based on the location information in the set of Pos objects.
 void shade(Pos pos)
          Highlights the text editor, based on the location information in the Pos object.
 java.util.Map<java.lang.String,java.lang.String> takeSnapshot()
          Return a modifiable map from each filename to its text content (Note: changes to the map does NOT affect this object)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

listeners

public final Listeners listeners
The current list of listeners; possible events are { STATUS_CHANGE, FOCUSED, CARET_MOVED }.

Constructor Detail

OurTabbedSyntaxWidget

public OurTabbedSyntaxWidget(java.lang.String fontName,
                             int fontSize,
                             int tabSize)
Constructs a tabbed editor pane.

Method Detail

addTo

public void addTo(javax.swing.JComponent newParent,
                  java.lang.Object constraint)
Add this object into the given container.


clearShade

public void clearShade()
Removes all highlights from every text buffer, then adjust the TAB LABEL COLOR if necessary.


reloadAll

public void reloadAll()
Refresh all tabs.


save

public java.lang.String save(boolean alwaysPickNewName)
Save the current tab content to the file system.

Parameters:
alwaysPickNewName - - if true, it will always pop up a File Selection dialog box to ask for the filename
Returns:
null if an error occurred (otherwise, return the filename)

close

public void close()
Close the current tab (then create a new empty tab if there were no tabs remaining)


closeAll

public boolean closeAll()
Close every tab then create a new empty tab; returns true iff success.


count

public int count()
Returns the number of tabs.


takeSnapshot

public java.util.Map<java.lang.String,java.lang.String> takeSnapshot()
Return a modifiable map from each filename to its text content (Note: changes to the map does NOT affect this object)


getFilenames

public java.util.List<java.lang.String> getFilenames()
Returns the list of filenames corresponding to each text buffer.


setFont

public void setFont(java.lang.String name,
                    int size,
                    int tabSize)
Changes the font name, font size, and tabsize of every text buffer.


enableSyntax

public void enableSyntax(boolean flag)
Enables or disables syntax highlighting.


get

public OurSyntaxWidget get()
Returns the JTextArea of the current text buffer.


modified

public boolean modified(int i)
True if the i-th text buffer has been modified since it was last loaded/saved


prev

public void prev()
Switches to the previous tab.


next

public void next()
Switches to the next tab.


newtab

public boolean newtab(java.lang.String filename)
Create a new tab with the given filename (if filename==null, we'll create a blank tab instead)

If a text buffer with that filename already exists, we will just switch to it; else we'll read that file into a new tab.

Returns:
false iff an error occurred

shade

public void shade(java.lang.Iterable<Pos> set,
                  java.awt.Color color,
                  boolean clearOldHighlightsFirst)
Highlights the text editor, based on the location information in the set of Pos objects.


shade

public void shade(Pos pos)
Highlights the text editor, based on the location information in the Pos object.