Search in sources :

Example 6 with IEditableProperty

use of games.strategy.engine.data.properties.IEditableProperty in project triplea by triplea-game.

the class GameDataExporter method propertyList.

@SuppressWarnings("unchecked")
private void propertyList(final GameData data) {
    // TODO: Unchecked Reflection
    xmlfile.append("    <propertyList>\n");
    final GameProperties gameProperties = data.getProperties();
    try {
        // TODO: unchecked reflection below.. this is bad stuff.. find ways to remove
        final Field conPropField = GameProperties.class.getDeclaredField(GameProperties.CONSTANT_PROPERTIES_FIELD_NAME);
        conPropField.setAccessible(true);
        final Field edPropField = GameProperties.class.getDeclaredField(GameProperties.EDITABLE_PROPERTIES_FIELD_NAME);
        edPropField.setAccessible(true);
        printConstantProperties((Map<String, Object>) conPropField.get(gameProperties));
        printEditableProperties((Map<String, IEditableProperty>) edPropField.get(gameProperties));
    } catch (final NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
        ClientLogger.logError("An Error occured whilst trying trying to setup the Property List", e);
    }
    xmlfile.append("    </propertyList>\n");
}
Also used : GameProperties(games.strategy.engine.data.properties.GameProperties) Field(java.lang.reflect.Field) IEditableProperty(games.strategy.engine.data.properties.IEditableProperty)

Example 7 with IEditableProperty

use of games.strategy.engine.data.properties.IEditableProperty in project triplea by triplea-game.

the class MapOptionsPanel method build.

static JPanel build(final GameData gameData, final StagingScreen screen) {
    final GameProperties properties = gameData.getProperties();
    final List<IEditableProperty> props = properties.getEditableProperties();
    final JPanelBuilder panelBuilder = JPanelBuilder.builder().gridBagLayout(2).add(new JLabel("<html><h2>Map Options</h2></html>")).add(new JPanel());
    props.stream().filter(prop -> !prop.getName().contains("bid")).forEach(prop -> {
        panelBuilder.add(JLabelBuilder.builder().textWithMaxLength(prop.getName(), 25).tooltip(prop.getName()).build());
        panelBuilder.add(screen != StagingScreen.NETWORK_CLIENT ? prop.getEditorComponent() : prop.getEditorComponentDisabled());
    });
    return panelBuilder.build();
}
Also used : GameProperties(games.strategy.engine.data.properties.GameProperties) GameProperties(games.strategy.engine.data.properties.GameProperties) GameData(games.strategy.engine.data.GameData) List(java.util.List) JLabelBuilder(swinglib.JLabelBuilder) JLabel(javax.swing.JLabel) JPanelBuilder(swinglib.JPanelBuilder) JPanel(javax.swing.JPanel) IEditableProperty(games.strategy.engine.data.properties.IEditableProperty) JPanel(javax.swing.JPanel) JPanelBuilder(swinglib.JPanelBuilder) JLabel(javax.swing.JLabel) IEditableProperty(games.strategy.engine.data.properties.IEditableProperty)

Aggregations

IEditableProperty (games.strategy.engine.data.properties.IEditableProperty)7 PropertiesUi (games.strategy.engine.data.properties.PropertiesUi)3 ColorProperty (games.strategy.engine.data.properties.ColorProperty)2 GameProperties (games.strategy.engine.data.properties.GameProperties)2 NumberProperty (games.strategy.engine.data.properties.NumberProperty)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 JDialog (javax.swing.JDialog)2 JLabel (javax.swing.JLabel)2 JOptionPane (javax.swing.JOptionPane)2 JPanel (javax.swing.JPanel)2 JScrollPane (javax.swing.JScrollPane)2 GameData (games.strategy.engine.data.GameData)1 BooleanProperty (games.strategy.engine.data.properties.BooleanProperty)1 FileProperty (games.strategy.engine.data.properties.FileProperty)1 StringProperty (games.strategy.engine.data.properties.StringProperty)1 SwingAction (games.strategy.ui.SwingAction)1 BorderLayout (java.awt.BorderLayout)1 Color (java.awt.Color)1