@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]; } } }
private boolean checkWithUser() { return (!workspace.jobManager.anyPrimaryJobs()) || org.nlogo.swing.OptionDialog.show( this, I18N.guiJ().get("common.messages.warning"), "Changing the size will halt and clear the world.", new String[] {"Change Size", I18N.guiJ().get("common.buttons.cancel")}) == 0; }
private void checkWithUserBeforeOpening2DModelin3D() throws UserCancelException { String[] options = { I18N.guiJ().get("common.buttons.continue"), I18N.guiJ().get("common.buttons.cancel") }; String message = "You are attempting to open a 2D model in " + org.nlogo.api.Version.version() + ". " + "You might need to make changes before it will work in 3D."; if (org.nlogo.swing.OptionDialog.show(this, "NetLogo", message, options) != 0) { throw new UserCancelException(); } }
private boolean userWantsToSaveFirst() throws UserCancelException { String[] options = { I18N.guiJ().get("common.buttons.save"), "Discard", I18N.guiJ().get("common.buttons.cancel") }; String message = "Do you want to save the changes you made to this model?"; switch (org.nlogo.swing.OptionDialog.show(this, "NetLogo", message, options)) { case 0: return true; case 1: return false; default: throw new UserCancelException(); } }
private void checkWithUserBeforeOpening3DModelin2D(String version) throws UserCancelException { String[] options = { I18N.guiJ().get("common.buttons.continue"), I18N.guiJ().get("common.buttons.cancel") }; String message = "You are attempting to open a model that was created" + " in a 3D version of NetLogo. (This is " + org.nlogo.api.Version.version() + "; " + "the model was created in " + version + ".) " + "NetLogo can try to open the model, but it may " + "or may not work."; if (org.nlogo.swing.OptionDialog.show(this, "NetLogo", message, options) != 0) { throw new UserCancelException(); } }
private void checkWithUserBeforeSavingModelFromOldVersion() throws UserCancelException { if (!org.nlogo.api.Version.compatibleVersion(savedVersion)) { String[] options = { I18N.guiJ().get("common.buttons.save"), I18N.guiJ().get("common.buttons.cancel") }; String message = "This model was made with " + savedVersion + ". " + "If you save it in " + org.nlogo.api.Version.version() + " it may not work in the old version anymore."; if (org.nlogo.swing.OptionDialog.show(this, "NetLogo", message, options) != 0) { throw new UserCancelException(); } savedVersion = org.nlogo.api.Version.version(); } }
// this is called whenever a workspace is about to be destroyed public void offerSave() throws UserCancelException { // check if we have an open movie if (app.workspace().movieEncoder != null) { String[] options = { I18N.guiJ().get("common.buttons.ok"), I18N.guiJ().get("common.buttons.cancel") }; String message = "There is a movie in progress. " + "Are you sure you want to exit this model? " + "You will lose the contents of your movie."; if (org.nlogo.swing.OptionDialog.show(this, "NetLogo", message, options) == 1) { throw new UserCancelException(); } app.workspace().movieEncoder.cancel(); app.workspace().movieEncoder = null; } if (app.dirtyMonitor().dirty() && userWantsToSaveFirst()) { save(); } }
private void notifyUserNotValidFile() throws UserCancelException { String[] options = {I18N.guiJ().get("common.buttons.ok")}; org.nlogo.swing.OptionDialog.show( this, "NetLogo", "The file is not a valid NetLogo model file.", options); throw new UserCancelException(); }