Example usage for javax.swing JOptionPane INFORMATION_MESSAGE

List of usage examples for javax.swing JOptionPane INFORMATION_MESSAGE

Introduction

In this page you can find the example usage for javax.swing JOptionPane INFORMATION_MESSAGE.

Prototype

int INFORMATION_MESSAGE

To view the source code for javax.swing JOptionPane INFORMATION_MESSAGE.

Click Source Link

Document

Used for information messages.

Usage

From source file:com.frostwire.gui.updates.InstallerUpdater.java

private void showUpdateMessage() {
    GUIMediator.safeInvokeLater(new Runnable() {
        public void run() {
            if (_executableFile == null) {
                return;
            }//from w  w w .  jav a2  s .  c  o m

            int result = JOptionPane.showConfirmDialog(null, _updateMessage.getMessageInstallerReady(),
                    I18n.tr("Update"), JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE);

            if (result == JOptionPane.YES_OPTION) {
                try {
                    if (OSUtils.isWindows()) {
                        String[] commands = new String[] { "CMD.EXE", "/C", _executableFile.getAbsolutePath() };

                        ProcessBuilder pbuilder = new ProcessBuilder(commands);
                        pbuilder.start();
                    } else if (OSUtils.isLinux() && OSUtils.isUbuntu()) {
                        String[] commands = new String[] { "gdebi-gtk", _executableFile.getAbsolutePath() };

                        ProcessBuilder pbuilder = new ProcessBuilder(commands);
                        pbuilder.start();
                    } else if (OSUtils.isMacOSX()) {
                        String[] mountCommand = new String[] { "hdiutil", "attach",
                                _executableFile.getAbsolutePath() };

                        String[] finderShowCommand = new String[] { "open",
                                "/Volumes/" + FilenameUtils.getBaseName(_executableFile.getName()) };

                        ProcessBuilder pbuilder = new ProcessBuilder(mountCommand);
                        Process mountingProcess = pbuilder.start();

                        mountingProcess.waitFor();

                        pbuilder = new ProcessBuilder(finderShowCommand);
                        pbuilder.start();
                    }

                    GUIMediator.shutdown();
                } catch (Throwable e) {
                    LOG.error("Unable to launch new installer", e);
                }
            }
        }
    });
}

From source file:FPSCounterDemo.java

 public void init() {
   setLayout(new BorderLayout());
   GraphicsConfiguration config = SimpleUniverse
         .getPreferredConfiguration();// ww  w.  j  av  a2 s  . c  o m

   Canvas3D c = new Canvas3D(config);
   add("Center", c);

   // Create a simple scene and attach it to the virtual universe
   BranchGroup scene = createSceneGraph();

   // Parse the command line to set the various parameters

   // Have Java 3D perform optimizations on this scene graph.
   scene.compile();
   u = new SimpleUniverse(c);

   // This will move the ViewPlatform back a bit so the
   // objects in the scene can be viewed.
   u.getViewingPlatform().setNominalViewingTransform();

   u.addBranchGraph(scene);

   JOptionPane
         .showMessageDialog(
               this,
               "\nThis program measures the number of frames rendered per second.\nNote that the frame rate is limited by the refresh rate of the monitor.\nTo get the true frame rate you need to disable vertical retrace.\n\nOn Windows(tm) you do this through the Control Panel.\n\nOn Unix set the environment variable OGL_NO_VBLANK\n(i.e. type \"setenv OGL_NO_VBLANK\" at the command prompt)",
               "Frame Counter", JOptionPane.INFORMATION_MESSAGE);
}

From source file:mobac.mapsources.loader.MapPackManager.java

public void loadMapPacks(MapSourcesManager mapSourcesManager) throws IOException, CertificateException {
    File[] mapPacks = getAllMapPackFiles();
    for (File mapPackFile : mapPacks) {
        File oldMapPackFile = new File(mapPackFile.getAbsolutePath() + ".old");
        try {/*from  w ww . ja  v  a2s.  com*/
            loadMapPack(mapPackFile, mapSourcesManager);
            if (oldMapPackFile.isFile())
                Utilities.deleteFile(oldMapPackFile);
        } catch (MapSourceCreateException e) {
            if (oldMapPackFile.isFile()) {
                mapPackFile.deleteOnExit();
                File newMapPackFile = new File(mapPackFile.getAbsolutePath() + ".new");
                Utilities.renameFile(oldMapPackFile, newMapPackFile);
                try {
                    JOptionPane.showMessageDialog(null,
                            "An error occured while installing the updated map package.\n"
                                    + "Please restart MOBAC for restoring the previous version.",
                            "Error loading updated map package", JOptionPane.INFORMATION_MESSAGE);
                    System.exit(1);
                } catch (Exception e1) {
                    log.error(e1.getMessage(), e1);
                }
            }
            GUIExceptionHandler.processException(e);
        } catch (CertificateException e) {
            throw e;
        } catch (Exception e) {
            throw new IOException("Failed to load map pack: " + mapPackFile, e);
        }
    }
}

From source file:edu.harvard.i2b2.analysis.queryClient.CRCQueryClient.java

public static String sendPDQQueryRequestSOAP(String XMLstr) {
    try {/*from w w  w.  j ava 2  s .  c om*/
        MessageUtil.getInstance().setRequest("URL: " + getPDQServiceName() + "\n" + XMLstr);

        HttpTransportProperties.Authenticator basicAuthentication = new HttpTransportProperties.Authenticator();

        basicAuthentication.setUsername(UserInfoBean.getInstance().getUserName());
        basicAuthentication.setPassword(UserInfoBean.getInstance().getUserPassword());

        OMElement payload = getQueryPayLoad(XMLstr);
        Options options = new Options();

        // options.setProperty(HTTPConstants.PROXY, proxyProperties);
        targetEPR = new EndpointReference(getPDQServiceName());
        options.setTo(targetEPR);

        options.setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE, basicAuthentication);

        options.setTimeOutInMilliSeconds(900000);
        options.setTransportInProtocol(Constants.TRANSPORT_HTTP);

        ConfigurationContext configContext =

                ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null);

        // Blocking invocation
        ServiceClient sender = new ServiceClient(configContext, null);
        sender.setOptions(options);

        OMElement responseElement = sender.sendReceive(payload);
        // log.debug("Client Side response " + responseElement.toString());

        MessageUtil.getInstance()
                .setResponse("URL: " + getPDQServiceName() + "\n" + responseElement.toString());
        return responseElement.toString();

    } catch (AxisFault axisFault) {
        axisFault.printStackTrace();
        if (axisFault.getMessage().indexOf("No route to host") >= 0) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    JOptionPane.showMessageDialog(null,
                            "Unable to make a connection to the remote server,\n this is often a network error, please try again",
                            "Network Error", JOptionPane.INFORMATION_MESSAGE);
                }
            });
        } else if (axisFault.getMessage().indexOf("Read timed out") >= 0) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    JOptionPane.showMessageDialog(null,
                            "Unable to obtain a response from the remote server, this is often a network error, please try again",
                            "Network Error", JOptionPane.INFORMATION_MESSAGE);
                }
            });
        }
        return null;
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}

From source file:org.esa.beam.timeseries.ui.graph.TimeSeriesGraphForm.java

private JPanel createButtonPanel(final String helpID) {
    showTimeSeriesForSelectedPinsButton = ToolButtonFactory
            .createButton(UIUtils.loadImageIcon("icons/SelectedPinSpectra24.gif"), true);
    showTimeSeriesForSelectedPinsButton.addActionListener(new ActionListener() {
        @Override//from  www.j  a  va 2  s . co  m
        public void actionPerformed(ActionEvent e) {
            if (graphModel.isShowingAllPins()) {
                showTimeSeriesForAllPinsButton.setSelected(false);
                graphModel.setIsShowingAllPins(false);
            }
            graphModel.setIsShowingSelectedPins(showTimeSeriesForSelectedPinsButton.isSelected());
        }
    });
    showTimeSeriesForSelectedPinsButton.setName("showTimeSeriesForSelectedPinsButton");
    showTimeSeriesForSelectedPinsButton.setToolTipText("Show time series for selected pin");

    //////////////////////////////////////////

    showTimeSeriesForAllPinsButton = ToolButtonFactory
            .createButton(UIUtils.loadImageIcon("icons/PinSpectra24.gif"), true);
    showTimeSeriesForAllPinsButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (graphModel.isShowingSelectedPins()) {
                showTimeSeriesForSelectedPinsButton.setSelected(false);
                graphModel.setIsShowingSelectedPins(false);
            }
            graphModel.setIsShowingAllPins(showTimeSeriesForAllPinsButton.isSelected());
        }
    });
    showTimeSeriesForAllPinsButton.setName("showTimeSeriesForAllPinsButton");
    showTimeSeriesForAllPinsButton.setToolTipText("Show time series for all pins");

    //////////////////////////////////////////

    showCursorTimeSeriesButton = ToolButtonFactory
            .createButton(UIUtils.loadImageIcon("icons/CursorSpectrum24.gif"), true);
    showCursorTimeSeriesButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            graphModel.setIsShowingCursorTimeSeries(showCursorTimeSeriesButton.isSelected());
        }
    });
    showCursorTimeSeriesButton.setToolTipText("Show time series for cursor");
    showCursorTimeSeriesButton.setSelected(true);

    //////////////////////////////////////////

    exportTimeSeriesButton = ToolButtonFactory.createButton(UIUtils.loadImageIcon("icons/Export24.gif"), false);
    exportTimeSeriesButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            final VisatApp app = VisatApp.getApp();
            final ProductSceneView view = app.getSelectedProductSceneView();

            JOptionPane.showMessageDialog(view, "Not available in the current version.", "Export data",
                    JOptionPane.INFORMATION_MESSAGE);

            //@todo se remove message dialog and fix export that only the visible graph data will be exported
            //                if (view != null
            //                    && view.getProduct() != null
            //                    && view.getProduct().getProductType().equals(AbstractTimeSeries.TIME_SERIES_PRODUCT_TYPE)
            //                    && TimeSeriesMapper.getInstance().getTimeSeries(view.getProduct()) != null) {
            //
            //                    AbstractTimeSeries timeSeries = TimeSeriesMapper.getInstance().getTimeSeries(view.getProduct());
            //                    ExportTimeBasedText.export(mainPanel, timeSeries, helpID);
            //                }
        }
    });
    exportTimeSeriesButton.setToolTipText("Export raster data time series of all pins");
    exportTimeSeriesButton.setName("exportTimeSeriesButton");
    final ProductSceneView sceneView = VisatApp.getApp().getSelectedProductSceneView();
    if (sceneView != null) {
        exportTimeSeriesButton.setEnabled(sceneView.getProduct().getPinGroup().getNodeCount() > 0);
    } else {
        exportTimeSeriesButton.setEnabled(false);
    }

    AbstractButton helpButton = ToolButtonFactory.createButton(UIUtils.loadImageIcon("icons/Help22.png"),
            false);
    helpButton.setToolTipText("Help");

    final TableLayout tableLayout = new TableLayout(1);
    tableLayout.setTablePadding(4, 4);
    tableLayout.setTableAnchor(TableLayout.Anchor.NORTHWEST);
    tableLayout.setTableFill(TableLayout.Fill.HORIZONTAL);
    tableLayout.setTableWeightX(1.0);
    tableLayout.setTableWeightY(0.0);
    JPanel buttonPanel = new JPanel(tableLayout);

    buttonPanel.add(showTimeSeriesForSelectedPinsButton);
    buttonPanel.add(showTimeSeriesForAllPinsButton);
    buttonPanel.add(showCursorTimeSeriesButton);
    buttonPanel.add(exportTimeSeriesButton);
    buttonPanel.add(tableLayout.createVerticalSpacer());
    buttonPanel.add(helpButton);
    if (helpID != null) {
        HelpSys.enableHelpOnButton(helpButton, helpID);
        HelpSys.enableHelpKey(buttonPanel, helpID);
    }
    return buttonPanel;
}

From source file:net.pms.newgui.NetworkTab.java

public JComponent build() {
    FormLayout layout = new FormLayout("left:pref, 2dlu, p, 2dlu , p, 2dlu, p, 2dlu, pref:grow",
            "p, 0dlu, p, 0dlu, p, 3dlu, p, 3dlu, p, 3dlu,p, 3dlu, p, 15dlu, p, 3dlu,p, 3dlu, p,  3dlu, p, 3dlu, p, 3dlu, p,3dlu, p, 3dlu, p, 15dlu, p,3dlu, p, 3dlu, p, 15dlu, p, 3dlu, p");
    PanelBuilder builder = new PanelBuilder(layout);
    builder.setBorder(Borders.DLU4_BORDER);
    builder.setOpaque(true);/*from w  w  w .  jav  a 2 s .  c o m*/

    CellConstraints cc = new CellConstraints();

    smcheckBox = new JCheckBox(Messages.getString("NetworkTab.3"));
    smcheckBox.setContentAreaFilled(false);
    smcheckBox.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            PMS.getConfiguration().setMinimized((e.getStateChange() == ItemEvent.SELECTED));
        }
    });
    if (PMS.getConfiguration().isMinimized()) {
        smcheckBox.setSelected(true);
    }

    JComponent cmp = builder.addSeparator(Messages.getString("NetworkTab.5"), cc.xyw(1, 1, 9));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    builder.addLabel(Messages.getString("NetworkTab.0"), cc.xy(1, 7));
    final KeyedComboBoxModel kcbm = new KeyedComboBoxModel(
            new Object[] { "bg", "ca", "zhs", "zht", "cz", "da", "nl", "en", "fi", "fr", "de", "el", "is", "it",
                    "ja", "no", "pl", "pt", "br", "ro", "ru", "sl", "es", "sv" },
            new Object[] { "Bulgarian", "Catalan", "Chinese (Simplified)", "Chinese (Traditional)", "Czech",
                    "Danish", "Dutch", "English", "Finnish", "French", "German", "Greek", "Icelandic",
                    "Italian", "Japanese", "Norwegian", "Polish", "Portuguese", "Portuguese (Brazilian)",
                    "Romanian", "Russian", "Slovenian", "Spanish", "Swedish" });
    langs = new JComboBox(kcbm);
    langs.setEditable(false);
    //langs.setSelectedIndex(0);
    String defaultLang = null;
    if (configuration.getLanguage() != null && configuration.getLanguage().length() > 0) {
        defaultLang = configuration.getLanguage();
    } else {
        defaultLang = Locale.getDefault().getLanguage();
    }
    if (defaultLang == null) {
        defaultLang = "en";
    }
    kcbm.setSelectedKey(defaultLang);
    if (langs.getSelectedIndex() == -1) {
        langs.setSelectedIndex(0);
    }

    langs.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                configuration.setLanguage((String) kcbm.getSelectedKey());

            }
        }
    });
    builder.add(langs, cc.xyw(3, 7, 7));

    builder.add(smcheckBox, cc.xyw(1, 9, 9));

    JButton service = new JButton(Messages.getString("NetworkTab.4"));
    service.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (PMS.get().installWin32Service()) {
                JOptionPane.showMessageDialog(
                        (JFrame) (SwingUtilities.getWindowAncestor((Component) PMS.get().getFrame())),
                        Messages.getString("NetworkTab.11") + Messages.getString("NetworkTab.12"),
                        "Information", JOptionPane.INFORMATION_MESSAGE);

            } else {
                JOptionPane.showMessageDialog(
                        (JFrame) (SwingUtilities.getWindowAncestor((Component) PMS.get().getFrame())),
                        Messages.getString("NetworkTab.14"), "Error", JOptionPane.ERROR_MESSAGE);
            }
        }
    });
    builder.add(service, cc.xy(1, 11));
    if (System.getProperty(LooksFrame.START_SERVICE) != null || !Platform.isWindows()) {
        service.setEnabled(false);
    }

    host = new JTextField(PMS.getConfiguration().getServerHostname());
    host.addKeyListener(new KeyListener() {

        @Override
        public void keyPressed(KeyEvent e) {
        }

        @Override
        public void keyTyped(KeyEvent e) {
        }

        @Override
        public void keyReleased(KeyEvent e) {
            configuration.setHostname(host.getText());
            PMS.get().getFrame().setReloadable(true);
        }
    });
    // host.setEnabled( StringUtils.isBlank(configuration.getNetworkInterface())) ;
    port = new JTextField(configuration.getServerPort() != 5001 ? "" + configuration.getServerPort() : "");
    port.addKeyListener(new KeyListener() {

        @Override
        public void keyPressed(KeyEvent e) {
        }

        @Override
        public void keyTyped(KeyEvent e) {
        }

        @Override
        public void keyReleased(KeyEvent e) {
            try {
                String p = port.getText();
                if (StringUtils.isEmpty(p)) {
                    p = "5001";
                }
                int ab = Integer.parseInt(p);
                configuration.setServerPort(ab);
                PMS.get().getFrame().setReloadable(true);
            } catch (NumberFormatException nfe) {
            }

        }
    });

    cmp = builder.addSeparator(Messages.getString("NetworkTab.22"), cc.xyw(1, 21, 9));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    ArrayList<String> names = new ArrayList<String>();
    names.add("");
    ArrayList<String> interfaces = new ArrayList<String>();
    interfaces.add("");
    Enumeration<NetworkInterface> enm;
    try {
        enm = NetworkInterface.getNetworkInterfaces();
        while (enm.hasMoreElements()) {
            NetworkInterface ni = enm.nextElement();
            // check for interface has at least one ip address.
            if (ni.getInetAddresses().hasMoreElements()) {
                names.add(ni.getName());
                String displayName = ni.getDisplayName();
                if (displayName == null) {
                    displayName = ni.getName();
                }
                interfaces.add(displayName.trim());
            }
        }
    } catch (SocketException e1) {
        logger.error(null, e1);
    }

    final KeyedComboBoxModel networkInterfaces = new KeyedComboBoxModel(names.toArray(), interfaces.toArray());
    networkinterfacesCBX = new JComboBox(networkInterfaces);
    networkInterfaces.setSelectedKey(configuration.getNetworkInterface());
    networkinterfacesCBX.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                configuration.setNetworkInterface((String) networkInterfaces.getSelectedKey());
                //host.setEnabled( StringUtils.isBlank(configuration.getNetworkInterface())) ;
                PMS.get().getFrame().setReloadable(true);
            }
        }
    });

    ip_filter = new JTextField(PMS.getConfiguration().getIpFilter());
    ip_filter.addKeyListener(new KeyListener() {

        @Override
        public void keyPressed(KeyEvent e) {
        }

        @Override
        public void keyTyped(KeyEvent e) {
        }

        @Override
        public void keyReleased(KeyEvent e) {
            configuration.setIpFilter(ip_filter.getText());
            PMS.get().getFrame().setReloadable(true);
        }
    });

    builder.addLabel(Messages.getString("NetworkTab.20"), cc.xy(1, 23));
    builder.add(networkinterfacesCBX, cc.xyw(3, 23, 7));
    builder.addLabel(Messages.getString("NetworkTab.23"), cc.xy(1, 25));
    builder.add(host, cc.xyw(3, 25, 7));
    builder.addLabel(Messages.getString("NetworkTab.24"), cc.xy(1, 27));
    builder.add(port, cc.xyw(3, 27, 7));
    builder.addLabel(Messages.getString("NetworkTab.30"), cc.xy(1, 29));
    builder.add(ip_filter, cc.xyw(3, 29, 7));

    cmp = builder.addSeparator(Messages.getString("NetworkTab.31"), cc.xyw(1, 31, 9));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    newHTTPEngine = new JCheckBox(Messages.getString("NetworkTab.32"));
    newHTTPEngine.setSelected(PMS.getConfiguration().isHTTPEngineV2());
    newHTTPEngine.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            PMS.getConfiguration().setHTTPEngineV2((e.getStateChange() == ItemEvent.SELECTED));
        }
    });
    builder.add(newHTTPEngine, cc.xyw(1, 33, 9));

    preventSleep = new JCheckBox(Messages.getString("NetworkTab.33"));
    preventSleep.setSelected(PMS.getConfiguration().isPreventsSleep());
    preventSleep.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            PMS.getConfiguration().setPreventsSleep((e.getStateChange() == ItemEvent.SELECTED));
        }
    });
    builder.add(preventSleep, cc.xyw(1, 35, 9));

    cmp = builder.addSeparator(Messages.getString("NetworkTab.34"), cc.xyw(1, 37, 9));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    JPanel panel = builder.getPanel();
    JScrollPane scrollPane = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    return scrollPane;
}

From source file:gov.nih.nci.nbia.StandaloneDMV3.java

public void launch(List<String> seriesList) {
    checkCompatibility();//  w  w w. j av a  2s . c o m
    if ((seriesList == null) || (seriesList.size() <= 0)) {
        JOptionPane.showMessageDialog(null,
                "This version of Download App requires to have at least one series instance UID in manifest file.");
        System.exit(0);
    } else {
        this.seriesList = seriesList;
        if (seriesList.size() > 9999) {
            int result = JOptionPane.showConfirmDialog(null,
                    "The number of series in manifest file exceeds the maximum 9,999 series threshold. Only the first 9,999 series will be downloaded.",
                    "Threshold Exceeded Notification", JOptionPane.OK_CANCEL_OPTION,
                    JOptionPane.INFORMATION_MESSAGE);

            if (result != JOptionPane.OK_OPTION) {
                System.exit(0);
            }
        }

        JFrame f;
        String os = System.getProperty("os.name").toLowerCase();
        if (os.startsWith("mac")) {
            f = showProgressForMac("Loading your data");
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    createMainWin();
                    f.setVisible(false);
                    f.dispose();
                }
            });
        } else {
            f = showProgress("Loading your data");
            createMainWin();
            f.setVisible(false);
            f.dispose();
        }
    }
}

From source file:net.sf.jabref.importer.fetcher.IEEEXploreFetcher.java

@Override
public boolean processQuery(String query, ImportInspector dialog, OutputPrinter status) {
    //IEEE API seems to use .QT. as a marker for the quotes for exact phrase searching
    String terms = query.replaceAll("\"", "\\.QT\\.");

    shouldContinue = true;/*from ww  w  .  j a  v  a2  s . c  om*/
    int parsed = 0;
    int pageNumber = 1;

    String postData = makeSearchPostRequestPayload(pageNumber, terms);

    try {
        //open the search URL
        URLDownload dl = new URLDownload(IEEEXploreFetcher.URL_SEARCH);

        //add request header
        dl.addParameters("Accept", "application/json");
        dl.addParameters("Content-Type", "application/json");

        // set post data
        dl.setPostData(postData);

        //retrieve the search results
        String page = dl.downloadToString(StandardCharsets.UTF_8);

        //the page can be blank if the search did not work (not sure the exact conditions that lead to this, but declaring it an invalid search for now)
        if (page.isEmpty()) {
            status.showMessage(Localization.lang("You have entered an invalid search '%0'.", query),
                    DIALOG_TITLE, JOptionPane.INFORMATION_MESSAGE);
            return false;
        }

        //parses the JSON data returned by the query
        //TODO: a faster way would be to parse the JSON tokens one at a time just to extract the article number, but this seems to be fast enough...
        JSONObject searchResultsJson = new JSONObject(page);
        int hits = searchResultsJson.getInt("totalRecords");

        //if no search results were found
        if (hits == 0) {
            status.showMessage(Localization.lang("No entries found for the search string '%0'", query),
                    DIALOG_TITLE, JOptionPane.INFORMATION_MESSAGE);
            return false;
        }

        //if max hits were exceeded, display the warning
        if (hits > IEEEXploreFetcher.MAX_FETCH) {
            status.showMessage(
                    Localization.lang("%0 entries found. To reduce server load, only %1 will be downloaded.",
                            String.valueOf(hits), String.valueOf(IEEEXploreFetcher.MAX_FETCH)),
                    DIALOG_TITLE, JOptionPane.INFORMATION_MESSAGE);
        }

        //fetch the raw Bibtex results from IEEEXplore
        String bibtexPage = new URLDownload(createBibtexQueryURL(searchResultsJson))
                .downloadToString(Globals.prefs.getDefaultEncoding());

        //preprocess the result (eg. convert HTML escaped characters to latex and do other formatting not performed by BibtexParser)
        bibtexPage = preprocessBibtexResultsPage(bibtexPage);

        //parse the page into Bibtex entries
        Collection<BibEntry> parsedBibtexCollection = BibtexParser.fromString(bibtexPage);
        if (parsedBibtexCollection == null) {
            status.showMessage(Localization.lang("Error while fetching from %0", getTitle()), DIALOG_TITLE,
                    JOptionPane.INFORMATION_MESSAGE);
            return false;
        }
        int nEntries = parsedBibtexCollection.size();
        Iterator<BibEntry> parsedBibtexCollectionIterator = parsedBibtexCollection.iterator();
        while (parsedBibtexCollectionIterator.hasNext() && shouldContinue) {
            dialog.addEntry(cleanup(parsedBibtexCollectionIterator.next()));
            dialog.setProgress(parsed, nEntries);
            parsed++;
        }

        return true;

    } catch (MalformedURLException e) {
        LOGGER.warn("Bad URL", e);
    } catch (ConnectException | UnknownHostException e) {
        status.showMessage(Localization.lang("Could not connect to %0", getTitle()), DIALOG_TITLE,
                JOptionPane.ERROR_MESSAGE);
    } catch (IOException | JSONException e) {
        status.showMessage(e.getMessage(), DIALOG_TITLE, JOptionPane.ERROR_MESSAGE);
        LOGGER.warn("Search IEEEXplore: " + e.getMessage(), e);
    }

    return false;
}

From source file:it.txt.access.capability.demo.soap.client.view.ClientGUIController.java

protected static void showInfoMessage(Component parent, String title, String msg) {
    JOptionPane.showMessageDialog(parent, msg, title, JOptionPane.INFORMATION_MESSAGE);
}

From source file:be.ugent.maf.cellmissy.gui.controller.analysis.doseresponse.area.AreaDRResultsController.java

/**
 * @param pdfFile//from   ww  w .ja v  a  2  s. c om
 */
@Override
protected void tryToCreateFile(File pdfFile) {
    try {
        boolean success = pdfFile.createNewFile();
        if (success) {
            doseResponseController.showMessage("Pdf Report successfully created!", "Report created",
                    JOptionPane.INFORMATION_MESSAGE);
        } else {
            Object[] options = { "Yes", "No", "Cancel" };
            int showOptionDialog = JOptionPane.showOptionDialog(null,
                    "File already exists. Do you want to replace it?", "", JOptionPane.YES_NO_OPTION,
                    JOptionPane.WARNING_MESSAGE, null, options, options[2]);
            // if YES, user wants to delete existing file and replace it
            if (showOptionDialog == 0) {
                boolean delete = pdfFile.delete();
                if (!delete) {
                    return;
                }
                // if NO, returns already existing file
            } else if (showOptionDialog == 1) {
                return;
            }
        }
    } catch (IOException ex) {
        doseResponseController.showMessage("Unexpected error: " + ex.getMessage() + ".", "Unexpected error",
                JOptionPane.ERROR_MESSAGE);
        return;
    }
    try (FileOutputStream fileOutputStream = new FileOutputStream(pdfFile)) {
        // actually create PDF file
        createPdfFile(fileOutputStream);
    } catch (IOException ex) {
        doseResponseController.showMessage("Unexpected error: " + ex.getMessage() + ".", "Unexpected error",
                JOptionPane.ERROR_MESSAGE);
    }
}