コード例 #1
0
ファイル: MasterView.java プロジェクト: kasyaar/jthinker
  @Override
  /** {@inheritDoc} */
  protected void contentChanged(DiagramPane pane) {
    if (pane == null) {
      updateMenus(false);
      saveItem.setEnabled(false);
      container.updateToolBar(null);
    } else {
      saveItem.setEnabled(!pane.isSaved());
      numberingItem.setState(pane.getOptions().isNumberingEnabled());
      updateMenus(true);

      OrderingLevel level = pane.getOptions().getOrderingLevel();
      orderingOffItem.setState(level == OrderingLevel.OFF);
      orderingOverlapItem.setState(level == OrderingLevel.SUPPRESS_OVERLAP);
      container.updateToolBar(pane);
    }
  }
コード例 #2
0
ファイル: MasterView.java プロジェクト: kasyaar/jthinker
 public void publishCurrent() {
   DiagramPane pane = getCurrentDiagram();
   if (pane == null) return;
   DiagramPublisher publisher = new DiagramPublisher();
   publisher.setXMLData(pane.getXMLData());
   HTMLProducer producer = pane.getImageMaker();
   try {
     publisher.setImageData(producer.getRawData("PNG"));
   } catch (Exception ex) {
     // TODO: Proceed this exception
   }
   publisher.setHTMLData(producer.renderHTMLWrapper());
   publisher.setCallback(container);
   if (container.getServerURL() != null) {
     InteropUtils.setAccessURL(container.getServerURL());
   }
   publisher.publish();
 }
コード例 #3
0
ファイル: MasterView.java プロジェクト: kasyaar/jthinker
  /**
   * Creates application's "File" menu.
   *
   * @return newly created application's menu
   */
  public JMenu createApplicationFileMenu() {
    JMenu fileMenu = new JMenu("File");

    JMenu newSubMenu = new JMenu("New");
    for (Action newDiagramAction : NewDiagramAction.createAll(this)) {
      newSubMenu.add(newDiagramAction);
    }
    fileMenu.add(newSubMenu);

    openItem = new JMenuItem(new LoadDiagramAction(this));

    Action action =
        new AbstractAction("Save") {
          public void actionPerformed(ActionEvent e) {
            saveCurrent(false);
          }
        };
    saveItem = new JMenuItem(action);

    action =
        new AbstractAction("Save as...") {
          public void actionPerformed(ActionEvent e) {
            saveCurrent(true);
          }
        };
    saveAsItem = new JMenuItem(action);

    action =
        new AbstractAction("Only image") {
          public void actionPerformed(ActionEvent e) {
            try {
              File file = chooseSave(JPEG_FILES, PNG_FILES);
              if (file == null) {
                return;
              }
              getCurrentDiagram().getImageMaker().imageExport(file);
            } catch (Exception ex) {
              ex.printStackTrace();
            }
          }
        };
    jpegExportItem = new JMenuItem(action);

    action =
        new AbstractAction("Image + HTML") {
          public void actionPerformed(ActionEvent e) {
            try {
              File imageFile = chooseSave(JPEG_FILES, PNG_FILES);
              if (imageFile == null) {
                return;
              }
              File htmlFile = chooseSave(HTML_FILES);
              if (htmlFile == null) {
                return;
              }
              getCurrentDiagram().getImageMaker().imageHtmlExport(imageFile, htmlFile);
            } catch (Exception ex) {
              ex.printStackTrace();
            }
          }
        };
    jpegHtmlExportItem = new JMenuItem(action);

    action =
        new AbstractAction("Publish") {
          public void actionPerformed(ActionEvent e) {
            publishCurrent();
          }
        };
    publishItem = new JMenuItem(action);

    fileMenu.addSeparator();

    if (container.localPersistence()) {
      fileMenu.add(openItem);
      fileMenu.add(saveItem);
      fileMenu.add(saveAsItem);

      JMenu exportMenu = new JMenu("Export to JPEG/PNG");
      exportMenu.add(jpegExportItem);
      exportMenu.add(jpegHtmlExportItem);
      fileMenu.add(exportMenu);

      fileMenu.addSeparator();
    }

    if (container.globalPersistenceWrite()) {
      fileMenu.add(publishItem);
      fileMenu.addSeparator();
    }

    return fileMenu;
  }