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:gui.FeedbackGui.java
private void jButtonSendActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSendActionPerformed boolean wasSent = false; if (this.jTextFieldFrom.getText().equals("")) { JOptionPane.showMessageDialog(this, this.langErrorInputFrom, this.langErrorInputTitle, JOptionPane.WARNING_MESSAGE); } else if (this.jTextAreaMessage.getText().equals("")) { JOptionPane.showMessageDialog(this, this.langErrorInputMessage, this.langErrorInputTitle, JOptionPane.WARNING_MESSAGE); } else {/*from w ww.ja v a 2 s . co m*/ RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(10 * 1000).build(); HttpClient httpclient = HttpClientBuilder.create().setDefaultRequestConfig(requestConfig).build(); HttpPost httppost = new HttpPost("http://gw2eventer.sourceforge.net/feedback/"); // Request parameters and other properties. List<NameValuePair> params = new ArrayList<NameValuePair>(5); params.add(new BasicNameValuePair("key", "jhk3h238kfh8k32r88hfk2h")); params.add(new BasicNameValuePair("date", new Date().getTime() + "")); params.add(new BasicNameValuePair("from", this.jTextFieldFrom.getText())); params.add(new BasicNameValuePair("subject", this.jTextFieldSubject.getText())); params.add(new BasicNameValuePair("message", this.jTextAreaMessage.getText())); try { httppost.setEntity(new UrlEncodedFormEntity(params, "UTF-8")); } catch (UnsupportedEncodingException ex) { Logger.getLogger(FeedbackGui.class.getName()).log(Level.SEVERE, null, ex); } //Execute and get the response. HttpResponse response; try { response = httpclient.execute(httppost); HttpEntity entity = response.getEntity(); if (entity != null) { InputStream instream = entity.getContent(); try { wasSent = true; BufferedReader rd = new BufferedReader( new InputStreamReader(response.getEntity().getContent(), Charset.forName("UTF-8"))); String line = ""; String out = ""; while ((line = rd.readLine()) != null) { out = out + line; } System.out.println(out); } finally { instream.close(); } } } catch (IOException | IllegalStateException ex) { Logger.getLogger(FeedbackGui.class.getName()).log(Level.SEVERE, null, ex); JOptionPane.showMessageDialog(this, this.langErrorSendMessage, this.langErrorSendTitle, JOptionPane.WARNING_MESSAGE); } finally { if (wasSent) { this.setVisible(false); } } } }
From source file:jamel.gui.JamelWindow.java
/** * Returns the info panel./*from w ww . j a va 2 s. com*/ * @return the info panel. */ private Component getInfoPanel() { final JEditorPane editorPane = new JEditorPane("text/html", "<center>" + this.infoString + "</center>"); editorPane.addHyperlinkListener(new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) try { java.awt.Desktop.getDesktop().browse(e.getURL().toURI()); } catch (Exception ex) { ex.printStackTrace(); JOptionPane.showMessageDialog(null, "<html>" + "Error.<br>" + "Cause: " + e.toString() + ".<br>" + "Please see server.log for more details.</html>", "Warning", JOptionPane.WARNING_MESSAGE); } } }); editorPane.setEditable(false); final JScrollPane scrollPane = new JScrollPane(editorPane); return scrollPane; }
From source file:net.sf.keystore_explorer.gui.actions.ExportKeyPairPrivateKeyAction.java
private void exportAsPvk(PrivateKey privateKey, String alias) throws CryptoException, IOException { File exportFile = null;// ww w . j a v a 2s.c o m try { DExportPrivateKeyPvk dExportPrivateKeyPvk = new DExportPrivateKeyPvk(frame, alias, privateKey, applicationSettings.getPasswordQualityConfig()); dExportPrivateKeyPvk.setLocationRelativeTo(frame); dExportPrivateKeyPvk.setVisible(true); if (!dExportPrivateKeyPvk.exportSelected()) { return; } exportFile = dExportPrivateKeyPvk.getExportFile(); int keyType = dExportPrivateKeyPvk.getKeyType(); boolean encrypt = dExportPrivateKeyPvk.encrypt(); boolean strongEncryption = false; Password exportPassword = null; if (encrypt) { strongEncryption = dExportPrivateKeyPvk.useStrongEncryption(); exportPassword = dExportPrivateKeyPvk.getExportPassword(); } byte[] encoded = getPvkEncodedPrivateKey(privateKey, keyType, exportPassword, strongEncryption); exportEncodedPrivateKey(encoded, exportFile); JOptionPane.showMessageDialog(frame, res.getString("ExportKeyPairPrivateKeyAction.ExportPrivateKeyPvkSuccessful.message"), res.getString("ExportKeyPairPrivateKeyAction.ExportPrivateKeyPvk.Title"), JOptionPane.INFORMATION_MESSAGE); } catch (FileNotFoundException ex) { String message = MessageFormat .format(res.getString("ExportKeyPairPrivateKeyAction.NoWriteFile.message"), exportFile); JOptionPane.showMessageDialog(frame, message, res.getString("ExportKeyPairPrivateKeyAction.ExportPrivateKeyPvk.Title"), JOptionPane.WARNING_MESSAGE); } }
From source file:be.ac.ua.comp.scarletnebula.gui.windows.LinkUnlinkWindow.java
private final JPanel getMainPanel() { final JPanel mainPanel = new JPanel(new GridBagLayout()); mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); final ServerList linkedServerList = new ServerList(linkedServerListModel); linkedServerList.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); final JScrollPane linkedServerScrollPane = new JScrollPane(linkedServerList); linkedServerScrollPane// w w w. ja v a 2s . com .setBorder(BorderFactory.createTitledBorder(new EmptyBorder(5, 20, 20, 20), "Linked Servers")); // Doesn't matter what this is set to, as long as it's the same as the // one for unlinkedServerScrollPane linkedServerScrollPane.setPreferredSize(new Dimension(10, 10)); final GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.gridx = 0; c.gridy = 0; c.weightx = 0.5; c.weighty = 1.0; mainPanel.add(linkedServerScrollPane, c); final ServerList unlinkedServerList = new ServerList(unlinkedServerListModel); unlinkedServerList.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); final JScrollPane unlinkedServerScrollPane = new JScrollPane(unlinkedServerList); unlinkedServerScrollPane .setBorder(BorderFactory.createTitledBorder(new EmptyBorder(5, 20, 20, 20), "Unlinked Servers")); // Doesn't matter what this is set to, as long as it's the same as the // one for unlinkedServerScrollPane unlinkedServerScrollPane.setPreferredSize(new Dimension(10, 10)); final JPanel middlePanel = new JPanel(); middlePanel.setLayout(new BoxLayout(middlePanel, BoxLayout.Y_AXIS)); middlePanel.add(Box.createVerticalGlue()); final JButton linkSelectionButton = new JButton("<"); final JButton unlinkSelectionButton = new JButton(">"); linkSelectionButton.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { // Move selection from unlinked to linked list final int selection = unlinkedServerList.getSelectedIndex(); if (selection < 0) { return; } final Server server = unlinkedServerListModel.getVisibleServerAtIndex(selection); unlinkedServerListModel.removeServer(server); linkedServerListModel.addServer(server); } }); unlinkSelectionButton.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { // Move selection from linked to unlinked list final int selection = linkedServerList.getSelectedIndex(); if (selection < 0) { return; } final int answer = JOptionPane.showOptionDialog(LinkUnlinkWindow.this, "You are about to unlink a server. " + "Unlinking a server will permanently remove \nall data associated with " + "this server, but the server will keep running. " + "\n\nAre you sure you wish to continue?", "Unlink Server", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, null, null); if (answer != JOptionPane.YES_OPTION) { return; } final Server server = linkedServerListModel.getVisibleServerAtIndex(selection); linkedServerListModel.removeServer(server); unlinkedServerListModel.addServer(server); } }); middlePanel.add(unlinkSelectionButton); middlePanel.add(Box.createVerticalStrut(10)); middlePanel.add(linkSelectionButton); middlePanel.add(Box.createVerticalGlue()); c.gridx = 1; c.gridy = 0; c.weightx = 0.0; c.weighty = 0.0; mainPanel.add(middlePanel, c); c.gridx = 2; c.gridy = 0; c.weightx = 0.5; c.weighty = 1.0; mainPanel.add(unlinkedServerScrollPane, c); return mainPanel; }
From source file:dbseer.gui.actions.ExplainChartAction.java
private void updateExplanations() { JTextField confidenceThresholdTextField = panel.getControlPanel().getConfidenceThresholdTextField(); if (!UserInputValidator.validateNumber(confidenceThresholdTextField.getText().trim(), "Confidence Threshold", true)) { return;/*from w w w.j av a2s. co m*/ } confidenceThreshold = Double.parseDouble(confidenceThresholdTextField.getText().trim()); if (confidenceThreshold < 0 || confidenceThreshold > 100) { JOptionPane.showMessageDialog(null, "Confidence threshold must be between 1 and 100.", "Warning", JOptionPane.WARNING_MESSAGE); return; } SwingUtilities.invokeLater(new Runnable() { @Override public void run() { DefaultListModel explanationListModel = panel.getControlPanel().getExplanationListModel(); explanationListModel.clear(); int rank = 1; for (DBSeerCausalModel explanation : explanations) { if (explanation.getConfidence() > confidenceThreshold) { String output = String.format("%d. %s\n", rank++, explanation.toString()); explanationListModel.addElement(output); } } } }); }
From source file:org.cds06.speleograph.graph.SeriesMenu.java
private JPopupMenu createPopupMenuForSeries(final Series series) { if (series == null) return new JPopupMenu(); final JPopupMenu menu = new JPopupMenu(series.getName()); menu.removeAll();/*from w w w. j a v a2 s .c o m*/ menu.add(new AbstractAction() { { putValue(NAME, "Renommer la srie"); } @Override public void actionPerformed(ActionEvent e) { menu.setVisible(false); String newName = ""; while (newName == null || newName.equals("")) { newName = (String) JOptionPane.showInputDialog(application, "Entrez un nouveau nom pour la srie", null, JOptionPane.QUESTION_MESSAGE, null, null, series.getName()); } series.setName(newName); } }); if (series.hasOwnAxis()) { menu.add(new AbstractAction() { { putValue(NAME, "Supprimer l'axe spcifique"); } @Override public void actionPerformed(ActionEvent e) { if (JOptionPane.showConfirmDialog(application, "tes vous sr de vouloir supprimer cet axe ?", "Confirmation", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) { series.setAxis(null); } } }); } else { menu.add(new JMenuItem(new AbstractAction() { { putValue(NAME, "Crer un axe spcifique pour la srie"); } @Override public void actionPerformed(ActionEvent e) { String name = JOptionPane.showInputDialog(application, "Quel titre pour cet axe ?", series.getAxis().getLabel()); if (name == null || "".equals(name)) return; // User has canceled series.setAxis(new NumberAxis(name)); } })); } menu.add(new SetTypeMenu(series)); if (series.isWater()) { menu.addSeparator(); menu.add(new SumOnPeriodAction(series)); menu.add(new CreateCumulAction(series)); } if (series.isWaterCumul()) { menu.addSeparator(); menu.add(new SamplingAction(series)); } if (series.isPressure()) { menu.addSeparator(); menu.add(new CorrelateAction(series)); menu.add(new WaterHeightAction(series)); } menu.addSeparator(); menu.add(new AbstractAction() { { String name; if (series.canUndo()) name = "Annuler " + series.getItemsName(); else name = series.getLastUndoName(); putValue(NAME, name); if (series.canUndo()) setEnabled(true); else { setEnabled(false); } } @Override public void actionPerformed(ActionEvent e) { series.undo(); } }); menu.add(new AbstractAction() { { String name; if (series.canRedo()) { name = "Refaire " + series.getNextRedoName(); setEnabled(true); } else { name = series.getNextRedoName(); setEnabled(false); } putValue(NAME, name); } @Override public void actionPerformed(ActionEvent e) { series.redo(); } }); menu.add(new AbstractAction() { { putValue(NAME, I18nSupport.translate("menus.serie.resetSerie")); if (series.canUndo()) setEnabled(true); else setEnabled(false); } @Override public void actionPerformed(ActionEvent e) { series.reset(); } }); menu.add(new LimitDateRangeAction(series)); menu.add(new HourSettingAction(series)); menu.addSeparator(); { JMenuItem deleteItem = new JMenuItem("Supprimer la srie"); deleteItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (JOptionPane.showConfirmDialog(application, "tes-vous sur de vouloir supprimer cette srie ?\n" + "Cette action est dfinitive.", "Confirmation", JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION) { series.delete(); } } }); menu.add(deleteItem); } menu.addSeparator(); { final JMenuItem up = new JMenuItem("Remonter dans la liste"), down = new JMenuItem("Descendre dans la liste"); ActionListener listener = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { if (e.getSource().equals(up)) { series.upSeriesInList(); } else { series.downSeriesInList(); } } }; up.addActionListener(listener); down.addActionListener(listener); if (series.isFirst()) { menu.add(down); } else if (series.isLast()) { menu.add(up); } else { menu.add(up); menu.add(down); } } menu.addSeparator(); { menu.add(new SeriesInfoAction(series)); } { JMenuItem colorItem = new JMenuItem("Couleur de la srie"); colorItem.addActionListener(new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { series.setColor(JColorChooser.showDialog(application, I18nSupport.translate("actions.selectColorForSeries"), series.getColor())); } }); menu.add(colorItem); } { JMenu plotRenderer = new JMenu("Affichage de la srie"); final ButtonGroup modes = new ButtonGroup(); java.util.List<DrawStyle> availableStyles; if (series.isMinMax()) { availableStyles = DrawStyles.getDrawableStylesForHighLow(); } else { availableStyles = DrawStyles.getDrawableStyles(); } for (final DrawStyle s : availableStyles) { final JRadioButtonMenuItem item = new JRadioButtonMenuItem(DrawStyles.getHumanCheckboxText(s)); item.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { if (item.isSelected()) series.setStyle(s); } }); modes.add(item); if (s.equals(series.getStyle())) { modes.setSelected(item.getModel(), true); } plotRenderer.add(item); } menu.add(plotRenderer); } menu.addSeparator(); menu.add(new AbstractAction() { { putValue(Action.NAME, "Fermer le fichier"); } @Override public void actionPerformed(ActionEvent e) { if (JOptionPane.showConfirmDialog(application, "tes-vous sur de vouloir fermer toutes les sries du fichier ?", "Confirmation", JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION) { final File f = series.getOrigin(); for (final Series s : Series.getInstances().toArray(new Series[Series.getInstances().size()])) { if (s.getOrigin().equals(f)) s.delete(); } } } }); return menu; }
From source file:com.funambol.email.admin.user.ResultSearchUserPanel.java
/** * Set up graphic elements for this panel. * * @throws Exception if error occures during creation of the panel *//* www . ja va2 s . c o m*/ private void init() throws Exception { // create objects to display this.setLayout(new BorderLayout()); this.setBorder(BorderFactory.createEmptyBorder()); // create a model for the user table and pass it to the JTable object model = new UserTableModel(); table = new JTable(model); table.setShowGrid(true); table.setAutoscrolls(true); table.setSelectionMode(DefaultListSelectionModel.SINGLE_SELECTION); JScrollPane scrollpane = new JScrollPane(table); table.setPreferredScrollableViewportSize(new Dimension(800, 200)); table.setFont(GuiFactory.defaultTableFont); table.getTableHeader().setFont(GuiFactory.defaultTableHeaderFont); this.add(scrollpane, BorderLayout.CENTER); // // Select user. // table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); ListSelectionModel rowSM = table.getSelectionModel(); rowSM.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent event) { if (event.getValueIsAdjusting()) { return; } ListSelectionModel lsm = (ListSelectionModel) event.getSource(); if (lsm.isSelectionEmpty()) { selectedUser = null; } else { int selectedRow = lsm.getMinSelectionIndex(); selectedUser = users[selectedRow]; } } }); rowSM.clearSelection(); table.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent event) { if (event.getClickCount() < 2) { return; } // // If the selected user is already associated to an account // then insertion process can't go on. // String userName = selectedUser.getUsername(); String value[] = new String[] { userName }; WhereClause wc = new WhereClause("username", value, WhereClause.OPT_EQ, true); MailServerAccount[] tmp = null; try { tmp = WSDao.getAccounts(wc); } catch (Exception e) { } if (tmp.length > 0) { StringBuilder sb = new StringBuilder("The user "); sb.append(userName).append(" is already associated to an account"); Object[] options = { "OK" }; JOptionPane.showOptionDialog(null, sb.toString(), "Warning", JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]); } else { // // Go to next step. // step.goToNextStep(); } } }); }
From source file:burlov.ultracipher.swing.MainPanel.java
private void deleteCurrentEntry() { DataEntry entry = editDataPanel.getData(); if (entry != null) { // int ret = JOptionPane.showOptionDialog(getMainFrame(), // "Delete entry?", "Confirm", // JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, // null, JOptionPane.NO_OPTION); int ret = JOptionPane.showConfirmDialog(SwingGuiApplication.getInstance().getMainFrame(), "Delete entry?", "Warning", JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE); if (ret == JOptionPane.OK_OPTION) { SwingGuiApplication.getInstance().getDatabase().deleteEntry(entry); SwingGuiApplication.getInstance().updateNeedSave(true); searchResultModel.removeElement(entry); editDataPanel.editData(null, false); searchResults.clearSelection(); }/*from www .j a v a 2 s. co m*/ } }
From source file:net.sf.jabref.gui.preftabs.PreferencesDialog.java
public PreferencesDialog(JabRefFrame parent) { super(parent, Localization.lang("JabRef preferences"), false); JabRefPreferences prefs = JabRefPreferences.getInstance(); frame = parent;// w w w .j a v a2 s .c om main = new JPanel(); JPanel mainPanel = new JPanel(); JPanel lower = new JPanel(); getContentPane().setLayout(new BorderLayout()); getContentPane().add(mainPanel, BorderLayout.CENTER); getContentPane().add(lower, BorderLayout.SOUTH); final CardLayout cardLayout = new CardLayout(); main.setLayout(cardLayout); List<PrefsTab> tabs = new ArrayList<>(); tabs.add(new GeneralTab(prefs)); tabs.add(new NetworkTab(prefs)); tabs.add(new FileTab(frame, prefs)); tabs.add(new FileSortTab(prefs)); tabs.add(new EntryEditorPrefsTab(frame, prefs)); tabs.add(new GroupsPrefsTab(prefs)); tabs.add(new AppearancePrefsTab(prefs)); tabs.add(new ExternalTab(frame, this, prefs)); tabs.add(new TablePrefsTab(prefs)); tabs.add(new TableColumnsTab(prefs, parent)); tabs.add(new LabelPatternPrefTab(prefs, parent.getCurrentBasePanel())); tabs.add(new PreviewPrefsTab(prefs)); tabs.add(new NameFormatterTab(prefs)); tabs.add(new ImportSettingsTab(prefs)); tabs.add(new XmpPrefsTab(prefs)); tabs.add(new AdvancedTab(prefs)); // add all tabs tabs.forEach(tab -> main.add((Component) tab, tab.getTabName())); mainPanel.setBorder(BorderFactory.createEtchedBorder()); String[] tabNames = tabs.stream().map(PrefsTab::getTabName).toArray(String[]::new); JList<String> chooser = new JList<>(tabNames); chooser.setBorder(BorderFactory.createEtchedBorder()); // Set a prototype value to control the width of the list: chooser.setPrototypeCellValue("This should be wide enough"); chooser.setSelectedIndex(0); chooser.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // Add the selection listener that will show the correct panel when // selection changes: chooser.addListSelectionListener(e -> { if (e.getValueIsAdjusting()) { return; } String o = chooser.getSelectedValue(); cardLayout.show(main, o); }); JPanel buttons = new JPanel(); buttons.setLayout(new GridLayout(4, 1)); buttons.add(importPreferences, 0); buttons.add(exportPreferences, 1); buttons.add(showPreferences, 2); buttons.add(resetPreferences, 3); JPanel westPanel = new JPanel(); westPanel.setLayout(new BorderLayout()); westPanel.add(chooser, BorderLayout.CENTER); westPanel.add(buttons, BorderLayout.SOUTH); mainPanel.setLayout(new BorderLayout()); mainPanel.add(main, BorderLayout.CENTER); mainPanel.add(westPanel, BorderLayout.WEST); JButton ok = new JButton(Localization.lang("OK")); JButton cancel = new JButton(Localization.lang("Cancel")); ok.addActionListener(new OkAction()); CancelAction cancelAction = new CancelAction(); cancel.addActionListener(cancelAction); lower.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); ButtonBarBuilder buttonBarBuilder = new ButtonBarBuilder(lower); buttonBarBuilder.addGlue(); buttonBarBuilder.addButton(ok); buttonBarBuilder.addButton(cancel); buttonBarBuilder.addGlue(); // Key bindings: KeyBinder.bindCloseDialogKeyToCancelAction(this.getRootPane(), cancelAction); // Import and export actions: exportPreferences.setToolTipText(Localization.lang("Export preferences to file")); exportPreferences.addActionListener(e -> { String filename = FileDialogs.getNewFile(frame, new File(System.getProperty("user.home")), Collections.singletonList(".xml"), JFileChooser.SAVE_DIALOG, false); if (filename == null) { return; } File file = new File(filename); if (!file.exists() || (JOptionPane.showConfirmDialog(PreferencesDialog.this, Localization.lang("'%0' exists. Overwrite file?", file.getName()), Localization.lang("Export preferences"), JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION)) { try { prefs.exportPreferences(filename); } catch (JabRefException ex) { LOGGER.warn(ex.getMessage(), ex); JOptionPane.showMessageDialog(PreferencesDialog.this, ex.getLocalizedMessage(), Localization.lang("Export preferences"), JOptionPane.ERROR_MESSAGE); } } }); importPreferences.setToolTipText(Localization.lang("Import preferences from file")); importPreferences.addActionListener(e -> { String filename = FileDialogs.getNewFile(frame, new File(System.getProperty("user.home")), Collections.singletonList(".xml"), JFileChooser.OPEN_DIALOG, false); if (filename != null) { try { prefs.importPreferences(filename); updateAfterPreferenceChanges(); JOptionPane.showMessageDialog(PreferencesDialog.this, Localization.lang("You must restart JabRef for this to come into effect."), Localization.lang("Import preferences"), JOptionPane.WARNING_MESSAGE); } catch (JabRefException ex) { LOGGER.warn(ex.getMessage(), ex); JOptionPane.showMessageDialog(PreferencesDialog.this, ex.getLocalizedMessage(), Localization.lang("Import preferences"), JOptionPane.ERROR_MESSAGE); } } }); showPreferences.addActionListener( e -> new PreferencesFilterDialog(new JabRefPreferencesFilter(Globals.prefs), frame) .setVisible(true)); resetPreferences.addActionListener(e -> { if (JOptionPane.showConfirmDialog(PreferencesDialog.this, Localization.lang("Are you sure you want to reset all settings to default values?"), Localization.lang("Reset preferences"), JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) { try { prefs.clear(); JOptionPane.showMessageDialog(PreferencesDialog.this, Localization.lang("You must restart JabRef for this to come into effect."), Localization.lang("Reset preferences"), JOptionPane.WARNING_MESSAGE); } catch (BackingStoreException ex) { LOGGER.warn(ex.getMessage(), ex); JOptionPane.showMessageDialog(PreferencesDialog.this, ex.getLocalizedMessage(), Localization.lang("Reset preferences"), JOptionPane.ERROR_MESSAGE); } updateAfterPreferenceChanges(); } }); setValues(); pack(); }
From source file:com.openbravo.pos.imports.JPanelCSVImport.java
/** * Reads the headers from the CSV file and initializes subsequent form * fields. This function first reads the headers from the CSVFileName file, * then puts them into the header combo boxes and enables the other form * inputs./* w ww . java 2s . c om*/ * * @todo Simplify this method by stripping the file reading and writing * functionality out into it's own class. Also make the enabling fields * section into it's own function and return the 'Headers' to the calling * function to be added there. * * @param CSVFileName Name of the file (including the path) to open and read * CSV data from * @throws IOException If there is an issue reading the CSV file */ private void GetheadersFromFile(String CSVFileName) throws IOException { File f = new File(CSVFileName); if (f.exists()) { products = new CsvReader(CSVFileName); products.setDelimiter(((String) jComboSeparator.getSelectedItem()).charAt(0)); products.readHeaders(); // We need a minimum of 5 columns to map all required fields if (products.getHeaderCount() < 5) { JOptionPane.showMessageDialog(null, "Insufficient headers found in file", "Invalid Header Count.", JOptionPane.WARNING_MESSAGE); products.close(); return; } rowCount = 0; int i = 0; Headers.clear(); Headers.add(""); jComboName.addItem(""); jComboReference.addItem(""); jComboBarcode.addItem(""); jComboBuy.addItem(""); jComboSell.addItem(""); jComboCategory.addItem(""); /** * @todo Return header list for processing elsewhere */ while (i < products.getHeaderCount()) { jComboReference.addItem(products.getHeader(i)); jComboBarcode.addItem(products.getHeader(i)); jComboName.addItem(products.getHeader(i)); jComboBuy.addItem(products.getHeader(i)); jComboSell.addItem(products.getHeader(i)); jComboCategory.addItem(products.getHeader(i)); Headers.add(products.getHeader(i)); ++i; } //enable all the chsck boxes ready for use enableCheckBoxes(); //Count the records found while (products.readRecord()) { ++rowCount; } jTextRecords.setText(Long.toString(rowCount)); // close the file we will open again when required products.close(); } else { JOptionPane.showMessageDialog(null, "Unable to locate " + CSVFileName, "File not found", JOptionPane.WARNING_MESSAGE); } }