Exemple #1
0
 public String saveAsFile(boolean accessingAsFile) throws IOException {
   File file = new SikuliIDEFileChooser(SikuliIDE.getInstance(), accessingAsFile).save();
   if (file == null) {
     return null;
   }
   String bundlePath = FileManager.slashify(file.getAbsolutePath(), false);
   if (!file.getAbsolutePath().endsWith(".sikuli")) {
     bundlePath += ".sikuli";
   }
   if (FileManager.exists(bundlePath)) {
     int res =
         JOptionPane.showConfirmDialog(
             null,
             SikuliIDEI18N._I("msgFileExists", bundlePath),
             SikuliIDEI18N._I("dlgFileExists"),
             JOptionPane.YES_NO_OPTION);
     if (res != JOptionPane.YES_OPTION) {
       return null;
     }
   } else {
     FileManager.mkdir(bundlePath);
   }
   try {
     saveAsBundle(bundlePath, (SikuliIDE.getInstance().getCurrentFileTabTitle()));
     if (Settings.isMac()) {
       if (!Settings.handlesMacBundles) {
         makeBundle(bundlePath, accessingAsFile);
       }
     }
   } catch (IOException iOException) {
   }
   return getCurrentShortFilename();
 }
Exemple #2
0
 public boolean close() throws IOException {
   if (isDirty()) {
     Object[] options = {
       SikuliIDEI18N._I("yes"), SikuliIDEI18N._I("no"), SikuliIDEI18N._I("cancel")
     };
     int ans =
         JOptionPane.showOptionDialog(
             this,
             SikuliIDEI18N._I("msgAskSaveChanges", getCurrentShortFilename()),
             SikuliIDEI18N._I("dlgAskCloseTab"),
             JOptionPane.YES_NO_CANCEL_OPTION,
             JOptionPane.WARNING_MESSAGE,
             null,
             options,
             options[0]);
     if (ans == JOptionPane.CANCEL_OPTION || ans == JOptionPane.CLOSED_OPTION) {
       return false;
     } else if (ans == JOptionPane.YES_OPTION) {
       if (saveFile() == null) {
         return false;
       }
     } else {
       SikuliIDE.getInstance().getTabPane().resetLastClosed();
     }
     if (_srcBundleTemp) {
       FileManager.deleteTempDir(_srcBundlePath);
     }
     setDirty(false);
   }
   if (_srcBundlePath != null) {
     ImagePath.remove(_srcBundlePath);
   }
   return true;
 }
Exemple #3
0
 // <editor-fold defaultstate="collapsed" desc="file handling">
 public String loadFile(boolean accessingAsFile) throws IOException {
   File file = new SikuliIDEFileChooser(SikuliIDE.getInstance(), accessingAsFile).load();
   if (file == null) {
     return null;
   }
   String fname = FileManager.slashify(file.getAbsolutePath(), false);
   SikuliIDE ide = SikuliIDE.getInstance();
   int i = ide.isAlreadyOpen(fname);
   if (i > -1) {
     Debug.log(2, "Already open in IDE: " + fname);
     return null;
   }
   loadFile(fname);
   if (_editingFile == null) {
     return null;
   }
   return fname;
 }
Exemple #4
0
 public void setDirty(boolean flag) {
   if (_dirty == flag) {
     return;
   }
   _dirty = flag;
   // <editor-fold defaultstate="collapsed" desc="RaiMan no global dirty">
   if (flag) {
     // RaiManMod getRootPane().putClientProperty("Window.documentModified", true);
   } else {
     // SikuliIDE.getInstance().checkDirtyPanes();
   }
   // </editor-fold>
   SikuliIDE.getInstance().setCurrentFileTabTitleDirty(_dirty);
 }
Exemple #5
0
  public String exportAsZip() throws IOException, FileNotFoundException {
    File file = new SikuliIDEFileChooser(SikuliIDE.getInstance()).export();
    if (file == null) {
      return null;
    }

    String zipPath = file.getAbsolutePath();
    String srcName = file.getName();
    if (!file.getAbsolutePath().endsWith(".skl")) {
      zipPath += ".skl";
    } else {
      srcName = srcName.substring(0, srcName.lastIndexOf('.'));
    }
    writeFile(getSrcBundle() + srcName + ".py");
    FileManager.zip(getSrcBundle(), zipPath);
    Debug.log(2, "export to executable file: " + zipPath);
    return zipPath;
  }