Commit 7267ca71 authored by Benedikt Zoennchen's avatar Benedikt Zoennchen

bug fix of issue #60

parent e2b2a85b
......@@ -40,7 +40,6 @@ public class ActionDeleteOutputDirectories extends AbstractAction {
e.printStackTrace();
logger.error(e.getLocalizedMessage());
}
model.refreshOutputTable();
}
}
}
......@@ -53,10 +53,23 @@ public class ProjectViewModel {
}
public void deleteOutputFiles(final int[] rows) throws IOException {
Arrays.stream(rows)
.mapToObj(row -> getOutputTableModel().getValue(row))
.filter(dir -> IOOutput.deleteOutputDirectory(dir))
.forEach(dir -> logger.info("delete output directory: " + dir.getName()));
// 1. delete output files on the hard disc
int j = 0;
for(int i = 0; i < rows.length; i++) {
File dir = getOutputTableModel().getValue(rows[i]-j);
if(IOOutput.deleteOutputDirectory(dir)) {
j++;
// 2. remove output files information from the output file table
outputTable.getModel().remove(dir);
// 3. remove output files information from the project output
getProject().getProjectOutput().removeOutputDir(dir.getName());
logger.info("output dir "+ dir +" dir deleted.");
}
}
}
public void deleteScenarios(final int[] rows) {
......
......@@ -50,6 +50,17 @@ public abstract class VadereTableModelSorted<T> extends DefaultTableModel {
public abstract void insertRow(int row, T value);
@Override
public void removeRow(int row) {
safeRemove(row);
}
public void removeRows(final int[] rows) {
for(int i=0; i<rows.length; i++){
removeRow(rows[i]-i);
}
}
public synchronized void insertValue(final T value) {
int index = rows.findPrecessor(value);
rows.add(value);
......@@ -58,7 +69,7 @@ public abstract class VadereTableModelSorted<T> extends DefaultTableModel {
}
private void safeRemove(final int row) {
removeRow(row);
rows.remove(row);
super.removeRow(row);
}
}
......@@ -3,20 +3,23 @@ package org.vadere.gui.projectview.view;
import org.apache.commons.lang3.ArrayUtils;
import org.vadere.gui.projectview.control.ActionSeeDiscardChanges;
import org.vadere.gui.projectview.model.ProjectViewModel;
import org.vadere.gui.projectview.model.VadereTableModelSorted;
import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
public class VTable extends JTable {
public class VTable<D> extends JTable {
private static final long serialVersionUID = 1L;
public ProjectViewModel projectViewModel;
public VTable(final DefaultTableModel model) {
public VTable(final VadereTableModelSorted<D> model) {
super(model);
}
......@@ -66,4 +69,8 @@ public class VTable extends JTable {
comp.setEnabled(enabled);
}
@Override
public VadereTableModelSorted<D> getModel() {
return (VadereTableModelSorted<D> )super.getModel();
}
}
......@@ -54,6 +54,24 @@ public class ProjectOutput {
return outputs;
}
/**
* removes the output-dirs from ProjectOutput but not from the hard drive!
* @param dirNames
*/
public void removeOutputDirs(final String... dirNames) {
for(String dirName : dirNames) {
simulationOutputs.remove(dirName);
}
}
/**
* removes the output-dir from ProjectOutput but not from the hard drive!
* @param dirName
*/
public void removeOutputDir(final String dirName) {
simulationOutputs.remove(dirName);
}
/**
* This function does not check if cached {@link SimulationOutput} is dirty. It is assumed
* {@link #update()} was called prior to this function.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment