/** Loads the icons for the tile patterns list. */ private void loadIcons() { tilePatternIcons.clear(); for (TilePattern tilePattern : tileset.getTilePatterns()) { tilePatternIcons.add(new TilePatternIcon(tilePattern, tileset)); } }
/** Closes this editor without confirmation. */ @Override public void close() { tileset.deleteObservers(); // Notify the children views. tilePatternsView.setTileset(null); tilesetImageView.setTileset(null); }
/** Saves the current resource. */ public void save() { try { tileset.save(); } catch (QuestEditorException ex) { GuiTools.errorDialog("Could not save the tileset: " + ex.getMessage()); } }
/** * This function is called when the user wants to close the current tileset. If the tileset is not * saved, we propose to save it. * * @return false if the user cancelled */ public boolean checkCurrentFileSaved() { boolean result = true; if (tileset != null && !tileset.isSaved()) { int answer = JOptionPane.showConfirmDialog( this, "The tileset has been modified. Do you want to save it?", "Save the modifications", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE); if (answer == JOptionPane.YES_OPTION) { save(); } else if (answer == JOptionPane.CANCEL_OPTION) { result = false; } } return result; }
/** * Sets the tileset observed. * * @param tileset the current tileset, or null if there is no tileset */ public void setTileset(Tileset tileset) { if (tileset != this.tileset) { if (this.tileset != null) { this.tileset.deleteObserver(tilePatternsListModel); } this.tileset = tileset; tilesetPropertiesView.setTileset(tileset); tilePatternView.setTileset(tileset); if (tileset != null) { tileset.addObserver(tilePatternsListModel); loadIcons(); tilePatternsListModel.update(tileset, null); } else { repaint(); } } }
/** * Give the name of the resource opened in the editor * * @return the name of the map */ public String getTitle() { return tileset == null ? "" : "Tileset " + tileset.getName(); }