List of usage examples for javax.swing JOptionPane showInternalMessageDialog
public static void showInternalMessageDialog(Component parentComponent, Object message, String title, int messageType)
messageType
parameter. From source file:Main.java
/** * visualizzazione errori HTML// ww w . j av a 2 s . c o m * * @param iframe internal frame di provenienza (di solito e' * <code>this</code>). * @param task task di provenienza dell'errore (di solito e' * <code>TASK_NAME</code>). * @param mess messaggio da visualizzare */ public static void dispInternalErrore(JInternalFrame iframe, String task, String mess) { // JOptionPane.showInternalMessageDialog(iframe, formattaHTML(mess), ERR_TITLE, JOptionPane.ERROR_MESSAGE); }
From source file:canreg.client.gui.management.CanReg4MigrationInternalFrame.java
@Action public void cancelAction() throws RemoteException, IOException { isPaused = true;//from ww w. j a va 2 s . c o m if (cTask != null) { if (JOptionPane.showInternalConfirmDialog( CanRegClientApp.getApplication().getMainFrame().getContentPane(), java.util.ResourceBundle.getBundle("canreg/client/gui/dataentry/resources/ImportView") .getString("REALLY_CANCEL?"), java.util.ResourceBundle.getBundle("canreg/client/gui/dataentry/resources/ImportView") .getString("PLEASE_CONFIRM."), JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { cTask.cancel(true); JOptionPane.showInternalMessageDialog( CanRegClientApp.getApplication().getMainFrame().getContentPane(), java.util.ResourceBundle.getBundle("canreg/client/gui/dataentry/resources/ImportView") .getString("IMPORT_OF_FILE_INTERUPTED"), java.util.ResourceBundle.getBundle("canreg/client/gui/dataentry/resources/ImportView") .getString("WARNING"), JOptionPane.WARNING_MESSAGE); cTask = null; this.dispose(); } else { isPaused = false; } } else { this.dispose(); } }
From source file:canreg.client.dataentry.Convert.java
public static Map importDictionary( canreg.client.gui.management.CanReg4MigrationInternalFrame.MigrationTask task, String file) { BufferedReader br = null;//from w w w. j a v a 2 s. c o m Map<Integer, Map<Integer, String>> allErrors = new TreeMap(); debugOut("Importing dictionary from " + file); try { FileInputStream fis = new FileInputStream(file); InputStreamReader isr = new InputStreamReader(fis, Charset.forName(Globals.CHARSET_ENGLISH)); br = new BufferedReader(isr); String dictionaryString = new String(); String line = br.readLine(); int dictionaryID = -1; while (line != null) { while (line != null && line.trim().length() == 0) { // skip empty lines line = br.readLine(); } if (line == null) { JOptionPane.showInternalMessageDialog( CanRegClientApp.getApplication().getMainFrame().getContentPane(), java.util.ResourceBundle.getBundle( "canreg/client/gui/dataentry/resources/ImportCompleteDictionaryInternalFrame") .getString("FILE_IS_NOT_CORRECT_FORMAT:_") + "\'" + file + "\'.", java.util.ResourceBundle.getBundle( "canreg/client/gui/dataentry/resources/ImportCompleteDictionaryInternalFrame") .getString("ERROR"), JOptionPane.ERROR_MESSAGE); //return ("Error"); } // first line contains the dictionary id // remove leading # if (line.startsWith("#")) { line = line.substring(1); } line = line.replace(' ', '\t'); String[] lineElements = line.split("\t"); dictionaryID = Integer.parseInt(lineElements[0]); // read next line; line = br.readLine(); // read untill blank line while (line != null && line.trim().length() > 0) { dictionaryString += line + "\n"; line = br.readLine(); } if (dictionaryString.trim().length() > 0) { try { Map<Integer, String> errors = canreg.client.dataentry.DictionaryHelper.testDictionary(null, dictionaryString); if (errors.size() > 0) { allErrors.put(dictionaryID, errors); Logger.getLogger(Convert.class.getName()).log(Level.WARNING, errors.size() + " errors in dictionary: " + dictionaryID, new Exception()); } else { canreg.client.dataentry.DictionaryHelper.replaceDictionary(dictionaryID, dictionaryString, CanRegClientApp.getApplication()); } dictionaryString = new String(); } catch (RemoteException ex) { Logger.getLogger(Convert.class.getName()).log(Level.SEVERE, null, ex); } } // Read next line line = br.readLine(); // Skip trailing blank lines while (line != null && line.trim().length() == 0) { line = br.readLine(); } } CanRegClientApp.getApplication().refreshDictionary(); } catch (FileNotFoundException fileNotFoundException) { JOptionPane.showInternalMessageDialog(CanRegClientApp.getApplication().getMainFrame().getContentPane(), java.util.ResourceBundle .getBundle( "canreg/client/gui/dataentry/resources/ImportCompleteDictionaryInternalFrame") .getString("COULD_NOT_PREVIEW_THE_FILE:_") + file + "\'.", java.util.ResourceBundle .getBundle( "canreg/client/gui/dataentry/resources/ImportCompleteDictionaryInternalFrame") .getString("ERROR"), JOptionPane.ERROR_MESSAGE); Logger.getLogger(ImportView.class.getName()).log(Level.WARNING, null, fileNotFoundException); } catch (IOException ex) { Logger.getLogger(ImportView.class.getName()).log(Level.SEVERE, null, ex); } catch (NumberFormatException nfe) { JOptionPane.showInternalMessageDialog(CanRegClientApp.getApplication().getMainFrame().getContentPane(), java.util.ResourceBundle .getBundle( "canreg/client/gui/dataentry/resources/ImportCompleteDictionaryInternalFrame") .getString("SOMETHING_WRONG_WITH_THE_DICTIONARY:_") + "\'" + file + "\'.", java.util.ResourceBundle .getBundle( "canreg/client/gui/dataentry/resources/ImportCompleteDictionaryInternalFrame") .getString("ERROR"), JOptionPane.ERROR_MESSAGE); Logger.getLogger(ImportView.class.getName()).log(Level.WARNING, null, nfe); } finally { try { br.close(); } catch (IOException ex) { Logger.getLogger(ImportView.class.getName()).log(Level.SEVERE, null, ex); } } return allErrors; // return your result }
From source file:canreg.client.gui.components.FastFilterInternalFrame.java
private void mouseClickHandler(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_mouseClickHandler DatabaseVariablesListElement dbvle = (DatabaseVariablesListElement) variableComboBox.getSelectedItem(); if (dictionaryPopUp && (valueTextField.equals(evt.getSource()) || valueTextField2.equals(evt.getSource())) && dbvle.getVariableType().equalsIgnoreCase("dict")) { if (possibleValuesMap == null) { JOptionPane.showInternalMessageDialog(this, java.util.ResourceBundle .getBundle("canreg/client/gui/components/resources/FastFilterInternalFrame") .getString("EMPTY_DICTIONARY"), java.util.ResourceBundle .getBundle("canreg/client/gui/components/resources/FastFilterInternalFrame") .getString("WARNING"), JOptionPane.WARNING_MESSAGE); } else {//from www . ja v a 2 s . c om // String oldValue = getValue().toString(); // DictionaryEntry oldSelection = possibleValuesMap.get(oldValue); if (dictionaryElementChooser == null) { dictionaryElementChooser = new DictionaryElementChooser(this); } else { dictionaryElementChooser.setFirstPass(); } dictionaryElementChooser.setDictionary(dictionary); // dictionaryElementChooser.setSelectedElement(oldSelection); // safe to cast as we check it in the first if-statement dictionaryElementChooserAssignedTextField = (JTextField) evt.getSource(); CanRegClientView.showAndPositionInternalFrame(CanRegClientApp.getApplication().getDesktopPane(), dictionaryElementChooser); } } else { // Do nothing } currentSelectionAdded = false; }
From source file:canreg.client.gui.components.PreviewFilePanel.java
/** * *///from www . j a v a 2 s.c om @Action public void previewAction() { // show the contents of the file BufferedReader br = null; try { changeFile(); // numberOfRecordsTextField.setText(""+(canreg.common.Tools.numberOfLinesInFile(inFile.getAbsolutePath())-1)); FileInputStream fis = new FileInputStream(inFile); br = new BufferedReader(new InputStreamReader(fis, (Charset) charsetsComboBox.getSelectedItem())); CSVFormat csvFormat = CSVFormat.DEFAULT.withFirstRecordAsHeader().withDelimiter(getSeparator()); CSVParser csvParser = new CSVParser(br, csvFormat); int linesToRead = Globals.NUMBER_OF_LINES_IN_IMPORT_PREVIEW; int numberOfLinesRead = 0; Vector<Vector<String>> data = new Vector<Vector<String>>(); String[] headers = csvParser.getHeaderMap().keySet().toArray(new String[0]); for (CSVRecord csvRecord : csvParser) { csvRecord.toMap(); Vector vec = new Vector(); Iterator<String> iterator = csvRecord.iterator(); while (iterator.hasNext()) { vec.add(iterator.next()); } data.add(vec); numberOfLinesRead++; if (numberOfLinesRead >= linesToRead) { break; } } numberOfRecordsShownTextField.setText(numberOfLinesRead + ""); // previewTextArea.setText(headers + "\n" + dataText); // previewTextArea.setCaretPosition(0); previewPanel.setVisible(true); Vector columnNames = new Vector(Arrays.asList(headers)); previewTable.setModel(new DefaultTableModel(data, columnNames)); } catch (FileNotFoundException fileNotFoundException) { JOptionPane.showInternalMessageDialog(CanRegClientApp.getApplication().getMainFrame().getContentPane(), java.util.ResourceBundle.getBundle("canreg/client/gui/dataentry/resources/ImportView") .getString("COULD_NOT_PREVIEW_FILE:") + " \'" + fileNameTextField.getText().trim() + "\'.", java.util.ResourceBundle.getBundle("canreg/client/gui/dataentry/resources/ImportView") .getString("ERROR"), JOptionPane.ERROR_MESSAGE); Logger.getLogger(PreviewFilePanel.class.getName()).log(Level.SEVERE, null, fileNotFoundException); } catch (IOException ex) { Logger.getLogger(PreviewFilePanel.class.getName()).log(Level.SEVERE, null, ex); } finally { try { if (br != null) { br.close(); } } catch (IOException ex) { Logger.getLogger(PreviewFilePanel.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:canreg.client.gui.components.PreviewFilePanel.java
@Action public void autoDetectAction() throws IOException { String encoding = Tools.detectCharacterCodingOfFile(fileNameTextField.getText()); if (encoding != null) { Charset charset = Charset.forName(encoding); charsetsComboBox.setSelectedItem(charset); // System.out.println("Detected encoding = " + encoding); } else {/*from w w w .ja v a 2s .c o m*/ JOptionPane.showInternalMessageDialog(CanRegClientApp.getApplication().getMainFrame().getContentPane(), "No encoding detected.", "Error.", JOptionPane.ERROR_MESSAGE); // JOptionPane.showInternalMessageDialog(CanRegClientApp.getApplication().getMainFrame().getContentPane(), java.util.ResourceBundle.getBundle("canreg/client/gui/components/resources/PreviewFilePanel").getString("NO_ENCODING_DETECTED."), java.util.ResourceBundle.getBundle("canreg/client/gui/dataentry/components/PreviewFilePanel").getString("ERROR"), JOptionPane.ERROR_MESSAGE); } }
From source file:canreg.client.gui.dataentry.ImportView.java
/** * *//*from w ww .j a va2 s. com*/ @Action public void cancelAction() { if (importTask != null) { if (JOptionPane.showInternalConfirmDialog( CanRegClientApp.getApplication().getMainFrame().getContentPane(), java.util.ResourceBundle.getBundle("canreg/client/gui/dataentry/resources/ImportView") .getString("REALLY_CANCEL?"), java.util.ResourceBundle.getBundle("canreg/client/gui/dataentry/resources/ImportView") .getString("PLEASE_CONFIRM."), JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { importTask.cancel(true); JOptionPane.showInternalMessageDialog( CanRegClientApp.getApplication().getMainFrame().getContentPane(), java.util.ResourceBundle.getBundle("canreg/client/gui/dataentry/resources/ImportView") .getString("IMPORT_OF_FILE_INTERUPTED"), java.util.ResourceBundle.getBundle("canreg/client/gui/dataentry/resources/ImportView") .getString("WARNING"), JOptionPane.WARNING_MESSAGE); importTask = null; this.dispose(); } } else { this.dispose(); } }
From source file:canreg.client.gui.dataentry.ImportView.java
private void initializeVariableMappingTab() { if (needToRebuildVariableMap && fileNameTextField.getText().trim().length() > 0) { BufferedReader br = null; List<Relation> map = null; panelList = new LinkedList(); try {/*w w w . java 2 s . c om*/ // Remove all variable mappings variablesPanel.removeAll(); // Read the first line of the file br = new BufferedReader(new FileReader(inFile)); String line = br.readLine(); // String[] lineElements = canreg.common.Tools.breakDownLine('\t', line); String[] lineElements = canreg.common.Tools.breakDownLine(getSeparator(), line); // Build variable mapping map = Import.constructRelations(doc, lineElements); // Add the panels for (Relation rel : map) { VariableMappingPanel vmp = new VariableMappingPanel(); panelList.add(vmp); vmp.setDBVariables(variablesInDB); vmp.setFileVariableName(rel.getFileVariableName()); vmp.setSelectedDBIndex(rel.getDatabaseTableVariableID()); variablesPanel.add(vmp); vmp.setVisible(true); } variablesPanel.revalidate(); variablesPanel.repaint(); } catch (RemoteException ex) { Logger.getLogger(ImportView.class.getName()).log(Level.SEVERE, null, ex); } catch (FileNotFoundException ex) { Logger.getLogger(ImportView.class.getName()).log(Level.SEVERE, null, ex); JOptionPane.showInternalMessageDialog( CanRegClientApp.getApplication().getMainFrame().getContentPane(), java.util.ResourceBundle.getBundle("canreg/client/gui/dataentry/resources/ImportView") .getString("COULD_NOT_OPEN_FILE:_") + "\'" + fileNameTextField.getText().trim() + "\'.", java.util.ResourceBundle.getBundle("canreg/client/gui/dataentry/resources/ImportView") .getString("ERROR"), JOptionPane.ERROR_MESSAGE); } catch (IOException ex) { Logger.getLogger(ImportView.class.getName()).log(Level.SEVERE, null, ex); } finally { needToRebuildVariableMap = false; try { br.close(); } catch (IOException ex) { Logger.getLogger(ImportView.class.getName()).log(Level.SEVERE, null, ex); } } } }
From source file:canreg.client.gui.dataentry.ImportView.java
/** * *//*from w ww . j av a2 s .com*/ @Action public void previewAction() { // show the contents of the file BufferedReader br = null; try { changeFile(); // numberOfRecordsTextField.setText(""+(canreg.common.Tools.numberOfLinesInFile(inFile.getAbsolutePath())-1)); FileInputStream fis = new FileInputStream(inFile); br = new BufferedReader(new InputStreamReader(fis, (Charset) charsetsComboBox.getSelectedItem())); CSVFormat csvFormat = CSVFormat.DEFAULT.withFirstRecordAsHeader().withDelimiter(getSeparator()); CSVParser csvParser = new CSVParser(br, csvFormat); int linesToRead = Globals.NUMBER_OF_LINES_IN_IMPORT_PREVIEW; int numberOfLinesRead = 0; Vector<Vector<String>> data = new Vector<Vector<String>>(); String[] headers = csvParser.getHeaderMap().keySet().toArray(new String[0]); for (CSVRecord csvRecord : csvParser) { csvRecord.toMap(); Vector vec = new Vector(); Iterator<String> iterator = csvRecord.iterator(); while (iterator.hasNext()) { vec.add(iterator.next()); } data.add(vec); numberOfLinesRead++; if (numberOfLinesRead >= linesToRead) { break; } } numberOfRecordsShownTextField.setText(numberOfLinesRead + ""); // previewTextArea.setText(headers + "\n" + dataText); // previewTextArea.setCaretPosition(0); previewPanel.setVisible(true); Vector columnNames = new Vector(Arrays.asList(headers)); previewTable.setModel(new DefaultTableModel(data, columnNames)); } catch (FileNotFoundException fileNotFoundException) { JOptionPane.showInternalMessageDialog(CanRegClientApp.getApplication().getMainFrame().getContentPane(), java.util.ResourceBundle.getBundle("canreg/client/gui/dataentry/resources/ImportView") .getString("COULD_NOT_PREVIEW_FILE:") + " \'" + fileNameTextField.getText().trim() + "\'.", java.util.ResourceBundle.getBundle("canreg/client/gui/dataentry/resources/ImportView") .getString("ERROR"), JOptionPane.ERROR_MESSAGE); Logger.getLogger(ImportView.class.getName()).log(Level.SEVERE, null, fileNotFoundException); } catch (IOException ex) { JOptionPane.showInternalMessageDialog(CanRegClientApp.getApplication().getMainFrame().getContentPane(), java.util.ResourceBundle.getBundle("canreg/client/gui/dataentry/resources/ImportView") .getString("COULD_NOT_PREVIEW_FILE:") + " \'" + fileNameTextField.getText().trim() + "\'.", java.util.ResourceBundle.getBundle("canreg/client/gui/dataentry/resources/ImportView") .getString("ERROR"), JOptionPane.ERROR_MESSAGE); Logger.getLogger(ImportView.class.getName()).log(Level.SEVERE, null, ex); } finally { try { if (br != null) { br.close(); } } catch (IOException ex) { Logger.getLogger(ImportView.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:canreg.client.gui.dataentry.ImportView.java
/** * * @throws java.io.IOException//from www . j a v a 2s .com */ @Action public void autodetectFileEncodingAction() throws java.io.IOException { String encoding = Tools.detectCharacterCodingOfFile(fileNameTextField.getText()); if (encoding != null) { Charset charset = Charset.forName(encoding); charsetsComboBox.setSelectedItem(charset); // System.out.println("Detected encoding = " + encoding); } else { JOptionPane.showInternalMessageDialog(CanRegClientApp.getApplication().getMainFrame().getContentPane(), java.util.ResourceBundle.getBundle("canreg/client/gui/dataentry/resources/ImportView") .getString("NO_ENCODING_DETECTED."), java.util.ResourceBundle.getBundle("canreg/client/gui/dataentry/resources/ImportView") .getString("ERROR"), JOptionPane.ERROR_MESSAGE); // System.out.println("No encoding detected."); } }