コード例 #1
0
 void previewB_actionPerformed(ActionEvent e) {
   File f;
   try {
     f = Util.getTempFile();
     new HTMLFileExport(f, editor.document, CurrentNote.get(), "UTF-8", false, null, false);
     Util.runBrowser("file:" + f.getAbsolutePath());
   } catch (IOException ioe) {
     new ExceptionDialog(ioe, "Cannot create temporary file", null);
   }
 }
コード例 #2
0
  void newResB_actionPerformed(ActionEvent e) {
    AddResourceDialog dlg = new AddResourceDialog(App.getFrame(), Local.getString("New resource"));
    Dimension frmSize = App.getFrame().getSize();
    Point loc = App.getFrame().getLocation();
    dlg.setLocation(
        (frmSize.width - dlg.getSize().width) / 2 + loc.x,
        (frmSize.height - dlg.getSize().height) / 2 + loc.y);
    dlg.setVisible(true);
    if (dlg.CANCELLED) return;
    if (dlg.localFileRB.isSelected()) {
      String fpath = dlg.pathField.getText();
      MimeType mt = MimeTypesList.getMimeTypeForFile(fpath);
      if (mt.getMimeTypeId().equals("__UNKNOWN")) {
        mt = addResourceType(fpath);
        if (mt == null) return;
      }
      if (!checkApp(mt)) return;
      // if file if projectFile, than copy the file and change url.
      if (dlg.projectFileCB.isSelected()) {
        fpath = copyFileToProjectDir(fpath);
        CurrentProject.getResourcesList().addResource(fpath, false, true);
      } else CurrentProject.getResourcesList().addResource(fpath);

      resourcesTable.tableChanged();
    } else {
      if (!Util.checkBrowser()) return;
      CurrentProject.getResourcesList().addResource(dlg.urlField.getText(), true, false);
      resourcesTable.tableChanged();
    }
  }
コード例 #3
0
  boolean checkApp(MimeType mt) {
    String appId = mt.getAppId();
    AppList appList = MimeTypesList.getAppList();
    File d;
    if (appId == null) {
      appId = Util.generateId();
      d = new File("/");
    } else {
      File exe = new File(appList.getFindPath(appId) + "/" + appList.getExec(appId));
      if (exe.isFile()) return true;
      d = new File(exe.getParent());
      while (!d.exists()) d = new File(d.getParent());
    }
    SetAppDialog dlg =
        new SetAppDialog(
            App.getFrame(),
            Local.getString(
                Local.getString("Select the application to open files of type")
                    + " '"
                    + mt.getLabel()
                    + "'"));
    Dimension dlgSize = new Dimension(420, 300);
    dlg.setSize(dlgSize);
    Dimension frmSize = App.getFrame().getSize();
    Point loc = App.getFrame().getLocation();
    dlg.setLocation(
        (frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y);
    dlg.setDirectory(d);
    dlg.appPanel.argumentsField.setText("$1");
    dlg.setVisible(true);
    if (dlg.CANCELLED) return false;
    File f = new File(dlg.appPanel.applicationField.getText());

    appList.addOrReplaceApp(
        appId,
        f.getParent().replace('\\', '/'),
        f.getName().replace('\\', '/'),
        dlg.appPanel.argumentsField.getText());
    mt.setApp(appId);
    /*appList.setFindPath(appId, chooser.getSelectedFile().getParent().replace('\\','/'));
    appList.setExec(appId, chooser.getSelectedFile().getName().replace('\\','/'));*/
    CurrentStorage.get().storeMimeTypesList();
    return true;
  }
コード例 #4
0
  /**
   * Copy a file to the directory of the current project
   *
   * @param srcStr The path of the source file.
   * @param destStr The destination path.
   * @return The new path of the file.
   */
  String copyFileToProjectDir(String srcStr) {

    String JN_DOCPATH = Util.getEnvDir();

    String baseName;
    int i = srcStr.lastIndexOf(File.separator);
    if (i != -1) {
      baseName = srcStr.substring(i + 1);
    } else baseName = srcStr;

    String destStr =
        JN_DOCPATH
            + CurrentProject.get().getID()
            + File.separator
            + "_projectFiles"
            + File.separator
            + baseName;

    File f = new File(JN_DOCPATH + CurrentProject.get().getID() + File.separator + "_projectFiles");
    if (!f.exists()) {
      f.mkdirs();
    }
    System.out.println("[DEBUG] Copy file from: " + srcStr + " to: " + destStr);

    try {
      FileInputStream in = new FileInputStream(srcStr);
      FileOutputStream out = new FileOutputStream(destStr);
      byte[] buf = new byte[4096];
      int len;
      while ((len = in.read(buf)) > 0) {
        out.write(buf, 0, len);
      }
      out.close();
      in.close();
    } catch (IOException e) {
      System.err.println(e.toString());
    }

    return destStr;
  }
コード例 #5
0
  // Tasks UI
  void drawTaskPanel() {
    if (processId != null) {
      Collection<Task> tasks = CurrentProject.getProcessList().getProcess(processId).getTasks();
      taskIds = new ArrayList<>();
      List<Task> taskList = new ArrayList<>(tasks);
      DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT);
      GridBagConstraints gc = new GridBagConstraints();
      gc.ipadx = 3;
      gc.ipady = 3;
      gc.gridy = 0;
      gc.weightx = 1;
      gc.weighty = 1;
      gc.anchor = GridBagConstraints.WEST;

      taskInnerPanel = new JPanel(new GridBagLayout());

      {
        JLabel title = new JLabel(Local.getString("Task"));
        JLabel status = new JLabel(Local.getString("Status"));
        JLabel priority = new JLabel(Local.getString("Priority"));

        gc.gridx = 1;
        taskInnerPanel.add(title, gc);
        gc.gridx = 2;
        taskInnerPanel.add(status, gc);
        gc.gridx = 3;
        taskInnerPanel.add(priority, gc);
      }

      for (Task task : taskList) {
        Util.debug("Adding task: " + task.getText());

        BasicArrowButton up = new BasicArrowButton(BasicArrowButton.NORTH);
        BasicArrowButton dn = new BasicArrowButton(BasicArrowButton.SOUTH);
        JLabel title = new JLabel(task.getText());
        JLabel status = new JLabel(task.getStatusString());
        JLabel priority = new JLabel(task.getPriorityString());

        gc.gridy = gc.gridy + 1;
        gc.gridx = 0;
        gc.gridx = 1;
        gc.anchor = GridBagConstraints.WEST;
        taskInnerPanel.add(title, gc);
        gc.gridx = 2;
        taskInnerPanel.add(status, gc);
        gc.gridx = 3;
        taskInnerPanel.add(priority, gc);
        gc.gridx = 4;
        gc.anchor = GridBagConstraints.CENTER;
        taskInnerPanel.add(up, gc);
        gc.gridx = 5;
        gc.anchor = GridBagConstraints.CENTER;
        taskInnerPanel.add(dn, gc);

        up.addActionListener(
            new ActionListener() {
              public void actionPerformed(ActionEvent action) {
                int index = taskList.indexOf(task);

                if (index > 0) {
                  Collections.swap(taskList, index, index - 1);
                  Collections.swap(taskIds, index, index - 1);

                  sortTasks(taskIds);
                }
              }
            });

        dn.addActionListener(
            new ActionListener() {
              public void actionPerformed(ActionEvent action) {
                int index = taskList.indexOf(task);

                if (index < taskList.size() - 1) {
                  Collections.swap(taskList, index, index + 1);
                  Collections.swap(taskIds, index, index + 1);

                  sortTasks(taskIds);
                }
              }
            });

        taskIds.add(task.getID());
      }

      taskScrollPane = new JScrollPane(taskInnerPanel);

      taskPanel = new JPanel(new BorderLayout());
      taskPanel.setPreferredSize(new Dimension(400, 300));
      taskPanel.setBorder(defaultBorder);
      taskPanel.add(taskScrollPane, BorderLayout.CENTER);
      this.getContentPane().add(taskPanel, BorderLayout.CENTER);
    }
  }
コード例 #6
0
 public static String getDateStamp(CalendarDate date) {
   return Util.getDateStamp(date.getCalendar());
 }
コード例 #7
0
 void runBrowser(String url) throws IOException {
   Util.runBrowser(url);
 }
コード例 #8
0
 void reportB_actionPerformed(ActionEvent e) {
   Util.runBrowser(App.BUGS_TRACKER_URL);
 }