public void setResponsesPanel(QTIContainerResponsesProcessingPanel jpResp) {
   jTabbedPane1.addTab(
       Messages.getLocalizedString("Evaluation"),
       null,
       jpResp,
       Messages.getLocalizedString("NotebookEvaluation"));
 }
 public static EventSounds getEventSounds(
     EventSounds initialValue, Options options, Component parent, MediaBagEditor mbe) {
   EventSounds result = null;
   Messages msg = options.getMessages();
   EventSoundsEditorPanel evsed = dlgPanels.get(options);
   if (evsed == null) {
     // mbep=(MediaBagMultiEditorPanel)mbe.createEditorPanel(options);
     evsed = new EventSoundsEditorPanel(options, mbe);
     // evsed.setPreferredSize(new java.awt.Dimension(500, 500));
     dlgPanels.put(options, evsed);
   }
   evsed.setEventSounds((EventSounds) initialValue.clone());
   boolean b = msg.showInputDlg(parent, evsed, "edit_evsounds_dlg_title");
   if (b) {
     result = evsed.getEventSounds();
   }
   return result;
 }
Beispiel #3
0
  public FressaFunctions(Options options) {

    msg = options.getMessages(BUNDLE);

    try {
      robot = new Robot();
    } catch (java.awt.AWTException ex) {
      System.err.println("Unable to create java.awt.Robot: " + ex.getMessage());
    }

    formExchange = new TFormExchange(INITIAL_FORM_EXCHANGE_POS, msg.get("acc_exchangeBtnChar"));
    formKeyboard = new TFormKeyboard(options, this);

    noHandCursor = options.getBoolean(NO_HAND_CURSOR, false);
    forceRectangularShapes = options.getBoolean(FORCE_RECTANGLES, false);

    scanTimerSpan = options.getInt(SCAN_TIMER_SPAN, DEFAULT_TIMER_SPAN);
    scanIncludingArrowButtons = options.getBoolean(SCAN_INCLUDING_ARROWS, true);
    withChangeZoneButton = options.getBoolean(CHANGE_ZONE_BUTTON, false);
    scanArrowsAtEndOfActivity = options.getBoolean(SCAN_ARROWS_AT_END, false);
    scanFlagButton = options.getBoolean(SCAN_FLAG, false);
    jumpWellPlaced = options.getBoolean(JUMP_WELL_PLACED, true);
    showKeyboard = options.getBoolean(SHOW_KEYBOARD, true);
    changeZoneIfNoClick = options.getBoolean(CHANGE_ZONE_IF_NO_CLICK, false);
    autoScanOnStart = options.getBoolean(AUTO_SCAN_ON_START, false);
    directedScanOnStart = options.getBoolean(DIRECTED_SCAN_ON_START, false);
    autoAutoScan = options.getBoolean(AUTO_AUTO_SCAN, false);
    withSwaying = options.getBoolean(SWAYING, false);
    readLabels = options.getBoolean(READ_LABELS, false);
    withVoice = options.getBoolean(WITH_VOICE, false);

    if (withVoice) {
      /*
      fressaVoice=new FressaVoice();
      fressaVoice.start();
      readText(msg.get("acc_voiceGreeting"));
      withVoice=fressaVoice.xxxxrunning;
       */
    }
  }
 public void setInformationPanel(QTIInformationPanel jpInfoPanel) {
   jTabbedPane1.addTab(Messages.getLocalizedString("Information"), null, jpInfoPanel, "");
 }
 //// public void setPresentationPanel(QTIMaterialPanel jpQTIMatPanel){
 public void setPresentationPanel(javax.swing.JPanel jpQTIMatPanel) {
   jTabbedPane1.addTab(Messages.getLocalizedString("Presentation"), null, jpQTIMatPanel, "");
 }
Beispiel #6
0
  public static String[] prompt(
      ResourceBridge rb,
      Component parent,
      String inputPath,
      String exportBasePath,
      String scormBasePath) {
    String[] result = null;
    ExportToJSDlg exportDlg = new ExportToJSDlg(rb);
    Messages msg = rb.getOptions().getMessages();
    String inputBase = (new File(inputPath)).getName();
    exportDlg.outputFolder = (new File(new File(exportBasePath), inputBase)).getPath();
    exportDlg.scormFile = (new File(new File(scormBasePath), inputBase + ".scorm.zip")).getPath();
    exportDlg.fillData();
    while (result == null) {
      if (!msg.showInputDlg(parent, exportDlg, "export_project_title")) {
        break;
      }
      exportDlg.getData();
      if (exportDlg.outputFolder == null) {
        msg.showErrorWarning(parent, "export_project_err_empty", null);
      } else {
        try {
          boolean folderOk = true;
          boolean scormOk = true;

          File outputFolderFile = new File(exportDlg.outputFolder);

          if (exportDlg.outputFolder.equals(inputPath)) {
            msg.showErrorWarning(parent, "export_project_err_sameFolder", null);
            folderOk = false;
          } else if (exportDlg.outputFolder.startsWith(inputPath)) {
            msg.showErrorWarning(parent, "export_project_err_nestedFolders", null);
            folderOk = false;
          } else if (outputFolderFile.exists() && outputFolderFile.isDirectory()) {
            if (outputFolderFile.list().length > 0) {
              folderOk =
                  msg.showQuestionDlg(parent, "export_project_warning_noEmptyFolder", null, "yn")
                      == Messages.YES;
            }
          } else if (!outputFolderFile.mkdirs()) {
            msg.showErrorWarning(parent, "edit_new_project_err_folderCreation", null);
            folderOk = false;
          }

          if (folderOk && exportDlg.exportScorm) {
            if (exportDlg.scormFile == null) {
              msg.showErrorWarning(parent, "export_project_scorm_file_err_empty", null);
              scormOk = false;
            } else {
              File scormFile = new File(exportDlg.scormFile);
              if (scormFile.exists()) {
                scormOk =
                    msg.showQuestionDlg(parent, "export_project_scorm_file_exists", null, "yn")
                        == Messages.YES;
              } else if (!scormFile.getParentFile().exists()
                  && !scormFile.getParentFile().mkdirs()) {
                msg.showErrorWarning(parent, "edit_new_project_err_folderCreation", null);
                scormOk = false;
              }
            }
          }

          if (folderOk && scormOk) {
            result =
                new String[] {
                  exportDlg.outputFolder,
                  inputPath,
                  exportDlg.exportAll ? "true" : "false",
                  exportDlg.exportScorm ? exportDlg.scormFile : null
                };
          }
        } catch (Exception ex) {
          msg.showErrorWarning(parent, "ERROR", ex);
        }
      }
    }
    return result;
  }
Beispiel #7
0
  public static void doTask(
      ResourceBridge rb,
      AuthorSettings settings,
      Component parent,
      final String inputPath,
      final String outputPath,
      final String mainFileName,
      final JClicProject project,
      final boolean copyAll,
      final String scormFile) {

    final Messages msg = rb.getOptions().getMessages();
    final ExportTaskDlg exportDlg = new ExportTaskDlg(rb);
    final AuthorSettings set = settings;

    JDialog dlg = new JDialog(JOptionPane.getFrameForComponent(parent), true);
    dlg.setTitle(msg.get("export_project_exporting"));
    dlg.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    dlg.getContentPane().setLayout(new BorderLayout(10, 10));
    dlg.getContentPane().add(exportDlg, BorderLayout.CENTER);
    dlg.pack();
    dlg.setLocationRelativeTo(parent);
    dlg.setLocation(
        (parent.getWidth() - dlg.getWidth()) / 2, (parent.getHeight() - dlg.getHeight()) / 2);

    exportDlg.sw =
        new edu.xtec.util.SwingWorker() {

          @Override
          public Object construct() {
            try {

              ArrayList<String> fileList = new ArrayList<String>();
              fileList.add("imsmanifest.xml");

              if (!copyAll) {
                exportDlg.ps.println("Processing: " + inputPath);
                ProjectFileUtils.processSingleFile(inputPath, outputPath, fileList, exportDlg.ps);
              } else {
                exportDlg.ps.println("Processing all projects in: " + inputPath);
                ProjectFileUtils.processRootFolder(inputPath, outputPath, fileList, exportDlg.ps);
              }

              exportDlg.ps.println("Generating file " + outputPath + "/index.html");
              FileOutputStream fos = new FileOutputStream(new File(outputPath, "index.html"));
              PrintWriter pw = new PrintWriter(new OutputStreamWriter(fos, "UTF-8"));
              String s = indexHtml.replaceAll("%TITLE%", StrUtils.safeHtml(project.settings.title));
              s = StrUtils.replace(s, "%MAINFILE%", mainFileName);
              s = StrUtils.replace(s, "%JSCODEBASE%", set.jsCodeBase);
              pw.print(s);
              pw.flush();
              pw.close();
              fileList.add("index.html");

              JSONObject json = project.settings.toJSON(msg);
              json.put("mainFile", mainFileName);

              exportDlg.exportPath = new File(outputPath);

              String fn = "favicon.ico";
              exportDlg.ps.println("Copying " + fn);
              StreamIO.writeStreamTo(
                  getClass().getResourceAsStream("/edu/xtec/resources/icons/" + fn),
                  new FileOutputStream(new File(outputPath, fn)));
              fileList.add(fn);

              fn = "icon-192.png";
              exportDlg.ps.println("Copying " + fn);
              StreamIO.writeStreamTo(
                  getClass().getResourceAsStream("/edu/xtec/resources/icons/" + fn),
                  new FileOutputStream(new File(outputPath, fn)));
              fileList.add(fn);

              fn = "icon-72.png";
              exportDlg.ps.println("Copying " + fn);
              StreamIO.writeStreamTo(
                  getClass().getResourceAsStream("/edu/xtec/resources/icons/" + fn),
                  new FileOutputStream(new File(outputPath, fn)));
              fileList.add(fn);

              exportDlg.ps.println("Copying project cover model");
              StreamIO.writeStreamTo(
                  getClass().getResourceAsStream("/edu/xtec/resources/icons/cover-base.jpg"),
                  new FileOutputStream(new File(outputPath, "project-cover.jpg")));
              fileList.add("project-cover.jpg");
              json.put("cover", "project-cover.jpg");

              exportDlg.ps.println("Copying project thumbnail model");
              StreamIO.writeStreamTo(
                  getClass().getResourceAsStream("/edu/xtec/resources/icons/thumb-base.jpg"),
                  new FileOutputStream(new File(outputPath, "project-thumb.jpg")));
              fileList.add("project-thumb.jpg");
              json.put("thumbnail", "project-thumb.jpg");

              exportDlg.ps.println("Generating project.json");
              fileList.add("project.json");

              // Order fileList and remove duplicate values
              Collections.sort(fileList);
              fileList = new ArrayList<String>(new LinkedHashSet<String>(fileList));
              json.append("files", fileList);

              fos = new FileOutputStream(new File(outputPath, "project.json"));
              pw = new PrintWriter(new OutputStreamWriter(fos, "UTF-8"));
              pw.print(json.toString(2));
              pw.flush();
              pw.close();

              exportDlg.ps.println("Generating imsmanifest.xml");
              fos = new FileOutputStream(new File(outputPath, "imsmanifest.xml"));
              pw = new PrintWriter(new OutputStreamWriter(fos, "UTF-8"));
              s = imsmanifest.replaceAll("%SCORMTITLE%", StrUtils.safeHtml(project.settings.title));
              s =
                  StrUtils.replace(
                      s,
                      "%SCORMID%",
                      "JClic-"
                          + Integer.toHexString((int) (Math.random() * 0xEFFFFF + 0x100000))
                              .toUpperCase());
              StringBuilder sb = new StringBuilder();
              ListIterator<String> it = fileList.listIterator();
              while (it.hasNext()) {
                sb.append("   <file href=\"").append(it.next()).append("\"/>\n");
              }
              s = StrUtils.replace(s, "%FILETAGS%", sb.toString());
              pw.print(s);
              pw.flush();
              pw.close();

              if (scormFile != null) {
                final byte[] BUFFER = new byte[1024];
                exportDlg.ps.println(
                    "Generating file \"" + scormFile + "\" with all content inside");

                ZipOutputStream out = new ZipOutputStream(new FileOutputStream(scormFile));
                it = fileList.listIterator();
                while (it.hasNext()) {
                  String file = it.next();
                  FileInputStream in = new FileInputStream(new File(outputPath, file));
                  ZipEntry entry = new ZipEntry(file);
                  out.putNextEntry(entry);
                  int i;
                  while ((i = in.read(BUFFER)) != -1) {
                    out.write(BUFFER, 0, i);
                  }
                  out.closeEntry();
                }
                out.close();
              }

              exportDlg.ps.println("\n" + msg.get("export_project_finished") + " " + outputPath);

              exportDlg.ps.println("\n" + msg.get("export_project_notice"));

              if (scormFile != null) {
                exportDlg.ps.printf(
                    "\n" + msg.get("export_project_scorm_notice") + "\n\n", scormFile);
              }

              exportDlg.browserBtn.setEnabled(true);

            } catch (InterruptedException iex) {
              exportDlg.ps.println(
                  "\nWARNING: The process was interrupted! Contents of the output folder might be unsuitable.");
            } catch (Exception ex) {
              exportDlg.ps.println("\nERROR processing ZIP file: " + ex.getMessage());
            }
            return null;
          }

          @Override
          public void finished() {
            exportDlg.cancelBtn.setText(msg.get("OK"));
            exportDlg.copyBtn.setEnabled(true);
            exportDlg.sw = null;
          }
        };

    exportDlg.sw.start();

    dlg.setVisible(true);
  }