Gridarta Editor
CollectArchesCommand.java
Go to the documentation of this file.
1 /*
2  * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games.
3  * Copyright (C) 2000-2023 The Gridarta Developers.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 package net.sf.gridarta.commands;
21 
22 import java.io.IOException;
24 import net.sf.japi.swing.misc.ConsoleProgress;
25 import org.apache.log4j.Category;
26 import org.apache.log4j.Logger;
27 import org.jetbrains.annotations.NotNull;
28 
36 public class CollectArchesCommand implements Command {
37 
41  @NotNull
42  private static final Category LOG = Logger.getLogger(CollectArchesCommand.class);
43 
47  @NotNull
49 
55  this.projectModel = projectModel;
56  }
57 
58  @Override
59  public int execute() {
61  LOG.fatal("Cannot collect resources");
62  return 1;
63  }
64  final Collector collector = new Collector(new ConsoleProgress(), projectModel.getResources(), projectModel.getProjectSettings().getCollectedDirectory());
65  collector.start();
66  try {
67  collector.waitUntilFinished();
68  } catch (final InterruptedException ignored) {
69  Thread.currentThread().interrupt();
70  return 1;
71  } catch (final IOException ex) {
72  LOG.error("I/O error during collection: " + ex);
73  return 1;
74  }
75  return 0;
76  }
77 
78 }
net.sf.gridarta.project.ProjectModel.getProjectSettings
ProjectSettings getProjectSettings()
Definition: ProjectModel.java:420
net.sf.gridarta.commands.CollectArchesCommand.CollectArchesCommand
CollectArchesCommand(@NotNull final ProjectModel<?, ?, ?> projectModel)
Creates a new instance.
Definition: CollectArchesCommand.java:54
net.sf.gridarta.commands.CollectArchesCommand.LOG
static final Category LOG
The Logger for printing log messages.
Definition: CollectArchesCommand.java:42
net.sf.gridarta
Base package of all Gridarta classes.
net.sf.gridarta.commands.CollectArchesCommand
Run archetype collection.
Definition: CollectArchesCommand.java:36
net.sf.gridarta.project.ProjectModel
Definition: ProjectModel.java:122
net.sf.gridarta.commands.Collector
A Collector is capable of iterating over a collection of {Collectables} and collecting them in a sepa...
Definition: Collector.java:35
net.sf.gridarta.commands.CollectArchesCommand.execute
int execute()
Executes the command.
Definition: CollectArchesCommand.java:59
net.sf
net.sf.gridarta.commands.Collector.waitUntilFinished
void waitUntilFinished()
Waits until collection has finished.
Definition: Collector.java:102
net
net.sf.gridarta.commands.Collector.start
void start()
Starts collecting.
Definition: Collector.java:86
net.sf.gridarta.model.resource.AbstractResources.canWriteCollected
boolean canWriteCollected()
Whether the resources can be written in collected form.
Definition: AbstractResources.java:119
net.sf.gridarta.project.ProjectModel.getResources
AbstractResources< G, A, R > getResources()
Definition: ProjectModel.java:475
net.sf.gridarta.commands.CollectArchesCommand.projectModel
final ProjectModel<?, ?, ?> projectModel
The project to collect.
Definition: CollectArchesCommand.java:48
net.sf.gridarta.model.settings.ProjectSettings.getCollectedDirectory
File getCollectedDirectory()
Returns the directory where collected archetypes are stored.
net.sf.gridarta.project
Definition: ProjectFactory.java:20
net.sf.gridarta.commands.Command
Interface for command-line commands.
Definition: Command.java:26