Search in sources :

Example 36 with JEditorPane

use of javax.swing.JEditorPane in project libgdx by libgdx.

the class GdxSetupUI method generate.

void generate() {
    final String name = ui.form.nameText.getText().trim();
    if (name.length() == 0) {
        JOptionPane.showMessageDialog(this, "Please enter a project name.");
        return;
    }
    final String pack = ui.form.packageText.getText().trim();
    if (pack.length() == 0) {
        JOptionPane.showMessageDialog(this, "Please enter a package name.");
        return;
    }
    Pattern pattern = Pattern.compile("[a-z][a-z0-9_]*(\\.[a-z0-9_]+)+[0-9a-z_]");
    Matcher matcher = pattern.matcher(pack);
    boolean matches = matcher.matches();
    if (!matches) {
        JOptionPane.showMessageDialog(this, "Invalid package name");
        return;
    }
    final String clazz = ui.form.gameClassText.getText().trim();
    if (clazz.length() == 0) {
        JOptionPane.showMessageDialog(this, "Please enter a game class name.");
        return;
    }
    final String destination = ui.form.destinationText.getText().trim();
    if (destination.length() == 0) {
        JOptionPane.showMessageDialog(this, "Please enter a destination directory.");
        return;
    }
    final String sdkLocation = ui.form.sdkLocationText.getText().trim();
    if (sdkLocation.length() == 0 && modules.contains(ProjectType.ANDROID)) {
        JOptionPane.showMessageDialog(this, "Please enter your Android SDK's path");
        return;
    }
    if (!GdxSetup.isSdkLocationValid(sdkLocation) && modules.contains(ProjectType.ANDROID)) {
        JOptionPane.showMessageDialog(this, "Your Android SDK path doesn't contain an SDK! Please install the Android SDK, including all platforms and build tools!");
        return;
    }
    if (modules.contains(ProjectType.ANDROID)) {
        if (!GdxSetup.isSdkUpToDate(sdkLocation)) {
            File sdkLocationFile = new File(sdkLocation);
            try {
                //give them a poke in the right direction
                if (System.getProperty("os.name").contains("Windows")) {
                    String replaced = sdkLocation.replace("\\", "\\\\");
                    Runtime.getRuntime().exec("\"" + replaced + "\\SDK Manager.exe\"");
                } else {
                    File sdkManager = new File(sdkLocation, "tools/android");
                    Runtime.getRuntime().exec(new String[] { sdkManager.getAbsolutePath(), "sdk" });
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
            return;
        }
    }
    if (!GdxSetup.isEmptyDirectory(destination)) {
        int value = JOptionPane.showConfirmDialog(this, "The destination is not empty, do you want to overwrite?", "Warning!", JOptionPane.YES_NO_OPTION);
        if (value != 0) {
            return;
        }
    }
    List<String> incompatList = builder.buildProject(modules, dependencies);
    if (incompatList.size() == 0) {
        try {
            builder.build();
        } catch (IOException e) {
            e.printStackTrace();
        }
    } else {
        JPanel panel = new JPanel();
        panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
        for (String subIncompat : incompatList) {
            JLabel label = new JLabel(subIncompat);
            label.setAlignmentX(Component.CENTER_ALIGNMENT);
            panel.add(label);
        }
        JLabel infoLabel = new JLabel("<html><br><br>The project can be generated, but you wont be able to use these extensions in the respective sub modules<br>Please see the link to learn about extensions</html>");
        infoLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
        panel.add(infoLabel);
        JEditorPane pane = new JEditorPane("text/html", "<a href=\"https://github.com/libgdx/libgdx/wiki/Dependency-management-with-Gradle\">Dependency Management</a>");
        pane.addHyperlinkListener(new HyperlinkListener() {

            @Override
            public void hyperlinkUpdate(HyperlinkEvent e) {
                if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED))
                    try {
                        Desktop.getDesktop().browse(new URI(e.getURL().toString()));
                    } catch (IOException e1) {
                        e1.printStackTrace();
                    } catch (URISyntaxException e1) {
                        e1.printStackTrace();
                    }
            }
        });
        pane.setEditable(false);
        pane.setOpaque(false);
        pane.setAlignmentX(Component.CENTER_ALIGNMENT);
        panel.add(pane);
        Object[] options = { "Yes, build it!", "No, I'll change my extensions" };
        int value = JOptionPane.showOptionDialog(null, panel, "Extension Incompatibilities", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, null);
        if (value != 0) {
            return;
        } else {
            try {
                builder.build();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
    ui.generateButton.setEnabled(false);
    new Thread() {

        public void run() {
            log("Generating app in " + destination);
            new GdxSetup().build(builder, destination, name, pack, clazz, sdkLocation, new CharCallback() {

                @Override
                public void character(char c) {
                    log(c);
                }
            }, ui.settings.getGradleArgs());
            log("Done!");
            if (ui.settings.getGradleArgs().contains("eclipse") || ui.settings.getGradleArgs().contains("idea")) {
                log("To import in Eclipse: File -> Import -> General -> Existing Projects into Workspace");
                log("To import to Intellij IDEA: File -> Open -> YourProject.ipr");
            } else {
                log("To import in Eclipse: File -> Import -> Gradle -> Gradle Project");
                log("To import to Intellij IDEA: File -> Open -> build.gradle");
                log("To import to NetBeans: File -> Open Project...");
            }
            SwingUtilities.invokeLater(new Runnable() {

                @Override
                public void run() {
                    ui.generateButton.setEnabled(true);
                }
            });
        }
    }.start();
}
Also used : Pattern(java.util.regex.Pattern) JPanel(javax.swing.JPanel) HyperlinkEvent(javax.swing.event.HyperlinkEvent) Matcher(java.util.regex.Matcher) BoxLayout(javax.swing.BoxLayout) JLabel(javax.swing.JLabel) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) Point(java.awt.Point) CharCallback(com.badlogic.gdx.setup.Executor.CharCallback) HyperlinkListener(javax.swing.event.HyperlinkListener) JEditorPane(javax.swing.JEditorPane) File(java.io.File)

Example 37 with JEditorPane

use of javax.swing.JEditorPane in project sonarqube by SonarSource.

the class ScannerReportViewerApp method initialize.

/**
   * Initialize the contents of the frame.
   */
private void initialize() {
    try {
        for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }
    } catch (Exception e) {
    // If Nimbus is not available, you can set the GUI to another look and feel.
    }
    frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    splitPane = new JSplitPane();
    frame.getContentPane().add(splitPane, BorderLayout.CENTER);
    tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    tabbedPane.setPreferredSize(new Dimension(500, 7));
    splitPane.setRightComponent(tabbedPane);
    componentDetailsTab = new JScrollPane();
    tabbedPane.addTab("Component details", null, componentDetailsTab, null);
    componentEditor = new JEditorPane();
    componentDetailsTab.setViewportView(componentEditor);
    sourceTab = new JScrollPane();
    tabbedPane.addTab("Source", null, sourceTab, null);
    sourceEditor = createSourceEditor();
    sourceEditor.setEditable(false);
    sourceTab.setViewportView(sourceEditor);
    textLineNumber = createTextLineNumber();
    sourceTab.setRowHeaderView(textLineNumber);
    highlightingTab = new JScrollPane();
    tabbedPane.addTab("Highlighting", null, highlightingTab, null);
    highlightingEditor = new JEditorPane();
    highlightingTab.setViewportView(highlightingEditor);
    symbolTab = new JScrollPane();
    tabbedPane.addTab("Symbol references", null, symbolTab, null);
    symbolEditor = new JEditorPane();
    symbolTab.setViewportView(symbolEditor);
    coverageTab = new JScrollPane();
    tabbedPane.addTab("Coverage", null, coverageTab, null);
    coverageEditor = new JEditorPane();
    coverageTab.setViewportView(coverageEditor);
    duplicationTab = new JScrollPane();
    tabbedPane.addTab("Duplications", null, duplicationTab, null);
    duplicationEditor = new JEditorPane();
    duplicationTab.setViewportView(duplicationEditor);
    testsTab = new JScrollPane();
    tabbedPane.addTab("Tests", null, testsTab, null);
    testsEditor = new JEditorPane();
    testsTab.setViewportView(testsEditor);
    issuesTab = new JScrollPane();
    tabbedPane.addTab("Issues", null, issuesTab, null);
    issuesEditor = new JEditorPane();
    issuesTab.setViewportView(issuesEditor);
    measuresTab = new JScrollPane();
    tabbedPane.addTab("Measures", null, measuresTab, null);
    measuresEditor = new JEditorPane();
    measuresTab.setViewportView(measuresEditor);
    scmTab = new JScrollPane();
    tabbedPane.addTab("SCM", null, scmTab, null);
    scmEditor = new JEditorPane();
    scmTab.setViewportView(scmEditor);
    treeScrollPane = new JScrollPane();
    treeScrollPane.setPreferredSize(new Dimension(200, 400));
    splitPane.setLeftComponent(treeScrollPane);
    componentTree = new JTree();
    componentTree.setModel(new DefaultTreeModel(new DefaultMutableTreeNode("empty") {

        {
        }
    }));
    treeScrollPane.setViewportView(componentTree);
    componentTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    componentTree.addTreeSelectionListener(new TreeSelectionListener() {

        @Override
        public void valueChanged(TreeSelectionEvent e) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) componentTree.getLastSelectedPathComponent();
            if (node == null) {
                // Nothing is selected.
                return;
            }
            frame.setCursor(new Cursor(Cursor.WAIT_CURSOR));
            updateDetails((Component) node.getUserObject());
            frame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        }
    });
    frame.pack();
}
Also used : JScrollPane(javax.swing.JScrollPane) LookAndFeelInfo(javax.swing.UIManager.LookAndFeelInfo) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) JTabbedPane(javax.swing.JTabbedPane) TreeSelectionListener(javax.swing.event.TreeSelectionListener) Dimension(java.awt.Dimension) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) Cursor(java.awt.Cursor) IOException(java.io.IOException) JTree(javax.swing.JTree) JFrame(javax.swing.JFrame) JEditorPane(javax.swing.JEditorPane) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent) JSplitPane(javax.swing.JSplitPane) Component(org.sonar.scanner.protocol.output.ScannerReport.Component)

Example 38 with JEditorPane

use of javax.swing.JEditorPane in project ACS by ACS-Community.

the class ErrorTreeCellRenderer method getXmlEditorPane.

/**
	 * This method initializes jEditorPane	
	 * 	
	 * @return javax.swing.JEditorPane	
	 */
private JEditorPane getXmlEditorPane() {
    if (xmlEditorPane == null) {
        xmlEditorPane = new JEditorPane();
        xmlEditorPane.setContentType("text/plain");
        xmlEditorPane.setEditable(false);
    }
    return xmlEditorPane;
}
Also used : JEditorPane(javax.swing.JEditorPane)

Example 39 with JEditorPane

use of javax.swing.JEditorPane in project ACS by ACS-Community.

the class CommandCenterGui method showUrlContent.

public void showUrlContent(URL url, String title) {
    if (dialog == null) {
        dialog = new JDialog(frame);
        dialog.setSize(600, 400);
        editor = new JEditorPane();
        editor.setEditable(false);
        JScrollPane scroll = new JScrollPane(editor);
        dialog.getContentPane().add(scroll);
        dialog.setLocationRelativeTo(frame);
    }
    try {
        editor.setPage(url);
        dialog.setTitle(title + "  -  " + url);
        dialog.setVisible(true);
    } catch (Exception exc) {
        ErrorBox.showMessageDialog(frame, "Cannot show the resource: " + exc, true);
    }
}
Also used : JScrollPane(javax.swing.JScrollPane) JEditorPane(javax.swing.JEditorPane) JDialog(javax.swing.JDialog) PropertyVetoException(java.beans.PropertyVetoException) UnresolvableException(alma.acs.commandcenter.util.VariableString.UnresolvableException)

Example 40 with JEditorPane

use of javax.swing.JEditorPane in project pcgen by PCGen.

the class CastSpell method setSpellModel.

/**
	 * <p>
	 * Sets the spell model for the dialog.  Although the dialog
	 * functions fine without this, setting the spell model turns on
	 * some additional capabilities.
	 * </p>
	 *
	 * @param model A non-null spell model.
	 */
public void setSpellModel(SpellModel model) {
    StringBuilder text = new StringBuilder();
    if (descPanel.getComponents().length == 0) {
        descText = new JEditorPane("text/html", "<html></html>");
        descScroll = new JScrollPane(descText);
        descPanel.add(descScroll, BorderLayout.CENTER);
    }
    descText.setBackground(getContentPane().getBackground());
    text.append("<html><body><font size='-2'>");
    text.append("<b>Duration: </b>" + model.getDuration() + ' ');
    text.append("<b>Range: </b>" + model.getRange() + ' ');
    text.append("<b>Save: </b>" + model.getSaveInfo() + ' ');
    text.append("<b>Cast: </b>" + model.getCastingTime() + ' ');
    text.append("<b>Target/Area: </b>" + model.getTarget() + ' ');
    text.append("<b>Desc: </b>" + model.getDesc() + ' ');
    text.append("</font></body></html>");
    descText.setText(text.toString());
    descPanel.setPreferredSize(new Dimension(mainPanel.getWidth() - 16, 75));
    descPanel.setMaximumSize(new Dimension(mainPanel.getWidth() - 16, 75));
    descPanel.setMinimumSize(new Dimension(mainPanel.getWidth() - 16, 75));
    pack();
    tEffect.setText(model.getDesc());
}
Also used : JScrollPane(javax.swing.JScrollPane) JEditorPane(javax.swing.JEditorPane) Dimension(java.awt.Dimension)

Aggregations

JEditorPane (javax.swing.JEditorPane)60 JScrollPane (javax.swing.JScrollPane)22 Dimension (java.awt.Dimension)12 JPanel (javax.swing.JPanel)12 IOException (java.io.IOException)11 JButton (javax.swing.JButton)11 JLabel (javax.swing.JLabel)11 JFrame (javax.swing.JFrame)10 GridBagLayout (java.awt.GridBagLayout)9 GridBagConstraints (java.awt.GridBagConstraints)8 JDialog (javax.swing.JDialog)7 HyperlinkEvent (javax.swing.event.HyperlinkEvent)6 BorderLayout (java.awt.BorderLayout)5 JTextField (javax.swing.JTextField)5 HyperlinkListener (javax.swing.event.HyperlinkListener)5 StyledEditorKit (javax.swing.text.StyledEditorKit)5 JCheckBox (javax.swing.JCheckBox)4 JSplitPane (javax.swing.JSplitPane)4 JTree (javax.swing.JTree)4 Component (java.awt.Component)3