Example #1
0
 private void saveOrUpdate(Resource subject, ValuesContext pc) {
   Object o = pc.invokeGetter();
   Property property = toRdfProperty(pc);
   if (Saver.supports(pc.type())) Saver.of(pc.type()).save(this, subject, property, o);
   else if (o == null) subject.removeAll(property);
   else if (pc.isPrimitive()) subject.removeAll(property).addProperty(property, toLiteral(m, o));
   else if (isNormalObject(o)) setPropertyValue(subject, property, o);
   else
     logger.log(
         Level.WARNING,
         MessageFormat.format(
             bundle.getString(UNSUPPORTED_TYPE), pc.type(), pc.subject.getClass()));
 }
Example #2
0
  private void doSave0() {
    try {

      Storable bean = taskQueue.take();
      String saverKey = bean.getClass().getSimpleName();
      Saver saver = savers.get(saverKey);
      if (saver == null) {
        saver = new Saver();
        savers.put(saverKey, saver);
      }
      saver.doSave(bean);
    } catch (Exception e) {
      LOG.error("Error doSaveForum", e);
    }
  }
Example #3
0
 public void setEnabled(boolean b) {
   enabled = b;
   if (doc != null) {
     doc.onPathTilesChanged();
     Saver.save(this);
   }
 }
Example #4
0
  public synchronized void finishCompact() {
    for (int zoom = Utils.MIN_ZOOM; zoom <= Utils.MAX_ZOOM; zoom++) {
      pathsInZooms[zoom].finishCompact();
    }

    if (doc != null) Saver.save(this);
  }
Example #5
0
 private void doSave(final String path) throws UserCancelException {
   checkWithUserBeforeSavingModelFromOldVersion();
   Saver saver = new Saver(path);
   org.nlogo.swing.ModalProgressTask.apply(
       org.nlogo.awt.Hierarchy.getFrame(this), "Saving...", saver);
   if (saver.getException() != null) {
     javax.swing.JOptionPane.showMessageDialog(
         this,
         "Save failed.  Error: " + saver.getException().getMessage(),
         "NetLogo",
         javax.swing.JOptionPane.ERROR_MESSAGE);
   }
   if (!saver.getResult()) {
     throw new UserCancelException();
   }
   app.tabs().saveExternalFiles();
 }
Example #6
0
 public List<LocationX> split(LocationX pm) {
   finishCompact();
   List<LocationX> placemarks = getPlaceMarks();
   int idx = placemarks.indexOf(pm);
   List<LocationX> sublist = placemarks.subList(0, idx);
   List<LocationX> sublist1 = placemarks.subList(idx, placemarks.size());
   set(sublist);
   Saver.save(this);
   return sublist1;
 }
Example #7
0
  public boolean addCompact(LocationX pm) {
    boolean compacted = false;
    LocationX compactedPm = pm;
    for (int zoom = Utils.MAX_ZOOM; zoom >= Utils.MIN_ZOOM; zoom--) {
      compactedPm = pathsInZooms[zoom].addCompacted(compactedPm, pm);
      if (zoom == Utils.MAX_ZOOM && compactedPm != null) compacted = true;
    }
    if (rect == null) rect = new RectX(pm.getLongitude(), pm.getLatitude(), 0, 0);
    else rect.union(pm.getLongitude(), pm.getLatitude());

    if (compacted && doc != null) Saver.save(this);

    return compacted;
  }
Example #8
0
  @Override
  public void save() throws IOException {
    List<LocationX> pms = getPlaceMarks();
    if (pms.size() < 2) return;

    File f = File.createTempFile(file.getName(), "tmp", file.getParentFile());

    PrintStream ps = null;
    Adapter.log("saving path " + file);
    try {
      ps = new PrintStream(f, "UTF-8");
      ps.println("header enabled=" + enabled);
      Saver.writePlacemarks(pms, ps);
      ps.flush();
    } finally {
      if (ps != null) ps.close();
    }

    file.delete();
    f.renameTo(file);
  }