private void setDocument(final URL document, boolean load) throws IOException {
    final Cursor cu = switchCursor(waitc);
    try {
      log.info(document);
      final URL old = this.document;
      this.firePropertyChange("document", old, this.document = document);
      setFile(this.document);
      url.setText(this.document == null ? "{null}" : this.document.toString());
      if (!load) return;

      cm.deregister(tactics.getCurves());
      final ComputedTrajectorySet cts;
      if (this.document == null) cts = null;
      else {
        final IONode n = new JCurlSerializer().read(this.document);
        final IOTrajectories it = (IOTrajectories) n;
        final TrajectorySet ts = it.trajectories().get(0);
        cts = (ComputedTrajectorySet) ts;
      }
      change.discardAllEdits();
      if (cts != null) cts.setCurrentTime(currentTime);
      tactics.setCurves(cts);
      broomSwing.setBroom(tactics.getBroom());
      cm.register(cts);
      setModified(false);
    } finally {
      switchCursor(cu);
    }
  }
 private JCurlShotPlanner() {
   change.addUndoableEditListener(this);
   tactics.setChanger(change);
   broomSwing.setChanger(change);
   curlerSwing.setChanger(change);
   birdPiccolo.setMaster(tactics);
   // tactics.setName("tactics");
   url.setName("urlLabel");
 }
 private File saveHelper(
     File dst, final File base, final String name, final boolean forceOverwrite) {
   JFileChooser fcJcx = null;
   for (; ; ) {
     if (fcJcx == null) fcJcx = createJcxChooser(base, name);
     if (dst == null) {
       if (JFileChooser.APPROVE_OPTION != fcJcx.showSaveDialog(getMainFrame())) return null;
       dst = fcJcx.getSelectedFile();
     }
     if (dst == null) continue;
     dst = gui.ensureSuffix(dst, jcxzPat);
     if (forceOverwrite || askOverwrite(dst))
       try {
         save(tactics.getCurves(), dst);
         return dst;
       } catch (final Exception e) {
         showErrorDialog("Couldn't save to '" + dst + "'", e);
       }
     else dst = null;
   }
 }
 /** Edit Menu Action */
 @Action
 public void editOut() {
   final ComputedTrajectorySet cts = tactics.getCurves();
   if (cts == null) return;
   change.addEdit(reset(cts, tactics.getBroom(), true));
 }
  @Override
  protected void startup() {
    // set the window icon:
    {
      final Image img;
      if (true) img = getContext().getResourceMap().getImageIcon("Application.icon").getImage();
      else {
        final ResourceMap r = getContext().getResourceMap();
        if (true)
          try {
            img =
                ImageIO.read(
                    this.getClass()
                        .getResource(
                            "/" + r.getResourcesDir() + "/" + r.getString("Application.icon")));
          } catch (final IOException e) {
            throw new RuntimeException("Unhandled", e);
          }
        else
          img =
              Toolkit.getDefaultToolkit()
                  .createImage(
                      this.getClass()
                          .getResource(
                              "/" + r.getResourcesDir() + "/" + r.getString("Application.icon")));
      }
      getMainFrame().setIconImage(img);
      // SystemTray tray = SystemTray.getSystemTray();
    }

    // File Filter
    jcxzPat = gui.createFileFilter("fileFilterJcxz", "jcz", "jcx");
    pngPat = gui.createFileFilter("fileFilterPng", "png");
    svgPat = gui.createFileFilter("fileFilterSvg", "svgz", "svg");

    getMainFrame().setJMenuBar(createMenuBar());

    final JComponent c = new JPanel();
    c.setLayout(new BorderLayout());
    tactics.setPreferredSize(new Dimension(400, 600));
    c.add(tactics, BorderLayout.CENTER);
    c.add(url, BorderLayout.NORTH);
    {
      final JPanel b = new JPanel();
      b.setLayout(new BorderLayout());
      final JTabbedPane t = new JTabbedPane(SwingConstants.TOP, JTabbedPane.SCROLL_TAB_LAYOUT);
      t.add("Rock", broomSwing);
      t.setMnemonicAt(0, 'R');
      t.add("Ice", curlerSwing);
      t.setMnemonicAt(1, 'I');
      t.add("Collission", new JLabel("TODO: Collission settings"));
      t.setMnemonicAt(2, 'C');
      b.add(t, BorderLayout.NORTH);
      if (false) b.add(new JLabel("TODO: Bird's eye view"), BorderLayout.CENTER);
      else b.add(birdPiccolo, BorderLayout.CENTER);
      c.add(b, BorderLayout.EAST);
    }

    show(c);
    view12Foot();
  }