List of usage examples for javax.swing JOptionPane showConfirmDialog
public static int showConfirmDialog(Component parentComponent, Object message) throws HeadlessException
From source file:net.sourceforge.doddle_owl.ui.GeneralOntologySelectionPanel.java
public void actionPerformed(ActionEvent e) { DODDLEProject project = DODDLE_OWL.getCurrentProject(); if (e.getSource() == removeGeneralOntologyDirButton) { int result = JOptionPane.showConfirmDialog(this, Translator.getTerm("RemoveGeneralOntologyDirectoryButton") + ": " + System.lineSeparator() + Utils.TEMP_DIR); if (result == JOptionPane.YES_OPTION) { String tmpDirName = "net.sourceforge.doddle-owl"; // tmpDirName??????????? File tmpDir = new File(Utils.TEMP_DIR); if (tmpDir.getAbsolutePath().contains(tmpDirName)) { deleteFile(tmpDir); // ??????? }/*from ww w . j a v a2 s. c om*/ } } else if (e.getSource() == edrCheckBox) { enableEDRDic(edrCheckBox.isSelected()); project.addLog("GenericEDRCheckBox", edrCheckBox.isSelected()); } else if (e.getSource() == edrtCheckBox) { enableEDRTDic(edrtCheckBox.isSelected()); project.addLog("TechnicalEDRCheckBox", edrtCheckBox.isSelected()); } else if (e.getSource() == wnCheckBox) { enableWordNetDic(wnCheckBox.isSelected()); wnVersionSelectionPanel.setEnabled(wnCheckBox.isSelected()); project.addLog("WordNetCheckBox", wnCheckBox.isSelected()); } else if (e.getSource() == jpnWnCheckBox) { enableJpnWordNetDic(jpnWnCheckBox.isSelected()); project.addLog("JpnWordNetCheckBox", jpnWnCheckBox.isSelected()); } else if (e.getSource() == jwoCheckBox) { if (jwoCheckBox.isSelected()) { File jwoDir = new File(JWO_HOME); if (!jwoDir.exists()) { jwoDir.mkdir(); } String[] tdbFiles = { "GOSP.dat", "GOSP.idn", "GOSP.info", "GPOS.dat", "GPOS.idn", "GPOS.info", "GSPO.dat", "GSPO.idn", "GSPO.info", "node2id.dat", "node2id.idn", "node2id.info", "nodes.dat", "nodes.info", "OSP.dat", "OSP.idn", "OSP.info", "OSPG.dat", "OSPG.idn", "OSPG.info", "POS.dat", "POS.idn", "POS.info", "POSG.dat", "POSG.idn", "POSG.info", "prefix2id.dat", "prefix2id.idn", "prefix2id.info", "prefixes.dat", "prefixes.info", "prefixIdx.dat", "prefixIdx.idn", "prefixIdx.info", "SPO.dat", "SPO.idn", "SPO.info", "SPOG.dat", "SPOG.idn", "SPOG.info", "this.info" }; for (String fname : tdbFiles) { File f = new File(JWO_HOME + File.separator + fname); if (!f.exists()) { URL url = DODDLE_OWL.class.getClassLoader() .getResource(Utils.RESOURCE_DIR + "jwo/" + f.getName()); try { if (url != null) { FileUtils.copyURLToFile(url, f); DODDLE_OWL.getLogger().log(Level.INFO, "copy: " + f.getAbsolutePath()); } } catch (IOException ioe) { ioe.printStackTrace(); } } } if (OWLOntologyManager.getRefOntology(jwoDir.getAbsolutePath()) == null) { dataset = TDBFactory.createDataset(jwoDir.getAbsolutePath()); Model ontModel = dataset.getDefaultModel(); ReferenceOWLOntology refOnt = new ReferenceOWLOntology(ontModel, jwoDir.getAbsolutePath(), nameSpaceTable); OWLOntologyManager.addRefOntology(refOnt.getURI(), refOnt); } } } }
From source file:com.stonelion.zooviewer.ui.JZVNodePanel.java
/** * Returns the 'Delete node(s)' action.//from ww w . j a va2 s . com * <p> * The action is created and mapped to the [Delete] key stroke * </p> * * @return the action */ @SuppressWarnings("serial") private Action getDeleteAction() { if (this.deleteAction == null) { String actionCommand = bundle.getString(DELETE_NODE_KEY); String actionKey = bundle.getString(DELETE_NODE_KEY + ".action"); this.deleteAction = new AbstractAction(actionCommand, Icons.DELETE) { @Override public void actionPerformed(ActionEvent e) { System.out.println("actionPerformed(): action = " + e.getActionCommand()); if (checkAction()) { // Checks if several nodes will be deleted if (nodes.length > 1) { model.deleteNodes(nodes); } else { model.deleteNode(nodes[0]); } } } private boolean checkAction() { // No node selected if (nodes == null) { JOptionPane.showMessageDialog(JZVNodePanel.this, bundle.getString("dlg.error.deleteWithoutSelection"), bundle.getString("dlg.error.title"), JOptionPane.ERROR_MESSAGE); return false; } return (JOptionPane.showConfirmDialog(JZVNodePanel.this, bundle.getString("dlg.confirm.update")) == JOptionPane.YES_OPTION); } }; this.deleteAction.putValue(Action.ACTION_COMMAND_KEY, actionKey); this.getInputMap(WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), actionKey); this.getActionMap().put(actionKey, this.deleteAction); } return this.deleteAction; }
From source file:javaapplication1.AlgoritmoGenetico.java
private void btnIniciarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnIniciarActionPerformed ArrayList<Individuo> mustra = new ArrayList<>(); int numeroDeIndividios = Integer.parseInt(numeroDeIndividuostext.getText()); for (int i = 0; i < numeroDeIndividios; i++) { Individuo ind = new Individuo(); ind.generarMatrizAleatoria();// w w w.j a v a 2s . c o m ind.generarMatrizBinaria(); ind.generarVectorBinario(); mustra.add(ind); //mostrarEnConsola(ind.getMatriz()); //mostrarMatrizBinaria(ind.getMatrizBinaria()); // JOptionPane.showMessageDialog(null," individuo "+i); } //System.out.println(mustra.get(0).getMatriz()[0][0]); Sintoma sintoma = new Sintoma(); Enfermedad enfermedad = new Enfermedad(); Sigmoide sigmoide = new Sigmoide(); Cruce cruce; double yc[] = new double[4]; double error[] = new double[4]; double errorPatron[] = new double[10]; double errorIteracion[] = new double[Integer.parseInt(numeroDeIteraciontxt.getText())]; boolean bandera = true; int it = 0; do { for (int p = 0; p < 10; p++) { //estos son los patrones int x[] = sintoma.getFila(p); int y[] = enfermedad.getFila(p); for (Individuo indi : mustra) { double R[][] = indi.getMatriz(); double suma = 0; double sumaError = 0; if (indi.getErrorPatron() == 0) { for (int i = 0; i < 4; i++) { for (int j = 0; j < 7; j++) { double aux = x[j] * R[j][i]; suma += aux; } yc[i] = sigmoide.function(suma); suma = 0; error[i] = y[i] - yc[i]; } for (int i = 0; i < error.length; i++) { sumaError += Math.abs(error[i]); } indi.setErrorPatron(sumaError / 4); } } //Ordenar de menor a mayor para obtener los mejores individuos para la reproduccion Collections.sort(mustra, new Comparator<Individuo>() { @Override public int compare(Individuo p1, Individuo p2) { // Aqui esta el truco, ahora comparamos p2 con p1 y no al reves como antes return new Double(p1.getErrorPatron()).compareTo(new Double(p2.getErrorPatron())); } }); System.out.println("//////////////Cargando////////////////////////////"); errorPatron[p] = mustra.get(0).getErrorPatron(); cruce = new Cruce(numeroDeIndividios, mustra); mustra = cruce.nuevaGenaracion(); graficarErrorPatron(errorPatron); } errorIteracion[it] = errorIteracion(errorPatron); graficarErrorIteracion(errorIteracion); it++; if (it >= Integer.parseInt(numeroDeIteraciontxt.getText())) { bandera = false; } else { if (errorIteracion[it - 1] <= Double.parseDouble(errorDeConvergencia.getText())) { bandera = false; } } } while (bandera); if (errorIteracion[it - 1] <= Double.parseDouble(errorDeConvergencia.getText())) { int s = JOptionPane.showConfirmDialog(null, "Encontro Individuo mas apto con un error de: " + mustra.get(0).getErrorPatron()); if (s == 0) { db conexion; try { conexion = new db(); individuoDAO indDao = new individuoDAO(conexion); indDao.insert(mustra.get(0)); } catch (SQLException ex) { Logger.getLogger(AlgoritmoGenetico.class.getName()).log(Level.SEVERE, null, ex); } } } else { JOptionPane.showMessageDialog(null, "convergio..."); } }
From source file:dev.agustin.serializer.MainWindow.java
private void doExit() { if (hasChanged) { int state = JOptionPane.showConfirmDialog(this, "File has been changed. Save before exit?"); if (state == JOptionPane.YES_OPTION) { saveJpctFile();//w w w. j av a2 s . c o m } else if (state == JOptionPane.CANCEL_OPTION) { return; } } System.exit(0); }
From source file:com.raddle.tools.MergeMain.java
private void initGUI() { try {//from w ww . j a va2 s.c om { this.setBounds(0, 0, 1050, 600); getContentPane().setLayout(null); this.setTitle("\u5c5e\u6027\u6587\u4ef6\u6bd4\u8f83"); { sourceTxt = new JTextField(); getContentPane().add(sourceTxt); sourceTxt.setBounds(12, 12, 373, 22); } { sourceBtn = new JButton(); getContentPane().add(sourceBtn); sourceBtn.setText("\u6253\u5f00"); sourceBtn.setBounds(406, 12, 74, 22); sourceBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { JFileChooser fileChooser = new JFileChooser(); // fileChooser.addChoosableFileFilter( new FileNameExtensionFilter("", "properties")); File curFile = new File(sourceTxt.getText()); if (curFile.exists()) { fileChooser.setCurrentDirectory(curFile.getParentFile()); } int result = fileChooser.showOpenDialog(MergeMain.this); if (result == JFileChooser.APPROVE_OPTION) { File selected = fileChooser.getSelectedFile(); source = new PropertyHolder(selected, "utf-8"); sourceTxt.setText(selected.getAbsolutePath()); properties.setProperty("left.file", selected.getAbsolutePath()); savePropMergeFile(); compare(); } } }); } { targetTxt = new JTextField(); getContentPane().add(targetTxt); targetTxt.setBounds(496, 12, 419, 22); } { targetBtn = new JButton(); getContentPane().add(targetBtn); targetBtn.setText("\u6253\u5f00"); targetBtn.setBounds(935, 12, 81, 22); targetBtn.setSize(74, 22); targetBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { JFileChooser fileChooser = new JFileChooser(); // fileChooser.addChoosableFileFilter( new FileNameExtensionFilter("", "properties")); File curFile = new File(targetTxt.getText()); if (curFile.exists()) { fileChooser.setCurrentDirectory(curFile.getParentFile()); } int result = fileChooser.showOpenDialog(MergeMain.this); if (result == JFileChooser.APPROVE_OPTION) { File selected = fileChooser.getSelectedFile(); target = new PropertyHolder(selected, "utf-8"); targetTxt.setText(selected.getAbsolutePath()); properties.setProperty("right.file", selected.getAbsolutePath()); savePropMergeFile(); compare(); } } }); } { jScrollPane1 = new JScrollPane(); getContentPane().add(jScrollPane1); jScrollPane1.setBounds(12, 127, 373, 413); { ListModel sourceListModel = new DefaultComboBoxModel(new String[] {}); sourceList = new JList(); jScrollPane1.setViewportView(sourceList); sourceList.setAutoscrolls(true); sourceList.setModel(sourceListModel); sourceList.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent evt) { if (evt.getKeyCode() == KeyEvent.VK_DELETE) { PropertyLine v = (PropertyLine) sourceList.getSelectedValue(); if (v != null) { int ret = JOptionPane.showConfirmDialog(MergeMain.this, "?" + v.getKey() + "?"); if (ret == JOptionPane.YES_OPTION) { v.setState(LineState.deleted); compare(); sourceList.setSelectedValue(v, true); } } } } }); sourceList.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { if (evt.getClickCount() == 2) { Object v = sourceList.getSelectedValue(); updatePropertyLine((PropertyLine) v); sourceList.setSelectedValue(v, true); } } }); sourceList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent evt) { if (sourceList.getSelectedValue() != null) { PropertyLine pl = (PropertyLine) sourceList.getSelectedValue(); if (target != null) { PropertyLine p = target.getLine(pl.getKey()); if (p != null) { TextDiffResult rt = TextdiffUtil.getDifferResult(p.toString(), pl.toString()); diffResultPane.setText("" + rt.getTargetHtml() + "<br/>?" + rt.getSrcHtml()); selectLine(targetList, p); return; } } TextDiffResult rt = TextdiffUtil.getDifferResult("", pl.toString()); diffResultPane.setText( "" + rt.getTargetHtml() + "<br/>?" + rt.getSrcHtml()); } } }); } } { jScrollPane2 = new JScrollPane(); getContentPane().add(jScrollPane2); jScrollPane2.setBounds(496, 127, 419, 413); { ListModel targetListModel = new DefaultComboBoxModel(new String[] {}); targetList = new JList(); jScrollPane2.setViewportView(targetList); targetList.setAutoscrolls(true); targetList.setModel(targetListModel); targetList.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent evt) { if (evt.getKeyCode() == KeyEvent.VK_DELETE) { PropertyLine v = (PropertyLine) targetList.getSelectedValue(); if (v != null) { int ret = JOptionPane.showConfirmDialog(MergeMain.this, "?" + v.getKey() + "?"); if (ret == JOptionPane.YES_OPTION) { v.setState(LineState.deleted); compare(); targetList.setSelectedValue(v, true); } } } } }); targetList.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { if (evt.getClickCount() == 2) { Object v = targetList.getSelectedValue(); updatePropertyLine((PropertyLine) v); targetList.setSelectedValue(v, true); } } }); targetList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent evt) { if (targetList.getSelectedValue() != null) { PropertyLine pl = (PropertyLine) targetList.getSelectedValue(); if (source != null) { PropertyLine s = source.getLine(pl.getKey()); if (s != null) { TextDiffResult rt = TextdiffUtil.getDifferResult(pl.toString(), s.toString()); diffResultPane.setText("" + rt.getTargetHtml() + "<br/>?" + rt.getSrcHtml()); selectLine(sourceList, s); return; } } TextDiffResult rt = TextdiffUtil.getDifferResult(pl.toString(), ""); diffResultPane.setText( "" + rt.getTargetHtml() + "<br/>?" + rt.getSrcHtml()); } } }); } } { sourceSaveBtn = new JButton(); getContentPane().add(sourceSaveBtn); sourceSaveBtn.setText("\u4fdd\u5b58"); sourceSaveBtn.setBounds(406, 45, 74, 22); sourceSaveBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { int result = JOptionPane.showConfirmDialog(MergeMain.this, "???\n" + source.getPropertyFile().getAbsolutePath()); if (result == JOptionPane.YES_OPTION) { source.saveFile(); JOptionPane.showMessageDialog(MergeMain.this, "??"); clearState(source); compare(); } } }); } { targetSaveBtn = new JButton(); getContentPane().add(targetSaveBtn); targetSaveBtn.setText("\u4fdd\u5b58"); targetSaveBtn.setBounds(935, 45, 81, 22); targetSaveBtn.setSize(74, 22); targetSaveBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { int result = JOptionPane.showConfirmDialog(MergeMain.this, "????\n" + target.getPropertyFile().getAbsolutePath()); if (result == JOptionPane.YES_OPTION) { target.saveFile(); JOptionPane.showMessageDialog(MergeMain.this, "??"); clearState(target); compare(); } } }); } { toTargetBtn = new JButton(); getContentPane().add(toTargetBtn); toTargetBtn.setText("->"); toTargetBtn.setBounds(406, 221, 74, 22); toTargetBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { Object[] oo = sourceList.getSelectedValues(); for (Object selected : oo) { PropertyLine s = (PropertyLine) selected; if (s != null && target != null) { PropertyLine t = target.getLine(s.getKey()); if (t == null) { PropertyLine n = s.clone(); n.setState(LineState.added); target.addPropertyLineAtSuitedPosition(n); } else if (!t.getValue().equals(s.getValue())) { t.setState(LineState.updated); t.setValue(s.getValue()); } else if (t.getState() == LineState.deleted) { if (t.getValue().equals(t.getOriginalValue())) { t.setState(LineState.original); } else { t.setState(LineState.updated); } } compare(); } } } }); } { toSourceBtn = new JButton(); getContentPane().add(toSourceBtn); toSourceBtn.setText("<-"); toSourceBtn.setBounds(406, 255, 74, 22); toSourceBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { Object[] oo = targetList.getSelectedValues(); for (Object selected : oo) { PropertyLine t = (PropertyLine) selected; if (t != null && source != null) { PropertyLine s = source.getLine(t.getKey()); if (s == null) { PropertyLine n = t.clone(); n.setState(LineState.added); source.addPropertyLineAtSuitedPosition(n); } else if (!s.getValue().equals(t.getValue())) { s.setState(LineState.updated); s.setValue(t.getValue()); } else if (s.getState() == LineState.deleted) { if (s.getValue().equals(s.getOriginalValue())) { s.setState(LineState.original); } else { s.setState(LineState.updated); } } compare(); } } } }); } { jScrollPane3 = new JScrollPane(); getContentPane().add(jScrollPane3); jScrollPane3.setBounds(12, 73, 903, 42); { diffResultPane = new JTextPane(); jScrollPane3.setViewportView(diffResultPane); diffResultPane.setBounds(12, 439, 903, 63); diffResultPane.setContentType("text/html"); diffResultPane.setPreferredSize(new java.awt.Dimension(901, 42)); } } { compareBtn = new JButton(); getContentPane().add(compareBtn); compareBtn.setText("\u6bd4\u8f83"); compareBtn.setBounds(406, 139, 74, 22); compareBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { compare(); } }); } { sourceReloadBtn = new JButton(); getContentPane().add(sourceReloadBtn); sourceReloadBtn.setText("\u91cd\u65b0\u8f7d\u5165"); sourceReloadBtn.setBounds(12, 40, 64, 29); sourceReloadBtn.setSize(90, 22); sourceReloadBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { if (sourceTxt.getText().length() > 0) { File curFile = new File(sourceTxt.getText().trim()); if (curFile.exists()) { source = new PropertyHolder(curFile, "utf-8"); sourceTxt.setText(curFile.getAbsolutePath()); properties.setProperty("left.file", curFile.getAbsolutePath()); savePropMergeFile(); compare(); } else { JOptionPane.showMessageDialog(MergeMain.this, "" + curFile.getAbsolutePath() + "?"); } } } }); } { targetReloadBtn = new JButton(); getContentPane().add(targetReloadBtn); targetReloadBtn.setText("\u91cd\u65b0\u8f7d\u5165"); targetReloadBtn.setBounds(839, 45, 90, 22); targetReloadBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { if (targetTxt.getText().length() > 0) { File curFile = new File(targetTxt.getText().trim()); if (curFile.exists()) { target = new PropertyHolder(curFile, "utf-8"); targetTxt.setText(curFile.getAbsolutePath()); properties.setProperty("right.file", curFile.getAbsolutePath()); savePropMergeFile(); compare(); } else { JOptionPane.showMessageDialog(MergeMain.this, "" + curFile.getAbsolutePath() + "?"); } } } }); } { helpBtn = new JButton(); getContentPane().add(helpBtn); helpBtn.setText("\u5e2e\u52a9"); helpBtn.setBounds(405, 338, 38, 29); helpBtn.setSize(74, 22); helpBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { StringBuilder sb = new StringBuilder(); sb.append("?").append("\n"); sb.append("del").append("\n"); sb.append("??").append("\n"); sb.append(": /.prop-merge/prop-merge.properties").append("\n"); JOptionPane.showMessageDialog(MergeMain.this, sb.toString()); } }); } { sourceEditBtn = new JButton(); getContentPane().add(sourceEditBtn); sourceEditBtn.setText("\u7f16\u8f91\u6587\u4ef6"); sourceEditBtn.setBounds(108, 40, 90, 22); sourceEditBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { if (sourceTxt.getText().length() > 0) { File curFile = new File(sourceTxt.getText()); editFile(curFile); } } }); } { targetEditBtn = new JButton(); getContentPane().add(targetEditBtn); targetEditBtn.setText("\u7f16\u8f91\u6587\u4ef6"); targetEditBtn.setBounds(743, 45, 90, 22); targetEditBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { if (targetTxt.getText().length() > 0) { File curFile = new File(targetTxt.getText()); editFile(curFile); } } }); } } pack(); } catch (Exception e) { e.printStackTrace(); } }
From source file:eu.apenet.dpt.standalone.gui.db.RetrieveFromDb.java
public void checkForUpdates(Container contentPane, String textNewAvailableVersion, String versionNb) { SimpleDateFormat dateFormatYYYYMMDD = new SimpleDateFormat("yyyyMMdd"); Date today = new Date(); String date = dateFormatYYYYMMDD.format(today); date = retrieve(DBUtil.OptionKeys.OPTION_UPDATEDATE.getName(), date); boolean doCheckUpdate = false; try {// w ww . j a va2 s. c o m Date lastUpdate = dateFormatYYYYMMDD.parse(date); long difference = today.getTime() - lastUpdate.getTime(); long oneWeeksInMilliseconds = 7 * 24 * 60 * 60 * 1000; if ((oneWeeksInMilliseconds - difference) < 0) { LOG.info("We do a check for updates - it has been more than 1 week since the last one."); doCheckUpdate = true; String query = DBUtil.createUpdateQuery(DBUtil.DBNames.TABLE_OPTIONS.getName(), DBUtil.DBNames.COLUMN_VALUE.getName(), dateFormatYYYYMMDD.format(today), DBUtil.OptionKeys.OPTION_UPDATEDATE.getName()); dbUtil.doSqlQuery(query, null); LOG.info("We just updated the database with the date of today - next check in 1 week."); } else { LOG.info("We do not do a check for updates"); } } catch (Exception e) { throw new RuntimeException(e); } if (doCheckUpdate) { try { URL url = new URL( "http://www.archivesportaleurope.net/Portal/dptupdate/version?versionNb=" + versionNb); // URL url = new URL("http://localhost:8080/Portal/dptupdate/version?versionNb=" + versionNb); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); if (connection.getResponseCode() == 200) { String newVersionNb = IOUtils.toString(connection.getInputStream()); LOG.info("New version available: " + newVersionNb); if (JOptionPane.showConfirmDialog(contentPane, textNewAvailableVersion) == 0) { BareBonesBrowserLaunch .openURL("http://dpt.archivesportaleurope.net/APE_data_preparation_tool_" + newVersionNb + ".zip"); System.exit(0); } } } catch (Exception e) { LOG.error("Error to connect for checking the new version (probably no internet connection)", e); } } }
From source file:uk.co.markfrimston.tasktree.Main.java
protected void promptAndRemove(DefaultMutableTreeNode node) { boolean canRemove = true; if (node.getChildCount() > 0) { int resp = JOptionPane.showConfirmDialog(this, "Item contains nested items. Remove anyway?"); if (resp != JOptionPane.YES_OPTION) { canRemove = false;// w ww . ja v a 2s .co m } } if (canRemove) { this.taskTree.removeTask(node); } }
From source file:fi.hoski.remote.ui.Admin.java
private void menuEvent() { JMenu eventMenu = new JMenu(); TextUtil.populate(eventMenu, "EVENTS"); menuBar.add(eventMenu);//from w w w . j a v a 2s .c o m JMenu addEventMenu = new JMenu(); TextUtil.populate(addEventMenu, "ADD EVENTS"); eventMenu.add(addEventMenu); JMenu editEventMenu = new JMenu(); TextUtil.populate(editEventMenu, "EDIT EVENTS"); eventMenu.add(editEventMenu); JMenu deleteEventMenu = new JMenu(); TextUtil.populate(deleteEventMenu, "DELETE EVENTS"); eventMenu.add(deleteEventMenu); int index = 0; for (final EventType eventType : EventType.values()) { // add JMenuItem addItem = new JMenuItem(); TextUtil.populate(addItem, eventType.name()); addItem.addActionListener(creators[index++]); addEventMenu.add(addItem); // edit ActionListener editAction = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Event selected = chooseEvent(eventType, "EDIT SELECTED"); if (selected != null) { EventEditor editor = new EventEditor(null); editor.edit(selected); } else { JOptionPane.showMessageDialog(frame, TextUtil.getText("NO SELECTION"), TextUtil.getText("MESSAGE"), JOptionPane.INFORMATION_MESSAGE); } } }; editAction = createActionListener(frame, editAction); JMenuItem editItem = new JMenuItem(); TextUtil.populate(editItem, eventType.name()); editItem.addActionListener(editAction); editEventMenu.add(editItem); // delete ActionListener deleteAction = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { List<Event> selected = chooseEvents(eventType, "DELETE SELECTED"); if (selected != null && selected.size() >= 1) { if (JOptionPane.showConfirmDialog(panel, TextUtil.getText("CONFIRM DELETE")) == JOptionPane.YES_OPTION) { dss.deleteEvents(selected); } } else { JOptionPane.showMessageDialog(frame, TextUtil.getText("NO SELECTION"), TextUtil.getText("MESSAGE"), JOptionPane.INFORMATION_MESSAGE); } } }; deleteAction = createActionListener(frame, deleteAction); JMenuItem deleteItem = new JMenuItem(); TextUtil.populate(deleteItem, eventType.name()); deleteItem.addActionListener(deleteAction); deleteEventMenu.add(deleteItem); } }
From source file:com.mirth.connect.client.ui.SettingsPanelServer.java
public void doBackup() { if (isSaveEnabled()) { int option = JOptionPane.showConfirmDialog(this, "Would you like to save the settings first?"); if (option == JOptionPane.YES_OPTION) { if (!doSave()) { return; }//from w ww .j ava 2 s.c o m } else if (option == JOptionPane.CANCEL_OPTION || option == JOptionPane.CLOSED_OPTION) { return; } } final String backupDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); final File exportFile = getFrame().createFileForExport(backupDate.substring(0, 10) + " Mirth Backup.xml", "XML"); if (exportFile != null) { final String workingId = getFrame().startWorking("Exporting server config..."); SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() { public Void doInBackground() { ServerConfiguration configuration = null; try { configuration = getFrame().mirthClient.getServerConfiguration(); } catch (ClientException e) { getFrame().alertThrowable(SettingsPanelServer.this, e); return null; } // Update resource names for (Channel channel : configuration.getChannels()) { getFrame().updateResourceNames(channel, configuration.getResourceProperties().getList()); } configuration.setDate(backupDate); String backupXML = ObjectXMLSerializer.getInstance().serialize(configuration); getFrame().exportFile(backupXML, exportFile, "Server Configuration"); return null; } public void done() { getFrame().stopWorking(workingId); } }; worker.execute(); } }
From source file:generadorqr.jifrNuevoQr.java
void GuardarQr() { if (txtNombreQr.getText().trim().isEmpty() || txtAreaDescripcionNuevoQr.getText().trim().isEmpty()) JOptionPane.showMessageDialog(null, "Ingrese Los Campos Obligatorios"); else {/*from w w w .ja v a2s . c o m*/ try { if (btnGenerarNuevoQr.getText().contains("Guardar")) { if (idCategoria == 0) { JOptionPane.showMessageDialog(this, "Debe de seleccionar una categora"); return; } //Ingreso en nuevo usuario if (!tempImagen[0].isEmpty()) { File imagen1 = new File(imagen[0]); if (!imagen1.exists()) imagen1.mkdir(); imagen[0] += "\\Imagenes"; if (CopiaArchivos(tempImagen[0], imagen[0], imagen, "Imagen1.jpg", 0)) imagen[0] += "\\Imagen1.jpg"; else return; if (!tempImagen[1].isEmpty()) { if (CopiaArchivos(tempImagen[1], imagen[1], imagen, "Imagen2.jpg", 1)) imagen[1] += "\\Imagen2.jpg"; else return; } if (!tempImagen[2].isEmpty()) { if (CopiaArchivos(tempImagen[2], imagen[2], imagen, "Imagen3.jpg", 2)) imagen[2] += "\\Imagen3.jpg"; else return; } if (!tempAudio.isEmpty()) { if (CopiaArchivos(tempAudio, audio, "Audio.mp3", 0)) audio += "\\Audio.mp3"; else return; } if (!tempVideo.isEmpty()) { if (CopiaArchivos(tempVideo, video, "Video.mp4", 1)) video += "\\Video.mp4"; else return; } File guardarQR = new File(imagenQR); try { ImageIO.write(bufferedImage, "png", guardarQR); } catch (Exception e) { } String SQLA = "INSERT INTO articulos(IDCATEGORIA,NOMBREARTICULO,CANTIDADARTICULO,DESCRIPCIONARTICULO,IMAGENUNOARTICULO,IMAGENDOSARTICULO," + "IMAGENTRESARTICULO,SONIDOARTICULO,VIDEOARTICULO,CODIGOQRARTICULO,IMAGENQRARTICULO)" + " VALUES(?,?,?,?,?,?,?,?,?,?,?)"; PreparedStatement ps = conn.prepareStatement(SQLA); ps.setInt(1, idCategoria); ps.setString(2, txtNombreQr.getText()); ps.setString(3, txtCantidadArticulo.getText()); ps.setString(4, txtAreaDescripcionNuevoQr.getText()); ps.setString(5, imagen[0]); ps.setString(6, imagen[1]); ps.setString(7, imagen[2]); ps.setString(8, audio); ps.setString(9, video); ps.setString(10, codigoImagenQR); ps.setString(11, imagenQR); int n = ps.executeUpdate(); if (n > 0) { JOptionPane.showMessageDialog(null, "Nuevo Qr creado Correctamente"); dispose(); internalGestionArticulos = new jifrGestionArticulos(); Principal.centrarVentanaGestionCA(internalGestionArticulos); } } else JOptionPane.showMessageDialog(this, "Debe por lo menos agregar una imagen al reconocimiento QR"); } else { if (idCategoria == idCat) idCategoria = idCat; else if (idCategoria == 0) { JOptionPane.showMessageDialog(this, "Debe de seleccionar una categora"); return; } imagen[0] += "\\Imagenes"; if (tempImagen[0].isEmpty()) imagen[0] = tempRutaActual[0]; else { File borrarImagenAntigua = new File(tempRutaActual[0]); borrarImagenAntigua.delete(); if (CopiaArchivos(tempImagen[0], imagen[0], imagen, "Imagen1.jpg", 0)) imagen[0] += "\\Imagen1.jpg"; else return; } if (tempImagen[1].isEmpty()) imagen[1] = tempRutaActual[1]; else { File borrarImagenAntigua = new File(tempRutaActual[1]); borrarImagenAntigua.delete(); if (CopiaArchivos(tempImagen[1], imagen[1], imagen, "Imagen2.jpg", 1)) imagen[1] += "\\Imagen2.jpg"; else return; } if (tempImagen[2].isEmpty()) imagen[2] = tempRutaActual[2]; else { File borrarImagenAntigua = new File(tempRutaActual[2]); borrarImagenAntigua.delete(); if (CopiaArchivos(tempImagen[2], imagen[2], imagen, "Imagen3.jpg", 2)) imagen[2] += "\\Imagen3.jpg"; else return; } if (tempAudio.isEmpty()) audio = tempRutaActual[3]; else { File borrarMultimediaAntigua = new File(tempRutaActual[3]); borrarMultimediaAntigua.delete(); if (CopiaArchivos(tempAudio, audio, "Audio.mp3", 0)) audio += "\\Audio.mp3"; else return; } if (tempVideo.isEmpty()) video = tempRutaActual[4]; else { File borrarMultimediaAntigua = new File(tempRutaActual[4]); borrarMultimediaAntigua.delete(); if (CopiaArchivos(tempVideo, video, "Video.mp4", 1)) video += "\\Video.mp4"; else return; } if (txtNombreQr.getText().trim().isEmpty() || txtAreaDescripcionNuevoQr.getText().trim().isEmpty()) JOptionPane.showMessageDialog(null, "Ingrese Los Campos Obligatorios"); else { String SQL = "UPDATE articulos SET IDCATEGORIA = ?, NOMBREARTICULO = ?,CANTIDADARTICULO = ?, DESCRIPCIONARTICULO = ?, IMAGENUNOARTICULO = ?, " + "IMAGENDOSARTICULO = ?, IMAGENTRESARTICULO = ?, SONIDOARTICULO = ?, VIDEOARTICULO = ? " + "WHERE IDARTICULO = " + ItemSeleccionado.idArticulo; PreparedStatement ps = conn.prepareStatement(SQL); ps.setInt(1, idCategoria); ps.setString(2, txtNombreQr.getText()); ps.setString(3, txtCantidadArticulo.getText()); ps.setString(4, txtAreaDescripcionNuevoQr.getText()); ps.setString(5, imagen[0]); ps.setString(6, imagen[1]); ps.setString(7, imagen[2]); ps.setString(8, audio); ps.setString(9, video); int n = ps.executeUpdate(); if (n > 0) { JOptionPane.showMessageDialog(null, "Informacin del QR actualizada Correctamente"); dispose(); internalGestionArticulos = new jifrGestionArticulos(); Principal.centrarVentanaGestionCA(internalGestionArticulos); } } } } catch (SQLException e) { JOptionPane.showConfirmDialog(null, "Error: " + e.getMessage()); File borrarDirectorio = new File( ValoresConstantes.DIRECTORIO_PRINCIPAL + "\\" + txtNombreQr.getText()); if (borrarDirectorio.exists()) try { FileUtils.deleteDirectory(borrarDirectorio); } catch (IOException ex) { Logger.getLogger(jifrNuevoQr.class.getName()).log(Level.SEVERE, null, ex); } } } }