guk.editIM
Class EditIM

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Window
                    |
                    +--java.awt.Frame
                          |
                          +--javax.swing.JFrame
                                |
                                +--guk.editIM.EditIM
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, java.util.EventListener, java.awt.image.ImageObserver, javax.swing.event.ListSelectionListener, java.awt.MenuContainer, javax.swing.RootPaneContainer, java.io.Serializable, javax.swing.WindowConstants

public class EditIM
extends javax.swing.JFrame
implements java.awt.event.ActionListener, javax.swing.event.ListSelectionListener

EditIM.java in guk.editIM: An Editor for Input Methods (for their keymap files, that is). Main file of the Input Method Editor.

See Also:
Serialized Form

Inner classes inherited from class javax.swing.JFrame
javax.swing.JFrame.AccessibleJFrame
 
Inner classes inherited from class java.awt.Frame
java.awt.Frame.AccessibleAWTFrame
 
Inner classes inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.AWTTreeLock
 
Field Summary
(package private)  javax.swing.JToggleButton blockIMButton
          The button to select NONE as the current GUK IM.
(package private)  FileCommands fileCommandProcessor
          the fileCommandProcessor is responsible for reading, writing and merging files into the editor.
(package private)  javax.swing.JFrame frame
          The frame that we are.
(package private)  javax.swing.JPanel glyphBar
          The glyphBar is a whole panel where another class can create additional user interface elements.
(package private)  javax.swing.JButton glyphButton
          a button that serves as a glyph preview window.
(package private)  char glyphChar
          The char that is currently visible on the glyph preview button.
(package private)  LocaleHotkey[] hotkeys
          Ten buttons, each selecting ONE of the GUK IMs as the IM that is used to edit the tables and the jumpField.
(package private)  java.lang.Object imControl
          Have a global InputMethod control object for virtual keyboard control and maybe other things.
(package private)  java.util.List installedLocales
          We collect lists of installed locales and unicode ranges here.
(package private)  javax.swing.JTextField jumpField
          Here, the user can enter a glyph or a glyph number, preferrably in \\u12ab syntax, to scroll to that glyph.
(package private)  MenuHelpers menu
          The MenuHelpers class provides functions like creating menu items and buttons.
(package private)  javax.swing.JLabel statusBar
          A status bar, and the frame that represents the this-object.
(package private)  EditIMPopups subMenuProcessor
          the subMenuProcessor is used to display some sub menus.
(package private)  javax.swing.JTable table1
          The first table is implemented in GlyphTable.java as data model.
(package private)  javax.swing.JTable table2
          The second table (for many to many compositions, using the data model defined in StringTable.java).
 
Fields inherited from class javax.swing.JFrame
accessibleContext, defaultCloseOperation, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Frame
base, CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, frameSerializedDataVersion, HAND_CURSOR, icon, ICONIFIED, mbManagement, menuBar, MOVE_CURSOR, N_RESIZE_CURSOR, nameCounter, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, ownedWindows, resizable, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, serialVersionUID, state, SW_RESIZE_CURSOR, TEXT_CURSOR, title, W_RESIZE_CURSOR, WAIT_CURSOR, weakThis
 
Fields inherited from class java.awt.Window
active, dbg, focusMgr, inputContext, inputContextLock, OPENED, ownedWindowList, showWithParent, warningString, windowListener, windowSerializedDataVersion
 
Fields inherited from class java.awt.Container
component, containerListener, containerSerializedDataVersion, dispatcher, layoutMgr, listeningBoundsChildren, listeningChildren, maxSize, ncomponents, printing, printingThreads
 
Fields inherited from class java.awt.Component
actionListenerK, adjustmentListenerK, appContext, background, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, changeSupport, componentListener, componentListenerK, componentOrientation, componentSerializedDataVersion, containerListenerK, cursor, dropTarget, enabled, eventMask, focusListener, focusListenerK, font, foreground, graphicsConfig, hasFocus, height, hierarchyBoundsListener, hierarchyBoundsListenerK, hierarchyListener, hierarchyListenerK, incRate, inputMethodListener, inputMethodListenerK, isInc, isPacked, itemListenerK, keyListener, keyListenerK, LEFT_ALIGNMENT, locale, LOCK, metrics, minSize, mouseListener, mouseListenerK, mouseMotionListener, mouseMotionListenerK, name, nameExplicitlySet, newEventsOnly, ownedWindowK, parent, peer, peerFont, popups, prefSize, privateKey, RIGHT_ALIGNMENT, textListenerK, TOP_ALIGNMENT, valid, visible, width, windowClosingException, windowListenerK, x, y
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
EditIM(java.awt.Font unifont, java.awt.im.spi.InputMethodDescriptor iMDesc, java.awt.im.spi.InputMethod iM, java.awt.Frame pFrame)
          The constructor calls methods to build the look and feel
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          This collects all user activity in form of events, parses it, and distributes it as needed.
private  void connectIM(java.awt.im.spi.InputMethodDescriptor iMDesc, java.awt.im.spi.InputMethod iM)
          Init IM connection and Locale list.
private  void editIMFeelInit()
          Here we add the FUNCTIONALITY to the menu items, if not done already in editIMLookInit().
private  void editIMLookInit(java.awt.Font unifont)
          Here we pile up lots of menu items in front of the user.
static void main(java.lang.String[] args)
          main - to allow running of the Input Method Editor as standalone.
protected  void processWindowEvent(java.awt.event.WindowEvent e)
          Overridden so that we can exit when window is closed.
(package private)  void updateGlyphButton(char glyph)
          Shows a new glyph on the glyph button and updates the related action command and tool tip.
 void updateTitle()
          A classical method: set the title depending on whether the edited document is changed (and should be saved before leaving the Input Method Editor).
 void valueChanged(javax.swing.event.ListSelectionEvent e)
          If the user has selected some table1 row, update the glyph button.
 
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, createRootPaneException, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isRootPaneCheckingEnabled, paramString, processKeyEvent, remove, setContentPane, setDefaultCloseOperation, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.awt.Frame
, addNotify, addToFrameList, constructComponentName, finalize, getCursorType, getFrames, getIconImage, getMenuBar, getState, getTitle, initIDs, isResizable, postProcessKeyEvent, readObject, remove, removeFromFrameList, removeNotify, setCursor, setIconImage, setMenuBar, setResizable, setState, setTitle, writeObject
 
Methods inherited from class java.awt.Window
addOwnedWindow, addWindowListener, adjustListeningChildren, applyResourceBundle, applyResourceBundle, connectOwnedWindow, dispatchEventImpl, dispose, eventEnabled, getFocusOwner, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getOwnedWindows, getOwner, getToolkit, getWarningString, hide, isActive, isShowing, nextFocus, ownedInit, pack, postEvent, postWindowEvent, preProcessKeyEvent, processEvent, removeOwnedWindow, removeWindowListener, resetGC, setCursor, setFocusOwner, setWarningString, show, toBack, toFront, transferFocus
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyOrientation, checkGD, countComponents, createChildHierarchyEvents, createHierarchyEvents, deliverEvent, dispatchEventToSelf, doLayout, findComponentAt, findComponentAt, findComponentAt, getAccessibleAt, getAccessibleChild, getAccessibleChildrenCount, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents_NoClientCode, getComponents, getInsets, getLayout, getMaximumSize, getMinimumSize, getMouseEventTarget, getPreferredSize, getWindow, insets, invalidate, invalidateTree, isAncestorOf, layout, lightweightPaint, lightweightPrint, list, list, locate, minimumSize, numListening, paint, paintComponents, paintHeavyweightComponents, postsOldMouseEvents, preferredSize, print, printComponents, printHeavyweightComponents, processContainerEvent, proxyEnableEvents, proxyRequestFocus, remove, removeAll, removeContainerListener, setFont, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, areInputMethodsEnabled, bounds, checkImage, checkImage, checkWindowClosingException, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAccessibleIndexInParent, getAccessibleStateSet, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont_NoClientCode, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen_NoTreeLock, getLocationOnScreen, getName, getNativeContainer, getParent_NoClientCode, getParent, getPeer, getSize, getSize, getToolkitImpl, getTreeLock, getWidth, getWindowForObject, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isEnabledImpl, isFocusTraversable, isLightweight, isOpaque, isRecursivelyVisible, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseMotionEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

jumpField

javax.swing.JTextField jumpField
Here, the user can enter a glyph or a glyph number, preferrably in \\u12ab syntax, to scroll to that glyph. Accessed from both look and feel components.

blockIMButton

javax.swing.JToggleButton blockIMButton
The button to select NONE as the current GUK IM. Accessed from both look and feel components, because the feel wants to know whether a blockimusage command came from the button or the checkbox.

hotkeys

LocaleHotkey[] hotkeys
Ten buttons, each selecting ONE of the GUK IMs as the IM that is used to edit the tables and the jumpField. Used a lot by look, feel and even the sub menu processor.

glyphButton

javax.swing.JButton glyphButton
a button that serves as a glyph preview window. clicking on it could cause some special actions like "copy glyph to cut buffer" or "add glyph to currently selected table2 row, left buffer" or "send key_typed event for that glyph to our creator"... BONUS: a panel where the sub menu processor can present some interaction components for glyph button related things. glyphChar is the char currently visible on glyphButton, to be used by other related buttons. Used by both the look and the feel (the feel dynamically updates the glyph button).

glyphBar

javax.swing.JPanel glyphBar
The glyphBar is a whole panel where another class can create additional user interface elements. Currently, a palette of glyphs (for fast and easy access, filled with glyphs by the user) exists there. Used by both the look and the feel, in particular the sub menu processor.

glyphChar

char glyphChar
The char that is currently visible on the glyph preview button. Updated by the the glyph button update (triggered by the list selection listener and read by the action listener.

table1

javax.swing.JTable table1
The first table is implemented in GlyphTable.java as data model. The tables are the main editor component.
See Also:
GlyphTable

table2

javax.swing.JTable table2
The second table (for many to many compositions, using the data model defined in StringTable.java).
See Also:
StringTable

statusBar

javax.swing.JLabel statusBar
A status bar, and the frame that represents the this-object. Updated by the action listener.

frame

javax.swing.JFrame frame
The frame that we are.

installedLocales

java.util.List installedLocales
We collect lists of installed locales and unicode ranges here. Set up by connectIM, used by the look setup and the action listener.

imControl

java.lang.Object imControl
Have a global InputMethod control object for virtual keyboard control and maybe other things. Used by the feel parts.

subMenuProcessor

EditIMPopups subMenuProcessor
the subMenuProcessor is used to display some sub menus. if it has done something, it throws an ActionEvent to the assigned listener (given as constructor argument). Contains or calls the help and about window, the file type / name requester, glyph button and glyph palette processing and other functions like smaller dialogues to request values from the user, and the clipboard tools.

fileCommandProcessor

FileCommands fileCommandProcessor
the fileCommandProcessor is responsible for reading, writing and merging files into the editor. It can pop up confirmation dialogues, but things like selection of file names and file types are done by subMenuProcessor. Knows the MapTable objects to communicate with. When needed, fileCommandProcessor throws an ActionEvent to the assigned listener (given as constructor argument).

menu

MenuHelpers menu
The MenuHelpers class provides functions like creating menu items and buttons. Initially, no action listener is set.
Constructor Detail

EditIM

public EditIM(java.awt.Font unifont,
              java.awt.im.spi.InputMethodDescriptor iMDesc,
              java.awt.im.spi.InputMethod iM,
              java.awt.Frame pFrame)
The constructor calls methods to build the look and feel
Parameters:
unifont - is a Unicode-capable font. If null, a default font will be used (with the help of the FontLoader).
iMDesc - an input method descriptor to be used, or null, which will cause the editor to connect to GUK IM itself.
iM - an input method object to connect to. If null, the editor will request one itself.
pFrame - the frame to which the user should be able to send key events, using the type to client function. If null, type to client will not be available.
Method Detail

connectIM

private void connectIM(java.awt.im.spi.InputMethodDescriptor iMDesc,
                       java.awt.im.spi.InputMethod iM)
Init IM connection and Locale list. basically taken from GATE GUK Editor.
Parameters:
iMDesc - An input method descriptor, or null. If null, we will open connection to GUK IM ourselves, and also ignore the iM parameter.
iM - An input method, or null. When null, several features will not be available!

editIMLookInit

private void editIMLookInit(java.awt.Font unifont)
                     throws java.lang.Exception
Here we pile up lots of menu items in front of the user. Several items will use the requested font.
Parameters:
unifont - Several items will use this font and assume that it can display all Unicode chars. If null, a default font will be loaded with the help of FontLoader.
Throws:
java.lang.Exception - If anything goes wrong, the Exception will be passed on to the caller.

editIMFeelInit

private void editIMFeelInit()
                     throws java.lang.Exception
Here we add the FUNCTIONALITY to the menu items, if not done already in editIMLookInit(). Also initializes functionality that is provided by separate classes.
Throws:
java.lang.Exception - If anything goes wrong, the Exception will simply be passed on to the caller.

updateGlyphButton

void updateGlyphButton(char glyph)
Shows a new glyph on the glyph button and updates the related action command and tool tip. Helper method to re-set the size of our glpyh button and to give it a new label and action to match the given char.
Parameters:
glyph - The Unicode character which should be associated to the glyph button GUI component.

updateTitle

public void updateTitle()
A classical method: set the title depending on whether the edited document is changed (and should be saved before leaving the Input Method Editor).

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
This collects all user activity in form of events, parses it, and distributes it as needed.

One actionPerformed method where all the events meet :-) This also dispatches events to other parts of EditIM. It calls actionPerformed rather than processEvent to bypass unnecessary processing. Please READ THE CODE to know which commands are parsed by which of the EditIM classes!

 Things that are handled directly here:
 addcharif char - append char to table2 selected row, left
    column, IF a row is selected. Be careful not to disturb
    editing sessions in table2. Use "addchar row char" command
    which itself is interpreted by table2/processCommand...
 activatelocale locale (not file) - activate locale for our IM
    (do not edit, just activate it as our InputContext IM).
    (also "clicks" the newly assigned first button)
 selectlocale locale - as activatelocale, but without click
 setlocalebuttonlocale button locale - just call appropriate
    hotkeys[...].loadlocale(Locale).
 ...
 Things that use the "checked" boolean value:
 showvirtualkeyboard tracking - enable/disable normal GUK IM
    virtual keyboard (shows the mapping for the current state)
 showvirtualkeyboard type - enable extended GUK virtual keyboard
    of special type (e.g. "what-happens-when Ctrl-Alt-something
    is pressed") - NOT IMPLEMENTED (not even in GUK!).
 blockimusage where - disable usage of IM in our input context
    (where value ignored). Only the system keyboard driver is
    used in that mode for table and jumpfield editing.
 exit localeeditor - leave this editor, by dispose or by exit,
    depending on whether there is a parent Frame.
 

Specified by:
actionPerformed in interface java.awt.event.ActionListener

valueChanged

public void valueChanged(javax.swing.event.ListSelectionEvent e)
If the user has selected some table1 row, update the glyph button. If the user has selected the last table2 row, add a new row to table2. Triggered by things for which we are the ListSelectionListener.
Specified by:
valueChanged in interface javax.swing.event.ListSelectionListener

processWindowEvent

protected void processWindowEvent(java.awt.event.WindowEvent e)
Overridden so that we can exit when window is closed.
Overrides:
processWindowEvent in class javax.swing.JFrame
Parameters:
e - A window event, telling us about closing, iconifying, activation, similar things.

main

public static void main(java.lang.String[] args)
main - to allow running of the Input Method Editor as standalone.