Go to the documentation of this file.
20 package net.sf.gridarta.gui.dialog.replace;
22 import java.awt.Component;
23 import java.awt.Container;
24 import java.awt.FlowLayout;
25 import java.awt.event.ItemEvent;
26 import java.awt.event.ItemListener;
27 import java.util.ArrayList;
28 import java.util.List;
29 import javax.swing.BorderFactory;
30 import javax.swing.Box;
31 import javax.swing.BoxLayout;
32 import javax.swing.Icon;
33 import javax.swing.JButton;
34 import javax.swing.JComboBox;
35 import javax.swing.JDialog;
36 import javax.swing.JLabel;
37 import javax.swing.JOptionPane;
38 import javax.swing.JPanel;
39 import javax.swing.JTextField;
40 import javax.swing.WindowConstants;
41 import javax.swing.text.JTextComponent;
57 import net.
sf.japi.swing.action.ActionBuilder;
58 import net.
sf.japi.swing.action.ActionBuilderFactory;
59 import net.
sf.japi.swing.action.ActionMethod;
60 import org.jetbrains.annotations.NotNull;
61 import org.jetbrains.annotations.Nullable;
79 private static final ActionBuilder
ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder(
"net.sf.gridarta");
210 public void pickmapActiveChanged(
final boolean pickmapActive) {
228 public void facesReloaded() {
243 public ReplaceDialog(@NotNull
final Component
parent, @NotNull
final CopyBuffer<G, A, R> copyBuffer, @NotNull
final ObjectChooser<G, A, R> objectChooser, @NotNull
final FaceObjectProviders faceObjectProviders, @NotNull
final InsertionModeSet<G, A, R> insertionModeSet) {
247 dialog.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
291 final JPanel mainPanel =
new JPanel();
292 mainPanel.setLayout(
new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
293 mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 2, 5));
296 final Container line1 =
new JPanel(
new FlowLayout(FlowLayout.LEFT));
298 line1.add(Box.createVerticalStrut(3));
303 line1.add(Box.createVerticalStrut(3));
306 mainPanel.add(line1);
309 final Container line2 =
new JPanel(
new FlowLayout(FlowLayout.LEFT));
311 line2.add(Box.createVerticalStrut(5));
317 line2.add(Box.createVerticalStrut(5));
322 mainPanel.add(line2);
325 final Container line3 =
new JPanel(
new FlowLayout(FlowLayout.LEFT));
327 line3.add(Box.createVerticalStrut(5));
346 line3.add(Box.createVerticalStrut(5));
349 mainPanel.add(line3);
352 final Container line4 =
new JPanel(
new FlowLayout(FlowLayout.LEFT));
354 line4.add(Box.createVerticalStrut(5));
359 mainPanel.add(line4);
361 final JButton okButton =
new JButton(
ACTION_BUILDER.createAction(
false,
"replaceOk",
this));
362 final JButton applyButton =
new JButton(
ACTION_BUILDER.createAction(
false,
"replaceApply",
this));
363 final JButton cancelButton =
new JButton(
ACTION_BUILDER.createAction(
false,
"replaceCancel",
this));
365 setMessage(mainPanel);
366 setOptions(
new Object[] { okButton, applyButton, cancelButton });
367 dialog.getRootPane().setDefaultButton(okButton);
385 if (newArch ==
null) {
390 final Icon oldIcon =
iconLabel.getIcon();
393 rfArchName.setText(
" " + newArch.getBestName());
397 if (alwaysPack || (oldIcon ==
null &&
iconLabel.getIcon() !=
null) || (oldIcon !=
null &&
iconLabel.getIcon() ==
null) || (oldIcon !=
iconLabel.getIcon() && oldIcon !=
null && oldIcon.getIconHeight() !=
iconLabel.getIcon().getIconHeight())) {
410 private static <T> List<T>
newList(@NotNull
final T element) {
411 final List<T>
list =
new ArrayList<>(1);
424 if (e.getStateChange() == ItemEvent.SELECTED &&
lastSelectedIndex != selectedIndex) {
426 switch (selectedIndex) {
505 final int replaceDensity;
508 }
catch (
final NumberFormatException ignored) {
512 if (replaceDensity < 1 || replaceDensity > 100) {
517 @Nullable
final List<? extends BaseObject<G, A, R, ?>> replaceList;
536 if (replaceCount <= 0) {
541 if (replaceCount == 1) {
544 ACTION_BUILDER.showMessageDialog(
this,
"replacedMany", replaceCount);
final InsertionModeSet< G, A, R > insertionModeSet
public< G extends GameObject< G, A, R >, A extends MapArchObject< A >, R extends Archetype< G, A, R > > ImageIcon getFace(@NotNull final BaseObject< G, A, R, ?> baseObject)
List<? extends BaseObject< G, A, R, ?> > getSelections()
ReplaceDialog(@NotNull final Component parent, @NotNull final CopyBuffer< G, A, R > copyBuffer, @NotNull final ObjectChooser< G, A, R > objectChooser, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final InsertionModeSet< G, A, R > insertionModeSet)
void dispose(@NotNull final MapView< G, A, R > mapView)
void itemStateChanged(@NotNull final ItemEvent e)
BaseObject< G, A, R, ?> replaceArch
Rectangle getSelectedRec()
List< G > getAllGameObjects()
static final int REPLACE_WITH_COPY_BUFFER
static< T > List< T > newList(@NotNull final T element)
JTextComponent replaceInput1
final CopyBuffer< G, A, R > copyBuffer
static final int REPLACE_ON_SELECTION
static< G extends GameObject< G, A, R > A extends R extends Archetype< G, A, R > int replace(@NotNull final MatchCriteria< G, A, R > matchCriteria, final boolean entireMap, final boolean deleteOnly, final int replaceDensity, @NotNull final MapView< G, A, R > mapView, @NotNull final InsertionModeSet< G, A, R > insertionModeSet, @Nullable final List<? extends BaseObject< G, A, R, ?>> replaceList)
List< G > replaceCopyBuffer
static final long serialVersionUID
void display(@NotNull final MapView< G, A, R > mapView)
This document describes some hints and requirements for general development on the CrossfireEditor If you plan to make changes to the editor code or setup please read the following and keep it in derived from a basic editor application called Gridder by Pasi Ker�nen so please communicate with best through the cf devel mailing list
JComboBox< String > replaceCriteria
MapControl< G, A, R > getMapControl()
static final int REPLACE_ON_MAP
List<? extends BaseObject< G, A, R, ?> > replacePickmap
static JLabel newLabel(@NotNull final ActionBuilder actionBuilder, @NotNull final String key)
final FaceObjectProvidersListener faceObjectProvidersListener
JComboBox< String > replaceWithBox
final ObjectChooser< G, A, R > objectChooser
MapView< G, A, R > mapView
List< MapSquare< G, A, R > > getSelectedSquares()
BaseObject< G, A, R, ?> getCursorSelection()
final FaceObjectProviders faceObjectProviders
static final ActionBuilder ACTION_BUILDER
JTextComponent replaceDensityInput
JComboBox< String > replaceEntireBox
static String getString(@NotNull final ActionBuilder actionBuilder, @NotNull final String key, @NotNull final String defaultValue)
void updateArchSelection(@Nullable final BaseObject< G, A, R, ?> newArch, final boolean alwaysPack)
BaseObject< G, A, R, ?> getSelection()
static final int REPLACE_WITH_OBJECT_CHOOSER
static final int REPLACE_WITH_NOTHING
static final int REPLACE_WITH_PICKMAP
void addObjectChooserListener(@NotNull ObjectChooserListener< G, A, R > listener)
MapModel< G, A, R > getMapModel()
final ObjectChooserListener< G, A, R > objectChooserListener
void addFaceObjectProvidersListener(@NotNull final FaceObjectProvidersListener listener)