コード例 #1
0
ファイル: FileMenu.java プロジェクト: orzoln/NetLogo
 @Override
 void action() throws UserCancelException, java.io.IOException {
   final String importPath =
       org.nlogo.swing.FileDialog.show(
           FileMenu.this, "Import Patch Colors RGB", java.awt.FileDialog.LOAD, null);
   final java.io.IOException[] exception = new java.io.IOException[] {null};
   org.nlogo.swing.ModalProgressTask.apply(
       org.nlogo.awt.Hierarchy.getFrame(FileMenu.this),
       "Importing Patch Colors...",
       new Runnable() {
         public void run() {
           try {
             // We can't wait for the thread to complete, or we end
             // up locking up the app since the Model Dialog and the
             // job wedge against one another. -- CLB 07/19/05
             org.nlogo.agent.ImportPatchColors.importPatchColors(
                 new org.nlogo.api.LocalFile(importPath), app.workspace().world(), false);
             app.workspace().view.dirty();
             app.workspace().view.repaint();
           } catch (java.io.IOException ex) {
             exception[0] = ex;
           }
         }
       });
   if (exception[0] != null) {
     throw exception[0];
   }
 }
コード例 #2
0
ファイル: FileMenu.java プロジェクト: orzoln/NetLogo
    @Override
    void action() throws UserCancelException, java.io.IOException {
      final String importPath =
          org.nlogo.swing.FileDialog.show(
              FileMenu.this, "Import HubNet Client Interface", java.awt.FileDialog.LOAD, null);
      final java.io.IOException[] exception = new java.io.IOException[] {null};
      final int choice =
          org.nlogo.swing.OptionDialog.show(
              app.workspace().getFrame(),
              "Import HubNet Client",
              "Which section would you like to import from?",
              new String[] {
                "Interface Tab", "HubNet client", I18N.guiJ().get("common.buttons.cancel")
              });

      if (choice != 2) {
        org.nlogo.swing.ModalProgressTask.apply(
            org.nlogo.awt.Hierarchy.getFrame(FileMenu.this),
            "Importing Drawing...",
            new Runnable() {
              public void run() {
                try {
                  app.workspace().getHubNetManager().importClientInterface(importPath, choice == 1);
                } catch (java.io.IOException ex) {
                  exception[0] = ex;
                }
              }
            });
        if (exception[0] != null) {
          throw exception[0];
        }
      }
    }
コード例 #3
0
ファイル: FileMenu.java プロジェクト: orzoln/NetLogo
 @Override
 void action() throws UserCancelException, java.io.IOException {
   final String exportPath =
       org.nlogo.swing.FileDialog.show(
           FileMenu.this,
           "Export Interface",
           java.awt.FileDialog.SAVE,
           app.workspace().guessExportName("interface.png"));
   final java.io.IOException[] exception = new java.io.IOException[] {null};
   org.nlogo.swing.ModalProgressTask.apply(
       org.nlogo.awt.Hierarchy.getFrame(FileMenu.this),
       "Exporting...",
       new Runnable() {
         public void run() {
           try {
             app.workspace().exportInterface(exportPath);
           } catch (java.io.IOException ex) {
             exception[0] = ex;
           }
         }
       });
   if (exception[0] != null) {
     throw exception[0];
   }
 }
コード例 #4
0
ファイル: InterfacePanel.java プロジェクト: rlegendi/NetLogo
 private void exportInterface() throws java.io.IOException {
   try {
     final String exportPath =
         org.nlogo.swing.FileDialog.show(
             this,
             "Export Interface",
             java.awt.FileDialog.SAVE,
             workspace.guessExportName("interface.png"));
     final java.io.IOException[] exception = new java.io.IOException[] {null};
     org.nlogo.swing.ModalProgressTask.apply(
         org.nlogo.awt.Hierarchy.getFrame(this),
         "Exporting...",
         new Runnable() {
           public void run() {
             try {
               workspace.exportInterface(exportPath);
             } catch (java.io.IOException ex) {
               exception[0] = ex;
             }
           }
         });
     if (exception[0] != null) {
       throw exception[0];
     }
   } catch (org.nlogo.awt.UserCancelException ex) {
     org.nlogo.util.Exceptions.ignore(ex);
   }
 }
コード例 #5
0
ファイル: FileMenu.java プロジェクト: orzoln/NetLogo
 private String userChooseSavePath() throws UserCancelException {
   String newFileName = guessFileName();
   String newDirectoryName = null;
   if (app.workspace().getModelType() == ModelTypeJ.NORMAL()) {
     // we only default to saving in the model dir for normal and
     // models. for library and new models, we use the current
     // FileDialog dir.
     newDirectoryName = app.workspace().getModelDir();
   }
   org.nlogo.swing.FileDialog.setDirectory(newDirectoryName);
   String path =
       org.nlogo.swing.FileDialog.show(this, "Save As", java.awt.FileDialog.SAVE, newFileName);
   if (!path.endsWith("." + modelSuffix())) {
     path += "." + modelSuffix();
   }
   return path;
 }
コード例 #6
0
ファイル: FileMenu.java プロジェクト: orzoln/NetLogo
 @Override
 void action() throws UserCancelException {
   final String exportPath =
       org.nlogo.swing.FileDialog.show(
           FileMenu.this,
           "Export Output",
           java.awt.FileDialog.SAVE,
           app.workspace().guessExportName("output.txt"));
   org.nlogo.swing.ModalProgressTask.apply(
       org.nlogo.awt.Hierarchy.getFrame(FileMenu.this),
       "Exporting...",
       new Runnable() {
         public void run() {
           new org.nlogo.window.Events.ExportOutputEvent(exportPath).raise(FileMenu.this);
         }
       });
 }
コード例 #7
0
ファイル: FileMenu.java プロジェクト: orzoln/NetLogo
    String getExportPath(String suffix) throws UserCancelException {
      // we use workspace.getModelFileName() here, because it really should
      // never any longer be null, now that we've forced the user to save.
      // it's important that it not be, in fact, since the applet relies
      // on the model having been saved to some file.
      String suggestedFileName = app.workspace().getModelFileName();

      // try to guess a decent file name to export to...
      int suffixIndex = suggestedFileName.lastIndexOf("." + modelSuffix());
      if (suffixIndex > 0
          && suffixIndex == suggestedFileName.length() - (modelSuffix().length() + 1)) {
        suggestedFileName =
            suggestedFileName.substring(
                0, suggestedFileName.length() - (modelSuffix().length() + 1));
      }
      suggestedFileName = suggestedFileName + suffix + ".html";

      // make the user choose the actual destination...
      return org.nlogo.swing.FileDialog.show(
          FileMenu.this, "Saving as Applet", java.awt.FileDialog.SAVE, suggestedFileName);
    }
コード例 #8
0
ファイル: FileMenu.java プロジェクト: orzoln/NetLogo
 @Override
 void action() throws UserCancelException, java.io.IOException {
   final String importPath =
       org.nlogo.swing.FileDialog.show(
           FileMenu.this, "Import Drawing", java.awt.FileDialog.LOAD, null);
   final java.io.IOException[] exception = new java.io.IOException[] {null};
   org.nlogo.swing.ModalProgressTask.apply(
       org.nlogo.awt.Hierarchy.getFrame(FileMenu.this),
       "Importing Drawing...",
       new Runnable() {
         public void run() {
           try {
             app.workspace().importDrawing(importPath);
             app.workspace().view.dirty();
             app.workspace().view.repaint();
           } catch (java.io.IOException ex) {
             exception[0] = ex;
           }
         }
       });
   if (exception[0] != null) {
     throw exception[0];
   }
 }
コード例 #9
0
ファイル: FileMenu.java プロジェクト: orzoln/NetLogo
 private String userChooseLoadPath() throws UserCancelException {
   return org.nlogo.swing.FileDialog.show(this, "Open", java.awt.FileDialog.LOAD, null);
 }