Java Code Examples for javax.swing.JOptionPane#NO_OPTION

The following examples show how to use javax.swing.JOptionPane#NO_OPTION . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainLifecycle.java    From raccoon4 with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onRequestShutdown(Globals globals) {
	TransferManager tm = globals.get(TransferManager.class);

	if (!tm.isIdle()) {
		int ret = JOptionPane.showConfirmDialog(
				globals.get(LifecycleManager.class).getWindow(),
				Messages.getString("MainLifecycle.confirm_exit.message"),
				Messages.getString("MainLifecycle.confirm_exit.title"),
				JOptionPane.YES_NO_OPTION);
		if (ret == JOptionPane.NO_OPTION) {
			return false;
		}
		tm.cancelAll();
	}

	return true;
}
 
Example 2
Source File: ScrDeclensionsGrids.java    From PolyGlot with MIT License 6 votes vote down vote up
@Override
public void dispose() {
    if (isDisposed()) {
        super.dispose();
    } else {
        if (!closeWithoutSave && chkAutogenOverride.isSelected()) {
            int userChoice = InfoBox.yesNoCancel("Save Confirmation", "Save changes?", this);

            // yes = save, no = don't save, any other choice = cancel & do not exit
            if (userChoice == JOptionPane.YES_OPTION) {
                saveValues();
                super.dispose();
            } else if (userChoice == JOptionPane.NO_OPTION) {
                super.dispose();
            }
        } else {
            if (depVals != null && !depVals.isVisible()) {
                depVals.dispose();
            }
            super.dispose();
        }
    }
}
 
Example 3
Source File: PdfExportDialog.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
protected boolean performConfirm() {
  final String filename = txFilename.getText();
  final File f = new File( filename );
  if ( f.exists() ) {
    final String key1 = "pdfsavedialog.targetOverwriteConfirmation"; //$NON-NLS-1$
    final String key2 = "pdfsavedialog.targetOverwriteTitle"; //$NON-NLS-1$
    if ( JOptionPane.showConfirmDialog( this, MessageFormat.format( getResources().getString( key1 ),
        new Object[] { txFilename.getText() } ), getResources().getString( key2 ), JOptionPane.YES_NO_OPTION,
        JOptionPane.QUESTION_MESSAGE ) == JOptionPane.NO_OPTION ) {
      return false;
    }
  }

  if ( getEncryptionValue().equals( PdfExportGUIModule.SECURITY_ENCRYPTION_128BIT )
      || getEncryptionValue().equals( PdfExportGUIModule.SECURITY_ENCRYPTION_40BIT ) ) {
    if ( txOwnerPassword.getText().trim().length() == 0 ) {
      if ( JOptionPane.showConfirmDialog( this, getResources().getString( "pdfsavedialog.ownerpasswordEmpty" ), //$NON-NLS-1$
          getResources().getString( "pdfsavedialog.warningTitle" ), //$NON-NLS-1$
          JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE ) == JOptionPane.NO_OPTION ) {
        return false;
      }
    }
  }
  return true;
}
 
Example 4
Source File: RemoveAudioFunction.java    From GpsPrune with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Perform the function
 */
public void begin()
{
	// Delete the current audio, and optionally its point too, keeping undo information
	AudioClip currentAudio = _app.getTrackInfo().getCurrentAudio();
	if (currentAudio != null)
	{
		// Audio is selected, see if it has a point or not
		boolean deleted = false;
		UndoDeleteAudio undoAction = null;
		if (currentAudio.getDataPoint() == null)
		{
			// no point attached, so just delete
			undoAction = new UndoDeleteAudio(currentAudio, _app.getTrackInfo().getSelection().getCurrentAudioIndex(),
				null, -1);
			deleted = _app.getTrackInfo().deleteCurrentAudio(false);
		}
		else
		{
			// point is attached, so need to confirm point deletion
			final int pointIndex = _app.getTrackInfo().getTrack().getPointIndex(currentAudio.getDataPoint());
			undoAction = new UndoDeleteAudio(currentAudio, _app.getTrackInfo().getSelection().getCurrentAudioIndex(),
				currentAudio.getDataPoint(), pointIndex);
			undoAction.setAtBoundaryOfSelectedRange(pointIndex == _app.getTrackInfo().getSelection().getStart() ||
				pointIndex == _app.getTrackInfo().getSelection().getEnd());
			int response = JOptionPane.showConfirmDialog(_app.getFrame(),
				I18nManager.getText("dialog.deleteaudio.deletepoint"),
				I18nManager.getText(getNameKey()), JOptionPane.YES_NO_CANCEL_OPTION);
			boolean deletePointToo = (response == JOptionPane.YES_OPTION);
			// Cancel delete if cancel pressed or dialog closed
			if (response == JOptionPane.YES_OPTION || response == JOptionPane.NO_OPTION) {
				deleted = _app.getTrackInfo().deleteCurrentAudio(deletePointToo);
			}
		}
		// Add undo information to stack if necessary
		if (deleted) {
			_app.completeFunction(undoAction, currentAudio.getName() + " " + I18nManager.getText("confirm.media.removed"));
		}
	}
}
 
Example 5
Source File: CSVTableExportDialog.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected boolean performConfirm() {
  final File f = new File( getFilename() );
  if ( f.exists() ) {
    final String key1 = "csvexportdialog.targetOverwriteConfirmation"; //$NON-NLS-1$
    final String key2 = "csvexportdialog.targetOverwriteTitle"; //$NON-NLS-1$
    if ( JOptionPane.showConfirmDialog( this, MessageFormat.format( getResources().getString( key1 ),
        new Object[] { getFilename() } ), getResources().getString( key2 ), JOptionPane.YES_NO_OPTION,
        JOptionPane.QUESTION_MESSAGE ) == JOptionPane.NO_OPTION ) {
      return false;
    }
  }
  return true;
}
 
Example 6
Source File: MainWindow.java    From jadx with Apache License 2.0 5 votes vote down vote up
private void saveProjectAs() {
	JFileChooser fileChooser = new JFileChooser();
	fileChooser.setAcceptAllFileFilterUsed(true);
	String[] exts = { JadxProject.PROJECT_EXTENSION };
	String description = "supported files: " + Arrays.toString(exts).replace('[', '(').replace(']', ')');
	fileChooser.setFileFilter(new FileNameExtensionFilter(description, exts));
	fileChooser.setToolTipText(NLS.str("file.save_project"));
	Path currentDirectory = settings.getLastSaveProjectPath();
	if (currentDirectory != null) {
		fileChooser.setCurrentDirectory(currentDirectory.toFile());
	}
	int ret = fileChooser.showSaveDialog(mainPanel);
	if (ret == JFileChooser.APPROVE_OPTION) {
		settings.setLastSaveProjectPath(fileChooser.getCurrentDirectory().toPath());

		Path path = fileChooser.getSelectedFile().toPath();
		if (!path.getFileName().toString().toLowerCase(Locale.ROOT).endsWith(JadxProject.PROJECT_EXTENSION)) {
			path = path.resolveSibling(path.getFileName() + "." + JadxProject.PROJECT_EXTENSION);
		}

		if (Files.exists(path)) {
			int res = JOptionPane.showConfirmDialog(
					this,
					NLS.str("confirm.save_as_message", path.getFileName()),
					NLS.str("confirm.save_as_title"),
					JOptionPane.YES_NO_OPTION);
			if (res == JOptionPane.NO_OPTION) {
				return;
			}
		}
		project.saveAs(path);
		update();
	}
}
 
Example 7
Source File: AppUtils.java    From RemoteSupportTool with Apache License 2.0 5 votes vote down vote up
public static Boolean askQuestion(Component parent, String message, String title) {
    JTextPane content = new JTextPane();
    content.setEditable(false);
    content.setOpaque(false);
    content.setText(message);

    int response = JOptionPane.showConfirmDialog(
            parent, content, title, JOptionPane.YES_NO_OPTION);

    if (response == JOptionPane.OK_OPTION)
        return true;
    if (response == JOptionPane.NO_OPTION)
        return false;
    return null;
}
 
Example 8
Source File: OptionPaneDemo.java    From beautyeye with Apache License 2.0 5 votes vote down vote up
/**
    * Creates the confirm dialog button.
    *
    * @return the j button
    */
   public JButton createConfirmDialogButton() {
Action a = new AbstractAction(getString("OptionPaneDemo.confirmbutton")) {
    public void actionPerformed(ActionEvent e) {
               int result = JOptionPane.showConfirmDialog(getDemoPanel(), getString("OptionPaneDemo.confirmquestion"));
               if(result == JOptionPane.YES_OPTION) {
	    JOptionPane.showMessageDialog(getDemoPanel(), getString("OptionPaneDemo.confirmyes"));
	} else if(result == JOptionPane.NO_OPTION) {
                   JOptionPane.showMessageDialog(getDemoPanel(), getString("OptionPaneDemo.confirmno"));
	}
    }
};
return createButton(a);
   }
 
Example 9
Source File: SourceTab.java    From FoxTelem with GNU General Public License v3.0 5 votes vote down vote up
private void stopButton() {
	if (Config.passManager.getState() == PassManager.FADED || Config.passManager.getState() == PassManager.DECODE) {
		Object[] options = {"Yes",
        "No"};
		int n = JOptionPane.showOptionDialog(
				MainWindow.frame,
				"The pass manager is still processing a satellite pass. If the satellite has\n"
				+ "faded it waits 2 minutes in case contact is re-established, even when it is at the\n"
				+ "horizon.  If you stop the decoder now the LOS will not be logged and TCA will not be calculated.\n"
				+ "Do you want to stop?",
				"Stop decoding while pass in progress?",
			    JOptionPane.YES_NO_OPTION, 
			    JOptionPane.ERROR_MESSAGE,
			    null,
			    options,
			    options[1]);
					
		if (n == JOptionPane.NO_OPTION) {
			// don't exit
		} else {
			stop();

		}
	} else {
		stop();
	}
}
 
Example 10
Source File: TaskYesNoAllDialog.java    From wpcleaner with Apache License 2.0 5 votes vote down vote up
/**
 * @see java.lang.Runnable#run()
 */
@Override
public void run() {
  Object[] options = new Object[] {
      GT._T("Yes"),
      GT._T("Yes to all"),
      GT._T("No"),
      GT._T("No to all"),
  }; 
  JOptionPane pane = new JOptionPane(
      message, JOptionPane.WARNING_MESSAGE,
      JOptionPane.YES_NO_OPTION, null, options);
  JDialog dialog = pane.createDialog(parent, Version.PROGRAM);
  dialog.setVisible(true);
  Object selectedValue = pane.getValue();
  if (selectedValue == null) {
    result = JOptionPane.CLOSED_OPTION;
  } else if (options[0].equals(selectedValue)) {
    result = JOptionPane.YES_OPTION;
  } else if (options[1].equals(selectedValue)) {
    result = Utilities.YES_ALL_OPTION;
  } else if (options[2].equals(selectedValue)) {
    result = JOptionPane.NO_OPTION;
  } else if (options[3].equals(selectedValue)) {
    result =  Utilities.NO_ALL_OPTION;
  } else {
    result = JOptionPane.CLOSED_OPTION;
  }
}
 
Example 11
Source File: ImportActionListener.java    From collect-earth with MIT License 5 votes vote down vote up
private Integer shouldImportNonFinishedRecords( boolean moreThanOneFiles ) {
	String message = "<html>" //$NON-NLS-1$
			+ Messages.getString("ImportActionListener.0") //$NON-NLS-1$
			+"<br/>" //$NON-NLS-1$
			+ Messages.getString("ImportActionListener.2") //$NON-NLS-1$
			+ "</html>";

	if( !moreThanOneFiles ){

		final int selectedOption = JOptionPane.showConfirmDialog(null,
				message  //$NON-NLS-1$
				,Messages.getString("ImportActionListener.3"),  //$NON-NLS-1$
				JOptionPane.YES_NO_OPTION);

		if (selectedOption == JOptionPane.YES_OPTION){
			return YES;
		}else if (selectedOption == JOptionPane.NO_OPTION){
			return NO;
		}else{
			return JOptionPane.CLOSED_OPTION;
		}
	}else{

		String[] buttons = { Messages.getString("YES"), Messages.getString("YES_TO_ALL"), Messages.getString("NO"), Messages.getString("NO_TO_ALL") };

		return JOptionPane.showOptionDialog(null, message, Messages.getString("ImportActionListener.3") ,
				JOptionPane.WARNING_MESSAGE, 0, null, buttons, buttons[1]);

	}
}
 
Example 12
Source File: HtmlZipExportDialog.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected boolean performConfirm() {
  final String filename = getFilename();
  final File f = new File( filename ).getAbsoluteFile();
  if ( f.exists() ) {
    final String key1 = "htmlexportdialog.targetOverwriteConfirmation"; //$NON-NLS-1$
    final String key2 = "htmlexportdialog.targetOverwriteTitle"; //$NON-NLS-1$
    if ( JOptionPane.showConfirmDialog( this, MessageFormat.format( getResources().getString( key1 ),
        new Object[] { getFilename() } ), getResources().getString( key2 ), JOptionPane.YES_NO_OPTION,
        JOptionPane.QUESTION_MESSAGE ) == JOptionPane.NO_OPTION ) {
      return false;
    }
  }

  return true;
}
 
Example 13
Source File: MainFrame.java    From ShootPlane with Apache License 2.0 5 votes vote down vote up
private void startGame() throws LineUnavailableException, UnsupportedAudioFileException, IOException {
Container c = this.getContentPane();
c.removeAll();
this.repaint();
BorderLayout borderLayout = new BorderLayout();
c.setLayout(borderLayout);
this.gamePlayingPanel = new GamePlayingPanel();
c.add(this.gamePlayingPanel, BorderLayout.CENTER);
this.gamePlayingPanel.startGame();
long startTime = System.currentTimeMillis();
while (this.gamePlayingPanel.getMyPlane().isAlive()) {
    try {
	Thread.sleep(Config.GAME_PANEL_REPAINT_INTERVAL);
    } catch (InterruptedException e) {
	e.printStackTrace();
    }
}
long endTime = System.currentTimeMillis();
// add to score list
this.addScore(this.gamePlayingPanel.getScore(), endTime - startTime);
int option = JOptionPane.showConfirmDialog(this, "Game Over, Score:" + this.gamePlayingPanel.getScore()
	+ ", Start Again?", "Game Over", JOptionPane.YES_NO_OPTION);
switch (option) {
case JOptionPane.YES_OPTION:
    loadGame();
    break;
case JOptionPane.NO_OPTION:
    stopGame();
    break;
}
   }
 
Example 14
Source File: TripleAFrame.java    From triplea with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Prompts the user with a list of territories that have air units that either cannot land
 * (movement action) or be placed (placement action) in the territory. The user is asked whether
 * they wish to end the current movement/placement action, which will destroy the air units in the
 * specified territories, or if they wish to continue the current movement/placement action in
 * order to possibly move/place those units in a different territory.
 *
 * @param gamePlayer The player performing the movement/placement action.
 * @param airCantLand The collection of territories that have air units that either cannot land or
 *     be placed in them.
 * @param movePhase {@code true} if a movement action is active; otherwise {@code false} if a
 *     placement action is active.
 * @return {@code true} if the user wishes to end the current movement/placement action, and thus
 *     destroy the affected air units; otherwise {@code false} if the user wishes to continue the
 *     current movement/placement action.
 */
public boolean getOkToLetAirDie(
    final GamePlayer gamePlayer,
    final Collection<Territory> airCantLand,
    final boolean movePhase) {
  if (airCantLand == null || airCantLand.isEmpty()) {
    return true;
  }
  messageAndDialogThreadPool.waitForAll();
  final StringBuilder sb = new StringBuilder("<html>Air units cannot land in:<ul> ");
  for (final Territory t : airCantLand) {
    sb.append("<li>").append(t.getName()).append("</li>");
  }
  sb.append("</ul></html>");
  final boolean lhtrProd =
      Properties.getLhtrCarrierProductionRules(data)
          || Properties.getLandExistingFightersOnNewCarriers(data);
  final int carrierCount =
      GameStepPropertiesHelper.getCombinedTurns(data, gamePlayer).stream()
          .map(GamePlayer::getUnitCollection)
          .map(units -> units.getMatches(Matches.unitIsCarrier()))
          .mapToInt(List::size)
          .sum();
  final boolean canProduceCarriersUnderFighter = lhtrProd && carrierCount != 0;
  if (canProduceCarriersUnderFighter && carrierCount > 0) {
    sb.append("\nYou have ")
        .append(carrierCount)
        .append(" ")
        .append(MyFormatter.pluralize("carrier", carrierCount))
        .append(" on which planes can land");
  }
  final String ok = movePhase ? "End Move Phase" : "Kill Planes";
  final String cancel = movePhase ? "Keep Moving" : "Change Placement";
  final String[] options = {cancel, ok};
  mapPanel.centerOn(airCantLand.iterator().next());
  final int choice =
      EventThreadJOptionPane.showOptionDialog(
          this,
          sb.toString(),
          "Air cannot land",
          JOptionPane.YES_NO_OPTION,
          JOptionPane.WARNING_MESSAGE,
          null,
          options,
          cancel,
          getUiContext().getCountDownLatchHandler());
  return choice == JOptionPane.NO_OPTION;
}
 
Example 15
Source File: VerificationView.java    From iBioSim with Apache License 2.0 4 votes vote down vote up
/**
 * Calls the appropriate dot program to show the graph.
 * @param fileName The absolute file name.
 */
public void showGraph(String fileName)
{
	File file = new File(fileName);

	File work = file.getParentFile();
	try {
		Runtime exec = Runtime.getRuntime();
		if (new File(fileName).exists()) {

			long kB = 1024;	// number of bytes in a kilobyte.

			long fileSize = file.length()/kB; // Size of file in megabytes.

			// If the file is larger than a given amount of megabytes,
			// then give the user the chance to cancel the operation.

			int thresholdSize = 100;	// Specifies the threshold for giving the
			// user the option to not attempt to open the file.
			if(fileSize > thresholdSize)
			{
				int answer = JOptionPane.showConfirmDialog(Gui.frame,
						"The size of the file exceeds " + thresholdSize + " kB."
								+ "The file may not open. Do you want to continue?", 
								"Do you want to continue?", JOptionPane.YES_NO_OPTION);

				if(answer == JOptionPane.NO_OPTION)
				{
					return;
				}
			}
			Preferences biosimrc = Preferences.userRoot();
			String command = biosimrc.get("biosim.general.graphviz", "") + " ";
			Process dot = exec.exec(command + fileName, null, work);
			log.addText(command + fileName + "\n");
			dot.waitFor();
		} else {
			JOptionPane.showMessageDialog(Gui.frame,
					"Unable to view dot file.", "Error",
					JOptionPane.ERROR_MESSAGE);
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
Example 16
Source File: ControlFlowPanel.java    From iBioSim with Apache License 2.0 4 votes vote down vote up
private boolean openGui(String oldName) {
	String id = (String) fromBox.getSelectedItem() + " " + (String) toBox.getSelectedItem();
	String[] oldFlow = new String[2];
	if (oldName != null) {
		oldFlow = oldName.split("\\s");
	}
	String[] newFlow = { (String) fromBox.getSelectedItem(), (String) toBox.getSelectedItem() };
	int value = JOptionPane.showOptionDialog(Gui.frame, this, "Control Flow Editor",
			JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, options[0]);
	if (value == JOptionPane.YES_OPTION) {
		id = (String) fromBox.getSelectedItem() + " " + (String) toBox.getSelectedItem();
		newFlow[0] = (String) fromBox.getSelectedItem();
		newFlow[1] = (String) toBox.getSelectedItem();
		if (oldName == null) {
			if (lhpn.containsMovement(newFlow[0], newFlow[1])) {
			  JOptionPane.showMessageDialog(Gui.frame,  "Movement already exists.", "Error", JOptionPane.ERROR_MESSAGE); 
				
				return false;
			}
		}
		else if (!oldName.equals(id)) {
			if (lhpn.containsMovement(newFlow[0], newFlow[1])) {
			  JOptionPane.showMessageDialog(Gui.frame, "Movement already exists.", "Error", JOptionPane.ERROR_MESSAGE); 
				
				return false;
			}
		}

		// Check to see if we need to add or edit

		if (selected != null && oldName != null && !oldName.equals(id)) {
			lhpn.removeMovement(oldFlow[0], oldFlow[1]);
		}
		lhpn.addMovement(fromBox.getSelectedItem().toString(), toBox.getSelectedItem()
				.toString());
		flowList.removeItem(oldName);
		flowList.addItem(id);
		flowList.setSelectedValue(id, true);
	}
	else if (value == JOptionPane.NO_OPTION) {
		return true;
	}
	return true;
}
 
Example 17
Source File: BurpExtender.java    From Berserko with GNU Affero General Public License v3.0 4 votes vote down vote up
private void testCredentials() {
	
	if (usernameTextField.getText().isEmpty()) {
		JOptionPane.showMessageDialog(null, "Username not set yet",
				"Error", JOptionPane.ERROR_MESSAGE);
		return;
	}

	if (!(domainStatusTextField.getText().equals(kdcTestSuccessString))) {
		int n = JOptionPane
				.showConfirmDialog(
						null,
						"You haven't successfully tested the domain settings yet, do you want to continue without doing so?\nIf the KDC can't be found, this command will hang Burp for quite a while (around 90 seconds).",
						"Proceed?", JOptionPane.YES_NO_OPTION);

		if (n == JOptionPane.NO_OPTION) {
			return;
		}
	}

	setKrb5Config();

	setupKerberosConfig();
	
	try {
		LoginContext loginContext = new LoginContext("KrbLogin",
				new KerberosCallBackHandler(username, password));
		loginContext.login();

		boolean forwardable = checkTgtForwardableFlag(loginContext
				.getSubject());

		credentialsStatusTextField.setText(credentialsTestSuccessString
				+ " ("
				+ (forwardable ? forwardableTgtString
						: notForwardableTgtString) + ")");
		JOptionPane.showMessageDialog(null, credentialsTestSuccessString
				+ "\n\n("
				+ (forwardable ? forwardableTgtString
						: notForwardableTgtString) + ")", "Success",
				JOptionPane.INFORMATION_MESSAGE);
	} catch (Exception e) {
		if (e.getMessage().startsWith(
				"Client not found in Kerberos database")) {
			credentialsStatusTextField
					.setText("Failed to acquire TGT - username appears to be invalid");
			JOptionPane
					.showMessageDialog(
							null,
							"Failed to acquire TGT - username appears to be invalid.",
							"Failure", JOptionPane.ERROR_MESSAGE);
			log(1, "Error when testing credentials: " + e.getMessage());				
		} else if (e.getMessage().startsWith(
				"Pre-authentication information was invalid")) {
			credentialsStatusTextField
					.setText("Failed to acquire TGT - password appears to be invalid");
			JOptionPane
					.showMessageDialog(
							null,
							"Failed to acquire TGT - password appears to be invalid.\n\nBe careful not to lock out the account with more tests.",
							"Failure", JOptionPane.ERROR_MESSAGE);
			log(1, "Error when testing credentials: " + e.getMessage());
		} else if( e.getMessage().startsWith( "KDC has no support for encryption type"))
		{
			credentialsStatusTextField
			.setText("Failed to acquire TGT - encryption type not supported");
			if( unlimitedJCE)
			{
				JOptionPane
				.showMessageDialog(
						null,
						"Failed to acquire TGT - encryption algorithm not supported by KDC.\n\nThis is unexpected, as you appear to have the JCE Unlimited Strength Jurisdiction Policy installed.",
						"Failure", JOptionPane.ERROR_MESSAGE);
			}
			else
			{
				JOptionPane
				.showMessageDialog(
						null,
						"Failed to acquire TGT - encryption algorithm not supported by KDC.\n\nThis is likely to be because you do not have the JCE Unlimited Strength Jurisdiction Policy installed.\n\nSee http://docs.oracle.com/javase/7/docs/technotes/guides/security/SunProviders.html#importlimits\n\nAlso note that newer versions of Burp seem to have a workaround for this.",
						"Failure", JOptionPane.ERROR_MESSAGE);
			}
			alertAndLog(1, "Error when testing credentials: " + e.getMessage());
		} else {
			credentialsStatusTextField.setText("Failed to acquire TGT: "
					+ e.getMessage());
			JOptionPane.showMessageDialog(null, "Failed to acquire TGT: "
					+ e.getMessage(), "Failure", JOptionPane.ERROR_MESSAGE);
			log(1,
					"Unexpected error when testing credentials: "
							+ e.getMessage());
			logException(2, e);
		}
	}
}
 
Example 18
Source File: ScrMainMenu.java    From PolyGlot with MIT License 4 votes vote down vote up
/**
 * Provides dialog for Save As, and returns boolean to determine whether
 * file save should take place. DOES NOT SAVE.
 *
 * @return true if file saved, false otherwise
 */
private boolean saveFileAsDialog() {
    boolean ret = false;
    JFileChooser chooser = new JFileChooser();
    FileNameExtensionFilter filter = new FileNameExtensionFilter("PolyGlot Dictionaries", "pgd");
    String curFileName = core.getCurFileName();

    chooser.setDialogTitle("Save Language");
    chooser.setFileFilter(filter);
    chooser.setApproveButtonText("Save");
    if (curFileName.isEmpty()) {
        chooser.setCurrentDirectory(core.getWorkingDirectory());
    } else {
        chooser.setCurrentDirectory(IOHandler.getDirectoryFromPath(curFileName));
        chooser.setSelectedFile(IOHandler.getFileFromPath(curFileName));
    }

    String fileName;

    if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
        fileName = chooser.getSelectedFile().getAbsolutePath();
        // if user has not provided an extension, add one
        if (!fileName.contains(".pgd")) {
            fileName += ".pgd";
        }

        if (IOHandler.fileExists(fileName)) {
            int overWrite = InfoBox.yesNoCancel("Overwrite Dialog",
                    "Overwrite existing file? " + fileName, core.getRootWindow());

            if (overWrite == JOptionPane.NO_OPTION) {
                ret = saveFileAsDialog();
            } else if (overWrite == JOptionPane.YES_OPTION) {
                core.setCurFileName(fileName);
                ret = true;
            }
        } else {
            core.setCurFileName(fileName);
            ret = true;
        }
    }

    return ret;
}
 
Example 19
Source File: DialogCallbackHandler.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
void setCallback(ConfirmationCallback callback)
    throws UnsupportedCallbackException
{
    this.callback = callback;

    int confirmationOptionType = callback.getOptionType();
    switch (confirmationOptionType) {
    case ConfirmationCallback.YES_NO_OPTION:
        optionType = JOptionPane.YES_NO_OPTION;
        translations = new int[] {
            JOptionPane.YES_OPTION, ConfirmationCallback.YES,
            JOptionPane.NO_OPTION, ConfirmationCallback.NO,
            JOptionPane.CLOSED_OPTION, ConfirmationCallback.NO
        };
        break;
    case ConfirmationCallback.YES_NO_CANCEL_OPTION:
        optionType = JOptionPane.YES_NO_CANCEL_OPTION;
        translations = new int[] {
            JOptionPane.YES_OPTION, ConfirmationCallback.YES,
            JOptionPane.NO_OPTION, ConfirmationCallback.NO,
            JOptionPane.CANCEL_OPTION, ConfirmationCallback.CANCEL,
            JOptionPane.CLOSED_OPTION, ConfirmationCallback.CANCEL
        };
        break;
    case ConfirmationCallback.OK_CANCEL_OPTION:
        optionType = JOptionPane.OK_CANCEL_OPTION;
        translations = new int[] {
            JOptionPane.OK_OPTION, ConfirmationCallback.OK,
            JOptionPane.CANCEL_OPTION, ConfirmationCallback.CANCEL,
            JOptionPane.CLOSED_OPTION, ConfirmationCallback.CANCEL
        };
        break;
    case ConfirmationCallback.UNSPECIFIED_OPTION:
        options = callback.getOptions();
        /*
         * There's no way to know if the default option means
         * to cancel the login, but there isn't a better way
         * to guess this.
         */
        translations = new int[] {
            JOptionPane.CLOSED_OPTION, callback.getDefaultOption()
        };
        break;
    default:
        throw new UnsupportedCallbackException(
            callback,
            "Unrecognized option type: " + confirmationOptionType);
    }

    int confirmationMessageType = callback.getMessageType();
    switch (confirmationMessageType) {
    case ConfirmationCallback.WARNING:
        messageType = JOptionPane.WARNING_MESSAGE;
        break;
    case ConfirmationCallback.ERROR:
        messageType = JOptionPane.ERROR_MESSAGE;
        break;
    case ConfirmationCallback.INFORMATION:
        messageType = JOptionPane.INFORMATION_MESSAGE;
        break;
    default:
        throw new UnsupportedCallbackException(
            callback,
            "Unrecognized message type: " + confirmationMessageType);
    }
}
 
Example 20
Source File: BigDataViewerBoundingBox.java    From SPIM_Registration with GNU General Public License v2.0 4 votes vote down vote up
public static Pair< BigDataViewer, Boolean > getBDV( final AbstractSpimData< ? > spimData, final Collection< ViewId > viewIdsToProcess )
	{
		final BDVPopup popup = ViewSetupExplorerPanel.bdvPopup();
		BigDataViewer bdv;
		boolean bdvIsLocal = false;

		if ( popup == null || popup.panel == null )
		{
			// locally run instance
			if ( AbstractImgLoader.class.isInstance( spimData.getSequenceDescription().getImgLoader() ) )
			{
				if ( JOptionPane.showConfirmDialog( null,
						"Opening <SpimData> dataset that is not suited for interactive browsing.\n" +
						"Consider resaving as HDF5 for better performance.\n" +
						"Proceed anyways?",
						"Warning",
						JOptionPane.YES_NO_OPTION ) == JOptionPane.NO_OPTION )
					return null;
			}

			bdv = BigDataViewer.open( spimData, "BigDataViewer", IOFunctions.getProgressWriter(), ViewerOptions.options() );
			bdvIsLocal = true;

//			if ( !bdv.tryLoadSettings( panel.xml() ) ) TODO: this should work, but currently tryLoadSettings is protected. fix that.
				InitializeViewerState.initBrightness( 0.001, 0.999, bdv.getViewer(), bdv.getSetupAssignments() );

			final List< BasicViewDescription< ? > > vds = new ArrayList< BasicViewDescription< ? > >();

			for ( final ViewId viewId : viewIdsToProcess )
				vds.add( spimData.getSequenceDescription().getViewDescriptions().get( viewId ) );

			ViewSetupExplorerPanel.updateBDV( bdv, true, spimData, null, vds );
		}
		else if ( popup.bdv == null )
		{
			// if BDV was closed by the user
			if ( popup.bdv != null && !popup.bdv.getViewerFrame().isVisible() )
				popup.bdv = null;

			try
			{
				bdv = popup.bdv = BDVPopup.createBDV( popup.panel );
			}
			catch (Exception e)
			{
				IOFunctions.println( "Could not run BigDataViewer: " + e );
				e.printStackTrace();
				bdv = popup.bdv = null;
			}
		}
		else
		{
			bdv = popup.bdv;
		}

		return new ValuePair< BigDataViewer, Boolean >( bdv, bdvIsLocal );
	}