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:org.accretegb.modules.germplasm.stockannotation.StockAnnotationPanel.java
/** * actions after delete button associated with Taxonomy table *///from w w w. j a v a 2s . c o m private void addTaxonomyDeleteButtonListener() { taxonomyTablePanel.getDeleteButton().addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int selrow = taxonomyTable.getSelectedRow(); int selcolumn = 0; // String columnName = taxonomyTable.getColumnName(selcolumn + 1); String taxval = (String) taxonomyTable.getModel().getValueAt(taxonomySelectedRow, taxonomyTable.getColumn("Taxonomy id").getModelIndex()); // actions on database try { // can't delete if a passport is associate with this taxonomy id List<Passport> parentPassports = PassportDAO.getInstance() .findByTaxonomy(Integer.parseInt(taxval)); if (parentPassports.size() > 0) { if (LoggerUtils.isLogEnabled()) { LoggerUtils.log(Level.INFO, "Taxonomy has passport associated " + "with it. Cannot delete"); } JOptionPane.showConfirmDialog(StockAnnotationPanel.this, "Cannot delete taxonomy associated with passports", "Error!", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE); taxonomyTable.setValueAt(false, selrow, 0); taxonomyTable.clearSelection(); } // otherwise delete record from database and delete row from table else { TaxonomyDAO.getInstance().delete(Integer.parseInt(taxval)); for (int i = 0; i < ((DefaultTableModel) taxonomyTable.getModel()).getRowCount(); i++) if (i == taxonomySelectedRow) { ((DefaultTableModel) taxonomyTable.getModel()) .removeRow(taxonomyTable.convertRowIndexToModel(i)); break; } // no selected row after delete taxonomySelectedRow = -1; taxonomyTable.setForeground(Color.BLACK); } } catch (HibernateException ex) { if (LoggerUtils.isLogEnabled()) { LoggerUtils.log(Level.INFO, ex.toString()); } } clearTaxonomySelection(); } }); }
From source file:org.accretegb.modules.germplasm.stockannotation.StockAnnotationPanel.java
/** * actions after edit button associated with Taxonomy table */// ww w . j a v a 2s. c o m private void addTaxonomyEditButtonListener() { taxonomyTablePanel.getEditButton().addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { taxonomyTablePanel.getDeleteButton().setEnabled(false); taxonomyTablePanel.getEditButton().setEnabled(false); // create a new panel for edit interface JPanel newSource = new JPanel(new MigLayout("insets 0, gapx 0")); String labelNames[] = { "<HTML>Genus<FONT COLOR = Red>*" + "</FONT></HTML>", "<HTML>Species Type<FONT COLOR = Red>*" + "</FONT></HTML>", "Subspecies", "Subtaxa", "Race", "Common Name", ColumnConstants.POPULATION, "Gto" }; // get current selected row int selRow = taxonomyTable.getSelectedRow(); String values[] = { taxonomyTable.getValueAt(selRow, 2).toString(), taxonomyTable.getValueAt(selRow, 3).toString(), taxonomyTable.getValueAt(selRow, 4) == null ? "" : taxonomyTable.getValueAt(selRow, 4).toString(), taxonomyTable.getValueAt(selRow, 5) == null ? "" : taxonomyTable.getValueAt(selRow, 5).toString(), taxonomyTable.getValueAt(selRow, 6) == null ? "" : taxonomyTable.getValueAt(selRow, 6).toString(), taxonomyTable.getValueAt(selRow, 7) == null ? "" : taxonomyTable.getValueAt(selRow, 7).toString(), taxonomyTable.getValueAt(selRow, 8) == null ? "" : taxonomyTable.getValueAt(selRow, 8).toString(), taxonomyTable.getValueAt(selRow, 9) == null ? "" : taxonomyTable.getValueAt(selRow, 9).toString() }; // check if input is valid boolean validInput = false; // create new components for edit interface JLabel labels[] = new JLabel[labelNames.length]; final JTextField textBoxes[] = new JTextField[labelNames.length]; // add components to new panel, write data from table to text field for (int columnIndex = 0; columnIndex < labels.length; columnIndex++) { labels[columnIndex] = new JLabel(labelNames[columnIndex]); newSource.add(labels[columnIndex], "gapleft 10, push"); textBoxes[columnIndex] = new JTextField(); textBoxes[columnIndex].setPreferredSize(new Dimension(200, 0)); textBoxes[columnIndex].setText(values[columnIndex]); newSource.add(textBoxes[columnIndex], "gapRight 10, wrap"); } do { // after editing, reset text for textfield for (int textBoxCounter = 0; textBoxCounter < labelNames.length; textBoxCounter++) textBoxes[textBoxCounter].setText(values[textBoxCounter]); // showConfirmDialog(Component parentComponent, Object message, String title, int optionType) int option = JOptionPane.showConfirmDialog(StockAnnotationPanel.this, newSource, "Enter New Taxonomy Information ", JOptionPane.DEFAULT_OPTION); validInput = true; if (option == JOptionPane.OK_OPTION) { for (int valueCounter = 0; valueCounter < labelNames.length; valueCounter++) { values[valueCounter] = textBoxes[valueCounter].getText(); if (labelNames[valueCounter].indexOf('*') != -1 && textBoxes[valueCounter].getText().equals("")) { if (LoggerUtils.isLogEnabled()) LoggerUtils.log(Level.INFO, labelNames[valueCounter] + " is mandatory"); validInput = false; // input is invalid } } // if input is valid if (validInput) { // update database Object newRow[] = updateTaxonomyTable(values); // update table ((DefaultTableModel) taxonomyTable.getModel()).insertRow(taxonomyTable.getRowCount(), newRow); } } // if input is valid if (!validInput) JOptionPane.showConfirmDialog(StockAnnotationPanel.this, "<HTML><FONT COLOR = Red>*</FONT> marked fields are mandatory.</HTML>", "Error!", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE); } while (!validInput); clearTaxonomySelection(); } }); }
From source file:org.accretegb.modules.germplasm.stockannotation.StockAnnotationPanel.java
/** * actions after add button associated with Taxonomy table *///from www.j a v a2 s .c o m private void addTaxonomyAddButtonListener() { taxonomyTablePanel.getAddButton().addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { taxonomyTablePanel.getDeleteButton().setEnabled(false); taxonomyTablePanel.getEditButton().setEnabled(false); // interface for adding new record JPanel newSource = new JPanel(new MigLayout("insets 0, gapx 0")); String labelNames[] = { "<HTML>Genus<FONT COLOR = Red>*" + "</FONT></HTML>", "<HTML>Species Type<FONT COLOR = Red>*" + "</FONT></HTML>", "Subspecies", "Subtaxa", "Race", "Common Name", ColumnConstants.POPULATION, "Gto" }; String values[] = { "", "", "", "", "", "", "", "" }; boolean validInput = false; JLabel labels[] = new JLabel[labelNames.length]; final JTextField textBoxes[] = new JTextField[labelNames.length]; for (int labelIndex = 0; labelIndex < labels.length; labelIndex++) { labels[labelIndex] = new JLabel(labelNames[labelIndex]); newSource.add(labels[labelIndex], "gapleft 10, push"); textBoxes[labelIndex] = new JTextField(); textBoxes[labelIndex].setPreferredSize(new Dimension(200, 0)); textBoxes[labelIndex].setText(values[labelIndex]); newSource.add(textBoxes[labelIndex], "gapRight 10, wrap"); } do { for (int columnIndex = 0; columnIndex < labelNames.length; columnIndex++) textBoxes[columnIndex].setText(values[columnIndex]); int option = JOptionPane.showConfirmDialog(StockAnnotationPanel.this, newSource, "Enter New Taxonomy Information ", JOptionPane.DEFAULT_OPTION); validInput = true; if (option == JOptionPane.OK_OPTION) { for (int valueCounter = 0; valueCounter < labelNames.length; valueCounter++) { values[valueCounter] = String.valueOf(textBoxes[valueCounter].getText()) .equalsIgnoreCase("") ? "NULL" : textBoxes[valueCounter].getText(); if (labelNames[valueCounter].indexOf('*') != -1 && textBoxes[valueCounter].getText().equals("")) { if (LoggerUtils.isLogEnabled()) LoggerUtils.log(Level.INFO, labelNames[valueCounter] + " " + "is " + "mandatory"); validInput = false; } } if (validInput) { // insert new record to database Object newRow[] = insertTaxonomyValues(values); // insert new row to table ((DefaultTableModel) taxonomyTable.getModel()).insertRow(taxonomyTable.getRowCount(), newRow); } } if (!validInput) JOptionPane.showConfirmDialog(StockAnnotationPanel.this, "<HTML><FONT COLOR = Red>*</FONT> marked fields are mandatory.</HTML>", "Error!", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE); } while (!validInput); clearTaxonomySelection(); } }); }
From source file:org.alex73.skarynka.scan.ui.book.BooksController.java
public BooksController() { try {// w w w . jav a 2 s . c o m panel = new BooksPanel(); ((AbstractDocument) panel.txtNewName.getDocument()).setDocumentFilter(bookNameFilter); listScanDirs(); panel.table.setModel(model()); panel.table.setRowSelectionAllowed(true); panel.table.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (SwingUtilities.isLeftMouseButton(e) && e.getClickCount() == 2) { BookRow b = books.get(panel.table.getSelectedRow()); DataStorage.openBook(b.bookName, true); } } @Override public void mousePressed(MouseEvent e) { if (SwingUtilities.isRightMouseButton(e)) { for (int i = 0; i < panel.menuProcess.getComponentCount(); i++) { Component item = panel.menuProcess.getComponent(i); if ((item instanceof JMenuItem) && (item.getName() != null)) { panel.menuProcess.remove(i); i--; } } if (Context.getPermissions().BookControl) { for (int scale : new int[] { 25, 50, 75, 100, 200 }) { JMenuItem item = new JMenuItem(scale + "%"); item.setName(scale + "%"); item.addActionListener(new ChangeScale(scale)); panel.menuProcess.add(item); } } currentBooksNames.clear(); int[] selected = panel.table.getSelectedRows(); boolean allLocals = true; boolean processAllowed = Context.getPermissions().BookControl; for (int row : selected) { BookRow b = books.get(panel.table.convertRowIndexToModel(row)); currentBooksNames.add(b.bookName); if (!b.local) { allLocals = false; } } panel.itemFinish.setVisible(allLocals); if (processAllowed) { for (Map.Entry<String, String> en : Context.getProcessCommands().entrySet()) { JMenuItem item = new JMenuItem(en.getValue()); item.setName(en.getKey()); item.addActionListener(commandListener); panel.menuProcess.add(item); } } panel.menuProcess.show(panel.table, e.getX(), e.getY()); } } }); panel.btnCreate.setEnabled(false); panel.btnCreate.addActionListener( new ActionErrorListener(panel, "ERROR_BOOK_CREATE", LOG, "Error create book") { protected void action(ActionEvent e) throws Exception { File bookDir = new File(Context.getBookDir(), panel.txtNewName.getText()); if (bookDir.exists()) { JOptionPane.showMessageDialog(panel, Messages.getString("PANEL_BOOK_NEW_BOOK_EXIST"), Messages.getString("PANEL_BOOK_TITLE"), JOptionPane.WARNING_MESSAGE); return; } DataStorage.openBook(panel.txtNewName.getText(), true); } }); setMenuListeners(); } catch (Throwable ex) { LOG.error("Error list books", ex); JOptionPane.showMessageDialog(DataStorage.mainFrame, "Error: " + ex.getClass() + " / " + ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } }
From source file:org.alex73.skarynka.scan.ui.scan.ScanDialogController.java
private ScanDialogController(PanelEditController panelController) { this.panelController = panelController; this.book = panelController.getBook(); int currentZoom = DataStorage.device.getZoom(); Dimension[] deviceImageSizes = DataStorage.device.getImageSize(); Dimension imageSize = deviceImageSizes[0]; for (int i = 1; i < deviceImageSizes.length; i++) { if (!imageSize.equals(deviceImageSizes[i])) { JOptionPane.showMessageDialog(DataStorage.mainFrame, Messages.getString("ERROR_WRONG_NOTEQUALSSIZE"), Messages.getString("ERROR_TITLE"), JOptionPane.ERROR_MESSAGE); return; }//from ww w . j a v a 2 s .c om } int pagesCount = book.getPagesCount(); if (pagesCount > 0) { int bookZoom = book.zoom; if (bookZoom != currentZoom) { if (JOptionPane.showConfirmDialog(DataStorage.mainFrame, Messages.getString("ERROR_WRONG_ZOOM", pagesCount, bookZoom, currentZoom), Messages.getString("ERROR_TITLE"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) != JOptionPane.OK_OPTION) { return; } } if (imageSize.width != book.imageSizeX || imageSize.height != book.imageSizeY) { if (JOptionPane.showConfirmDialog(DataStorage.mainFrame, Messages.getString("ERROR_WRONG_IMAGESIZE", pagesCount, s(new Dimension(book.imageSizeX, book.imageSizeY)), s(imageSize)), Messages.getString("ERROR_TITLE"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) != JOptionPane.OK_OPTION) { return; } for (String page : book.listPages()) { Book2.PageInfo pi = book.getPageInfo(page); pi.cropPosX = Integer.MIN_VALUE; pi.cropPosY = Integer.MIN_VALUE; } } } book.zoom = currentZoom; book.imageSizeX = imageSize.width; book.imageSizeY = imageSize.height; String dpi = Context.getSettings().get("dpi." + book.zoom); if (dpi != null) { book.dpi = Integer.parseInt(dpi); } else { book.dpi = 300; } dialog = new ScanDialog(DataStorage.mainFrame, true); dialog.btnClose.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { dialog.dispose(); } }); dialog.addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { DataStorage.device.setPreviewPanels(); panelController.show(); } }); init(dialog.controlLeft, dialog.liveLeft); init(dialog.controlRight, dialog.liveRight); checkNumbers(); showStatus(); boolean[] visible = DataStorage.device.setPreviewPanels(dialog.liveLeft, dialog.liveRight); dialog.controlLeft.setVisible(visible[0]); dialog.controlRight.setVisible(visible[1]); dialog.liveLeft.setVisible(visible[0]); dialog.liveRight.setVisible(visible[1]); int[] rotations = DataStorage.device.getRotations(); dialog.liveLeft.setRotation(rotations[0]); dialog.liveRight.setRotation(rotations[1]); dialog.setBounds(GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds()); dialog.validate(); dialog.controlLeft.txtNumber.setVisible(false); dialog.controlLeft.txtNumber.setVisible(false); int keyCode = HIDScanController.getKeyCode(Context.getSettings().get("hidscan-keys")); if (keyCode != 0) { addAction(keyCode, actionScan); } if (keyCode != KeyEvent.VK_F1) { addAction(KeyEvent.VK_F1, actionScan); } dialog.btnScan.addActionListener(actionScan); addAction(KeyEvent.VK_F2, actionRescan); dialog.btnRescan.addActionListener(actionRescan); dialog.setVisible(true); }
From source file:org.apache.cayenne.modeler.dialog.pref.DataSourcePreferences.java
/** * Tries to establish a DB connection, reporting the status of this * operation.//from w ww . j a v a 2s . c om */ public void testDataSourceAction() { DBConnectionInfo currentDataSource = getConnectionInfo(); if (currentDataSource == null) { return; } if (currentDataSource.getJdbcDriver() == null) { JOptionPane.showMessageDialog(null, "No JDBC Driver specified", "Warning", JOptionPane.WARNING_MESSAGE); return; } if (currentDataSource.getUrl() == null) { JOptionPane.showMessageDialog(null, "No Database URL specified", "Warning", JOptionPane.WARNING_MESSAGE); return; } try { FileClassLoadingService classLoader = new FileClassLoadingService(); List<File> oldPathFiles = ((FileClassLoadingService) getApplication().getClassLoadingService()) .getPathFiles(); Collection<String> details = new ArrayList<>(); for (File oldPathFile : oldPathFiles) { details.add(oldPathFile.getAbsolutePath()); } Preferences classPathPreferences = getApplication().getPreferencesNode(ClasspathPreferences.class, ""); if (editor.getChangedPreferences().containsKey(classPathPreferences)) { Map<String, String> map = editor.getChangedPreferences().get(classPathPreferences); for (Map.Entry<String, String> en : map.entrySet()) { String key = en.getKey(); if (!details.contains(key)) { details.add(key); } } } if (editor.getRemovedPreferences().containsKey(classPathPreferences)) { Map<String, String> map = editor.getRemovedPreferences().get(classPathPreferences); for (Map.Entry<String, String> en : map.entrySet()) { String key = en.getKey(); if (details.contains(key)) { details.remove(key); } } } if (details.size() > 0) { // transform preference to file... Transformer transformer = new Transformer() { public Object transform(Object object) { String pref = (String) object; return new File(pref); } }; classLoader.setPathFiles(CollectionUtils.collect(details, transformer)); } Class<Driver> driverClass = classLoader.loadClass(Driver.class, currentDataSource.getJdbcDriver()); Driver driver = driverClass.newInstance(); // connect via Cayenne DriverDataSource - it addresses some driver // issues... // can't use try with resource here as we can loose meaningful exception Connection c = new DriverDataSource(driver, currentDataSource.getUrl(), currentDataSource.getUserName(), currentDataSource.getPassword()).getConnection(); try { c.close(); } catch (SQLException ignored) { // i guess we can ignore this... } JOptionPane.showMessageDialog(null, "Connected Successfully", "Success", JOptionPane.INFORMATION_MESSAGE); } catch (Throwable th) { th = Util.unwindException(th); String message = "Error connecting to DB: " + th.getLocalizedMessage(); StringTokenizer st = new StringTokenizer(message); StringBuilder sbMessage = new StringBuilder(); int len = 0; String tempString; while (st.hasMoreTokens()) { tempString = st.nextElement().toString(); if (len < 110) { len = len + tempString.length() + 1; } else { sbMessage.append("\n"); len = 0; } sbMessage.append(tempString).append(" "); } JOptionPane.showMessageDialog(null, sbMessage.toString(), "Warning", JOptionPane.WARNING_MESSAGE); } }
From source file:org.apache.jmeter.visualizers.RespTimeGraphVisualizer.java
private void actionMakeGraph() { String msgErr = null;// w w w .jav a2 s .c o m // Calculate the test duration. Needs to xAxis Labels and getData. durationTest = maxStartTime - minStartTime; if (seriesNames.size() <= 0) { msgErr = JMeterUtils.getResString("aggregate_graph_no_values_to_graph"); // $NON-NLS-1$ } else if (durationTest < 1) { msgErr = JMeterUtils.getResString("graph_resp_time_not_enough_data"); // $NON-NLS-1$ } if (msgErr == null) { makeGraph(); tabbedGraph.setSelectedIndex(1); } else { tabbedGraph.setSelectedIndex(0); JOptionPane.showMessageDialog(null, msgErr, msgErr, JOptionPane.WARNING_MESSAGE); } }
From source file:org.apache.jmeter.visualizers.StatGraphVisualizer.java
private void actionMakeGraph() { if (model.getRowCount() > 1) { makeGraph();/*from ww w . jav a 2 s.co m*/ tabbedGraph.setSelectedIndex(1); } else { JOptionPane.showMessageDialog(null, JMeterUtils.getResString("aggregate_graph_no_values_to_graph"), // $NON-NLS-1$ JMeterUtils.getResString("aggregate_graph_no_values_to_graph"), // $NON-NLS-1$ JOptionPane.WARNING_MESSAGE); } }
From source file:org.bibsonomy.plugin.jabref.worker.ImportPostsByCriteriaWorker.java
public void run() { dialog.setVisible(true);/* ww w . ja v a2 s. c om*/ dialog.setProgress(0, 0); int numberOfPosts = 0, start = 0, end = PluginProperties.getNumberOfPostsPerRequest(), cycle = 0, numberOfPostsPerRequest = PluginProperties.getNumberOfPostsPerRequest(); boolean continueFetching = false; do { numberOfPosts = 0; List<String> tags = null; String search = null; switch (type) { case TAGS: if (criteria.contains(" ")) { tags = Arrays.asList(criteria.split("\\s")); } else { tags = Arrays.asList(new String[] { criteria }); } break; case FULL_TEXT: search = criteria; break; } try { final Collection<Post<BibTex>> result = getLogic().getPosts(BibTex.class, grouping, groupingValue, tags, null, search, null, null, null, null, start, end); for (Post<? extends Resource> post : result) { dialog.setProgress(numberOfPosts++, numberOfPostsPerRequest); BibtexEntry entry = JabRefModelConverter.convertPost(post); // clear fields if the fetched posts does not belong to the // user if (!PluginProperties.getUsername().equals(entry.getField("username"))) { entry.clearField("intrahash"); entry.clearField("interhash"); entry.clearField("file"); entry.clearField("owner"); } dialog.addEntry(entry); } if (!continueFetching) { if (!ignoreRequestSize) { if (!PluginProperties.getIgnoreMorePostsWarning()) { if (numberOfPosts == numberOfPostsPerRequest) { int status = JOptionPane.showOptionDialog(dialog, "<html>There are probably more than " + PluginProperties.getNumberOfPostsPerRequest() + " posts available. Continue importing?<br>You can stop importing entries by hitting the Stop button on the import dialog.", "More posts available", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, null, JOptionPane.YES_OPTION); switch (status) { case JOptionPane.YES_OPTION: continueFetching = true; break; case JOptionPane.NO_OPTION: this.stopFetching(); break; default: break; } } } } } start = ((cycle + 1) * numberOfPostsPerRequest); end = ((cycle + 2) * numberOfPostsPerRequest); cycle++; } catch (AuthenticationException ex) { (new ShowSettingsDialogAction((JabRefFrame) dialog.getOwner())).actionPerformed(null); } catch (Exception ex) { LOG.error("Failed to import posts", ex); } } while (fetchNext() && numberOfPosts >= numberOfPostsPerRequest); dialog.entryListComplete(); }