Package ca.cgjennings.apps.arkham
Class ContextBar.Context
- java.lang.Object
-
- ca.cgjennings.apps.arkham.ContextBar.Context
-
- Enclosing class:
- ContextBar
public static class ContextBar.Context extends java.lang.ObjectEncapsulates information about the bar's current context. This allows buttons to behave in a manner appropriate to the control that the bar is attached to. Before the context bar is attached to a new control, each of its buttons will be queried with this context to determine if they should be hidden or disabled.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CodeTypegetCodeType()If the current target is a code editor, returns theCodeTypeof the code being edited.DeckgetDeck()If the target is a page in a deck, returns theDeck.StrangeEonsEditorgetEditor()If the target is within a Strange Eons editor tab, returns the editor.GamegetGame()If the target is part of an editor associated with a particular game, returns the game.GameComponentgetGameComponent()If the target is part of an editor for a game component, returns the game component.PageViewgetPageView()If the target is a page in a deck, returns the target as a page view instance.ContextBargetSource()Returns the context bar that this context information is associated with.javax.swing.JComponentgetTarget()Returns the control that the bar is attached to.booleanisMarkupTarget()Returnstrueif the target component is also the current markup target.booleanisMultipleLineTextEditor()Returnstrueif the context bar is attached to some kind of text editor, and that editor supports more than a single line of text.
-
-
-
Method Detail
-
getSource
public ContextBar getSource()
Returns the context bar that this context information is associated with.- Returns:
- the context bar whose context is being described
-
getTarget
public javax.swing.JComponent getTarget()
Returns the control that the bar is attached to. In some cases, this may be a child of the component that you expect. For example, the context bar attaches to the editor child component of an editable combo box, not the combo box itself.- Returns:
- the control the bar is attached to
-
isMarkupTarget
public boolean isMarkupTarget()
Returnstrueif the target component is also the current markup target.- Returns:
- if the bar is attached to the markup target
-
isMultipleLineTextEditor
public boolean isMultipleLineTextEditor()
Returnstrueif the context bar is attached to some kind of text editor, and that editor supports more than a single line of text. For example, a context bar attached to aJTextFieldwould returnfalse, while a context bar attached to aJTextAreawould returntrue.- Returns:
trueif the context bar is attached to a multi-line text editor
-
getCodeType
public CodeType getCodeType()
If the current target is a code editor, returns theCodeTypeof the code being edited. Otherwise, returnsnull. The following code can be used to verify that the target is a valid markup target but is not used to edit code (i.e., that it is used to enter markup for a game component):if( context.isMarkupTarget() && context.getCodeType() == null ) { // the target is (very likely) a text field for a game component }- Returns:
- the type of code being edited, or
null; if code is being edited but the type is indeterminate, script code (CodeType.JAVASCRIPT) is assumed
-
getEditor
public StrangeEonsEditor getEditor()
If the target is within a Strange Eons editor tab, returns the editor. Otherwise returnsnull.- Returns:
- the editor affected by the target, or
null
-
getGameComponent
public GameComponent getGameComponent()
If the target is part of an editor for a game component, returns the game component. Otherwise, returnsnull.- Returns:
- the game component affected by the markup target, or
null
-
getGame
public Game getGame()
If the target is part of an editor associated with a particular game, returns the game. Otherwise, returnsnull.- Returns:
- the game of the game component affected by the markup target,
or
null
-
getPageView
public PageView getPageView()
If the target is a page in a deck, returns the target as a page view instance. Otherwise, returnsnull.- Returns:
- the page view represented by the target, or
null
-
-