示例#1
0
  @Override
  public void run(WorkspaceEntry we) {
    final Framework framework = Framework.getInstance();
    final GraphEditorPanel editor = framework.getMainWindow().getCurrentEditor();
    final ToolboxPanel toolbox = editor.getToolBox();
    final CpogSelectionTool tool = toolbox.getToolInstance(CpogSelectionTool.class);

    editor.getWorkspaceEntry().captureMemento();

    JFileChooser chooser = new JFileChooser();
    File f;
    if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {

      f = chooser.getSelectedFile();

      if (tool.insertCpogFromFile(f)) {
        editor.getWorkspaceEntry().saveMemento();
      } else {
        editor.getWorkspaceEntry().cancelMemento();
      }
    }
  }
示例#2
0
  public void run(final WorkspaceEntry we) {
    System.out.println("Verifying Model");

    Xmas xnet = (Xmas) we.getModelEntry().getMathModel();
    VisualXmas vnet = (VisualXmas) we.getModelEntry().getVisualModel();

    try {
      File cpnFile = XmasSettings.getTempVxmCpnFile();
      File inFile = XmasSettings.getTempVxmInFile();
      FileUtils.copyFile(cpnFile, inFile);

      ArrayList<String> vxmCommand = new ArrayList<>();
      vxmCommand.add(XmasSettings.getTempVxmCommandFile().getAbsolutePath());
      vxmCommand.addAll(processArg(XmasSettings.getTempVxmVsettingsFile().getAbsolutePath()));
      ExternalProcessTask.printCommandLine(vxmCommand);
      String[] cmdArray = vxmCommand.toArray(new String[vxmCommand.size()]);
      Process vxmProcess =
          Runtime.getRuntime().exec(cmdArray, null, XmasSettings.getTempVxmDirectory());

      String s, str = "";
      InputStreamReader inputStreamReader = new InputStreamReader(vxmProcess.getInputStream());
      BufferedReader stdInput = new BufferedReader(inputStreamReader);
      int n = 0;
      int test = -1;
      initHighlight(xnet, vnet);
      while ((s = stdInput.readLine()) != null) {
        if (test == -1) test = checkType(s);
        if (n > 0) str = str + s + '\n';
        n++;
        System.out.println(s);
      }
      if (level.equals("advanced")) {
        System.out.println("LEVEL IS ADVANCED ");
        File qslFile = XmasSettings.getTempVxmQslFile();
        processQsl(qslFile.getAbsolutePath());

        File equFile = XmasSettings.getTempVxmEquFile();
        str = processEq(equFile.getAbsolutePath());
      } else if (level.equals("normal") && test == 2) {
        System.out.println("LEVEL IS NORMAL ");
        File locFile = XmasSettings.getTempVxmLocFile();
        str = processLoc(locFile.getAbsolutePath());
      }
      if (test > 0) {
        if (display.equals("popup")) {
          if (!level.equals("advanced")) {
            new SolutionsDialog1(test, str);
          } else {
            new SolutionsDialog2(test, str);
          }
        }
        if (test == 2) {
          if (highlight.equals("local")) {
            localHighlight(str, xnet, vnet);
          } else if (highlight.equals("rel")) {
            relHighlight(str, xnet, vnet);
            // System.out.println("str = " + str);
            activeHighlight(xnet, vnet);
          }
        }
      } else if (test == 0) {
        if (display.equals("popup")) {
          String message = "The system is deadlock-free.";
          JOptionPane.showMessageDialog(null, message);
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    }

    // final SolutionsDialog solutionsDialog = new SolutionsDialog("hello", null);
    // GUI.centerAndSizeToParent(solutionsDialog, we.getFramework().getMainWindow());
    // solutionsDialog.setVisible(true);
    final Framework framework = Framework.getInstance();
    for (GraphEditorPanel e : framework.getMainWindow().getEditors(we)) {
      editor1 = e;
      g = (Graphics2D) e.getGraphics();
      for (int i = 0; i < 25; i++) {
        // GUI.drawEditorMessage(editor1, g, Color.RED, "hello");
      }
    }
  }