118 for (JButton button : preprocessButtons.values()) {
119 button.setEnabled(
false);
121 for (JButton button : postprocessButtons.values()) {
122 button.setEnabled(
false);
125 JButton btnChoose =
new JButton(
"Choose");
126 btnChoose.addActionListener(e -> {
127 JFileChooser chooser =
new JFileChooser();
129 int result = chooser.showOpenDialog(null);
130 if (result == JFileChooser.APPROVE_OPTION) {
131 File f = chooser.getSelectedFile();
141 this.
btnEdit =
new JButton(
"Edit…");
142 this.
btnEdit.setEnabled(
false);
143 this.
btnEdit.addActionListener(e -> {
156 txtRam =
new JTextField();
160 String javaVersion = System.getProperty(
"java.version")
162 + System.getProperty(
"java.vm.vendor")
164 + System.getProperty(
"java.vm.info")
166 + System.getProperty(
"sun.arch.data.model")
175 if (System.getProperty(
"os.name").startsWith(
"Win")) {
176 jvmLocation = System.getProperties().getProperty(
"java.home")
182 jvmLocation = System.getProperties().getProperty(
"java.home")
212 JButton btnOpen =
new JButton(
"Open");
213 btnOpen.addActionListener(e -> {
217 Desktop.getDesktop().open(f);
218 }
catch (IOException ex) {
219 ex.printStackTrace();
224 JButton btnDelete =
new JButton(
"Delete");
225 btnDelete.addActionListener(e -> {
227 int i = JOptionPane.showOptionDialog(
Gui.this,
228 "Do you really want to delete the output directory? This action cannot be undone.",
229 "Delete Output Directory", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null,
230 new String[] {
"Cancel",
"Delete" },
"Cancel");
233 IOUtils.deleteDirectoryRecursively(
new File(
txtOutput.getText()).toPath());
235 ex.printStackTrace();
241 JTabbedPane tabbedPane =
new JTabbedPane(JTabbedPane.TOP);
244 GroupLayout groupLayout =
new GroupLayout(getContentPane());
246 final GroupLayout.SequentialGroup prebuttonsSequentialGroup = groupLayout.createSequentialGroup();
247 final GroupLayout.ParallelGroup prebuttonsParallelGroup = groupLayout.createParallelGroup();
248 for (JButton button : preprocessButtons.values()) {
249 prebuttonsSequentialGroup.addComponent(button);
250 prebuttonsParallelGroup.addComponent(button);
253 final GroupLayout.SequentialGroup postbuttonsSequentialGroup = groupLayout.createSequentialGroup();
254 final GroupLayout.ParallelGroup postbuttonsParallelGroup = groupLayout.createParallelGroup();
255 for (JButton button : postprocessButtons.values()) {
256 postbuttonsSequentialGroup.addComponent(button);
257 postbuttonsParallelGroup.addComponent(button);
260 groupLayout.setHorizontalGroup(groupLayout.createParallelGroup(Alignment.TRAILING)
261 .addGroup(Alignment.LEADING, groupLayout.createSequentialGroup()
263 .addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
265 .addComponent(tabbedPane, GroupLayout.DEFAULT_SIZE, 729, Short.MAX_VALUE)
267 .addGroup(prebuttonsSequentialGroup)
268 .addGroup(postbuttonsSequentialGroup)
269 .addGroup(groupLayout.createSequentialGroup()
270 .addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
280 .addPreferredGap(ComponentPlacement.RELATED)
281 .addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
283 .addGroup(groupLayout.createSequentialGroup()
284 .addComponent(
txtRam, GroupLayout.PREFERRED_SIZE, 69,
285 GroupLayout.PREFERRED_SIZE)
286 .addPreferredGap(ComponentPlacement.RELATED)
287 .addComponent(
lblMb))
294 .addGroup(groupLayout.createSequentialGroup()
297 .addPreferredGap(ComponentPlacement.RELATED)
298 .addComponent(btnChoose)
299 .addPreferredGap(ComponentPlacement.RELATED)
301 .addComponent(
progressBar, GroupLayout.DEFAULT_SIZE, 285,
303 .addGroup(groupLayout.createSequentialGroup()
304 .addComponent(
txtOutput, GroupLayout.DEFAULT_SIZE, 112,
306 .addPreferredGap(ComponentPlacement.RELATED)
307 .addComponent(btnOpen)
308 .addPreferredGap(ComponentPlacement.RELATED)
309 .addComponent(btnDelete)))))
310 .addContainerGap()));
311 groupLayout.setVerticalGroup(groupLayout.createParallelGroup(Alignment.LEADING)
312 .addGroup(groupLayout.createSequentialGroup()
314 .addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
316 .addComponent(
txtMatsimversion, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
317 GroupLayout.PREFERRED_SIZE))
318 .addPreferredGap(ComponentPlacement.RELATED)
319 .addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
321 .addComponent(
txtJvmversion, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
322 GroupLayout.PREFERRED_SIZE))
323 .addPreferredGap(ComponentPlacement.RELATED)
324 .addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
326 .addComponent(
txtJvmlocation, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
327 GroupLayout.PREFERRED_SIZE))
328 .addPreferredGap(ComponentPlacement.RELATED)
329 .addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
331 .addComponent(
txtConfigfilename, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
332 GroupLayout.PREFERRED_SIZE)
333 .addComponent(btnChoose)
335 .addPreferredGap(ComponentPlacement.RELATED)
337 .addPreferredGap(ComponentPlacement.RELATED)
338 .addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
340 .addComponent(
txtOutput, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
341 GroupLayout.PREFERRED_SIZE)
342 .addComponent(btnDelete)
343 .addComponent(btnOpen))
344 .addPreferredGap(ComponentPlacement.RELATED)
345 .addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
347 .addComponent(
txtRam, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
348 GroupLayout.PREFERRED_SIZE)
349 .addComponent(
lblMb))
350 .addPreferredGap(ComponentPlacement.UNRELATED)
351 .addGroup(prebuttonsParallelGroup)
352 .addPreferredGap(ComponentPlacement.UNRELATED)
353 .addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
355 .addComponent(
progressBar, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
356 GroupLayout.PREFERRED_SIZE))
357 .addPreferredGap(ComponentPlacement.UNRELATED)
358 .addGroup(postbuttonsParallelGroup)
359 .addPreferredGap(ComponentPlacement.RELATED)
360 .addComponent(tabbedPane, GroupLayout.DEFAULT_SIZE, 180, Short.MAX_VALUE)
361 .addContainerGap()));
368 tabbedPane.addTab(
"Output", null,
scrollPane, null);
370 JScrollPane scrollPane_1 =
new JScrollPane();
371 tabbedPane.addTab(
"Warnings & Errors", null, scrollPane_1, null);
379 getContentPane().setLayout(groupLayout);
400 SaveFileSaver chooser =
new SaveFileSaver();
401 chooser.setSelectedFile(
new File(
"defaultConfig.xml"));
402 int saveResult = chooser.showSaveDialog(null);
403 if (saveResult == JFileChooser.APPROVE_OPTION) {
404 File destFile = chooser.getSelectedFile();
405 Config config = ConfigUtils.createConfig();
406 new ConfigWriter(config).write(destFile.getAbsolutePath());
420 JMenuItem mntmTransitValidator =
new JMenuItem(
"Validate TransitSchedule…");
421 this.
mnTools.add(mntmTransitValidator);
422 mntmTransitValidator.addActionListener(e -> {
427 if (!configFilename.isEmpty()) {
428 Config config = ConfigUtils.createConfig();
430 ConfigUtils.loadConfig(config, configFilename);
static final JLabel lblConfigurationFile
static final JLabel lblFilepaths
static final JLabel lblOutputDirectory
void loadFromConfig(Config config, File configDirectory)
JMenuItem mntmCreateDefaultConfig
JTextField txtConfigfilename
void loadConfigFile(final File configFile)
PopulationSampler popSampler
JMenuItem mntmCreateSamplePopulation
JMenuItem mntmUncompressFile
volatile ExeRunner exeRunner
ScheduleValidatorWindow transitValidator
static final JLabel lblMemory
static final JLabel lblJavaLocation
static final JLabel lblYouAreUsingMATSimVersion
JTextField txtMatsimversion
Gui(final String title, final Class<?> mainClass)
JMenuItem mntmCompressFile
static final JLabel lblYouAreUsingJavaVersion
JTextField txtJvmlocation
static final JLabel lblMb