PageRenderTime 34ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 1ms

/NuSCRtoFBD/src/main/MainWindow.java

http://fbdtoverilog.googlecode.com/
Java | 1782 lines | 1447 code | 266 blank | 69 comment | 219 complexity | 9712fad02432506f1c82e27fb706c3b3 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. package main;
  2. import fsm.TransitionForFSM;
  3. import gui.CombinedDialog;
  4. import gui.VerilogShow;
  5. import gui.TwoCTable;
  6. import java.awt.BorderLayout;
  7. import java.awt.Component;
  8. import java.awt.Dimension;
  9. import java.awt.Font;
  10. import java.awt.Label;
  11. import java.awt.Point;
  12. import java.awt.event.ActionEvent;
  13. import java.awt.event.ActionListener;
  14. import java.awt.event.MouseListener;
  15. import java.awt.event.WindowAdapter;
  16. import java.awt.event.WindowEvent;
  17. import java.io.BufferedReader;
  18. import java.io.File;
  19. import java.io.FileOutputStream;
  20. import java.io.FileReader;
  21. import java.io.FileWriter;
  22. import java.io.IOException;
  23. import java.text.SimpleDateFormat;
  24. import java.util.ArrayList;
  25. import java.util.Calendar;
  26. import java.util.LinkedList;
  27. import java.util.Queue;
  28. import java.util.Stack;
  29. import javax.swing.BorderFactory;
  30. import javax.swing.BoxLayout;
  31. import javax.swing.Icon;
  32. import javax.swing.ImageIcon;
  33. import javax.swing.JButton;
  34. import javax.swing.JFileChooser;
  35. import javax.swing.JFrame;
  36. import javax.swing.JLabel;
  37. import javax.swing.JMenu;
  38. import javax.swing.JMenuBar;
  39. import javax.swing.JMenuItem;
  40. import javax.swing.JOptionPane;
  41. import javax.swing.JPanel;
  42. import javax.swing.JScrollPane;
  43. import javax.swing.JTable;
  44. import javax.swing.JTextArea;
  45. import javax.swing.JTextField;
  46. import javax.swing.JTextPane;
  47. import javax.swing.JToolBar;
  48. import javax.swing.JTree;
  49. import javax.swing.SwingUtilities;
  50. import javax.swing.border.EtchedBorder;
  51. import javax.swing.event.TreeSelectionEvent;
  52. import javax.swing.event.TreeSelectionListener;
  53. import javax.swing.table.DefaultTableCellRenderer;
  54. import javax.swing.table.TableColumn;
  55. import javax.swing.tree.DefaultMutableTreeNode;
  56. import javax.swing.tree.DefaultTreeCellRenderer;
  57. import javax.swing.tree.DefaultTreeModel;
  58. import javax.swing.tree.TreePath;
  59. import javax.xml.parsers.ParserConfigurationException;
  60. import net.infonode.docking.DockingWindow;
  61. import net.infonode.docking.DockingWindowAdapter;
  62. import net.infonode.docking.DockingWindowListener;
  63. import net.infonode.docking.RootWindow;
  64. import net.infonode.docking.SplitWindow;
  65. import net.infonode.docking.TabWindow;
  66. import net.infonode.docking.View;
  67. import net.infonode.docking.properties.RootWindowProperties;
  68. import net.infonode.docking.theme.DockingWindowsTheme;
  69. import net.infonode.docking.theme.ShapedGradientDockingTheme;
  70. import net.infonode.docking.util.DockingUtil;
  71. import net.infonode.docking.util.ViewMap;
  72. import net.infonode.docking.action.*;
  73. import org.w3c.dom.Document;
  74. import org.w3c.dom.Element;
  75. // org.w3c.dom : xml data ??? api? DOM? interface ??
  76. // .Document : XML ?? ??
  77. // .Element : XML ???? ??
  78. import parselink.VariableLinking;
  79. import parselink.XmlParsing;
  80. import sdt.ActionInformation;
  81. import tts.TransitionForTTS;
  82. import twoctable.ConditionInformationForTwoC;
  83. import twoctable.TwoCInformationAutomata;
  84. import twoctable.TwoCInformationSDT;
  85. import twoctable.TwoCTableData;
  86. import variableinformation.FODInformation;
  87. import variableinformation.FSMInformation;
  88. import variableinformation.GenericInformation;
  89. import variableinformation.GenericLinkableInformation;
  90. import variableinformation.InputInformation;
  91. import variableinformation.OutputInformation;
  92. import variableinformation.SDTInformation;
  93. import variableinformation.TTSInformation;
  94. import y.base.Edge;
  95. import y.base.Node;
  96. import y.view.EdgeRealizer;
  97. import y.view.Graph2D;
  98. import y.view.Graph2DView;
  99. import y.view.NodeRealizer;
  100. import y.view.Port;
  101. // yWorks company
  102. // y.jar graphic editor
  103. import basefbd.CombineEngine;
  104. import basefbd.CondInformation;
  105. import basefbd.DrawBlocks;
  106. import basefbd.SequenceEngine;
  107. import blockInformation.CombinedSelBlock;
  108. import blockInformation.MoveBlock;
  109. import blockInformation.MuxBlock;
  110. import blockInformation.TwoInputBlock;
  111. import candc.CandC;
  112. import com.sun.org.apache.xerces.internal.dom.DocumentImpl;
  113. import com.sun.org.apache.xml.internal.serialize.OutputFormat;
  114. import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
  115. @SuppressWarnings("serial")
  116. public class MainWindow extends JFrame {
  117. protected JTree m_tree = null;
  118. protected DefaultTreeModel m_model = null;
  119. protected JTree m_tree2 = null;
  120. protected DefaultTreeModel m_model2 = null;
  121. protected JTable m_twoCtable;
  122. protected JTable m_combinedTwoCtable;
  123. protected TwoCTableData m_tableData1;
  124. protected TwoCTableData m_tableData2;
  125. public final static String appTitle = "NuSCRtoFBD";
  126. public final static String appVer = "..";
  127. FODInformation root;
  128. XmlParsing xmlParsing;
  129. VariableLinking variableLinking;
  130. CandC candc;
  131. GenericInformation currentVariable;
  132. CombineEngine combineEngine;
  133. //Queue<CondInformation> mcondsQue = new Queue<CondInformation>();
  134. Queue<CondInformation> condsQueueLast= new LinkedList<CondInformation>(); //??? name? contents
  135. ArrayList<CombinedSelBlock> combinedSelBlocks = new ArrayList<CombinedSelBlock>(); //?? ???? ?? ??.
  136. String[] combinedStringForFBD;
  137. SequenceEngine sequenceEngine;
  138. public Stack<Object> operatorStackPre = new Stack<Object>(); //?????
  139. public Stack<Object> operatorStackOutput = new Stack<Object>();
  140. public Stack<Object> operatorStackState = new Stack<Object>();
  141. public Queue<Object> totalStackQueue = new LinkedList<Object>();
  142. //Queue<Stack<Object>> totalStackQueue = new LinkedList<Stack<object>>();
  143. Object[] levelHash; //fod total? ?? level? collection? hashtable
  144. public Queue<Label> labelColletionPre = new LinkedList<Label>(); //??, ???? ?? label collection
  145. public Queue<Label> labelColletionOutput = new LinkedList<Label>();
  146. public Queue<Label> labelColletionState = new LinkedList<Label>();
  147. public Queue<Queue<Label>> labelColletionTotal = new LinkedList<Queue<Label>>();
  148. Queue<String> outputsForSelBlock; //selblock? output
  149. Queue<String> statesForSelBlock;
  150. public Graph2DView pre_view = new Graph2DView();
  151. public Graph2DView output_view = new Graph2DView();
  152. public Graph2DView state_view = new Graph2DView();
  153. public Graph2DView total_view = new Graph2DView();
  154. boolean isSaving = false;
  155. String savePath = "a.xml";
  156. int totalLocalIdNumber=1;
  157. public static void main(String[] args) {
  158. SwingUtilities.invokeLater(new Runnable() {
  159. public void run() {
  160. try {
  161. JFrame.setDefaultLookAndFeelDecorated(true);
  162. } catch (Exception exception) {
  163. exception.printStackTrace();
  164. }
  165. new MainWindow();
  166. }
  167. });
  168. }
  169. public MainWindow() {
  170. super(appTitle);
  171. setLayout(new BorderLayout());
  172. setJMenuBar(createMenuBar());
  173. initDockingWindows();
  174. initContentsPanel();
  175. clearContents();
  176. add(mainWindow, BorderLayout.CENTER);
  177. statusLabel.setMinimumSize(new Dimension(400, 25));
  178. statusPanel.setLayout(new BoxLayout(statusPanel, BoxLayout.LINE_AXIS));
  179. statusPanel.add(statusLabel);
  180. add(statusPanel, BorderLayout.PAGE_END);
  181. this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  182. setPreferredSize(new Dimension(1500, 1000));
  183. setLocation(200, 100);
  184. pack();
  185. setVisible(true);
  186. this.addWindowListener(new WindowAdapter() {
  187. public void windowClosing(WindowEvent e) {
  188. //actionExit();
  189. }
  190. });
  191. }
  192. // settings
  193. public static String[] V_KEYWORDS = {"module", "endmodule", "assign", "input", "output", "reg", "wire", "initial", "always", "begin", "end", "posedge", "negedge", "if", "endif"};
  194. public static String[] V_KEYWORDS2 = {"assert"};
  195. // icons
  196. final static ImageIcon iconOpen = new ImageIcon("icons/open.png");
  197. final static ImageIcon iconSave = new ImageIcon("icons/save.png");
  198. final static ImageIcon iconZoomIn = new ImageIcon("icons/zoomin.png");
  199. final static ImageIcon iconZoomOut = new ImageIcon("icons/zoomout.png");
  200. final static ImageIcon iconFitToSize = new ImageIcon("icons/fittosize.png");
  201. final static ImageIcon iconChecking = new ImageIcon("icons/checking.png");
  202. final static ImageIcon iconCombined = new ImageIcon("icons/combined.png");
  203. final static ImageIcon iconSequence = new ImageIcon("icons/sequence.png");
  204. final static ImageIcon iconAbout = new ImageIcon("icons/about.png");
  205. final static ImageIcon iconFBDtoVerilog = new ImageIcon("icons/fbdtoverilog.png");
  206. // contents
  207. ActionListener actionListener = new MenuEventHandler();
  208. JToolBar toolbar = new JToolBar();
  209. JPanel topPanel = new JPanel(new BorderLayout());
  210. JPanel treePanel = new JPanel(new BorderLayout());
  211. JPanel viewPanel = new JPanel(new BorderLayout());
  212. JTextField stPathField = new JTextField();
  213. JTextField verilogPathField = new JTextField();
  214. JTextArea stTextArea = new JTextArea();
  215. JTextPane verilogTextArea = new JTextPane();
  216. JButton buttonOpen = createButton(iconOpen, "Open Data", OPEN);
  217. JButton buttonSave = createButton(iconSave, "Save Data", SAVE);
  218. JButton buttonZoomIn = createButton(iconZoomIn, "Zoom In", ZOOMIN);
  219. JButton buttonZoomOut = createButton(iconZoomOut, "Zoom Out", ZOOMOUT);
  220. JButton buttonFitToSize = createButton(iconFitToSize, "Fit to Size", FITTOSIZE);
  221. JButton buttonCheck = createButton(iconChecking, "Checking Completeness & Consistancy", CHECKING);
  222. JButton buttonCombinedText = createButton(iconCombined, "Combined Text", COMBINED);
  223. JButton buttonTotalSequence = createButton(iconSequence, "Total Sequence", SEQUENCE);
  224. JButton buttonAbout = createButton(iconAbout, "About", ABOUT);
  225. JButton buttonFBDtoVerilog = createButton(iconFBDtoVerilog,"FBD to Verilog", FBDTOVERILOG);
  226. JPanel statusPanel = new JPanel();
  227. JLabel statusLabel = new JLabel();
  228. void initContentsPanel() {
  229. int y = 38;
  230. buttonOpen.setPreferredSize(new Dimension(y, y));
  231. buttonSave.setPreferredSize(new Dimension(y, y));
  232. buttonZoomIn.setPreferredSize(new Dimension(y, y));
  233. buttonZoomOut.setPreferredSize(new Dimension(y, y));
  234. buttonFitToSize.setPreferredSize(new Dimension(y, y));
  235. buttonCheck.setPreferredSize(new Dimension(y, y));
  236. buttonCombinedText.setPreferredSize(new Dimension(y, y));
  237. buttonTotalSequence.setPreferredSize(new Dimension(y, y));
  238. buttonAbout.setPreferredSize(new Dimension(y, y));
  239. buttonFBDtoVerilog.setPreferredSize(new Dimension(y, y));
  240. stPathField.setEditable(false);
  241. verilogPathField.setEditable(false);
  242. stTextArea.setFont(new Font("Courier New", Font.PLAIN, 15));
  243. verilogTextArea.setFont(new Font("Courier New", Font.PLAIN, 15));
  244. stTextArea.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
  245. verilogTextArea.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
  246. JToolBar toolBar = new JToolBar();
  247. toolBar.add(buttonOpen);
  248. toolBar.add(buttonSave);
  249. toolBar.addSeparator();
  250. toolBar.add(buttonZoomIn);
  251. toolBar.add(buttonZoomOut);
  252. toolBar.add(buttonFitToSize);
  253. toolBar.addSeparator();
  254. toolBar.add(buttonCheck);
  255. toolBar.add(buttonCombinedText);
  256. toolBar.addSeparator();
  257. toolBar.add(buttonAbout);
  258. toolBar.setSize(38, 38);
  259. toolBar.add(buttonFBDtoVerilog);
  260. add(toolBar, "North");
  261. treePanel.add(new JScrollPane(stTextArea), BorderLayout.CENTER);
  262. viewPanel.add(new JScrollPane(verilogTextArea), BorderLayout.CENTER);
  263. }
  264. void clearContents() {
  265. msgStatus("Ready");
  266. stPathField.setText("");
  267. verilogPathField.setText("");
  268. stTextArea.setText("");
  269. verilogTextArea.setText("");
  270. closeCE();
  271. }
  272. JButton createButton(Icon icon, String toolTipText, int actionCommand) {
  273. JButton button = new JButton();
  274. button.setToolTipText(toolTipText);
  275. button.setActionCommand(new Integer(actionCommand).toString());
  276. button.addActionListener(actionListener);
  277. button.setIcon(icon);
  278. return button;
  279. }
  280. // docking window items
  281. RootWindowProperties properties = new RootWindowProperties();
  282. DockingWindowsTheme currentTheme = new ShapedGradientDockingTheme();
  283. View[] views = new View[12];
  284. ViewMap viewMap = new ViewMap();
  285. RootWindow mainWindow;
  286. RootWindow leftWindow;
  287. TabWindow windowTab;
  288. TabWindow description;
  289. TabWindow mainTab;
  290. void initDockingWindows() {
  291. views[0] = createView("Hierachy Window", new ImageIcon(""), treePanel);
  292. views[1] = createView("2CTable", new ImageIcon(""), viewPanel);
  293. views[4] = createView("Combined 2CTable", new ImageIcon(""), viewPanel);
  294. views[5] = createView("Preprocessing part FBD", new ImageIcon(""), viewPanel);
  295. views[6] = createView("Output part FBD", new ImageIcon(""), viewPanel);
  296. views[7] = createView("State variable part FBD", new ImageIcon(""), viewPanel);
  297. views[8] = createView("Total FBD", new ImageIcon(""), viewPanel);
  298. views[9] = createView("Description Window", new ImageIcon(""), viewPanel);
  299. viewMap.addView(0, views[0]);
  300. viewMap.addView(1, views[1]);
  301. mainWindow = DockingUtil.createRootWindow(viewMap, false);
  302. properties.addSuperObject(currentTheme.getRootWindowProperties());
  303. mainWindow.getRootWindowProperties().addSuperObject(properties);
  304. leftWindow = DockingUtil.createRootWindow(viewMap, false);
  305. properties.addSuperObject(currentTheme.getRootWindowProperties());
  306. leftWindow.getRootWindowProperties().addSuperObject(properties);
  307. windowTab = createTabWindow();
  308. mainTab = createTabWindow();
  309. description = createTabWindow();
  310. windowTab.addTab(views[0]);
  311. mainTab.addTab(views[1]);
  312. mainTab.addTab(views[4]);
  313. mainTab.addTab(views[5]);
  314. mainTab.addTab(views[6]);
  315. mainTab.addTab(views[7]);
  316. mainTab.addTab(views[8]);
  317. description.addTab(views[9]);
  318. //////
  319. //////
  320. mainWindow.setWindow(new SplitWindow(true, 0.2f, leftWindow, mainTab)); //??
  321. leftWindow.setWindow(new SplitWindow(false, 0.7f, windowTab, description)); //? ??
  322. setVisible(true);
  323. }
  324. View createView(String viewTitle ,Icon icon, Component component) {
  325. View view = new View( viewTitle, icon, component);
  326. view.getWindowProperties().setDragEnabled(false);
  327. view.getWindowProperties().setCloseEnabled(false);
  328. return view;
  329. }
  330. TabWindow createTabWindow() {
  331. TabWindow tab = new TabWindow();
  332. tab.getTabWindowProperties().getCloseButtonProperties().setVisible(false);
  333. tab.getWindowProperties().setDragEnabled(false);
  334. return tab;
  335. }
  336. // menu
  337. JMenuItem menuOpen,menuSave,menuZoomIn,menuZoomOut, menuCheck,menuCombinedText,menuSequence,menuAbout;
  338. JMenuBar createMenuBar() {
  339. JMenuBar menu = new JMenuBar();
  340. JMenu fileMenu = new JMenu("File");
  341. JMenu viewMenu = new JMenu("View");
  342. JMenu informationMenu = new JMenu("Information");
  343. JMenu helpMenu = new JMenu("Help");
  344. fileMenu.add(menuOpen=createMenuItem(new ImageIcon(), "Open Data", OPEN));
  345. fileMenu.add(menuSave=createMenuItem(new ImageIcon(),"Save Data",SAVE));
  346. viewMenu.add(menuZoomIn=createMenuItem(new ImageIcon(),"Zoom In",ZOOMIN));
  347. viewMenu.add(menuZoomOut=createMenuItem(new ImageIcon(),"Zoom Out",ZOOMOUT));
  348. viewMenu.add(menuZoomOut=createMenuItem(new ImageIcon(),"Fit to Size",FITTOSIZE));
  349. informationMenu.add(menuCheck=createMenuItem(new ImageIcon(),"Check C&C",OPEN));
  350. informationMenu.add(menuCombinedText=createMenuItem(new ImageIcon(),"Combined Text",OPEN));
  351. informationMenu.add(menuSequence=createMenuItem(new ImageIcon(),"Total Sequence",OPEN));
  352. helpMenu.add(menuAbout=createMenuItem(new ImageIcon(), "About", ABOUT));
  353. menu.add(fileMenu);
  354. menu.add(viewMenu);
  355. menu.add(informationMenu);
  356. menu.add(helpMenu);
  357. return menu;
  358. }
  359. JMenuItem createMenuItem(String itemText, int actionCommand) {
  360. JMenuItem menu = new JMenuItem(itemText);
  361. menu.setActionCommand(new Integer(actionCommand).toString());
  362. menu.addActionListener(actionListener);
  363. return menu;
  364. }
  365. JMenuItem createMenuItem(Icon icon, String itemText, int actionCommand) {
  366. JMenuItem menu = createMenuItem(itemText, actionCommand);
  367. menu.setIcon(icon);
  368. return menu;
  369. }
  370. public static final int OPEN = 10;
  371. public static final int SAVE = 11;
  372. public static final int ZOOMIN = 20;
  373. public static final int ZOOMOUT = 21;
  374. public static final int FITTOSIZE = 22;
  375. public static final int CHECKING = 30;
  376. public static final int COMBINED = 40;
  377. public static final int SEQUENCE = 50;
  378. public static final int ABOUT = 1;
  379. public static final int FBDTOVERILOG = 2;
  380. class MenuEventHandler implements ActionListener {
  381. public void actionPerformed(ActionEvent event) {
  382. int cmd = Integer.parseInt(event.getActionCommand());
  383. switch(cmd) {
  384. case OPEN:
  385. actionOpen();
  386. break;
  387. case SAVE:
  388. try {
  389. actionSave();
  390. } catch (ParserConfigurationException e) {
  391. e.printStackTrace();
  392. } catch (IOException e) {
  393. e.printStackTrace();
  394. }
  395. break;
  396. case ZOOMIN:
  397. actionZoomIn();
  398. break;
  399. case ZOOMOUT:
  400. actionZoomOut();
  401. break;
  402. case FITTOSIZE:
  403. actionFitToSize();
  404. break;
  405. case CHECKING:
  406. actionChecking();
  407. break;
  408. case COMBINED:
  409. actionCombined();
  410. break;
  411. case ABOUT:
  412. actionAbout();
  413. break;
  414. case FBDTOVERILOG:
  415. actionFBDtoVerilog();
  416. break;
  417. default:
  418. System.err.println("No such actinon: " + cmd);
  419. }
  420. }
  421. }
  422. // actions
  423. void actionOpen() {
  424. String[] exts = {".xml"};
  425. String filePath = getFileNameFromFileChooser(this, "Load XML", false, exts);
  426. if(filePath == null)
  427. return;
  428. xmlParsing = new XmlParsing(this);
  429. root = xmlParsing.LoadNuSCRXml(filePath);
  430. root = root.fods.get(0);
  431. variableLinking = new VariableLinking(root); //linking
  432. variableLinking.LinkVariables(root);
  433. candc = new CandC();
  434. candc.CheckCandC(root);
  435. InitTreeView();
  436. // Hierarchy Window
  437. for(int i=0;i<((FODInformation)root.fods.get(0)).fods.size();i++)
  438. {
  439. if(i==6)
  440. continue;
  441. FODInformation currentFOD = ((FODInformation)root.fods.get(0)).fods.get(i);
  442. //for(SDTInformation sdtInformation : currentFOD.sdts)
  443. //{
  444. // currentVariable = sdtInformation;
  445. // ViewTwoCTableForSDT(sdtInformation.twoCInformation);
  446. //}
  447. for(FSMInformation fsmInformation : currentFOD.fsms)
  448. {
  449. currentVariable = fsmInformation;
  450. ViewTwoCTableForAutomataForSave(fsmInformation.twoCInformationAutomata);
  451. }
  452. for(TTSInformation ttsInformation : currentFOD.ttss)
  453. {
  454. currentVariable = ttsInformation;
  455. ViewTwoCTableForAutomataForSave(ttsInformation.twoCInformationAutomata);
  456. }
  457. }
  458. }
  459. void actionSave() throws ParserConfigurationException, IOException{
  460. Document xmldoc= new DocumentImpl();
  461. Element rootElement = xmldoc.createElement("project");
  462. rootElement.setAttribute("xmlns", "http://www.plcopen.org/xml/tc6.xsd");
  463. rootElement.setAttribute("xmlns:xhtml","http://www.w3.org/1999/xhtml");
  464. rootElement.setAttribute("xmlns:xsi","http://www.w3.org/2001/XMLSchema-instance");
  465. rootElement.setAttribute("xsi:schemaLocation","c://tc6.xsd");
  466. // project attribute ? ??? ?????
  467. Element fileHeader = xmldoc.createElement("fileHeader");
  468. fileHeader.setAttribute("companyName", "KONKUKUNIV_DSLAB");
  469. fileHeader.setAttribute("productName", "nonamenow");
  470. fileHeader.setAttribute("productVersion", "1");
  471. Calendar calendar = Calendar.getInstance();
  472. SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
  473. fileHeader.setAttribute("creationDateTime", dateFormat.format(calendar.getTime()));
  474. Element contentHeader = xmldoc.createElement("contentHeader");
  475. contentHeader.setAttribute("name", "bhb");
  476. contentHeader.setAttribute("author", "bhback");
  477. contentHeader.setAttribute("modificationDateTime", dateFormat.format(calendar.getTime()));
  478. Element coordinateInfo = xmldoc.createElement("coordinateInfo");
  479. Element fbd = xmldoc.createElement("fbd");
  480. Element scaling_fbd = xmldoc.createElement("scaling");
  481. scaling_fbd.setAttribute("x", "16");
  482. scaling_fbd.setAttribute("y", "16");
  483. Element ld = xmldoc.createElement("ld");
  484. Element scaling_ld = xmldoc.createElement("scaling");
  485. scaling_ld.setAttribute("x", "16");
  486. scaling_ld.setAttribute("y", "16");
  487. Element sfc = xmldoc.createElement("sfc");
  488. Element scaling_sfc = xmldoc.createElement("scaling");
  489. scaling_sfc.setAttribute("x", "16");
  490. scaling_sfc.setAttribute("y", "16");
  491. Element types = xmldoc.createElement("types");
  492. Element dataTypes = xmldoc.createElement("dataTypes");
  493. Element pous = xmldoc.createElement("pous");
  494. Element pou = xmldoc.createElement("pou");
  495. pou.setAttribute("name", "BP_for_Test"); // BP_for_Test? ??? ??? ???
  496. pou.setAttribute("pouType", "functionBlock");
  497. Element _interface = xmldoc.createElement("interface"); // Interface ?? ?? ??. localVars, inputVars, outputVars definition
  498. Element localVars = xmldoc.createElement("localVars");
  499. localVars.setAttribute("name", "constant"); // localVars "constant" 'k_'? ???? ??? ??? constant
  500. localVars.setAttribute("constant", "true");
  501. Element inputVars = xmldoc.createElement("inputVars");
  502. Element outputVars = xmldoc.createElement("outputVars"); // How can I getting information of variables???
  503. Element body = xmldoc.createElement("body");
  504. Element FBD = xmldoc.createElement("FBD");
  505. Element instances = xmldoc.createElement("instances");
  506. Element configurations = xmldoc.createElement("configurations");
  507. for(int i=0;i<((FODInformation)root.fods.get(0)).fods.size();i++) // tctable ??
  508. {
  509. if(i==6)
  510. continue;
  511. FODInformation currentFOD = ((FODInformation)root.fods.get(0)).fods.get(i);
  512. //for(SDTInformation sdtInformation : currentFOD.sdts)
  513. //{
  514. // currentVariable = sdtInformation;
  515. // ViewTwoCTableForSDT(sdtInformation.twoCInformation);
  516. //}
  517. for(FSMInformation fsmInformation : currentFOD.fsms)
  518. {
  519. currentVariable = fsmInformation;
  520. ViewTwoCTableForAutomataForSave(fsmInformation.twoCInformationAutomata);
  521. }
  522. for(TTSInformation ttsInformation : currentFOD.ttss)
  523. {
  524. currentVariable = ttsInformation;
  525. ViewTwoCTableForAutomataForSave(ttsInformation.twoCInformationAutomata);
  526. }
  527. }
  528. this.isSaving = true;
  529. String[] exts = {".xml"};
  530. this.savePath = getFileNameFromFileChooser(this, "Save XML", false, exts);
  531. this.totalLocalIdNumber=1;
  532. for(int i=0;i<((FODInformation)root.fods.get(0)).fods.size();i++)
  533. {
  534. if(i==6)
  535. continue;
  536. currentVariable = ((FODInformation)root.fods.get(0)).fods.get(i);
  537. InitGraphicViews();
  538. DrawFunctionBlockDiagram(xmldoc, FBD);
  539. }
  540. this.totalLocalIdNumber = 1;
  541. body.appendChild(FBD);
  542. pou.appendChild(_interface);
  543. pou.appendChild(body);
  544. pous.appendChild(pou);
  545. // <interface>\
  546. _interface.appendChild(localVars);
  547. _interface.appendChild(inputVars);
  548. _interface.appendChild(outputVars);
  549. types.appendChild(dataTypes);
  550. types.appendChild(pous);
  551. fbd.appendChild(scaling_fbd);
  552. ld.appendChild(scaling_ld);
  553. sfc.appendChild(scaling_sfc);
  554. coordinateInfo.appendChild(fbd);
  555. coordinateInfo.appendChild(ld);
  556. coordinateInfo.appendChild(sfc);
  557. contentHeader.appendChild(coordinateInfo);
  558. instances.appendChild(configurations);
  559. rootElement.appendChild(fileHeader);
  560. rootElement.appendChild(contentHeader);
  561. rootElement.appendChild(types);
  562. rootElement.appendChild(instances);
  563. xmldoc.appendChild(rootElement);
  564. // Element ? child? (node)? ???? ??
  565. if(savePath.length()<4)
  566. savePath+=".xml";
  567. //String test = savePath.substring(savePath.length()-5, savePath.length()-1);
  568. if(savePath.substring(savePath.length()-4, savePath.length()).equals(".xml") == false)
  569. savePath+=".xml";
  570. FileOutputStream fos = new FileOutputStream(savePath);
  571. OutputFormat of = new OutputFormat("XML","UTF-8",true);
  572. of.setIndent(5);
  573. of.setIndenting(true);
  574. XMLSerializer serializer = new XMLSerializer(fos, of);
  575. serializer.asDOMSerializer();
  576. serializer.serialize( xmldoc.getDocumentElement());
  577. fos.close();
  578. this.isSaving = false;
  579. mainTab.setSelectedTab(0);
  580. JOptionPane.showMessageDialog(this, "Save Completed", appTitle, JOptionPane.PLAIN_MESSAGE);
  581. }
  582. void actionZoomIn()
  583. {
  584. View view = (View)mainTab.getSelectedWindow();
  585. String s = view.getTitle();
  586. if(s.equals("Preprocessing part FBD"))
  587. { pre_view.setZoom(pre_view.getZoom() * 1.2D);pre_view.updateView();}
  588. else if(s.equals("Output part FBD"))
  589. { output_view.setZoom(output_view.getZoom() * 1.2D);output_view.updateView();}
  590. else if(s.equals("State variable part FBD"))
  591. { state_view.setZoom(state_view.getZoom() * 1.2D);state_view.updateView();}
  592. else if(s.equals("Total FBD"))
  593. { total_view.setZoom(total_view.getZoom() * 1.2D);total_view.updateView();}
  594. }
  595. void actionZoomOut()
  596. {
  597. View view = (View)mainTab.getSelectedWindow();
  598. String s = view.getTitle();
  599. if(s.equals("Preprocessing part FBD"))
  600. { pre_view.setZoom(pre_view.getZoom() * 0.80000000000000004D);pre_view.updateView();}
  601. else if(s.equals("Output part FBD"))
  602. { output_view.setZoom(output_view.getZoom() * 0.80000000000000004D);output_view.updateView();}
  603. else if(s.equals("State variable part FBD"))
  604. { state_view.setZoom(state_view.getZoom() * 0.80000000000000004D);state_view.updateView();}
  605. else if(s.equals("Total FBD"))
  606. { total_view.setZoom(total_view.getZoom() * 0.80000000000000004D);total_view.updateView();}
  607. }
  608. void actionFitToSize()
  609. {
  610. View view = (View)mainTab.getSelectedWindow();
  611. String s = view.getTitle();
  612. if(s.equals("Preprocessing part FBD"))
  613. { pre_view.fitContent();pre_view.updateView();}
  614. else if(s.equals("Output part FBD"))
  615. { output_view.fitContent();output_view.updateView();}
  616. else if(s.equals("State variable part FBD"))
  617. { state_view.fitContent();state_view.updateView();}
  618. else if(s.equals("Total FBD"))
  619. { total_view.fitContent();total_view.updateView();}
  620. }
  621. void actionChecking() {
  622. if(currentVariable instanceof SDTInformation)
  623. {
  624. SDTInformation sdtInformation = (SDTInformation)currentVariable;
  625. TwoCTable messageCandC = new TwoCTable();
  626. if (sdtInformation.twoCInformation.errorMessage.equals(""))
  627. messageCandC.SetErrorText("No Error");
  628. else
  629. messageCandC.SetErrorText(sdtInformation.twoCInformation.errorMessage);
  630. if(sdtInformation.twoCInformation.warningMessage.equals(""))
  631. messageCandC.SetWarningText("No Warning");
  632. else
  633. messageCandC.SetWarningText(sdtInformation.twoCInformation.warningMessage);
  634. messageCandC.setVisible(true);
  635. }
  636. else if(currentVariable instanceof FSMInformation)
  637. {
  638. FSMInformation fsmInformation = (FSMInformation)currentVariable;
  639. TwoCTable messageCandC = new TwoCTable();
  640. if (fsmInformation.twoCInformationAutomata.errorMessage.equals(""))
  641. messageCandC.SetErrorText("No Error");
  642. else
  643. messageCandC.SetErrorText(fsmInformation.twoCInformationAutomata.errorMessage);
  644. messageCandC.SetWarningText("No Warning");
  645. messageCandC.setVisible(true);
  646. }
  647. else if (currentVariable instanceof TTSInformation)
  648. {
  649. TTSInformation ttsInformation = (TTSInformation)currentVariable;
  650. TwoCTable messageCandC = new TwoCTable();
  651. if (ttsInformation.twoCInformationAutomata.errorMessage.equals(""))
  652. messageCandC.SetErrorText("No Error");
  653. else
  654. messageCandC.SetErrorText(ttsInformation.twoCInformationAutomata.errorMessage);
  655. messageCandC.SetWarningText("No Warning");
  656. messageCandC.setVisible(true);
  657. }
  658. }
  659. void actionCombined() {
  660. CombinedDialog com = new CombinedDialog();
  661. com.setVisible(true);
  662. com.SetCombinedCondition(condsQueueLast);
  663. }
  664. void actionAbout() {
  665. JOptionPane.showMessageDialog(this, "Version " + 1.1 + "\n"
  666. + "qorgudqn@konkuk.ac.kr\n"
  667. + "Copyleft (c) 2009 konkuk university"
  668. , appTitle, JOptionPane.PLAIN_MESSAGE);
  669. }
  670. void actionFBDtoVerilog() {
  671. VerilogShow com = new VerilogShow();
  672. //com.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  673. com.setSize(700, 200);
  674. com.setVisible(true);
  675. com.setLocation(500, 200);
  676. }
  677. public void closeCE() {
  678. if(views[2] != null) views[2].close();
  679. if(views[3] != null) views[3].close();
  680. }
  681. // public methods for UI control
  682. public void msgStatus(String msg) {
  683. statusLabel.setText(msg);
  684. }
  685. public void setSTText(String str) {
  686. stTextArea.setText(str);
  687. }
  688. public void addSTText(String str) {
  689. stTextArea.append(str + "\n");
  690. }
  691. public void setVerilogText(String str) {
  692. verilogTextArea.setText(str);
  693. }
  694. public String readFile(String filePath) {
  695. String str = "";
  696. try {
  697. BufferedReader reader = new BufferedReader(new FileReader(new File(filePath)));
  698. String line;
  699. while((line = reader.readLine()) != null)
  700. str += line + "\n";
  701. } catch(IOException e) {
  702. msgStatus(e.getMessage());
  703. }
  704. return str;
  705. }
  706. public String writeFile(String filePath, String content, String ext) {
  707. File file = new File(filePath);
  708. if(file.canRead()) {
  709. int ok = JOptionPane.showConfirmDialog(this,
  710. file.getName() + " exists. Overwrite?\nCancel to rename.",
  711. "Confirm dialog", JOptionPane.OK_CANCEL_OPTION);
  712. if(ok != JOptionPane.OK_OPTION) {
  713. filePath = getFileNameFromFileChooser(this, "Load FBD", true, ext);
  714. if(filePath == null) return null;
  715. }
  716. }
  717. try {
  718. FileWriter fw = new FileWriter(filePath);
  719. fw.write(content, 0, content.length());
  720. fw.flush();
  721. fw.close();
  722. } catch (IOException e) {
  723. msgStatus(e.getMessage());
  724. }
  725. return filePath;
  726. }
  727. public String getFileNameFromFileChooser(Component parent, String title, boolean isSave, String ext) {
  728. String[] exts = new String[1];
  729. exts[0] = ext;
  730. return getFileNameFromFileChooser(parent, title, isSave, exts);
  731. }
  732. public String getFileNameFromFileChooser(Component parent, String title, boolean isSave, String[] exts) {
  733. JFileChooser fileChooser = new JFileChooser(".");
  734. fileChooser.setDialogTitle(title);
  735. ExtFilter defaultFilter = new ExtFilter(exts[0]);
  736. for(int i=1; i<exts.length; i++)
  737. fileChooser.addChoosableFileFilter(new ExtFilter(exts[i]));
  738. fileChooser.setFileFilter(defaultFilter);
  739. int userCommand;
  740. if(isSaving) {
  741. fileChooser.setDialogType( JFileChooser.SAVE_DIALOG);
  742. userCommand = fileChooser.showSaveDialog(parent);
  743. } else {
  744. fileChooser.setDialogType( JFileChooser.OPEN_DIALOG);
  745. userCommand = fileChooser.showOpenDialog(parent);
  746. }
  747. if(userCommand == JFileChooser.CANCEL_OPTION)
  748. return null;
  749. else {
  750. String filename = fileChooser.getSelectedFile().getAbsolutePath();
  751. return filename;
  752. }
  753. }
  754. public void InitTreeView()
  755. {
  756. DefaultMutableTreeNode top = new DefaultMutableTreeNode(root.name);
  757. DefaultMutableTreeNode parent = top;
  758. Object[] nodes = new Object[xmlParsing.nodeCount+1];
  759. int count=0;
  760. nodes[0] = root;
  761. for(FODInformation fodInformation : root.fods) //????? ?? variable?? tree? ???.
  762. ShowNextNode(fodInformation,parent,nodes,count);
  763. for(SDTInformation sdtInformation : root.sdts)
  764. ShowNextNode(sdtInformation, parent,nodes,count);
  765. for(FSMInformation fsmInformation : root.fsms)
  766. ShowNextNode(fsmInformation, parent,nodes,count);
  767. for (TTSInformation ttsInformation : root.ttss)
  768. ShowNextNode(ttsInformation, parent,nodes,count);
  769. m_model = new DefaultTreeModel(top); //? ?? ?? ???? ??? ??.
  770. m_tree = new JTree(m_model);
  771. DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
  772. m_tree.setCellRenderer(renderer);
  773. m_tree.setShowsRootHandles(true);
  774. m_tree.setEditable(false);
  775. m_tree.setVisible(true);
  776. m_tree.addTreeSelectionListener(new NodeSelectionListener());
  777. m_tree.validate();
  778. JScrollPane s = new JScrollPane();
  779. s.getViewport().add(m_tree);
  780. views[0] = createView("Hierachy Window", new ImageIcon(""), s);
  781. windowTab = createTabWindow();
  782. windowTab.addTab(views[0]);
  783. mainWindow.setWindow(new SplitWindow(true, 0.2f, leftWindow, mainTab));
  784. leftWindow.setWindow(new SplitWindow(false, 0.7f, windowTab, description));
  785. }
  786. public void SetDescriptionNodes()
  787. {
  788. DefaultMutableTreeNode top = new DefaultMutableTreeNode(currentVariable.name);
  789. DefaultMutableTreeNode parent = top;
  790. DefaultMutableTreeNode childDescription = new DefaultMutableTreeNode("Description");
  791. for(String s : currentVariable.description)
  792. {
  793. if(s.equals("")==false)
  794. {
  795. DefaultMutableTreeNode c = new DefaultMutableTreeNode(s);
  796. childDescription.add(c);
  797. }
  798. }
  799. DefaultMutableTreeNode childTemplateNumber = new DefaultMutableTreeNode("Template Number");
  800. for(String s : currentVariable.templeteNumber)
  801. {
  802. if(s.equals("")==false)
  803. {
  804. DefaultMutableTreeNode c = new DefaultMutableTreeNode(s);
  805. childTemplateNumber.add(c);
  806. }
  807. }
  808. DefaultMutableTreeNode childInput = new DefaultMutableTreeNode("Input");
  809. if(currentVariable instanceof FODInformation)
  810. {
  811. for(InputInformation i : currentVariable.inputs)
  812. {
  813. if(i.name.equals("")==false)
  814. {
  815. DefaultMutableTreeNode c = new DefaultMutableTreeNode(i.name);
  816. childInput.add(c);
  817. }
  818. }
  819. }
  820. else if(currentVariable instanceof SDTInformation)
  821. {
  822. for(GenericLinkableInformation g : ((SDTInformation)currentVariable).inputsForSDT)
  823. {
  824. DefaultMutableTreeNode c = new DefaultMutableTreeNode(g.name);
  825. childInput.add(c);
  826. }
  827. }
  828. else if(currentVariable instanceof FSMInformation)
  829. {
  830. for(GenericLinkableInformation g : ((FSMInformation)currentVariable).inputsForFSM)
  831. {
  832. DefaultMutableTreeNode c = new DefaultMutableTreeNode(g.name);
  833. childInput.add(c);
  834. }
  835. }
  836. else if(currentVariable instanceof TTSInformation)
  837. {
  838. for(GenericLinkableInformation g : ((TTSInformation)currentVariable).inputsForTTS)
  839. {
  840. DefaultMutableTreeNode c = new DefaultMutableTreeNode(g.name);
  841. childInput.add(c);
  842. }
  843. }
  844. DefaultMutableTreeNode childOutput = new DefaultMutableTreeNode("Output");
  845. if(currentVariable instanceof FODInformation)
  846. {
  847. for(OutputInformation o : currentVariable.outputs)
  848. {
  849. if(o.name.equals("")==false)
  850. {
  851. DefaultMutableTreeNode c = new DefaultMutableTreeNode(o.name);
  852. childOutput.add(c);
  853. }
  854. }
  855. }
  856. else if(currentVariable instanceof SDTInformation)
  857. {
  858. DefaultMutableTreeNode c = new DefaultMutableTreeNode(((SDTInformation)currentVariable).name);
  859. childOutput.add(c);
  860. }
  861. else if(currentVariable instanceof FSMInformation)
  862. {
  863. DefaultMutableTreeNode c = new DefaultMutableTreeNode(((FSMInformation)currentVariable).name);
  864. childOutput.add(c);
  865. }
  866. else if(currentVariable instanceof TTSInformation)
  867. {
  868. DefaultMutableTreeNode c = new DefaultMutableTreeNode(((TTSInformation)currentVariable).name);
  869. childOutput.add(c);
  870. }
  871. DefaultMutableTreeNode childConstant = new DefaultMutableTreeNode("Constant");
  872. for(String s : currentVariable.constants)
  873. {
  874. DefaultMutableTreeNode c = new DefaultMutableTreeNode(s);
  875. childConstant.add(c);
  876. }
  877. DefaultMutableTreeNode childLocalClockVariable = new DefaultMutableTreeNode("Local Clock Variable");
  878. for(String s : currentVariable.localClockVarialbles)
  879. {
  880. if(s.equals("")==false)
  881. {
  882. DefaultMutableTreeNode c = new DefaultMutableTreeNode(s);
  883. childLocalClockVariable.add(c);
  884. }
  885. }
  886. DefaultMutableTreeNode childPreviousStateVariable = new DefaultMutableTreeNode("Previous State Variable");
  887. if(currentVariable.previousStateVariable.equals("")==false)
  888. {
  889. DefaultMutableTreeNode c = new DefaultMutableTreeNode(currentVariable.previousStateVariable);
  890. childPreviousStateVariable.add(c);
  891. }
  892. DefaultMutableTreeNode childMemoriazableVariable = new DefaultMutableTreeNode("Memoriazable Variable Of External Input");
  893. for(String s : currentVariable.momoriazbleVariableofExternalinputs)
  894. {
  895. if(s.equals("")==false)
  896. {
  897. DefaultMutableTreeNode cc = new DefaultMutableTreeNode(s);
  898. childMemoriazableVariable.add(cc);
  899. }
  900. }
  901. parent.add(childDescription);
  902. parent.add(childTemplateNumber);
  903. parent.add(childInput);
  904. parent.add(childOutput);
  905. parent.add(childConstant);
  906. parent.add(childLocalClockVariable);
  907. parent.add(childPreviousStateVariable);
  908. parent.add(childMemoriazableVariable);
  909. m_model2 = new DefaultTreeModel(top); //? ?? ?? ???? ??? ??.
  910. m_tree2 = new JTree(m_model2);
  911. DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
  912. m_tree2.setCellRenderer(renderer);
  913. m_tree2.setShowsRootHandles(true);
  914. m_tree2.setEditable(false);
  915. m_tree2.setVisible(true);
  916. m_tree2.addTreeSelectionListener(new NodeSelectionListener());
  917. m_tree2.validate();
  918. JScrollPane s = new JScrollPane();
  919. s.getViewport().add(m_tree2);
  920. views[9] = createView("Description Window", new ImageIcon(""), s);
  921. description = createTabWindow();
  922. description.addTab(views[9]);
  923. mainWindow.setWindow(new SplitWindow(true, 0.2f, leftWindow, mainTab));
  924. leftWindow.setWindow(new SplitWindow(false, 0.7f, windowTab, description));
  925. }
  926. public void ShowNextNode(GenericInformation genericInformation,DefaultMutableTreeNode parentTreeNode,Object[] nodes,int count)
  927. {
  928. DefaultMutableTreeNode child = new DefaultMutableTreeNode(genericInformation.name);
  929. parentTreeNode.add(child);
  930. count++;
  931. if (genericInformation instanceof FODInformation)
  932. {
  933. FODInformation fodInformation= (FODInformation)genericInformation;
  934. for (FODInformation fod : fodInformation.fods)
  935. {
  936. nodes[count] = fod;
  937. ShowNextNode(fod, child,nodes,count);
  938. }
  939. for (SDTInformation sdt : fodInformation.sdts)
  940. {
  941. nodes[count] = sdt;
  942. ShowNextNode(sdt, child,nodes,count);
  943. }
  944. for (FSMInformation fsm : fodInformation.fsms)
  945. {
  946. nodes[count] = fsm;
  947. ShowNextNode(fsm, child,nodes,count);
  948. }
  949. for (TTSInformation tts : fodInformation.ttss)
  950. {
  951. nodes[count] = tts;
  952. ShowNextNode(tts, child,nodes,count);
  953. }
  954. }
  955. }
  956. public void InitTwoCViewForSDT(int contentCount,TwoCInformationSDT twoCInformation) //colum??
  957. {
  958. int count = 0;
  959. DefaultTableCellRenderer r = new DefaultTableCellRenderer();
  960. r.setHorizontalAlignment(JLabel.LEFT);
  961. m_tableData1 = new TwoCTableData();
  962. m_tableData2 = new TwoCTableData();
  963. m_twoCtable = new JTable();
  964. m_twoCtable.setAutoCreateColumnsFromModel(false);
  965. m_twoCtable.setModel(m_tableData1);
  966. TableColumn column1 = new TableColumn(count, 500, r, null);
  967. m_twoCtable.addColumn(column1);
  968. m_combinedTwoCtable = new JTable();
  969. m_combinedTwoCtable.setAutoCreateColumnsFromModel(false);
  970. m_combinedTwoCtable.setModel(m_tableData2);
  971. TableColumn column2 = new TableColumn(count, 500, r, null);
  972. m_combinedTwoCtable.addColumn(column2);
  973. count++;
  974. int colcount=0;
  975. for(int i=0;i<contentCount;i++)
  976. {
  977. if(twoCInformation.conditionContents[0][i]==null)
  978. break;
  979. if(twoCInformation.conditionContents[0][i].equals("T"))
  980. colcount++;
  981. else if(twoCInformation.conditionContents[0][i].equals("F"))
  982. colcount++;
  983. else if(twoCInformation.conditionContents[0][i].equals("-"))
  984. colcount+=2;
  985. }
  986. for (; colcount > 0; colcount--)
  987. {
  988. DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
  989. renderer.setHorizontalAlignment(JLabel.CENTER);
  990. TableColumn column11 = new TableColumn(count, 60, renderer, null);
  991. m_twoCtable.addColumn(column11);
  992. TableColumn column22= new TableColumn(count, 60, renderer, null);
  993. m_combinedTwoCtable.addColumn(column22);
  994. count++;
  995. }
  996. JScrollPane s = new JScrollPane();
  997. s.getViewport().add(m_twoCtable);
  998. JScrollPane ss = new JScrollPane();
  999. ss.getViewport().add(m_combinedTwoCtable);
  1000. views[1] = createView("2CTable", new ImageIcon(""), s);
  1001. views[4] = createView("Combined 2CTable",new ImageIcon(""),ss);
  1002. mainTab = createTabWindow();
  1003. mainTab.addTab(views[1]);
  1004. mainTab.addTab(views[4]);
  1005. mainTab.addTab(views[5]);
  1006. mainTab.addTab(views[6]);
  1007. mainTab.addTab(views[7]);
  1008. mainTab.addTab(views[8]);
  1009. mainTab.setSelectedTab(0);
  1010. mainWindow.setWindow(new SplitWindow(true, 0.2f, leftWindow, mainTab));
  1011. leftWindow.setWindow(new SplitWindow(false, 0.7f, windowTab, description));
  1012. }
  1013. public void InitTwoCViewForAutomata(int contentCount) //colum??
  1014. {
  1015. int count = 0;
  1016. DefaultTableCellRenderer r = new DefaultTableCellRenderer();
  1017. r.setHorizontalAlignment(JLabel.LEFT);
  1018. m_tableData1 = new TwoCTableData();
  1019. m_tableData2 = new TwoCTableData();
  1020. m_twoCtable = new JTable();
  1021. m_twoCtable.setAutoCreateColumnsFromModel(false);
  1022. m_twoCtable.setModel(m_tableData1);
  1023. TableColumn column1 = new TableColumn(count, 500, r, null);
  1024. m_twoCtable.addColumn(column1);
  1025. m_combinedTwoCtable = new JTable();
  1026. m_combinedTwoCtable.setAutoCreateColumnsFromModel(false);
  1027. m_combinedTwoCtable.setModel(m_tableData2);
  1028. TableColumn column2 = new TableColumn(count, 500, r, null);
  1029. m_combinedTwoCtable.addColumn(column2);
  1030. count++;
  1031. for (; contentCount > 0; contentCount--)
  1032. {
  1033. DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
  1034. renderer.setHorizontalAlignment(JLabel.CENTER);
  1035. TableColumn column11 = new TableColumn(count, 50, renderer, null);
  1036. m_twoCtable.addColumn(column11);
  1037. TableColumn column22= new TableColumn(count, 50, renderer, null);
  1038. m_combinedTwoCtable.addColumn(column22);
  1039. count++;
  1040. }
  1041. JScrollPane s = new JScrollPane();
  1042. s.getViewport().add(m_twoCtable);
  1043. JScrollPane ss = new JScrollPane();
  1044. ss.getViewport().add(m_combinedTwoCtable);
  1045. views[1] = createView("2CTable", new ImageIcon(""), s);
  1046. views[4] = createView("Combined 2CTable",new ImageIcon(""),ss);
  1047. mainTab = createTabWindow();
  1048. mainTab.addTab(views[1]);
  1049. mainTab.addTab(views[4]);
  1050. mainTab.addTab(views[5]);
  1051. mainTab.addTab(views[6]);
  1052. mainTab.addTab(views[7]);
  1053. mainTab.addTab(views[8]);
  1054. mainTab.setSelectedTab(0);
  1055. MouseListener l = null;
  1056. views[8].addMouseListener(l);
  1057. mainWindow.setWindow(new SplitWindow(true, 0.2f, leftWindow, mainTab));
  1058. leftWindow.setWindow(new SplitWindow(false, 0.7f, windowTab, description));
  1059. }
  1060. public void actionPerformed(ActionEvent e){
  1061. }
  1062. public void ViewTwoCTableForSDT(TwoCInformationSDT twoCInformation) //list view? ??
  1063. {
  1064. InitTwoCViewForSDT(twoCInformation.conditionContents[0].length-1,twoCInformation);
  1065. for (int i=0;i<twoCInformation.conditionContents.length ;i++ )
  1066. {
  1067. ArrayList<String> array = new ArrayList<String>();
  1068. int x=0;
  1069. array.add(twoCInformation.conditionContents[i][0]);
  1070. for (int j=1;j<twoCInformation.conditionContents[i].length ;j++ )
  1071. array.add(twoCInformation.conditionContents[i][j]);
  1072. String[] ss = new String[array.size()];
  1073. for(String s : array)
  1074. { ss[x++] = s; }
  1075. m_tableData1.m_vector.addElement(ss);
  1076. }
  1077. m_tableData1.m_vector.addElement(new String[]{"Action","Action"});
  1078. for (int i=0;i<twoCInformation.actionContents.length ;i++ )
  1079. {
  1080. ArrayList<String> array = new ArrayList<String>();
  1081. int x=0;
  1082. array.add(twoCInformation.actionContents[i][0]);
  1083. for (int j=1;j<twoCInformation.actionContents[i].length ;j++ )
  1084. array.add(twoCInformation.actionContents[i][j]);
  1085. String[] ss = new String[array.size()];
  1086. for(String s : array)
  1087. { ss[x++] = s; }
  1088. m_tableData1.m_vector.addElement(ss);
  1089. }
  1090. //****************************************************************************************
  1091. //combined ? ??.
  1092. String[] conditions = new String[twoCInformation.conditionContents.length]; //?? ?? ??
  1093. for (int i=0;i<twoCInformation.conditionContents.length ;i++ )
  1094. conditions[i] = twoCInformation.conditionContents[i][0];
  1095. combineEngine = new CombineEngine();
  1096. condsQueueLast = new LinkedList<CondInformation>();
  1097. combineEngine.MakeCond(conditions,condsQueueLast); //combine
  1098. for (int i=0;i<twoCInformation.conditionContents.length ;i++ )
  1099. {
  1100. ArrayList<String> array = new ArrayList<String>();
  1101. int x=0;
  1102. array.add(conditions[i]);
  1103. for (int j=1;j<twoCInformation.conditionContents[i].length ;j++ )
  1104. array.add(twoCInformation.conditionContents[i][j]);
  1105. String[] ss = new String[array.size()];
  1106. for(String s : array)
  1107. { ss[x++] = s; }
  1108. m_tableData2.m_vector.addElement(ss);
  1109. }
  1110. m_tableData2.m_vector.addElement(new String[]{"Action","Action"});
  1111. for (int i=0;i<twoCInformation.actionContents.length ;i++ )
  1112. {
  1113. ArrayList<String> array = new ArrayList<String>();
  1114. int x=0;
  1115. array.add(twoCInformation.actionContents[i][0]);
  1116. for (int j=1;j<twoCInformation.actionContents[i].length ;j++ )
  1117. array.add(twoCInformation.actionContents[i][j]);
  1118. String[] ss = new String[array.size()];
  1119. for(String s : array)
  1120. { ss[x++] = s; }
  1121. m_tableData2.m_vector.addElement(ss);
  1122. }
  1123. //output????.
  1124. twoCInformation.outputString = twoCInformation.actionContents[0][0].substring(0, twoCInformation.actionContents[0][0].indexOf(':'));
  1125. twoCInformation.outputString =twoCInformation.outputString.replace("\n", "");
  1126. //*******************************************************************************************
  1127. //???? ?? action?? condition ??.
  1128. //*******************************************************************************************
  1129. String selBlockString = "(";
  1130. combinedSelBlocks.clear();
  1131. for (int i=1;i<twoCInformation.conditionContents[0].length ;i++ )
  1132. {
  1133. for (int j=0;j<twoCInformation.conditionContents.length ;j++ )
  1134. {
  1135. if(j==0)
  1136. {
  1137. if(twoCInformation.conditionContents[j].length<=i)
  1138. continue;
  1139. if ( twoCInformation.conditionContents[j][i] == null||twoCInformation.conditionContents[j][i].equals("")||twoCInformation.conditionContents[j][i].equals(" "))
  1140. break;
  1141. if(twoCInformation.conditionContents[j][i].equals("T"))
  1142. selBlockString +="("+conditions[j]+")";
  1143. else
  1144. selBlockString += "!" + "(" + conditions[j] + ")";
  1145. }
  1146. else
  1147. {
  1148. if (twoCInformation.conditionContents[j][i] == null||twoCInformation.conditionContents[j][i].equals(""))
  1149. break;
  1150. if(twoCInformation.conditionContents[j][i].equals("T"))
  1151. selBlockString += "&" + "(" + conditions[j] + ")";
  1152. else
  1153. selBlockString += "&!" + "(" + conditions[j] + ")";
  1154. }
  1155. if (twoCInformation.conditionContents[j][i] == null||twoCInformation.conditionContents[j][i].equals(""))
  1156. {
  1157. selBlockString = "(";
  1158. break;
  1159. }
  1160. }
  1161. if(selBlockString.equals("("))
  1162. continue;
  1163. selBlockString += ")";
  1164. String output = "";
  1165. boolean startFlag = false;
  1166. for(int j=0;j<twoCInformation.actionContents.length;j++)
  1167. {
  1168. if(twoCInformation.actionContents[j].length<=i)
  1169. continue;
  1170. if(twoCInformation.actionContents[j][i]==null)
  1171. continue;
  1172. if(twoCInformation.actionContents[j][i].equals("O")||twoCInformation.act

Large files files are truncated, but you can click here to view the full file