You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(103) |
Jun
(121) |
Jul
(16) |
Aug
(67) |
Sep
(126) |
Oct
(161) |
Nov
(164) |
Dec
(588) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(394) |
Feb
(181) |
Mar
(131) |
Apr
(180) |
May
(255) |
Jun
(11) |
Jul
(79) |
Aug
(70) |
Sep
(274) |
Oct
(138) |
Nov
(195) |
Dec
(8) |
2008 |
Jan
(3) |
Feb
(142) |
Mar
(162) |
Apr
(124) |
May
(148) |
Jun
(157) |
Jul
(425) |
Aug
(373) |
Sep
(264) |
Oct
(315) |
Nov
(225) |
Dec
(6) |
2009 |
Jan
(67) |
Feb
(78) |
Mar
(279) |
Apr
(294) |
May
(92) |
Jun
(65) |
Jul
(134) |
Aug
(41) |
Sep
(138) |
Oct
(125) |
Nov
(126) |
Dec
(122) |
2010 |
Jan
(15) |
Feb
(48) |
Mar
(9) |
Apr
(195) |
May
(373) |
Jun
(507) |
Jul
(42) |
Aug
(16) |
Sep
(38) |
Oct
(81) |
Nov
(64) |
Dec
(18) |
2011 |
Jan
(13) |
Feb
(12) |
Mar
(39) |
Apr
(1) |
May
(2) |
Jun
(27) |
Jul
(27) |
Aug
(31) |
Sep
(14) |
Oct
(102) |
Nov
(20) |
Dec
(37) |
2012 |
Jan
(22) |
Feb
(1) |
Mar
(1) |
Apr
(2) |
May
(2) |
Jun
(18) |
Jul
(6) |
Aug
(1) |
Sep
(1) |
Oct
|
Nov
|
Dec
|
2013 |
Jan
(1) |
Feb
(2) |
Mar
(1) |
Apr
(1) |
May
(47) |
Jun
(7) |
Jul
(107) |
Aug
|
Sep
|
Oct
(112) |
Nov
(31) |
Dec
(17) |
2014 |
Jan
(29) |
Feb
(111) |
Mar
(34) |
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
(18) |
Dec
(10) |
From: <aki...@us...> - 2013-07-19 06:37:47
|
Revision: 9360 http://sourceforge.net/p/gridarta/code/9360 Author: akirschbaum Date: 2013-07-19 06:37:44 +0000 (Fri, 19 Jul 2013) Log Message: ----------- Fix typo. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GuiInfoGlue.java Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GuiInfoGlue.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GuiInfoGlue.java 2013-07-19 06:35:23 UTC (rev 9359) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GuiInfoGlue.java 2013-07-19 06:37:44 UTC (rev 9360) @@ -43,7 +43,7 @@ * Creates a new instance. * @param attribute the dialog attribute this entry represents * @param glue the component to display filled both horizontally and - * verically + * vertically */ public GuiInfoGlue(@NotNull final DialogAttribute<G, A, R, T> attribute, @NotNull final Component glue) { super(attribute); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-07-19 06:35:29
|
Revision: 9359 http://sourceforge.net/p/gridarta/code/9359 Author: akirschbaum Date: 2013-07-19 06:35:23 +0000 (Fri, 19 Jul 2013) Log Message: ----------- Remove GuiInfoGlue.isText(). Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/AttributesPaneBuilder.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GuiInfo.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GuiInfoGlue.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GuiInfoRow.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GuiInfoTwoColumn.java Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/AttributesPaneBuilder.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/AttributesPaneBuilder.java 2013-07-19 06:23:01 UTC (rev 9358) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/AttributesPaneBuilder.java 2013-07-19 06:35:23 UTC (rev 9359) @@ -451,7 +451,7 @@ input.setCaretPosition(0); input.setBorder(BorderFactory.createEmptyBorder(3, 7, 0, 0)); input.getPainter().setInvalidLinesPainted(false); - guiInfo = new GuiInfoGlue<G, A, R, ArchetypeAttributeText>(new DialogAttributeText<G, A, R>(archetypeAttribute, input), input, true); + guiInfo = new GuiInfoGlue<G, A, R, ArchetypeAttributeText>(new DialogAttributeText<G, A, R>(archetypeAttribute, input), input); } @Override @@ -612,7 +612,7 @@ gbc.weighty = 1.0; final Object glueGbc = gbc.clone(); - boolean isText = false; + boolean hasGlue = false; // now add the entries, line by line for (final ArchetypeAttribute archetypeAttribute : archetypeAttributeSection) { if (!(archetypeAttribute instanceof ArchetypeAttributeFixed)) { @@ -632,11 +632,11 @@ addElement(panel, tmpGuiInfo.getComponent(), compGbc); addElement(panel, tmpGuiInfo.getRow(), rowGbc); addElement(panel, tmpGuiInfo.getGlue(), glueGbc); - isText |= tmpGuiInfo.isText(); + hasGlue |= tmpGuiInfo.getGlue() != null; } } - if (!isText) { + if (!hasGlue) { // if the component does not already have glue, put glue inside to align its contents to the top. panel.add(Box.createGlue(), glueGbc); } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GuiInfo.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GuiInfo.java 2013-07-19 06:23:01 UTC (rev 9358) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GuiInfo.java 2013-07-19 06:35:23 UTC (rev 9359) @@ -93,6 +93,4 @@ @Nullable public abstract Component getGlue(); - public abstract boolean isText(); - } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GuiInfoGlue.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GuiInfoGlue.java 2013-07-19 06:23:01 UTC (rev 9358) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GuiInfoGlue.java 2013-07-19 06:35:23 UTC (rev 9359) @@ -39,18 +39,15 @@ @NotNull private final Component glue; - private final boolean isText; - /** * Creates a new instance. * @param attribute the dialog attribute this entry represents * @param glue the component to display filled both horizontally and * verically */ - public GuiInfoGlue(@NotNull final DialogAttribute<G, A, R, T> attribute, @NotNull final Component glue, final boolean isText) { + public GuiInfoGlue(@NotNull final DialogAttribute<G, A, R, T> attribute, @NotNull final Component glue) { super(attribute); this.glue = glue; - this.isText = isText; } /** @@ -89,12 +86,4 @@ return glue; } - /** - * {@inheritDoc} - */ - @Override - public boolean isText() { - return isText; - } - } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GuiInfoRow.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GuiInfoRow.java 2013-07-19 06:23:01 UTC (rev 9358) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GuiInfoRow.java 2013-07-19 06:35:23 UTC (rev 9359) @@ -85,12 +85,4 @@ return null; } - /** - * {@inheritDoc} - */ - @Override - public boolean isText() { - return false; - } - } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GuiInfoTwoColumn.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GuiInfoTwoColumn.java 2013-07-19 06:23:01 UTC (rev 9358) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GuiInfoTwoColumn.java 2013-07-19 06:35:23 UTC (rev 9359) @@ -94,12 +94,4 @@ return null; } - /** - * {@inheritDoc} - */ - @Override - public boolean isText() { - return false; - } - } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-07-19 06:23:06
|
Revision: 9358 http://sourceforge.net/p/gridarta/code/9358 Author: akirschbaum Date: 2013-07-19 06:23:01 +0000 (Fri, 19 Jul 2013) Log Message: ----------- Clean up GuiInfo. Fixes layout issue with type="bool_spec" in types.xml. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/AttributesPaneBuilder.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GuiInfo.java Added Paths: ----------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GuiInfoGlue.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GuiInfoRow.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GuiInfoTwoColumn.java Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/AttributesPaneBuilder.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/AttributesPaneBuilder.java 2013-07-19 05:56:07 UTC (rev 9357) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/AttributesPaneBuilder.java 2013-07-19 06:23:01 UTC (rev 9358) @@ -264,39 +264,33 @@ final String defaultText = attributes.getAttributeString(attributeName); final AnimationComponent input = new AnimationComponent(defaultText, animationObjects, faceObjectProviders, noFaceSquareIcon, unknownSquareIcon); final JLabel cLabel = new JLabel(archetypeAttribute.getAttributeName() + ": "); - guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeAnimationName>(new DialogAttributeAnimationName<G, A, R>(archetypeAttribute, input), cLabel, input, null, null, false); + guiInfo = new GuiInfoTwoColumn<G, A, R, ArchetypeAttributeAnimationName>(new DialogAttributeAnimationName<G, A, R>(archetypeAttribute, input), cLabel, input); } @Override public void visit(@NotNull final ArchetypeAttributeBitmask archetypeAttribute) { final JTextArea input = new JTextArea(); final DialogAttributeBitmask<G, A, R> tmpAttribute = new DialogAttributeBitmask<G, A, R>(archetypeAttribute, input); - @Nullable final JTextArea component; - @Nullable final JButton label; - @Nullable final JLabel row; final AttributeBitmask bitmask = archetypeTypeSet.getBitmask(archetypeAttribute.getBitmaskName()); if (bitmask != null) { tmpAttribute.setBitmask(bitmask); - label = new JButton(new MaskChangeAL<G, A, R>(archetypeAttribute.getAttributeName() + ":", tmpAttribute)); + final JButton label = new JButton(new MaskChangeAL<G, A, R>(archetypeAttribute.getAttributeName() + ":", tmpAttribute)); input.setBackground(parent.getBackground()); input.setEditable(false); input.setBorder(BorderFactory.createLineBorder(Color.gray)); input.setText(bitmask.getText(tmpAttribute.getValue())); - component = input; tmpAttribute.setEncodedValue(attributes.getAttributeString(archetypeAttribute.getArchetypeAttributeName())); - row = null; + guiInfo = new GuiInfoTwoColumn<G, A, R, ArchetypeAttributeBitmask>(tmpAttribute, label, input); } else { - label = null; - component = null; - row = new JLabel("Error: Undefined Bitmask"); + final JLabel row = new JLabel("Error: Undefined Bitmask"); + guiInfo = new GuiInfoRow<G, A, R, ArchetypeAttributeBitmask>(tmpAttribute, row); } - guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeBitmask>(tmpAttribute, label, component, row, null, false); } @Override public void visit(@NotNull final ArchetypeAttributeBool archetypeAttribute) { final JCheckBox input = new JCheckBox(archetypeAttribute.getAttributeName(), attributes.getAttributeInt(archetypeAttribute.getArchetypeAttributeName()) == 1); - guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeBool>(new DialogAttributeBool<G, A, R>(archetypeAttribute, input), null, null, input, null, false); + guiInfo = new GuiInfoRow<G, A, R, ArchetypeAttributeBool>(new DialogAttributeBool<G, A, R>(archetypeAttribute, input), input); } @Override @@ -309,7 +303,7 @@ defaultValue = attributeString.equals(archetypeAttribute.getTrueValue()); } final JCheckBox input = new JCheckBox(archetypeAttribute.getAttributeName(), defaultValue); - guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeBoolSpec>(new DialogAttributeBoolSpec<G, A, R>(archetypeAttribute, input), null, input, null, null, false); + guiInfo = new GuiInfoRow<G, A, R, ArchetypeAttributeBoolSpec>(new DialogAttributeBoolSpec<G, A, R>(archetypeAttribute, input), input); } @Override @@ -318,7 +312,7 @@ final String defaultText = attributes.getAttributeString(attributeName); final FaceComponent input = new FaceComponent(defaultText, faceObjects, faceObjectProviders, noFaceSquareIcon, unknownSquareIcon); final JLabel label = new JLabel(archetypeAttribute.getAttributeName() + ":"); - guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeFaceName>(new DialogAttributeFaceName<G, A, R>(archetypeAttribute, input), label, input, null, null, false); + guiInfo = new GuiInfoTwoColumn<G, A, R, ArchetypeAttributeFaceName>(new DialogAttributeFaceName<G, A, R>(archetypeAttribute, input), label, input); } @Override @@ -340,7 +334,7 @@ final Number value = attributes.getAttributeDouble(archetypeAttribute.getArchetypeAttributeName()); final JFormattedTextField input = new JFormattedTextField(factory, value); input.setColumns(fieldLength); - guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeFloat>(new DialogAttributeFloat<G, A, R>(archetypeAttribute, input), label, input, null, null, false); + guiInfo = new GuiInfoTwoColumn<G, A, R, ArchetypeAttributeFloat>(new DialogAttributeFloat<G, A, R>(archetypeAttribute, input), label, input); } @Override @@ -355,15 +349,15 @@ final Number value = attributes.getAttributeInt(archetypeAttribute.getArchetypeAttributeName()); final JFormattedTextField input = new JFormattedTextField(factory, value); input.setColumns(fieldLength); - guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeInt>(new DialogAttributeInt<G, A, R>(archetypeAttribute, input), label, input, null, null, false); + guiInfo = new GuiInfoTwoColumn<G, A, R, ArchetypeAttributeInt>(new DialogAttributeInt<G, A, R>(archetypeAttribute, input), label, input); } @Override public void visit(@NotNull final ArchetypeAttributeInvSpell archetypeAttribute) { final JLabel label = new JLabel(archetypeAttribute.getAttributeName() + ": "); label.setForeground(INT_COLOR); - @Nullable final JComboBox input = buildInvSpellBox(gameObjectSpells, attributes, archetypeAttribute.isOptionalSpell(), archetypeAttribute.getAttributeName()); - guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeInvSpell>(new DialogAttributeInvSpell<G, A, R>(archetypeAttribute.isOptionalSpell(), archetypeAttribute, input, gameObjectSpells), label, input, null, null, false); + final JComboBox input = buildInvSpellBox(gameObjectSpells, attributes, archetypeAttribute.isOptionalSpell(), archetypeAttribute.getAttributeName()); + guiInfo = new GuiInfoTwoColumn<G, A, R, ArchetypeAttributeInvSpell>(new DialogAttributeInvSpell<G, A, R>(archetypeAttribute.isOptionalSpell(), archetypeAttribute, input, gameObjectSpells), label, input); } @Override @@ -371,7 +365,7 @@ final JLabel label = new JLabel(archetypeAttribute.getAttributeName() + ": "); label.setForeground(INT_COLOR); final JComponent component; - @Nullable final JComboBox input; + final JComboBox input; final ArchetypeTypeList list = archetypeTypeSet.getList(archetypeAttribute.getListName()); if (list != null) { input = buildArrayBox(list, attributes, archetypeAttribute.getArchetypeAttributeName(), archetypeAttribute.getAttributeName()); @@ -381,7 +375,7 @@ input = new JComboBox(); component = new JLabel("Error: Undefined List"); } - guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeList>(new DialogAttributeList<G, A, R>(archetypeAttribute, input, archetypeTypeSet), label, component, null, null, false); + guiInfo = new GuiInfoTwoColumn<G, A, R, ArchetypeAttributeList>(new DialogAttributeList<G, A, R>(archetypeAttribute, input, archetypeTypeSet), label, component); } @Override @@ -396,7 +390,7 @@ final Number value = attributes.getAttributeLong(archetypeAttribute.getArchetypeAttributeName()); final JFormattedTextField input = new JFormattedTextField(factory, value); input.setColumns(fieldLength); - guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeLong>(new DialogAttributeLong<G, A, R>(archetypeAttribute, input), label, input, null, null, false); + guiInfo = new GuiInfoTwoColumn<G, A, R, ArchetypeAttributeLong>(new DialogAttributeLong<G, A, R>(archetypeAttribute, input), label, input); } @Override @@ -408,7 +402,7 @@ } final JLabel label = new JLabel(archetypeAttribute.getAttributeName() + ": "); final TilePanel tilePanel = new TilePanel(mapFileFilter, attributes.getAttributeString(archetypeAttribute.getArchetypeAttributeName()), relativeReference, globalSettings.getMapsDirectory()); - guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeMapPath>(new DialogAttributeMapPath<G, A, R>(archetypeAttribute, tilePanel), label, tilePanel, null, null, false); + guiInfo = new GuiInfoTwoColumn<G, A, R, ArchetypeAttributeMapPath>(new DialogAttributeMapPath<G, A, R>(archetypeAttribute, tilePanel), label, tilePanel); } @Override @@ -416,15 +410,15 @@ final JLabel label = new JLabel(archetypeAttribute.getAttributeName() + ": "); final File mapsDirectory = globalSettings.getMapsDirectory(); final TilePanel tilePanel = new TilePanel(scriptFileFilter, attributes.getAttributeString(archetypeAttribute.getArchetypeAttributeName()), new File(mapsDirectory, "dummy"), mapsDirectory); - guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeScriptFile>(new DialogAttributeScriptFile<G, A, R>(archetypeAttribute, tilePanel), label, tilePanel, null, null, false); + guiInfo = new GuiInfoTwoColumn<G, A, R, ArchetypeAttributeScriptFile>(new DialogAttributeScriptFile<G, A, R>(archetypeAttribute, tilePanel), label, tilePanel); } @Override public void visit(@NotNull final ArchetypeAttributeSpell archetypeAttribute) { final JLabel label = new JLabel(archetypeAttribute.getAttributeName() + ": "); label.setForeground(INT_COLOR); - @Nullable final JComboBox input = buildSpellBox(attributes, numberSpells, undefinedSpellIndex, false, archetypeAttribute); - guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeSpell>(new DialogAttributeSpell<G, A, R>(archetypeAttribute, input, numberSpells), label, input, null, null, false); + final JComboBox input = buildSpellBox(attributes, numberSpells, undefinedSpellIndex, false, archetypeAttribute); + guiInfo = new GuiInfoTwoColumn<G, A, R, ArchetypeAttributeSpell>(new DialogAttributeSpell<G, A, R>(archetypeAttribute, input, numberSpells), label, input); } @Override @@ -432,7 +426,7 @@ final String defaultText = attributes.getAttributeString(archetypeAttribute.getArchetypeAttributeName()); final JTextField input = new JTextField(defaultText, ArchetypeAttribute.TEXTFIELD_COLUMNS); final JLabel label = new JLabel(archetypeAttribute.getAttributeName() + ": "); - guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeString>(new DialogAttributeString<G, A, R>(archetypeAttribute, input), label, input, null, null, false); + guiInfo = new GuiInfoTwoColumn<G, A, R, ArchetypeAttributeString>(new DialogAttributeString<G, A, R>(archetypeAttribute, input), label, input); } @Override @@ -457,7 +451,7 @@ input.setCaretPosition(0); input.setBorder(BorderFactory.createEmptyBorder(3, 7, 0, 0)); input.getPainter().setInvalidLinesPainted(false); - guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeText>(new DialogAttributeText<G, A, R>(archetypeAttribute, input), null, null, null, input, true); + guiInfo = new GuiInfoGlue<G, A, R, ArchetypeAttributeText>(new DialogAttributeText<G, A, R>(archetypeAttribute, input), input, true); } @Override @@ -470,15 +464,15 @@ input.setEditable(false); final DialogAttributeTreasure<G, A, R> tmpAttribute = new DialogAttributeTreasure<G, A, R>(archetypeAttribute, input, treasureTree); final JButton label = new JButton(new ViewTreasurelistAL(input, parent, treasureListTree)); - guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeTreasure>(tmpAttribute, label, input, null, null, false); + guiInfo = new GuiInfoTwoColumn<G, A, R, ArchetypeAttributeTreasure>(tmpAttribute, label, input); } @Override public void visit(@NotNull final ArchetypeAttributeZSpell archetypeAttribute) { final JLabel label = new JLabel(archetypeAttribute.getAttributeName() + ": "); label.setForeground(INT_COLOR); - @Nullable final JComboBox input = buildSpellBox(attributes, numberSpells, undefinedSpellIndex, true, archetypeAttribute); - guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeZSpell>(new DialogAttributeZSpell<G, A, R>(archetypeAttribute, input, numberSpells, undefinedSpellIndex), label, input, null, null, false); + final JComboBox input = buildSpellBox(attributes, numberSpells, undefinedSpellIndex, true, archetypeAttribute); + guiInfo = new GuiInfoTwoColumn<G, A, R, ArchetypeAttributeZSpell>(new DialogAttributeZSpell<G, A, R>(archetypeAttribute, input, numberSpells, undefinedSpellIndex), label, input); } }; @@ -632,8 +626,8 @@ final GuiInfo<G, A, R, ?> tmpGuiInfo = guiInfo; assert tmpGuiInfo != null; - dialogAttributes.add(tmpGuiInfo.getNewAttr()); - helpButton.addActionListener(new HelpActionListener(tmpGuiInfo.getNewAttr().getRef(), parent)); + dialogAttributes.add(tmpGuiInfo.getAttribute()); + helpButton.addActionListener(new HelpActionListener(tmpGuiInfo.getAttribute().getRef(), parent)); addElement(panel, tmpGuiInfo.getLabel(), labelGbc); addElement(panel, tmpGuiInfo.getComponent(), compGbc); addElement(panel, tmpGuiInfo.getRow(), rowGbc); Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GuiInfo.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GuiInfo.java 2013-07-19 05:56:07 UTC (rev 9357) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GuiInfo.java 2013-07-19 06:23:01 UTC (rev 9358) @@ -31,63 +31,68 @@ * Information about one attribute line in a {@link GameObjectAttributesDialog}. * @author Andreas Kirschbaum */ -public class GuiInfo<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, T extends ArchetypeAttribute> { +public abstract class GuiInfo<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, T extends ArchetypeAttribute> { - // now create the attribute-GUI-instance - + /** + * The {@link DialogAttribute} this entry represents. + */ @NotNull - private final DialogAttribute<G, A, R, T> newAttr; + private final DialogAttribute<G, A, R, T> attribute; - @Nullable - private final Component label; - - @Nullable - private final Component component; - - @Nullable - private final Component row; - - @Nullable - private final Component glue; - - private final boolean isText; - - public GuiInfo(@NotNull final DialogAttribute<G, A, R, T> newAttr, @Nullable final Component label, @Nullable final Component component, @Nullable final Component row, @Nullable final Component glue, final boolean isText) { - this.newAttr = newAttr; - this.label = label; - this.component = component; - this.row = row; - this.glue = glue; - this.isText = isText; + /** + * Creates a new instance. + * @param attribute the dialog attribute this entry represents + */ + protected GuiInfo(@NotNull final DialogAttribute<G, A, R, T> attribute) { + this.attribute = attribute; } + /** + * Returns the {@link DialogAttribute} this entry represents. + * @return the dialog attribute + */ @NotNull - public DialogAttribute<G, A, R, T> getNewAttr() { - return newAttr; + public DialogAttribute<G, A, R, T> getAttribute() { + return attribute; } + /** + * Returns the label to display in the first column or {@code null}. If + * non-{@code null}, both {@link #getRow()} and {@link #getGlue()} are + * {@code null} and {@link #getComponent()} is non-{@code null}. + * @return the label + */ @Nullable - public Component getLabel() { - return label; - } + public abstract Component getLabel(); + /** + * Returns the component to display in the second column or {@code null}. If + * non-{@code null}, both {@link #getRow()} and {@link #getGlue()} are + * {@code null} and {@link #getLabel()} is non-{@code null}. + * @return the label + */ @Nullable - public Component getComponent() { - return component; - } + public abstract Component getComponent(); + /** + * Returns the row component to display filled horizontally or {@code null}. + * If non-{@code null}, all of {@link #getLabel()}, {@link #getComponent()}, + * and {@link #getGlue()} are {@code null}. + * @return the row component + */ @Nullable - public Component getRow() { - return row; - } + public abstract Component getRow(); + /** + * Returns the glue component to display filled both horizontally and + * vertically or {@code null}. If non-{@code null}, all of {@link + * #getLabel()}, {@link #getComponent()}, and {@link #getRow()} are {@code + * null}. + * @return the glue component + */ @Nullable - public Component getGlue() { - return glue; - } + public abstract Component getGlue(); - public boolean isText() { - return isText; - } + public abstract boolean isText(); } Added: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GuiInfoGlue.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GuiInfoGlue.java (rev 0) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GuiInfoGlue.java 2013-07-19 06:23:01 UTC (rev 9358) @@ -0,0 +1,100 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2011 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.gui.dialog.gameobjectattributes; + +import java.awt.Component; +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.archetypetype.ArchetypeAttribute; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.maparchobject.MapArchObject; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * A {@link GuiInfo} that fills one component both horizontally and vertically. + * @author Andreas Kirschbaum + */ +public class GuiInfoGlue<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, T extends ArchetypeAttribute> extends GuiInfo<G, A, R, T> { + + /** + * The component to display filled both horizontally and vertically. + */ + @NotNull + private final Component glue; + + private final boolean isText; + + /** + * Creates a new instance. + * @param attribute the dialog attribute this entry represents + * @param glue the component to display filled both horizontally and + * verically + */ + public GuiInfoGlue(@NotNull final DialogAttribute<G, A, R, T> attribute, @NotNull final Component glue, final boolean isText) { + super(attribute); + this.glue = glue; + this.isText = isText; + } + + /** + * {@inheritDoc} + */ + @Nullable + @Override + public Component getLabel() { + return null; + } + + /** + * {@inheritDoc} + */ + @Nullable + @Override + public Component getComponent() { + return null; + } + + /** + * {@inheritDoc} + */ + @Nullable + @Override + public Component getRow() { + return null; + } + + /** + * {@inheritDoc} + */ + @NotNull + @Override + public Component getGlue() { + return glue; + } + + /** + * {@inheritDoc} + */ + @Override + public boolean isText() { + return isText; + } + +} Property changes on: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GuiInfoGlue.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Added: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GuiInfoRow.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GuiInfoRow.java (rev 0) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GuiInfoRow.java 2013-07-19 06:23:01 UTC (rev 9358) @@ -0,0 +1,96 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2011 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.gui.dialog.gameobjectattributes; + +import java.awt.Component; +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.archetypetype.ArchetypeAttribute; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.maparchobject.MapArchObject; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * A {@link GuiInfo} that fills one component horizontally. + * @author Andreas Kirschbaum + */ +public class GuiInfoRow<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, T extends ArchetypeAttribute> extends GuiInfo<G, A, R, T> { + + /** + * The component to display filled horizontally. + */ + @NotNull + private final Component row; + + /** + * Creates a new instance. + * @param attribute the dialog attribute this entry represents + * @param row the component to display filled horizontally + */ + public GuiInfoRow(@NotNull final DialogAttribute<G, A, R, T> attribute, @NotNull final Component row) { + super(attribute); + this.row = row; + } + + /** + * {@inheritDoc} + */ + @Nullable + @Override + public Component getLabel() { + return null; + } + + /** + * {@inheritDoc} + */ + @Nullable + @Override + public Component getComponent() { + return null; + } + + /** + * {@inheritDoc} + */ + @NotNull + @Override + public Component getRow() { + return row; + } + + /** + * {@inheritDoc} + */ + @Nullable + @Override + public Component getGlue() { + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public boolean isText() { + return false; + } + +} Property changes on: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GuiInfoRow.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Added: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GuiInfoTwoColumn.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GuiInfoTwoColumn.java (rev 0) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GuiInfoTwoColumn.java 2013-07-19 06:23:01 UTC (rev 9358) @@ -0,0 +1,105 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2011 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.gui.dialog.gameobjectattributes; + +import java.awt.Component; +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.archetypetype.ArchetypeAttribute; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.maparchobject.MapArchObject; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * A {@link GuiInfo} that displays a label and another component in two + * columns. + * @author Andreas Kirschbaum + */ +public class GuiInfoTwoColumn<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, T extends ArchetypeAttribute> extends GuiInfo<G, A, R, T> { + + /** + * The label to display in the first column. + */ + @NotNull + private final Component label; + + /** + * The component to display in the second column. + */ + @NotNull + private final Component component; + + /** + * Creates a new instance. + * @param attribute the dialog attribute this entry represents + * @param label the label to display in the first column + * @param component the component to display in the second column + */ + public GuiInfoTwoColumn(@NotNull final DialogAttribute<G, A, R, T> attribute, @NotNull final Component label, @NotNull final Component component) { + super(attribute); + this.label = label; + this.component = component; + } + + /** + * {@inheritDoc} + */ + @NotNull + @Override + public Component getLabel() { + return label; + } + + /** + * {@inheritDoc} + */ + @NotNull + @Override + public Component getComponent() { + return component; + } + + /** + * {@inheritDoc} + */ + @Nullable + @Override + public Component getRow() { + return null; + } + + /** + * {@inheritDoc} + */ + @Nullable + @Override + public Component getGlue() { + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public boolean isText() { + return false; + } + +} Property changes on: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GuiInfoTwoColumn.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-07-19 05:56:12
|
Revision: 9357 http://sourceforge.net/p/gridarta/code/9357 Author: akirschbaum Date: 2013-07-19 05:56:07 +0000 (Fri, 19 Jul 2013) Log Message: ----------- Make checkboxes span both columns in game object attribute dialog. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/AttributesPaneBuilder.java Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/AttributesPaneBuilder.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/AttributesPaneBuilder.java 2013-07-18 20:35:53 UTC (rev 9356) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/AttributesPaneBuilder.java 2013-07-19 05:56:07 UTC (rev 9357) @@ -614,6 +614,7 @@ gbc.anchor = GridBagConstraints.WEST; final Object rowGbc = gbc.clone(); gbc.fill = GridBagConstraints.BOTH; + gbc.gridwidth = 2; gbc.weighty = 1.0; final Object glueGbc = gbc.clone(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-07-18 20:35:58
|
Revision: 9356 http://sourceforge.net/p/gridarta/code/9356 Author: akirschbaum Date: 2013-07-18 20:35:53 +0000 (Thu, 18 Jul 2013) Log Message: ----------- Remove useless comments. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/AttributesPaneBuilder.java Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/AttributesPaneBuilder.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/AttributesPaneBuilder.java 2013-07-18 20:34:08 UTC (rev 9355) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/AttributesPaneBuilder.java 2013-07-18 20:35:53 UTC (rev 9356) @@ -337,7 +337,6 @@ final NumberFormatter formatter = new NumberFormatter(format); formatter.setValueClass(Double.class); final DefaultFormatterFactory factory = new DefaultFormatterFactory(formatter); - // parse value from attributes final Number value = attributes.getAttributeDouble(archetypeAttribute.getArchetypeAttributeName()); final JFormattedTextField input = new JFormattedTextField(factory, value); input.setColumns(fieldLength); @@ -353,7 +352,6 @@ format.setGroupingUsed(false); final NumberFormatter formatter = new NumberFormatter(format); final DefaultFormatterFactory factory = new DefaultFormatterFactory(formatter); - // parse value from attributes final Number value = attributes.getAttributeInt(archetypeAttribute.getArchetypeAttributeName()); final JFormattedTextField input = new JFormattedTextField(factory, value); input.setColumns(fieldLength); @@ -364,7 +362,6 @@ public void visit(@NotNull final ArchetypeAttributeInvSpell archetypeAttribute) { final JLabel label = new JLabel(archetypeAttribute.getAttributeName() + ": "); label.setForeground(INT_COLOR); - // create ComboBox with parsed selection @Nullable final JComboBox input = buildInvSpellBox(gameObjectSpells, attributes, archetypeAttribute.isOptionalSpell(), archetypeAttribute.getAttributeName()); guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeInvSpell>(new DialogAttributeInvSpell<G, A, R>(archetypeAttribute.isOptionalSpell(), archetypeAttribute, input, gameObjectSpells), label, input, null, null, false); } @@ -373,12 +370,10 @@ public void visit(@NotNull final ArchetypeAttributeList archetypeAttribute) { final JLabel label = new JLabel(archetypeAttribute.getAttributeName() + ": "); label.setForeground(INT_COLOR); - // create ComboBox with parsed selection final JComponent component; @Nullable final JComboBox input; final ArchetypeTypeList list = archetypeTypeSet.getList(archetypeAttribute.getListName()); if (list != null) { - // build the list from vector data input = buildArrayBox(list, attributes, archetypeAttribute.getArchetypeAttributeName(), archetypeAttribute.getAttributeName()); component = input; } else { @@ -398,7 +393,6 @@ format.setGroupingUsed(false); final NumberFormatter formatter = new NumberFormatter(format); final DefaultFormatterFactory factory = new DefaultFormatterFactory(formatter); - // parse value from attributes final Number value = attributes.getAttributeLong(archetypeAttribute.getArchetypeAttributeName()); final JFormattedTextField input = new JFormattedTextField(factory, value); input.setColumns(fieldLength); @@ -429,7 +423,6 @@ public void visit(@NotNull final ArchetypeAttributeSpell archetypeAttribute) { final JLabel label = new JLabel(archetypeAttribute.getAttributeName() + ": "); label.setForeground(INT_COLOR); - // create ComboBox with parsed selection @Nullable final JComboBox input = buildSpellBox(attributes, numberSpells, undefinedSpellIndex, false, archetypeAttribute); guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeSpell>(new DialogAttributeSpell<G, A, R>(archetypeAttribute, input, numberSpells), label, input, null, null, false); } @@ -469,7 +462,6 @@ @Override public void visit(@NotNull final ArchetypeAttributeTreasure archetypeAttribute) { - // textfield (no direct input, text is set by the treasurelist dialog) String treasureName = attributes.getAttributeString(archetypeAttribute.getArchetypeAttributeName()); if (treasureName.trim().isEmpty() || treasureName.trim().equalsIgnoreCase("none")) { treasureName = CFTreasureListTree.NONE_SYM; @@ -485,7 +477,6 @@ public void visit(@NotNull final ArchetypeAttributeZSpell archetypeAttribute) { final JLabel label = new JLabel(archetypeAttribute.getAttributeName() + ": "); label.setForeground(INT_COLOR); - // create ComboBox with parsed selection @Nullable final JComboBox input = buildSpellBox(attributes, numberSpells, undefinedSpellIndex, true, archetypeAttribute); guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeZSpell>(new DialogAttributeZSpell<G, A, R>(archetypeAttribute, input, numberSpells, undefinedSpellIndex), label, input, null, null, false); } @@ -577,7 +568,6 @@ } } - // set selected tab tabbedPane.setSelectedIndex(sectionId > 0 ? 0 : -1); tabbedPane.validate(); } @@ -745,7 +735,6 @@ */ @NotNull private static JComboBox buildArrayBox(@NotNull final ArchetypeTypeList listData, @NotNull final Attributes attributes, @NotNull final String archetypeAttributeName, @NotNull final String attributeName) { - // build the array of list-items final String[] array = new String[listData.size()]; boolean hasSelection = false; final int value = attributes.getAttributeInt(archetypeAttributeName); @@ -754,11 +743,11 @@ array[i] = listData.get(i).getSecond(); if (!hasSelection && listData.get(i).getFirst() == value) { hasSelection = true; - selectedIndex = i; // set selection to this index in the array + selectedIndex = i; } } - final JComboBox comboBox = new JComboBox(array); // set "content" - comboBox.setSelectedIndex(selectedIndex); // set active selection + final JComboBox comboBox = new JComboBox(array); + comboBox.setSelectedIndex(selectedIndex); comboBox.setMaximumRowCount(10); comboBox.setKeySelectionManager(new StringKeyManager(comboBox)); comboBox.setName(attributeName); @@ -782,12 +771,10 @@ spellNumber = undefinedSpellIndex; } - // do we have "none" spell? final int selectedIndex; if (spellNumber == undefinedSpellIndex && isZSpell) { selectedIndex = 0; } else { - // now look up the spell-number in the array of spells selectedIndex = 1 + AbstractArchetypeAttributeSpell.findSpellIndex(numberSpells, spellNumber); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-07-18 20:34:12
|
Revision: 9355 http://sourceforge.net/p/gridarta/code/9355 Author: akirschbaum Date: 2013-07-18 20:34:08 +0000 (Thu, 18 Jul 2013) Log Message: ----------- Do not confuse attribute value and list index. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/AttributesPaneBuilder.java Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/AttributesPaneBuilder.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/AttributesPaneBuilder.java 2013-07-18 19:35:20 UTC (rev 9354) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/AttributesPaneBuilder.java 2013-07-18 20:34:08 UTC (rev 9355) @@ -748,20 +748,17 @@ // build the array of list-items final String[] array = new String[listData.size()]; boolean hasSelection = false; - int active = attributes.getAttributeInt(archetypeAttributeName); + final int value = attributes.getAttributeInt(archetypeAttributeName); + int selectedIndex = 0; for (int i = 0; i < array.length; i++) { array[i] = listData.get(i).getSecond(); - if (!hasSelection && listData.get(i).getFirst() == active) { + if (!hasSelection && listData.get(i).getFirst() == value) { hasSelection = true; - active = i; // set selection to this index in the array + selectedIndex = i; // set selection to this index in the array } } - // if there is no valid pre-selection, show first element of list - if (!hasSelection) { - active = 0; - } final JComboBox comboBox = new JComboBox(array); // set "content" - comboBox.setSelectedIndex(active); // set active selection + comboBox.setSelectedIndex(selectedIndex); // set active selection comboBox.setMaximumRowCount(10); comboBox.setKeySelectionManager(new StringKeyManager(comboBox)); comboBox.setName(attributeName); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-07-18 19:35:25
|
Revision: 9354 http://sourceforge.net/p/gridarta/code/9354 Author: akirschbaum Date: 2013-07-18 19:35:20 +0000 (Thu, 18 Jul 2013) Log Message: ----------- Simplify code. Modified Paths: -------------- trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/model/io/DefaultGameObjectParser.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/renderer/ToolTipAppender.java trunk/src/model/src/main/java/net/sf/gridarta/model/io/AbstractGameObjectParser.java Modified: trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/model/io/DefaultGameObjectParser.java =================================================================== --- trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/model/io/DefaultGameObjectParser.java 2013-07-15 20:35:51 UTC (rev 9353) +++ trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/model/io/DefaultGameObjectParser.java 2013-07-18 19:35:20 UTC (rev 9354) @@ -293,7 +293,7 @@ * @param key the key to add */ private static void addKey(final String key) { - keys.put(key.equals("msg") || key.equals("lore") ? key + "\n" : key + " ", idKey++); + keys.put(key, idKey++); } /** Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/renderer/ToolTipAppender.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/renderer/ToolTipAppender.java 2013-07-15 20:35:51 UTC (rev 9353) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/renderer/ToolTipAppender.java 2013-07-18 19:35:20 UTC (rev 9354) @@ -75,8 +75,8 @@ } } else { final Map<String, String> fields = gameObjectParser != null ? gameObjectParser.getModifiedFields(gameObject) : Collections.<String, String>emptyMap(); - fields.remove("x "); - fields.remove("y "); + fields.remove("x"); + fields.remove("y"); if (alwaysInclude || !fields.isEmpty() || !gameObject.isEmpty()) { if (empty) { empty = false; @@ -88,7 +88,7 @@ for (final Map.Entry<String, String> field : fields.entrySet()) { sb.append("<br>"); sb.append(prefix); - sb.append((encode(field.getKey()) + encode(field.getValue())).trim().replaceAll("\n", "<br>" + prefix)); + sb.append((encode(field.getKey()) + " " + encode(field.getValue())).trim().replaceAll("\n", "<br>" + prefix)); } for (final G invGameObject : gameObject.reverse()) { appendGameObject(invGameObject, true, prefix + " "); Modified: trunk/src/model/src/main/java/net/sf/gridarta/model/io/AbstractGameObjectParser.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/io/AbstractGameObjectParser.java 2013-07-15 20:35:51 UTC (rev 9353) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/io/AbstractGameObjectParser.java 2013-07-18 19:35:20 UTC (rev 9354) @@ -212,9 +212,17 @@ appendable.append(gameObject.getArchetype().getArchetypeName()); appendable.append("\n"); for (final Entry<String, String> entry : fields.entrySet()) { - appendable.append(entry.getKey()); - appendable.append(entry.getValue()); - appendable.append("\n"); + final String key = entry.getKey(); + appendable.append(key); + if (key.equals("msg")) { + appendable.append("\n"); + appendable.append(entry.getValue()); + appendable.append("endmsg\n"); + } else { + appendable.append(" "); + appendable.append(entry.getValue()); + appendable.append("\n"); + } } for (final G inventoryItem : gameObject) { @@ -234,7 +242,7 @@ final String msgText = gameObject.getMsgText(); final String archMsgText = archetype.getMsgText(); if (msgText != null && !msgText.equals(archMsgText == null ? "" : archMsgText)) { - fields.put("msg\n", msgText + "endmsg"); + fields.put("msg", msgText); } final CharSequence objText = gameObject.getObjectText(); @@ -242,7 +250,7 @@ for (final String aTmp : StringUtils.PATTERN_END_OF_LINE.split(objText, 0)) { final String[] line = StringUtils.PATTERN_SPACES.split(aTmp, 2); if (line.length == 2) { - fields.put(line[0] + " ", line[1]); + fields.put(line[0], line[1]); } else { log.warn("writeMapArch: ignoring invalid arch line: " + aTmp); } @@ -251,10 +259,10 @@ // map coordinates only belong into map arches (not inventory arches) if (gameObject.getMapX() != 0) { - fields.put("x ", Integer.toString(gameObject.getMapX())); + fields.put("x", Integer.toString(gameObject.getMapX())); } if (gameObject.getMapY() != 0) { - fields.put("y ", Integer.toString(gameObject.getMapY())); + fields.put("y", Integer.toString(gameObject.getMapY())); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-07-15 20:36:00
|
Revision: 9353 http://sourceforge.net/p/gridarta/code/9353 Author: akirschbaum Date: 2013-07-15 20:35:51 +0000 (Mon, 15 Jul 2013) Log Message: ----------- Remove unused code. Modified Paths: -------------- trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/GameObjectText.java Modified: trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/GameObjectText.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/GameObjectText.java 2013-07-15 20:01:43 UTC (rev 9352) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/GameObjectText.java 2013-07-15 20:35:51 UTC (rev 9353) @@ -146,14 +146,6 @@ } /** - * Clears the object text. - */ - public void resetObjectText() { - objectText.setLength(0); - clearAttributeCache(); - } - - /** * Sets the object text. * @param objectText the object text to set * @return whether the object text was changed This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-07-15 20:01:46
|
Revision: 9352 http://sourceforge.net/p/gridarta/code/9352 Author: akirschbaum Date: 2013-07-15 20:01:43 +0000 (Mon, 15 Jul 2013) Log Message: ----------- Merge duplicated code. Modified Paths: -------------- trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/AbstractBaseObject.java Modified: trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/AbstractBaseObject.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/AbstractBaseObject.java 2013-07-15 19:56:58 UTC (rev 9351) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/AbstractBaseObject.java 2013-07-15 20:01:43 UTC (rev 9352) @@ -357,12 +357,7 @@ return; } - beginGameObjectChange(); - try { - updateCachedAttributes(); - } finally { - endGameObjectChange(); - } + updateCachedAttributes(); } /** @@ -375,12 +370,7 @@ return; } - beginGameObjectChange(); - try { - updateCachedAttributes(); - } finally { - endGameObjectChange(); - } + updateCachedAttributes(); } /** @@ -392,12 +382,7 @@ return; } - beginGameObjectChange(); - try { - updateCachedAttributes(); - } finally { - endGameObjectChange(); - } + updateCachedAttributes(); } /** @@ -773,12 +758,7 @@ return; } - beginGameObjectChange(); - try { - updateCachedAttributes(); - } finally { - endGameObjectChange(); - } + updateCachedAttributes(); } /** @@ -790,12 +770,7 @@ return; } - beginGameObjectChange(); - try { - updateCachedAttributes(); - } finally { - endGameObjectChange(); - } + updateCachedAttributes(); } /** @@ -1195,12 +1170,17 @@ * whenever the object text has changed. */ private void updateCachedAttributes() { - direction = getAttributeInt(DIRECTION); - setFaceName(getAttributeString(FACE)); - setAnimName(getAttributeString(ANIMATION)); - setTypeNo(getAttributeInt(TYPE)); - setObjName(getAttributeString(NAME)); - setObjectFace(); + beginGameObjectChange(); + try { + direction = getAttributeInt(DIRECTION); + setFaceName(getAttributeString(FACE)); + setAnimName(getAttributeString(ANIMATION)); + setTypeNo(getAttributeInt(TYPE)); + setObjName(getAttributeString(NAME)); + setObjectFace(); + } finally { + endGameObjectChange(); + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-07-15 19:57:05
|
Revision: 9351 http://sourceforge.net/p/gridarta/code/9351 Author: akirschbaum Date: 2013-07-15 19:56:58 +0000 (Mon, 15 Jul 2013) Log Message: ----------- Move code from AbstractBaseObject to GameObjectText. Modified Paths: -------------- trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/AbstractBaseObject.java trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/GameObjectText.java Modified: trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/AbstractBaseObject.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/AbstractBaseObject.java 2013-07-15 19:53:29 UTC (rev 9350) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/AbstractBaseObject.java 2013-07-15 19:56:58 UTC (rev 9351) @@ -352,11 +352,6 @@ */ @Override public void setAttributeString(@NotNull final String attributeName, @NotNull final String value) { - if (value.isEmpty()) { - removeAttribute(attributeName); - return; - } - final boolean sameAsInArchetype = getArchetype().getAttributeString(attributeName).equals(value); if (!gameObjectText.setAttributeValue(attributeName, sameAsInArchetype, value)) { return; Modified: trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/GameObjectText.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/GameObjectText.java 2013-07-15 19:53:29 UTC (rev 9350) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/GameObjectText.java 2013-07-15 19:56:58 UTC (rev 9351) @@ -226,6 +226,10 @@ * @return whether the object text has changed */ public boolean setAttributeValue(@NotNull final String attributeName, final boolean sameAsInArchetype, @NotNull final String value) { + if (value.isEmpty()) { + return removeAttribute(attributeName); + } + final String attributeNameWithSpace = attributeName.trim() + " "; boolean exists = false; final StringBuilder result = new StringBuilder(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-07-15 19:53:36
|
Revision: 9350 http://sourceforge.net/p/gridarta/code/9350 Author: akirschbaum Date: 2013-07-15 19:53:29 +0000 (Mon, 15 Jul 2013) Log Message: ----------- Move code from AbstractBaseObject to GameObjectText. Modified Paths: -------------- trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/AbstractBaseObject.java trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/GameObjectText.java Modified: trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/AbstractBaseObject.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/AbstractBaseObject.java 2013-07-15 19:48:50 UTC (rev 9349) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/AbstractBaseObject.java 2013-07-15 19:53:29 UTC (rev 9350) @@ -358,7 +358,16 @@ } final boolean sameAsInArchetype = getArchetype().getAttributeString(attributeName).equals(value); - setAttributeValue(attributeName, sameAsInArchetype, value); + if (!gameObjectText.setAttributeValue(attributeName, sameAsInArchetype, value)) { + return; + } + + beginGameObjectChange(); + try { + updateCachedAttributes(); + } finally { + endGameObjectChange(); + } } /** @@ -367,36 +376,16 @@ @Override public void setAttributeInt(@NotNull final String attributeName, final int value) { final boolean sameAsInArchetype = getArchetype().getAttributeInt(attributeName) == value; - setAttributeValue(attributeName, sameAsInArchetype, Integer.toString(value)); - } + if (!gameObjectText.setAttributeValue(attributeName, sameAsInArchetype, Integer.toString(value))) { + return; + } - /** - * Updates an attribute's value. - * @param attributeName the attribute name - * @param sameAsInArchetype whether the new value is the same as in the - * archetype - * @param value the new value - */ - private void setAttributeValue(@NotNull final String attributeName, final boolean sameAsInArchetype, @NotNull final String value) { - final String attributeNameWithSpace = attributeName.trim() + " "; - boolean exists = false; - final StringBuilder result = new StringBuilder(); - for (final String line : StringUtils.PATTERN_END_OF_LINE.split(getObjectText(), 0)) { - if (line.isEmpty()) { - // skip empty lines that occur due to split on empty object texts. - } else if (!line.startsWith(attributeNameWithSpace)) { - result.append(line).append('\n'); - } else { - exists = true; - if (!sameAsInArchetype) { - result.append(attributeNameWithSpace).append(value).append('\n'); - } - } + beginGameObjectChange(); + try { + updateCachedAttributes(); + } finally { + endGameObjectChange(); } - if (!exists && !sameAsInArchetype) { - result.append(attributeNameWithSpace).append(value).append('\n'); - } - setObjectText(result.toString()); } /** Modified: trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/GameObjectText.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/GameObjectText.java 2013-07-15 19:48:50 UTC (rev 9349) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/GameObjectText.java 2013-07-15 19:53:29 UTC (rev 9350) @@ -217,4 +217,34 @@ return setObjectText(sb.toString()); } + /** + * Updates an attribute's value. + * @param attributeName the attribute name + * @param sameAsInArchetype whether the new value is the same as in the + * archetype + * @param value the new value + * @return whether the object text has changed + */ + public boolean setAttributeValue(@NotNull final String attributeName, final boolean sameAsInArchetype, @NotNull final String value) { + final String attributeNameWithSpace = attributeName.trim() + " "; + boolean exists = false; + final StringBuilder result = new StringBuilder(); + for (final String line : StringUtils.PATTERN_END_OF_LINE.split(objectText.toString(), 0)) { + if (line.isEmpty()) { + // skip empty lines that occur due to split on empty object texts. + } else if (!line.startsWith(attributeNameWithSpace)) { + result.append(line).append('\n'); + } else { + exists = true; + if (!sameAsInArchetype) { + result.append(attributeNameWithSpace).append(value).append('\n'); + } + } + } + if (!exists && !sameAsInArchetype) { + result.append(attributeNameWithSpace).append(value).append('\n'); + } + return setObjectText(result.toString()); + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-07-15 19:49:03
|
Revision: 9349 http://sourceforge.net/p/gridarta/code/9349 Author: akirschbaum Date: 2013-07-15 19:48:50 +0000 (Mon, 15 Jul 2013) Log Message: ----------- Replace length() == 0 with isEmpty(). Modified Paths: -------------- trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/gui/mappropertiesdialog/MapPropertiesDialog.java trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/model/io/MapArchObjectParser.java trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/model/scripts/DefaultScriptedEvent.java trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/gui/mappropertiesdialog/MapPropertiesDialog.java trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/model/io/MapArchObjectParser.java trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/model/maparchobject/MapArchObject.java trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/model/scripts/DefaultScriptedEvent.java trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/gui/mappropertiesdialog/MapPropertiesDialog.java trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/model/io/MapArchObjectParser.java trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/model/scripts/DefaultScriptedEvent.java trunk/src/gridarta/src/main/java/net/sf/gridarta/actions/AttachTiledMaps.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/AttributesPaneBuilder.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeAnimationName.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeBitmask.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeFaceName.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeFloat.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeInt.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeInvSpell.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeList.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeLong.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeMapPath.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeScriptFile.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeSpell.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeString.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeText.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeTreasure.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeZSpell.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/newmap/NewMapDialog.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapactions/MapActions.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/maptilepane/TilePanel.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/renderer/ToolTipAppender.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapfiles/MapFolder.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/connectionview/LockedItemsView.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/gameobjectattributes/ArchTab.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/gameobjectattributes/FaceTab.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/gameobjectattributes/MsgTextTab.java trunk/src/gridarta/src/main/java/net/sf/gridarta/updater/UpdaterManager.java trunk/src/model/src/main/java/net/sf/gridarta/model/archetype/AbstractArchetype.java trunk/src/model/src/main/java/net/sf/gridarta/model/archetype/AttributeListUtils.java trunk/src/model/src/main/java/net/sf/gridarta/model/archetypetype/ArchetypeAttributeDefinition.java trunk/src/model/src/main/java/net/sf/gridarta/model/archetypetype/ArchetypeType.java trunk/src/model/src/main/java/net/sf/gridarta/model/archetypetype/ArchetypeTypeSetParser.java trunk/src/model/src/main/java/net/sf/gridarta/model/archetypetype/AttributeBitmask.java trunk/src/model/src/main/java/net/sf/gridarta/model/autojoin/AutojoinListsParser.java trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/AbstractBaseObject.java trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/GameObjectText.java trunk/src/model/src/main/java/net/sf/gridarta/model/gameobject/AbstractGameObject.java trunk/src/model/src/main/java/net/sf/gridarta/model/gameobject/GameObjectUtils.java trunk/src/model/src/main/java/net/sf/gridarta/model/gameobject/MultiPositionData.java trunk/src/model/src/main/java/net/sf/gridarta/model/io/AbstractArchetypeParser.java trunk/src/model/src/main/java/net/sf/gridarta/model/io/AbstractGameObjectParser.java trunk/src/model/src/main/java/net/sf/gridarta/model/io/AbstractMapArchObjectParser.java trunk/src/model/src/main/java/net/sf/gridarta/model/io/AnimationObjectsReader.java trunk/src/model/src/main/java/net/sf/gridarta/model/maparchobject/AbstractMapArchObject.java trunk/src/model/src/main/java/net/sf/gridarta/model/mappathnormalizer/MapPathNormalizer.java trunk/src/model/src/main/java/net/sf/gridarta/model/match/GameObjectMatcherParser.java trunk/src/model/src/main/java/net/sf/gridarta/model/scripts/ScriptUtils.java trunk/src/model/src/main/java/net/sf/gridarta/model/smoothface/SmoothFacesLoader.java trunk/src/model/src/main/java/net/sf/gridarta/model/spells/GameObjectSpell.java trunk/src/model/src/main/java/net/sf/gridarta/model/treasurelist/TreasureLoader.java trunk/src/model/src/main/java/net/sf/gridarta/model/validation/checks/ConnectedInsideContainerChecker.java trunk/src/model/src/main/java/net/sf/gridarta/model/validation/checks/ConnectedPickableChecker.java trunk/src/model/src/main/java/net/sf/gridarta/model/validation/checks/TilePathsChecker.java trunk/src/model/src/test/java/net/sf/gridarta/model/io/TestMapArchObjectParser.java trunk/src/preferences/src/main/java/net/sf/gridarta/preferences/Storage.java trunk/src/textedit/src/main/java/net/sf/gridarta/textedit/scripteditor/CFPythonPopup.java trunk/src/textedit/src/main/java/net/sf/gridarta/textedit/scripteditor/ScriptEditControl.java trunk/src/textedit/src/main/java/net/sf/gridarta/textedit/textarea/DefaultInputHandler.java trunk/src/textedit/src/main/java/net/sf/gridarta/textedit/textarea/actions/Find.java trunk/src/textedit/src/main/java/net/sf/gridarta/textedit/textarea/actions/FunctionMenu.java trunk/src/textedit/src/main/java/net/sf/gridarta/textedit/textarea/actions/Paste.java trunk/src/textedit/src/main/java/net/sf/gridarta/textedit/textarea/tokenmarker/DaimoninAITokenMarker.java Modified: trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/gui/mappropertiesdialog/MapPropertiesDialog.java =================================================================== --- trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/gui/mappropertiesdialog/MapPropertiesDialog.java 2013-07-15 19:29:09 UTC (rev 9348) +++ trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/gui/mappropertiesdialog/MapPropertiesDialog.java 2013-07-15 19:48:50 UTC (rev 9349) @@ -658,7 +658,7 @@ mainControl.showMessage("Illegal Value", "Darkness level must be in range 0-1000." ); return false; }*/ - if (mapName.getText().length() == 0) { + if (mapName.getText().isEmpty()) { ACTION_BUILDER.showMessageDialog(this, "mapErrorMissingMapName"); return false; } @@ -721,7 +721,7 @@ * @throws IllegalArgumentException when parsing fails */ private static int parseProperty(@NotNull final String s, @NotNull final String label) { - if (s.length() == 0) { + if (s.isEmpty()) { return 0; // empty string is interpreted as zero } final int r = Integer.parseInt(s); // trying to parse Modified: trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/model/io/MapArchObjectParser.java =================================================================== --- trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/model/io/MapArchObjectParser.java 2013-07-15 19:29:09 UTC (rev 9348) +++ trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/model/io/MapArchObjectParser.java 2013-07-15 19:48:50 UTC (rev 9349) @@ -42,7 +42,7 @@ public void save(@NotNull final Appendable appendable, @NotNull final MapArchObject mapArchObject) throws IOException { final Formatter format = new Formatter(appendable); appendable.append("arch map\n"); - if (mapArchObject.getMapName().length() > 0) { + if (!mapArchObject.getMapName().isEmpty()) { format.format("name %s\n", mapArchObject.getMapName()); } format.format("msg\n%s%sendmsg\n", mapArchObject.getText().trim(), "\n"); @@ -103,7 +103,7 @@ appendable.append("pvp 1\n"); } for (final Direction direction : Direction.values()) { - if (mapArchObject.getTilePath(direction).length() > 0) { + if (!mapArchObject.getTilePath(direction).isEmpty()) { format.format("tile_path_%d %s\n", direction.ordinal() + 1, mapArchObject.getTilePath(direction)); } } @@ -113,15 +113,15 @@ format.format("tileset_y %d\n", mapArchObject.getTilesetY()); } final String backgroundMusic = mapArchObject.getBackgroundMusic(); - if (backgroundMusic.length() > 0) { + if (!backgroundMusic.isEmpty()) { format.format("bg_music %s\n", backgroundMusic); } final String region = mapArchObject.getRegion(); - if (region.length() > 0) { + if (!region.isEmpty()) { format.format("region %s\n", region); } final String weather = mapArchObject.getWeather(); - if (weather.length() > 0) { + if (!weather.isEmpty()) { format.format("weather %s\n", weather); } appendable.append("end\n"); Modified: trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/model/scripts/DefaultScriptedEvent.java =================================================================== --- trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/model/scripts/DefaultScriptedEvent.java 2013-07-15 19:29:09 UTC (rev 9348) +++ trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/model/scripts/DefaultScriptedEvent.java 2013-07-15 19:48:50 UTC (rev 9349) @@ -116,13 +116,13 @@ final String newPluginName = scriptedEventEditor.getInputPluginName(); final String newOptions = scriptedEventEditor.getInputOptions(); - if (newPath.length() > 0) { + if (!newPath.isEmpty()) { setScriptPath(newPath); } - if (newPluginName.length() > 0) { + if (!newPluginName.isEmpty()) { setPluginName(newPluginName); } - if (newOptions.length() > 0) { + if (!newOptions.isEmpty()) { setOptions(newOptions); } } Modified: trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/gui/mappropertiesdialog/MapPropertiesDialog.java =================================================================== --- trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/gui/mappropertiesdialog/MapPropertiesDialog.java 2013-07-15 19:29:09 UTC (rev 9348) +++ trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/gui/mappropertiesdialog/MapPropertiesDialog.java 2013-07-15 19:48:50 UTC (rev 9349) @@ -709,7 +709,7 @@ ACTION_BUILDER.showMessageDialog(this, "mapErrorInvalidDarkness"); return false; } - if (mapName.getText().length() == 0) { + if (mapName.getText().isEmpty()) { ACTION_BUILDER.showMessageDialog(this, "mapErrorMissingMapName"); return false; } @@ -777,7 +777,7 @@ * @throws IllegalArgumentException when parsing fails */ private static int parseProperty(@NotNull final String s, @NotNull final String label) { - if (s.length() == 0) { + if (s.isEmpty()) { return 0; // empty string is interpreted as zero } @@ -807,7 +807,7 @@ * @throws IllegalArgumentException when parsing fails */ private static double parsePropertyToDouble(@NotNull final String s, @NotNull final String label) { - if (s.length() == 0) { + if (s.isEmpty()) { return 0.0; // empty string is interpreted as zero } Modified: trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/model/io/MapArchObjectParser.java =================================================================== --- trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/model/io/MapArchObjectParser.java 2013-07-15 19:29:09 UTC (rev 9348) +++ trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/model/io/MapArchObjectParser.java 2013-07-15 19:48:50 UTC (rev 9349) @@ -50,7 +50,7 @@ public void save(@NotNull final Appendable appendable, @NotNull final MapArchObject mapArchObject) throws IOException { final Formatter format = new Formatter(appendable); appendable.append("arch map\n"); - if (mapArchObject.getMapName().length() > 0) { + if (!mapArchObject.getMapName().isEmpty()) { format.format("name %s\n", mapArchObject.getMapName()); } if (mapArchObject.getSwapTime() != 0) { @@ -65,10 +65,10 @@ if (mapArchObject.getDifficulty() != 0) { format.format("difficulty %d\n", mapArchObject.getDifficulty()); } - if (mapArchObject.getRegion().length() > 0) { + if (!mapArchObject.getRegion().isEmpty()) { format.format("region %s\n", mapArchObject.getRegion()); } - if (mapArchObject.getShopItems().length() > 0) { + if (!mapArchObject.getShopItems().isEmpty()) { format.format("shopitems %s\n", mapArchObject.getShopItems()); } // The following floating point equality comparison is assumed to be okay @@ -81,7 +81,7 @@ if (mapArchObject.getShopMax() != 0) { format.format("shopmax %d\n", mapArchObject.getShopMax()); } - if (mapArchObject.getShopRace().length() > 0) { + if (!mapArchObject.getShopRace().isEmpty()) { format.format("shoprace %s\n", mapArchObject.getShopRace()); } if (mapArchObject.getDarkness() != 0) { @@ -95,10 +95,10 @@ if (mapArchObject.getEnterY() != 0) { format.format("enter_y %d\n", mapArchObject.getEnterY()); } - if (mapArchObject.getText().trim().length() > 0) { + if (!mapArchObject.getText().trim().isEmpty()) { format.format("msg\n" + "%s\n" + "endmsg\n", mapArchObject.getText().trim()); } - if (mapArchObject.getLore().trim().length() > 0) { + if (!mapArchObject.getLore().trim().isEmpty()) { format.format("maplore\n" + "%s\n" + "endmaplore\n", mapArchObject.getLore().trim()); } if (mapArchObject.isUnique()) { @@ -129,14 +129,14 @@ format.format("sky %d\n", mapArchObject.getSky()); } for (final Direction direction : Direction.values()) { - if (mapArchObject.getTilePath(direction).length() > 0) { + if (!mapArchObject.getTilePath(direction).isEmpty()) { format.format("tile_path_%d %s\n", direction.ordinal() + 1, mapArchObject.getTilePath(direction)); } } if (mapArchObject.isNoSmooth()) { appendable.append("nosmooth 1\n"); } - if (mapArchObject.getBackgroundMusic().length() > 0) { + if (!mapArchObject.getBackgroundMusic().isEmpty()) { format.format("background_music %s\n", mapArchObject.getBackgroundMusic()); } appendable.append("end\n"); @@ -233,7 +233,7 @@ break; } - if (mapArchObject.getLore().length() > 0) { + if (!mapArchObject.getLore().isEmpty()) { mapArchObject.addLore("\n"); } mapArchObject.addLore(loreLine); Modified: trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/model/maparchobject/MapArchObject.java =================================================================== --- trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/model/maparchobject/MapArchObject.java 2013-07-15 19:29:09 UTC (rev 9348) +++ trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/model/maparchobject/MapArchObject.java 2013-07-15 19:48:50 UTC (rev 9349) @@ -560,7 +560,7 @@ * @param text the text to append */ public void addLore(@NotNull final String text) { - if (text.length() == 0) { + if (text.isEmpty()) { return; } Modified: trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/model/scripts/DefaultScriptedEvent.java =================================================================== --- trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/model/scripts/DefaultScriptedEvent.java 2013-07-15 19:29:09 UTC (rev 9348) +++ trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/model/scripts/DefaultScriptedEvent.java 2013-07-15 19:48:50 UTC (rev 9349) @@ -116,10 +116,10 @@ final String newPluginName = scriptedEventEditor.getInputPluginName(); final String newOptions = scriptedEventEditor.getInputOptions(); - if (newPath.length() > 0) { + if (!newPath.isEmpty()) { setScriptPath(newPath); } - if (newPluginName.length() > 0) { + if (!newPluginName.isEmpty()) { setPluginName(newPluginName); } setOptions(newOptions); // unlike the above two, event options can be empty Modified: trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/gui/mappropertiesdialog/MapPropertiesDialog.java =================================================================== --- trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/gui/mappropertiesdialog/MapPropertiesDialog.java 2013-07-15 19:29:09 UTC (rev 9348) +++ trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/gui/mappropertiesdialog/MapPropertiesDialog.java 2013-07-15 19:48:50 UTC (rev 9349) @@ -643,7 +643,7 @@ mainControl.showMessage("Illegal Value", "Darkness level must be in range 0-1000." ); return false; }*/ - if (mapName.getText().length() == 0) { + if (mapName.getText().isEmpty()) { ACTION_BUILDER.showMessageDialog(this, "mapErrorMissingMapName"); return false; } @@ -704,7 +704,7 @@ * @throws IllegalArgumentException if parsing fails */ private static int parseProperty(@NotNull final String s, @NotNull final String label) { - if (s.length() == 0) { + if (s.isEmpty()) { return 0; // empty string is interpreted as zero } final int r = Integer.parseInt(s); // trying to parse Modified: trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/model/io/MapArchObjectParser.java =================================================================== --- trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/model/io/MapArchObjectParser.java 2013-07-15 19:29:09 UTC (rev 9348) +++ trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/model/io/MapArchObjectParser.java 2013-07-15 19:48:50 UTC (rev 9349) @@ -42,7 +42,7 @@ public void save(@NotNull final Appendable appendable, @NotNull final MapArchObject mapArchObject) throws IOException { final Formatter format = new Formatter(appendable); appendable.append("arch map\n"); - if (mapArchObject.getMapName().length() > 0) { + if (!mapArchObject.getMapName().isEmpty()) { format.format("name %s\n", mapArchObject.getMapName()); } format.format("msg\n%s%sendmsg\n", mapArchObject.getText().trim(), "\n"); @@ -103,7 +103,7 @@ appendable.append("pvp 1\n"); } for (final Direction direction : Direction.values()) { - if (mapArchObject.getTilePath(direction).length() > 0) { + if (!mapArchObject.getTilePath(direction).isEmpty()) { format.format("tile_path_%d %s\n", direction.ordinal() + 1, mapArchObject.getTilePath(direction)); } } Modified: trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/model/scripts/DefaultScriptedEvent.java =================================================================== --- trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/model/scripts/DefaultScriptedEvent.java 2013-07-15 19:29:09 UTC (rev 9348) +++ trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/model/scripts/DefaultScriptedEvent.java 2013-07-15 19:48:50 UTC (rev 9349) @@ -116,13 +116,13 @@ final String newPluginName = scriptedEventEditor.getInputPluginName(); final String newOptions = scriptedEventEditor.getInputOptions(); - if (newPath.length() > 0) { + if (!newPath.isEmpty()) { setScriptPath(newPath); } - if (newPluginName.length() > 0) { + if (!newPluginName.isEmpty()) { setPluginName(newPluginName); } - if (newOptions.length() > 0) { + if (!newOptions.isEmpty()) { setOptions(newOptions); } } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/actions/AttachTiledMaps.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/actions/AttachTiledMaps.java 2013-07-15 19:29:09 UTC (rev 9348) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/actions/AttachTiledMaps.java 2013-07-15 19:48:50 UTC (rev 9349) @@ -193,7 +193,7 @@ final Direction direction = mapLink.getMapDirection(); if (mapControls.get(direction.ordinal()) == null) { final String tilePath = mapControl.getMapModel().getMapArchObject().getTilePath(mapLink.getLinkDirection()); - if (tilePath.length() > 0) { + if (!tilePath.isEmpty()) { try { mapControls.set(direction.ordinal(), loadMapControl(mapControl.getMapModel(), tilePath)); repeatFlag = true; @@ -331,7 +331,7 @@ final String sep = Matcher.quoteReplacement(File.separator); /* our map is in root - second is higher or same map */ - if (first.length() == 0) { + if (first.isEmpty()) { return link.substring(mapDirectory.length()).trim().replaceAll(sep, "/"); } // same folder... we return the name without '/' Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/AttributesPaneBuilder.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/AttributesPaneBuilder.java 2013-07-15 19:29:09 UTC (rev 9348) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/AttributesPaneBuilder.java 2013-07-15 19:48:50 UTC (rev 9349) @@ -301,10 +301,10 @@ @Override public void visit(@NotNull final ArchetypeAttributeBoolSpec archetypeAttribute) { - final CharSequence attributeString = attributes.getAttributeString(archetypeAttribute.getArchetypeAttributeName()); + final String attributeString = attributes.getAttributeString(archetypeAttribute.getArchetypeAttributeName()); final boolean defaultValue; if (archetypeAttribute.getTrueValue().equals("0")) { - defaultValue = attributeString.length() == 0 || attributeString.equals("0"); + defaultValue = attributeString.isEmpty() || attributeString.equals("0"); } else { defaultValue = attributeString.equals(archetypeAttribute.getTrueValue()); } @@ -449,7 +449,7 @@ final GameObject<?, ?, ?> tmp = (GameObject<?, ?, ?>) attributes; final String archetypeMsgText = tmp.getArchetype().getMsgText(); final String gameObjectMsgText = tmp.getMsgText(); - if (archetypeMsgText != null && archetypeMsgText.length() > 0 && (gameObjectMsgText == null || gameObjectMsgText.length() == 0)) { + if (archetypeMsgText != null && !archetypeMsgText.isEmpty() && (gameObjectMsgText == null || gameObjectMsgText.isEmpty())) { text = archetypeMsgText; } else { text = gameObjectMsgText; @@ -471,7 +471,7 @@ public void visit(@NotNull final ArchetypeAttributeTreasure archetypeAttribute) { // textfield (no direct input, text is set by the treasurelist dialog) String treasureName = attributes.getAttributeString(archetypeAttribute.getArchetypeAttributeName()); - if (treasureName.trim().length() == 0 || treasureName.trim().equalsIgnoreCase("none")) { + if (treasureName.trim().isEmpty() || treasureName.trim().equalsIgnoreCase("none")) { treasureName = CFTreasureListTree.NONE_SYM; } final JTextField input = new JTextField(" " + treasureName, ArchetypeAttribute.TEXTFIELD_COLUMNS); Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeAnimationName.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeAnimationName.java 2013-07-15 19:29:09 UTC (rev 9348) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeAnimationName.java 2013-07-15 19:48:50 UTC (rev 9349) @@ -70,7 +70,7 @@ @Override public void appendSummary(@NotNull final Document doc, @NotNull final Style style) { final String value = input.getAnimName(); - if (value.length() > 0) { + if (!value.isEmpty()) { addLine(doc, style, getRef().getAttributeName() + " = " + value); } } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeBitmask.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeBitmask.java 2013-07-15 19:29:09 UTC (rev 9348) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeBitmask.java 2013-07-15 19:48:50 UTC (rev 9349) @@ -79,8 +79,8 @@ public String getText2(@NotNull final G gameObject, @NotNull final Archetype<G, A, R> archetype, final String[] newMsg, final ArchetypeType archetypeType, final Component parent) { final String encodedValue = getEncodedValue(); // get bitmask value final String archetypeAttributeName = getRef().getArchetypeAttributeName(); - CharSequence oldValue = archetype.getAttributeString(archetypeAttributeName); - if (oldValue.length() == 0) { + String oldValue = archetype.getAttributeString(archetypeAttributeName); + if (oldValue.isEmpty()) { oldValue = "0"; } @@ -97,7 +97,7 @@ @Override public void appendSummary(@NotNull final Document doc, @NotNull final Style style) { final String tmp = input.getText().trim(); - if (tmp.length() > 0 && !tmp.startsWith("<")) { + if (!tmp.isEmpty() && !tmp.startsWith("<")) { addLine(doc, style, getRef().getAttributeName() + " = " + tmp); } } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeFaceName.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeFaceName.java 2013-07-15 19:29:09 UTC (rev 9348) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeFaceName.java 2013-07-15 19:48:50 UTC (rev 9349) @@ -70,7 +70,7 @@ @Override public void appendSummary(@NotNull final Document doc, @NotNull final Style style) { final String value = input.getFaceName(); - if (value.length() > 0) { + if (!value.isEmpty()) { addLine(doc, style, getRef().getAttributeName() + " = " + value); } } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeFloat.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeFloat.java 2013-07-15 19:29:09 UTC (rev 9348) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeFloat.java 2013-07-15 19:48:50 UTC (rev 9349) @@ -57,7 +57,7 @@ @Override public String getText2(@NotNull final G gameObject, @NotNull final Archetype<G, A, R> archetype, final String[] newMsg, final ArchetypeType archetypeType, final Component parent) { final String archetypeAttributeName = getRef().getArchetypeAttributeName(); - if (input.getText().trim().length() == 0) { + if (input.getText().trim().isEmpty()) { if (archetype.hasAttribute(archetypeAttributeName)) { return archetypeAttributeName + " 0.0"; } @@ -85,7 +85,7 @@ @Override public void appendSummary(@NotNull final Document doc, @NotNull final Style style) { final String value = input.getText(); - if (value != null && value.length() > 0 && !value.equals("0")) { + if (value != null && !value.isEmpty() && !value.equals("0")) { addLine(doc, style, getRef().getAttributeName() + " = " + value); } } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeInt.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeInt.java 2013-07-15 19:29:09 UTC (rev 9348) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeInt.java 2013-07-15 19:48:50 UTC (rev 9349) @@ -65,7 +65,7 @@ public String getText2(@NotNull final G gameObject, @NotNull final Archetype<G, A, R> archetype, final String[] newMsg, final ArchetypeType archetypeType, final Component parent) { final String archetypeAttributeName = ref.getArchetypeAttributeName(); final int value; - if (input.getText().trim().length() == 0) { + if (input.getText().trim().isEmpty()) { value = 0; } else { try { @@ -94,7 +94,7 @@ @Override public void appendSummary(@NotNull final Document doc, @NotNull final Style style) { final String value = input.getText(); - if (value != null && value.length() > 0 && !value.equals("0")) { + if (value != null && !value.isEmpty() && !value.equals("0")) { addLine(doc, style, ref.getAttributeName() + " = " + value); } } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeInvSpell.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeInvSpell.java 2013-07-15 19:29:09 UTC (rev 9348) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeInvSpell.java 2013-07-15 19:48:50 UTC (rev 9349) @@ -131,7 +131,7 @@ @Override public void appendSummary(@NotNull final Document doc, @NotNull final Style style) { final String value = input.getSelectedItem().toString().trim(); - if (value.length() > 0 && !value.startsWith("<")) { + if (!value.isEmpty() && !value.startsWith("<")) { addLine(doc, style, getRef().getAttributeName() + " = " + value); } } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeList.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeList.java 2013-07-15 19:29:09 UTC (rev 9348) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeList.java 2013-07-15 19:48:50 UTC (rev 9349) @@ -81,7 +81,7 @@ @Override public void appendSummary(@NotNull final Document doc, @NotNull final Style style) { final String value = input.getSelectedItem().toString().trim(); - if (value.length() > 0 && !value.startsWith("<")) { + if (!value.isEmpty() && !value.startsWith("<")) { addLine(doc, style, getRef().getAttributeName() + " = " + value); } } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeLong.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeLong.java 2013-07-15 19:29:09 UTC (rev 9348) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeLong.java 2013-07-15 19:48:50 UTC (rev 9349) @@ -57,7 +57,7 @@ @Override public String getText2(@NotNull final G gameObject, @NotNull final Archetype<G, A, R> archetype, final String[] newMsg, final ArchetypeType archetypeType, final Component parent) { final String archetypeAttributeName = getRef().getArchetypeAttributeName(); - if (input.getText().trim().length() == 0) { + if (input.getText().trim().isEmpty()) { if (archetype.getAttributeLong(archetypeAttributeName) != 0L) { return archetypeAttributeName + " 0"; } @@ -82,7 +82,7 @@ @Override public void appendSummary(@NotNull final Document doc, @NotNull final Style style) { final String value = input.getText(); - if (value != null && value.length() > 0 && !value.equals("0")) { + if (value != null && !value.isEmpty() && !value.equals("0")) { addLine(doc, style, getRef().getAttributeName() + " = " + value); } } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeMapPath.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeMapPath.java 2013-07-15 19:29:09 UTC (rev 9348) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeMapPath.java 2013-07-15 19:48:50 UTC (rev 9349) @@ -70,7 +70,7 @@ @Override public void appendSummary(@NotNull final Document doc, @NotNull final Style style) { final String value = input.getText(); - if (value != null && value.length() > 0) { + if (value != null && !value.isEmpty()) { addLine(doc, style, getRef().getAttributeName() + " = " + value); } } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeScriptFile.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeScriptFile.java 2013-07-15 19:29:09 UTC (rev 9348) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeScriptFile.java 2013-07-15 19:48:50 UTC (rev 9349) @@ -70,7 +70,7 @@ @Override public void appendSummary(@NotNull final Document doc, @NotNull final Style style) { final String value = input.getText(); - if (value != null && value.length() > 0) { + if (value != null && !value.isEmpty()) { addLine(doc, style, getRef().getAttributeName() + " = " + value); } } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeSpell.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeSpell.java 2013-07-15 19:29:09 UTC (rev 9348) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeSpell.java 2013-07-15 19:48:50 UTC (rev 9349) @@ -81,7 +81,7 @@ @Override public void appendSummary(@NotNull final Document doc, @NotNull final Style style) { final String value = input.getSelectedItem().toString().trim(); - if (value.length() > 0 && !value.startsWith("<")) { + if (!value.isEmpty() && !value.startsWith("<")) { addLine(doc, style, getRef().getAttributeName() + " = " + value); } } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeString.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeString.java 2013-07-15 19:29:09 UTC (rev 9348) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeString.java 2013-07-15 19:48:50 UTC (rev 9349) @@ -72,7 +72,7 @@ @Override public void appendSummary(@NotNull final Document doc, @NotNull final Style style) { final String value = input.getText(); - if (value != null && value.length() > 0) { + if (value != null && !value.isEmpty()) { addLine(doc, style, getRef().getAttributeName() + " = " + value); } } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeText.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeText.java 2013-07-15 19:29:09 UTC (rev 9348) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeText.java 2013-07-15 19:48:50 UTC (rev 9349) @@ -58,7 +58,7 @@ public String getText2(@NotNull final G gameObject, @NotNull final Archetype<G, A, R> archetype, final String[] newMsg, final ArchetypeType archetypeType, final Component parent) { if (getRef().getArchetypeAttributeName().equalsIgnoreCase("msg")) { final String msgText = StringUtils.removeTrailingWhitespaceFromLines(input.getText()); - if (msgText.length() > 0) { + if (!msgText.isEmpty()) { newMsg[0] = msgText; } } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeTreasure.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeTreasure.java 2013-07-15 19:29:09 UTC (rev 9348) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeTreasure.java 2013-07-15 19:48:50 UTC (rev 9349) @@ -69,7 +69,7 @@ @Override public String getText2(@NotNull final G gameObject, @NotNull final Archetype<G, A, R> archetype, final String[] newMsg, final ArchetypeType archetypeType, final Component parent) { final String inline = input.getText().trim(); // input string - final boolean isNone = inline.equals(CFTreasureListTree.NONE_SYM) || inline.length() == 0; + final boolean isNone = inline.equals(CFTreasureListTree.NONE_SYM) || inline.isEmpty(); final String archetypeAttributeName = getRef().getArchetypeAttributeName(); if (!isNone && treasureTree.get(inline) == null && !inline.equalsIgnoreCase(archetype.getAttributeString(archetypeAttributeName))) { // The user has specified a WRONG treasurelist name, and it does not come @@ -95,7 +95,7 @@ @Override public void appendSummary(@NotNull final Document doc, @NotNull final Style style) { final String value = input.getText().trim(); - if (value.length() > 0 && !value.equals(CFTreasureListTree.NONE_SYM)) { + if (!value.isEmpty() && !value.equals(CFTreasureListTree.NONE_SYM)) { addLine(doc, style, getRef().getAttributeName() + " = " + value); } } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeZSpell.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeZSpell.java 2013-07-15 19:29:09 UTC (rev 9348) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeZSpell.java 2013-07-15 19:48:50 UTC (rev 9349) @@ -87,7 +87,7 @@ @Override public void appendSummary(@NotNull final Document doc, @NotNull final Style style) { final String value = input.getSelectedItem().toString().trim(); - if (value.length() > 0 && !value.startsWith("<")) { + if (!value.isEmpty() && !value.startsWith("<")) { addLine(doc, style, getRef().getAttributeName() + " = " + value); } } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java 2013-07-15 19:29:09 UTC (rev 9348) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java 2013-07-15 19:48:50 UTC (rev 9349) @@ -583,12 +583,12 @@ gbc.weightx = 1.0; final JTextComponent nameTextField; final String objName = gameObject.getObjName(); - if (objName.length() > 0) { - nameTextField = new JTextField(objName, 16); - } else { + if (objName.isEmpty()) { final String archObjName = archetype.getObjName(); - final String nameText = archObjName.length() > 0 ? archObjName : archetype.getArchetypeName(); + final String nameText = !archObjName.isEmpty() ? archObjName : archetype.getArchetypeName(); nameTextField = new JTextField(nameText, 16); + } else { + nameTextField = new JTextField(objName, 16); } nameTextField.setEditable(false); header.add(nameTextField, gbc); @@ -719,7 +719,7 @@ if (text == null) { return false; } - if (text.length() > 0) { + if (!text.isEmpty()) { newArchText.append(text).append("\n"); } } @@ -730,7 +730,7 @@ // ### TODO: for changed types, copy fixed attributes over default arches ### if (archetypeAttribute instanceof ArchetypeAttributeFixed) { final String defaultValue = archetype.getAttributeString(archetypeAttribute.getArchetypeAttributeName()); - if (defaultValue.length() == 0 || (gameObject.getTypeNo() != archetype.getTypeNo() && !defaultValue.equalsIgnoreCase(archetypeAttribute.getAttributeName()))) { + if (defaultValue.isEmpty() || (gameObject.getTypeNo() != archetype.getTypeNo() && !defaultValue.equalsIgnoreCase(archetypeAttribute.getAttributeName()))) { // usually, fixed attributes are only applied when *not* defined in the archetype. // the reason behind this is: if the default gameObject violates our fixed attribute, // we assume the default gameObject is "right" and we are "wrong". The typedefs aren't that trustworthy. @@ -757,8 +757,8 @@ final String archetypeMsgText = archetype.getMsgText(); gameObject.setMsgText(msgText.equals(archetypeMsgText == null ? "" : archetypeMsgText) ? null : msgText); } else { - final CharSequence archetypeMsgText = archetype.getMsgText(); - gameObject.setMsgText(archetypeMsgText != null && archetypeMsgText.length() > 0 ? "" : null); + final String archetypeMsgText = archetype.getMsgText(); + gameObject.setMsgText(archetypeMsgText != null && !archetypeMsgText.isEmpty() ? "" : null); } // now lets assign the visible face - perhaps we have still an animation Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/newmap/NewMapDialog.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/newmap/NewMapDialog.java 2013-07-15 19:29:09 UTC (rev 9348) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/newmap/NewMapDialog.java 2013-07-15 19:48:50 UTC (rev 9349) @@ -253,7 +253,7 @@ @Nullable private String getMapName() { final String mapName = mapNameField.getText(); - return mapName.length() > 0 ? mapName : null; + return !mapName.isEmpty() ? mapName : null; } /** Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapactions/MapActions.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapactions/MapActions.java 2013-07-15 19:29:09 UTC (rev 9348) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapactions/MapActions.java 2013-07-15 19:48:50 UTC (rev 9349) @@ -948,7 +948,7 @@ } final String path = mapView.getMapControl().getMapModel().getMapArchObject().getTilePath(direction); - if (path.length() == 0) { + if (path.isEmpty()) { return false; } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/maptilepane/TilePanel.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/maptilepane/TilePanel.java 2013-07-15 19:29:09 UTC (rev 9348) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/maptilepane/TilePanel.java 2013-07-15 19:48:50 UTC (rev 9349) @@ -184,7 +184,7 @@ final File tmpRelativeReference = relativeReference; final JFileChooser chooser = tmpRelativeReference == null ? new JFileChooser() : new JFileChooser(tmpRelativeReference.getParentFile()); final String oldFilename = getText(); - if (oldFilename.length() > 0) { + if (!oldFilename.isEmpty()) { // Point the chooser on the current path tile file final File oldFile; if (tmpRelativeReference == null || oldFilename.startsWith("/")) { Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/renderer/ToolTipAppender.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/renderer/ToolTipAppender.java 2013-07-15 19:29:09 UTC (rev 9348) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/renderer/ToolTipAppender.java 2013-07-15 19:48:50 UTC (rev 9349) @@ -61,7 +61,7 @@ final String objectText = gameObject.getObjectText(); final String msgText = gameObject.getMsgText(); final String text = objectText + (msgText == null ? "" : msgText + "\n" + "msg\n" + msgText + "\n" + "endmsg"); - if (alwaysInclude || text.length() > 0 || !gameObject.isEmpty()) { + if (alwaysInclude || !text.isEmpty() || !gameObject.isEmpty()) { if (empty) { empty = false; } else { Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapfiles/MapFolder.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapfiles/MapFolder.java 2013-07-15 19:29:09 UTC (rev 9348) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapfiles/MapFolder.java 2013-07-15 19:48:50 UTC (rev 9349) @@ -103,7 +103,7 @@ public MapFolder(@Nullable final MapFolder<G, A, R> parent, @NotNull final String name, @NotNull final File baseDir, @NotNull final MapViewsManager<G, A, R> mapViewsManager) throws InvalidNameException { this.baseDir = baseDir; this.mapViewsManager = mapViewsManager; - if (parent == null ? name.length() > 0 : !PATTERN_VALID_MAP_FOLDER_NAME.matcher(name).matches()) { + if (parent == null ? !name.isEmpty() : !PATTERN_VALID_MAP_FOLDER_NAME.matcher(name).matches()) { throw new InvalidNameException(name); } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/connectionview/LockedItemsView.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/connectionview/LockedItemsView.java 2013-07-15 19:29:09 UTC (rev 9348) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/connectionview/LockedItemsView.java 2013-07-15 19:48:50 UTC (rev 9349) @@ -79,7 +79,7 @@ private void scanGameObject(@NotNull final GameObject<G, A, R> gameObject) { if (typeNumbers.contains(gameObject.getTypeNo())) { final String slayingSpec = gameObject.getAttributeString(BaseObject.SLAYING); - if (slayingSpec.length() > 0) { + if (!slayingSpec.isEmpty()) { addConnection(slayingSpec, gameObject); } } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/gameobjectattributes/ArchTab.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/gameobjectattributes/ArchTab.java 2013-07-15 19:29:09 UTC (rev 9348) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/gameobjectattributes/ArchTab.java 2013-07-15 19:48:50 UTC (rev 9349) @@ -277,11 +277,11 @@ setArchNameField("", Color.black); } else { final String objName = gameObject.getAttributeString(BaseObject.NAME, false); - if (objName.length() > 0) { + if (objName.isEmpty()) { + final String archObjName = gameObject.getArchetype().getObjName(); + setArchNameField(archObjName.isEmpty() ? gameObject.getArchetype().getArchetypeName() : archObjName, Color.black); + } else { setArchNameField(objName, Color.blue); - } else { - final String archObjName = gameObject.getArchetype().getObjName(); - setArchNameField(archObjName.length() > 0 ? archObjName : gameObject.getArchetype().getArchetypeName(), Color.black); } } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/gameobjectattributes/FaceTab.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/gameobjectattributes/FaceTab.java 2013-07-15 19:29:09 UTC (rev 9348) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/gameobjectattributes/FaceTab.java 2013-07-15 19:48:50 UTC (rev 9349) @@ -352,7 +352,7 @@ final String animSpeed = animSpeedTextField.getText().trim(); final String animSpeedAttribute = gameObject.getArchetype().getAttributeString(BaseObject.ANIM_SPEED); - if (animSpeed.length() == 0 || (animSpeed.equals("0") ? "" : animSpeed).equals(animSpeedAttribute)) { + if (animSpeed.isEmpty() || (animSpeed.equals("0") ? "" : animSpeed).equals(animSpeedAttribute)) { gameObject.removeAttribute(BaseObject.ANIM_SPEED); } else { gameObject.setAttributeString(BaseObject.ANIM_SPEED, animSpeed); Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/gameobjectattributes/MsgTextTab.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/gameobjectattributes/MsgTextTab.java 2013-07-15 19:29:09 UTC (rev 9348) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/gameobjectattributes/MsgTextTab.java 2013-07-15 19:48:50 UTC (rev 9349) @@ -162,7 +162,13 @@ // if there is an entry in the archTextArea (msg window), this // overrules the default text (if any) final String msgText = StringUtils.removeTrailingWhitespaceFromLines(archTextArea.getText()); - if (msgText.length() > 0) { // there is something in the msg win + if (msgText.isEmpty()) { // there is nothing in the msg win + if (archetype.getMsgText() == null) { + return null; // always delete this... + } else { + return ""; // but here we must overrule default with msg/endmsg (empty msg) + } + } else { // there is something in the msg win final String archetypeMsgText = archetype.getMsgText(); if (archetypeMsgText != null) { if (msgText.equals(archetypeMsgText)) { @@ -173,12 +179,6 @@ } else { return msgText; } - } else { // there is nothing in the msg win - if (archetype.getMsgText() != null) { - return ""; // but here we must overrule default with msg/endmsg (empty msg) - } else { - return null; // always delete this... - } } } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/updater/UpdaterManager.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/updater/UpdaterManager.java 2013-07-15 19:29:09 UTC (rev 9348) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/updater/UpdaterManager.java 2013-07-15 19:48:50 UTC (rev 9349) @@ -115,8 +115,8 @@ this.parentComponent = parentComponent; this.updateFileName = updateFileName; - final CharSequence propUrl = ACTION_BUILDER.getString("update.url"); - hasUpdateURL = propUrl != null && propUrl.length() > 0; + final String propUrl = ACTION_BUILDER.getString("update.url"); + hasUpdateURL = propUrl != null && !propUrl.isEmpty(); } /** Modified: trunk/src/model/src/main/java/net/sf/gridarta/model/archetype/AbstractArchetype.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/archetype/AbstractArchetype.java 2013-07-15 19:29:09 UTC (rev 9348) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/archetype/AbstractArchetype.java 2013-07-15 19:48:50 UTC (rev 9349) @@ -137,10 +137,10 @@ @Nullable @Override protected String getEffectiveFaceName(@NotNull final String faceName) { - final String normalizedFaceName = faceName.length() > 0 ? faceName.intern() : null; + final String normalizedFaceName = faceName.isEmpty() ? null : faceName.intern(); //Strings are interned //noinspection StringEquality - return normalizedFaceName != null && normalizedFaceName.length() > 0 ? normalizedFaceName : null; + return normalizedFaceName != null && !normalizedFaceName.isEmpty() ? normalizedFaceName : null; } /** Modified: trunk/src/model/src/main/java/net/sf/gridarta/model/archetype/AttributeListUtils.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/archetype/AttributeListUtils.java 2013-07-15 19:29:09 UTC (rev 9348) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/archetype/AttributeListUtils.java 2013-07-15 19:48:50 UTC (rev 9349) @@ -52,7 +52,7 @@ final StringBuilder sb = new StringBuilder(); for (final String line : lines) { - if (line.length() > 0 && !line.startsWith(prefix)) { + if (!line.isEmpty() && !line.startsWith(prefix)) { sb.append(line); sb.append('\n'); } @@ -74,7 +74,7 @@ final StringBuilder result = new StringBuilder(); for (final String line : StringUtils.PATTERN_END_OF_LINE.split(archetype.getObjectText(), 0)) { final int spaceIndex = line.indexOf(' '); - if (line.length() > 0 && spaceIndex > 0 && StringUtils.diffTextString(oldObjectText, line.substring(0, spaceIndex + 1), true) == null) { + if (!line.isEmpty() && spaceIndex > 0 && StringUtils.diffTextString(oldObjectText, line.substring(0, spaceIndex + 1), true) == null) { result.append(line).append('\n'); } } @@ -100,7 +100,7 @@ if (test != null) { c = test.charAt(0); } - if (line.length() > 0 && (test == null || c == '\n')) { + if (!line.isEmpty() && (test == null || c == '\n')) { result.append(line).append('\n'); } } catch (final StringIndexOutOfBoundsException ignored) { Modified: trunk/src/model/src/main/java/net/sf/gridarta/model/archetypetype/ArchetypeAttributeDefinition.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/archetypetype/ArchetypeAttributeDefinition.java 2013-07-15 19:29:09 UTC (rev 9348) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/archetypetype/ArchetypeAttributeDefinition.java 2013-07-15 19:48:50 UTC (rev 9349) @@ -65,8 +65,8 @@ * @param attributeValue the attribute value * @return whether the attribute value matches */ - private boolean matches(@NotNull final CharSequence attributeValue) { - return attributeValue.equals(value) || (value.equals("0") && attributeValue.length() == 0); + private boolean matches(@NotNull final String attributeValue) { + return attributeValue.equals(value) || (value.equals("0") && attributeValue.isEmpty()); } /** Modified: trunk/src/model/src/main/java/net/sf/gridarta/model/archetypetype/ArchetypeType.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/archetypetype/ArchetypeType.java 2013-07-15 19:29:09 UTC (rev 9348) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/archetypetype/ArchetypeType.java 2013-07-15 19:48:50 UTC (rev 9349) @@ -292,7 +292,7 @@ sb.append(typeNo); sb.append(')'); - if (display.length() > 0) { + if (!display.isEmpty()) { sb.append(" ["); int start = 0; while (start < display.length()) { Modified: trunk/src/model/src/main/java/net/sf/gridarta/model/archetypetype/ArchetypeTypeSetParser.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/archetypetype/ArchetypeTypeSetParser.java 2013-07-15 19:29:09 UTC (rev 9348) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/archetypetype/ArchetypeTypeSetPars... [truncated message content] |
From: <aki...@us...> - 2013-07-15 19:29:18
|
Revision: 9348 http://sourceforge.net/p/gridarta/code/9348 Author: akirschbaum Date: 2013-07-15 19:29:09 +0000 (Mon, 15 Jul 2013) Log Message: ----------- Merge duplicated code. Modified Paths: -------------- trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/AbstractBaseObject.java Modified: trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/AbstractBaseObject.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/AbstractBaseObject.java 2013-07-15 19:22:24 UTC (rev 9347) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/AbstractBaseObject.java 2013-07-15 19:29:09 UTC (rev 9348) @@ -357,26 +357,8 @@ return; } - final String attributeNameWithSpace = attributeName.trim() + " "; // attributeName must be followed by space final boolean sameAsInArchetype = getArchetype().getAttributeString(attributeName).equals(value); - boolean exists = false; - final StringBuilder result = new StringBuilder(); - for (final String line : StringUtils.PATTERN_END_OF_LINE.split(getObjectText(), 0)) { - if (line.length() == 0) { - // skip empty lines that occur due to split on empty object texts. - } else if (!line.startsWith(attributeNameWithSpace)) { - result.append(line).append('\n'); - } else { - exists = true; - if (!sameAsInArchetype) { - result.append(attributeNameWithSpace).append(value).append('\n'); - } - } - } - if (!exists && !sameAsInArchetype) { - result.append(attributeNameWithSpace).append(value).append('\n'); - } - setObjectText(result.toString()); + setAttributeValue(attributeName, sameAsInArchetype, value); } /** @@ -384,8 +366,19 @@ */ @Override public void setAttributeInt(@NotNull final String attributeName, final int value) { + final boolean sameAsInArchetype = getArchetype().getAttributeInt(attributeName) == value; + setAttributeValue(attributeName, sameAsInArchetype, Integer.toString(value)); + } + + /** + * Updates an attribute's value. + * @param attributeName the attribute name + * @param sameAsInArchetype whether the new value is the same as in the + * archetype + * @param value the new value + */ + private void setAttributeValue(@NotNull final String attributeName, final boolean sameAsInArchetype, @NotNull final String value) { final String attributeNameWithSpace = attributeName.trim() + " "; - final boolean sameAsInArchetype = getArchetype().getAttributeInt(attributeName) == value; boolean exists = false; final StringBuilder result = new StringBuilder(); for (final String line : StringUtils.PATTERN_END_OF_LINE.split(getObjectText(), 0)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-07-15 19:22:29
|
Revision: 9347 http://sourceforge.net/p/gridarta/code/9347 Author: akirschbaum Date: 2013-07-15 19:22:24 +0000 (Mon, 15 Jul 2013) Log Message: ----------- Move code from AbstractBaseObject to GameObjectText. Modified Paths: -------------- trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/AbstractBaseObject.java trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/GameObjectText.java Modified: trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/AbstractBaseObject.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/AbstractBaseObject.java 2013-07-15 19:15:49 UTC (rev 9346) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/AbstractBaseObject.java 2013-07-15 19:22:24 UTC (rev 9347) @@ -411,15 +411,16 @@ */ @Override public void removeAttribute(@NotNull final String attributeName) { - final String attributeNameWithSpace = attributeName.trim() + " "; // attributeName must be followed by space + if (!gameObjectText.removeAttribute(attributeName)) { + return; + } - final StringBuilder sb = new StringBuilder(); - for (final String line : StringUtils.PATTERN_END_OF_LINE.split(getObjectText(), 0)) { - if (line.length() > 0 && !line.startsWith(attributeNameWithSpace)) { - sb.append(line).append('\n'); - } + beginGameObjectChange(); + try { + updateCachedAttributes(); + } finally { + endGameObjectChange(); } - setObjectText(sb.toString()); } /** Modified: trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/GameObjectText.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/GameObjectText.java 2013-07-15 19:15:49 UTC (rev 9346) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/GameObjectText.java 2013-07-15 19:22:24 UTC (rev 9347) @@ -200,4 +200,21 @@ return gameObjectText.objectText.toString().equals(objectText.toString()); } + /** + * Removes an attribute. + * @param attributeName the attribute name + * @return whether the object text has changed + */ + public boolean removeAttribute(@NotNull final String attributeName) { + final String attributeNameWithSpace = attributeName.trim() + " "; // attributeName must be followed by space + + final StringBuilder sb = new StringBuilder(); + for (final String line : StringUtils.PATTERN_END_OF_LINE.split(objectText.toString(), 0)) { + if (line.length() > 0 && !line.startsWith(attributeNameWithSpace)) { + sb.append(line).append('\n'); + } + } + return setObjectText(sb.toString()); + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-07-15 19:15:53
|
Revision: 9346 http://sourceforge.net/p/gridarta/code/9346 Author: akirschbaum Date: 2013-07-15 19:15:49 +0000 (Mon, 15 Jul 2013) Log Message: ----------- Move code from AbstractBaseObject to GameObjectText. Modified Paths: -------------- trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/AbstractBaseObject.java trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/GameObjectText.java Modified: trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/AbstractBaseObject.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/AbstractBaseObject.java 2013-07-15 08:29:34 UTC (rev 9345) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/AbstractBaseObject.java 2013-07-15 19:15:49 UTC (rev 9346) @@ -791,13 +791,12 @@ */ @Override public void addObjectText(@NotNull final String line) { - if (line.length() <= 0) { + if (!gameObjectText.addObjectText(line)) { return; } beginGameObjectChange(); try { - gameObjectText.addObjectText(line); updateCachedAttributes(); } finally { endGameObjectChange(); @@ -809,18 +808,12 @@ */ @Override public void setObjectText(@NotNull final String objectText) { - final String oldObjectText = gameObjectText.getObjectText(); - if (oldObjectText.length() == objectText.length()) { - final String oldSortedObjectText = StringUtils.sortLines(oldObjectText); - final String newSortedObjectText = StringUtils.sortLines(objectText); - if (oldSortedObjectText.equals(newSortedObjectText)) { - return; - } + if (!gameObjectText.setObjectText(objectText)) { + return; } beginGameObjectChange(); try { - gameObjectText.setObjectText(objectText); updateCachedAttributes(); } finally { endGameObjectChange(); Modified: trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/GameObjectText.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/GameObjectText.java 2013-07-15 08:29:34 UTC (rev 9345) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/GameObjectText.java 2013-07-15 19:15:49 UTC (rev 9346) @@ -131,16 +131,18 @@ * Appends a line to the object text. * @param line the line to append, may contain '\n' for appending multiple * lines + * @return whether the object text was changed */ - public void addObjectText(@NotNull final String line) { + public boolean addObjectText(@NotNull final String line) { if (line.length() == 0) { - return; + return false; } objectText.append(line); if (!line.endsWith("\n")) { objectText.append('\n'); } clearAttributeCache(); + return true; } /** @@ -154,14 +156,25 @@ /** * Sets the object text. * @param objectText the object text to set + * @return whether the object text was changed */ - public void setObjectText(@NotNull final String objectText) { + public boolean setObjectText(@NotNull final String objectText) { + final String oldObjectText = this.objectText.toString(); + if (oldObjectText.length() == objectText.length()) { + final String oldSortedObjectText = StringUtils.sortLines(oldObjectText); + final String newSortedObjectText = StringUtils.sortLines(objectText); + if (oldSortedObjectText.equals(newSortedObjectText)) { + return false; + } + } + this.objectText.setLength(0); this.objectText.append(objectText); if (objectText.length() > 0 && !objectText.endsWith("\n")) { this.objectText.append('\n'); } clearAttributeCache(); + return true; } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-07-15 08:29:40
|
Revision: 9345 http://sourceforge.net/p/gridarta/code/9345 Author: akirschbaum Date: 2013-07-15 08:29:34 +0000 (Mon, 15 Jul 2013) Log Message: ----------- Extract Attributes from BaseObject. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/AttributesPaneBuilder.java trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/BaseObject.java Added Paths: ----------- trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/Attributes.java Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/AttributesPaneBuilder.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/AttributesPaneBuilder.java 2013-07-14 21:34:00 UTC (rev 9344) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/AttributesPaneBuilder.java 2013-07-15 08:29:34 UTC (rev 9345) @@ -82,6 +82,7 @@ import net.sf.gridarta.model.archetypetype.ArchetypeTypeList; import net.sf.gridarta.model.archetypetype.ArchetypeTypeSet; import net.sf.gridarta.model.archetypetype.AttributeBitmask; +import net.sf.gridarta.model.baseobject.Attributes; import net.sf.gridarta.model.baseobject.BaseObject; import net.sf.gridarta.model.face.FaceObjectProviders; import net.sf.gridarta.model.face.FaceObjects; @@ -125,7 +126,7 @@ * @serial */ @NotNull - private G gameObject; + private Attributes attributes; /** * The parent component for dialogs. @@ -260,7 +261,7 @@ @Override public void visit(@NotNull final ArchetypeAttributeAnimationName archetypeAttribute) { final String attributeName = archetypeAttribute.getArchetypeAttributeName(); - final String defaultText = gameObject.getAttributeString(attributeName); + final String defaultText = attributes.getAttributeString(attributeName); final AnimationComponent input = new AnimationComponent(defaultText, animationObjects, faceObjectProviders, noFaceSquareIcon, unknownSquareIcon); final JLabel cLabel = new JLabel(archetypeAttribute.getAttributeName() + ": "); guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeAnimationName>(new DialogAttributeAnimationName<G, A, R>(archetypeAttribute, input), cLabel, input, null, null, false); @@ -282,7 +283,7 @@ input.setBorder(BorderFactory.createLineBorder(Color.gray)); input.setText(bitmask.getText(tmpAttribute.getValue())); component = input; - tmpAttribute.setEncodedValue(gameObject.getAttributeString(archetypeAttribute.getArchetypeAttributeName())); + tmpAttribute.setEncodedValue(attributes.getAttributeString(archetypeAttribute.getArchetypeAttributeName())); row = null; } else { label = null; @@ -294,13 +295,13 @@ @Override public void visit(@NotNull final ArchetypeAttributeBool archetypeAttribute) { - final JCheckBox input = new JCheckBox(archetypeAttribute.getAttributeName(), gameObject.getAttributeInt(archetypeAttribute.getArchetypeAttributeName()) == 1); + final JCheckBox input = new JCheckBox(archetypeAttribute.getAttributeName(), attributes.getAttributeInt(archetypeAttribute.getArchetypeAttributeName()) == 1); guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeBool>(new DialogAttributeBool<G, A, R>(archetypeAttribute, input), null, null, input, null, false); } @Override public void visit(@NotNull final ArchetypeAttributeBoolSpec archetypeAttribute) { - final CharSequence attributeString = gameObject.getAttributeString(archetypeAttribute.getArchetypeAttributeName()); + final CharSequence attributeString = attributes.getAttributeString(archetypeAttribute.getArchetypeAttributeName()); final boolean defaultValue; if (archetypeAttribute.getTrueValue().equals("0")) { defaultValue = attributeString.length() == 0 || attributeString.equals("0"); @@ -314,7 +315,7 @@ @Override public void visit(@NotNull final ArchetypeAttributeFaceName archetypeAttribute) { final String attributeName = archetypeAttribute.getArchetypeAttributeName(); - final String defaultText = gameObject.getAttributeString(attributeName); + final String defaultText = attributes.getAttributeString(attributeName); final FaceComponent input = new FaceComponent(defaultText, faceObjects, faceObjectProviders, noFaceSquareIcon, unknownSquareIcon); final JLabel label = new JLabel(archetypeAttribute.getAttributeName() + ":"); guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeFaceName>(new DialogAttributeFaceName<G, A, R>(archetypeAttribute, input), label, input, null, null, false); @@ -336,8 +337,8 @@ final NumberFormatter formatter = new NumberFormatter(format); formatter.setValueClass(Double.class); final DefaultFormatterFactory factory = new DefaultFormatterFactory(formatter); - // parse value from gameObject - final Number value = gameObject.getAttributeDouble(archetypeAttribute.getArchetypeAttributeName()); + // parse value from attributes + final Number value = attributes.getAttributeDouble(archetypeAttribute.getArchetypeAttributeName()); final JFormattedTextField input = new JFormattedTextField(factory, value); input.setColumns(fieldLength); guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeFloat>(new DialogAttributeFloat<G, A, R>(archetypeAttribute, input), label, input, null, null, false); @@ -352,8 +353,8 @@ format.setGroupingUsed(false); final NumberFormatter formatter = new NumberFormatter(format); final DefaultFormatterFactory factory = new DefaultFormatterFactory(formatter); - // parse value from gameObject - final Number value = gameObject.getAttributeInt(archetypeAttribute.getArchetypeAttributeName()); + // parse value from attributes + final Number value = attributes.getAttributeInt(archetypeAttribute.getArchetypeAttributeName()); final JFormattedTextField input = new JFormattedTextField(factory, value); input.setColumns(fieldLength); guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeInt>(new DialogAttributeInt<G, A, R>(archetypeAttribute, input), label, input, null, null, false); @@ -364,7 +365,7 @@ final JLabel label = new JLabel(archetypeAttribute.getAttributeName() + ": "); label.setForeground(INT_COLOR); // create ComboBox with parsed selection - @Nullable final JComboBox input = buildInvSpellBox(gameObjectSpells, gameObject, archetypeAttribute.isOptionalSpell(), archetypeAttribute.getAttributeName()); + @Nullable final JComboBox input = buildInvSpellBox(gameObjectSpells, attributes, archetypeAttribute.isOptionalSpell(), archetypeAttribute.getAttributeName()); guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeInvSpell>(new DialogAttributeInvSpell<G, A, R>(archetypeAttribute.isOptionalSpell(), archetypeAttribute, input, gameObjectSpells), label, input, null, null, false); } @@ -378,7 +379,7 @@ final ArchetypeTypeList list = archetypeTypeSet.getList(archetypeAttribute.getListName()); if (list != null) { // build the list from vector data - input = buildArrayBox(list, gameObject, archetypeAttribute.getArchetypeAttributeName(), archetypeAttribute.getAttributeName()); + input = buildArrayBox(list, attributes, archetypeAttribute.getArchetypeAttributeName(), archetypeAttribute.getAttributeName()); component = input; } else { // error: list data is missing or corrupt @@ -397,8 +398,8 @@ format.setGroupingUsed(false); final NumberFormatter formatter = new NumberFormatter(format); final DefaultFormatterFactory factory = new DefaultFormatterFactory(formatter); - // parse value from gameObject - final Number value = gameObject.getAttributeLong(archetypeAttribute.getArchetypeAttributeName()); + // parse value from attributes + final Number value = attributes.getAttributeLong(archetypeAttribute.getArchetypeAttributeName()); final JFormattedTextField input = new JFormattedTextField(factory, value); input.setColumns(fieldLength); guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeLong>(new DialogAttributeLong<G, A, R>(archetypeAttribute, input), label, input, null, null, false); @@ -406,13 +407,13 @@ @Override public void visit(@NotNull final ArchetypeAttributeMapPath archetypeAttribute) { - final MapSquare<G, A, R> mapSquare = gameObject.getMapSquare(); + final MapSquare<?, ?, ?> mapSquare = attributes instanceof GameObject ? ((GameObject<?, ?, ?>) attributes).getMapSquare() : null; File relativeReference = mapSquare == null ? null : mapSquare.getMapModel().getMapFile(); if (relativeReference == null) { relativeReference = new File(globalSettings.getMapsDirectory(), "dummy"); } final JLabel label = new JLabel(archetypeAttribute.getAttributeName() + ": "); - final TilePanel tilePanel = new TilePanel(mapFileFilter, gameObject.getAttributeString(archetypeAttribute.getArchetypeAttributeName()), relativeReference, globalSettings.getMapsDirectory()); + final TilePanel tilePanel = new TilePanel(mapFileFilter, attributes.getAttributeString(archetypeAttribute.getArchetypeAttributeName()), relativeReference, globalSettings.getMapsDirectory()); guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeMapPath>(new DialogAttributeMapPath<G, A, R>(archetypeAttribute, tilePanel), label, tilePanel, null, null, false); } @@ -420,7 +421,7 @@ public void visit(@NotNull final ArchetypeAttributeScriptFile archetypeAttribute) { final JLabel label = new JLabel(archetypeAttribute.getAttributeName() + ": "); final File mapsDirectory = globalSettings.getMapsDirectory(); - final TilePanel tilePanel = new TilePanel(scriptFileFilter, gameObject.getAttributeString(archetypeAttribute.getArchetypeAttributeName()), new File(mapsDirectory, "dummy"), mapsDirectory); + final TilePanel tilePanel = new TilePanel(scriptFileFilter, attributes.getAttributeString(archetypeAttribute.getArchetypeAttributeName()), new File(mapsDirectory, "dummy"), mapsDirectory); guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeScriptFile>(new DialogAttributeScriptFile<G, A, R>(archetypeAttribute, tilePanel), label, tilePanel, null, null, false); } @@ -429,13 +430,13 @@ final JLabel label = new JLabel(archetypeAttribute.getAttributeName() + ": "); label.setForeground(INT_COLOR); // create ComboBox with parsed selection - @Nullable final JComboBox input = buildSpellBox(gameObject, numberSpells, undefinedSpellIndex, false, archetypeAttribute); + @Nullable final JComboBox input = buildSpellBox(attributes, numberSpells, undefinedSpellIndex, false, archetypeAttribute); guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeSpell>(new DialogAttributeSpell<G, A, R>(archetypeAttribute, input, numberSpells), label, input, null, null, false); } @Override public void visit(@NotNull final ArchetypeAttributeString archetypeAttribute) { - final String defaultText = gameObject.getAttributeString(archetypeAttribute.getArchetypeAttributeName()); + final String defaultText = attributes.getAttributeString(archetypeAttribute.getArchetypeAttributeName()); final JTextField input = new JTextField(defaultText, ArchetypeAttribute.TEXTFIELD_COLUMNS); final JLabel label = new JLabel(archetypeAttribute.getAttributeName() + ": "); guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeString>(new DialogAttributeString<G, A, R>(archetypeAttribute, input), label, input, null, null, false); @@ -443,15 +444,18 @@ @Override public void visit(@NotNull final ArchetypeAttributeText archetypeAttribute) { - String text = ""; - if (archetypeAttribute.getArchetypeAttributeName().equals("msg")) { - final String archetypeMsgText = gameObject.getArchetype().getMsgText(); - final String gameObjectMsgText = gameObject.getMsgText(); + final String text; + if (archetypeAttribute.getArchetypeAttributeName().equals("msg") && attributes instanceof GameObject) { + final GameObject<?, ?, ?> tmp = (GameObject<?, ?, ?>) attributes; + final String archetypeMsgText = tmp.getArchetype().getMsgText(); + final String gameObjectMsgText = tmp.getMsgText(); if (archetypeMsgText != null && archetypeMsgText.length() > 0 && (gameObjectMsgText == null || gameObjectMsgText.length() == 0)) { text = archetypeMsgText; } else { text = gameObjectMsgText; } + } else { + text = ""; } final JEditTextArea input = new JEditTextArea(textAreaDefaults); input.setDocument(new SyntaxDocument()); @@ -466,7 +470,7 @@ @Override public void visit(@NotNull final ArchetypeAttributeTreasure archetypeAttribute) { // textfield (no direct input, text is set by the treasurelist dialog) - String treasureName = gameObject.getAttributeString(archetypeAttribute.getArchetypeAttributeName()); + String treasureName = attributes.getAttributeString(archetypeAttribute.getArchetypeAttributeName()); if (treasureName.trim().length() == 0 || treasureName.trim().equalsIgnoreCase("none")) { treasureName = CFTreasureListTree.NONE_SYM; } @@ -482,7 +486,7 @@ final JLabel label = new JLabel(archetypeAttribute.getAttributeName() + ": "); label.setForeground(INT_COLOR); // create ComboBox with parsed selection - @Nullable final JComboBox input = buildSpellBox(gameObject, numberSpells, undefinedSpellIndex, true, archetypeAttribute); + @Nullable final JComboBox input = buildSpellBox(attributes, numberSpells, undefinedSpellIndex, true, archetypeAttribute); guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeZSpell>(new DialogAttributeZSpell<G, A, R>(archetypeAttribute, input, numberSpells, undefinedSpellIndex), label, input, null, null, false); } @@ -490,7 +494,7 @@ /** * Creates a new instance. - * @param gameObject the game object for which the attributes are built + * @param attributes the game object for which the attributes are built * @param parent the parent component for dialogs * @param archetypeTypeSet the reference to the list of archetype types * @param treasureListTree the treasure list tree to display @@ -510,8 +514,8 @@ * @param unknownSquareIcon the image icon for undefined animations * @param textAreaDefaults the text area defaults for text fields */ - public AttributesPaneBuilder(@NotNull final G gameObject, @NotNull final Component parent, final ArchetypeTypeSet archetypeTypeSet, @NotNull final CFTreasureListTree treasureListTree, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final AnimationObjects animationObjects, @NotNull final GlobalSettings globalSettings, @NotNull final FileFilter mapFileFilter, @NotNull final FileFilter scriptFileFilter, @NotNull final FaceObjects faceObjects, @NotNull final Spells<GameObjectSpell<G, A, R>> gameObjectSpells, @NotNull final Spells<NumberSpell> numberSpells, final int undefinedSpellIndex, @NotNull final TreasureTree treasureTree, @NotNull final ImageIcon noFaceSquareIcon, @NotNull final ImageIcon unknownSquareIcon, @NotNull final TextAreaDefaults textAreaDefaults) { - this.gameObject = gameObject; + public AttributesPaneBuilder(@NotNull final Attributes attributes, @NotNull final Component parent, final ArchetypeTypeSet archetypeTypeSet, @NotNull final CFTreasureListTree treasureListTree, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final AnimationObjects animationObjects, @NotNull final GlobalSettings globalSettings, @NotNull final FileFilter mapFileFilter, @NotNull final FileFilter scriptFileFilter, @NotNull final FaceObjects faceObjects, @NotNull final Spells<GameObjectSpell<G, A, R>> gameObjectSpells, @NotNull final Spells<NumberSpell> numberSpells, final int undefinedSpellIndex, @NotNull final TreasureTree treasureTree, @NotNull final ImageIcon noFaceSquareIcon, @NotNull final ImageIcon unknownSquareIcon, @NotNull final TextAreaDefaults textAreaDefaults) { + this.attributes = attributes; this.parent = parent; this.archetypeTypeSet = archetypeTypeSet; this.treasureListTree = treasureListTree; @@ -550,12 +554,12 @@ /** * Constructs the central part of the attribute dialog, containing the - * object's gameObject attributes. - * @param gameObject the game object for which the attributes are built + * object's attributes. + * @param attributes the attributes for which the attributes panel is built * @param archetypeType the archetype type of {@code gamObject} */ - public void buildAttribute(@NotNull final G gameObject, @NotNull final Iterable<ArchetypeAttributeSection> archetypeType) { - this.gameObject = gameObject; + public void buildAttribute(@NotNull final Attributes attributes, @NotNull final Iterable<ArchetypeAttributeSection> archetypeType) { + this.attributes = attributes; tabbedPane.removeAll(); int sectionId = 0; for (final ArchetypeAttributeSection archetypeAttributeSection : archetypeType) { @@ -674,14 +678,18 @@ * @param gameObjectSpells the game object spells to use * @param isOptionalSpell whether the entry <none> should be shown * @param attributeName the archetype attribute's name - * @param gameObject the associated game object + * @param attributes the associated game object * @return the completed <code>JComboBox</code> */ @NotNull - private static <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> JComboBox buildInvSpellBox(@NotNull final Spells<GameObjectSpell<G, A, R>> gameObjectSpells, @NotNull final BaseObject<?, ?, ?, ?> gameObject, final boolean isOptionalSpell, @NotNull final String attributeName) { + private static <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> JComboBox buildInvSpellBox(@NotNull final Spells<GameObjectSpell<G, A, R>> gameObjectSpells, @NotNull final Attributes attributes, final boolean isOptionalSpell, @NotNull final String attributeName) { + if (!(attributes instanceof BaseObject)) { + throw new IllegalArgumentException(); + } + final BaseObject<?, ?, ?, ?> baseObject = (BaseObject<?, ?, ?, ?>) attributes; final int selectedIndex; @Nullable final String title; - switch (gameObject.countInvObjects()) { + switch (baseObject.countInvObjects()) { case 0: selectedIndex = gameObjectSpells.size(); title = isOptionalSpell ? null : "<none>"; @@ -693,7 +701,7 @@ break; case 1: - final GameObject<?, ?, ?> invObject = gameObject.iterator().next(); + final GameObject<?, ?, ?> invObject = baseObject.iterator().next(); final String invObjectArchetypeName = invObject.getArchetype().getArchetypeName(); int index = 0; @Nullable String tmpTitle = "<customized spell>"; @@ -730,17 +738,17 @@ /** * Constructs the combo box for arrays of "list data". * @param listData list with list items and corresponding values - * @param gameObject the associated game object + * @param attributes the associated game object * @param archetypeAttributeName the name of the shown attribute * @param attributeName the label to show on the combo box * @return the completed <code>JComboBox</code> */ @NotNull - private static JComboBox buildArrayBox(@NotNull final ArchetypeTypeList listData, @NotNull final BaseObject<?, ?, ?, ?> gameObject, @NotNull final String archetypeAttributeName, @NotNull final String attributeName) { + private static JComboBox buildArrayBox(@NotNull final ArchetypeTypeList listData, @NotNull final Attributes attributes, @NotNull final String archetypeAttributeName, @NotNull final String attributeName) { // build the array of list-items final String[] array = new String[listData.size()]; boolean hasSelection = false; - int active = gameObject.getAttributeInt(archetypeAttributeName); + int active = attributes.getAttributeInt(archetypeAttributeName); for (int i = 0; i < array.length; i++) { array[i] = listData.get(i).getSecond(); if (!hasSelection && listData.get(i).getFirst() == active) { @@ -762,7 +770,7 @@ /** * Constructs the combo box of the available spells. - * @param gameObject the associated game object + * @param attributes the associated game object * @param numberSpells the number spells to use * @param undefinedSpellIndex the index to use for the undefined spell * @param isZSpell whether a z-spell or a spell combo box is built @@ -770,8 +778,8 @@ * @return the completed <code>JComboBox</code> */ @NotNull - private static JComboBox buildSpellBox(@NotNull final BaseObject<?, ?, ?, ?> gameObject, @NotNull final Spells<NumberSpell> numberSpells, final int undefinedSpellIndex, final boolean isZSpell, @NotNull final ArchetypeAttribute archetypeAttribute) { - int spellNumber = gameObject.getAttributeInt(archetypeAttribute.getArchetypeAttributeName()); + private static JComboBox buildSpellBox(@NotNull final Attributes attributes, @NotNull final Spells<NumberSpell> numberSpells, final int undefinedSpellIndex, final boolean isZSpell, @NotNull final ArchetypeAttribute archetypeAttribute) { + int spellNumber = attributes.getAttributeInt(archetypeAttribute.getArchetypeAttributeName()); if (spellNumber < 0 || spellNumber >= numberSpells.size()) { spellNumber = undefinedSpellIndex; Added: trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/Attributes.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/Attributes.java (rev 0) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/Attributes.java 2013-07-15 08:29:34 UTC (rev 9345) @@ -0,0 +1,86 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2011 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.model.baseobject; + +import org.jetbrains.annotations.NotNull; + +/** + * A set of key/value pairs. + * @author Andreas Kirschbaum + */ +public interface Attributes { + + /** + * Returns whether an attribute name exists. + * @param attributeName the attribute name + * @return whether the attribute name exists + */ + boolean hasAttribute(@NotNull String attributeName); + + /** + * Returns the requested attribute value of this GameObject as {@link + * String}. The attribute value is first searched in this GameObject. If the + * attribute value is not found and this GameObject is not an Archetype + * itself, the attribute value is searched in this GameObject's Archetype as + * well. + * @param attributeName the name of the attribute to search + * @return the attribute value or an empty String ("") if no such attribute + */ + @NotNull + String getAttributeString(@NotNull String attributeName); + + /** + * Returns an attribute value of this Archetype as int. + * @param attributeName the name of the attribute value to return + * @return the attribute value or <code>0</code> (zero) if not found + * @see #getAttributeString(String) + */ + int getAttributeInt(@NotNull String attributeName); + + /** + * Returns an attribute value of this Archetype as long. + * @param attributeName the name of the attribute value to return + * @return the attribute value or <code>0</code> (zero) if not found + * @see #getAttributeString(String) + */ + long getAttributeLong(@NotNull String attributeName); + + /** + * Returns an attribute value of this Archetype as double. + * @param attributeName the name of the attribute value to return + * @return the attribute value or <code>0.0</code> (zero) if not found + * @see #getAttributeString(String) + */ + double getAttributeDouble(@NotNull String attributeName); + + /** + * Sets an int value attribute. + * @param attributeName the name of the attribute to update + * @param value the new value + */ + void setAttributeInt(@NotNull String attributeName, int value); + + /** + * Removes the String of an archetype attribute from the objectText. + * @param attributeName search for "attributeName <string>" + */ + void removeAttribute(@NotNull String attributeName); + +} Property changes on: trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/Attributes.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Modified: trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/BaseObject.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/BaseObject.java 2013-07-14 21:34:00 UTC (rev 9344) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/baseobject/BaseObject.java 2013-07-15 08:29:34 UTC (rev 9345) @@ -31,7 +31,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -public interface BaseObject<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, T extends BaseObject<G, A, R, T>> extends Cloneable, Iterable<G>, Serializable { +public interface BaseObject<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, T extends BaseObject<G, A, R, T>> extends Attributes, Cloneable, Iterable<G>, Serializable { int EDIT_TYPE_NONE = 0x10000; // special case @@ -168,13 +168,6 @@ boolean hasAttribute(@NotNull String attributeName, boolean queryArchetype); /** - * Returns whether an attribute name exists. - * @param attributeName the attribute name - * @return whether the attribute name exists - */ - boolean hasAttribute(@NotNull String attributeName); - - /** * Returns the requested attribute value of this GameObject as {@link * String}. The attribute value is first searched in this GameObject. If * <code>queryArchetype == true</code>, additional search is done: if the @@ -194,20 +187,6 @@ String getAttributeString(@NotNull String attributeName, boolean queryArchetype); /** - * Returns the requested attribute value of this GameObject as {@link - * String}. The attribute value is first searched in this GameObject. If the - * attribute value is not found and this GameObject is not an Archetype - * itself, the attribute value is searched in this GameObject's Archetype as - * well. <p/> This methods corresponds to {@link #getAttributeString(String, - * boolean)} with <code>useArchetype == true</code>. - * @param attributeName the name of the attribute to search - * @return the attribute value or an empty String ("") if no such attribute - * @see #getAttributeString(String, boolean) - */ - @NotNull - String getAttributeString(@NotNull String attributeName); - - /** * Returns the requested attribute value of this GameObject as * <code>int</code>. * @param attributeName the name of the attribute to search @@ -219,14 +198,6 @@ int getAttributeInt(@NotNull String attributeName, boolean queryArchetype); /** - * Returns an attribute value of this Archetype as int. - * @param attributeName the name of the attribute value to return - * @return the attribute value or <code>0</code> (zero) if not found - * @see #getAttributeString(String) - */ - int getAttributeInt(@NotNull String attributeName); - - /** * Returns the requested attribute value of this GameObject as * <code>long</code>. * @param attributeName the name of the attribute to search @@ -238,14 +209,6 @@ long getAttributeLong(@NotNull String attributeName, boolean queryArchetype); /** - * Returns an attribute value of this Archetype as long. - * @param attributeName the name of the attribute value to return - * @return the attribute value or <code>0</code> (zero) if not found - * @see #getAttributeString(String) - */ - long getAttributeLong(@NotNull String attributeName); - - /** * Returns the requested attribute value of this GameObject as * <code>double</code>. * @param attributeName the name of the attribute to search @@ -257,14 +220,6 @@ double getAttributeDouble(@NotNull String attributeName, boolean queryArchetype); /** - * Returns an attribute value of this Archetype as double. - * @param attributeName the name of the attribute value to return - * @return the attribute value or <code>0.0</code> (zero) if not found - * @see #getAttributeString(String) - */ - double getAttributeDouble(@NotNull String attributeName); - - /** * Sets the String of an archetype attribute in the objectText. * @param attributeName search for "attributeName <string>" * @param value the value to set @@ -272,19 +227,6 @@ void setAttributeString(@NotNull String attributeName, @NotNull String value); /** - * Sets an int value attribute. - * @param attributeName the name of the attribute to update - * @param value the new value - */ - void setAttributeInt(@NotNull String attributeName, int value); - - /** - * Removes the String of an archetype attribute from the objectText. - * @param attributeName search for "attributeName <string>" - */ - void removeAttribute(@NotNull String attributeName); - - /** * Notifies the map model that this container is about to change. */ void notifyBeginChange(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-07-14 21:34:03
|
Revision: 9344 http://sourceforge.net/p/gridarta/code/9344 Author: akirschbaum Date: 2013-07-14 21:34:00 +0000 (Sun, 14 Jul 2013) Log Message: ----------- Extract AttributesPaneBuilder from GameObjectAttributesDialog. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java Added Paths: ----------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/AttributesPaneBuilder.java Added: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/AttributesPaneBuilder.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/AttributesPaneBuilder.java (rev 0) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/AttributesPaneBuilder.java 2013-07-14 21:34:00 UTC (rev 9344) @@ -0,0 +1,802 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2011 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.gui.dialog.gameobjectattributes; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Container; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.awt.event.FocusListener; +import java.io.File; +import java.text.DecimalFormat; +import java.text.NumberFormat; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import javax.swing.AbstractButton; +import javax.swing.BorderFactory; +import javax.swing.Box; +import javax.swing.DefaultComboBoxModel; +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.JFormattedTextField; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTabbedPane; +import javax.swing.JTextArea; +import javax.swing.JTextField; +import javax.swing.filechooser.FileFilter; +import javax.swing.text.DefaultFormatterFactory; +import javax.swing.text.NumberFormatter; +import net.sf.gridarta.gui.map.maptilepane.TilePanel; +import net.sf.gridarta.gui.treasurelist.CFTreasureListTree; +import net.sf.gridarta.gui.utils.AnimationComponent; +import net.sf.gridarta.gui.utils.FaceComponent; +import net.sf.gridarta.model.anim.AnimationObjects; +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.archetypetype.AbstractArchetypeAttributeSpell; +import net.sf.gridarta.model.archetypetype.ArchetypeAttribute; +import net.sf.gridarta.model.archetypetype.ArchetypeAttributeAnimationName; +import net.sf.gridarta.model.archetypetype.ArchetypeAttributeBitmask; +import net.sf.gridarta.model.archetypetype.ArchetypeAttributeBool; +import net.sf.gridarta.model.archetypetype.ArchetypeAttributeBoolSpec; +import net.sf.gridarta.model.archetypetype.ArchetypeAttributeFaceName; +import net.sf.gridarta.model.archetypetype.ArchetypeAttributeFixed; +import net.sf.gridarta.model.archetypetype.ArchetypeAttributeFloat; +import net.sf.gridarta.model.archetypetype.ArchetypeAttributeInt; +import net.sf.gridarta.model.archetypetype.ArchetypeAttributeInvSpell; +import net.sf.gridarta.model.archetypetype.ArchetypeAttributeList; +import net.sf.gridarta.model.archetypetype.ArchetypeAttributeLong; +import net.sf.gridarta.model.archetypetype.ArchetypeAttributeMapPath; +import net.sf.gridarta.model.archetypetype.ArchetypeAttributeScriptFile; +import net.sf.gridarta.model.archetypetype.ArchetypeAttributeSection; +import net.sf.gridarta.model.archetypetype.ArchetypeAttributeSpell; +import net.sf.gridarta.model.archetypetype.ArchetypeAttributeString; +import net.sf.gridarta.model.archetypetype.ArchetypeAttributeText; +import net.sf.gridarta.model.archetypetype.ArchetypeAttributeTreasure; +import net.sf.gridarta.model.archetypetype.ArchetypeAttributeVisitor; +import net.sf.gridarta.model.archetypetype.ArchetypeAttributeZSpell; +import net.sf.gridarta.model.archetypetype.ArchetypeTypeList; +import net.sf.gridarta.model.archetypetype.ArchetypeTypeSet; +import net.sf.gridarta.model.archetypetype.AttributeBitmask; +import net.sf.gridarta.model.baseobject.BaseObject; +import net.sf.gridarta.model.face.FaceObjectProviders; +import net.sf.gridarta.model.face.FaceObjects; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.maparchobject.MapArchObject; +import net.sf.gridarta.model.mapmodel.MapSquare; +import net.sf.gridarta.model.settings.GlobalSettings; +import net.sf.gridarta.model.spells.GameObjectSpell; +import net.sf.gridarta.model.spells.NumberSpell; +import net.sf.gridarta.model.spells.Spell; +import net.sf.gridarta.model.spells.Spells; +import net.sf.gridarta.model.treasurelist.TreasureTree; +import net.sf.gridarta.textedit.textarea.JEditTextArea; +import net.sf.gridarta.textedit.textarea.SyntaxDocument; +import net.sf.gridarta.textedit.textarea.TextAreaDefaults; +import net.sf.gridarta.textedit.textarea.tokenmarker.TokenMarkerFactory; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Builder for game object attribute panels. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @author Andreas Kirschbaum + */ +public class AttributesPaneBuilder<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> { + + /** + * Color for float values. + */ + @NotNull + public static final Color FLOAT_COLOR = new Color(19, 134, 0); + + /** + * Color for int values. + */ + @NotNull + public static final Color INT_COLOR = new Color(74, 70, 156); + + /** + * The game object being modified. + * @serial + */ + @NotNull + private G gameObject; + + /** + * The parent component for dialogs. + */ + @NotNull + private final Component parent; + + /** + * Reference to the {@link ArchetypeTypeSet}. + */ + @NotNull + private final ArchetypeTypeSet archetypeTypeSet; + + /** + * The {@link CFTreasureListTree} to use. + * @serial + */ + @NotNull + private final CFTreasureListTree treasureListTree; + + /** + * The {@link FaceObjectProviders} for looking up faces. + */ + @NotNull + private final FaceObjectProviders faceObjectProviders; + + /** + * The {@link AnimationObjects} instance for choosing animation names. + * @serial + */ + @NotNull + private final AnimationObjects animationObjects; + + /** + * The {@link GlobalSettings} instance. + */ + @NotNull + private final GlobalSettings globalSettings; + + /** + * The {@link FileFilter} to use for map files. + */ + @NotNull + private final FileFilter mapFileFilter; + + /** + * The {@link FileFilter} to use for script files. + */ + @NotNull + private final FileFilter scriptFileFilter; + + /** + * The {@link FaceObjects} instance for choosing face names. + * @serial + */ + @NotNull + private final FaceObjects faceObjects; + + /** + * The game object spells to use. + */ + @NotNull + private final Spells<GameObjectSpell<G, A, R>> gameObjectSpells; + + /** + * The numbered spells. + */ + @NotNull + private final Spells<NumberSpell> numberSpells; + + /** + * The index for "no spell". + * @serial + */ + private final int undefinedSpellIndex; + + /** + * The {@link TreasureTree} to use. + */ + @NotNull + private final TreasureTree treasureTree; + + /** + * The {@link ImageIcon} for no animations. + * @serial + */ + @NotNull + private final ImageIcon noFaceSquareIcon; + + /** + * The {@link ImageIcon} for undefined animations. + * @serial + */ + @NotNull + private final ImageIcon unknownSquareIcon; + + /** + * The {@link TextAreaDefaults} for text fields. + */ + @NotNull + private final TextAreaDefaults textAreaDefaults; + + /** + * The central tabbed pane (the place where all the attribute tabs are). + * @serial + */ + @NotNull + private final JTabbedPane tabbedPane = new JTabbedPane(); + + @NotNull + private final FocusListener focusListener = new ScrollToVisibleFocusListener(); + + /** + * All {@link DialogAttribute DialogAttributes} in the dialog. + */ + @NotNull + private final Collection<DialogAttribute<G, A, R, ?>> dialogAttributes = new ArrayList<DialogAttribute<G, A, R, ?>>(); + + /** + * The return value for {@link #archetypeAttributeVisitor}. + */ + @Nullable + private GuiInfo<G, A, R, ?> guiInfo; + + /** + * The {@link ArchetypeAttributeVisitor} for creating GUI elements for + * {@link ArchetypeAttribute ArchetypeAttributes}. + */ + @NotNull + private final ArchetypeAttributeVisitor archetypeAttributeVisitor = new ArchetypeAttributeVisitor() { + + @Override + public void visit(@NotNull final ArchetypeAttributeAnimationName archetypeAttribute) { + final String attributeName = archetypeAttribute.getArchetypeAttributeName(); + final String defaultText = gameObject.getAttributeString(attributeName); + final AnimationComponent input = new AnimationComponent(defaultText, animationObjects, faceObjectProviders, noFaceSquareIcon, unknownSquareIcon); + final JLabel cLabel = new JLabel(archetypeAttribute.getAttributeName() + ": "); + guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeAnimationName>(new DialogAttributeAnimationName<G, A, R>(archetypeAttribute, input), cLabel, input, null, null, false); + } + + @Override + public void visit(@NotNull final ArchetypeAttributeBitmask archetypeAttribute) { + final JTextArea input = new JTextArea(); + final DialogAttributeBitmask<G, A, R> tmpAttribute = new DialogAttributeBitmask<G, A, R>(archetypeAttribute, input); + @Nullable final JTextArea component; + @Nullable final JButton label; + @Nullable final JLabel row; + final AttributeBitmask bitmask = archetypeTypeSet.getBitmask(archetypeAttribute.getBitmaskName()); + if (bitmask != null) { + tmpAttribute.setBitmask(bitmask); + label = new JButton(new MaskChangeAL<G, A, R>(archetypeAttribute.getAttributeName() + ":", tmpAttribute)); + input.setBackground(parent.getBackground()); + input.setEditable(false); + input.setBorder(BorderFactory.createLineBorder(Color.gray)); + input.setText(bitmask.getText(tmpAttribute.getValue())); + component = input; + tmpAttribute.setEncodedValue(gameObject.getAttributeString(archetypeAttribute.getArchetypeAttributeName())); + row = null; + } else { + label = null; + component = null; + row = new JLabel("Error: Undefined Bitmask"); + } + guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeBitmask>(tmpAttribute, label, component, row, null, false); + } + + @Override + public void visit(@NotNull final ArchetypeAttributeBool archetypeAttribute) { + final JCheckBox input = new JCheckBox(archetypeAttribute.getAttributeName(), gameObject.getAttributeInt(archetypeAttribute.getArchetypeAttributeName()) == 1); + guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeBool>(new DialogAttributeBool<G, A, R>(archetypeAttribute, input), null, null, input, null, false); + } + + @Override + public void visit(@NotNull final ArchetypeAttributeBoolSpec archetypeAttribute) { + final CharSequence attributeString = gameObject.getAttributeString(archetypeAttribute.getArchetypeAttributeName()); + final boolean defaultValue; + if (archetypeAttribute.getTrueValue().equals("0")) { + defaultValue = attributeString.length() == 0 || attributeString.equals("0"); + } else { + defaultValue = attributeString.equals(archetypeAttribute.getTrueValue()); + } + final JCheckBox input = new JCheckBox(archetypeAttribute.getAttributeName(), defaultValue); + guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeBoolSpec>(new DialogAttributeBoolSpec<G, A, R>(archetypeAttribute, input), null, input, null, null, false); + } + + @Override + public void visit(@NotNull final ArchetypeAttributeFaceName archetypeAttribute) { + final String attributeName = archetypeAttribute.getArchetypeAttributeName(); + final String defaultText = gameObject.getAttributeString(attributeName); + final FaceComponent input = new FaceComponent(defaultText, faceObjects, faceObjectProviders, noFaceSquareIcon, unknownSquareIcon); + final JLabel label = new JLabel(archetypeAttribute.getAttributeName() + ":"); + guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeFaceName>(new DialogAttributeFaceName<G, A, R>(archetypeAttribute, input), label, input, null, null, false); + } + + @Override + public void visit(@NotNull final ArchetypeAttributeFixed archetypeAttribute) { + throw new AssertionError(); + } + + @Override + public void visit(@NotNull final ArchetypeAttributeFloat archetypeAttribute) { + final JLabel label = new JLabel(archetypeAttribute.getAttributeName() + ": "); + label.setForeground(FLOAT_COLOR); + final int fieldLength = archetypeAttribute.getInputLength() == 0 ? ArchetypeAttribute.TEXTFIELD_COLUMNS : archetypeAttribute.getInputLength(); + final DecimalFormat format = new DecimalFormat("#0.0#"); + format.setMaximumFractionDigits(10); + format.setGroupingUsed(false); + final NumberFormatter formatter = new NumberFormatter(format); + formatter.setValueClass(Double.class); + final DefaultFormatterFactory factory = new DefaultFormatterFactory(formatter); + // parse value from gameObject + final Number value = gameObject.getAttributeDouble(archetypeAttribute.getArchetypeAttributeName()); + final JFormattedTextField input = new JFormattedTextField(factory, value); + input.setColumns(fieldLength); + guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeFloat>(new DialogAttributeFloat<G, A, R>(archetypeAttribute, input), label, input, null, null, false); + } + + @Override + public void visit(@NotNull final ArchetypeAttributeInt archetypeAttribute) { + final JLabel label = new JLabel(archetypeAttribute.getAttributeName() + ": "); + label.setForeground(INT_COLOR); + final int fieldLength = archetypeAttribute.getInputLength() == 0 ? ArchetypeAttribute.TEXTFIELD_COLUMNS : archetypeAttribute.getInputLength(); + final NumberFormat format = NumberFormat.getIntegerInstance(); + format.setGroupingUsed(false); + final NumberFormatter formatter = new NumberFormatter(format); + final DefaultFormatterFactory factory = new DefaultFormatterFactory(formatter); + // parse value from gameObject + final Number value = gameObject.getAttributeInt(archetypeAttribute.getArchetypeAttributeName()); + final JFormattedTextField input = new JFormattedTextField(factory, value); + input.setColumns(fieldLength); + guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeInt>(new DialogAttributeInt<G, A, R>(archetypeAttribute, input), label, input, null, null, false); + } + + @Override + public void visit(@NotNull final ArchetypeAttributeInvSpell archetypeAttribute) { + final JLabel label = new JLabel(archetypeAttribute.getAttributeName() + ": "); + label.setForeground(INT_COLOR); + // create ComboBox with parsed selection + @Nullable final JComboBox input = buildInvSpellBox(gameObjectSpells, gameObject, archetypeAttribute.isOptionalSpell(), archetypeAttribute.getAttributeName()); + guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeInvSpell>(new DialogAttributeInvSpell<G, A, R>(archetypeAttribute.isOptionalSpell(), archetypeAttribute, input, gameObjectSpells), label, input, null, null, false); + } + + @Override + public void visit(@NotNull final ArchetypeAttributeList archetypeAttribute) { + final JLabel label = new JLabel(archetypeAttribute.getAttributeName() + ": "); + label.setForeground(INT_COLOR); + // create ComboBox with parsed selection + final JComponent component; + @Nullable final JComboBox input; + final ArchetypeTypeList list = archetypeTypeSet.getList(archetypeAttribute.getListName()); + if (list != null) { + // build the list from vector data + input = buildArrayBox(list, gameObject, archetypeAttribute.getArchetypeAttributeName(), archetypeAttribute.getAttributeName()); + component = input; + } else { + // error: list data is missing or corrupt + input = new JComboBox(); + component = new JLabel("Error: Undefined List"); + } + guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeList>(new DialogAttributeList<G, A, R>(archetypeAttribute, input, archetypeTypeSet), label, component, null, null, false); + } + + @Override + public void visit(@NotNull final ArchetypeAttributeLong archetypeAttribute) { + final JLabel label = new JLabel(archetypeAttribute.getAttributeName() + ": "); + label.setForeground(INT_COLOR); + final int fieldLength = archetypeAttribute.getInputLength() == 0 ? ArchetypeAttribute.TEXTFIELD_COLUMNS : archetypeAttribute.getInputLength(); + final NumberFormat format = NumberFormat.getIntegerInstance(); + format.setGroupingUsed(false); + final NumberFormatter formatter = new NumberFormatter(format); + final DefaultFormatterFactory factory = new DefaultFormatterFactory(formatter); + // parse value from gameObject + final Number value = gameObject.getAttributeLong(archetypeAttribute.getArchetypeAttributeName()); + final JFormattedTextField input = new JFormattedTextField(factory, value); + input.setColumns(fieldLength); + guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeLong>(new DialogAttributeLong<G, A, R>(archetypeAttribute, input), label, input, null, null, false); + } + + @Override + public void visit(@NotNull final ArchetypeAttributeMapPath archetypeAttribute) { + final MapSquare<G, A, R> mapSquare = gameObject.getMapSquare(); + File relativeReference = mapSquare == null ? null : mapSquare.getMapModel().getMapFile(); + if (relativeReference == null) { + relativeReference = new File(globalSettings.getMapsDirectory(), "dummy"); + } + final JLabel label = new JLabel(archetypeAttribute.getAttributeName() + ": "); + final TilePanel tilePanel = new TilePanel(mapFileFilter, gameObject.getAttributeString(archetypeAttribute.getArchetypeAttributeName()), relativeReference, globalSettings.getMapsDirectory()); + guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeMapPath>(new DialogAttributeMapPath<G, A, R>(archetypeAttribute, tilePanel), label, tilePanel, null, null, false); + } + + @Override + public void visit(@NotNull final ArchetypeAttributeScriptFile archetypeAttribute) { + final JLabel label = new JLabel(archetypeAttribute.getAttributeName() + ": "); + final File mapsDirectory = globalSettings.getMapsDirectory(); + final TilePanel tilePanel = new TilePanel(scriptFileFilter, gameObject.getAttributeString(archetypeAttribute.getArchetypeAttributeName()), new File(mapsDirectory, "dummy"), mapsDirectory); + guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeScriptFile>(new DialogAttributeScriptFile<G, A, R>(archetypeAttribute, tilePanel), label, tilePanel, null, null, false); + } + + @Override + public void visit(@NotNull final ArchetypeAttributeSpell archetypeAttribute) { + final JLabel label = new JLabel(archetypeAttribute.getAttributeName() + ": "); + label.setForeground(INT_COLOR); + // create ComboBox with parsed selection + @Nullable final JComboBox input = buildSpellBox(gameObject, numberSpells, undefinedSpellIndex, false, archetypeAttribute); + guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeSpell>(new DialogAttributeSpell<G, A, R>(archetypeAttribute, input, numberSpells), label, input, null, null, false); + } + + @Override + public void visit(@NotNull final ArchetypeAttributeString archetypeAttribute) { + final String defaultText = gameObject.getAttributeString(archetypeAttribute.getArchetypeAttributeName()); + final JTextField input = new JTextField(defaultText, ArchetypeAttribute.TEXTFIELD_COLUMNS); + final JLabel label = new JLabel(archetypeAttribute.getAttributeName() + ": "); + guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeString>(new DialogAttributeString<G, A, R>(archetypeAttribute, input), label, input, null, null, false); + } + + @Override + public void visit(@NotNull final ArchetypeAttributeText archetypeAttribute) { + String text = ""; + if (archetypeAttribute.getArchetypeAttributeName().equals("msg")) { + final String archetypeMsgText = gameObject.getArchetype().getMsgText(); + final String gameObjectMsgText = gameObject.getMsgText(); + if (archetypeMsgText != null && archetypeMsgText.length() > 0 && (gameObjectMsgText == null || gameObjectMsgText.length() == 0)) { + text = archetypeMsgText; + } else { + text = gameObjectMsgText; + } + } + final JEditTextArea input = new JEditTextArea(textAreaDefaults); + input.setDocument(new SyntaxDocument()); + input.getDocument().setTokenMarker(TokenMarkerFactory.createTokenMarker(archetypeAttribute.getFileExtension())); + input.setText(text == null ? "" : text); + input.setCaretPosition(0); + input.setBorder(BorderFactory.createEmptyBorder(3, 7, 0, 0)); + input.getPainter().setInvalidLinesPainted(false); + guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeText>(new DialogAttributeText<G, A, R>(archetypeAttribute, input), null, null, null, input, true); + } + + @Override + public void visit(@NotNull final ArchetypeAttributeTreasure archetypeAttribute) { + // textfield (no direct input, text is set by the treasurelist dialog) + String treasureName = gameObject.getAttributeString(archetypeAttribute.getArchetypeAttributeName()); + if (treasureName.trim().length() == 0 || treasureName.trim().equalsIgnoreCase("none")) { + treasureName = CFTreasureListTree.NONE_SYM; + } + final JTextField input = new JTextField(" " + treasureName, ArchetypeAttribute.TEXTFIELD_COLUMNS); + input.setEditable(false); + final DialogAttributeTreasure<G, A, R> tmpAttribute = new DialogAttributeTreasure<G, A, R>(archetypeAttribute, input, treasureTree); + final JButton label = new JButton(new ViewTreasurelistAL(input, parent, treasureListTree)); + guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeTreasure>(tmpAttribute, label, input, null, null, false); + } + + @Override + public void visit(@NotNull final ArchetypeAttributeZSpell archetypeAttribute) { + final JLabel label = new JLabel(archetypeAttribute.getAttributeName() + ": "); + label.setForeground(INT_COLOR); + // create ComboBox with parsed selection + @Nullable final JComboBox input = buildSpellBox(gameObject, numberSpells, undefinedSpellIndex, true, archetypeAttribute); + guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeZSpell>(new DialogAttributeZSpell<G, A, R>(archetypeAttribute, input, numberSpells, undefinedSpellIndex), label, input, null, null, false); + } + + }; + + /** + * Creates a new instance. + * @param gameObject the game object for which the attributes are built + * @param parent the parent component for dialogs + * @param archetypeTypeSet the reference to the list of archetype types + * @param treasureListTree the treasure list tree to display + * @param faceObjectProviders the face object providers for looking up + * faces + * @param animationObjects the animation objects instance for choosing + * animation names + * @param globalSettings the global settings to use + * @param mapFileFilter the file filter to use for map files + * @param scriptFileFilter the file filter to use for script files + * @param faceObjects the face objects instance for choosing face names + * @param gameObjectSpells the game object spells to use + * @param numberSpells the numbered spells to use + * @param undefinedSpellIndex the index for "no spell" + * @param treasureTree the treasure tree to use + * @param noFaceSquareIcon the image icon for no animations + * @param unknownSquareIcon the image icon for undefined animations + * @param textAreaDefaults the text area defaults for text fields + */ + public AttributesPaneBuilder(@NotNull final G gameObject, @NotNull final Component parent, final ArchetypeTypeSet archetypeTypeSet, @NotNull final CFTreasureListTree treasureListTree, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final AnimationObjects animationObjects, @NotNull final GlobalSettings globalSettings, @NotNull final FileFilter mapFileFilter, @NotNull final FileFilter scriptFileFilter, @NotNull final FaceObjects faceObjects, @NotNull final Spells<GameObjectSpell<G, A, R>> gameObjectSpells, @NotNull final Spells<NumberSpell> numberSpells, final int undefinedSpellIndex, @NotNull final TreasureTree treasureTree, @NotNull final ImageIcon noFaceSquareIcon, @NotNull final ImageIcon unknownSquareIcon, @NotNull final TextAreaDefaults textAreaDefaults) { + this.gameObject = gameObject; + this.parent = parent; + this.archetypeTypeSet = archetypeTypeSet; + this.treasureListTree = treasureListTree; + this.faceObjectProviders = faceObjectProviders; + this.animationObjects = animationObjects; + this.globalSettings = globalSettings; + this.mapFileFilter = mapFileFilter; + this.scriptFileFilter = scriptFileFilter; + this.faceObjects = faceObjects; + this.gameObjectSpells = gameObjectSpells; + this.numberSpells = numberSpells; + this.undefinedSpellIndex = undefinedSpellIndex; + this.treasureTree = treasureTree; + this.noFaceSquareIcon = noFaceSquareIcon; + this.unknownSquareIcon = unknownSquareIcon; + this.textAreaDefaults = textAreaDefaults; + } + + /** + * Returns the {@link JTabbedPane} that contains all attribute tabs. + * @return the pane + */ + @NotNull + public JTabbedPane getTabbedPane() { + return tabbedPane; + } + + /** + * Returns all {@link DialogAttribute DialogAttributes} in the dialog. + * @return the dialog attributes + */ + @NotNull + public Collection<DialogAttribute<G, A, R, ?>> getDialogAttributes() { + return Collections.unmodifiableCollection(dialogAttributes); + } + + /** + * Constructs the central part of the attribute dialog, containing the + * object's gameObject attributes. + * @param gameObject the game object for which the attributes are built + * @param archetypeType the archetype type of {@code gamObject} + */ + public void buildAttribute(@NotNull final G gameObject, @NotNull final Iterable<ArchetypeAttributeSection> archetypeType) { + this.gameObject = gameObject; + tabbedPane.removeAll(); + int sectionId = 0; + for (final ArchetypeAttributeSection archetypeAttributeSection : archetypeType) { + final Component panel = makeAttributePanel(archetypeAttributeSection); + if (panel != null) { + final String sectionName = archetypeAttributeSection.getSectionName(); + final String title; + if (sectionName.length() <= 1) { + title = sectionName; + } else { + title = sectionName.substring(0, 1).toUpperCase() + sectionName.substring(1); + } + tabbedPane.addTab(title, null, panel); + sectionId++; + } + } + + // set selected tab + tabbedPane.setSelectedIndex(sectionId > 0 ? 0 : -1); + tabbedPane.validate(); + } + + /** + * This method creates an attribute panel for one section of attributes. If + * the section is empty, null is returned. + * @param archetypeAttributeSection the section + * @return a <code>Component</code> containing the attribute panel + * (currently always a JScrollPane) + */ + @Nullable + private Component makeAttributePanel(@NotNull final Iterable<ArchetypeAttribute> archetypeAttributeSection) { + int matchingAttributes = 0; // number of attributes in this section + boolean hasBitmask = false; // true if this section contains a bitmask attribute + + // first we check how many attributes this section has + for (final ArchetypeAttribute archetypeAttribute : archetypeAttributeSection) { + // count number of attributes + if (!(archetypeAttribute instanceof ArchetypeAttributeFixed)) { + matchingAttributes++; + } + // check for bitmask attributes + if (!hasBitmask && archetypeAttribute instanceof ArchetypeAttributeBitmask) { + hasBitmask = true; + } + } + if (matchingAttributes == 0) { + return null; + } + + // All attribute-"lines" go into this panel: + final JPanel panel = new JPanel(new GridBagLayout()); + final Insets gbcInsets = new Insets(2, 2, 2, 2); + + final GridBagConstraints gbc = new GridBagConstraints(); + gbc.insets = gbcInsets; + final Object helpGbc = gbc.clone(); + gbc.fill = GridBagConstraints.HORIZONTAL; + final Object labelGbc = gbc.clone(); + gbc.weightx = 1.0; + gbc.gridwidth = GridBagConstraints.REMAINDER; + final Object compGbc = gbc.clone(); + gbc.anchor = GridBagConstraints.WEST; + final Object rowGbc = gbc.clone(); + gbc.fill = GridBagConstraints.BOTH; + gbc.weighty = 1.0; + final Object glueGbc = gbc.clone(); + + boolean isText = false; + // now add the entries, line by line + for (final ArchetypeAttribute archetypeAttribute : archetypeAttributeSection) { + if (!(archetypeAttribute instanceof ArchetypeAttributeFixed)) { + final AbstractButton helpButton = new JButton("?"); + helpButton.setMargin(new Insets(0, 5, 0, 5)); + panel.add(helpButton, helpGbc); + helpButton.addFocusListener(focusListener); + + guiInfo = null; + archetypeAttribute.visit(archetypeAttributeVisitor); + final GuiInfo<G, A, R, ?> tmpGuiInfo = guiInfo; + assert tmpGuiInfo != null; + + dialogAttributes.add(tmpGuiInfo.getNewAttr()); + helpButton.addActionListener(new HelpActionListener(tmpGuiInfo.getNewAttr().getRef(), parent)); + addElement(panel, tmpGuiInfo.getLabel(), labelGbc); + addElement(panel, tmpGuiInfo.getComponent(), compGbc); + addElement(panel, tmpGuiInfo.getRow(), rowGbc); + addElement(panel, tmpGuiInfo.getGlue(), glueGbc); + isText |= tmpGuiInfo.isText(); + } + } + + if (!isText) { + // if the component does not already have glue, put glue inside to align its contents to the top. + panel.add(Box.createGlue(), glueGbc); + } + final JScrollPane panelReturn = new JScrollPane(panel); + panelReturn.getVerticalScrollBar().setUnitIncrement(8); + return panelReturn; + } + + /** + * Adds a {@link Component} to a {@link Container}. + * @param container the container to add to + * @param component the component to add or <code>null</code> + * @param constraints the constraints + */ + private void addElement(@NotNull final Container container, @Nullable final Component component, @NotNull final Object constraints) { + if (component != null) { + container.add(component, constraints); + component.addFocusListener(focusListener); + } + } + + /** + * Constructs the combo box of the available spells. + * @param gameObjectSpells the game object spells to use + * @param isOptionalSpell whether the entry <none> should be shown + * @param attributeName the archetype attribute's name + * @param gameObject the associated game object + * @return the completed <code>JComboBox</code> + */ + @NotNull + private static <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> JComboBox buildInvSpellBox(@NotNull final Spells<GameObjectSpell<G, A, R>> gameObjectSpells, @NotNull final BaseObject<?, ?, ?, ?> gameObject, final boolean isOptionalSpell, @NotNull final String attributeName) { + final int selectedIndex; + @Nullable final String title; + switch (gameObject.countInvObjects()) { + case 0: + selectedIndex = gameObjectSpells.size(); + title = isOptionalSpell ? null : "<none>"; + break; + + default: + selectedIndex = gameObjectSpells.size() + (isOptionalSpell ? 1 : 0); + title = "<multiple>"; + break; + + case 1: + final GameObject<?, ?, ?> invObject = gameObject.iterator().next(); + final String invObjectArchetypeName = invObject.getArchetype().getArchetypeName(); + int index = 0; + @Nullable String tmpTitle = "<customized spell>"; + for (final GameObjectSpell<?, ?, ?> spellObject : gameObjectSpells) { + if (invObjectArchetypeName.equals(spellObject.getArchetypeName())) { + tmpTitle = invObject.isDefaultGameObject() ? null : spellObject.getName() + " <customized>"; + break; + } + index++; + } + selectedIndex = tmpTitle != null ? gameObjectSpells.size() + (isOptionalSpell ? 1 : 0) : index; + title = tmpTitle; + break; + } + + final DefaultComboBoxModel model = new DefaultComboBoxModel(); + for (final Spell spell : gameObjectSpells) { + model.addElement(spell.getName()); + } + if (isOptionalSpell) { + model.addElement("<none>"); + } + if (title != null) { + model.addElement(title); + } + final JComboBox comboBox = new JComboBox(model); + comboBox.setSelectedIndex(selectedIndex); + comboBox.setMaximumRowCount(10); + comboBox.setKeySelectionManager(new StringKeyManager(comboBox)); + comboBox.setName(attributeName); + return comboBox; + } + + /** + * Constructs the combo box for arrays of "list data". + * @param listData list with list items and corresponding values + * @param gameObject the associated game object + * @param archetypeAttributeName the name of the shown attribute + * @param attributeName the label to show on the combo box + * @return the completed <code>JComboBox</code> + */ + @NotNull + private static JComboBox buildArrayBox(@NotNull final ArchetypeTypeList listData, @NotNull final BaseObject<?, ?, ?, ?> gameObject, @NotNull final String archetypeAttributeName, @NotNull final String attributeName) { + // build the array of list-items + final String[] array = new String[listData.size()]; + boolean hasSelection = false; + int active = gameObject.getAttributeInt(archetypeAttributeName); + for (int i = 0; i < array.length; i++) { + array[i] = listData.get(i).getSecond(); + if (!hasSelection && listData.get(i).getFirst() == active) { + hasSelection = true; + active = i; // set selection to this index in the array + } + } + // if there is no valid pre-selection, show first element of list + if (!hasSelection) { + active = 0; + } + final JComboBox comboBox = new JComboBox(array); // set "content" + comboBox.setSelectedIndex(active); // set active selection + comboBox.setMaximumRowCount(10); + comboBox.setKeySelectionManager(new StringKeyManager(comboBox)); + comboBox.setName(attributeName); + return comboBox; + } + + /** + * Constructs the combo box of the available spells. + * @param gameObject the associated game object + * @param numberSpells the number spells to use + * @param undefinedSpellIndex the index to use for the undefined spell + * @param isZSpell whether a z-spell or a spell combo box is built + * @param archetypeAttribute the archetype attribute + * @return the completed <code>JComboBox</code> + */ + @NotNull + private static JComboBox buildSpellBox(@NotNull final BaseObject<?, ?, ?, ?> gameObject, @NotNull final Spells<NumberSpell> numberSpells, final int undefinedSpellIndex, final boolean isZSpell, @NotNull final ArchetypeAttribute archetypeAttribute) { + int spellNumber = gameObject.getAttributeInt(archetypeAttribute.getArchetypeAttributeName()); + + if (spellNumber < 0 || spellNumber >= numberSpells.size()) { + spellNumber = undefinedSpellIndex; + } + + // do we have "none" spell? + final int selectedIndex; + if (spellNumber == undefinedSpellIndex && isZSpell) { + selectedIndex = 0; + } else { + // now look up the spell-number in the array of spells + selectedIndex = 1 + AbstractArchetypeAttributeSpell.findSpellIndex(numberSpells, spellNumber); + } + + final DefaultComboBoxModel model = new DefaultComboBoxModel(); + model.addElement("<none>"); + for (final Spell spell : numberSpells) { + model.addElement(spell.getName()); + } + final JComboBox comboBox = new JComboBox(model); + comboBox.setSelectedIndex(selectedIndex); + comboBox.setMaximumRowCount(10); + comboBox.setKeySelectionManager(new StringKeyManager(comboBox)); + comboBox.setName(archetypeAttribute.getAttributeName()); + return comboBox; + } + +} Property changes on: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/AttributesPaneBuilder.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java 2013-07-14 21:01:05 UTC (rev 9343) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java 2013-07-14 21:34:00 UTC (rev 9344) @@ -29,78 +29,42 @@ import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.Point; -import java.awt.event.FocusListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.io.File; -import java.text.DecimalFormat; -import java.text.NumberFormat; -import java.util.ArrayList; -import java.util.Collection; import java.util.Set; import javax.swing.AbstractButton; import javax.swing.Action; import javax.swing.BorderFactory; import javax.swing.Box; -import javax.swing.DefaultComboBoxModel; import javax.swing.ImageIcon; import javax.swing.JButton; -import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JComponent; import javax.swing.JDialog; -import javax.swing.JFormattedTextField; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; -import javax.swing.JTabbedPane; -import javax.swing.JTextArea; import javax.swing.JTextField; import javax.swing.JTextPane; import javax.swing.SwingConstants; import javax.swing.filechooser.FileFilter; import javax.swing.text.BadLocationException; -import javax.swing.text.DefaultFormatterFactory; import javax.swing.text.Document; import javax.swing.text.JTextComponent; -import javax.swing.text.NumberFormatter; import javax.swing.text.Style; import javax.swing.text.StyleConstants; import javax.swing.text.StyleContext; import net.sf.gridarta.gui.dialog.help.Help; -import net.sf.gridarta.gui.map.maptilepane.TilePanel; import net.sf.gridarta.gui.treasurelist.CFTreasureListTree; -import net.sf.gridarta.gui.utils.AnimationComponent; -import net.sf.gridarta.gui.utils.FaceComponent; import net.sf.gridarta.model.anim.AnimationObjects; import net.sf.gridarta.model.archetype.Archetype; -import net.sf.gridarta.model.archetypetype.AbstractArchetypeAttributeSpell; import net.sf.gridarta.model.archetypetype.ArchetypeAttribute; -import net.sf.gridarta.model.archetypetype.ArchetypeAttributeAnimationName; -import net.sf.gridarta.model.archetypetype.ArchetypeAttributeBitmask; -import net.sf.gridarta.model.archetypetype.ArchetypeAttributeBool; -import net.sf.gridarta.model.archetypetype.ArchetypeAttributeBoolSpec; -import net.sf.gridarta.model.archetypetype.ArchetypeAttributeFaceName; import net.sf.gridarta.model.archetypetype.ArchetypeAttributeFixed; -import net.sf.gridarta.model.archetypetype.ArchetypeAttributeFloat; -import net.sf.gridarta.model.archetypetype.ArchetypeAttributeInt; -import net.sf.gridarta.model.archetypetype.ArchetypeAttributeInvSpell; -import net.sf.gridarta.model.archetypetype.ArchetypeAttributeList; -import net.sf.gridarta.model.archetypetype.ArchetypeAttributeLong; -import net.sf.gridarta.model.archetypetype.ArchetypeAttributeMapPath; -import net.sf.gridarta.model.archetypetype.ArchetypeAttributeScriptFile; import net.sf.gridarta.model.archetypetype.ArchetypeAttributeSection; -import net.sf.gridarta.model.archetypetype.ArchetypeAttributeSpell; -import net.sf.gridarta.model.archetypetype.ArchetypeAttributeString; -import net.sf.gridarta.model.archetypetype.ArchetypeAttributeText; -import net.sf.gridarta.model.archetypetype.ArchetypeAttributeTreasure; -import net.sf.gridarta.model.archetypetype.ArchetypeAttributeVisitor; -import net.sf.gridarta.model.archetypetype.ArchetypeAttributeZSpell; import net.sf.gridarta.model.archetypetype.ArchetypeType; -import net.sf.gridarta.model.archetypetype.ArchetypeTypeList; import net.sf.gridarta.model.archetypetype.ArchetypeTypeSet; -import net.sf.gridarta.model.archetypetype.AttributeBitmask; import net.sf.gridarta.model.baseobject.BaseObject; import net.sf.gridarta.model.face.FaceObjectProviders; import net.sf.gridarta.model.face.FaceObjectProvidersListener; @@ -117,14 +81,10 @@ import net.sf.gridarta.model.settings.GlobalSettings; import net.sf.gridarta.model.spells.GameObjectSpell; import net.sf.gridarta.model.spells.NumberSpell; -import net.sf.gridarta.model.spells.Spell; import net.sf.gridarta.model.spells.Spells; import net.sf.gridarta.model.treasurelist.TreasureTree; import net.sf.gridarta.model.validation.ErrorCollector; -import net.sf.gridarta.textedit.textarea.JEditTextArea; -import net.sf.gridarta.textedit.textarea.SyntaxDocument; import net.sf.gridarta.textedit.textarea.TextAreaDefaults; -import net.sf.gridarta.textedit.textarea.tokenmarker.TokenMarkerFactory; import net.sf.gridarta.utils.ActionBuilderUtils; import net.sf.gridarta.utils.Size2D; import net.sf.gridarta.utils.StringUtils; @@ -144,23 +104,6 @@ public class GameObjectAttributesDialog<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> { /** - * Color for float values. - */ - @NotNull - public static final Color FLOAT_COLOR = new Color(19, 134, 0); - - /** - * Color for int values. - */ - @NotNull - public static final Color INT_COLOR = new Color(74, 70, 156); - - /** - * The serial version UID. - */ - private static final long serialVersionUID = 1L; - - /** * The Logger for printing log messages. */ @NotNull @@ -192,107 +135,18 @@ private final Frame parent; /** - * The {@link CFTreasureListTree} to use. - * @serial - */ - @NotNull - private final CFTreasureListTree treasureListTree; - - /** * The {@link FaceObjectProviders} for looking up faces. */ @NotNull private final FaceObjectProviders faceObjectProviders; /** - * The {@link AnimationObjects} instance for choosing animation names. - * @serial - */ - @NotNull - private final AnimationObjects animationObjects; - - /** - * The {@link GlobalSettings} instance. - */ - @NotNull - private final GlobalSettings globalSettings; - - /** - * The {@link FileFilter} to use for map files. - */ - @NotNull - private final FileFilter mapFileFilter; - - /** - * The {@link FileFilter} to use for script files. - */ - @NotNull - private final FileFilter scriptFileFilter; - - /** - * The {@link FaceObjects} instance for choosing face names. - * @serial - */ - @NotNull - private final FaceObjects faceObjects; - - /** - * The game object spells to use. - */ - @NotNull - private final Spells<GameObjectSpell<G, A, R>> gameObjectSpells; - - /** - * The numbered spells. - */ - @NotNull - private final Spells<NumberSpell> numberSpells; - - /** - * The index for "no spell". - * @serial - */ - private final int undefinedSpellIndex; - - /** - * The {@link TreasureTree} to use. - */ - @NotNull - private final TreasureTree treasureTree; - - /** - * The {@link ImageIcon} for no animations. - * @serial - */ - @NotNull - private final ImageIcon noFaceSquareIcon; - - /** - * The {@link ImageIcon} for undefined animations. - * @serial - */ - @NotNull - private final ImageIcon unknownSquareIcon; - - /** - * The {@link TextAreaDefaults} for text fields. - */ - @NotNull - private final TextAreaDefaults textAreaDefaults; - - /** * The {@link MapManager} instance. */ @NotNull private final MapManager<G, A, R> mapManager; - /** - * All {@link DialogAttribute DialogAttributes} in the dialog. - */ @NotNull - private final Collection<DialogAttribute<G, A, R, ?>> dialogAttributes = new ArrayList<DialogAttribute<G, A, R, ?>>(); - - @NotNull private final JOptionPane optionPane = new JOptionPane() { /** @@ -312,6 +166,13 @@ }; /** + * /he {@link AttributesPaneBuilder} for creating (and re-creating) the + * attribute tabs. + */ + @NotNull + private final AttributesPaneBuilder<G, A, R> attributesPaneBuilder; + + /** * The panel for object's face (png). * @serial */ @@ -389,13 +250,6 @@ private JButton okButton; /** - * The central tabbed pane (the place where all the attribute tabs are). - * @serial - */ - @NotNull - private final JTabbedPane tabbedPane = new JTabbedPane(); - - /** * The central pane, this is the parent component of above tabbed pane. * @serial */ @@ -410,262 +264,15 @@ private final JTextPane summaryTextPane; @NotNull - private final FocusListener focusListener = new ScrollToVisibleFocusListener(); - - @NotNull private final Style summaryTextStyle; /** - * The return value for {@link #archetypeAttributeVisitor}. - */ - @Nullable - private GuiInfo<G, A, R, ?> guiInfo; - - /** * The {@link ArchetypeType} of {@link #gameObject}. */ @NotNull private ArchetypeType archetypeType; /** - * The {@link ArchetypeAttributeVisitor} for creating GUI elements for - * {@link ArchetypeAttribute ArchetypeAttributes}. - */ - @NotNull - private final ArchetypeAttributeVisitor archetypeAttributeVisitor = new ArchetypeAttributeVisitor() { - - @Override - public void visit(@NotNull final ArchetypeAttributeAnimationName archetypeAttribute) { - final String attributeName = archetypeAttribute.getArchetypeAttributeName(); - final String defaultText = gameObject.getAttributeString(attributeName); - final AnimationComponent input = new AnimationComponent(defaultText, animationObjects, faceObjectProviders, noFaceSquareIcon, unknownSquareIcon); - final JLabel cLabel = new JLabel(archetypeAttribute.getAttributeName() + ": "); - guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeAnimationName>(new DialogAttributeAnimationName<G, A, R>(archetypeAttribute, input), cLabel, input, null, null, false); - } - - @Override - public void visit(@NotNull final ArchetypeAttributeBitmask archetypeAttribute) { - final JTextArea input = new JTextArea(); - final DialogAttributeBitmask<G, A, R> tmpAttribute = new DialogAttributeBitmask<G, A, R>(archetypeAttribute, input); - @Nullable final JTextArea component; - @Nullable final JButton label; - @Nullable final JLabel row; - final AttributeBitmask bitmask = archetypeTypeSet.getBitmask(archetypeAttribute.getBitmaskName()); - if (bitmask != null) { - tmpAttribute.setBitmask(bitmask); - label = new JButton(new MaskChangeAL<G, A, R>(archetypeAttribute.getAttributeName() + ":", tmpAttribute)); - input.setBackground(optionPane.getBackground()); - input.setEditable(false); - input.setBorder(BorderFactory.createLineBorder(Color.gray)); - input.setText(bitmask.getText(tmpAttribute.getValue())); - component = input; - tmpAttribute.setEncodedValue(gameObject.getAttributeString(archetypeAttribute.getArchetypeAttributeName())); - row = null; - } else { - label = null; - component = null; - row = new JLabel("Error: Undefined Bitmask"); - } - guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeBitmask>(tmpAttribute, label, component, row, null, false); - } - - @Override - public void visit(@NotNull final ArchetypeAttributeBool archetypeAttribute) { - final JCheckBox input = new JCheckBox(archetypeAttribute.getAttributeName(), gameObject.getAttributeInt(archetypeAttribute.getArchetypeAttributeName()) == 1); - guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeBool>(new DialogAttributeBool<G, A, R>(archetypeAttribute, input), null, null, input, null, false); - } - - @Override - public void visit(@NotNull final ArchetypeAttributeBoolSpec archetypeAttribute) { - final CharSequence attributeString = gameObject.getAttributeString(archetypeAttribute.getArchetypeAttributeName()); - final boolean defaultValue; - if (archetypeAttribute.getTrueValue().equals("0")) { - defaultValue = attributeString.length() == 0 || attributeString.equals("0"); - } else { - defaultValue = attributeString.equals(archetypeAttribute.getTrueValue()); - } - final JCheckBox input = new JCheckBox(archetypeAttribute.getAttributeName(), defaultValue); - guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeBoolSpec>(new DialogAttributeBoolSpec<G, A, R>(archetypeAttribute, input), null, input, null, null, false); - } - - @Override - public void visit(@NotNull final ArchetypeAttributeFaceName archetypeAttribute) { - final String attributeName = archetypeAttribute.getArchetypeAttributeName(); - final String defaultText = gameObject.getAttributeString(attributeName); - final FaceComponent input = new FaceComponent(defaultText, faceObjects, faceObjectProviders, noFaceSquareIcon, unknownSquareIcon); - final JLabel label = new JLabel(archetypeAttribute.getAttributeName() + ":"); - guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeFaceName>(new DialogAttributeFaceName<G, A, R>(archetypeAttribute, input), label, input, null, null, false); - } - - @Override - public void visit(@NotNull final ArchetypeAttributeFixed archetypeAttribute) { - throw new AssertionError(); - } - - @Override - public void visit(@NotNull final ArchetypeAttributeFloat archetypeAttribute) { - final JLabel label = new JLabel(archetypeAttribute.getAttributeName() + ": "); - label.setForeground(FLOAT_COLOR); - final int fieldLength = archetypeAttribute.getInputLength() == 0 ? ArchetypeAttribute.TEXTFIELD_COLUMNS : archetypeAttribute.getInputLength(); - final DecimalFormat format = new DecimalFormat("#0.0#"); - format.setMaximumFractionDigits(10); - format.setGroupingUsed(false); - final NumberFormatter formatter = new NumberFormatter(format); - formatter.setValueClass(Double.class); - final DefaultFormatterFactory factory = new DefaultFormatterFactory(formatter); - // parse value from gameObject - final Number value = gameObject.getAttributeDouble(archetypeAttribute.getArchetypeAttributeName()); - final JFormattedTextField input = new JFormattedTextField(factory, value); - input.setColumns(fieldLength); - guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeFloat>(new DialogAttributeFloat<G, A, R>(archetypeAttribute, input), label, input, null, null, false); - } - - @Override - public void visit(@NotNull final ArchetypeAttributeInt archetypeAttribute) { - final JLabel label = new JLabel(archetypeAttribute.getAttributeName() + ": "); - label.setForeground(INT_COLOR); - final int fieldLength = archetypeAttribute.getInputLength() == 0 ? ArchetypeAttribute.TEXTFIELD_COLUMNS : archetypeAttribute.getInputLength(); - final NumberFormat format = NumberFormat.getIntegerInstance(); - format.setGroupingUsed(false); - final NumberFormatter formatter = new NumberFormatter(format); - final DefaultFormatterFactory factory = new DefaultFormatterFactory(formatter); - // parse value from gameObject - final Number value = gameObject.getAttributeInt(archetypeAttribute.getArchetypeAttributeName()); - final JFormattedTextField input = new JFormattedTextField(factory, value); - input.setColumns(fieldLength); - guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeInt>(new DialogAttributeInt<G, A, R>(archetypeAttribute, input), label, input, null, null, false); - } - - @Override - public void visit(@NotNull final ArchetypeAttributeInvSpell archetypeAttribute) { - final JLabel label = new JLabel(archetypeAttribute.getAttributeName() + ": "); - label.setForeground(INT_COLOR); - // create ComboBox with parsed selection - @Nullable final JComboBox input = buildInvSpellBox(gameObjectSpells, gameObject, archetypeAttribute.isOptionalSpell(), archetypeAttribute.getAttributeName()); - guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeInvSpell>(new DialogAttributeInvSpell<G, A, R>(archetypeAttribute.isOptionalSpell(), archetypeAttribute, input, gameObjectSpells), label, input, null, null, false); - } - - @Override - public void visit(@NotNull final ArchetypeAttributeList archetypeAttribute) { - final JLabel label = new JLabel(archetypeAttribute.getAttributeName() + ": "); - label.setForeground(INT_COLOR); - // create ComboBox with parsed selection - final JComponent component; - @Nullable final JComboBox input; - final ArchetypeTypeList list = archetypeTypeSet.getList(archetypeAttribute.getListName()); - if (list != null) { - // build the list from vector data - input = buildArrayBox(list, gameObject, archetypeAttribute.getArchetypeAttributeName(), archetypeAttribute.getAttributeName()); - component = input; - } else { - // error: list data is missing or corrupt - input = new JComboBox(); - component = new JLabel("Error: Undefined List"); - } - guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeList>(new DialogAttributeList<G, A, R>(archetypeAttribute, input, archetypeTypeSet), label, component, null, null, false); - } - - @Override - public void visit(@NotNull final ArchetypeAttributeLong archetypeAttribute) { - final JLabel label = new JLabel(archetypeAttribute.getAttributeName() + ": "); - label.setForeground(INT_COLOR); - final int fieldLength = archetypeAttribute.getInputLength() == 0 ? ArchetypeAttribute.TEXTFIELD_COLUMNS : archetypeAttribute.getInputLength(); - final NumberFormat format = NumberFormat.getIntegerInstance(); - format.setGroupingUsed(false); - final NumberFormatter formatter = new NumberFormatter(format); - final DefaultFormatterFactory factory = new DefaultFormatterFactory(formatter); - // parse value from gameObject - final Number value = gameObject.getAttributeLong(archetypeAttribute.getArchetypeAttributeName()); - final JFormattedTextField input = new JFormattedTextField(factory, value); - input.setColumns(fieldLength); - guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeLong>(new DialogAttributeLong<G, A, R>(archetypeAttribute, input), label, input, null, null, false); - } - - @Override - public void visit(@NotNull final ArchetypeAttributeMapPath archetypeAttribute) { - final MapSquare<G, A, R> mapSquare = gameObject.getMapSquare(); - File relativeReference = mapSquare == null ? null : mapSquare.getMapModel().getMapFile(); - if (relativeReference == null) { - relativeReference = new File(globalSettings.getMapsDirectory(), "dummy"); - } - final JLabel label = new JLabel(archetypeAttribute.get... [truncated message content] |
From: <aki...@us...> - 2013-07-14 21:01:08
|
Revision: 9343 http://sourceforge.net/p/gridarta/code/9343 Author: akirschbaum Date: 2013-07-14 21:01:05 +0000 (Sun, 14 Jul 2013) Log Message: ----------- Do not extend from JOptionPane. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java 2013-07-14 20:56:03 UTC (rev 9342) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java 2013-07-14 21:01:05 UTC (rev 9343) @@ -141,7 +141,7 @@ * @author <a href="mailto:ch...@ri...">Christian Hujer</a> * @author Andreas Kirschbaum */ -public class GameObjectAttributesDialog<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends JOptionPane { +public class GameObjectAttributesDialog<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> { /** * Color for float values. @@ -292,6 +292,25 @@ @NotNull private final Collection<DialogAttribute<G, A, R, ?>> dialogAttributes = new ArrayList<DialogAttribute<G, A, R, ?>>(); + @NotNull + private final JOptionPane optionPane = new JOptionPane() { + + /** + * {@inheritDoc} + */ + @Override + public void setValue(@Nullable final Object newValue) { + super.setValue(newValue); + if (newValue != UNINITIALIZED_VALUE) { + gameObjectAttributesDialogFactory.hideAttributeDialog(gameObject); + mapModel.removeMapModelListener(mapModelListener); + mapManager.removeMapManagerListener(mapManagerListener); + faceObjectProviders.removeFaceObjectProvidersListener(faceObjectProvidersListener); + } + } + + }; + /** * The panel for object's face (png). * @serial @@ -435,7 +454,7 @@ if (bitmask != null) { tmpAttribute.setBitmask(bitmask); label = new JButton(new MaskChangeAL<G, A, R>(archetypeAttribute.getAttributeName() + ":", tmpAttribute)); - input.setBackground(getBackground()); + input.setBackground(optionPane.getBackground()); input.setEditable(false); input.setBorder(BorderFactory.createLineBorder(Color.gray)); input.setText(bitmask.getText(tmpAttribute.getValue())); @@ -631,7 +650,7 @@ final JTextField input = new JTextField(" " + treasureName, ArchetypeAttribute.TEXTFIELD_COLUMNS); input.setEditable(false); final DialogAttributeTreasure<G, A, R> tmpAttribute = new DialogAttributeTreasure<G, A, R>(archetypeAttribute, input, treasureTree); - final JButton label = new JButton(new ViewTreasurelistAL(input, GameObjectAttributesDialog.this, treasureListTree)); + final JButton label = new JButton(new ViewTreasurelistAL(input, optionPane, treasureListTree)); guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeTreasure>(tmpAttribute, label, input, null, null, false); } @@ -656,21 +675,21 @@ @Override public void mapSizeChanged(@NotNull final Size2D newSize) { if (gameObject.getMapSquare() == null) { - setValue(cancelButton); + optionPane.setValue(cancelButton); } } @Override public void mapSquaresChanged(@NotNull final Set<MapSquare<G, A, R>> mapSquares) { if (gameObject.getMapSquare() != mapModel.getMapSquare(mapPos)) { - setValue(cancelButton); + optionPane.setValue(cancelButton); } } @Override public void mapObjectsChanged(@NotNull final Set<G> gameObjects, @NotNull final Set<G> transientGameObjects) { if (gameObject.getMapSquare() == null) { - setValue(cancelButton); + optionPane.setValue(cancelButton); } } @@ -715,7 +734,7 @@ @Override public void mapClosed(@NotNull final MapControl<G, A, R> mapControl) { if (mapControl.getMapModel() == mapModel) { - setValue(cancelButton); + optionPane.setValue(cancelButton); } } @@ -772,7 +791,7 @@ if (deselected == null) { deselected = archetypeType; } - if (JOptionPane.showConfirmDialog(GameObjectAttributesDialog.this, "Do you really want to change the type of this\n" + "object from \"" + deselected.getTypeName() + "\" to \"" + newType.getTypeName() + "\"?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE) == JOptionPane.YES_OPTION) { + if (JOptionPane.showConfirmDialog(optionPane, "Do you really want to change the type of this\n" + "object from \"" + deselected.getTypeName() + "\" to \"" + newType.getTypeName() + "\"?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE) == JOptionPane.YES_OPTION) { archetypeType = newType; final MapModel<G, A, R> mapModel = gameObject.getMapSquare().getMapModel(); @@ -877,14 +896,14 @@ gbc.weighty = 1.0; contentPanel.add(centerPanel, gbc); - setOptions(buildOptions()); + optionPane.setOptions(buildOptions()); summaryTextStyle = summaryTextPane.getStyle(StyleContext.DEFAULT_STYLE); StyleConstants.setForeground(summaryTextStyle, Color.black); faceObjectProviders.addFaceObjectProvidersListener(faceObjectProvidersListener); - setMessage(contentPanel); + optionPane.setMessage(contentPanel); } /** @@ -893,7 +912,7 @@ */ @NotNull public JDialog createDialog() { - final JDialog dialog = createDialog(parent, ActionBuilderUtils.getString(ACTION_BUILDER, "attribTitle")); + final JDialog dialog = optionPane.createDialog(parent, ActionBuilderUtils.getString(ACTION_BUILDER, "attribTitle")); dialog.getRootPane().setDefaultButton(okButton); dialog.setResizable(true); dialog.setModal(false); @@ -902,20 +921,6 @@ } /** - * {@inheritDoc} - */ - @Override - public void setValue(@Nullable final Object newValue) { - super.setValue(newValue); - if (newValue != UNINITIALIZED_VALUE) { - gameObjectAttributesDialogFactory.hideAttributeDialog(gameObject); - mapModel.removeMapModelListener(mapModelListener); - mapManager.removeMapManagerListener(mapManagerListener); - faceObjectProviders.removeFaceObjectProvidersListener(faceObjectProvidersListener); - } - } - - /** * Constructs the combo box of the available archetypes. * @return a <code>JComponent</code> with the combo box in it */ @@ -1089,7 +1094,7 @@ assert tmpGuiInfo != null; dialogAttributes.add(tmpGuiInfo.getNewAttr()); - helpButton.addActionListener(new HelpActionListener(tmpGuiInfo.getNewAttr().getRef(), this)); + helpButton.addActionListener(new HelpActionListener(tmpGuiInfo.getNewAttr().getRef(), optionPane)); addElement(panel, tmpGuiInfo.getLabel(), labelGbc); addElement(panel, tmpGuiInfo.getComponent(), compGbc); addElement(panel, tmpGuiInfo.getRow(), rowGbc); @@ -1147,7 +1152,7 @@ @ActionMethod public void attribOk() { if (applySettings()) { - setValue(okButton); + optionPane.setValue(okButton); } } @@ -1164,7 +1169,7 @@ */ @ActionMethod public void attribCancel() { - setValue(cancelButton); + optionPane.setValue(cancelButton); } /** @@ -1233,7 +1238,7 @@ final StringBuilder newArchText = new StringBuilder(); final String[] newMsg = new String[1]; for (final DialogAttribute<G, A, R, ?> dialogAttribute : dialogAttributes) { - final String text = dialogAttribute.getText2(gameObject, archetype, newMsg, tmpArchetypeType, this); + final String text = dialogAttribute.getText2(gameObject, archetype, newMsg, tmpArchetypeType, optionPane); if (text == null) { return false; } @@ -1288,7 +1293,7 @@ // kept. "Misc" is no real type - it is more a default mask for // unknown types. For all other archetype types, a popup dialog is // opened and the user may decide what to do with his errors. - final boolean keepErrors = archetypeTypeSet.isFallbackArchetypeType(tmpArchetypeType) || ConfirmErrorsDialog.askConfirmErrors(errors, this); + final boolean keepErrors = archetypeTypeSet.isFallbackArchetypeType(tmpArchetypeType) || ConfirmErrorsDialog.askConfirmErrors(errors, optionPane); if (keepErrors) { gameObject.addObjectText(errors.trim()); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-07-14 20:56:09
|
Revision: 9342 http://sourceforge.net/p/gridarta/code/9342 Author: akirschbaum Date: 2013-07-14 20:56:03 +0000 (Sun, 14 Jul 2013) Log Message: ----------- Add private modifier. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java 2013-07-14 20:52:09 UTC (rev 9341) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java 2013-07-14 20:56:03 UTC (rev 9342) @@ -1006,7 +1006,7 @@ * Constructs the central part of the attribute dialog, containing the * object's gameObject attributes. */ - public final void buildAttribute() { + private void buildAttribute() { tabbedPane.removeAll(); int sectionId = 0; for (final ArchetypeAttributeSection archetypeAttributeSection : archetypeType) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-07-14 20:52:14
|
Revision: 9341 http://sourceforge.net/p/gridarta/code/9341 Author: akirschbaum Date: 2013-07-14 20:52:09 +0000 (Sun, 14 Jul 2013) Log Message: ----------- Remove unused code. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java 2013-07-14 20:50:04 UTC (rev 9340) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java 2013-07-14 20:52:09 UTC (rev 9341) @@ -922,24 +922,15 @@ @NotNull private Component buildTypesBox() { final ArchetypeType[] model = new ArchetypeType[archetypeTypeSet.getArchetypeTypeCount()]; - - // read all type names int i = 0; for (final ArchetypeType tmp : archetypeTypeSet) { model[i++] = tmp; } - // the active type appears selected in the box - final int selection = archetypeTypeSet.getArchetypeTypeIndex(archetypeType); - final JComboBox typeComboBox = new JComboBox(model); typeComboBox.setSelectedItem(archetypeType); typeComboBox.setRenderer(new ArchetypeTypeListCellRenderer()); - - //typeComboBox.setKeySelectionManager(new StringKeyManager(typeComboBox)); - typeComboBox.setName("Types"); - typeComboBox.addItemListener(typesBoxItemListener); return typeComboBox; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-07-14 20:50:08
|
Revision: 9340 http://sourceforge.net/p/gridarta/code/9340 Author: akirschbaum Date: 2013-07-14 20:50:04 +0000 (Sun, 14 Jul 2013) Log Message: ----------- Convert GameObjectAttributesDialog.TypesBoxItemListener to anonymous class. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java 2013-07-14 20:44:18 UTC (rev 9339) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java 2013-07-14 20:50:04 UTC (rev 9340) @@ -139,6 +139,7 @@ /** * Common base class for game object attributes dialogs. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @author Andreas Kirschbaum */ public class GameObjectAttributesDialog<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends JOptionPane { @@ -734,6 +735,66 @@ }; /** + * ItemListener for the type-selection box on the attribute dialog. + */ + @NotNull + private final ItemListener typesBoxItemListener = new ItemListener() { + + /** + * The latest deselected item. + */ + @Nullable + private ArchetypeType deselected; + + /** + * While <code>true</code>, this listener ignores all events. + */ + private boolean ignoreEvent; + + /** + * {@inheritDoc} + */ + @Override + public void itemStateChanged(@NotNull final ItemEvent e) { + if (ignoreEvent) { + return; + } + + if (e.getStateChange() == ItemEvent.DESELECTED) { + deselected = (ArchetypeType) e.getItem(); + } else if (e.getStateChange() == ItemEvent.SELECTED && !e.getItem().equals(deselected)) { + final ArchetypeType newType = (ArchetypeType) e.getItem(); + + final JComboBox typeComboBox = (JComboBox) e.getSource(); + + typeComboBox.hidePopup(); + + if (deselected == null) { + deselected = archetypeType; + } + if (JOptionPane.showConfirmDialog(GameObjectAttributesDialog.this, "Do you really want to change the type of this\n" + "object from \"" + deselected.getTypeName() + "\" to \"" + newType.getTypeName() + "\"?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE) == JOptionPane.YES_OPTION) { + archetypeType = newType; + + final MapModel<G, A, R> mapModel = gameObject.getMapSquare().getMapModel(); + mapModel.beginTransaction("change type to " + newType.getTypeName()); + try { + gameObject.setAttributeInt(BaseObject.TYPE, newType.getTypeNo()); + } finally { + mapModel.endTransaction(); + } + + buildAttribute(); + } else { + ignoreEvent = true; + typeComboBox.setSelectedItem(archetypeType); + ignoreEvent = false; + } + } + } + + }; + + /** * Creates a new instance. * @param gameObjectAttributesDialogFactory the associated factory * @param archetypeTypeSet the reference to the list of archetype types @@ -879,7 +940,7 @@ typeComboBox.setName("Types"); - typeComboBox.addItemListener(new TypesBoxItemListener()); + typeComboBox.addItemListener(typesBoxItemListener); return typeComboBox; } @@ -1375,72 +1436,4 @@ return comboBox; } - /** - * ItemListener for the type-selection box on the attribute-dialog. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - * @author Andreas Kirschbaum - */ - private class TypesBoxItemListener implements ItemListener { - - /** - * The latest deselected item. - */ - @Nullable - private ArchetypeType deselected; - - /** - * While <code>true</code>, this listener ignores all events. - */ - private boolean ignoreEvent; - - /** - * Creates a new instance. - */ - private TypesBoxItemListener() { - ignoreEvent = false; - } - - /** - * {@inheritDoc} - */ - @Override - public void itemStateChanged(@NotNull final ItemEvent e) { - if (ignoreEvent) { - return; - } - - if (e.getStateChange() == ItemEvent.DESELECTED) { - deselected = (ArchetypeType) e.getItem(); - } else if (e.getStateChange() == ItemEvent.SELECTED && !e.getItem().equals(deselected)) { - final ArchetypeType newType = (ArchetypeType) e.getItem(); - - final JComboBox typeComboBox = (JComboBox) e.getSource(); - - typeComboBox.hidePopup(); - - if (deselected == null) { - deselected = archetypeType; - } - if (JOptionPane.showConfirmDialog(GameObjectAttributesDialog.this, "Do you really want to change the type of this\n" + "object from \"" + deselected.getTypeName() + "\" to \"" + newType.getTypeName() + "\"?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE) == JOptionPane.YES_OPTION) { - archetypeType = newType; - - final MapModel<G, A, R> mapModel = gameObject.getMapSquare().getMapModel(); - mapModel.beginTransaction("change type to " + newType.getTypeName()); - try { - gameObject.setAttributeInt(BaseObject.TYPE, newType.getTypeNo()); - } finally { - mapModel.endTransaction(); - } - - buildAttribute(); - } else { - ignoreEvent = true; - typeComboBox.setSelectedItem(archetypeType); - ignoreEvent = false; - } - } - } - - } - } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-07-14 20:44:23
|
Revision: 9339 http://sourceforge.net/p/gridarta/code/9339 Author: akirschbaum Date: 2013-07-14 20:44:18 +0000 (Sun, 14 Jul 2013) Log Message: ----------- Simplify code. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java 2013-07-14 20:26:40 UTC (rev 9338) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java 2013-07-14 20:44:18 UTC (rev 9339) @@ -872,14 +872,14 @@ final int selection = archetypeTypeSet.getArchetypeTypeIndex(archetypeType); final JComboBox typeComboBox = new JComboBox(model); - typeComboBox.setSelectedIndex(selection); + typeComboBox.setSelectedItem(archetypeType); typeComboBox.setRenderer(new ArchetypeTypeListCellRenderer()); //typeComboBox.setKeySelectionManager(new StringKeyManager(typeComboBox)); typeComboBox.setName("Types"); - typeComboBox.addItemListener(new TypesBoxItemListener(selection)); + typeComboBox.addItemListener(new TypesBoxItemListener()); return typeComboBox; } @@ -1394,18 +1394,9 @@ private boolean ignoreEvent; /** - * The position of this type in the type list. This differs from the - * GameObject if the type is undefined. - * @serial - */ - private int type; - - /** * Creates a new instance. - * @param type the initially selected type */ - private TypesBoxItemListener(final int type) { - this.type = type; + private TypesBoxItemListener() { ignoreEvent = false; } @@ -1432,7 +1423,6 @@ } if (JOptionPane.showConfirmDialog(GameObjectAttributesDialog.this, "Do you really want to change the type of this\n" + "object from \"" + deselected.getTypeName() + "\" to \"" + newType.getTypeName() + "\"?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE) == JOptionPane.YES_OPTION) { archetypeType = newType; - type = typeComboBox.getSelectedIndex(); final MapModel<G, A, R> mapModel = gameObject.getMapSquare().getMapModel(); mapModel.beginTransaction("change type to " + newType.getTypeName()); @@ -1445,7 +1435,7 @@ buildAttribute(); } else { ignoreEvent = true; - typeComboBox.setSelectedIndex(type); + typeComboBox.setSelectedItem(archetypeType); ignoreEvent = false; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-07-14 20:26:46
|
Revision: 9338 http://sourceforge.net/p/gridarta/code/9338 Author: akirschbaum Date: 2013-07-14 20:26:40 +0000 (Sun, 14 Jul 2013) Log Message: ----------- Convert TypesBoxItemListener to inner class of GameObjectAttributesDialog. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java Removed Paths: ------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/TypesBoxItemListener.java Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java 2013-07-14 19:41:03 UTC (rev 9337) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java 2013-07-14 20:26:40 UTC (rev 9338) @@ -30,6 +30,8 @@ import java.awt.Insets; import java.awt.Point; import java.awt.event.FocusListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; import java.io.File; import java.text.DecimalFormat; import java.text.NumberFormat; @@ -290,13 +292,6 @@ private final Collection<DialogAttribute<G, A, R, ?>> dialogAttributes = new ArrayList<DialogAttribute<G, A, R, ?>>(); /** - * The {@link TypesBoxItemListener} attached to the combo box box for - * selecting the object's type. - */ - @NotNull - private TypesBoxItemListener<G, A, R> typesBoxItemListener; - - /** * The panel for object's face (png). * @serial */ @@ -407,6 +402,12 @@ private GuiInfo<G, A, R, ?> guiInfo; /** + * The {@link ArchetypeType} of {@link #gameObject}. + */ + @NotNull + private ArchetypeType archetypeType; + + /** * The {@link ArchetypeAttributeVisitor} for creating GUI elements for * {@link ArchetypeAttribute ArchetypeAttributes}. */ @@ -789,8 +790,8 @@ mapManager.addMapManagerListener(mapManagerListener); // first split top-left and -right - final ArchetypeType archetypeType = archetypeTypeSet.getArchetypeTypeByBaseObject(gameObject); - final JComponent leftPane = buildHeader(archetypeTypeSet.getArchetypeTypeIndex(archetypeType), archetypeType); + archetypeType = archetypeTypeSet.getArchetypeTypeByBaseObject(gameObject); + final JComponent leftPane = buildHeader(); // Now split horizontally buildAttribute(); @@ -855,12 +856,10 @@ /** * Constructs the combo box of the available archetypes. - * @param type the initially selected type - * @param archetypeType the archetype type to display * @return a <code>JComponent</code> with the combo box in it */ @NotNull - private Component buildTypesBox(final int type, @NotNull final ArchetypeType archetypeType) { + private Component buildTypesBox() { final ArchetypeType[] model = new ArchetypeType[archetypeTypeSet.getArchetypeTypeCount()]; // read all type names @@ -870,7 +869,7 @@ } // the active type appears selected in the box - final int selection = type; + final int selection = archetypeTypeSet.getArchetypeTypeIndex(archetypeType); final JComboBox typeComboBox = new JComboBox(model); typeComboBox.setSelectedIndex(selection); @@ -880,9 +879,7 @@ typeComboBox.setName("Types"); - // the listener: - typesBoxItemListener = new TypesBoxItemListener<G, A, R>(this, gameObject, type, typeComboBox, archetypeType); - typeComboBox.addItemListener(typesBoxItemListener); + typeComboBox.addItemListener(new TypesBoxItemListener(selection)); return typeComboBox; } @@ -899,13 +896,11 @@ /** * Constructs the upper left part of the attribute dialog, containing name, * type, archetype name and face. - * @param type the initially selected type - * @param archetypeType the archetype type to display * @return a <code>JScrollPane</code> with the upper left part of the dialog * window */ @NotNull - private JComponent buildHeader(final int type, @NotNull final ArchetypeType archetypeType) { + private JComponent buildHeader() { final JComponent header = new JPanel(new GridBagLayout()); // the final thing, in a panel final GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.BOTH; @@ -946,7 +941,7 @@ nameTextField.setEditable(false); header.add(nameTextField, gbc); gbc.gridy++; - header.add(buildTypesBox(type, archetypeType), gbc); // build type-selection box + header.add(buildTypesBox(), gbc); // build type-selection box gbc.gridy++; final JTextComponent archetypeTextField = new JTextField(archetype.getArchetypeName(), 16); archetypeTextField.setEditable(false); @@ -961,7 +956,6 @@ */ public final void buildAttribute() { tabbedPane.removeAll(); - final ArchetypeType archetypeType = typesBoxItemListener.getArchetypeType(); int sectionId = 0; for (final ArchetypeAttributeSection archetypeAttributeSection : archetypeType) { final Component panel = makeAttributePanel(archetypeAttributeSection); @@ -1091,7 +1085,6 @@ */ @ActionMethod public void attribHelp() { - final ArchetypeType archetypeType = typesBoxItemListener.getArchetypeType(); final String helpText = ACTION_BUILDER.format("arcDoc.htmlText", archetypeType.getTypeName(), archetypeType.getDescription(), archetypeType.getUse()); new Help(/* XXX */ parent, helpText).setVisible(true); } @@ -1198,7 +1191,7 @@ } // Also write all the 'fixed' attributes into the archetype text - for (final ArchetypeAttributeSection archetypeAttributeSection : typesBoxItemListener.getArchetypeType()) { + for (final ArchetypeAttributeSection archetypeAttributeSection : archetypeType) { for (final ArchetypeAttribute archetypeAttribute : archetypeAttributeSection) { // ### TODO: for changed types, copy fixed attributes over default arches ### if (archetypeAttribute instanceof ArchetypeAttributeFixed) { @@ -1382,4 +1375,82 @@ return comboBox; } + /** + * ItemListener for the type-selection box on the attribute-dialog. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @author Andreas Kirschbaum + */ + private class TypesBoxItemListener implements ItemListener { + + /** + * The latest deselected item. + */ + @Nullable + private ArchetypeType deselected; + + /** + * While <code>true</code>, this listener ignores all events. + */ + private boolean ignoreEvent; + + /** + * The position of this type in the type list. This differs from the + * GameObject if the type is undefined. + * @serial + */ + private int type; + + /** + * Creates a new instance. + * @param type the initially selected type + */ + private TypesBoxItemListener(final int type) { + this.type = type; + ignoreEvent = false; + } + + /** + * {@inheritDoc} + */ + @Override + public void itemStateChanged(@NotNull final ItemEvent e) { + if (ignoreEvent) { + return; + } + + if (e.getStateChange() == ItemEvent.DESELECTED) { + deselected = (ArchetypeType) e.getItem(); + } else if (e.getStateChange() == ItemEvent.SELECTED && !e.getItem().equals(deselected)) { + final ArchetypeType newType = (ArchetypeType) e.getItem(); + + final JComboBox typeComboBox = (JComboBox) e.getSource(); + + typeComboBox.hidePopup(); + + if (deselected == null) { + deselected = archetypeType; + } + if (JOptionPane.showConfirmDialog(GameObjectAttributesDialog.this, "Do you really want to change the type of this\n" + "object from \"" + deselected.getTypeName() + "\" to \"" + newType.getTypeName() + "\"?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE) == JOptionPane.YES_OPTION) { + archetypeType = newType; + type = typeComboBox.getSelectedIndex(); + + final MapModel<G, A, R> mapModel = gameObject.getMapSquare().getMapModel(); + mapModel.beginTransaction("change type to " + newType.getTypeName()); + try { + gameObject.setAttributeInt(BaseObject.TYPE, newType.getTypeNo()); + } finally { + mapModel.endTransaction(); + } + + buildAttribute(); + } else { + ignoreEvent = true; + typeComboBox.setSelectedIndex(type); + ignoreEvent = false; + } + } + } + + } + } Deleted: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/TypesBoxItemListener.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/TypesBoxItemListener.java 2013-07-14 19:41:03 UTC (rev 9337) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/TypesBoxItemListener.java 2013-07-14 20:26:40 UTC (rev 9338) @@ -1,152 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2011 The Gridarta Developers. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package net.sf.gridarta.gui.dialog.gameobjectattributes; - -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import javax.swing.JComboBox; -import javax.swing.JOptionPane; -import net.sf.gridarta.model.archetype.Archetype; -import net.sf.gridarta.model.archetypetype.ArchetypeType; -import net.sf.gridarta.model.baseobject.BaseObject; -import net.sf.gridarta.model.gameobject.GameObject; -import net.sf.gridarta.model.maparchobject.MapArchObject; -import net.sf.gridarta.model.mapmodel.MapModel; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * ItemListener for the type-selection box on the attribute-dialog. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - * @author Andreas Kirschbaum - */ -public class TypesBoxItemListener<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements ItemListener { - - /** - * The attribute dialog main frame. - */ - @NotNull - private final GameObjectAttributesDialog<G, A, R> gameObjectAttributesDialog; - - /** - * The game object which has the error to be added. - */ - @NotNull - private final GameObject<G, A, R> gameObject; - - /** - * The selection box for the type. - */ - @NotNull - private final JComboBox typeComboBox; - - /** - * Reference to the type data. - * @serial - */ - @NotNull - private ArchetypeType archetypeType; - - /** - * The latest deselected item. - */ - @Nullable - private ArchetypeType deselected; - - /** - * While <code>true</code>, this listener ignores all events. - */ - private boolean ignoreEvent; - - /** - * The position of this type in the type list. This differs from the - * GameObject if the type is undefined. - * @serial - */ - private int type; - - /** - * Creates a new instance. - * @param frameNew the attribute dialog main frame - * @param gameObject the game object which has the error to be added - * @param type the initially selected type - * @param typeComboBox the selection box for the type - * @param archetypeType the references to the data type - */ - public TypesBoxItemListener(@NotNull final GameObjectAttributesDialog<G, A, R> frameNew, @NotNull final GameObject<G, A, R> gameObject, final int type, @NotNull final JComboBox typeComboBox, @NotNull final ArchetypeType archetypeType) { - gameObjectAttributesDialog = frameNew; - this.gameObject = gameObject; - this.type = type; - this.typeComboBox = typeComboBox; - this.archetypeType = archetypeType; - ignoreEvent = false; - } - - /** - * {@inheritDoc} - */ - @Override - public void itemStateChanged(@NotNull final ItemEvent e) { - if (ignoreEvent) { - return; - } - - if (e.getStateChange() == ItemEvent.DESELECTED) { - deselected = (ArchetypeType) e.getItem(); - } else if (e.getStateChange() == ItemEvent.SELECTED && !e.getItem().equals(deselected)) { - final ArchetypeType newType = (ArchetypeType) e.getItem(); - - typeComboBox.hidePopup(); - - if (deselected == null) { - deselected = archetypeType; - } - if (JOptionPane.showConfirmDialog(gameObjectAttributesDialog, "Do you really want to change the type of this\n" + "object from \"" + deselected.getTypeName() + "\" to \"" + newType.getTypeName() + "\"?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE) == JOptionPane.YES_OPTION) { - archetypeType = newType; - - final MapModel<G, A, R> mapModel = gameObject.getMapSquare().getMapModel(); - mapModel.beginTransaction("change type to " + newType.getTypeName()); - try { - gameObject.setAttributeInt(BaseObject.TYPE, newType.getTypeNo()); - } finally { - mapModel.endTransaction(); - } - - type = typeComboBox.getSelectedIndex(); - - gameObjectAttributesDialog.buildAttribute(); - } else { - ignoreEvent = true; - typeComboBox.setSelectedIndex(type); - ignoreEvent = false; - } - } - } - - /** - * Returns a reference to the type data. - * @return the reference - */ - @NotNull - public ArchetypeType getArchetypeType() { - return archetypeType; - } - -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-07-14 19:41:06
|
Revision: 9337 http://sourceforge.net/p/gridarta/code/9337 Author: akirschbaum Date: 2013-07-14 19:41:03 +0000 (Sun, 14 Jul 2013) Log Message: ----------- Simplify code. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/TypesBoxItemListener.java Added Paths: ----------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/ArchetypeTypeListCellRenderer.java Added: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/ArchetypeTypeListCellRenderer.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/ArchetypeTypeListCellRenderer.java (rev 0) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/ArchetypeTypeListCellRenderer.java 2013-07-14 19:41:03 UTC (rev 9337) @@ -0,0 +1,50 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2011 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.gui.dialog.gameobjectattributes; + +import java.awt.Component; +import javax.swing.DefaultListCellRenderer; +import javax.swing.JList; +import net.sf.gridarta.model.archetypetype.ArchetypeType; + +/** + * A {@link javax.swing.ListCellRenderer ListCellRenderer} implementation that + * displays {@link ArchetypeType ArchetypeTypes}. + */ +public class ArchetypeTypeListCellRenderer extends DefaultListCellRenderer { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /* This is the only method defined by ListCellRenderer. We just + * reconfigure the label each time we're called. + */ + + @Override + public Component getListCellRendererComponent(final JList list, final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + final ArchetypeType archetypeType = (ArchetypeType) value; + setText(archetypeType.getTypeName()); + return this; + } + +} Property changes on: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/ArchetypeTypeListCellRenderer.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java 2013-07-14 19:25:30 UTC (rev 9336) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java 2013-07-14 19:41:03 UTC (rev 9337) @@ -861,26 +861,27 @@ */ @NotNull private Component buildTypesBox(final int type, @NotNull final ArchetypeType archetypeType) { - final String[] nameList = new String[archetypeTypeSet.getArchetypeTypeCount()]; + final ArchetypeType[] model = new ArchetypeType[archetypeTypeSet.getArchetypeTypeCount()]; // read all type names int i = 0; for (final ArchetypeType tmp : archetypeTypeSet) { - nameList[i++] = " " + tmp.getTypeName(); + model[i++] = tmp; } // the active type appears selected in the box final int selection = type; - final JComboBox typeComboBox = new JComboBox(nameList); + final JComboBox typeComboBox = new JComboBox(model); typeComboBox.setSelectedIndex(selection); + typeComboBox.setRenderer(new ArchetypeTypeListCellRenderer()); //typeComboBox.setKeySelectionManager(new StringKeyManager(typeComboBox)); typeComboBox.setName("Types"); // the listener: - typesBoxItemListener = new TypesBoxItemListener<G, A, R>(this, gameObject, type, archetypeTypeSet, typeComboBox, archetypeType); + typesBoxItemListener = new TypesBoxItemListener<G, A, R>(this, gameObject, type, typeComboBox, archetypeType); typeComboBox.addItemListener(typesBoxItemListener); return typeComboBox; } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/TypesBoxItemListener.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/TypesBoxItemListener.java 2013-07-14 19:25:30 UTC (rev 9336) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/TypesBoxItemListener.java 2013-07-14 19:41:03 UTC (rev 9337) @@ -25,7 +25,6 @@ import javax.swing.JOptionPane; import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.archetypetype.ArchetypeType; -import net.sf.gridarta.model.archetypetype.ArchetypeTypeSet; import net.sf.gridarta.model.baseobject.BaseObject; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.maparchobject.MapArchObject; @@ -53,12 +52,6 @@ private final GameObject<G, A, R> gameObject; /** - * The {@link ArchetypeTypeSet} to display. - */ - @NotNull - private final ArchetypeTypeSet archetypeTypeSet; - - /** * The selection box for the type. */ @NotNull @@ -75,7 +68,7 @@ * The latest deselected item. */ @Nullable - private String deselected; + private ArchetypeType deselected; /** * While <code>true</code>, this listener ignores all events. @@ -94,15 +87,13 @@ * @param frameNew the attribute dialog main frame * @param gameObject the game object which has the error to be added * @param type the initially selected type - * @param archetypeTypeSet the archetype type set to display * @param typeComboBox the selection box for the type * @param archetypeType the references to the data type */ - public TypesBoxItemListener(@NotNull final GameObjectAttributesDialog<G, A, R> frameNew, @NotNull final GameObject<G, A, R> gameObject, final int type, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final JComboBox typeComboBox, @NotNull final ArchetypeType archetypeType) { + public TypesBoxItemListener(@NotNull final GameObjectAttributesDialog<G, A, R> frameNew, @NotNull final GameObject<G, A, R> gameObject, final int type, @NotNull final JComboBox typeComboBox, @NotNull final ArchetypeType archetypeType) { gameObjectAttributesDialog = frameNew; this.gameObject = gameObject; this.type = type; - this.archetypeTypeSet = archetypeTypeSet; this.typeComboBox = typeComboBox; this.archetypeType = archetypeType; ignoreEvent = false; @@ -118,16 +109,16 @@ } if (e.getStateChange() == ItemEvent.DESELECTED) { - deselected = ((String) e.getItem()).trim(); + deselected = (ArchetypeType) e.getItem(); } else if (e.getStateChange() == ItemEvent.SELECTED && !e.getItem().equals(deselected)) { - final ArchetypeType newType = archetypeTypeSet.getArchetypeTypeByName((String) e.getItem()); + final ArchetypeType newType = (ArchetypeType) e.getItem(); typeComboBox.hidePopup(); if (deselected == null) { - deselected = archetypeType.getTypeName(); + deselected = archetypeType; } - if (JOptionPane.showConfirmDialog(gameObjectAttributesDialog, "Do you really want to change the type of this\n" + "object from \"" + deselected + "\" to \"" + newType.getTypeName() + "\"?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE) == JOptionPane.YES_OPTION) { + if (JOptionPane.showConfirmDialog(gameObjectAttributesDialog, "Do you really want to change the type of this\n" + "object from \"" + deselected.getTypeName() + "\" to \"" + newType.getTypeName() + "\"?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE) == JOptionPane.YES_OPTION) { archetypeType = newType; final MapModel<G, A, R> mapModel = gameObject.getMapSquare().getMapModel(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-07-14 19:25:34
|
Revision: 9336 http://sourceforge.net/p/gridarta/code/9336 Author: akirschbaum Date: 2013-07-14 19:25:30 +0000 (Sun, 14 Jul 2013) Log Message: ----------- Remove unused code. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/TypesBoxItemListener.java Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java 2013-07-14 19:02:55 UTC (rev 9335) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java 2013-07-14 19:25:30 UTC (rev 9336) @@ -880,7 +880,7 @@ typeComboBox.setName("Types"); // the listener: - typesBoxItemListener = new TypesBoxItemListener<G, A, R>(this, gameObject, type, archetypeTypeSet, dialogAttributes, typeComboBox, archetypeType); + typesBoxItemListener = new TypesBoxItemListener<G, A, R>(this, gameObject, type, archetypeTypeSet, typeComboBox, archetypeType); typeComboBox.addItemListener(typesBoxItemListener); return typeComboBox; } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/TypesBoxItemListener.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/TypesBoxItemListener.java 2013-07-14 19:02:55 UTC (rev 9335) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/TypesBoxItemListener.java 2013-07-14 19:25:30 UTC (rev 9336) @@ -21,8 +21,6 @@ import java.awt.event.ItemEvent; import java.awt.event.ItemListener; -import java.util.ArrayList; -import java.util.Collection; import javax.swing.JComboBox; import javax.swing.JOptionPane; import net.sf.gridarta.model.archetype.Archetype; @@ -61,12 +59,6 @@ private final ArchetypeTypeSet archetypeTypeSet; /** - * The {@link DialogAttribute DialogAttributes} to update. - */ - @NotNull - private final Collection<DialogAttribute<G, A, R, ?>> dialogAttributes; - - /** * The selection box for the type. */ @NotNull @@ -103,16 +95,14 @@ * @param gameObject the game object which has the error to be added * @param type the initially selected type * @param archetypeTypeSet the archetype type set to display - * @param dialogAttributes the dialog attributes to update * @param typeComboBox the selection box for the type * @param archetypeType the references to the data type */ - public TypesBoxItemListener(@NotNull final GameObjectAttributesDialog<G, A, R> frameNew, @NotNull final GameObject<G, A, R> gameObject, final int type, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final Collection<DialogAttribute<G, A, R, ?>> dialogAttributes, @NotNull final JComboBox typeComboBox, @NotNull final ArchetypeType archetypeType) { + public TypesBoxItemListener(@NotNull final GameObjectAttributesDialog<G, A, R> frameNew, @NotNull final GameObject<G, A, R> gameObject, final int type, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final JComboBox typeComboBox, @NotNull final ArchetypeType archetypeType) { gameObjectAttributesDialog = frameNew; this.gameObject = gameObject; this.type = type; this.archetypeTypeSet = archetypeTypeSet; - this.dialogAttributes = new ArrayList<DialogAttribute<G, A, R, ?>>(dialogAttributes); this.typeComboBox = typeComboBox; this.archetypeType = archetypeType; ignoreEvent = false; @@ -147,7 +137,6 @@ } finally { mapModel.endTransaction(); } - dialogAttributes.clear(); type = typeComboBox.getSelectedIndex(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |