Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
vadere
vadere
Commits
50d9ef0d
Commit
50d9ef0d
authored
Oct 11, 2017
by
Benedikt Zoennchen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix problems with the output processor view - expert view
parent
81dd0f86
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
29 additions
and
96 deletions
+29
-96
VadereGui/resources/outputTemplates/output_default.json
VadereGui/resources/outputTemplates/output_default.json
+0
-14
VadereGui/src/org/vadere/gui/projectview/control/ActionLoadProject.java
...org/vadere/gui/projectview/control/ActionLoadProject.java
+1
-1
VadereGui/src/org/vadere/gui/projectview/utils/ClassFinder.java
...Gui/src/org/vadere/gui/projectview/utils/ClassFinder.java
+1
-47
VadereGui/src/org/vadere/gui/projectview/view/DataProcessingView.java
...c/org/vadere/gui/projectview/view/DataProcessingView.java
+23
-23
VadereGui/src/org/vadere/gui/projectview/view/ProjectView.java
...eGui/src/org/vadere/gui/projectview/view/ProjectView.java
+1
-1
VadereGui/src/org/vadere/gui/projectview/view/ScenarioPanel.java
...ui/src/org/vadere/gui/projectview/view/ScenarioPanel.java
+0
-7
VadereGui/src/org/vadere/gui/projectview/view/TextView.java
VadereGui/src/org/vadere/gui/projectview/view/TextView.java
+0
-1
VadereSimulator/src/org/vadere/simulator/projects/dataprocessing/outputfile/OutputFile.java
...ulator/projects/dataprocessing/outputfile/OutputFile.java
+3
-2
No files found.
VadereGui/resources/outputTemplates/output_default.json
View file @
50d9ef0d
...
...
@@ -173,20 +173,6 @@
},
{
"type"
:
"org.vadere.simulator.projects.dataprocessing.processor.PedestrianSourceIdProcessor"
,
"id"
:
19
},
{
"type"
:
"org.vadere.simulator.projects.dataprocessing.processor.FloorFieldGridProcessor"
,
"id"
:
20
,
"attributesType"
:
"org.vadere.state.attributes.processor.AttributesFloorFieldProcessor"
,
"attributes"
:
{
"targetId"
:
1
}
},
{
"type"
:
"org.vadere.simulator.projects.dataprocessing.processor.FloorFieldProcessor"
,
"id"
:
21
,
"attributesType"
:
"org.vadere.state.attributes.processor.AttributesFloorFieldProcessor"
,
"attributes"
:
{
"targetId"
:
1
}
}
],
"isTimestamped"
:
true
}
VadereGui/src/org/vadere/gui/projectview/control/ActionLoadProject.java
View file @
50d9ef0d
...
...
@@ -104,7 +104,7 @@ public class ActionLoadProject extends AbstractAction {
projectViewModel
.
setProject
(
project
);
projectViewModel
.
refreshOutputTable
();
logger
.
info
(
"refreshed output table"
);
logger
.
info
(
"refreshed output table
- 2
"
);
// select and load first scenario from list
projectViewModel
.
setSelectedRowIndexInScenarioTable
(
0
);
...
...
VadereGui/src/org/vadere/gui/projectview/utils/ClassFinder.java
View file @
50d9ef0d
...
...
@@ -135,7 +135,7 @@ public class ClassFinder {
* Scans all classes accessible from the context class loader which belong to the given package
* and subpackages.
*
* Deprecated since this method
does not work inside a jar file
!
* Deprecated since this method
is slow if we have to access jar file, which is the case if we execute the project via vadere.jar
!
*
* @param packageName The base package
* @return The classes
...
...
@@ -184,52 +184,6 @@ public class ClassFinder {
return
classes
;
}
/**
* Scans all classes accessible from the context class loader which belong to the given package
* and subpackages. Works inside a jar file.
*
*
* @param packageName The base package
* @return The classes
* @throws ClassNotFoundException
* @throws IOException
*/
private
static
List
<
Class
<?>>
getClassesStream
(
String
packageName
)
throws
ClassNotFoundException
,
IOException
{
List
<
Class
<?>>
classes
=
new
ArrayList
<>();
ClassLoader
classLoader
=
Thread
.
currentThread
().
getContextClassLoader
();
String
path
=
packageName
.
replace
(
'.'
,
'/'
);
List
<
String
>
resources
=
new
ArrayList
<>();
LinkedList
<
String
>
dirs
=
new
LinkedList
<>();
dirs
.
add
(
path
);
log
.
info
(
ClassFinder
.
class
.
forName
(
AttributesBHM
.
class
.
getName
()));
while
(!
dirs
.
isEmpty
())
{
String
currentDir
=
dirs
.
removeFirst
();
String
currentPackage
=
currentDir
.
replace
(
'/'
,
'.'
);
InputStream
in
=
ClassFinder
.
class
.
getResourceAsStream
(
"/"
+
currentDir
);
BufferedReader
rdr
=
new
BufferedReader
(
new
InputStreamReader
(
in
));
String
line
;
// line is either a .class file or a directory containing .class files or other directories
while
((
line
=
rdr
.
readLine
())
!=
null
)
{
// line is a filenamew
if
(
line
.
endsWith
(
".class"
))
{
classes
.
add
(
ClassFinder
.
class
.
forName
(
currentPackage
+
'.'
+
line
.
substring
(
0
,
line
.
length
()
-
6
)));
}
else
{
dirs
.
add
(
currentDir
+
'/'
+
line
);
}
}
rdr
.
close
();
}
return
classes
;
}
/**
* Recursive method used to find all classes in a given directory and subdirs.
*
...
...
VadereGui/src/org/vadere/gui/projectview/view/DataProcessingView.java
View file @
50d9ef0d
...
...
@@ -109,7 +109,6 @@ class DataProcessingView extends JPanel implements IJsonView {
JPanel
togglePanel
=
new
JPanel
(
new
FlowLayout
(
FlowLayout
.
RIGHT
));
togglePanel
.
add
(
switchJsonViewModeLabel
);
add
(
togglePanel
,
BorderLayout
.
SOUTH
);
switchMode
();
}
...
...
@@ -119,24 +118,27 @@ class DataProcessingView extends JPanel implements IJsonView {
+
"</b> mode</u></font></span></html>"
);
Preferences
.
userNodeForPackage
(
DataProcessingView
.
class
).
put
(
"dataProcessingViewMode"
,
inGuiViewMode
?
guiViewMode
:
jsonViewMode
);
viewPanel
.
removeAll
();
if
(
inGuiViewMode
)
{
logger
.
info
(
"switch to gui view"
);
GuiView
guiView
=
new
GuiView
();
activeJsonView
=
guiView
;
viewPanel
.
add
(
guiView
);
}
else
{
logger
.
info
(
"switch to expert view"
);
TextView
expertView
=
buildExpertView
();
activeJsonView
=
expertView
;
viewPanel
.
add
(
expertView
);
}
if
(
currentScenario
!=
null
)
{
activeJsonView
.
setVadereScenario
(
currentScenario
);
activeJsonView
.
isEditable
(
isEditable
);
}
revalidate
();
repaint
();
}
...
...
@@ -145,36 +147,34 @@ class DataProcessingView extends JPanel implements IJsonView {
private
TextView
buildExpertView
()
{
TextView
panel
=
new
TextView
(
"/"
+
IOUtils
.
OUTPUT_DIR
,
"default_directory_outputprocessors"
,
AttributeType
.
OUTPUTPROCESSOR
);
JMenuBar
processorsMenuBar
=
new
JMenuBar
();
processorsMenu
=
new
JMenu
(
Messages
.
getString
(
"Tab.Model.loadTemplateMenu.title"
));
processorsMenu
.
setEnabled
(
isEditable
);
processorsMenuBar
.
add
(
processorsMenu
);
try
{
File
[]
templateFiles
=
new
File
(
this
.
getClass
().
getResource
(
"/outputTemplates/"
).
getPath
()).
listFiles
();
for
(
File
templateFile
:
Arrays
.
stream
(
templateFiles
).
filter
(
File:
:
isFile
).
collect
(
Collectors
.
toList
()))
{
String
templateFileName
=
templateFile
.
getName
();
String
templateJson
=
org
.
apache
.
commons
.
io
.
IOUtils
.
toString
(
this
.
getClass
().
getResourceAsStream
(
"/outputTemplates/"
+
templateFileName
),
"UTF-8"
);
processorsMenu
.
add
(
new
JMenuItem
(
new
AbstractAction
(
templateFileName
)
{
@Override
public
void
actionPerformed
(
ActionEvent
e
)
{
if
(
JOptionPane
.
showConfirmDialog
(
ProjectView
.
getMainWindow
(),
Messages
.
getString
(
"Tab.Model.confirmLoadTemplate.text"
),
Messages
.
getString
(
"Tab.Model.confirmLoadTemplate.title"
),
JOptionPane
.
OK_CANCEL_OPTION
)
==
JOptionPane
.
OK_OPTION
)
{
try
{
panel
.
setText
(
templateJson
);
}
catch
(
Exception
e1
)
{
e1
.
printStackTrace
();
}
}
}
}));
}
//TODO [bug, jar]: the file name is hard coded and it is not possible to add more presets! This is because listFile() does not work inside a jar.
String
fileName
=
"output_default"
;
String
templateJson
=
org
.
apache
.
commons
.
io
.
IOUtils
.
toString
(
this
.
getClass
().
getResourceAsStream
(
"/outputTemplates/"
+
fileName
+
".json"
),
"UTF-8"
);
processorsMenu
.
add
(
new
JMenuItem
(
new
AbstractAction
(
fileName
)
{
@Override
public
void
actionPerformed
(
ActionEvent
e
)
{
if
(
JOptionPane
.
showConfirmDialog
(
ProjectView
.
getMainWindow
(),
Messages
.
getString
(
"Tab.Model.confirmLoadTemplate.text"
),
Messages
.
getString
(
"Tab.Model.confirmLoadTemplate.title"
),
JOptionPane
.
OK_CANCEL_OPTION
)
==
JOptionPane
.
OK_OPTION
)
{
try
{
panel
.
setText
(
templateJson
);
}
catch
(
Exception
e1
)
{
e1
.
printStackTrace
();
}
}
}
}));
panel
.
getPanelTop
().
add
(
processorsMenuBar
,
0
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
logger
.
error
(
"could not initialize output processor expert view: "
+
e
.
getMessage
());
}
return
panel
;
}
...
...
VadereGui/src/org/vadere/gui/projectview/view/ProjectView.java
View file @
50d9ef0d
...
...
@@ -492,7 +492,7 @@ public class ProjectView extends JFrame implements ProjectFinishedListener, Sing
model
.
setCurrentScenario
(
bundle
.
getScenario
());
logger
.
info
(
String
.
format
(
"selected scenario '%s'"
,
bundle
.
getScenario
().
getName
()));
scenarioJPanel
.
setScenario
(
bundle
.
getScenario
(),
true
);
scenarioJPanel
.
setScenario
(
bundle
.
getScenario
(),
true
);
outputTableRenderer
.
setMarkedOutputFiles
(
bundle
.
getOutputDirectories
());
outputTable
.
repaint
();
// make cell renderer mark associated outputs
...
...
VadereGui/src/org/vadere/gui/projectview/view/ScenarioPanel.java
View file @
50d9ef0d
...
...
@@ -72,7 +72,6 @@ public class ScenarioPanel extends JPanel implements IProjectChangeListener, Pro
// Edit card...
JPanel
editCard
=
new
JPanel
();
editCard
.
setBorder
(
new
EmptyBorder
(
5
,
5
,
5
,
5
));
editCard
.
setLayout
(
new
BorderLayout
(
0
,
0
));
editCard
.
setBounds
(
0
,
0
,
500
,
100
);
...
...
@@ -141,7 +140,6 @@ public class ScenarioPanel extends JPanel implements IProjectChangeListener, Pro
}
}
})));
JMenu
mnModelNameMenu
=
new
JMenu
(
Messages
.
getString
(
"Tab.Model.insertModelNameMenu.title"
));
presetMenuBar
.
add
(
mnModelNameMenu
);
menusInTabs
.
add
(
mnModelNameMenu
);
...
...
@@ -153,7 +151,6 @@ public class ScenarioPanel extends JPanel implements IProjectChangeListener, Pro
attributesModelView
.
insertAtCursor
(
"\""
+
className
+
"\""
);
}
})));
logger
.
info
(
"3"
);
ClassFinder
.
getModelNames
().
stream
()
.
sorted
()
.
forEach
(
className
->
mnModelNameMenu
.
add
(
new
JMenuItem
(
new
AbstractAction
(
className
)
{
...
...
@@ -162,16 +159,13 @@ public class ScenarioPanel extends JPanel implements IProjectChangeListener, Pro
attributesModelView
.
insertAtCursor
(
"\""
+
className
+
"\""
);
}
})));
attributesModelView
.
getPanelTop
().
add
(
presetMenuBar
,
0
);
// the 0 puts it at the leftest position instead of the rightest
tabbedPane
.
addTab
(
Messages
.
getString
(
"Tab.Model.title"
),
attributesModelView
);
topographyFileView
=
new
TextView
(
"/scenarios"
,
"default_directory_scenarios"
,
AttributeType
.
TOPOGRAPHY
);
tabbedPane
.
addTab
(
Messages
.
getString
(
"Tab.Topography.title"
),
topographyFileView
);
dataProcessingGUIview
=
new
DataProcessingView
();
tabbedPane
.
addTab
(
"Data processing GUI"
,
dataProcessingGUIview
);
// online visualization card...
JPanel
visualizationCard
=
new
JPanel
();
...
...
@@ -183,7 +177,6 @@ public class ScenarioPanel extends JPanel implements IProjectChangeListener, Pro
// Add panels
super
.
add
(
editCard
,
editCardName
);
super
.
add
(
visualizationCard
,
visualizationCardName
);
}
public
void
showVisualization
()
{
...
...
VadereGui/src/org/vadere/gui/projectview/view/TextView.java
View file @
50d9ef0d
...
...
@@ -113,7 +113,6 @@ public class TextView extends JPanel implements IJsonView {
this
.
default_resource
=
default_resource
;
this
.
attributeType
=
attributeType
;
setLayout
(
new
BorderLayout
(
0
,
0
));
logger
.
info
(
"04"
);
panelTop
=
new
JPanel
();
add
(
panelTop
,
BorderLayout
.
NORTH
);
panelTop
.
setLayout
(
new
FlowLayout
(
FlowLayout
.
CENTER
,
5
,
5
));
...
...
VadereSimulator/src/org/vadere/simulator/projects/dataprocessing/outputfile/OutputFile.java
View file @
50d9ef0d
...
...
@@ -45,13 +45,14 @@ public abstract class OutputFile<K extends DataKey<K>> {
}
public
void
setRelativeFileName
(
final
String
fileName
)
{
File
file
=
new
File
(
this
.
fileName
);
/*
File file = new File(this.fileName);
if(file.getParentFile() != null) {
this.fileName = new File(this.fileName).getParentFile().toPath().resolve(fileName).toString();
}
else {
this.fileName = fileName;
}
}*/
this
.
fileName
=
fileName
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment