List of usage examples for javax.swing JOptionPane WARNING_MESSAGE
int WARNING_MESSAGE
To view the source code for javax.swing JOptionPane WARNING_MESSAGE.
Click Source Link
From source file:com.sshtools.common.ui.SshToolsApplicationClientPanel.java
/** * * * @param saveAs/*from w w w . j av a 2s. c o m*/ * @param file * @param profile * * @return */ public File saveConnection(boolean saveAs, File file, SshToolsConnectionProfile profile) { if (profile != null) { if ((file == null) || saveAs) { String prefsDir = super.getApplication().getApplicationPreferencesDirectory().getAbsolutePath(); JFileChooser fileDialog = new JFileChooser(prefsDir); fileDialog.setFileFilter(connectionFileFilter); int ret = fileDialog.showSaveDialog(this); if (ret == fileDialog.CANCEL_OPTION) { return null; } file = fileDialog.getSelectedFile(); if (!file.getName().toLowerCase().endsWith(".xml")) { file = new File(file.getAbsolutePath() + ".xml"); } } try { if (saveAs && file.exists()) { if (JOptionPane.showConfirmDialog(this, "File already exists. Are you sure?", "File exists", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.NO_OPTION) { return null; } } // Check to make sure its valid if (file != null) { // Save the connection details to file log.debug("Saving connection to " + file.getAbsolutePath()); profile.save(file.getAbsolutePath()); if (profile == getCurrentConnectionProfile()) { log.debug("Current connection saved, disabling save action."); setNeedSave(false); } return file; } else { showExceptionMessage("The file specified is invalid!", "Save Connection"); } } catch (InvalidProfileFileException e) { showExceptionMessage(e.getMessage(), "Save Connection"); } } return null; }
From source file:ca.uhn.hl7v2.testpanel.controller.Controller.java
public void showDialogWarning(String message) { JOptionPane.showMessageDialog(provideViewFrameIfItExists(), message, DIALOG_TITLE, JOptionPane.WARNING_MESSAGE); }
From source file:de.bfs.radon.omsimulation.gui.OMPanelResults.java
/** * Initialises the interface of the results panel. *//*from ww w. ja v a 2s .c o m*/ protected void initialize() { setLayout(null); lblExportChartTo = new JLabel("Export chart to ..."); lblExportChartTo.setBounds(436, 479, 144, 14); lblExportChartTo.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); lblExportChartTo.setVisible(false); add(lblExportChartTo); btnMaximize = new JButton("Fullscreen"); btnMaximize.setBounds(10, 475, 124, 23); btnMaximize.setFont(new Font("SansSerif", Font.PLAIN, 11)); btnMaximize.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (comboBoxSimulations.isEnabled()) { if (comboBoxSimulations.getSelectedItem() != null) { JFrame chartFrame = new JFrame(); OMSimulation simulation = (OMSimulation) comboBoxSimulations.getSelectedItem(); String title = simulation.toString(); DescriptiveStatistics statistics = null; OMStatistics statisticsType = (OMStatistics) comboBoxStatistics.getSelectedItem(); OMRoomType roomType = null; switch (statisticsType) { case RoomArithmeticMeans: title = "R_AM, " + title; statistics = simulation.getRoomAmDescriptiveStats(); roomType = OMRoomType.Room; break; case RoomGeometricMeans: title = "R_GM, " + title; statistics = simulation.getRoomGmDescriptiveStats(); roomType = OMRoomType.Room; break; case RoomMedianQ50: title = "R_MED, " + title; statistics = simulation.getRoomMedDescriptiveStats(); roomType = OMRoomType.Room; break; case RoomMaxima: title = "R_MAX, " + title; statistics = simulation.getRoomMaxDescriptiveStats(); roomType = OMRoomType.Room; break; case CellarArithmeticMeans: title = "C_AM, " + title; statistics = simulation.getCellarAmDescriptiveStats(); roomType = OMRoomType.Cellar; break; case CellarGeometricMeans: title = "C_GM, " + title; statistics = simulation.getCellarGmDescriptiveStats(); roomType = OMRoomType.Cellar; break; case CellarMedianQ50: title = "C_MED, " + title; statistics = simulation.getCellarMedDescriptiveStats(); roomType = OMRoomType.Cellar; break; case CellarMaxima: title = "C_MAX, " + title; statistics = simulation.getCellarMaxDescriptiveStats(); roomType = OMRoomType.Cellar; break; default: title = "R_AM, " + title; statistics = simulation.getRoomAmDescriptiveStats(); roomType = OMRoomType.Misc; break; } JPanel chartPanel = createDistributionPanel(title, statistics, roomType, false, true, true); chartFrame.getContentPane().add(chartPanel); chartFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); chartFrame.setBounds(0, 0, (int) dim.getWidth(), (int) dim.getHeight()); chartFrame.setTitle("OM Simulation Tool: " + title); chartFrame.setResizable(true); chartFrame.setExtendedState(JFrame.MAXIMIZED_BOTH); chartFrame.setVisible(true); } } } }); add(btnMaximize); btnCsv = new JButton("CSV"); btnCsv.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser fileDialog = new JFileChooser(); fileDialog.setFileFilter(new FileNameExtensionFilter("*.csv", "csv")); fileDialog.showSaveDialog(getParent()); final File file = fileDialog.getSelectedFile(); if (file != null) { String csv; String[] tmpFileName = file.getAbsolutePath().split("\\."); if (tmpFileName[tmpFileName.length - 1].equals("csv")) { csv = ""; } else { csv = ".csv"; } String csvPath = file.getAbsolutePath() + csv; OMSimulation simulation = (OMSimulation) comboBoxSimulations.getSelectedItem(); OMCampaign[] campaigns = simulation.getCampaigns(); File csvFile = new File(csvPath); try { FileWriter logWriter = new FileWriter(csvFile); BufferedWriter csvOutput = new BufferedWriter(logWriter); OMStatistics statisticsType = (OMStatistics) comboBoxStatistics.getSelectedItem(); String head = ""; switch (statisticsType) { case RoomArithmeticMeans: head = "R_AM"; break; case RoomGeometricMeans: head = "R_GM"; break; case RoomMedianQ50: head = "R_MED"; break; case RoomMaxima: head = "R_MAX"; break; case CellarArithmeticMeans: head = "C_AM"; break; case CellarGeometricMeans: head = "C_GM"; break; case CellarMedianQ50: head = "C_MED"; break; case CellarMaxima: head = "C_MAX"; break; default: head = "R_AM"; break; } csvOutput.write("\"ID\";\"CAMPAIGN\";\"START\";\"" + head + "\""); csvOutput.newLine(); int value = 0; for (int i = 0; i < campaigns.length; i++) { switch (statisticsType) { case RoomArithmeticMeans: value = (int) campaigns[i].getRoomAverage(); break; case RoomGeometricMeans: value = (int) campaigns[i].getRoomLogAverage(); break; case RoomMedianQ50: value = (int) campaigns[i].getRoomMedian(); break; case RoomMaxima: value = (int) campaigns[i].getRoomMaximum(); break; case CellarArithmeticMeans: value = (int) campaigns[i].getCellarAverage(); break; case CellarGeometricMeans: value = (int) campaigns[i].getCellarLogAverage(); break; case CellarMedianQ50: value = (int) campaigns[i].getCellarMedian(); break; case CellarMaxima: value = (int) campaigns[i].getCellarMaximum(); break; default: value = (int) campaigns[i].getRoomAverage(); break; } csvOutput.write("\"" + i + "\";\"" + campaigns[i].getVariation() + "\";\"" + campaigns[i].getStart() + "\";\"" + value + "\""); csvOutput.newLine(); } JOptionPane.showMessageDialog(null, "CSV saved successfully!\n" + csvPath, "Success", JOptionPane.INFORMATION_MESSAGE); csvOutput.close(); } catch (IOException ioe) { JOptionPane.showMessageDialog(null, "Failed to write CSV. Please check permissions!\n" + ioe.getMessage(), "Failed", JOptionPane.ERROR_MESSAGE); ioe.printStackTrace(); } } else { JOptionPane.showMessageDialog(null, "Failed to write CSV. Please check the file path!", "Failed", JOptionPane.ERROR_MESSAGE); } } }); btnCsv.setBounds(590, 475, 70, 23); btnCsv.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); btnCsv.setVisible(false); add(btnCsv); btnPdf = new JButton("PDF"); btnPdf.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser fileDialog = new JFileChooser(); fileDialog.setFileFilter(new FileNameExtensionFilter("*.pdf", "pdf")); fileDialog.showSaveDialog(getParent()); final File file = fileDialog.getSelectedFile(); if (file != null) { String pdf; String[] tmpFileName = file.getAbsolutePath().split("\\."); if (tmpFileName[tmpFileName.length - 1].equals("pdf")) { pdf = ""; } else { pdf = ".pdf"; } String pdfPath = file.getAbsolutePath() + pdf; OMSimulation simulation = (OMSimulation) comboBoxSimulations.getSelectedItem(); String title = simulation.toString(); DescriptiveStatistics statistics = null; OMStatistics statisticsType = (OMStatistics) comboBoxStatistics.getSelectedItem(); OMRoomType roomType = null; switch (statisticsType) { case RoomArithmeticMeans: title = "R_AM, " + title; statistics = simulation.getRoomAmDescriptiveStats(); roomType = OMRoomType.Room; break; case RoomGeometricMeans: title = "R_GM, " + title; statistics = simulation.getRoomGmDescriptiveStats(); roomType = OMRoomType.Room; break; case RoomMedianQ50: title = "R_MED, " + title; statistics = simulation.getRoomMedDescriptiveStats(); roomType = OMRoomType.Room; break; case RoomMaxima: title = "R_MAX, " + title; statistics = simulation.getRoomMaxDescriptiveStats(); roomType = OMRoomType.Room; break; case CellarArithmeticMeans: title = "C_AM, " + title; statistics = simulation.getCellarAmDescriptiveStats(); roomType = OMRoomType.Cellar; break; case CellarGeometricMeans: title = "C_GM, " + title; statistics = simulation.getCellarGmDescriptiveStats(); roomType = OMRoomType.Cellar; break; case CellarMedianQ50: title = "C_MED, " + title; statistics = simulation.getCellarMedDescriptiveStats(); roomType = OMRoomType.Cellar; break; case CellarMaxima: title = "C_MAX, " + title; statistics = simulation.getCellarMaxDescriptiveStats(); roomType = OMRoomType.Cellar; break; default: title = "R_AM, " + title; statistics = simulation.getRoomAmDescriptiveStats(); roomType = OMRoomType.Misc; break; } JFreeChart chart = OMCharts.createDistributionChart(title, statistics, roomType, false); int height = (int) PageSize.A4.getWidth(); int width = (int) PageSize.A4.getHeight(); try { OMExports.exportPdf(pdfPath, chart, width, height, new DefaultFontMapper(), title); JOptionPane.showMessageDialog(null, "PDF saved successfully!\n" + pdfPath, "Success", JOptionPane.INFORMATION_MESSAGE); } catch (IOException ioe) { JOptionPane.showMessageDialog(null, "Failed to write PDF. Please check permissions!\n" + ioe.getMessage(), "Failed", JOptionPane.ERROR_MESSAGE); ioe.printStackTrace(); } } else { JOptionPane.showMessageDialog(null, "Failed to write PDF. Please check the file path!", "Failed", JOptionPane.ERROR_MESSAGE); } } }); btnPdf.setBounds(670, 475, 70, 23); btnPdf.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); btnPdf.setVisible(false); add(btnPdf); lblSelectSimulation = new JLabel("Select Simulation"); lblSelectSimulation.setFont(new Font("SansSerif", Font.PLAIN, 11)); lblSelectSimulation.setBounds(10, 65, 132, 14); add(lblSelectSimulation); lblSelectStatistics = new JLabel("Select Statistics"); lblSelectStatistics.setFont(new Font("SansSerif", Font.PLAIN, 11)); lblSelectStatistics.setBounds(10, 94, 132, 14); add(lblSelectStatistics); comboBoxSimulations = new JComboBox<OMSimulation>(); comboBoxSimulations.setFont(new Font("SansSerif", Font.PLAIN, 11)); comboBoxSimulations.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent arg0) { boolean b = false; if (comboBoxSimulations.isEnabled()) { if (comboBoxSimulations.getSelectedItem() != null) { b = true; comboBoxStatistics.removeAllItems(); comboBoxStatistics.setModel(new DefaultComboBoxModel<OMStatistics>(OMStatistics.values())); } else { b = false; comboBoxStatistics.removeAllItems(); } } else { b = false; comboBoxStatistics.removeAllItems(); } progressBar.setEnabled(b); btnPdf.setVisible(b); btnCsv.setVisible(b); btnMaximize.setVisible(b); lblExportChartTo.setVisible(b); comboBoxStatistics.setEnabled(b); lblSelectStatistics.setEnabled(b); } }); comboBoxSimulations.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { boolean b = false; if (comboBoxSimulations.isEnabled()) { if (comboBoxSimulations.getSelectedItem() != null) { b = true; comboBoxStatistics.removeAllItems(); comboBoxStatistics.setModel(new DefaultComboBoxModel<OMStatistics>(OMStatistics.values())); comboBoxStatistics.setSelectedIndex(0); } else { b = false; comboBoxStatistics.removeAllItems(); } } else { b = false; comboBoxStatistics.removeAllItems(); } progressBar.setEnabled(b); btnPdf.setVisible(b); btnCsv.setVisible(b); btnMaximize.setVisible(b); lblExportChartTo.setVisible(b); comboBoxStatistics.setEnabled(b); lblSelectStatistics.setEnabled(b); } }); comboBoxSimulations.setBounds(152, 61, 454, 22); add(comboBoxSimulations); btnRefresh = new JButton("Load"); btnRefresh.setFont(new Font("SansSerif", Font.PLAIN, 11)); btnRefresh.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (txtOmsFile.getText() != null && !txtOmsFile.getText().equals("") && !txtOmsFile.getText().equals(" ")) { txtOmsFile.setBackground(Color.WHITE); String omsPath = txtOmsFile.getText(); String oms; String[] tmpFileName = omsPath.split("\\."); if (tmpFileName[tmpFileName.length - 1].equals("oms")) { oms = ""; } else { oms = ".oms"; } txtOmsFile.setText(omsPath + oms); setOmsFile(omsPath + oms); File omsFile = new File(omsPath + oms); if (omsFile.exists()) { txtOmsFile.setBackground(Color.WHITE); btnRefresh.setEnabled(false); comboBoxSimulations.setEnabled(false); setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); progressBar.setStringPainted(true); progressBar.setVisible(true); progressBar.setIndeterminate(true); btnPdf.setVisible(false); btnCsv.setVisible(false); btnMaximize.setVisible(false); lblExportChartTo.setVisible(false); refreshSimulationsTask = new RefreshSimulations(); refreshSimulationsTask.execute(); } else { txtOmsFile.setBackground(new Color(255, 222, 222, 128)); JOptionPane.showMessageDialog(null, "OMS-file not found, please check the file path!", "Error", JOptionPane.ERROR_MESSAGE); } } else { txtOmsFile.setBackground(new Color(255, 222, 222, 128)); JOptionPane.showMessageDialog(null, "Please select an OMS-file!", "Warning", JOptionPane.WARNING_MESSAGE); } } }); comboBoxStatistics = new JComboBox<OMStatistics>(); comboBoxStatistics.setFont(new Font("SansSerif", Font.PLAIN, 11)); comboBoxStatistics.setBounds(152, 90, 454, 22); comboBoxStatistics.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { updateDistribution(); } }); add(comboBoxStatistics); btnRefresh.setBounds(616, 61, 124, 23); add(btnRefresh); panelDistribution = new JPanel(); panelDistribution.setBounds(10, 118, 730, 347); add(panelDistribution); progressBar = new JProgressBar(); progressBar.setFont(new Font("SansSerif", Font.PLAIN, 11)); progressBar.setBounds(10, 475, 730, 23); add(progressBar); progressBar.setEnabled(false); comboBoxStatistics.setEnabled(false); lblSelectStatistics.setEnabled(false); btnPdf.setVisible(false); btnCsv.setVisible(false); btnMaximize.setVisible(false); lblExportChartTo.setVisible(false); lblHelp = new JLabel("Select an OMS-Simulation file to analyse the simulation results and " + "display the distribution chart."); lblHelp.setForeground(Color.GRAY); lblHelp.setFont(new Font("SansSerif", Font.PLAIN, 11)); lblHelp.setBounds(10, 10, 730, 14); add(lblHelp); lblSelectOms = new JLabel("Open OMS-File"); lblSelectOms.setFont(new Font("SansSerif", Font.PLAIN, 11)); lblSelectOms.setBounds(10, 36, 132, 14); add(lblSelectOms); txtOmsFile = new JTextField(); txtOmsFile.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { setOmsFile(txtOmsFile.getText()); } }); txtOmsFile.setFont(new Font("SansSerif", Font.PLAIN, 11)); txtOmsFile.setColumns(10); txtOmsFile.setBounds(152, 33, 454, 20); add(txtOmsFile); buttonBrowse = new JButton("Browse"); buttonBrowse.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { JFileChooser fileDialog = new JFileChooser(); fileDialog.setFileFilter(new FileNameExtensionFilter("*.oms", "oms")); fileDialog.showOpenDialog(getParent()); final File file = fileDialog.getSelectedFile(); if (file != null) { String oms; String[] tmpFileName = file.getAbsolutePath().split("\\."); if (tmpFileName[tmpFileName.length - 1].equals("oms")) { oms = ""; } else { oms = ".oms"; } txtOmsFile.setText(file.getAbsolutePath() + oms); setOmsFile(file.getAbsolutePath() + oms); } } }); buttonBrowse.setFont(new Font("SansSerif", Font.PLAIN, 11)); buttonBrowse.setBounds(616, 32, 124, 23); add(buttonBrowse); progressBar.setVisible(false); }
From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.imagem.PanelDescricaoImagens.java
public void avaliaUrl(String url) { PegarPaginaWEB ppw = new PegarPaginaWEB(); if (url != null) { salvaAlteracoes.setNomeDoArquivoEmDisco(null); try {/* w w w . jav a 2s . co m*/ String codHtml = ppw.getContent(url); TxtBuffer.setContentOriginal(codHtml, "0"); parentFrame.showPainelFerramentaImgPArq(codHtml, url); } catch (HttpException e1) { JOptionPane.showMessageDialog(this, TradPainelAvaliacao.AVISO_NAO_CONECTOU, TradPainelAvaliacao.AVISO, JOptionPane.WARNING_MESSAGE); } catch (Exception e1) { JOptionPane.showMessageDialog(this, TradPainelAvaliacao.AVISO_VERIFIQUE_URL, TradPainelAvaliacao.AVISO, JOptionPane.WARNING_MESSAGE); } } }
From source file:com.sec.ose.osi.thread.ui_related.UserCommandExecutionThread.java
private boolean isValidProjectName(Collection<String> projectList) { for (String projectName : projectList) { String modifiedProjectName = projectName.replace("[", "_"); modifiedProjectName = modifiedProjectName.replace("]", "_"); modifiedProjectName = modifiedProjectName.replace("/", "_"); modifiedProjectName = modifiedProjectName.replace("|", "_"); modifiedProjectName = modifiedProjectName.replace(":", "_"); modifiedProjectName = modifiedProjectName.replace(",", "_"); modifiedProjectName = modifiedProjectName.replace("?", "_"); modifiedProjectName = modifiedProjectName.replace(";", "_"); modifiedProjectName = modifiedProjectName.replace("\\", "_"); if (modifiedProjectName.equals(projectName) == false) { JOptionPane.showMessageDialog(null, "\"" + projectName + "\" is not valid project name.\n" + "If project name in protex contains any characters in" + "\"[]?:;/\\,\" \n" + "Any report is not generated.\n" + "You should remove characters above.", "Report will not be generated", JOptionPane.WARNING_MESSAGE); return false; }/*from ww w. ja v a 2s . c o m*/ } return true; }
From source file:info.puzz.trackprofiler.gui.TrackProfilerFrame.java
private void showError(Message message) { JOptionPane.showMessageDialog(this, message.getLocalizedMessage(), new Message(Messages.ERROR).toString(), JOptionPane.WARNING_MESSAGE); }
From source file:fitnesserefactor.FitnesseRefactor.java
private void DelTableActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_DelTableActionPerformed if (ParentFolder.isSelected()) { if (!"".equals(JtreePath)) { File dir = new File(JtreePath); try { if (dir.getParent() != null && dir.isFile()) { String Testcase = dir.getParent(); File dir1 = new File(Testcase); if (dir1.getParent() != null && dir1.isDirectory()) { String parent = dir1.getParent(); File dir2 = new File(Testcase); if (dir2.getParent() != null) { String GrandParent = dir2.getParent(); File dir3 = new File(GrandParent); File[] allFiles = dir3.listFiles(); ArrayList al = new ArrayList(); for (File file : allFiles) { String TestcaseNames = file.getName(); al.add(TestcaseNames); }//from w ww. j a va2 s .co m if (!fromTxt.getText().isEmpty() && !toTxt.getText().isEmpty()) { int FromTxtInt = Integer.parseInt(fromTxt.getText()); int ToTxtInt = Integer.parseInt(toTxt.getText()); int TotFiles = al.size(); if ((ToTxtInt > FromTxtInt) && (ToTxtInt > 0) && (FromTxtInt > 0) && ToTxtInt <= al.size() - 2) { for (int removeAfterToIndx = (ToTxtInt + 2); removeAfterToIndx < TotFiles; removeAfterToIndx++) { al.remove(ToTxtInt + 2); } if (FromTxtInt > 1) { for (int removeFromIndx = 1; removeFromIndx < FromTxtInt; removeFromIndx++) { al.remove(2); } } } else { JOptionPane.showMessageDialog(null, "FROM test case number cannot be greater/equal to TO test case number.\nFROM and TO test case numbers should be greater than zero. \nTO test case number should not be greater than the testcase count ", "Warning", JOptionPane.WARNING_MESSAGE); } } for (int i = 2; i <= al.size(); i++) { System.out.println(dir2.getParent() + "\\" + al.get(i) + "\\content.txt"); File EachFile = new File(dir2.getParent() + "\\" + al.get(i) + "\\content.txt"); for (int j = 0; j < FileUtils.readLines(EachFile).size(); j++) { String line = (String) FileUtils.readLines(EachFile).get(j); if (line.matches("(.*)" + FitnesseTablesList.getSelectedItem().toString() + "(.*)")) { p = j; ReadAllLines(EachFile); int selectTableSize = SizeOfTable(EachFile); for (int DeleteLines = 0; DeleteLines <= selectTableSize; DeleteLines++) { AllLines.remove(p); } WriteAllLines(EachFile); } } } } else { JOptionPane.showMessageDialog(null, "There are no testcases under the parent folder", "Error", JOptionPane.ERROR_MESSAGE); } } else { JOptionPane.showMessageDialog(null, "There are no testcases under the parent folder", "Error", JOptionPane.ERROR_MESSAGE); } } else { JOptionPane.showMessageDialog(null, "Need to select atleast one content.txt file", "Warning", JOptionPane.WARNING_MESSAGE); } } catch (Exception E) { //JOptionPane.showMessageDialog(null, E, "Java Runtime Error", JOptionPane.ERROR ); } } } }
From source file:frames.consulta.java
private void btnbuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnbuscarActionPerformed // String valor = txtbuscar.getText(); // cargartablapacientes(valor); String men;/* ww w. java 2s. co m*/ men = txtbuscar.getText(); grupoconsulta.add(cedula); grupoconsulta.add(apellido); if (cedula.isSelected()) { atributo = "cedula"; cargartablapacientes(txtbuscar.getText()); } else if (apellido.isSelected()) { atributo = "apellido"; cargartablapacientes(txtbuscar.getText()); } else if (men.isEmpty()) { JOptionPane.showMessageDialog(null, "Escribe en el campo busqueda", "Error", JOptionPane.WARNING_MESSAGE); } //if (!apellido.isSelected() || !cedula.isSelected()) else { JOptionPane.showMessageDialog(null, "Seleccione un tipo de busqueda"); } }
From source file:com.clough.android.adbv.view.MainFrame.java
private void showTreeNodePopup(int x, int y, boolean isDatabasePopup) { JPopupMenu treeNodePopup = new JPopupMenu(); if (isDatabasePopup) { JMenuItem newTableMenuItem = new JMenuItem("New table"); newTableMenuItem.addActionListener(new ActionListener() { @Override/*from w ww . j a v a 2 s . c om*/ public void actionPerformed(ActionEvent e) { System.out.println("new table"); new CreateTableDialog(MainFrame.this, true).setVisible(true); if (tableQueryList != null && tableQueryList.size() > 0) { for (String query : tableQueryList.values()) { inputQuery = query; runQuery(); } refreshDatabase(); tableQueryList = null; } } }); treeNodePopup.add(newTableMenuItem); } else { JMenuItem viewAllMenuItem = new JMenuItem("View table"); viewAllMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.out.println("view all"); inputQuery = "select * from `" + selectedTreeNodeValue + "`"; queryingTextArea.setText(inputQuery); runQuery(); } }); treeNodePopup.add(viewAllMenuItem); JMenuItem dropTableMenuItem = new JMenuItem("Drop table"); dropTableMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.out.println("drop table"); if (JOptionPane.showConfirmDialog(null, "All the data in table " + selectedTreeNodeValue + " will be lost!\nClick OK to delete the table", "Sqlite table dropping", JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION) { inputQuery = "drop table `" + selectedTreeNodeValue + "`"; queryingTextArea.setText(inputQuery); runQuery(); refreshDatabase(); } } }); treeNodePopup.add(dropTableMenuItem); JMenuItem updateTableMenuItem = new JMenuItem("Update table"); updateTableMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.out.println("update table"); final Object[] columnsOfTable = getColumnsOfTable(selectedTreeNodeValue); new SwingWorker<Void, Void>() { String result; @Override protected Void doInBackground() throws Exception { try { Thread.sleep(100); } catch (InterruptedException ex) { } result = ioManager.executeQuery("select * from `" + selectedTreeNodeValue + "`"); return null; } @Override protected void done() { closeProgressDialog(); new UpdateTableDialog(MainFrame.this, true, result, selectedTreeNodeValue, columnsOfTable).setVisible(true); } }.execute(); showProgressDialog(true, 0, "Recieving data from table " + selectedTreeNodeValue); if ((rowsToInsert != null && rowsToInsert.size() > 0) || (rowsToUpdate != null && rowsToUpdate.size() > 0) || (rowsToDelete != null && rowsToDelete.size() > 0)) { new SwingWorker<Void, Void>() { @Override protected Void doInBackground() { try { Thread.sleep(100); } catch (InterruptedException ex) { } String result = ""; try { for (Row row : rowsToInsert) { String insertQuery = createTableInsertQuery(selectedTreeNodeValue, row); System.out.println("insertQuery : " + insertQuery); result = ioManager.executeQuery(insertQuery); if (result.equals("[]")) { waitingDialog.incrementProgressBar(); } else { throw new Exception(); } } for (Row row : rowsToUpdate) { String updateQuery = createTableUpdateQuery(selectedTreeNodeValue, row); System.out.println("updateQuery : " + updateQuery); result = ioManager.executeQuery(updateQuery); if (result.equals("[]")) { waitingDialog.incrementProgressBar(); } else { throw new Exception(); } } for (Row row : rowsToDelete) { String deleteQuery = createTableDeleteQuery(selectedTreeNodeValue, row); System.out.println("deleteQuery : " + deleteQuery); result = ioManager.executeQuery(deleteQuery); if (result.equals("[]")) { waitingDialog.incrementProgressBar(); } else { throw new Exception(); } } } catch (Exception ex) { JOptionPane.showMessageDialog(null, result, "Result error", JOptionPane.ERROR_MESSAGE); } return null; } @Override protected void done() { closeProgressDialog(); refreshDatabase(); rowsToInsert = null; rowsToUpdate = null; rowsToDelete = null; } }.execute(); showProgressDialog(false, rowsToInsert.size() + rowsToUpdate.size() + rowsToDelete.size(), "Applying changes to the dialog " + selectedTreeNodeValue); } } }); treeNodePopup.add(updateTableMenuItem); JMenuItem copyCreateStatementMenuItem = new JMenuItem("Copy create statement"); copyCreateStatementMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.out.println("copy create statement"); for (int i = 0; i < tables.length; i++) { if (tables[i].equals(selectedTreeNodeValue)) { StringSelection selection = new StringSelection(queries[i]); Toolkit.getDefaultToolkit().getSystemClipboard().setContents(selection, selection); JOptionPane.showMessageDialog(null, "Copied create statement of the table `" + selectedTreeNodeValue + "` to the clipboard", "Copy create statement", JOptionPane.INFORMATION_MESSAGE); break; } } } }); treeNodePopup.add(copyCreateStatementMenuItem); JMenuItem copyColumnNamesMenuItem = new JMenuItem("Copy column names"); copyColumnNamesMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.out.println("copy column names"); for (int i = 0; i < tables.length; i++) { if (tables[i].equals(selectedTreeNodeValue)) { String columnNames = ""; for (String column : columns[i]) { columnNames = columnNames.concat(column + ","); } StringSelection selection = new StringSelection( columnNames.substring(0, columnNames.length() - 1)); Toolkit.getDefaultToolkit().getSystemClipboard().setContents(selection, selection); JOptionPane.showMessageDialog(null, "Copied create statement of the table `" + selectedTreeNodeValue + "` to the clipboard", "Copy create statement", JOptionPane.INFORMATION_MESSAGE); break; } } } }); treeNodePopup.add(copyColumnNamesMenuItem); } treeNodePopup.show(tableInfoTree, x, y); }
From source file:edu.ku.brc.specify.tasks.subpane.wb.TemplateEditor.java
/** * @param fmp/*from w ww . jav a 2 s . c o m*/ * @return */ protected boolean confirmUnmapAttachToTable(FieldMappingPanel fmp) { return UIRegistry.displayConfirmLocalized("TemplateEditor.ConfirmAttachedToUnmapTitle", "TemplateEditor.confireAttachedToUnmap", "OK", "Cancel", JOptionPane.WARNING_MESSAGE); }