Commit 47471145 authored by Stefan Schuhbaeck's avatar Stefan Schuhbaeck

add copy to clipboard action to outputTable

parent 6c45179a
......@@ -199,6 +199,7 @@ AdjustPanel.lblStep.text=Timestep
ProjectView.mntmOutputToSceneario.text=Generate scenario
ProjectView.mntmRunOutput.text=Run offline again
ProjectView.mntmCopyOutputDir.text=Copy output path to clipboard
SettingsDialog.chbShowPedestrianIds.text=Show PedestrianIds
PostVis.chShowEvacTimeColor.text=Color Pedestrians regarding to Evacuation Times
......
......@@ -200,6 +200,7 @@ AdjustPanel.lblStep.text=Zeitschritt
ProjectView.mntmOutputToSceneario.text=Generiere Szenario
ProjectView.mntmRunOutput.text=Offline erneut starten
ProjectView.mntmCopyOutputDir.text=Kopiere Output Pfad in Zwischenablage
SettingsDialog.chbShowPedestrianIds.text=Fu\u00dfg\u00E4nger-Ids anzeigen
PostVis.additional.border.text=PostVis
......
package org.vadere.gui.projectview.control;
import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.event.ActionEvent;
import javax.swing.*;
public class ActionToClipboard extends AbstractAction {
String data;
public ActionToClipboard(String name, String data){
super(name);
this.data = data;
}
@Override
public void actionPerformed(ActionEvent e) {
StringSelection selection = new StringSelection(data);
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(selection, selection);
}
}
......@@ -28,6 +28,7 @@ import org.vadere.gui.projectview.control.ActionSaveAsProject;
import org.vadere.gui.projectview.control.ActionSaveProject;
import org.vadere.gui.projectview.control.ActionSeeDiscardChanges;
import org.vadere.gui.projectview.control.ActionShowAboutDialog;
import org.vadere.gui.projectview.control.ActionToClipboard;
import org.vadere.gui.projectview.control.IOutputFileRefreshListener;
import org.vadere.gui.projectview.control.IProjectChangeListener;
import org.vadere.gui.projectview.control.ShowResultDialogAction;
......@@ -587,6 +588,35 @@ public class ProjectView extends JFrame implements ProjectFinishedListener, Sing
outputListPopupMenu
.add(new JMenuItem(new ActionRunOutput(Messages.getString("ProjectView.mntmRunOutput.text"), model)));
JMenu copyPath = new JMenu(Messages.getString("ProjectView.mntmCopyOutputDir.text"));
outputTable.getSelectionModel().addListSelectionListener(new TableSelectionListener(outputTable) {
@Override
public void onSelect(ListSelectionEvent e) {
try {
OutputBundle bundle = model.getSelectedOutputBundle();
File outDir = bundle.getDirectory();
copyPath.removeAll();
copyPath.add(new JMenuItem(
new ActionToClipboard(outDir.getName() + "/", outDir.getAbsolutePath()))
);
File[] children = outDir.listFiles();
if (children != null){
for (File file : children) {
String name = file.isDirectory() ? file.getName() + "/" : file.getName();
copyPath.add(new JMenuItem(
new ActionToClipboard(name, file.getAbsolutePath()))
);
}
}
} catch (IOException ex) {
logger.error(ex);
}
}
});
outputListPopupMenu.add(copyPath);
JPopupMenu outputListPopupMenuMultiSelect = new JPopupMenu();
outputListPopupMenuMultiSelect.add(new JMenuItem(deleteOutputFileAction));
......
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