Exemplo n.º 1
0
  /** Reads the view from the specified uri. */
  @Override
  public void read(URI f, URIChooser chooser) throws IOException {
    try {
      final Drawing drawing = createDrawing();
      InputFormat inputFormat = drawing.getInputFormats().get(0);
      inputFormat.read(f, drawing, true);
      SwingUtilities.invokeAndWait(
          new Runnable() {

            @Override
            public void run() {
              view.getDrawing().removeUndoableEditListener(undo);
              view.setDrawing(drawing);
              view.getDrawing().addUndoableEditListener(undo);
              undo.discardAllEdits();
            }
          });
    } catch (InterruptedException e) {
      InternalError error = new InternalError();
      e.initCause(e);
      throw error;
    } catch (InvocationTargetException e) {
      InternalError error = new InternalError();
      e.initCause(e);
      throw error;
    }
  }
Exemplo n.º 2
0
 public void setDrawing(Drawing d) {
   undoManager.discardAllEdits();
   view.getDrawing().removeUndoableEditListener(undoManager);
   view.setDrawing(d);
   d.addUndoableEditListener(undoManager);
 }
Exemplo n.º 3
0
 /** Writes the view to the specified uri. */
 @Override
 public void write(URI f, URIChooser chooser) throws IOException {
   Drawing drawing = view.getDrawing();
   OutputFormat outputFormat = drawing.getOutputFormats().get(0);
   outputFormat.write(f, drawing);
 }