20 package net.sf.gridarta.gui.panel.gameobjectattributes;
22 import java.awt.Color;
23 import java.awt.GridLayout;
24 import javax.swing.JPanel;
25 import javax.swing.JScrollPane;
26 import javax.swing.JTextArea;
27 import javax.swing.ScrollPaneConstants;
28 import javax.swing.border.EtchedBorder;
35 import org.jetbrains.annotations.NotNull;
36 import org.jetbrains.annotations.Nullable;
54 private final JPanel
textPanel =
new JPanel(
new GridLayout(1, 1));
67 super(gameObjectAttributesModel);
68 archTextArea.setLineWrap(
true);
71 final JScrollPane sta =
new JScrollPane(archTextArea);
72 sta.setBorder(
new EtchedBorder());
73 sta.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
74 sta.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
80 refresh(gameObjectAttributesModel.getSelectedGameObject());
90 protected final void refresh(@Nullable
final G gameObject) {
91 final boolean hasMessage;
92 if (gameObject == null) {
96 final String msgText = gameObject.getMsgText();
97 if (msgText != null) {
101 final String archMsgText = gameObject.getArchetype().getMsgText();
102 if (archMsgText != null) {
116 return !archTextArea.getText().equals(defaultArchTextAreaValue);
121 archTextArea.requestFocusInWindow();
125 protected void apply(@NotNull
final G gameObject) {
126 gameObject.setMsgText(
getMsgText(gameObject));
141 if (msgText.isEmpty()) {
148 final String archetypeMsgText = archetype.
getMsgText();
149 if (archetypeMsgText != null) {
150 if (msgText.equals(archetypeMsgText)) {
166 private void setArchTextArea(@NotNull
final String objText, @NotNull
final Color color) {
167 archTextArea.setForeground(color);
168 archTextArea.setText(objText);
169 archTextArea.setCaretPosition(0);
170 defaultArchTextAreaValue = objText;
void addAutoApply( @NotNull final Component component)
Registers a component that auto-applies when the focus is lost.
Utility class for string manipulation.
Graphical User Interface of Gridarta.
void setArchTextArea(@NotNull final String objText, @NotNull final Color color)
Updates the value of the archTextArea.
MODIFIED
The tab contents are modified from defaults.
static String removeTrailingWhitespaceFromLines(@NotNull final CharSequence str)
Removes trailing whitespace from all lines of a string.
Base package of all Gridarta classes.
Reflects a game object (object on a map).
final JPanel textPanel
The content panel.
GameObjects are the objects based on Archetypes found on maps.
final JTextArea archTextArea
Arch text field.
void setTabSeverity( @NotNull final Severity tabSeverity)
Sets the tab severity.
String getMsgText()
Returns the message bound to this object.
void apply(@NotNull final G gameObject)
R getArchetype()
Returns the Archetype this GameObject is based on.
Severity levels for colors of tabs.
String defaultArchTextAreaValue
The initial value of the archTextArea.
The "Msg Text" tab in the game object attributes panel.
DEFAULT
The tab contents are unchanged from defaults.
final void refresh(@Nullable final G gameObject)
String getMsgText(@NotNull final GameObject< G, A, R > gameObject)
Returns the message text to be set.
MsgTextTab(@NotNull final GameObjectAttributesModel< G, A, R > gameObjectAttributesModel)
Creates a new instance.
Interface for MapArchObjects.
Base class for GameObjectAttributesTab implementations.