Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Simonstrator
PeerfactSim.KOM
Commits
ab9bd722
Commit
ab9bd722
authored
Jan 21, 2023
by
Ermek Kuban
Browse files
change depends due exporter file move
parent
004135a2
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/util/guirunner/GUIRunner.java
View file @
ab9bd722
...
...
@@ -18,9 +18,8 @@
*
*/
package
de.tud.kom.p2psim.impl.util.guirunner
;
package
de.tud.kom.p2psim.impl.util.guirunner
;
import
java.awt.BorderLayout
;
import
java.awt.FlowLayout
;
import
java.awt.GridBagConstraints
;
...
...
@@ -54,95 +53,95 @@ import de.tud.kom.p2psim.impl.util.guirunner.impl.RunnerController;
import
de.tud.kom.p2psim.impl.util.guirunner.impl.VariableFieldEditor
;
import
de.tud.kom.p2psim.impl.util.guirunner.impl.VariationSelector
;
import
de.tud.kom.p2psim.impl.util.guirunner.seed.SeedChooser
;
/**
* A window to select a configuration file to run PFS from. Useful for
* developers switching between different configuration files many times, as
well as
* for presentations etc.
*
* @author Leo Nobach
* @version 3.0, 25.11.2008
*
*/
public
class
GUIRunner
extends
JFrame
implements
WindowListener
,
KeyListener
{
/**
*
*/
private
static
final
long
serialVersionUID
=
6126914669745711438L
;
/*
* Konfigurationspfade
*/
static
final
String
CONF_PATH
=
"GUIRunner/MainWindow/"
;
static
final
String
CONF_PATH_WIDTH
=
CONF_PATH
+
"Width"
;
static
final
String
CONF_PATH_HEIGHT
=
CONF_PATH
+
"Height"
;
static
final
String
CONF_PATH_POSX
=
CONF_PATH
+
"PosX"
;
static
final
String
CONF_PATH_POSY
=
CONF_PATH
+
"PosY"
;
public
static
final
String
DEFAULT_CONFIG_DIR
=
"./config"
;
public
static
final
Image
frameIcon
=
new
ImageIcon
(
"images/icons/frame_icon.png"
).
getImage
();
private
static
final
String
SPLITTER_CONF_PATH
=
CONF_PATH
+
"SplitterPos"
;
public
static
LastOpened
lastOpened
=
new
LastOpened
();
public
static
RunnerController
ctrl
=
new
RunnerController
();
/**
* A window to select a configuration file to run PFS from. Useful for
* developers switching between different configuration files many times, as
*
well as
for presentations etc.
*
* @author Leo Nobach
* @version 3.0, 25.11.2008
*
*/
public
class
GUIRunner
extends
JFrame
implements
WindowListener
,
KeyListener
{
/**
*
*/
private
static
final
long
serialVersionUID
=
6126914669745711438L
;
/*
* Konfigurationspfade
*/
static
final
String
CONF_PATH
=
"GUIRunner/MainWindow/"
;
static
final
String
CONF_PATH_WIDTH
=
CONF_PATH
+
"Width"
;
static
final
String
CONF_PATH_HEIGHT
=
CONF_PATH
+
"Height"
;
static
final
String
CONF_PATH_POSX
=
CONF_PATH
+
"PosX"
;
static
final
String
CONF_PATH_POSY
=
CONF_PATH
+
"PosY"
;
public
static
final
String
DEFAULT_CONFIG_DIR
=
"./config"
;
public
static
final
Image
frameIcon
=
new
ImageIcon
(
"images/icons/frame_icon.png"
).
getImage
();
private
static
final
String
SPLITTER_CONF_PATH
=
CONF_PATH
+
"SplitterPos"
;
public
static
LastOpened
lastOpened
=
new
LastOpened
();
public
static
RunnerController
ctrl
=
new
RunnerController
();
JSplitPane
splitPane
;
JTextField
searchBar
;
DirView
dirView
;
public
GUIRunner
()
{
ctrl
.
setLastOpened
(
lastOpened
);
ctrl
.
setMainWindow
(
this
);
this
.
setTitle
(
"PeerfactSim.KOM - Select Launch Configuration"
);
this
.
setIconImage
(
frameIcon
);
this
.
setDefaultCloseOperation
(
WindowConstants
.
DO_NOTHING_ON_CLOSE
);
this
.
addWindowListener
(
this
);
DirView
dirView
;
public
GUIRunner
()
{
ctrl
.
setLastOpened
(
lastOpened
);
ctrl
.
setMainWindow
(
this
);
this
.
setTitle
(
"PeerfactSim.KOM - Select Launch Configuration"
);
this
.
setIconImage
(
frameIcon
);
this
.
setDefaultCloseOperation
(
WindowConstants
.
DO_NOTHING_ON_CLOSE
);
this
.
addWindowListener
(
this
);
int
winWidth
=
Config
.
getValue
(
CONF_PATH_WIDTH
,
600
);
int
winHeight
=
Config
.
getValue
(
CONF_PATH_HEIGHT
,
600
);
this
.
setSize
(
winWidth
,
winHeight
);
Point
point
=
new
Point
(
Config
.
getValue
(
CONF_PATH_POSX
,
0
),
Config
.
getValue
(
CONF_PATH_POSY
,
0
));
this
.
setSize
(
winWidth
,
winHeight
);
Point
point
=
new
Point
(
Config
.
getValue
(
CONF_PATH_POSX
,
0
),
Config
.
getValue
(
CONF_PATH_POSY
,
0
));
if
(
point
.
getX
()
>=
0
&&
point
.
getY
()
>=
0
&&
Toolkit
.
getDefaultToolkit
().
getScreenSize
()
.
getWidth
()
<
point
.
getX
()
-
winWidth
&&
Toolkit
.
getDefaultToolkit
().
getScreenSize
()
.
getHeight
()
<
point
.
getY
()
-
winHeight
)
{
&&
Toolkit
.
getDefaultToolkit
().
getScreenSize
()
.
getWidth
()
<
point
.
getX
()
-
winWidth
&&
Toolkit
.
getDefaultToolkit
().
getScreenSize
()
.
getHeight
()
<
point
.
getY
()
-
winHeight
)
{
this
.
setLocation
(
point
);
}
this
.
setLayout
(
new
BorderLayout
());
dirView
=
new
DirView
(
ctrl
,
lastOpened
);
JScrollPane
sp
=
new
JScrollPane
(
dirView
);
this
.
add
(
new
ButtonBar
(),
BorderLayout
.
SOUTH
);
JPanel
sidepanel
=
new
JPanel
();
sidepanel
.
setLayout
(
new
GridBagLayout
());
GridBagConstraints
c
=
new
GridBagConstraints
();
SeedChooser
seed
=
new
SeedChooser
(
ctrl
.
getDetermination
());
seed
.
setBorder
(
BorderFactory
.
createTitledBorder
(
"Seed options"
));
c
.
gridx
=
0
;
c
.
gridy
=
0
;
c
.
weightx
=
1
;
c
.
weighty
=
0
;
c
.
fill
=
GridBagConstraints
.
BOTH
;
sidepanel
.
add
(
seed
,
c
);
}
this
.
setLayout
(
new
BorderLayout
());
dirView
=
new
DirView
(
ctrl
,
lastOpened
);
JScrollPane
sp
=
new
JScrollPane
(
dirView
);
this
.
add
(
new
ButtonBar
(),
BorderLayout
.
SOUTH
);
JPanel
sidepanel
=
new
JPanel
();
sidepanel
.
setLayout
(
new
GridBagLayout
());
GridBagConstraints
c
=
new
GridBagConstraints
();
SeedChooser
seed
=
new
SeedChooser
(
ctrl
.
getDetermination
());
seed
.
setBorder
(
BorderFactory
.
createTitledBorder
(
"Seed options"
));
c
.
gridx
=
0
;
c
.
gridy
=
0
;
c
.
weightx
=
1
;
c
.
weighty
=
0
;
c
.
fill
=
GridBagConstraints
.
BOTH
;
sidepanel
.
add
(
seed
,
c
);
JComponent
vars
=
new
VariableFieldEditor
(
ctrl
).
getComponent
();
vars
.
setBorder
(
BorderFactory
.
createTitledBorder
(
"Variables"
));
...
...
@@ -154,12 +153,12 @@ public class GUIRunner extends JFrame implements WindowListener, KeyListener {
variations
.
setBorder
(
BorderFactory
.
createTitledBorder
(
"Variations"
));
c
.
gridy
=
2
;
c
.
weighty
=
0
;
sidepanel
.
add
(
variations
,
c
);
JComponent
desc
=
new
DescriptionWnd
(
ctrl
).
getComponent
();
desc
.
setBorder
(
BorderFactory
.
createTitledBorder
(
"Description"
));
c
.
gridy
=
3
;
c
.
weighty
=
1
;
sidepanel
.
add
(
variations
,
c
);
JComponent
desc
=
new
DescriptionWnd
(
ctrl
).
getComponent
();
desc
.
setBorder
(
BorderFactory
.
createTitledBorder
(
"Description"
));
c
.
gridy
=
3
;
c
.
weighty
=
1
;
sidepanel
.
add
(
desc
,
c
);
searchBar
=
new
JTextField
();
...
...
@@ -171,30 +170,32 @@ public class GUIRunner extends JFrame implements WindowListener, KeyListener {
}
});
JSplitPane
searchDirViewSplitPane
=
new
JSplitPane
(
JSplitPane
.
VERTICAL_SPLIT
,
searchBar
,
sp
);
searchDirViewSplitPane
.
setEnabled
(
false
);
splitPane
=
new
JSplitPane
(
JSplitPane
.
HORIZONTAL_SPLIT
,
sidepanel
,
searchDirViewSplitPane
);
splitPane
.
setDividerLocation
(
Config
.
getValue
(
SPLITTER_CONF_PATH
,
400
));
this
.
add
(
splitPane
,
BorderLayout
.
CENTER
);
GlobalKeyEventDispatcher
disp
=
new
GlobalKeyEventDispatcher
(
this
);
disp
.
addKeyListener
(
this
);
this
.
setVisible
(
true
);
}
public
class
ButtonBar
extends
JPanel
implements
ActionListener
{
/**
*
*/
private
static
final
long
serialVersionUID
=
-
7482502225920138689L
;
JSplitPane
searchDirViewSplitPane
=
new
JSplitPane
(
JSplitPane
.
VERTICAL_SPLIT
,
searchBar
,
sp
);
searchDirViewSplitPane
.
setEnabled
(
false
);
splitPane
=
new
JSplitPane
(
JSplitPane
.
HORIZONTAL_SPLIT
,
sidepanel
,
searchDirViewSplitPane
);
splitPane
.
setDividerLocation
(
Config
.
getValue
(
SPLITTER_CONF_PATH
,
400
));
this
.
add
(
splitPane
,
BorderLayout
.
CENTER
);
GlobalKeyEventDispatcher
disp
=
new
GlobalKeyEventDispatcher
(
this
);
disp
.
addKeyListener
(
this
);
this
.
setVisible
(
true
);
}
public
class
ButtonBar
extends
JPanel
implements
ActionListener
{
/**
*
*/
private
static
final
long
serialVersionUID
=
-
7482502225920138689L
;
private
JButton
cancelBtn
;
private
JButton
launchExporter
;
public
ButtonBar
()
{
// private JButton launchExporter;
public
ButtonBar
()
{
this
.
setLayout
(
new
FlowLayout
());
JButton
launchBtn
=
new
JButton
(
"Start Simulation"
);
...
...
@@ -203,120 +204,112 @@ public class GUIRunner extends JFrame implements WindowListener, KeyListener {
cancelBtn
=
new
JButton
(
"Cancel"
);
this
.
add
(
cancelBtn
);
launchExporter
=
new
JButton
(
"Start Trace Exporter"
);
this
.
add
(
launchExporter
);
launchExporter
.
addActionListener
(
this
);
cancelBtn
.
addActionListener
(
this
);
}
@Override
public
void
actionPerformed
(
ActionEvent
e
)
{
if
(
e
.
getSource
()
==
cancelBtn
)
//
launchExporter = new JButton("Start Trace Exporter");
//
this.add(launchExporter);
//
launchExporter.addActionListener(this);
cancelBtn
.
addActionListener
(
this
);
}
@Override
public
void
actionPerformed
(
ActionEvent
e
)
{
if
(
e
.
getSource
()
==
cancelBtn
)
closeRunner
();
if
(
e
.
getSource
()
==
launchExporter
)
start
Exporter
();
}
}
//
if (e.getSource() == launchExporter)
// new de.tudarmstadt.maki.simonstrator.peerfact.
Exporter
GUI
();
//
}
}
public
void
closeRunner
()
{
disposeRunner
();
System
.
exit
(
0
);
}
public
void
disposeRunner
()
{
saveSettings
();
this
.
setVisible
(
false
);
this
.
dispose
();
Config
.
writeXMLFile
();
}
/**
* Speichert Einstellungen wie Fenstergröße o.ä.
*/
public
void
saveSettings
()
{
Config
.
setValue
(
CONF_PATH_WIDTH
,
this
.
getWidth
());
Config
.
setValue
(
CONF_PATH_HEIGHT
,
this
.
getHeight
());
Config
.
setValue
(
CONF_PATH_POSX
,
this
.
getX
());
Config
.
setValue
(
CONF_PATH_POSY
,
this
.
getY
());
Config
.
setValue
(
SPLITTER_CONF_PATH
,
splitPane
.
getDividerLocation
());
}
@Override
public
void
windowActivated
(
WindowEvent
arg0
)
{
// Nothing to do
}
@Override
public
void
windowClosed
(
WindowEvent
arg0
)
{
// Nothing to do
}
@Override
public
void
windowClosing
(
WindowEvent
arg0
)
{
closeRunner
();
}
@Override
public
void
windowDeactivated
(
WindowEvent
arg0
)
{
// Nothing to do
}
@Override
public
void
windowDeiconified
(
WindowEvent
arg0
)
{
// Nothing to do
}
@Override
public
void
windowIconified
(
WindowEvent
arg0
)
{
// Nothing to do
}
@Override
public
void
windowOpened
(
WindowEvent
arg0
)
{
// Nothing to do
}
public
void
startExporter
()
{
disposeRunner
();
ExporterGUI
expo
=
new
ExporterGUI
();
expo
.
setVisible
(
true
);
}
public
void
disposeRunner
()
{
saveSettings
();
this
.
setVisible
(
false
);
this
.
dispose
();
Config
.
writeXMLFile
();
}
/**
* Speichert Einstellungen wie Fenstergröße o.ä.
*/
public
void
saveSettings
()
{
Config
.
setValue
(
CONF_PATH_WIDTH
,
this
.
getWidth
());
Config
.
setValue
(
CONF_PATH_HEIGHT
,
this
.
getHeight
());
Config
.
setValue
(
CONF_PATH_POSX
,
this
.
getX
());
Config
.
setValue
(
CONF_PATH_POSY
,
this
.
getY
());
Config
.
setValue
(
SPLITTER_CONF_PATH
,
splitPane
.
getDividerLocation
());
}
@Override
public
void
windowActivated
(
WindowEvent
arg0
)
{
// Nothing to do
}
@Override
public
void
windowClosed
(
WindowEvent
arg0
)
{
// Nothing to do
}
@Override
public
void
windowClosing
(
WindowEvent
arg0
)
{
closeRunner
();
}
@Override
public
void
windowDeactivated
(
WindowEvent
arg0
)
{
// Nothing to do
}
@Override
public
void
windowDeiconified
(
WindowEvent
arg0
)
{
// Nothing to do
}
@Override
public
void
windowIconified
(
WindowEvent
arg0
)
{
// Nothing to do
}
@Override
public
void
windowOpened
(
WindowEvent
arg0
)
{
// Nothing to do
}
public
static
void
main
(
String
[]
args
)
{
new
GUIRunner
();
}
@Override
public
void
keyPressed
(
KeyEvent
e
)
{
if
(
e
.
getKeyCode
()
==
KeyEvent
.
VK_ENTER
)
ctrl
.
invokeRunSimulator
();
else
if
(
e
.
getKeyCode
()
==
KeyEvent
.
VK_ESCAPE
)
this
.
closeRunner
();
}
@Override
public
void
keyReleased
(
KeyEvent
e
)
{
// Nothing to do
}
@Override
public
void
keyTyped
(
KeyEvent
e
)
{
// Nothing to do
}
}
new
GUIRunner
();
}
@Override
public
void
keyPressed
(
KeyEvent
e
)
{
if
(
e
.
getKeyCode
()
==
KeyEvent
.
VK_ENTER
)
ctrl
.
invokeRunSimulator
();
else
if
(
e
.
getKeyCode
()
==
KeyEvent
.
VK_ESCAPE
)
this
.
closeRunner
();
}
@Override
public
void
keyReleased
(
KeyEvent
e
)
{
// Nothing to do
}
@Override
public
void
keyTyped
(
KeyEvent
e
)
{
// Nothing to do
}
}
src/de/tud/kom/p2psim/impl/util/guirunner/impl/DirView.java
View file @
ab9bd722
...
...
@@ -23,15 +23,12 @@ package de.tud.kom.p2psim.impl.util.guirunner.impl;
import
java.awt.event.MouseEvent
;
import
java.awt.event.MouseListener
;
import
javax.swing.JOptionPane
;
import
javax.swing.JTree
;
import
javax.swing.event.TreeSelectionEvent
;
import
javax.swing.event.TreeSelectionListener
;
import
javax.swing.tree.DefaultTreeModel
;
import
javax.swing.tree.TreeSelectionModel
;
import
de.tud.kom.p2psim.impl.util.guirunner.ExporterGUI
;
/**
* A tree view that shows available and recently opened configuration files.
*
...
...
@@ -44,7 +41,7 @@ public class DirView extends JTree
private
RunnerController
ctrl
;
private
ExporterGUI
expo
=
new
ExporterGUI
();
//
private ExporterGUI expo = new ExporterGUI();
private
ConfigTreeNode
selectedConfigNode
=
null
;
...
...
@@ -115,21 +112,21 @@ public class DirView extends JTree
@Override
public
void
mouseClicked
(
MouseEvent
arg0
)
{
JOptionPane
optionConfigStart
=
new
JOptionPane
();
int
selectedOption
=
0
;
//
JOptionPane optionConfigStart = new JOptionPane();
//
int selectedOption = 0;
if
(
arg0
.
getClickCount
()
==
2
&&
selectedConfigNode
!=
null
)
{
selectedOption
=
optionConfigStart
.
showOptionDialog
(
null
,
"Use this configuration file to start"
,
"Choose option"
,
JOptionPane
.
YES_NO_OPTION
,
JOptionPane
.
QUESTION_MESSAGE
,
null
,
new
String
[]
{
"Simulation"
,
"Trace Exporter"
},
""
);
if
(
selectedOption
==
0
)
{
ctrl
.
invokeRunSimulator
();
}
else
{
expo
.
setConfigFile
(
selectedConfigNode
.
getConfigFile
()
);
expo
.
setVisible
(
true
);
}
//
selectedOption = optionConfigStart.showOptionDialog(null,
//
"Use this configuration file to start", "Choose option",
//
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE,
//
null, new String[] { "Simulation", "Trace Exporter" }, "");
//
//
if (selectedOption == 0) {
ctrl
.
invokeRunSimulator
();
//
} else {
//
expo.setConfigFile(selectedConfigNode);
//
expo.setVisible(true);
//
//
}
}
...
...
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