Example usage for javax.swing JEditorPane setText

List of usage examples for javax.swing JEditorPane setText

Introduction

In this page you can find the example usage for javax.swing JEditorPane setText.

Prototype

@BeanProperty(bound = false, description = "the text of this component")
public void setText(String t) 

Source Link

Document

Sets the text of this TextComponent to the specified content, which is expected to be in the format of the content type of this editor.

Usage

From source file:org.geworkbench.components.lincs.LincsInterface.java

private void viewLicense_actionPerformed(String FileName) {

    getLicenseFromFile(FileName);/* w  ww .j a  v  a2 s  . co  m*/
    JDialog licenseDialog = new JDialog();
    final JEditorPane jEditorPane = new JEditorPane("text/html", "");
    jEditorPane.getDocument().putProperty("IgnoreCharsetDirective", Boolean.TRUE);
    jEditorPane.setText(licenseContent);
    if (jEditorPane.getCaretPosition() > 1) {
        jEditorPane.setCaretPosition(1);
    }
    JScrollPane scrollPane = new JScrollPane(jEditorPane);
    licenseDialog.setTitle("Lincs Interface License");
    licenseDialog.setContentPane(scrollPane);
    licenseDialog.setSize(400, 300);
    licenseDialog.setLocationRelativeTo(this);
    licenseDialog.setVisible(true);
}

From source file:org.geworkbench.engine.ccm.ComponentConfigurationManagerWindow.java

/**
 * Display a dialog box with a components license in it.
 * // ww w.jav a 2s  .c o  m
 * @param ActionEvent
 * @return void
 */
private void viewLicense_actionPerformed(ActionEvent e) {

    int[] selectedRow = table.getSelectedRows();

    String license = "Select a component in order to view its license.";
    String componentName = null;
    if (selectedRow != null && selectedRow.length > 0 && selectedRow[0] >= 0) {

        int modelRow = table.convertRowIndexToModel(selectedRow[0]);
        license = (String) ccmTableModel.getModelValueAt(modelRow, CCMTableModel.LICENSE_INDEX);
        componentName = (String) ccmTableModel.getModelValueAt(modelRow, CCMTableModel.NAME_INDEX);
    }

    JDialog licenseDialog = new JDialog();
    final JEditorPane jEditorPane = new JEditorPane("text/html", "");
    jEditorPane.getDocument().putProperty("IgnoreCharsetDirective", Boolean.TRUE);
    jEditorPane.setText(license);
    if (jEditorPane.getCaretPosition() > 1) {
        jEditorPane.setCaretPosition(1);
    }
    JScrollPane scrollPane = new JScrollPane(jEditorPane);
    licenseDialog.setTitle(componentName + " License");
    licenseDialog.setContentPane(scrollPane);
    licenseDialog.setSize(400, 300);
    licenseDialog.setLocationRelativeTo(frame);
    licenseDialog.setVisible(true);
}

From source file:org.geworkbench.engine.ccm.ComponentConfigurationManagerWindow2.java

/**
 * Display a dialog box with a components license in it.
 * //w w  w.  j a  va2 s  .  c o  m
 * @param ActionEvent
 * @return void
 */
private void viewLicense_actionPerformed(ActionEvent e) {

    int[] selectedRow = table.getSelectedRows();

    String license = "Select a component in order to view its license.";
    String componentName = null;
    if (selectedRow != null && selectedRow.length > 0 && selectedRow[0] >= 0) {

        int modelRow = table.convertRowIndexToModel(selectedRow[0]);
        license = (String) ccmTableModel.getModelValueAt(modelRow, CCMTableModel2.LICENSE_INDEX);
        componentName = (String) ccmTableModel.getModelValueAt(modelRow, CCMTableModel2.NAME_INDEX);
    }

    JDialog licenseDialog = new JDialog();
    final JEditorPane jEditorPane = new JEditorPane("text/html", "");
    jEditorPane.getDocument().putProperty("IgnoreCharsetDirective", Boolean.TRUE);
    jEditorPane.setText(license);
    if (jEditorPane.getCaretPosition() > 1) {
        jEditorPane.setCaretPosition(1);
    }
    JScrollPane scrollPane = new JScrollPane(jEditorPane);
    licenseDialog.setTitle(componentName + " License");
    licenseDialog.setContentPane(scrollPane);
    licenseDialog.setSize(400, 300);
    licenseDialog.setLocationRelativeTo(frame);
    licenseDialog.setVisible(true);
}

From source file:org.isatools.isacreator.ontologyselectiontool.ViewTermDefinitionUI.java

private JEditorPane createOntologyInformationDisplay(OntologyBranch term) {

    JEditorPane ontologyInfo = new JEditorPane();
    ontologyInfo.setContentType("text/html");
    ontologyInfo.setEditable(false);/* w  w  w .  j av a2  s .c  o m*/
    ontologyInfo.setBackground(UIHelper.BG_COLOR);

    String labelContent = "<html>" + "<head>" + "<style type=\"text/css\">" + "<!--" + ".bodyFont {"
            + "   font-family: Verdana;" + "   font-size: 8.5px;" + "   color: #006838;" + "}" + "-->"
            + "</style>" + "</head>" + "<body class=\"bodyFont\">";

    labelContent += "<b>Term name: </b>" + term.getBranchName() + "</p>";

    // special handling for ChEBI to get the structural image
    System.out.println("Showing CHEBI image for " + term.getBranchIdentifier());
    if (term.getBranchIdentifier().toLowerCase().contains("chebi")) {

        String chebiTermId = term.getBranchIdentifier()
                .substring(term.getBranchIdentifier().lastIndexOf("_") + 1);

        System.out.println("Showing CHEBI image for " + chebiTermId);

        String chebiImageURL = "http://www.ebi.ac.uk/chebi/displayImage.do?defaultImage=true&imageIndex=0&chebiId="
                + chebiTermId;
        labelContent += "<p><b>Chemical structure:</b>" + "<p/>" + "<img src=\"" + chebiImageURL
                + "\" alt=\"chemical structure for " + term.getBranchName()
                + "\" width=\"150\" height=\"150\"/>";

    }

    properties = sortMap(properties);

    if (properties != null && properties.size() > 0) {
        for (String propertyType : properties.keySet()) {
            if (propertyType != null) {

                labelContent += ("<p><b>" + propertyType + ": </b>");
                labelContent += (properties.get(propertyType) == null ? "no definition available"
                        : properties.get(propertyType) + "</font></p>");
            }
        }
    } else {
        labelContent += "<p>No definition found for this term! This can be due to 2 reasons: "
                + "1) Unfortunately, not all terms have their definitions supplied; and 2) the "
                + "ability to view the definitions for a term in this tool is not yet fully supported.</p>";
    }

    labelContent += "</body></html>";

    ontologyInfo.setText(labelContent);

    return ontologyInfo;
}

From source file:org.isatools.isacreator.visualization.AssayInfoPanel.java

private JPanel prepareAssayInformation() {

    assayInformation.removeAll();//from www.  j  a  v a 2  s  .co  m

    JEditorPane currentlyShowingInfo = new JEditorPane();
    currentlyShowingInfo.setContentType("text/html");
    currentlyShowingInfo.setEditable(false);
    currentlyShowingInfo.setBackground(UIHelper.BG_COLOR);
    currentlyShowingInfo.setPreferredSize(new Dimension(width - 10, height - 30));

    Map<String, String> data = getAssayDetails();

    String labelContent = "<html>" + "<head>" + "<style type=\"text/css\">" + "<!--" + ".bodyFont {"
            + "   font-family: Verdana;" + "   font-size: 9px;" + "   color: #006838;" + "}" + "-->"
            + "</style>" + "</head>" + "<body class=\"bodyFont\">";

    for (Object key : data.keySet()) {
        labelContent += ("<p><b>" + ((String) key).trim() + ": </b>");
        labelContent += (data.get(key) + "</font></p>");
    }

    labelContent += "</body></html>";

    currentlyShowingInfo.setText(labelContent);

    assayInformation.add(currentlyShowingInfo);

    return assayInformation;
}

From source file:org.isatools.isacreator.visualization.InvestigationInfoPanel.java

private JPanel prepareInvestigationInformation() {

    investigationInformation.removeAll();

    JEditorPane currentlyShowingInfo = new JEditorPane();
    currentlyShowingInfo.setContentType("text/html");
    currentlyShowingInfo.setEditable(false);
    currentlyShowingInfo.setBackground(UIHelper.BG_COLOR);

    JScrollPane infoScroller = new JScrollPane(currentlyShowingInfo, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    infoScroller.setBackground(UIHelper.BG_COLOR);
    infoScroller.getViewport().setBackground(UIHelper.BG_COLOR);
    infoScroller.setPreferredSize(new Dimension(width - 10, height - 50));
    infoScroller.setBorder(null);/*from  w w w. j a v  a 2s .co  m*/

    IAppWidgetFactory.makeIAppScrollPane(infoScroller);

    Map<String, String> data = getInvestigationDetails();

    String labelContent = "<html>" + "<head>" + "<style type=\"text/css\">" + "<!--" + ".bodyFont {"
            + "   font-family: Verdana;" + "   font-size: 9px;" + "   color: #006838;" + "}" + "-->"
            + "</style>" + "</head>" + "<body class=\"bodyFont\">";

    for (Object key : data.keySet()) {
        labelContent += ("<p><b>" + ((String) key).trim() + ": </b>");
        labelContent += (data.get(key) + "</font></p>");
    }

    labelContent += "</body></html>";

    currentlyShowingInfo.setText(labelContent);

    investigationInformation.add(infoScroller);

    return investigationInformation;
}

From source file:org.isatools.isacreator.visualization.StudyInfoPanel.java

private JPanel prepareStudyInformation() {

    studyInformation.removeAll();/* w  ww.j  av a  2  s  .co  m*/

    JEditorPane currentlyShowingInfo = new JEditorPane();
    currentlyShowingInfo.setContentType("text/html");
    currentlyShowingInfo.setEditable(false);
    currentlyShowingInfo.setBackground(UIHelper.BG_COLOR);
    currentlyShowingInfo.setPreferredSize(new Dimension(width - 10, height - 30));

    JScrollPane infoScroller = new JScrollPane(currentlyShowingInfo, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    infoScroller.setBackground(UIHelper.BG_COLOR);
    infoScroller.getViewport().setBackground(UIHelper.BG_COLOR);
    infoScroller.setPreferredSize(new Dimension(width - 10, height - 50));
    infoScroller.setBorder(null);

    IAppWidgetFactory.makeIAppScrollPane(infoScroller);

    Map<String, String> data = getStudyDetails();

    String labelContent = "<html>" + "<head>" + "<style type=\"text/css\">" + "<!--" + ".bodyFont {"
            + "   font-family: Verdana;" + "   font-size: 9px;" + "   color: #006838;" + "}" + "-->"
            + "</style>" + "</head>" + "<body class=\"bodyFont\">";

    for (Object key : data.keySet()) {
        labelContent += ("<p><b>" + ((String) key).trim() + ": </b>");
        labelContent += (data.get(key) + "</font></p>");
    }

    labelContent += "</body></html>";

    currentlyShowingInfo.setText(labelContent);

    studyInformation.add(infoScroller);

    return studyInformation;
}

From source file:org.jivesoftware.sparkimpl.updater.CheckUpdates.java

public void downloadUpdate(final File downloadedFile, final SparkVersion version) {
    final java.util.Timer timer = new java.util.Timer();

    // Prepare HTTP post
    final GetMethod post = new GetMethod(version.getDownloadURL());

    // Get HTTP client
    Protocol.registerProtocol("https", new Protocol("https", new EasySSLProtocolSocketFactory(), 443));
    final HttpClient httpclient = new HttpClient();
    String proxyHost = System.getProperty("http.proxyHost");
    String proxyPort = System.getProperty("http.proxyPort");
    if (ModelUtil.hasLength(proxyHost) && ModelUtil.hasLength(proxyPort)) {
        try {//from  ww w . j  a v a 2 s .  c o  m
            httpclient.getHostConfiguration().setProxy(proxyHost, Integer.parseInt(proxyPort));
        } catch (NumberFormatException e) {
            Log.error(e);
        }
    }

    // Execute request

    try {
        int result = httpclient.executeMethod(post);
        if (result != 200) {
            return;
        }

        long length = post.getResponseContentLength();
        int contentLength = (int) length;

        bar = new JProgressBar(0, contentLength);
    } catch (IOException e) {
        Log.error(e);
    }

    final JFrame frame = new JFrame(Res.getString("title.downloading.im.client"));

    frame.setIconImage(SparkRes.getImageIcon(SparkRes.SMALL_MESSAGE_IMAGE).getImage());

    titlePanel = new TitlePanel(Res.getString("title.upgrading.client"),
            Res.getString("message.version", version.getVersion()),
            SparkRes.getImageIcon(SparkRes.SEND_FILE_24x24), true);

    final Thread thread = new Thread(new Runnable() {
        public void run() {
            try {
                InputStream stream = post.getResponseBodyAsStream();
                long size = post.getResponseContentLength();
                ByteFormat formater = new ByteFormat();
                sizeText = formater.format(size);
                titlePanel.setDescription(Res.getString("message.version", version.getVersion()) + " \n"
                        + Res.getString("message.file.size", sizeText));

                downloadedFile.getParentFile().mkdirs();

                FileOutputStream out = new FileOutputStream(downloadedFile);
                copy(stream, out);
                out.close();

                if (!cancel) {
                    downloadComplete = true;
                    promptForInstallation(downloadedFile, Res.getString("title.download.complete"),
                            Res.getString("message.restart.spark"));
                } else {
                    out.close();
                    downloadedFile.delete();
                }

                UPDATING = false;
                frame.dispose();
            } catch (Exception ex) {
                // Nothing to do
            } finally {
                timer.cancel();
                // Release current connection to the connection pool once you are done
                post.releaseConnection();
            }
        }
    });

    frame.getContentPane().setLayout(new GridBagLayout());
    frame.getContentPane().add(titlePanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
    frame.getContentPane().add(bar, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));

    JEditorPane pane = new JEditorPane();
    boolean displayContentPane = version.getChangeLogURL() != null || version.getDisplayMessage() != null;

    try {
        pane.setEditable(false);
        if (version.getChangeLogURL() != null) {
            pane.setEditorKit(new HTMLEditorKit());
            pane.setPage(version.getChangeLogURL());
        } else if (version.getDisplayMessage() != null) {
            pane.setText(version.getDisplayMessage());
        }

        if (displayContentPane) {
            frame.getContentPane().add(new JScrollPane(pane), new GridBagConstraints(0, 2, 1, 1, 1.0, 1.0,
                    GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
        }
    } catch (IOException e) {
        Log.error(e);
    }

    frame.getContentPane().setBackground(Color.WHITE);
    frame.pack();
    if (displayContentPane) {
        frame.setSize(600, 400);
    } else {
        frame.setSize(400, 100);
    }
    frame.setLocationRelativeTo(SparkManager.getMainWindow());
    GraphicUtils.centerWindowOnScreen(frame);
    frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent windowEvent) {
            thread.interrupt();
            cancel = true;

            UPDATING = false;

            if (!downloadComplete) {
                JOptionPane.showMessageDialog(SparkManager.getMainWindow(),
                        Res.getString("message.updating.cancelled"), Res.getString("title.cancelled"),
                        JOptionPane.ERROR_MESSAGE);
            }

        }
    });
    frame.setVisible(true);
    thread.start();

    timer.scheduleAtFixedRate(new TimerTask() {
        int seconds = 1;

        public void run() {
            ByteFormat formatter = new ByteFormat();
            long value = bar.getValue();
            long average = value / seconds;
            String text = formatter.format(average) + "/Sec";

            String total = formatter.format(value);
            titlePanel.setDescription(Res.getString("message.version", version.getVersion()) + " \n"
                    + Res.getString("message.file.size", sizeText) + "\n"
                    + Res.getString("message.transfer.rate") + ": " + text + "\n"
                    + Res.getString("message.total.downloaded") + ": " + total);
            seconds++;
        }
    }, 1000, 1000);
}

From source file:org.nuclos.client.dbtransfer.DBTransferImport.java

private PanelWizardStep newStep1(final MainFrameTab ifrm) {
    final SpringLocaleDelegate localeDelegate = getSpringLocaleDelegate();
    final PanelWizardStep step = new PanelWizardStep(
            localeDelegate.getMessage("dbtransfer.import.step1.1", "Konfigurationsdatei"),
            localeDelegate.getMessage("dbtransfer.import.step1.2",
                    "Bitte w\u00e4hlen Sie eine Konfigurationsdatei aus."));

    final JLabel lbFile = new JLabel(localeDelegate.getMessage("dbtransfer.import.step1.3", "Datei"));

    utils.initJPanel(step,/* ww w  .  j a va  2s  .  c  o m*/
            new double[] { TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED,
                    TableLayout.FILL },
            new double[] { 20, TableLayout.PREFERRED, lbFile.getPreferredSize().height, TableLayout.FILL });

    final JButton btnBrowse = new JButton("...");
    //final JProgressBar progressBar = new JProgressBar(0, 230);
    final JCheckBox chbxImportAsNuclon = new JCheckBox(
            localeDelegate.getMessage("configuration.transfer.import.as.nuclon", "Import als Nuclon"));
    chbxImportAsNuclon.setEnabled(false);
    final JEditorPane editWarnings = new JEditorPane();
    editWarnings.setContentType("text/html");
    editWarnings.setEditable(false);
    editWarnings.setBackground(Color.WHITE);

    final JScrollPane scrollWarn = new JScrollPane(editWarnings);
    scrollWarn.setPreferredSize(new Dimension(680, 250));
    scrollWarn.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    scrollWarn.getVerticalScrollBar().setUnitIncrement(20);
    scrollWarn.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrollWarn.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    final JScrollPane scrollPrev = new JScrollPane(jpnPreviewContent);
    scrollPrev.setPreferredSize(new Dimension(680, 250));
    scrollPrev.setBorder(new LineBorder(Color.LIGHT_GRAY, 1));
    scrollPrev.getVerticalScrollBar().setUnitIncrement(20);
    scrollPrev.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrollPrev.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    final JPanel jpnPreview = new JPanel(new BorderLayout());
    jpnPreview.add(jpnPreviewHeader, BorderLayout.NORTH);
    jpnPreview.add(scrollPrev, BorderLayout.CENTER);
    jpnPreview.add(jpnPreviewFooter, BorderLayout.SOUTH);
    jpnPreview.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    jpnPreview.setBackground(Color.WHITE);
    jpnPreviewHeader.setBackground(Color.WHITE);
    jpnPreviewContent.setBackground(Color.WHITE);
    jpnPreviewFooter.setBackground(Color.WHITE);

    final JTabbedPane tabbedPane = new JTabbedPane();
    tabbedPane.addTab(localeDelegate.getMessage("configuration.transfer.prepare.warnings.tab", "Warnungen"),
            scrollWarn);
    final String sDefaultPreparePreviewTabText = localeDelegate
            .getMessage("configuration.transfer.prepare.preview.tab", "Vorschau der Schema Aenderungen");
    tabbedPane.addTab(sDefaultPreparePreviewTabText, jpnPreview);

    final JLabel lbNewUser = new JLabel();

    step.add(lbFile, "0,0");
    step.add(tfTransferFile, "1,0");
    step.add(btnBrowse, "2,0");
    step.add(chbxImportAsNuclon, "1,1");//step.add(progressBar, "1,1");
    step.add(lbNewUser, "0,2,3,2");
    step.add(tabbedPane, "0,3,3,3");

    tfTransferFile.setEditable(false);

    final ActionListener prepareImportAction = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ev) {
            ifrm.lockLayerWithProgress(Transfer.TOPIC_CORRELATIONID_PREPARE);

            Thread t = new Thread() {
                @Override
                public void run() {
                    step.setComplete(false);
                    boolean blnTransferWithWarnings = false;
                    //progressBar.setValue(0);
                    //progressBar.setVisible(true);
                    try {
                        String fileName = tfTransferFile.getText();
                        if (StringUtils.isNullOrEmpty(fileName)) {
                            return;
                        }
                        File f = new File(fileName);
                        long size = f.length();

                        final InputStream fin = new BufferedInputStream(new FileInputStream(f));
                        final byte[] transferFile;
                        try {
                            transferFile = utils.getBytes(fin, (int) size);
                        } finally {
                            fin.close();
                        }

                        resetStep2();
                        importTransferObject = getTransferFacadeRemote().prepareTransfer(isNuclon,
                                transferFile);
                        chbxImportAsNuclon.setEnabled(importTransferObject.getTransferOptions()
                                .containsKey(TransferOption.IS_NUCLON_IMPORT_ALLOWED));

                        step.setComplete(!importTransferObject.result.hasCriticals());

                        if (!importTransferObject.result.hasCriticals()
                                && !importTransferObject.result.hasWarnings()) {
                            editWarnings.setText(localeDelegate.getMessage(
                                    "configuration.transfer.prepare.no.warnings", "Keine Warnungen"));
                        } else {
                            editWarnings.setText("<html><body><font color=\"#800000\">"
                                    + importTransferObject.result.getCriticals() + "</font>"
                                    + (importTransferObject.result.hasCriticals() ? "<br />" : "")
                                    + importTransferObject.result.getWarnings() + "</body></html>");
                        }

                        int iPreviewSize = importTransferObject.getPreviewParts().size();
                        blnTransferWithWarnings = setupPreviewPanel(importTransferObject.getPreviewParts());
                        tabbedPane.setTitleAt(1, sDefaultPreparePreviewTabText
                                + (iPreviewSize == 0 ? "" : " (" + iPreviewSize + ")"));
                        lbNewUser.setText(
                                "Neue Benutzer" + ": " + (importTransferObject.getNewUserCount() == 0 ? "keine"
                                        : importTransferObject.getNewUserCount()));
                    } catch (Exception e) {
                        //                              progressBar.setVisible(false);
                        Errors.getInstance().showExceptionDialog(ifrm, e);
                    } finally {
                        btnBrowse.setEnabled(true);
                        //                              progressBar.setVisible(false);
                        ifrm.unlockLayer();
                    }
                    if (blnTransferWithWarnings) {
                        JOptionPane.showMessageDialog(jpnPreviewContent, localeDelegate.getMessage(
                                "dbtransfer.import.step1.19",
                                "Nicht alle Statements knnen durchgefhrt werden!\nBitte kontrollieren Sie die mit rot markierten Eintrge!",
                                "Warning", JOptionPane.WARNING_MESSAGE));
                    }
                }

            };

            t.start();
        }
    };
    final ActionListener browseAction = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ev) {
            final JFileChooser filechooser = utils.getFileChooser(
                    localeDelegate.getMessage("configuration.transfer.file.nuclet", "Nuclet-Dateien"),
                    ".nuclet");
            final int iBtn = filechooser.showOpenDialog(ifrm);

            if (iBtn == JFileChooser.APPROVE_OPTION) {

                final File file = filechooser.getSelectedFile();
                if (file != null) {
                    tfTransferFile.setText("");
                    btnBrowse.setEnabled(false);
                    //progressBar.setVisible(true);

                    String fileName = file.getPath();
                    if (StringUtils.isNullOrEmpty(fileName)) {
                        return;
                    }

                    tfTransferFile.setText(fileName);

                    prepareImportAction.actionPerformed(new ActionEvent(this, 0, "prepare"));
                }
            }
        }
    };
    final ActionListener importAsNuclonAction = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            isNuclon = chbxImportAsNuclon.isSelected();
            prepareImportAction.actionPerformed(new ActionEvent(this, 0, "prepare"));
        }
    };
    btnBrowse.addActionListener(browseAction);
    chbxImportAsNuclon.addActionListener(importAsNuclonAction);

    //      progressBar.setVisible(false);

    return step;
}

From source file:org.nuclos.client.dbtransfer.DBTransferImport.java

private PanelWizardStep newStep5(final MainFrameTab ifrm) {
    final SpringLocaleDelegate localeDelegate = getSpringLocaleDelegate();
    final JLabel lbResult = new JLabel();
    final JEditorPane editLog = new JEditorPane();
    final JScrollPane scrollLog = new JScrollPane(editLog);
    final JLabel lbStructureChangeResult = new JLabel(
            localeDelegate.getMessage("dbtransfer.import.step5.1", "\u00c4nderungen am Datenbankschema"));
    final JButton btnSaveStructureChangeScript = new JButton(
            localeDelegate.getMessage("dbtransfer.import.step5.2", "Script speichern") + "...");
    final JButton btnSaveStructureChangeLog = new JButton(
            localeDelegate.getMessage("dbtransfer.import.step5.3", "Log speichern") + "...");

    editLog.setContentType("text/html");
    editLog.setEditable(false);//from  w  w w . ja  va  2  s. co  m

    final PanelWizardStep step = new PanelWizardStep(
            localeDelegate.getMessage("dbtransfer.import.step5.4", "Ergebnis"), localeDelegate.getMessage(
                    "dbtransfer.import.step5.5", "Hier wird Ihnen das Ergebnis des Imports angezeigt.")) {

        @Override
        public void prepare() {
            if (!importTransferResult.hasWarnings() && !importTransferResult.hasCriticals()) {
                lbResult.setText(localeDelegate.getMessage("dbtransfer.import.step5.6", "Import erfolgreich!"));
                this.setComplete(true);
            } else {
                lbResult.setText(
                        localeDelegate.getMessage("dbtransfer.import.step5.7", "Ein Problem ist aufgetreten!"));
                blnSaveOfLogRecommend = true;
            }
            StringBuffer sbLog = new StringBuffer();
            sbLog.append("<html><body>");
            if (!importTransferResult.foundReferences.isEmpty()) {
                sbLog.append(localeDelegate.getMessage("dbtransfer.import.step5.8",
                        "Folgende Konfigurationsobjekte sollten entfernt werden, werden aber noch verwendet")
                        + ":<br />");
                for (Pair<String, String> reference : importTransferResult.foundReferences) {
                    sbLog.append(
                            "- " + reference.y + " ("
                                    + localeDelegate.getLabelFromMetaDataVO(
                                            MetaDataClientProvider.getInstance().getEntity(reference.x))
                                    + ")<br />");
                }
                sbLog.append("<br />" + localeDelegate.getMessage("dbtransfer.import.step5.9",
                        "Passen Sie Ihre Konfiguration dahingehend an oder bearbeiten Sie die Daten,\nwelche noch auf die Konfigurationsobjekte verweisen."));
                sbLog.append("<br />");
            }
            sbLog.append("<font color=\"#800000\">" + importTransferObject.result.getCriticals() + "</font>"
                    + (importTransferObject.result.hasCriticals() ? "<br />" : ""));
            sbLog.append(importTransferResult.getWarnings());
            sbLog.append("</body></html>");
            editLog.setText(sbLog.toString());
        }
    };

    utils.initJPanel(step, new double[] { TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED,
            TableLayout.FILL }, new double[] { 20, TableLayout.FILL, TableLayout.PREFERRED });

    step.add(lbResult, "0,0,3,0");
    step.add(scrollLog, "0,1,3,1");
    step.add(lbStructureChangeResult, "0,2");
    step.add(btnSaveStructureChangeScript, "1,2");
    step.add(btnSaveStructureChangeLog, "2,2");

    btnSaveStructureChangeScript.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            try {
                UIUtils.showWaitCursorForFrame(ifrm, true);

                final StringBuffer sbSql = new StringBuffer();
                org.apache.commons.collections.CollectionUtils.forAllDo(importTransferResult.script,
                        new Closure() {
                            @Override
                            public void execute(Object element) {
                                sbSql.append("<DDL>" + element + "</DDL>\n\n");
                            }
                        });

                final JFileChooser filechooser = utils.getFileChooser(
                        localeDelegate.getMessage("configuration.transfer.file.sql", "SQL-Dateien"),
                        ".import-sql.txt");
                filechooser.setSelectedFile(new File(tfTransferFile.getText() + ".import-sql.txt"));
                final int iBtn = filechooser.showSaveDialog(step);

                if (iBtn == JFileChooser.APPROVE_OPTION) {
                    final File file = filechooser.getSelectedFile();
                    if (file != null) {
                        String fileName = file.getPath();

                        if (!fileName.toLowerCase().endsWith(".import-sql.txt")) {
                            fileName += ".import-sql.txt";
                        }

                        File outFile = new File(fileName);
                        final Writer out = new BufferedWriter(new FileWriter(outFile));
                        try {
                            out.write(sbSql.toString());
                        } finally {
                            out.close();
                        }
                        if (blnSaveOfScriptRecommend) {
                            step.setComplete(true);
                        }
                    }
                }
            } catch (Exception e) {
                Errors.getInstance().showExceptionDialog(ifrm, e);
            } finally {
                UIUtils.showWaitCursorForFrame(ifrm, false);
            }
        }
    });
    btnSaveStructureChangeLog.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            try {
                UIUtils.showWaitCursorForFrame(ifrm, true);

                final JFileChooser filechooser = utils.getFileChooser(
                        localeDelegate.getMessage("configuration.transfer.file.log", "Log-Dateien"),
                        ".import-log.html");
                filechooser.setSelectedFile(new File(tfTransferFile.getText() + ".import-log.html"));
                final int iBtn = filechooser.showSaveDialog(step);

                if (iBtn == JFileChooser.APPROVE_OPTION) {
                    final File file = filechooser.getSelectedFile();
                    if (file != null) {
                        String fileName = file.getPath();

                        if (!fileName.toLowerCase().endsWith(".import-log.html")) {
                            fileName += ".import-log.html";
                        }

                        File outFile = new File(fileName);
                        final Writer out = new BufferedWriter(new FileWriter(outFile));
                        try {
                            out.write(editLog.getText());
                        } finally {
                            out.close();
                        }
                        if (blnSaveOfLogRecommend) {
                            step.setComplete(true);
                        }
                    }
                }
            } catch (Exception e) {
                Errors.getInstance().showExceptionDialog(ifrm, e);
            } finally {
                UIUtils.showWaitCursorForFrame(ifrm, false);
            }
        }
    });

    return step;
}