Commit c0760ff5 authored by maysam zoor's avatar maysam zoor

add progress bar

parent 96f44166
......@@ -39,6 +39,7 @@
package ui.simulationtraceanalysis;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Font;
......@@ -68,6 +69,7 @@ import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTable;
......@@ -122,7 +124,7 @@ public class JFrameLatencyDetailedAnalysis extends JFrame implements ActionListe
protected JTextArea jta;
protected JScrollPane jsp;
private JTabbedPane commandTab, resultTab;/* , resultTabDetailed; */
private JPanel loadxml, commands, jp01, jp02, /* activities, */ graphAnalysisResult, jp03, jp04, jp05; // ,graphAnalysisResultDetailed;
private JPanel loadxml, commands, jp01, jp02, /* activities, */ graphAnalysisResult, jp03, jp04, jp05, progressBarpanel; // ,graphAnalysisResultDetailed;
protected JButton buttonClose, buttonShowDGraph, buttonSaveDGraph, buttonBrowse, buttonDetailedAnalysis;
public Vector<String> checkedTransactions = new Vector<String>();
......@@ -159,6 +161,10 @@ public class JFrameLatencyDetailedAnalysis extends JFrame implements ActionListe
private Thread t;
// @SuppressWarnings("deprecation")
JProgressBar pbar;
JFrameCompareLatencyDetail jframeCompareLatencyDetail;
public JFrameLatencyDetailedAnalysis(TMLMapping<TGComponent> tmap, List<TMLComponentDesignPanel> cpanels, SimulationTrace selectedST) {
super("Latency Detailed Analysis");
initActions();
......@@ -203,6 +209,41 @@ public class JFrameLatencyDetailedAnalysis extends JFrame implements ActionListe
framePanel.add(jp, mainConstraint);
GridBagLayout gridbag01 = new GridBagLayout();
GridBagConstraints c01 = new GridBagConstraints();
progressBarpanel = new JPanel(gridbag01);
c01.gridheight = 1;
c01.weighty = 1.0;
c01.weightx = 1.0;
c01.gridwidth = 1;
c01.gridx = 0;
c01.gridy = 0;
// c01.fill = GridBagConstraints.BOTH;
JLabel pBarLabel = new JLabel("Progress of Graph Generation", JLabel.LEFT);
progressBarpanel.add(pBarLabel, c01);
c01.gridheight = 1;
c01.weighty = 1.0;
c01.weightx = 1.0;
c01.gridwidth = 1;
c01.gridx = 1;
c01.gridy = 0;
pbar = new JProgressBar();
pbar.setForeground(Color.GREEN);
progressBarpanel.add(pbar, c01);
mainConstraint.gridheight = 1;
mainConstraint.gridx = 0;
mainConstraint.gridy = 3;
mainConstraint.ipady = 40;
mainConstraint.fill = GridBagConstraints.HORIZONTAL;
framePanel.add(progressBarpanel, mainConstraint);
// mainpanel.add(jp, BorderLayout.NORTH);
// GridBagLayout gridbag02 = new GridBagLayout();
......@@ -242,21 +283,24 @@ public class JFrameLatencyDetailedAnalysis extends JFrame implements ActionListe
framePanel.add(graphAnalysisResult, mainConstraint);
// mainTop.add(commands, c02);
// mainConstraint.gridwidth = GridBagConstraints.REMAINDER; // end row
// mainConstraint.fill = GridBagConstraints.BOTH;
jp05 = new JPanel(new BorderLayout());
// mainpanel.add(split, BorderLayout.SOUTH);
mainConstraint.weighty = 00;
mainConstraint.ipady = 100;
mainConstraint.gridx = 0;
mainConstraint.gridy = 3;
mainConstraint.gridy = 4;
mainConstraint.fill = GridBagConstraints.HORIZONTAL;
framePanel.add(jp05, mainConstraint);
commandTab = GraphicLib.createTabbedPaneRegular();// new JTabbedPane();
GridBagLayout gridbag01 = new GridBagLayout();
GridBagConstraints c01 = new GridBagConstraints();
gridbag01 = new GridBagLayout();
c01 = new GridBagConstraints();
loadxml = new JPanel(gridbag01);
commandTab.addTab("load XML", null, loadxml, "load XML");
......@@ -461,6 +505,7 @@ public class JFrameLatencyDetailedAnalysis extends JFrame implements ActionListe
t = new Thread() {
public void run() {
generateDirectedGraph(tmap, cpanels);
}
};
......@@ -468,6 +513,10 @@ public class JFrameLatencyDetailedAnalysis extends JFrame implements ActionListe
}
public void updateBar(int newValue) {
pbar.setValue(newValue);
}
public DirectedGraphTranslator getDgraph() {
return dgraph;
}
......@@ -479,7 +528,7 @@ public class JFrameLatencyDetailedAnalysis extends JFrame implements ActionListe
private void generateDirectedGraph(TMLMapping<TGComponent> tmap, List<TMLComponentDesignPanel> cpanels) {
try {
dgraph = new DirectedGraphTranslator(tmap, cpanels);
dgraph = new DirectedGraphTranslator(this, jframeCompareLatencyDetail, tmap, cpanels, 0);
jta.append("A Directed Graph with " + dgraph.getGraphsize() + " vertices" + dgraph.getGraphEdgeSet() + "Edges was generated.\n");
// buttonSaveDGraph.setEnabled(true);
buttonShowDGraph.setEnabled(true);
......
......@@ -38,15 +38,18 @@ import ui.window.JDialogToChosePanel;
public class latencyDetailedAnalysisMain {
public DirectedGraphTranslator dgraph;
// public DirectedGraphTranslator dgraph;
private Vector<String> checkedTransactionsFile1 = new Vector<String>();
public Vector<String> checkedTransactionsFile2 = new Vector<String>();
public Vector<String> checkedTransactionsFile = new Vector<String>();
public MainGUI mainGUI_compare2, mainGUI_compare;
private JFrameLatencyDetailedAnalysis latencyDetailedAnalysis;
JFrameCompareLatencyDetail cld;
private Thread t, t1;
public TMLMapping<TGComponent> map1;
public List<TMLComponentDesignPanel> cpanels1;
public latencyDetailedAnalysisMain(int callerId, MainGUI mainGUI, SimulationTrace selectedST, boolean b, boolean compare, int j) {
......@@ -106,6 +109,7 @@ public class latencyDetailedAnalysisMain {
TMLArchiPanel tmlap = (TMLArchiPanel) tp;
TMLMapping<TGComponent> map = mainGUI_compare.gtm.getTMLMapping();
for (TGComponent component : tmlap.tmlap.getComponentList()) {
tmlNodesToValidate.add(component);
}
......@@ -140,7 +144,11 @@ public class latencyDetailedAnalysisMain {
}
}
if (compare) {
dgraph = new DirectedGraphTranslator(map, cpanels);
map1 = map;
setCpanels1(cpanels);
// dgraph = new DirectedGraphTranslator(latencyDetailedAnalysis,cld,map,
// cpanels,1);
for (TGComponent tgc1 : map.getTMLModeling().getCheckedComps().keySet()) {
String compName = map.getTMLModeling().getCheckedComps().get(tgc1);
......@@ -165,7 +173,11 @@ public class latencyDetailedAnalysisMain {
cpanels = new ArrayList<TMLComponentDesignPanel>();
cpanels.add(tmlcdp);
if (compare) {
dgraph = new DirectedGraphTranslator(map, cpanels);
// dgraph = new DirectedGraphTranslator(latencyDetailedAnalysis,cld,map,
// cpanels,1);
map1 = map;
setCpanels1(cpanels);
for (TGComponent tgc : map.getTMLModeling().getCheckedComps().keySet()) {
String compName = map.getTMLModeling().getCheckedComps().get(tgc);
......@@ -216,59 +228,48 @@ public class latencyDetailedAnalysisMain {
e1.printStackTrace();
}
while (dgraph.getGraphsize() == 0) {
}
if (dgraph.getGraphsize() > 0) {
dgraph1 = dgraph;
dgraph = null;
JFileChooser fc;
JFrameCompareLatencyDetail cld = new JFrameCompareLatencyDetail(this, mainGUI, dgraph1, checkedTransactionsFile1, selectedST, true);
/*
* if (ConfigurationTTool.SystemCCodeDirectory.length() > 0) { fc = new
* JFileChooser(ConfigurationTTool.SystemCCodeDirectory); } else { fc = new
* JFileChooser(); }
*
* FileNameExtensionFilter filter = new FileNameExtensionFilter("XML files",
* "xml"); fc.setFileFilter(filter);
*
* int returnVal = fc.showOpenDialog(mainGUI.frame);
*
* if (returnVal == JFileChooser.APPROVE_OPTION) { File filefc =
* fc.getSelectedFile(); // file2.setText(file.getPath());
*
* // Object obj = filefc;
*
* checkedTransactionsFile = new Vector<String>(); SimulationTrace file2 = new
* SimulationTrace(filefc.getName(), 6, filefc.getAbsolutePath());
*
* if (file2 instanceof SimulationTrace) {
*
* try { latencyDetailedAnalysisForXML(mainGUI, file2, false, true, 2); } catch
* (XPathExpressionException | ParserConfigurationException | SAXException |
* IOException e) { // TODO Auto-generated catch block e.printStackTrace(); }
*
* while (dgraph.getGraphsize() == 0) {
*
* }
*
* if (dgraph.getGraphsize() > 0) { dgraph2 = dgraph; checkedTransactionsFile2 =
* checkedTransactionsFile; JFrameCompareLatencyDetail cld = new
* JFrameCompareLatencyDetail(dgraph1, dgraph2, checkedTransactionsFile1,
* checkedTransactionsFile2, selectedST, file2, true);
*
* mainGUI_compare2.closeTurtleModeling();
*
* } }
*
* }
*/
cld = new JFrameCompareLatencyDetail(this, mainGUI, checkedTransactionsFile1, map1, cpanels1, selectedST, true);
/*
* if (ConfigurationTTool.SystemCCodeDirectory.length() > 0) { fc = new
* JFileChooser(ConfigurationTTool.SystemCCodeDirectory); } else { fc = new
* JFileChooser(); }
*
* FileNameExtensionFilter filter = new FileNameExtensionFilter("XML files",
* "xml"); fc.setFileFilter(filter);
*
* int returnVal = fc.showOpenDialog(mainGUI.frame);
*
* if (returnVal == JFileChooser.APPROVE_OPTION) { File filefc =
* fc.getSelectedFile(); // file2.setText(file.getPath());
*
* // Object obj = filefc;
*
* checkedTransactionsFile = new Vector<String>(); SimulationTrace file2 = new
* SimulationTrace(filefc.getName(), 6, filefc.getAbsolutePath());
*
* if (file2 instanceof SimulationTrace) {
*
* try { latencyDetailedAnalysisForXML(mainGUI, file2, false, true, 2); } catch
* (XPathExpressionException | ParserConfigurationException | SAXException |
* IOException e) { // TODO Auto-generated catch block e.printStackTrace(); }
*
* while (dgraph.getGraphsize() == 0) {
*
* }
*
* if (dgraph.getGraphsize() > 0) { dgraph2 = dgraph; checkedTransactionsFile2 =
* checkedTransactionsFile; JFrameCompareLatencyDetail cld = new
* JFrameCompareLatencyDetail(dgraph1, dgraph2, checkedTransactionsFile1,
* checkedTransactionsFile2, selectedST, file2, true);
*
* mainGUI_compare2.closeTurtleModeling();
*
* } }
*
* }
*/
}
}
public void latencyDetailedAnalysisForXML(MainGUI mainGUI, SimulationTrace selectedST, boolean b, boolean compare, int j)
......@@ -463,14 +464,6 @@ public class latencyDetailedAnalysisMain {
}
public DirectedGraphTranslator getDgraph() {
return dgraph;
}
public void setDgraph(DirectedGraphTranslator dgraph) {
this.dgraph = dgraph;
}
public Vector<String> getCheckedTransactionsFile() {
return checkedTransactionsFile;
}
......@@ -501,4 +494,12 @@ public class latencyDetailedAnalysisMain {
return t1;
}
public List<TMLComponentDesignPanel> getCpanels1() {
return cpanels1;
}
public void setCpanels1(List<TMLComponentDesignPanel> cpanels1) {
this.cpanels1 = cpanels1;
}
}
......@@ -19,6 +19,7 @@ import ui.TMLArchiPanel;
import ui.interactivesimulation.SimulationTransaction;
import ui.simulationtraceanalysis.DirectedGraphTranslator;
import ui.simulationtraceanalysis.JFrameCompareLatencyDetail;
import ui.simulationtraceanalysis.JFrameLatencyDetailedAnalysis;
import ui.simulationtraceanalysis.latencyDetailedAnalysisMain;
public class CompareLatencyInSimulationTraces extends AbstractUITest {
......@@ -40,6 +41,7 @@ public class CompareLatencyInSimulationTraces extends AbstractUITest {
private static String task1, task2, task3, task4;
JFrameCompareLatencyDetail cld;
private latencyDetailedAnalysisMain latencyDetailedAnalysisMain;
private JFrameLatencyDetailedAnalysis jFrameLatencyDetailedAnalysis;
Vector<SimulationTransaction> transFile1, transFile2;
SimulationTrace simT1, simT2;
......@@ -72,6 +74,16 @@ public class CompareLatencyInSimulationTraces extends AbstractUITest {
try {
latencyDetailedAnalysisMain.latencyDetailedAnalysisForXML(mainGUI, simT1, false, true, 1);
cld = new JFrameCompareLatencyDetail(latencyDetailedAnalysisMain, mainGUI, checkedTransactionsFile1,
latencyDetailedAnalysisMain.map1, latencyDetailedAnalysisMain.cpanels1, simT1, false);
if (cld == null) {
System.out.println("NULL Panel");
} else {
cld.setVisible(false);
}
} catch (XPathExpressionException | ParserConfigurationException | SAXException | IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
......@@ -86,60 +98,68 @@ public class CompareLatencyInSimulationTraces extends AbstractUITest {
}
if (t.getState() == Thread.State.TERMINATED) {
while (latencyDetailedAnalysisMain.getDgraph().getGraphsize() == 0) {
while (cld.t.getState() != Thread.State.TERMINATED) {
}
if (cld.t.getState() == Thread.State.TERMINATED) {
if (latencyDetailedAnalysisMain.getDgraph().getGraphsize() > 0) {
dgraph1 = latencyDetailedAnalysisMain.getDgraph();
checkedTransactionsFile1 = latencyDetailedAnalysisMain.getCheckedTransactionsFile();
latencyDetailedAnalysisMain.setDgraph(null);
cld = new JFrameCompareLatencyDetail(latencyDetailedAnalysisMain, mainGUI, dgraph1, checkedTransactionsFile1, simT1, false);
while (cld.dgraph.getGraphsize() == 0) {
if (cld == null) {
System.out.println("NULL Panel");
} else {
cld.setVisible(false);
}
latencyDetailedAnalysisMain.setCheckedTransactionsFile(new Vector<String>());
simT2 = new SimulationTrace("graphTestSimulationTrace", 6, (getBaseResourcesDir() + simulationTracePathFile2));
if (cld.dgraph.getGraphsize() > 0) {
dgraph1 = cld.dgraph;
checkedTransactionsFile1 = latencyDetailedAnalysisMain.getCheckedTransactionsFile();
cld.dgraph = null;
Thread t1 = new Thread() {
public void run() {
latencyDetailedAnalysisMain.setCheckedTransactionsFile(new Vector<String>());
simT2 = new SimulationTrace("graphTestSimulationTrace", 6, (getBaseResourcesDir() + simulationTracePathFile2));
try {
Thread t1 = new Thread() {
public void run() {
try {
latencyDetailedAnalysisMain.latencyDetailedAnalysisForXML(mainGUI, simT2, false, true, 1);
} catch (XPathExpressionException | ParserConfigurationException | SAXException | IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
latencyDetailedAnalysisMain.latencyDetailedAnalysisForXML(mainGUI, simT2, false, true, 1);
} catch (XPathExpressionException | ParserConfigurationException | SAXException | IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
};
t1.start();
while (t1.getState() != Thread.State.TERMINATED) {
}
};
t1.start();
if (t1.getState() == Thread.State.TERMINATED) {
while (t1.getState() != Thread.State.TERMINATED) {
t1 = new Thread() {
public void run() {
dgraph2 = new DirectedGraphTranslator(jFrameLatencyDetailedAnalysis, cld, latencyDetailedAnalysisMain.map1,
latencyDetailedAnalysisMain.getCpanels1(), 3);
}
if (t1.getState() == Thread.State.TERMINATED) {
}
while (latencyDetailedAnalysisMain.getDgraph().getGraphsize() == 0) {
};
}
t1.start();
if (latencyDetailedAnalysisMain.getDgraph().getGraphsize() > 0) {
dgraph2 = latencyDetailedAnalysisMain.getDgraph();
while (t1.getState() != Thread.State.TERMINATED) {
checkedTransactionsFile2 = latencyDetailedAnalysisMain.getCheckedTransactionsFile();
}
}
if (t1.getState() == Thread.State.TERMINATED) {
checkedTransactionsFile2 = latencyDetailedAnalysisMain.getCheckedTransactionsFile();
}
}
}
}
}
}
......
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