Java Code Examples for javax.swing.JOptionPane#showConfirmDialog()

The following examples show how to use javax.swing.JOptionPane#showConfirmDialog() . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
/**
 * Action that flags the currently selected sheet as invalid.
 *
 * @param e the event that triggered this action
 */
@Action(enabledProperty = STUB_VALID)
public void invalidateSheet (ActionEvent e)
{
    SheetStub stub = StubsController.getCurrentStub();

    if (stub != null) {
        int answer = JOptionPane.showConfirmDialog(
                OMR.gui.getFrame(),
                "About to set sheet " + stub.getId() + " as invalid." + "\nDo you confirm?");

        if (answer == JOptionPane.YES_OPTION) {
            final Sheet sheet = stub.getSheet();
            final StubsController controller = StubsController.getInstance();

            if (ViewParameters.getInstance().isInvalidSheetDisplay() == false) {
                controller.removeAssembly(sheet.getStub());
            } else {
                controller.callAboutStub(sheet.getStub());
            }
        }
    }
}
 
Example 2
/** Does something with respect to check if the name of a territory is valid or not. */
private void doneCurrentGroup() {
  final JTextField text = new JTextField();
  guessCountryName(text, centers.entrySet());
  final int option = JOptionPane.showConfirmDialog(this, text);
  // cancel = 2
  // no = 1
  // yes = 0
  if (option == 0) {
    if (!centers.containsKey(text.getText())) {
      // not a valid name
      JOptionPane.showMessageDialog(this, "not a valid name");
      current = null;
      return;
    }
    polygons.put(text.getText(), new ArrayList<>(current));
    current = null;
  } else if (option > 0) {
    current = null;
  } else {
    log.info("something very invalid");
  }
}
 
Example 3
@Override
protected void onOk() {
    if (!isCanOk()) {
        JOptionPane
                .showMessageDialog(
                        this,
                        ResourceLoader
                                .getString("you_should_enter_name_or_at_least_on_added_elemen"));
        return;
    }
    if (!isOkStreamName()) {
        if (JOptionPane.showConfirmDialog(this, ResourceLoader
                        .getString("you_entered_exists_stream_continue"),
                ResourceLoader.getString("warning"),
                JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION) {
            return;
        } else
            loadFrom(sectorNameEditor.findStreamByName());

    }
    isOk = true;
    super.onOk();
}
 
Example 4
Source Project: zxpoly   File: MainForm.java    License: GNU General Public License v3.0 6 votes vote down vote up
private void formWindowClosing(java.awt.event.WindowEvent evt) {
  boolean hasChangedDisk = false;
  for (int i = 0; i < 4; i++) {
    final TrDosDisk disk = this.board.getBetaDiskInterface().getDiskInDrive(i);
    hasChangedDisk |= (disk != null && disk.isChanged());
  }

  boolean close = false;

  if (hasChangedDisk) {
    if (JOptionPane
        .showConfirmDialog(this, "Emulator has unsaved disks, do you realy want to close it?",
            "Detected unsaved data", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) {
      close = true;
    }
  } else {
    close = true;
  }

  this.board.dispose();

  if (close) {
    System.exit(0);
  }
}
 
Example 5
/**
 * Displays a message to user in the event an unexpected exception occurs.
 * User can open logs folder and/or Issue tracker directly from this dialog.
 */
private static void doNotifyUser() {
    try {

        // By specifying a frame the JOptionPane will be shown in the taskbar.
        // Otherwise if the dialog is hidden it is easy to forget it is still open.
        final JFrame frame = new JFrame(MText.get(_S1));
        frame.setUndecorated(true);
        frame.setVisible(true);
        frame.setLocationRelativeTo(null);

        String prompt = MText.get(_S2);
        if (Desktop.isDesktopSupported()) {
            prompt += String.format("\n\n%s\n%s", MText.get(_S3), MText.get(_S4));
            final int action = JOptionPane.showConfirmDialog(frame, prompt, MText.get(_S1), JOptionPane.OK_OPTION, JOptionPane.ERROR_MESSAGE, null);
            if (action == JOptionPane.YES_OPTION) {
                DesktopHelper.tryOpen(MagicFileSystem.getDataPath(MagicFileSystem.DataPath.LOGS).toFile());
            }
        } else {
            JOptionPane.showMessageDialog(frame, prompt, MText.get(_S1), JOptionPane.ERROR_MESSAGE);
        }

    } catch (Exception e) {
        // do nothing - crash report has already been generated and app is about to exit anyway.
    }
}
 
Example 6
public ResetTaskWork(final EgDownloaderWindow mainWindow, final List<Task> tasks, String message) {
	//询问是否重置任务
	int result = JOptionPane.showConfirmDialog(mainWindow, message);
	if(result == JOptionPane.OK_OPTION){//确定
		new CommonSwingWorker(new Runnable() {
			public void run() {
				//mainWindow.setEnabled(false);
				ResetAllTaskWindow w = (ResetAllTaskWindow) mainWindow.resetAllTaskWindow;
				if(w == null){
					mainWindow.resetAllTaskWindow = new ResetAllTaskWindow(mainWindow, tasks);
				}
				w = (ResetAllTaskWindow) mainWindow.resetAllTaskWindow;
				w.setInfoLabel("    0");
				w.setVisible(true);
				Task task = null;
				for(int i = 0; i < tasks.size(); i ++){
					task = tasks.get(i);
					if(task.getStatus() != TaskStatus.STARTED//正在下载
							&& task.getStatus() != TaskStatus.UNCREATED//未创建
							 && task.getStatus() != TaskStatus.UNSTARTED){//未开始
						//重置图片状态
						for(int j = 0; j < task.getPictures().size(); j ++){
							task.getPictures().get(j).setCompleted(false);
						}
						task.setCurrent(0);//进度未0
						task.setStatus(TaskStatus.UNSTARTED);//状态未开始
						task.setCompletedTime("");//完成时间置空
						task.setReaded(false);//未阅读
					}
					w.setInfoLabel("    " + (i + 1));
					mainWindow.pictureDbTemplate.update(task.getPictures());
				}
				//保存数据
				mainWindow.taskDbTemplate.update(tasks);
				w.dispose();
				JOptionPane.showMessageDialog(mainWindow, "重置任务完成!");
			}
		}).execute();
	}
}
 
Example 7
private void btExcluirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btExcluirActionPerformed
    int opcao = JOptionPane.showConfirmDialog(this, "Deseja realmente excluir o fornecedor " + fornecedor + "?");
    if (opcao == 0) {
        try {
            fornecedorDAO.excluir(fornecedor);
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(this, "Erro ao excluir o fornecedor.\n" + ex.getMessage(), "Erro", JOptionPane.ERROR_MESSAGE);
            return;
        }

        habilitarFormulario(false);
        carregarGrade();
    }
}
 
Example 8
Source Project: astor   File: ChartPanel.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Displays a dialog that allows the user to edit the properties for the
 * current chart.
 *
 * @since 1.0.3
 */
public void doEditChartProperties() {

    ChartEditor editor = ChartEditorManager.getChartEditor(this.chart);
    int result = JOptionPane.showConfirmDialog(this, editor,
            localizationResources.getString("Chart_Properties"),
            JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
    if (result == JOptionPane.OK_OPTION) {
        editor.updateChart(this.chart);
    }

}
 
Example 9
Source Project: mts   File: JFrameConf.java    License: GNU General Public License v3.0 5 votes vote down vote up
public void showMessagesForClosing(){
    if (this.jPanelContainer.getComponentCount() > 1 && this.jPanelContainer.isModified()){
        int choix = JOptionPane.showConfirmDialog(this, "Something has changed, do you want to save?", "Warning", JOptionPane.YES_NO_CANCEL_OPTION);
        if (choix == JOptionPane.OK_OPTION){
            Config.getConfigByName(currentFile).save(this.jPanelContainer, this.currentFile);
            if (this.jPanelContainer.restartNeeded()){
                JOptionPane.showMessageDialog(this, "By changing a particular parameter," + "\n" + " you will need to restart M.T.S. in order to the parameter to be effective.", "Warning", JOptionPane.WARNING_MESSAGE);
            }
            this.dispose();
        }
        else if (choix == JOptionPane.NO_OPTION){
            this.dispose();
        }
    }
}
 
Example 10
/**
 * Called when clicked upon, will delete constraint.
 *
 * @param e The action event
 */
@Override
@SuppressWarnings("unchecked")
public void actionPerformed(ActionEvent e) {
	// If there is nothing seleceted then just do nothing
	if (_theFrame.getInfoTreeUI().getInfoTree().isSelectionEmpty()) {
		return;
	}

	// If we're currently synced with a db, give the user the chance to
	// cancel operation
	if (_theFrame.getMModel().isSynced()) {
		int choice = JOptionPane.showConfirmDialog(_theFrame,
				"Warning: this sketch is currently synced with a db; continue and break synchronization?",
				"Warning!", JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE);

		if (choice == JOptionPane.CANCEL_OPTION) {
			return;
		}
	}

	// Get currently selected object
	DefaultMutableTreeNode curSelected = (DefaultMutableTreeNode) _theFrame.getInfoTreeUI().getInfoTree()
			.getSelectionPath().getLastPathComponent();

	if (curSelected instanceof ModelConstraint) {
		_theFrame.getMModel().removeConstraint((ModelConstraint<F, GM, M, N, E>) curSelected);
		_theFrame.getMModel().setDirty();
		_theFrame.getMModel().setSynced(false);
	}
}
 
Example 11
Source Project: opensim-gui   File: DefaultPlotEditor.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Allow the user to change the outline stroke.
 */
private void attemptOutlineStrokeSelection() {
    StrokeChooserPanel panel 
        = new StrokeChooserPanel(null, this.availableStrokeSamples);
    int result = JOptionPane.showConfirmDialog(this, panel,
        localizationResources.getString("Stroke_Selection"),
        JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);

    if (result == JOptionPane.OK_OPTION) {
        this.outlineStrokeSample.setStroke(panel.getSelectedStroke());
    }
}
 
Example 12
Source Project: osp   File: VideoClip.java    License: GNU General Public License v3.0 4 votes vote down vote up
/**
 * Creates a new object.
 *
 * @param control the XMLControl with the object data
 * @return the newly created object
 */
public Object createObject(XMLControl control) {
  // load the video and return a new clip
  boolean hasVideo = control.getPropertyNames().contains("video"); //$NON-NLS-1$
  if(!hasVideo) {
    return new VideoClip(null);
  }
  ResourceLoader.addSearchPath(control.getString("basepath")); //$NON-NLS-1$
  XMLControl child = control.getChildControl("video"); //$NON-NLS-1$
  String path = child.getString("path"); //$NON-NLS-1$
  Video video = VideoIO.getVideo(path, null);
  boolean engineChange = false;
  if (video==null && path!=null && !VideoIO.isCanceled()) {
  	if (ResourceLoader.getResource(path)!=null) { // resource exists but not loaded
     OSPLog.info("\""+path+"\" could not be opened");                                                  //$NON-NLS-1$ //$NON-NLS-2$
     // determine if other engines are available for the video extension
     ArrayList<VideoType> otherEngines = new ArrayList<VideoType>();
     String engine = VideoIO.getEngine();
     String ext = XML.getExtension(path);        
     if (!engine.equals(VideoIO.ENGINE_XUGGLE)) {
     	VideoType xuggleType = VideoIO.getVideoType("Xuggle", ext); //$NON-NLS-1$
     	if (xuggleType!=null) otherEngines.add(xuggleType);
     }
     if (otherEngines.isEmpty()) {
      JOptionPane.showMessageDialog(null, 
      		MediaRes.getString("VideoIO.Dialog.BadVideo.Message")+"\n\n"+path, //$NON-NLS-1$ //$NON-NLS-2$
      		MediaRes.getString("VideoClip.Dialog.BadVideo.Title"),                                          //$NON-NLS-1$
          JOptionPane.WARNING_MESSAGE); 
     }
     else {
   		// provide immediate way to open with other engines
 			JCheckBox changePreferredEngine = new JCheckBox(MediaRes.getString("VideoIO.Dialog.TryDifferentEngine.Checkbox")); //$NON-NLS-1$
     	video = VideoIO.getVideo(path, otherEngines, changePreferredEngine, null);
  		engineChange = changePreferredEngine.isSelected();
   	if (video!=null && changePreferredEngine.isSelected()) {
   		String typeName = video.getClass().getSimpleName();
   		String newEngine = typeName.indexOf("Xuggle")>-1? VideoIO.ENGINE_XUGGLE: //$NON-NLS-1$
   			VideoIO.ENGINE_NONE;
   		VideoIO.setEngine(newEngine);
   	}	        	
     }
  	}
  	else {
     int response = JOptionPane.showConfirmDialog(null, "\""+path+"\" "                                //$NON-NLS-1$ //$NON-NLS-2$
       +MediaRes.getString("VideoClip.Dialog.VideoNotFound.Message"),                                  //$NON-NLS-1$
         MediaRes.getString("VideoClip.Dialog.VideoNotFound.Title"),                                   //$NON-NLS-1$
           JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
     if(response==JOptionPane.YES_OPTION) {
     	VideoIO.getChooser().setAccessory(VideoIO.videoEnginePanel);
 	    VideoIO.videoEnginePanel.reset();
       VideoIO.getChooser().setSelectedFile(new File(path));
       java.io.File[] files = VideoIO.getChooserFiles("open video");                                         //$NON-NLS-1$
       if(files!=null && files.length>0) {
         VideoType selectedType = VideoIO.videoEnginePanel.getSelectedVideoType();
       	path = XML.getAbsolutePath(files[0]);
         video = VideoIO.getVideo(path, selectedType);
       }
     }
  	}
  }
  if (video!=null) {
    Collection<?> filters = (Collection<?>) child.getObject("filters"); //$NON-NLS-1$
    if(filters!=null) {
      video.getFilterStack().clear();
      Iterator<?> it = filters.iterator();
      while(it.hasNext()) {
        Filter filter = (Filter) it.next();
        video.getFilterStack().addFilter(filter);
      }
    }
    if (video instanceof ImageVideo) {
    	double dt = child.getDouble("delta_t"); //$NON-NLS-1$
    	if (!Double.isNaN(dt)) {
    		((ImageVideo)video).setFrameDuration(dt);
    	}
    }
    
  }
  VideoClip clip = new VideoClip(video);
  clip.changeEngine = engineChange;
  if (path!=null) {
  	if (!path.startsWith("/") && path.indexOf(":")==-1) { //$NON-NLS-1$ //$NON-NLS-2$
  		// convert path to absolute 
    	String base = control.getString("basepath"); //$NON-NLS-1$
  		path = XML.getResolvedPath(path, base);
  	}
  	clip.videoPath = path;
  }
  return clip;
}
 
Example 13
Source Project: zxpoly   File: MainForm.java    License: GNU General Public License v3.0 4 votes vote down vote up
private void menuOptionsEnableVideoStreamActionPerformed(final ActionEvent actionEvent) {
  this.stepSemaphor.lock();
  try {
    if (this.menuOptionsEnableVideoStream.isSelected()) {
      if (AppOptions.getInstance().isGrabSound()
          && !this.board.getBeeper().isNullBeeper()
          && JOptionPane.showConfirmDialog(this,
          "Beeper should be turned off for video sound. Ok?",
          "Beeper deactivation", JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE)
          != JOptionPane.OK_OPTION) {
        this.menuOptionsEnableVideoStream.setSelected(false);
        return;
      } else {
        this.board.getBeeper().setSourceSoundPort(null);
      }

      final Beeper beeper = this.board.getBeeper().isNullBeeper()
          && AppOptions.getInstance().isGrabSound() ? this.board.getBeeper() : null;

      try {
        final InetAddress interfaceAddress =
            InetAddress.getByName(AppOptions.getInstance().getAddress());
        this.videoStreamer.start(
            beeper,
            AppOptions.getInstance().getFfmpegPath(),
            interfaceAddress,
            AppOptions.getInstance().getPort(),
            AppOptions.getInstance().getFrameRate()
        );
      } catch (Exception ex) {
        JOptionPane.showMessageDialog(this, ex.getMessage(), "Error",
            JOptionPane.ERROR_MESSAGE);
        this.menuOptionsEnableVideoStream.setSelected(false);
      }
    } else {
      this.videoStreamer.stop();
    }
  } finally {
    this.stepSemaphor.unlock();
  }
}
 
Example 14
void menuSaveAsHtml_actionPerformed(ActionEvent e) {
  try {
    directoryChooser.setDialogTitle("Select Folder In Which To Save HTML and GIF Files");
    if (JFileChooser.APPROVE_OPTION == directoryChooser.showSaveDialog(this)) {
      int choice = JOptionPane.showConfirmDialog(this,
          "Would you like the spatial function images "
           + "to show the A and B geometries?", "Confirmation",
          JOptionPane.YES_NO_CANCEL_OPTION);
      final HtmlWriter writer = new HtmlWriter();
      switch (choice) {
        case JOptionPane.CANCEL_OPTION:
          return;
        case JOptionPane.YES_OPTION:
          writer.setShowingABwithSpatialFunction(true);
          break;
        case JOptionPane.NO_OPTION:
          writer.setShowingABwithSpatialFunction(false);
          break;
      }
      final File directory = directoryChooser.getSelectedFile();
      Assert.isTrue(directory.exists());
      //        BusyDialog.setOwner(this);
      //        BusyDialog busyDialog = new BusyDialog();
      //        writer.setBusyDialog(busyDialog);
      //        try {
      //          busyDialog.execute("Saving .html and .gif files", new BusyDialog.Executable() {
      //            public void execute() throws Exception {
      writer.write(directory, tbModel.getTestCaseList(), tbModel.getPrecisionModel());
      //            }
      //          });
      //        }
      //        catch (Exception e2) {
      //          System.out.println(busyDialog.getStackTrace());
      //          throw e2;
      //        }
    }
  }
  catch (Exception x) {
    SwingUtil.reportException(this, x);
  }
}
 
Example 15
public static BigDataViewer createBDV( final ExplorerWindow< ? , ? > panel , LinkOverlay lo)
{
	if ( AbstractImgLoader.class.isInstance( panel.getSpimData().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;
	}

	boolean allViews2D = true;
	@SuppressWarnings("unchecked")
	final Collection< BasicViewDescription< ? > > viewDescriptions =
		(Collection< BasicViewDescription< ? > >) panel.getSpimData().getSequenceDescription().getViewDescriptions().values();
	for (final BasicViewDescription< ? > vd : viewDescriptions)
		if (vd.isPresent() && vd.getViewSetup().hasSize() && vd.getViewSetup().getSize().dimension( 2 ) != 1)
		{
			allViews2D = false;
			break;
		}

	final ViewerOptions options = ViewerOptions.options().accumulateProjectorFactory( MaximumProjectorARGB.factory );
	if (allViews2D)
	{
		options.transformEventHandlerFactory(new BehaviourTransformEventHandlerPlanarFactory() );
	}

	BigDataViewer bdv = BigDataViewer.open( panel.getSpimData(), 
											"BigDataViewer", 
											null, 
											options );

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

	FilteredAndGroupedExplorerPanel.setFusedModeSimple( bdv, panel.getSpimData() );

	minMaxGroupByChannels( bdv, panel.getSpimData() );
	colorByChannels( bdv, panel.getSpimData(), 0 );

	Set<Class<? extends Entity>> groupingFactors = new HashSet<>();
	groupingFactors.add( Channel.class );
	groupingFactors.add( Illumination.class );		
	groupSourcesByFactors( bdv, panel.getSpimData(), groupingFactors );

	FilteredAndGroupedExplorerPanel.updateBDV( bdv, panel.colorMode(), panel.getSpimData(), panel.firstSelectedVD(), ((GroupedRowWindow)panel).selectedRowsGroups());

	ScrollableBrightnessDialog.setAsBrightnessDialog( bdv );

	bdv.getViewer().addTransformListener( lo );
	bdv.getViewer().getDisplay().addOverlayRenderer( lo );
	
	bdv.getViewerFrame().setVisible( true );		
	bdv.getViewer().requestRepaint();

	return bdv;
	
}
 
Example 16
Source Project: JavaMainRepo   File: AquaticController.java    License: Apache License 2.0 4 votes vote down vote up
public void actionPerformed(ActionEvent e) {

			if ((!aquatic.getName().equals("Enter name")) && (!aquatic.getNrOfLegs().equals("Enter nrOfLegs"))
					&& (!aquatic.getCost().equals("Enter cost")) && (!aquatic.getDanger().equals("Enter danger perc"))
					&& (!aquatic.getDepth().equals("Enter swim depth"))) {

				if (JOptionPane.showConfirmDialog(aquatic,
						"Are you sure you want to save this aquatic animal ?") == 0) {

					try {
						String name = aquatic.getName();
						String nrOfLegs = aquatic.getNrOfLegs();
						String cost = aquatic.getCost();
						String danger = aquatic.getDanger();
						String depth = aquatic.getDepth();
						String water = aquatic.getWater();
						String animal = aquatic.getAquatic();
						Aquatic a;
						if (animal.equals("SeaHorse"))
							a = new SeaHorse(Integer.parseInt(nrOfLegs), name, Double.parseDouble(cost),
									Double.parseDouble(danger), Integer.parseInt(depth), WaterType.getWater(water));
						else if (animal.equals("Shark"))
							a = new Shark(Integer.parseInt(nrOfLegs), name, Double.parseDouble(cost),
									Double.parseDouble(danger), Integer.parseInt(depth), WaterType.getWater(water));
						else
							a = new Salmon(Integer.parseInt(nrOfLegs), name, Double.parseDouble(cost),
									Double.parseDouble(danger), Integer.parseInt(depth), WaterType.getWater(water));
						animals.add(a);
						JOptionPane.showMessageDialog(aquatic, "Aquatic animal was succesfully created !");
						new MainMenuController(new MainMenuFrame("Menu"), true);
					} catch (Exception ee) {
						JOptionPane.showMessageDialog(aquatic, "Entered data is wrong");
						new AquaticController(new AquaticFrame("Aquatic"), true);
					}

				} else
					new MainMenuController(new MainMenuFrame("Menu"), true);

			} else {
				JOptionPane.showMessageDialog(aquatic, "You must fill all the fields !");
				new AquaticController(new AquaticFrame("Aquatic"), true);
			}

		}
 
Example 17
/**
 * Rename the currently selected entry
 */
public void renameSelectedEntry() {
	try {
		KeyStoreHistory history = kseFrame.getActiveKeyStoreHistory();
		KeyStoreState currentState = history.getCurrentState();

		String alias = kseFrame.getSelectedEntryAlias();

		Password password = getEntryPassword(alias, currentState);

		if (password == null) {
			return;
		}

		KeyStoreState newState = currentState.createBasisForNextState(this);

		KeyStore keyStore = newState.getKeyStore();

		Key key = keyStore.getKey(alias, password.toCharArray());

		DGetAlias dGetAlias = new DGetAlias(frame, res.getString("RenameKeyAction.NewEntryAlias.Title"), alias);
		dGetAlias.setLocationRelativeTo(frame);
		dGetAlias.setVisible(true);
		String newAlias = dGetAlias.getAlias();

		if (newAlias == null) {
			return;
		}

		if (newAlias.equalsIgnoreCase(alias)) {
			JOptionPane.showMessageDialog(frame,
					MessageFormat.format(res.getString("RenameKeyAction.RenameAliasIdentical.message"), alias),
					res.getString("RenameKeyAction.RenameEntry.Title"), JOptionPane.WARNING_MESSAGE);
			return;
		}

		if (keyStore.containsAlias(newAlias)) {
			String message = MessageFormat
					.format(res.getString("RenameKeyAction.OverWriteEntry.message"), newAlias);

			int selected = JOptionPane.showConfirmDialog(frame, message,
					res.getString("RenameKeyAction.RenameEntry.Title"), JOptionPane.YES_NO_OPTION);
			if (selected != JOptionPane.YES_OPTION) {
				return;
			}

			keyStore.deleteEntry(newAlias);
			newState.removeEntryPassword(newAlias);
		}

		keyStore.setKeyEntry(newAlias, key, password.toCharArray(), null);
		newState.setEntryPassword(newAlias, new Password(password));

		keyStore.deleteEntry(alias);
		newState.removeEntryPassword(alias);

		currentState.append(newState);

		kseFrame.updateControls(true);
	} catch (Exception ex) {
		DError.displayError(frame, ex);
	}
}
 
Example 18
@Override
public void actionPerformed(ActionEvent e)
{
	EquipmentSetFacade equipSet = character.getEquipmentSetRef().get();
	List<EquipNode> paths = getSelectedEquipmentSetNodes();
	if (!paths.isEmpty())
	{
		Object[][] data = new Object[paths.size()][3];
		for (int i = 0; i < paths.size(); i++)
		{
			EquipNode path = paths.get(i);
			data[i][0] = path.getEquipment();
			data[i][1] = equipSet.getQuantity(path);
		}
		Object[] columns = {LanguageBundle.getString("in_equipItem"), //$NON-NLS-1$
			LanguageBundle.getString("in_equipQuantityAbbrev"), //$NON-NLS-1$
		};
		DefaultTableModel tableModel = new DefaultTableModel(data, columns)
		{

			@Override
			public Class<?> getColumnClass(int columnIndex)
			{
				if (columnIndex == 1)
				{
					return Integer.class;
				}
				return Object.class;
			}

			@Override
			public boolean isCellEditable(int row, int column)
			{
				return column != 0;
			}

		};
		JTable table = new JTable(tableModel);
		table.setFocusable(false);
		table.setCellSelectionEnabled(false);
		table.setDefaultRenderer(Integer.class, new TableCellUtilities.SpinnerRenderer());
		table.setDefaultEditor(Integer.class, new SpinnerEditor(equipSet.getEquippedItems()));
		table.setRowHeight(22);
		table.getColumnModel().getColumn(0).setPreferredWidth(140);
		table.getColumnModel().getColumn(1).setPreferredWidth(50);
		table.setPreferredScrollableViewportSize(table.getPreferredSize());
		JTableHeader header = table.getTableHeader();
		header.setReorderingAllowed(false);
		JScrollPane pane = EquipmentModels.prepareScrollPane(table);
		JPanel panel = new JPanel(new BorderLayout());
		JLabel help = new JLabel(LanguageBundle.getString("in_equipSelectUnequipQty")); //$NON-NLS-1$
		panel.add(help, BorderLayout.NORTH);
		panel.add(pane, BorderLayout.CENTER);
		int res = JOptionPane.showConfirmDialog(JOptionPane.getFrameForComponent(equipmentTable), panel,
			LanguageBundle.getString("in_equipUnequipSel"), //$NON-NLS-1$
			JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);

		if (res == JOptionPane.OK_OPTION)
		{
			for (int i = 0; i < paths.size(); i++)
			{
				equipSet.removeEquipment(paths.get(i), (Integer) tableModel.getValueAt(i, 1));
			}
		}
	}
}
 
Example 19
/**
 * An implemented <code>ActionListener</code> which performs all needed actions when a <code>JCheckBox</code> or <code>JButton</code>
 * is clicked.
 * 
 * @param e	an <code>ActionEvent</code>
 */	
public void actionPerformed(ActionEvent e) {
	String command = e.getActionCommand();
	//delete all mix zones
	if("clearMixZones".equals(command)){	
		if(JOptionPane.showConfirmDialog(null, Messages.getString("MixZonePanel.msgBoxClearAll"), "", JOptionPane.YES_NO_OPTION) == 0){
			Map.getInstance().clearMixZones();
			Renderer.getInstance().ReRender(true, false);
		}
	}
	//set flag to add mix zones automatically to every street corner
	else if("autoAddMixZones".equals(command)){
		Renderer.getInstance().setAutoAddMixZones(autoAddMixZones_.isSelected());
	}
	//set flag to enable encrypted communication in mix-zone
	else if("encryptedBeacons".equals(command)){
		Vehicle.setEncryptedBeaconsInMix_(encryptedBeacons_.isSelected());
		if(!encryptedBeacons_.isSelected()){
			showEncryptedBeacons_.setSelected(false);
			RSU.setShowEncryptedBeaconsInMix_(false);
		}
	}		
	//set flag to enable the demonstation mode of encrypted communication in mix-zone
	else if("showEncryptedBeacons".equals(command)){
		RSU.setShowEncryptedBeaconsInMix_(showEncryptedBeacons_.isSelected());
	}	
	//JRadioButton event; add mix zone mode
	else if("addMixZone".equals(command)){
		mixRadius_.setVisible(true);
		radiusLabel_.setVisible(true);
		autoAddMixZones_.setVisible(true);
		autoAddLabel_.setVisible(true);
		deleteNote_.setVisible(false);
		addNote_.setVisible(true);
		encryptedBeacons_.setVisible(true);	
		encryptedBeaconsLabel_.setVisible(true);
		showEncryptedBeacons_.setVisible(true);
		showEncryptedBeaconsLabel_.setVisible(true);
	}
	//JRadioButton event; delete mix zone mode
	else if("deleteMixZone".equals(command)){
		mixRadius_.setVisible(false);
		radiusLabel_.setVisible(false);
		autoAddMixZones_.setVisible(false);
		autoAddLabel_.setVisible(false);
		deleteNote_.setVisible(true);
		addNote_.setVisible(false);
		encryptedBeacons_.setVisible(false);	
		encryptedBeaconsLabel_.setVisible(false);
		showEncryptedBeacons_.setVisible(false);
		showEncryptedBeaconsLabel_.setVisible(false);
	}
}
 
Example 20
Source Project: scelight   File: LGuiUtils.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * Shows a YES-NO confirmation dialog to the user.
 * <p>
 * This method blocks until the dialog is closed.
 * </p>
 * 
 * @param messages messages and components to be displayed to the user
 * @return true if YES option was chosen, false otherwise (including closing the dialog)
 */
public static boolean confirm( final Object... messages ) {
	Sound.beepOnConfirmation();
	
	return JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog( LEnv.CURRENT_GUI_FRAME.get(), messages, "Confirmation", JOptionPane.YES_NO_OPTION,
	        JOptionPane.WARNING_MESSAGE );
}