Exemplo n.º 1
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;
 }
Exemplo n.º 2
0
 public void loadFile(String filename) {
   filename = FileManager.slashify(filename, false);
   setSrcBundle(filename + "/");
   File script = new File(filename);
   _editingFile = FileManager.getScriptFile(script, null, null);
   if (_editingFile != null) {
     editingType =
         _editingFile
             .getAbsolutePath()
             .substring(_editingFile.getAbsolutePath().lastIndexOf(".") + 1);
     initBeforeLoad(editingType);
     try {
       this.read(
           new BufferedReader(new InputStreamReader(new FileInputStream(_editingFile), "UTF8")),
           null);
     } catch (Exception ex) {
       _editingFile = null;
     }
   }
   if (_editingFile != null) {
     updateDocumentListeners();
     setDirty(false);
     _srcBundleTemp = false;
   } else {
     _srcBundlePath = null;
   }
 }
Exemplo n.º 3
0
 private void writeSrcFile() throws IOException {
   Debug.log(3, "IDE: writeSrcFile: " + _editingFile.getName());
   writeFile(_editingFile.getAbsolutePath());
   if (PreferencesUser.getInstance().getAtSaveMakeHTML()) {
     convertSrcToHtml(getSrcBundle());
   } else {
     String snameDir = new File(_editingFile.getAbsolutePath()).getParentFile().getName();
     String sname = snameDir.replace(".sikuli", "") + ".html";
     (new File(snameDir, sname)).delete();
   }
   if (PreferencesUser.getInstance().getAtSaveCleanBundle()) {
     cleanBundle(getSrcBundle());
   }
   setDirty(false);
 }