List of usage examples for javax.swing JOptionPane ERROR_MESSAGE
int ERROR_MESSAGE
To view the source code for javax.swing JOptionPane ERROR_MESSAGE.
Click Source Link
From source file:eulermind.MindDB.java
public void startUp() { try {// www .j a va 2 s . c o m initBackGraph(); m_rootIndex = getOrCreateIndex(ROOT_INDEX_NAME); m_trashIndex = getOrCreateIndex(TRASH_INDEX_NAME); createFullTextVertexKeyIndex(MindModel.TEXT_PROP_NAME); Vertex root = null; if (m_rootIndex.get(ROOT_KEY_NAME, ROOT_KEY_NAME).iterator().hasNext()) { root = m_rootIndex.get(ROOT_KEY_NAME, ROOT_KEY_NAME).iterator().next(); } else { if (m_graph instanceof OrientGraph) { root = getVertex(new ORecordId("#9:0")); } if (root == null) { root = addVertex(null); } m_rootIndex.put(ROOT_KEY_NAME, ROOT_KEY_NAME, root); //translate the root id from temporary to permanence m_graph.commit(); } m_rootId = root.getId(); } catch (Exception e) { m_logger.error("startup mind db get exception: " + e.getMessage()); m_logger.error("StackTrace: {}", Utils.getThrowableStackTraceString(e)); JOptionPane.showMessageDialog(null, "database error, you must fix it firsly ! " + m_path, null, JOptionPane.ERROR_MESSAGE); System.exit(1); } }
From source file:sample.fa.ScriptRunnerApplication.java
void loadScript(File f) { try {/*from w ww . ja v a2 s . co m*/ scriptContents.setText(String.join("\n", Files.readAllLines(f.toPath()))); String name = f.getName(); int lastDot = name.lastIndexOf('.'); if (lastDot >= 0) { String extension = name.substring(lastDot + 1); for (int i = 0; i < languagesModel.getSize(); i++) { ScriptEngine se = languagesModel.getElementAt(i); if (se.getFactory().getExtensions().indexOf(extension) >= 0) { languagesModel.setSelectedItem(se); break; } } } } catch (IOException ex) { JOptionPane.showMessageDialog(scriptContents, ex.getMessage(), "Error Loading Script", JOptionPane.ERROR_MESSAGE); } }
From source file:com.commander4j.sys.JHost.java
public synchronized boolean connect(String sessionID, String host, String sqlPath, String viewPath) { Connection tempConn;//w w w.j a v a2s .c o m boolean result = false; if (getSqlstatements().IsInitialised() == false) { getSqlstatements().setXMLFilename(sqlPath); getSqlstatements().setjdbcDriver(getDatabaseParameters().getjdbcDriver()); getSqlstatements().loadSQLStatements(host); getViewstatements().setXMLFilename(viewPath); getViewstatements().setjdbcDriver(getDatabaseParameters().getjdbcDriver()); getViewstatements().loadSQLStatements(host); getSqlstatements().setSubstitutions(getViewstatements().getSQLStatements()); getSqlstatements().setInitialised(); } if (connections.containsKey(sessionID) == false) { try { Class.forName(getDatabaseParameters().getjdbcDriver()).newInstance(); try { logger.debug(getDatabaseParameters().getjdbcConnectString()); DriverManager.setLoginTimeout(5); tempConn = DriverManager.getConnection(getDatabaseParameters().getjdbcConnectString(), getDatabaseParameters().getjdbcUsername(), getDatabaseParameters().getjdbcPassword()); tempConn.setAutoCommit(false); tempConn.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED); ++instanceCount; addConnection(sessionID, tempConn); result = true; setConnected(sessionID, true); logger.debug("Opened connection for session ID : " + sessionID); } catch (Exception ex) { String err = ""; try { err = ex.getMessage().substring(0, ex.getMessage().indexOf("\n")); } catch (Exception ex2) { err = ex.getMessage(); } logger.fatal(ex); if (Common.sd.getData(sessionID, "silentExceptions").equals("Yes") == false) { JUtility.errorBeep(); JSplashScreenUtils.hide(); JOptionPane.showMessageDialog(null, WordUtils.wrap(err, 100), "Database Connection Error (" + getSiteDescription() + ")", JOptionPane.ERROR_MESSAGE); } result = false; } } catch (Exception ex) { logger.fatal(ex); if (Common.sd.getData(sessionID, "silentExceptions").equals("Yes") == false) { JUtility.errorBeep(); JOptionPane.showMessageDialog(null, "Invalid jdbc driver [" + ex.getMessage() + "]", "Login Error (" + getSiteDescription() + ")", JOptionPane.ERROR_MESSAGE); } result = false; } } return result; }
From source file:com.emr.schemas.SchemerMapper.java
/** * Method for getting the database's tables and populating the List with the same. *///ww w . j a v a2s . c om public final void getDatabaseMetaData() { try { DatabaseMetaData dbmd = emrConn.getMetaData(); String[] types = { "TABLE" }; ResultSet rs = dbmd.getTables(null, null, "%", types); while (rs.next()) { //Add table name to Jlist listModel.addElement(rs.getString("TABLE_NAME")); } } catch (SQLException e) { String stacktrace = org.apache.commons.lang3.exception.ExceptionUtils.getStackTrace(e); JOptionPane.showMessageDialog(this, "Could not fetch Tables for the KenyaEMR Database. Error Details: " + stacktrace, "Table Names Error", JOptionPane.ERROR_MESSAGE); } }
From source file:net.pms.dlna.DLNAMediaDatabase.java
public void init(boolean force) { dbCount = -1;//from w w w . j ava 2 s. c o m String version = null; Connection conn = null; ResultSet rs = null; Statement stmt = null; try { conn = getConnection(); } catch (SQLException se) { final File dbFile = new File(dbDir + File.separator + dbName + ".data.db"); final File dbDirectory = new File(dbDir); if (dbFile.exists() || (se.getErrorCode() == 90048)) { // Cache is corrupt or wrong version, so delete it FileUtils.deleteQuietly(dbDirectory); if (!dbDirectory.exists()) { logger.debug("The cache has been deleted because it was corrupt or had the wrong version"); } else { if (!PMS.isHeadless()) { JOptionPane.showMessageDialog( (JFrame) (SwingUtilities.getWindowAncestor((Component) PMS.get().getFrame())), String.format(Messages.getString("DLNAMediaDatabase.5"), dbDir), Messages.getString("Dialog.Error"), JOptionPane.ERROR_MESSAGE); } logger.debug("Damaged cache can't be deleted. Stop the program and delete the folder \"" + dbDir + "\" manually"); configuration.setUseCache(false); return; } } else { logger.debug("Cache connection error: " + se.getMessage()); configuration.setUseCache(false); return; } } try { conn = getConnection(); stmt = conn.createStatement(); rs = stmt.executeQuery("SELECT count(*) FROM FILES"); if (rs.next()) { dbCount = rs.getInt(1); } rs.close(); stmt.close(); stmt = conn.createStatement(); rs = stmt.executeQuery("SELECT VALUE FROM METADATA WHERE KEY = 'VERSION'"); if (rs.next()) { version = rs.getString(1); } } catch (SQLException se) { if (se.getErrorCode() != 42102) { // Don't log exception "Table "FILES" not found" which will be corrected in following step logger.error(null, se); } } finally { close(rs); close(stmt); close(conn); } boolean force_reinit = !PMS.getVersion().equals(version); // here we can force a deletion for a specific version if (force || dbCount == -1 || force_reinit) { logger.debug("Database will be (re)initialized"); try { conn = getConnection(); executeUpdate(conn, "DROP TABLE FILES"); executeUpdate(conn, "DROP TABLE METADATA"); executeUpdate(conn, "DROP TABLE REGEXP_RULES"); executeUpdate(conn, "DROP TABLE AUDIOTRACKS"); executeUpdate(conn, "DROP TABLE SUBTRACKS"); } catch (SQLException se) { if (se.getErrorCode() != 42102) { // Don't log exception "Table "FILES" not found" which will be corrected in following step logger.error(null, se); } } try { StringBuilder sb = new StringBuilder(); sb.append("CREATE TABLE FILES ("); sb.append(" ID INT AUTO_INCREMENT"); sb.append(", FILENAME VARCHAR2(1024) NOT NULL"); sb.append(", MODIFIED TIMESTAMP NOT NULL"); sb.append(", TYPE INT"); sb.append(", DURATION DOUBLE"); sb.append(", BITRATE INT"); sb.append(", WIDTH INT"); sb.append(", HEIGHT INT"); sb.append(", SIZE NUMERIC"); sb.append(", CODECV VARCHAR2(").append(SIZE_CODECV).append(")"); sb.append(", FRAMERATE VARCHAR2(").append(SIZE_FRAMERATE).append(")"); sb.append(", ASPECT VARCHAR2(").append(SIZE_ASPECT).append(")"); sb.append(", ASPECTRATIOCONTAINER VARCHAR2(").append(SIZE_ASPECTRATIO_CONTAINER).append(")"); sb.append(", ASPECTRATIOVIDEOTRACK VARCHAR2(").append(SIZE_ASPECTRATIO_VIDEOTRACK).append(")"); sb.append(", REFRAMES TINYINT"); sb.append(", AVCLEVEL VARCHAR2(").append(SIZE_AVC_LEVEL).append(")"); sb.append(", BITSPERPIXEL INT"); sb.append(", THUMB BINARY"); sb.append(", CONTAINER VARCHAR2(").append(SIZE_CONTAINER).append(")"); sb.append(", MODEL VARCHAR2(").append(SIZE_MODEL).append(")"); sb.append(", EXPOSURE INT"); sb.append(", ORIENTATION INT"); sb.append(", ISO INT"); sb.append(", MUXINGMODE VARCHAR2(").append(SIZE_MUXINGMODE).append(")"); sb.append(", FRAMERATEMODE VARCHAR2(").append(SIZE_FRAMERATE_MODE).append(")"); sb.append(", constraint PK1 primary key (FILENAME, MODIFIED, ID))"); executeUpdate(conn, sb.toString()); sb = new StringBuilder(); sb.append("CREATE TABLE AUDIOTRACKS ("); sb.append(" FILEID INT NOT NULL"); sb.append(", ID INT NOT NULL"); sb.append(", LANG VARCHAR2(").append(SIZE_LANG).append(")"); sb.append(", FLAVOR VARCHAR2(").append(SIZE_FLAVOR).append(")"); sb.append(", NRAUDIOCHANNELS NUMERIC"); sb.append(", SAMPLEFREQ VARCHAR2(").append(SIZE_SAMPLEFREQ).append(")"); sb.append(", CODECA VARCHAR2(").append(SIZE_CODECA).append(")"); sb.append(", BITSPERSAMPLE INT"); sb.append(", ALBUM VARCHAR2(").append(SIZE_ALBUM).append(")"); sb.append(", ARTIST VARCHAR2(").append(SIZE_ARTIST).append(")"); sb.append(", SONGNAME VARCHAR2(").append(SIZE_SONGNAME).append(")"); sb.append(", GENRE VARCHAR2(").append(SIZE_GENRE).append(")"); sb.append(", YEAR INT"); sb.append(", TRACK INT"); sb.append(", DELAY INT"); sb.append(", MUXINGMODE VARCHAR2(").append(SIZE_MUXINGMODE).append(")"); sb.append(", BITRATE INT"); sb.append(", constraint PKAUDIO primary key (FILEID, ID))"); executeUpdate(conn, sb.toString()); sb = new StringBuilder(); sb.append("CREATE TABLE SUBTRACKS ("); sb.append(" FILEID INT NOT NULL"); sb.append(", ID INT NOT NULL"); sb.append(", LANG VARCHAR2(").append(SIZE_LANG).append(")"); sb.append(", FLAVOR VARCHAR2(").append(SIZE_FLAVOR).append(")"); sb.append(", TYPE INT"); sb.append(", constraint PKSUB primary key (FILEID, ID))"); executeUpdate(conn, sb.toString()); executeUpdate(conn, "CREATE TABLE METADATA (KEY VARCHAR2(255) NOT NULL, VALUE VARCHAR2(255) NOT NULL)"); executeUpdate(conn, "INSERT INTO METADATA VALUES ('VERSION', '" + PMS.getVersion() + "')"); executeUpdate(conn, "CREATE INDEX IDXARTIST on AUDIOTRACKS (ARTIST asc);"); executeUpdate(conn, "CREATE INDEX IDXALBUM on AUDIOTRACKS (ALBUM asc);"); executeUpdate(conn, "CREATE INDEX IDXGENRE on AUDIOTRACKS (GENRE asc);"); executeUpdate(conn, "CREATE INDEX IDXYEAR on AUDIOTRACKS (YEAR asc);"); executeUpdate(conn, "CREATE TABLE REGEXP_RULES ( ID VARCHAR2(255) PRIMARY KEY, RULE VARCHAR2(255), ORDR NUMERIC);"); executeUpdate(conn, "INSERT INTO REGEXP_RULES VALUES ( '###', '(?i)^\\W.+', 0 );"); executeUpdate(conn, "INSERT INTO REGEXP_RULES VALUES ( '0-9', '(?i)^\\d.+', 1 );"); // Retrieve the alphabet property value and split it String[] chars = Messages.getString("DLNAMediaDatabase.1").split(","); for (int i = 0; i < chars.length; i++) { // Create regexp rules for characters with a sort order based on the property value executeUpdate(conn, "INSERT INTO REGEXP_RULES VALUES ( '" + chars[i] + "', '(?i)^" + chars[i] + ".+', " + (i + 2) + " );"); } logger.debug("Database initialized"); } catch (SQLException se) { logger.info("Error in table creation: " + se.getMessage()); } finally { close(conn); } } else { logger.debug("Database file count: " + dbCount); logger.debug("Database version: " + version); } }
From source file:de.badw.strauss.glyphpicker.controller.alltab.TeiLoadWorker.java
/** * Loads data from a file./*from ww w . j ava2s . com*/ * * @return the resulting GlyphDefinition list */ public List<GlyphDefinition> loadDataFromFile() { String fileName = dataSource.getBasePath(); if (fileName != null) { File file = new File(fileName); InputStream inputStream = null; try { inputStream = new FileInputStream(file); } catch (IOException e) { JOptionPane.showMessageDialog( null, String.format(i18n.getString("TeiLoadWorker.couldNotLoadData"), e.getLocalizedMessage(), fileName), i18n.getString("TeiLoadWorker.error"), JOptionPane.ERROR_MESSAGE); LOGGER.info(e); } if (inputStream != null) { return parseXmlSax(inputStream); } } return null; }
From source file:components.CustomDialog.java
/** This method reacts to state changes in the option pane. */ public void propertyChange(PropertyChangeEvent e) { String prop = e.getPropertyName(); if (isVisible() && (e.getSource() == optionPane) && (JOptionPane.VALUE_PROPERTY.equals(prop) || JOptionPane.INPUT_VALUE_PROPERTY.equals(prop))) { Object value = optionPane.getValue(); if (value == JOptionPane.UNINITIALIZED_VALUE) { //ignore reset return; }// w w w . ja v a 2 s . c o m //Reset the JOptionPane's value. //If you don't do this, then if the user //presses the same button next time, no //property change event will be fired. optionPane.setValue(JOptionPane.UNINITIALIZED_VALUE); if (btnString1.equals(value)) { typedText = textField.getText(); String ucText = typedText.toUpperCase(); if (magicWord.equals(ucText)) { //we're done; clear and dismiss the dialog clearAndHide(); } else { //text was invalid textField.selectAll(); JOptionPane .showMessageDialog( CustomDialog.this, "Sorry, \"" + typedText + "\" " + "isn't a valid response.\n" + "Please enter " + magicWord + ".", "Try again", JOptionPane.ERROR_MESSAGE); typedText = null; textField.requestFocusInWindow(); } } else { //user closed dialog or clicked cancel dd.setLabel("It's OK. " + "We won't force you to type " + magicWord + "."); typedText = null; clearAndHide(); } } }
From source file:me.philnate.textmanager.utils.PDFCreator.java
@SuppressWarnings("deprecation") private void preparePDF() { try {/*from w w w . ja va 2s .c om*/ File path = new File(SystemUtils.getUserDir(), "template"); File template = new File(path, Setting.find("template").getValue()); Velocity.setProperty("file.resource.loader.path", path.getAbsolutePath()); Velocity.init(); VelocityContext ctx = new VelocityContext(); // User data/Settings for (Setting setting : ds.find(Setting.class).asList()) { ctx.put(setting.getKey(), setting.getValue()); } NumberFormat format = NumberFormat.getNumberInstance(new Locale(Setting.find("locale").getValue())); // #60 always show 2 digits for fraction no matter if right most(s) // are zero format.setMinimumFractionDigits(2); format.setMaximumFractionDigits(2); ctx.put("number", format); // TODO update schema to have separate first and lastname // Customer data ctx.put("customer", customer); // General data ctx.put("month", new DateFormatSymbols().getMonths()[month]); ctx.put("math", new MathTool()); // Billing data ctx.put("allItems", BillingItem.find(customer.getId(), year, month)); ctx.put("billNo", bill.getBillNo()); StringWriter writer = new StringWriter(); Velocity.mergeTemplate(template.getName(), ctx, writer); File filledTemplate = new File(path, bill.getBillNo() + ".tex"); FileUtils.writeStringToFile(filledTemplate, writer.toString(), "ISO-8859-1"); ProcessBuilder pdfLatex = new ProcessBuilder(Setting.find("pdfLatex").getValue(), "-interaction nonstopmode", "-output-format pdf", filledTemplate.toString()); // Saving template file (just in case it may be needed later GridFSFile texFile = tex.createFile(filledTemplate); texFile.put("month", month); texFile.put("year", year); texFile.put("customerId", customer.getId()); texFile.save(); pdfLatex.directory(path); String pdfPath = filledTemplate.toString().replaceAll("tex$", "pdf"); if (0 == printOutputStream(pdfLatex)) { // display Bill in DocumentViewer new ProcessBuilder(Setting.find("pdfViewer").getValue(), pdfPath).start().waitFor(); GridFSFile pdfFile = pdf.createFile(new File(pdfPath)); pdfFile.put("month", month); pdfFile.put("year", year); pdfFile.put("customerId", customer.getId()); pdf.remove(QueryBuilder.start("month").is(month).and("year").is(year).and("customerId") .is(customer.getId()).get()); pdfFile.save(); File[] files = path.listFiles((FileFilter) new WildcardFileFilter(bill.getBillNo() + ".*")); for (File file : files) { FileUtils.forceDelete(file); } } else { new JOptionPane( "Bei der Erstellung der Rechnung ist ein Fehler aufgetreten. Es wurde keine Rechnung erstellt.\n Bitte Schauen sie in die Logdatei fr nhere Fehlerinformationen.", JOptionPane.ERROR_MESSAGE).setVisible(true); } } catch (IOException e) { Throwables.propagate(e); } catch (InterruptedException e) { Throwables.propagate(e); } }
From source file:com.joey.software.Tools.AScanViewerTool.java
public void createJPanel() { JSplitPane graphSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT); graphSplit.setLeftComponent(previewPanel); graphSplit.setRightComponent(dataPanel); graphSplit.setOneTouchExpandable(true); graphSplit.setDividerLocation(400);// w ww. j ava 2 s . c o m JPanel graphHolder = new JPanel(new BorderLayout()); graphHolder.add(graphSplit, BorderLayout.CENTER); graphHolder.setBorder(BorderFactory.createTitledBorder("")); JPanel tool = new JPanel(new BorderLayout()); tool.add(saveCSVData, BorderLayout.SOUTH); tool.add(aScanType, BorderLayout.CENTER); JPanel leftPanel = new JPanel(new BorderLayout()); leftPanel.add(graphHolder, BorderLayout.CENTER); leftPanel.add(tool, BorderLayout.SOUTH); JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); split.setOneTouchExpandable(true); split.setRightComponent(imageViewPanel); split.setLeftComponent(leftPanel); split.setDividerLocation(600); JPanel mainPanel = new JPanel(new BorderLayout()); mainPanel.add(split, BorderLayout.CENTER); getContentPane().setLayout(new BorderLayout()); getContentPane().add(mainPanel); aScanType.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { imageViewPanel.setViewType(aScanType.getSelectedIndex()); } }); saveCSVData.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { File f = FileSelectionField.getUserFile(); f = FileOperations.renameFileType(f, "csv"); saveAScanData(f); } catch (Exception e1) { JOptionPane.showMessageDialog(null, "Error : " + e1.getLocalizedMessage(), "Error Saving Data", JOptionPane.ERROR_MESSAGE); e1.printStackTrace(); } } }); }
From source file:net.sf.jabref.gui.UrlDragDrop.java
@Override public void drop(DropTargetDropEvent dtde) { Transferable tsf = dtde.getTransferable(); dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE); //try with an URL DataFlavor dtURL = null;//ww w . ja va 2s .com try { dtURL = new DataFlavor("application/x-java-url; class=java.net.URL"); } catch (ClassNotFoundException e) { LOGGER.warn("Could not find DropTargetDropEvent class.", e); } try { URL url = (URL) tsf.getTransferData(dtURL); JOptionChoice res = (JOptionChoice) JOptionPane.showInputDialog(editor, "", Localization.lang("Select action"), JOptionPane.QUESTION_MESSAGE, null, new JOptionChoice[] { new JOptionChoice(Localization.lang("Insert URL"), 0), new JOptionChoice(Localization.lang("Download file"), 1) }, new JOptionChoice(Localization.lang("Insert URL"), 0)); if (res != null) { switch (res.getId()) { //insert URL case 0: feditor.setText(url.toString()); editor.updateField(feditor); break; //download file case 1: try { //auto filename: File file = new File(new File(Globals.prefs.get("pdfDirectory")), editor.getEntry().getCiteKey() + ".pdf"); frame.output(Localization.lang("Downloading...")); MonitoredURLDownload.buildMonitoredDownload(editor, url).downloadToFile(file); frame.output(Localization.lang("Download completed")); feditor.setText(file.toURI().toURL().toString()); editor.updateField(feditor); } catch (IOException ioex) { LOGGER.error("Error while downloading file.", ioex); JOptionPane.showMessageDialog(editor, Localization.lang("File download"), Localization.lang("Error while downloading file:" + ioex.getMessage()), JOptionPane.ERROR_MESSAGE); } break; default: LOGGER.warn("Unknown selection (should not happen)"); break; } } return; } catch (UnsupportedFlavorException nfe) { // not an URL then... LOGGER.warn("Could not parse URL.", nfe); } catch (IOException ioex) { LOGGER.warn("Could not perform drag and drop.", ioex); } try { //try with a File List @SuppressWarnings("unchecked") List<File> filelist = (List<File>) tsf.getTransferData(DataFlavor.javaFileListFlavor); if (filelist.size() > 1) { JOptionPane.showMessageDialog(editor, Localization.lang("Only one item is supported"), Localization.lang("Drag and Drop Error"), JOptionPane.ERROR_MESSAGE); return; } File fl = filelist.get(0); feditor.setText(fl.toURI().toURL().toString()); editor.updateField(feditor); } catch (UnsupportedFlavorException nfe) { JOptionPane.showMessageDialog(editor, Localization.lang("Operation not supported"), Localization.lang("Drag and Drop Error"), JOptionPane.ERROR_MESSAGE); LOGGER.warn("Could not perform drag and drop.", nfe); } catch (IOException ioex) { LOGGER.warn("Could not perform drag and drop.", ioex); } }