// editor,
// Resources.getString("action.layer.mergeall.name"), Resources.getString("action.layer.mergeall.tooltip"));
// }
protected void doPerformAction() {
Map map = editor.getMap();
boolean result = MessageDialog.open(MessageDialog.QUESTION_WITH_CANCEL,editor.getEditorSite().getShell(),"Merge Tiles?",
"Do you wish to merge tile images, and create a new tile set?",SWT.NONE);
// int ret = JOptionPane.showConfirmDialog(null,
// "Do you wish to merge tile images, and create a new tile set?",
// "Merge Tiles?", JOptionPane.YES_NO_CANCEL_OPTION);
if (result) {
TileMergeHelper tmh = new TileMergeHelper(map);
int len = map.getTotalLayers();
//TODO: Add a dialog option: "Yes, visible only"
TileLayer newLayer = tmh.merge(0, len, true);
map.removeAllLayers();
map.addLayer(newLayer);
newLayer.setName("Merged Layer");
map.addTileset(tmh.getSet());
editor.setCurrentLayer(0);
}
else /*if (ret == JOptionPane.NO_OPTION)*/ {
while (map.getTotalLayers() > 1) {
map.mergeLayerDown(editor.getCurrentLayerIndex());
}
editor.setCurrentLayer(0);
}
}