Ejemplo 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;
 }
Ejemplo n.º 2
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();
 }
Ejemplo n.º 3
0
 private void actionPerformedUpdates(Window _parent) {
   boolean tempDirty = isDirty();
   if (paneNaming.isDirty()) {
     String filename = paneNaming.getAbsolutePath();
     String oldFilename = _imgBtn.getFilename();
     if (FileManager.exists(filename)) {
       String name = FileManager.getName(filename);
       int ret =
           JOptionPane.showConfirmDialog(
               _parent,
               SikuliIDEI18N._I("msgFileExists", name),
               SikuliIDEI18N._I("dlgFileExists"),
               JOptionPane.WARNING_MESSAGE,
               JOptionPane.YES_NO_OPTION);
       if (ret != JOptionPane.YES_OPTION) {
         return;
       }
     }
     try {
       FileManager.xcopy(oldFilename, filename, null);
       (new File(oldFilename)).delete();
       _imgBtn.setFilename(filename);
     } catch (IOException ioe) {
       Debug.error("renaming failed: " + oldFilename + " " + filename);
       Debug.error(ioe.getMessage());
     }
     paneNaming.updateFilename();
     addDirty(true);
   }
   addDirty(
       _imgBtn.setParameters(
           _screenshot.isExact(), _screenshot.getSimilarity(), _screenshot.getNumMatches()));
   addDirty(_imgBtn.setTargetOffset(_tarOffsetPane.getTargetOffset()));
   Debug.log(2, "update: " + _imgBtn.toString());
   if (isDirty() || tempDirty) {
     int i = _imgBtn.getWindow().getTabbedPane().getSelectedIndex();
     _imgBtn.getWindow().setMessageApplied(i, true);
     _imgBtn.repaint();
   }
 }
Ejemplo n.º 4
0
 static String _I(String key, Object... args) {
   return SikuliIDEI18N._I(key, args);
 }