public void showItem() {

    if (!this.editorPanel.getViewer().isLanguageFunctionAvailable()) {

      return;
    }

    this.highlight =
        this.editorPanel
            .getEditor()
            .addHighlight(this.position, this.position + this.word.length(), null, true);

    final FindSynonymsActionHandler _this = this;

    QTextEditor editor = this.editorPanel.getEditor();

    Rectangle r = null;

    try {

      r = editor.modelToView(this.position);

    } catch (Exception e) {

      // BadLocationException!
      Environment.logError("Location: " + this.position + " is not valid", e);

      UIUtils.showErrorMessage(this.editorPanel, "Unable to display synonyms.");

      return;
    }

    int y = r.y;

    // Show a panel of all the items.
    final QPopup p = this.popup;

    p.setOpaque(false);

    Synonyms syns = null;

    try {

      syns = this.projectViewer.getSynonymProvider().getSynonyms(this.word);

    } catch (Exception e) {

      UIUtils.showErrorMessage(this.editorPanel, "Unable to display synonyms.");

      Environment.logError("Unable to lookup synonyms for: " + word, e);

      return;
    }

    if ((syns.words.size() == 0) && (this.word.toLowerCase().endsWith("ed"))) {

      // Trim off the ed and try again.
      try {

        syns = this.projectViewer.getSynonyms(this.word.substring(0, this.word.length() - 2));

      } catch (Exception e) {

        UIUtils.showErrorMessage(this.editorPanel, "Unable to display synonyms.");

        Environment.logError("Unable to lookup synonyms for: " + word, e);

        return;
      }
    }

    if ((syns.words.size() == 0) && (this.word.toLowerCase().endsWith("s"))) {

      // Trim off the ed and try again.
      try {

        syns = this.projectViewer.getSynonyms(this.word.substring(0, this.word.length() - 1));

      } catch (Exception e) {

        UIUtils.showErrorMessage(this.editorPanel, "Unable to display synonyms.");

        Environment.logError("Unable to lookup synonyms for: " + word, e);

        return;
      }
    }

    StringBuilder sb = new StringBuilder();

    if (syns.words.size() > 0) {

      sb.append("6px");

      for (int i = 0; i < syns.words.size(); i++) {

        if (sb.length() > 0) {

          sb.append(", ");
        }

        sb.append("p, 3px, [p,90px], 5px");
      }
      /*
                if (syns.words.size () > 0)
                {

                    sb.append (",5px");

                }
      */
    } else {

      sb.append("6px, p, 6px");
    }

    FormLayout summOnly = new FormLayout("3px, fill:380px:grow, 3px", sb.toString());
    PanelBuilder pb = new PanelBuilder(summOnly);

    CellConstraints cc = new CellConstraints();

    int ind = 2;

    Map<String, String> names = new HashMap();
    names.put(Synonyms.ADJECTIVE + "", "Adjectives");
    names.put(Synonyms.NOUN + "", "Nouns");
    names.put(Synonyms.VERB + "", "Verbs");
    names.put(Synonyms.ADVERB + "", "Adverbs");
    names.put(Synonyms.OTHER + "", "Other");

    if (syns.words.size() == 0) {

      JLabel l = new JLabel("No synonyms found.");
      l.setFont(l.getFont().deriveFont(Font.ITALIC));

      pb.add(l, cc.xy(2, 2));
    }

    // Determine what type of word we are looking for.
    for (Synonyms.Part i : syns.words) {

      JLabel l = new JLabel(names.get(i.type + ""));

      l.setFont(l.getFont().deriveFont(Font.ITALIC));
      l.setFont(l.getFont().deriveFont((float) UIUtils.getEditorFontSize(10)));
      l.setBorder(
          new CompoundBorder(
              new MatteBorder(0, 0, 1, 0, Environment.getBorderColor()),
              new EmptyBorder(0, 0, 3, 0)));

      pb.add(l, cc.xy(2, ind));

      ind += 2;

      HTMLEditorKit kit = new HTMLEditorKit();
      HTMLDocument doc = (HTMLDocument) kit.createDefaultDocument();

      JTextPane t = new JTextPane(doc);
      t.setEditorKit(kit);
      t.setEditable(false);
      t.setOpaque(false);

      StringBuilder buf =
          new StringBuilder(
              "<style>a { text-decoration: none; } a:hover { text-decoration: underline; }</style><span style='color: #000000; font-size: "
                  + ((int) UIUtils.getEditorFontSize(10) /*t.getFont ().getSize () + 2*/)
                  + "pt; font-family: "
                  + t.getFont().getFontName()
                  + ";'>");

      for (int x = 0; x < i.words.size(); x++) {

        String w = (String) i.words.get(x);

        buf.append("<a class='x' href='http://" + w + "'>" + w + "</a>");

        if (x < (i.words.size() - 1)) {

          buf.append(", ");
        }
      }

      buf.append("</span>");

      t.setText(buf.toString());

      t.addHyperlinkListener(
          new HyperlinkAdapter() {

            public void hyperlinkUpdate(HyperlinkEvent ev) {

              if (ev.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {

                QTextEditor ed = _this.editorPanel.getEditor();

                ed.replaceText(
                    _this.position, _this.position + _this.word.length(), ev.getURL().getHost());

                ed.removeHighlight(_this.highlight);

                _this.popup.setVisible(false);

                _this.projectViewer.fireProjectEvent(
                    ProjectEvent.SYNONYM, ProjectEvent.REPLACE, ev.getURL().getHost());
              }
            }
          });

      // Annoying that we have to do this but it prevents the text from being too small.

      t.setSize(new Dimension(380, Short.MAX_VALUE));

      JScrollPane sp = new JScrollPane(t);

      t.setCaretPosition(0);

      sp.setOpaque(false);
      sp.getVerticalScrollBar().setValue(0);
      /*
                  sp.setPreferredSize (t.getPreferredSize ());
                  sp.setMaximumSize (new Dimension (380,
                                                    75));
      */
      sp.getViewport().setOpaque(false);
      sp.setOpaque(false);
      sp.setBorder(null);
      sp.getViewport().setBackground(Color.WHITE);
      sp.setAlignmentX(Component.LEFT_ALIGNMENT);

      pb.add(sp, cc.xy(2, ind));

      ind += 2;
    }

    JPanel pan = pb.getPanel();
    pan.setOpaque(true);
    pan.setBackground(Color.WHITE);

    this.popup.setContent(pan);

    // r.y -= this.editorPanel.getScrollPane ().getVerticalScrollBar ().getValue ();

    Point po = SwingUtilities.convertPoint(editor, r.x, r.y, this.editorPanel);

    r.x = po.x;
    r.y = po.y;

    // Subtract the insets of the editorPanel.
    Insets ins = this.editorPanel.getInsets();

    r.x -= ins.left;
    r.y -= ins.top;

    this.editorPanel.showPopupAt(this.popup, r, "above", true);
  }
  private void checkClickOnHyperlink(String html, String link, String expectedTarget)
      throws Exception {
    JTextPane textPane = createTextPane(html);
    DummyHyperlinkListener listener = new DummyHyperlinkListener();
    textPane.addHyperlinkListener(listener);
    TextBox textComponent = new TextBox(textPane);
    textComponent.clickOnHyperlink(link);
    assertEquals(1, listener.getCallCount());
    assertEquals(expectedTarget, listener.getLastEvent().getDescription());

    listener.reset();
    textComponent.triggerClickOnHyperlink(link).run();
    assertEquals(1, listener.getCallCount());
    assertEquals(expectedTarget, listener.getLastEvent().getDescription());
  }
Example #3
0
 /** Enables hyperlinks. Hyperlink anchors load in the text pane. */
 public void enableHyperlinks() {
   if (hyperlinkListener != null) { // remove old listener
     textPane.removeHyperlinkListener(hyperlinkListener);
   }
   hyperlinkListener =
       new HyperlinkListener() {
         public void hyperlinkUpdate(HyperlinkEvent e) {
           if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
             try {
               textPane.setPage(e.getURL());
             } catch (IOException ex) {
             }
           }
         }
       };
   textPane.addHyperlinkListener(hyperlinkListener);
 }
  @Override
  protected Object doInBackground() {
    URL url = null;
    try {
      url = new URL(this.url);

      if (MirrorUtils.isAddressReachable(url.toString())) {
        editorPane.setVisible(false);
        editorPane.setContentType("text/html");
        // editorPane.setEditable(false);
        ToolTipManager.sharedInstance().registerComponent(editorPane);

        editorPane.addHyperlinkListener(
            new HyperlinkListener() {
              @Override
              public void hyperlinkUpdate(HyperlinkEvent e) {

                if (HyperlinkEvent.EventType.ACTIVATED == e.getEventType()) {
                  try {
                    if (Desktop.isDesktopSupported()) {
                      Desktop.getDesktop().browse(e.getURL().toURI());
                    }
                  } catch (IOException e1) {
                    e1.printStackTrace();
                  } catch (URISyntaxException e1) {
                    e1.printStackTrace();
                  }
                }
              }
            });

        editorPane.addPropertyChangeListener(this);
        editorPane.setPage(url);
      } else {
        editorPane.setText("Oh Noes! Our Tumblr Feed is Down!");
      }
    } catch (MalformedURLException e1) {
      e1.printStackTrace();
    } catch (IOException e1) {
      editorPane.setText("Oh Noes! Our Tumblr Server is Down!");
      Util.log("Tumbler log @ '%' not avaliable.", url);
    }

    return null;
  }
Example #5
0
  public HelpDialog() {
    setTitle("Справочная информация");
    setBounds(100, 100, 450, 300);
    setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    getContentPane().setLayout(new BorderLayout());
    contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    getContentPane().add(contentPanel, BorderLayout.CENTER);
    contentPanel.setLayout(new BorderLayout(0, 0));

    editorPane = new JTextPane();
    editorPane.setEditable(false);
    editorPane.addHyperlinkListener(
        new HyperlinkListener() {
          public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
              if (Desktop.isDesktopSupported()) {
                try {
                  Desktop.getDesktop().browse(e.getURL().toURI());
                } catch (IOException e1) {
                  // TODO Auto-generated catch block
                  e1.printStackTrace();
                } catch (URISyntaxException e1) {
                  // TODO Auto-generated catch block
                  e1.printStackTrace();
                }
              }
            }
          }
        });
    JScrollPane scrollPane = new JScrollPane(editorPane);
    contentPanel.add(scrollPane, BorderLayout.CENTER);
    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new FlowLayout(FlowLayout.CENTER));
    getContentPane().add(buttonPane, BorderLayout.SOUTH);
    JButton okButton = new JButton("Принять");
    okButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            setVisible(false);
          }
        });
    okButton.setActionCommand("OK");
    buttonPane.add(okButton);
    getRootPane().setDefaultButton(okButton);
  }
Example #6
0
  /** Constructor. */
  public LegendPanel(int mode, final CyServices cyServices) {
    this.setLayout(new BorderLayout());

    JTextPane textPane = new JTextPane();
    textPane.setEditable(false);
    textPane.setContentType("text/html");
    textPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);

    URL legendUrl;
    if (mode == BIOPAX_LEGEND) {
      legendUrl = LegendPanel.class.getResource("legend.html");
    } else {
      legendUrl = LegendPanel.class.getResource("binary_legend.html");
    }
    StringBuffer temp = new StringBuffer();
    temp.append("<html><body>");

    try {
      String legendHtml = retrieveDocument(legendUrl.toString());
      temp.append(legendHtml);
    } catch (Exception e) {
      temp.append("Could not load legend... " + e.toString());
    }

    temp.append("</body></html>");
    textPane.setText(temp.toString());

    textPane.addHyperlinkListener(
        new HyperlinkListener() {
          public void hyperlinkUpdate(HyperlinkEvent hyperlinkEvent) {
            if (hyperlinkEvent.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
              String name = hyperlinkEvent.getDescription();
              if (name.equalsIgnoreCase("filter")) {
                new EdgeFilterUi(cyServices.applicationManager.getCurrentNetwork(), cyServices);
              }
            }
          }
        });

    BioPaxDetailsPanel.modifyStyleSheetForSingleDocument(textPane);

    JScrollPane scrollPane = new JScrollPane(textPane);
    this.add(scrollPane, BorderLayout.CENTER);
  }
Example #7
0
  public TOSDialog() {
    super(null, false, IdeModalityType.IDE);
    init();
    setTitle("eddy - Logging preferences");
    setCrossClosesWindow(false);
    // get TOS page out of our jar or directory
    final String pathname = PathUtil.getJarPathForClass(TOSDialog.class);
    final File path = new File(pathname);
    try {
      final URL url;
      if (path.isDirectory()) {
        url = new File(path, "intro.html").toURI().toURL();
      } else {
        url = ResourceUtil.getResource(TOSDialog.class, "", "intro.html");
      }
      TOSTextPane.setPage(url);
    } catch (MalformedURLException e) {
      throw new RuntimeException("Cannot load intro text. Please try reinstalling.", e);
    } catch (IOException e) {
      throw new RuntimeException("Cannot load intro text. Please try reinstalling.", e);
    }

    HyperlinkListener l =
        new HyperlinkListener() {
          @Override
          public void hyperlinkUpdate(HyperlinkEvent e) {
            log("got link event: " + e);
            if (HyperlinkEvent.EventType.ACTIVATED == e.getEventType()) {
              try {
                java.awt.Desktop.getDesktop().browse(e.getURL().toURI());
              } catch (IOException e1) {
                // wtf, do nothing
                log("exception: " + e1);
              } catch (URISyntaxException e2) {
                // broken link, do nothing
                log("exception: " + e2);
              }
            }
          }
        };
    TOSTextPane.addHyperlinkListener(l);
  }
Example #8
0
 /** Enables hyperlinks. Hyperlink anchors load in the native browser. */
 public void enableDesktopHyperlinks() {
   if (hyperlinkListener != null) { // remove old listener
     textPane.removeHyperlinkListener(hyperlinkListener);
   }
   hyperlinkListener =
       new HyperlinkListener() {
         public void hyperlinkUpdate(HyperlinkEvent e) {
           if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
             try {
               if (!org.opensourcephysics.desktop.OSPDesktop.browse(e.getURL().toURI())) {
                 // try the old way
                 org.opensourcephysics.desktop.ostermiller.Browser.init();
                 org.opensourcephysics.desktop.ostermiller.Browser.displayURL(
                     e.getURL().toString());
               }
             } catch (Exception e1) {
             }
           }
         }
       };
   textPane.addHyperlinkListener(hyperlinkListener);
 }
 /**
  * This method initializes jTextPane
  *
  * @return javax.swing.JTextPane
  */
 private JTextPane getJTextPane() {
   if (jTextPane == null) {
     jTextPane = new JTextPane();
     jTextPane.setContentType("text/html");
     jTextPane.setText(helpText);
     jTextPane.addHyperlinkListener(
         new HyperlinkListener() {
           public void hyperlinkUpdate(HyperlinkEvent e) {
             if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
               try {
                 FileOpener opener = new MultiOSFileOpener();
                 opener.open(e.getURL().toString());
               } catch (Exception ex) {
                 logger.error("", ex);
               }
             }
           }
         });
     jTextPane.setEditable(false);
   }
   return jTextPane;
 }
 public GithubLoginPanel(final GithubLoginDialog dialog) {
   DocumentListener listener =
       new DocumentAdapter() {
         @Override
         protected void textChanged(DocumentEvent e) {
           dialog.clearErrors();
         }
       };
   myLoginTextField.getDocument().addDocumentListener(listener);
   myPasswordField.getDocument().addDocumentListener(listener);
   mySignupTextField.setText(
       "<html>Do not have an account at github.com? <a href=\"https://github.com\">Sign up</a>.</html>");
   mySignupTextField.setMargin(new Insets(5, 0, 0, 0));
   mySignupTextField.addHyperlinkListener(
       new HyperlinkAdapter() {
         @Override
         protected void hyperlinkActivated(final HyperlinkEvent e) {
           BrowserUtil.browse(e.getURL());
         }
       });
   mySignupTextField.setBackground(UIUtil.TRANSPARENT_COLOR);
   mySignupTextField.setCursor(new Cursor(Cursor.HAND_CURSOR));
 }
  /** Create the frame. */
  public PreferencesWindow(
      final Preferences prefs, MetadataInfo defaultMetadata, final Frame owner) {
    super(owner, true);
    setLocationRelativeTo(owner);
    long startTime = System.nanoTime();

    final Future<HttpResponse> status = checkForUpdates();
    isWindows = System.getProperty("os.name").startsWith("Windows");
    this.prefs = prefs;
    if (defaultMetadata != null) {
      this.defaultMetadata = defaultMetadata;
    } else {
      this.defaultMetadata = new MetadataInfo();
    }
    addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent arg0) {
            save();
            if (onSave != null) {
              onSave.run();
            }
          }
        });
    setTitle("Preferences");
    setMinimumSize(new Dimension(640, 480));
    contentPane = new JPanel();
    setContentPane(contentPane);

    GridBagLayout gbl_contentPane = new GridBagLayout();
    gbl_contentPane.columnWidths = new int[] {725, 0};
    gbl_contentPane.rowHeights = new int[] {389, 29, 0};
    gbl_contentPane.columnWeights = new double[] {0.0, Double.MIN_VALUE};
    gbl_contentPane.rowWeights = new double[] {0.0, 0.0, Double.MIN_VALUE};
    contentPane.setLayout(gbl_contentPane);

    JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    GridBagConstraints gbc_tabbedPane = new GridBagConstraints();
    gbc_tabbedPane.weighty = 1.0;
    gbc_tabbedPane.weightx = 1.0;
    gbc_tabbedPane.fill = GridBagConstraints.BOTH;
    gbc_tabbedPane.insets = new Insets(0, 0, 5, 0);
    gbc_tabbedPane.gridx = 0;
    gbc_tabbedPane.gridy = 0;
    contentPane.add(tabbedPane, gbc_tabbedPane);

    JPanel panelGeneral = new JPanel();
    tabbedPane.addTab("General", null, panelGeneral, null);
    panelGeneral.setLayout(new MigLayout("", "[grow]", "[][]"));

    JPanel panel_1 = new JPanel();
    panel_1.setBorder(
        new TitledBorder(
            new LineBorder(new Color(184, 207, 229)),
            "On Save ...",
            TitledBorder.LEADING,
            TitledBorder.TOP,
            null,
            new Color(51, 51, 51)));
    panel_1.setLayout(new MigLayout("", "[]", "[][]"));

    onsaveCopyDocumentTo = new JCheckBox("Copy Document To XMP");
    onsaveCopyDocumentTo.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            if (onsaveCopyDocumentTo.isSelected()) {
              onsaveCopyXmpTo.setSelected(false);
            }
            copyBasicToXmp = onsaveCopyDocumentTo.isSelected();
            copyXmpToBasic = onsaveCopyXmpTo.isSelected();
          }
        });
    panel_1.add(onsaveCopyDocumentTo, "cell 0 0,alignx left,aligny top");
    onsaveCopyDocumentTo.setSelected(false);

    onsaveCopyXmpTo = new JCheckBox("Copy XMP To Document");
    onsaveCopyXmpTo.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            if (onsaveCopyXmpTo.isSelected()) {
              onsaveCopyDocumentTo.setSelected(false);
            }
            copyBasicToXmp = onsaveCopyDocumentTo.isSelected();
            copyXmpToBasic = onsaveCopyXmpTo.isSelected();
          }
        });
    panel_1.add(onsaveCopyXmpTo, "cell 0 1");
    onsaveCopyXmpTo.setSelected(false);
    panelGeneral.add(panel_1, "flowx,cell 0 0,alignx left,aligny top");

    onsaveCopyXmpTo.setSelected(prefs.getBoolean("onsaveCopyXmpTo", false));
    onsaveCopyDocumentTo.setSelected(prefs.getBoolean("onsaveCopyBasicTo", false));

    JPanel panel = new JPanel();
    panel.setBorder(
        new TitledBorder(
            new LineBorder(new Color(184, 207, 229)),
            "Rename template",
            TitledBorder.LEADING,
            TitledBorder.TOP,
            null,
            new Color(51, 51, 51)));
    panelGeneral.add(panel, "cell 0 1,grow");
    panel.setLayout(new MigLayout("", "[grow]", "[][][]"));

    lblNewLabel = new JLabel("Preview:");
    panel.add(lblNewLabel, "cell 0 1");

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setViewportBorder(null);
    panel.add(scrollPane, "cell 0 2,grow");

    JTextPane txtpnAaa = new JTextPane();
    txtpnAaa.setBackground(UIManager.getColor("Panel.background"));
    txtpnAaa.setEditable(false);
    scrollPane.setViewportView(txtpnAaa);
    txtpnAaa.setContentType("text/html");
    txtpnAaa.setText(
        "Supported fields:<br>\n<pre>\n<i>"
            + CommandLine.mdFieldsHelpMessage(60, "  {", "}", false)
            + "</i></pre>");
    txtpnAaa.setFont(UIManager.getFont("TextPane.font"));
    txtpnAaa.setCaretPosition(0);

    comboBox = new JComboBox();
    comboBox.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            showPreview((String) getRenameTemplateCombo().getModel().getSelectedItem());
          }
        });
    comboBox.setEditable(true);
    comboBox.setModel(
        new DefaultComboBoxModel(
            new String[] {
              "", "{doc.author} - {doc.title}.pdf", "{doc.author} - {doc.creationDate}.pdf"
            }));
    panel.add(comboBox, "cell 0 0,growx");

    JPanel saveActionPanel = new JPanel();
    saveActionPanel.setBorder(
        new TitledBorder(
            null, "Default save action", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    panelGeneral.add(saveActionPanel, "cell 0 0");
    saveActionPanel.setLayout(new MigLayout("", "[][]", "[][]"));

    final JRadioButton rdbtnSave = new JRadioButton("Save");

    buttonGroup.add(rdbtnSave);
    saveActionPanel.add(rdbtnSave, "flowy,cell 0 0,alignx left,aligny top");

    final JRadioButton rdbtnSaveAndRename = new JRadioButton("Save & rename");
    rdbtnSaveAndRename.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {}
        });
    buttonGroup.add(rdbtnSaveAndRename);

    final JRadioButton rdbtnSaveAs = new JRadioButton("Save as ...");
    buttonGroup.add(rdbtnSaveAs);

    saveActionPanel.add(rdbtnSaveAndRename, "cell 0 0,alignx left,aligny top");

    saveActionPanel.add(rdbtnSaveAs, "cell 1 0,aligny top");
    final JTextComponent tcA = (JTextComponent) comboBox.getEditor().getEditorComponent();

    JPanel panelDefaults = new JPanel();
    tabbedPane.addTab("Defaults", null, panelDefaults, null);
    GridBagLayout gbl_panelDefaults = new GridBagLayout();
    gbl_panelDefaults.columnWidths = new int[] {555, 0};
    gbl_panelDefaults.rowHeights = new int[] {32, 100, 0};
    gbl_panelDefaults.columnWeights = new double[] {0.0, Double.MIN_VALUE};
    gbl_panelDefaults.rowWeights = new double[] {0.0, Double.MIN_VALUE};
    panelDefaults.setLayout(gbl_panelDefaults);

    JLabel lblDefineHereDefault =
        new JLabel(
            "Define here default values for the fields you would like prefilled if not set in the PDF document ");
    GridBagConstraints gbc_lblDefineHereDefault = new GridBagConstraints();
    gbc_lblDefineHereDefault.insets = new Insets(5, 5, 0, 0);
    gbc_lblDefineHereDefault.weightx = 1.0;
    gbc_lblDefineHereDefault.anchor = GridBagConstraints.NORTH;
    gbc_lblDefineHereDefault.fill = GridBagConstraints.HORIZONTAL;
    gbc_lblDefineHereDefault.gridx = 0;
    gbc_lblDefineHereDefault.gridy = 0;
    panelDefaults.add(lblDefineHereDefault, gbc_lblDefineHereDefault);

    GridBagConstraints gbc_lblDefineHereDefault1 = new GridBagConstraints();
    gbc_lblDefineHereDefault1.weightx = 1.0;
    gbc_lblDefineHereDefault1.weighty = 1.0;
    gbc_lblDefineHereDefault1.anchor = GridBagConstraints.NORTH;
    gbc_lblDefineHereDefault1.fill = GridBagConstraints.BOTH;
    gbc_lblDefineHereDefault1.gridx = 0;
    gbc_lblDefineHereDefault1.gridy = 1;
    defaultMetadataPane = new MetadataEditPane();

    panelDefaults.add(defaultMetadataPane.tabbedaPane, gbc_lblDefineHereDefault1);

    JPanel panelOsIntegration = new JPanel();
    tabbedPane.addTab("Os Integration", null, panelOsIntegration, null);
    panelOsIntegration.setLayout(new MigLayout("", "[grow]", "[grow]"));

    JPanel panel_2 = new JPanel();
    panel_2.setBorder(
        new TitledBorder(
            new EtchedBorder(EtchedBorder.LOWERED, null, null),
            "Explorer context menu (Windows only)",
            TitledBorder.LEADING,
            TitledBorder.TOP,
            null,
            new Color(0, 0, 0)));
    panelOsIntegration.add(panel_2, "cell 0 0,grow");
    panel_2.setLayout(new MigLayout("", "[][]", "[growprio 50,grow][growprio 50,grow]"));

    JButton btnRegister = new JButton("Add to context menu");
    btnRegister.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            try {
              WindowsRegisterContextMenu.register();
            } catch (Exception e1) {
              // StringWriter sw = new StringWriter();
              // PrintWriter pw = new PrintWriter(sw);
              // e1.printStackTrace(pw);
              // JOptionPane.showMessageDialog(owner,
              // "Failed to register context menu:\n" + e1.toString()
              // +"\n" +sw.toString());
              JOptionPane.showMessageDialog(
                  owner, "Failed to register context menu:\n" + e1.toString());
              e1.printStackTrace();
            }
          }
        });
    panel_2.add(btnRegister, "cell 0 0,growx,aligny center");

    JButton btnUnregister = new JButton("Remove from context menu");
    btnUnregister.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            WindowsRegisterContextMenu.unregister();
          }
        });

    final JLabel lblNewLabel_1 = new JLabel("");
    panel_2.add(lblNewLabel_1, "cell 1 0 1 2");

    panel_2.add(btnUnregister, "cell 0 1,growx,aligny center");

    btnRegister.setEnabled(isWindows);
    btnUnregister.setEnabled(isWindows);

    JPanel panelBatchLicense = new JPanel();
    tabbedPane.addTab("License", null, panelBatchLicense, null);
    GridBagLayout gbl_panelBatchLicense = new GridBagLayout();
    gbl_panelBatchLicense.columnWidths = new int[] {0, 0, 0};
    gbl_panelBatchLicense.rowHeights = new int[] {0, 0, 0, 0, 0};
    gbl_panelBatchLicense.columnWeights = new double[] {0.0, 1.0, Double.MIN_VALUE};
    gbl_panelBatchLicense.rowWeights = new double[] {0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
    panelBatchLicense.setLayout(gbl_panelBatchLicense);

    JTextPane txtpnEnterLicenseInformation = new JTextPane();
    txtpnEnterLicenseInformation.setEditable(false);
    txtpnEnterLicenseInformation.setBackground(UIManager.getColor("Panel.background"));
    txtpnEnterLicenseInformation.setContentType("text/html");
    txtpnEnterLicenseInformation.setText(
        "<h3 align='center'>Enter license information below to use batch operations.</h3><p align='center'>You can get license at <a href=\""
            + Constants.batchLicenseUrl
            + "\">"
            + Constants.batchLicenseUrl
            + "</a></p>");
    GridBagConstraints gbc_txtpnEnterLicenseInformation = new GridBagConstraints();
    gbc_txtpnEnterLicenseInformation.gridwidth = 2;
    gbc_txtpnEnterLicenseInformation.insets = new Insets(15, 0, 5, 0);
    gbc_txtpnEnterLicenseInformation.fill = GridBagConstraints.HORIZONTAL;
    gbc_txtpnEnterLicenseInformation.gridx = 0;
    gbc_txtpnEnterLicenseInformation.gridy = 0;
    panelBatchLicense.add(txtpnEnterLicenseInformation, gbc_txtpnEnterLicenseInformation);
    txtpnEnterLicenseInformation.addHyperlinkListener(
        new HyperlinkListener() {
          public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType() != HyperlinkEvent.EventType.ACTIVATED) {
              return;
            }
            if (!java.awt.Desktop.isDesktopSupported()) {
              return;
            }
            java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
            if (!desktop.isSupported(java.awt.Desktop.Action.BROWSE)) {
              return;
            }

            try {
              java.net.URI uri = e.getURL().toURI();
              desktop.browse(uri);
            } catch (Exception e1) {

            }
          }
        });
    JLabel lblNewLabel_2 = new JLabel("Email");
    GridBagConstraints gbc_lblNewLabel_2 = new GridBagConstraints();
    gbc_lblNewLabel_2.insets = new Insets(15, 15, 5, 5);
    gbc_lblNewLabel_2.anchor = GridBagConstraints.EAST;
    gbc_lblNewLabel_2.gridx = 0;
    gbc_lblNewLabel_2.gridy = 1;
    panelBatchLicense.add(lblNewLabel_2, gbc_lblNewLabel_2);

    emailField = new JTextField();
    GridBagConstraints gbc_emailField = new GridBagConstraints();
    gbc_emailField.insets = new Insets(15, 0, 5, 15);
    gbc_emailField.fill = GridBagConstraints.HORIZONTAL;
    gbc_emailField.gridx = 1;
    gbc_emailField.gridy = 1;
    panelBatchLicense.add(emailField, gbc_emailField);
    emailField.setColumns(10);
    emailField.setText(Main.getPreferences().get("email", ""));
    emailField
        .getDocument()
        .addDocumentListener(
            new DocumentListener() {
              @Override
              public void removeUpdate(DocumentEvent e) {
                updateLicense();
              }

              @Override
              public void insertUpdate(DocumentEvent e) {
                updateLicense();
              }

              @Override
              public void changedUpdate(DocumentEvent e) {}
            });

    JLabel lblLicenseKey = new JLabel("License key");
    GridBagConstraints gbc_lblLicenseKey = new GridBagConstraints();
    gbc_lblLicenseKey.anchor = GridBagConstraints.EAST;
    gbc_lblLicenseKey.insets = new Insets(0, 15, 5, 5);
    gbc_lblLicenseKey.gridx = 0;
    gbc_lblLicenseKey.gridy = 2;
    panelBatchLicense.add(lblLicenseKey, gbc_lblLicenseKey);

    keyField = new JTextField();
    GridBagConstraints gbc_keyField = new GridBagConstraints();
    gbc_keyField.insets = new Insets(0, 0, 5, 15);
    gbc_keyField.fill = GridBagConstraints.HORIZONTAL;
    gbc_keyField.gridx = 1;
    gbc_keyField.gridy = 2;
    panelBatchLicense.add(keyField, gbc_keyField);
    keyField.setColumns(10);
    keyField.setText(Main.getPreferences().get("key", ""));
    keyField
        .getDocument()
        .addDocumentListener(
            new DocumentListener() {
              @Override
              public void removeUpdate(DocumentEvent e) {
                updateLicense();
              }

              @Override
              public void insertUpdate(DocumentEvent e) {
                updateLicense();
              }

              @Override
              public void changedUpdate(DocumentEvent e) {}
            });

    labelLicenseStatus = new JLabel("No License");
    GridBagConstraints gbc_labelLicenseStatus = new GridBagConstraints();
    gbc_labelLicenseStatus.gridwidth = 2;
    gbc_labelLicenseStatus.insets = new Insets(30, 15, 0, 15);
    gbc_labelLicenseStatus.gridx = 0;
    gbc_labelLicenseStatus.gridy = 3;
    panelBatchLicense.add(labelLicenseStatus, gbc_labelLicenseStatus);

    JScrollPane scrollPane_1 = new JScrollPane();
    tabbedPane.addTab("About", null, scrollPane_1, null);

    txtpnDf = new JTextPane();
    txtpnDf.addHyperlinkListener(
        new HyperlinkListener() {
          public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType() != HyperlinkEvent.EventType.ACTIVATED) {
              return;
            }
            if (!java.awt.Desktop.isDesktopSupported()) {
              return;
            }
            java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
            if (!desktop.isSupported(java.awt.Desktop.Action.BROWSE)) {
              return;
            }

            try {
              java.net.URI uri = e.getURL().toURI();
              desktop.browse(uri);
            } catch (Exception e1) {

            }
          }
        });
    txtpnDf.setContentType("text/html");
    txtpnDf.setEditable(false);
    txtpnDf.setText(
        aboutMsg =
            "<h1 align=center>Pdf Metadata editor</h1>\n\n<p align=center><a href=\"http://broken-by.me/pdf-metadata-editor/\">http://broken-by.me/pdf-metadata-editor/</a></p>\n<br>\n<p align=center>If you have suggestions, found bugs or just want to share some idea about it you can write me at : <a href=\"mailto:[email protected]\"/>[email protected]</a></p>\n<br>");
    scrollPane_1.setViewportView(txtpnDf);

    JPanel panel_3 = new JPanel();
    GridBagConstraints gbc_panel_3 = new GridBagConstraints();
    gbc_panel_3.insets = new Insets(0, 5, 0, 5);
    gbc_panel_3.fill = GridBagConstraints.BOTH;
    gbc_panel_3.gridx = 0;
    gbc_panel_3.gridy = 1;
    contentPane.add(panel_3, gbc_panel_3);
    panel_3.setLayout(new BorderLayout(0, 0));

    JButton btnClose = new JButton("Close");
    panel_3.add(btnClose, BorderLayout.EAST);

    updateStatusLabel = new JLabel("...");
    panel_3.add(updateStatusLabel, BorderLayout.WEST);
    btnClose.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            setVisible(false);
            save();
          }
        });

    ActionListener onDefaultSaveAction =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (rdbtnSave.isSelected()) {
              defaultSaveAction = "save";
            } else if (rdbtnSaveAndRename.isSelected()) {
              defaultSaveAction = "saveRename";

            } else if (rdbtnSaveAs.isSelected()) {
              defaultSaveAction = "saveAs";
            }
          }
        };
    rdbtnSave.addActionListener(onDefaultSaveAction);
    rdbtnSaveAndRename.addActionListener(onDefaultSaveAction);
    rdbtnSaveAs.addActionListener(onDefaultSaveAction);
    tcA.getDocument()
        .addDocumentListener(
            new DocumentListener() {
              @Override
              public void changedUpdate(DocumentEvent arg0) {
                showPreview((String) comboBox.getEditor().getItem());
              }

              @Override
              public void insertUpdate(DocumentEvent arg0) {
                showPreview((String) comboBox.getEditor().getItem());
              }

              @Override
              public void removeUpdate(DocumentEvent arg0) {
                showPreview((String) comboBox.getEditor().getItem());
              }
            });
    String defaultSaveAction = prefs.get("defaultSaveAction", "save");
    if (defaultSaveAction.equals("saveRename")) {
      rdbtnSaveAndRename.setSelected(true);
    } else if (defaultSaveAction.equals("saveAs")) {
      rdbtnSaveAndRename.setSelected(true);
    } else {
      rdbtnSave.setSelected(true);
    }

    SwingUtilities.invokeLater(
        new Runnable() {

          @Override
          public void run() {
            lblNewLabel_1.setIcon(
                new ImageIcon(
                    PreferencesWindow.class.getResource("/pmedit/os_integration_hint.png")));
          }
        });

    load();
    refresh();
    contentPane.doLayout();

    if (status.isDone()) {
      showUpdatesStatus(status);
    } else {
      (new Thread(
              new Runnable() {

                @Override
                public void run() {
                  showUpdatesStatus(status);
                }
              }))
          .start();
    }
    updateLicense();
  }
  private JComponent createCenterPane() {
    MyTableRenderer mtr = new MyTableRenderer();
    JPanel toReturn = new JPanel(new BorderLayout());

    JLabel lab = new JLabel(getText("found"));
    lab.setBorder(BorderFactory.createEmptyBorder(0, 0, 6, 0));
    toReturn.add(lab, BorderLayout.NORTH);
    tableTb = new JTable();
    tableTb.setAutoCreateColumnsFromModel(false);
    TableColumn col = new TableColumn(0);
    col.setHeaderValue(getText("tclocale"));
    col.setCellRenderer(mtr);
    tableTb.addColumn(col);
    col = new TableColumn(1);
    col.setHeaderValue(getText("tcmodified"));
    col.setCellRenderer(mtr);
    tableTb.addColumn(col);
    col = new TableColumn(2);
    col.setHeaderValue(getText("tcsize"));
    col.setCellRenderer(mtr);
    tableTb.addColumn(col);
    col = new TableColumn(3);
    col.setHeaderValue(getText("tcurl"));
    col.setPreferredWidth(200);
    col.setCellRenderer(mtr);
    tableTb.addColumn(col);
    JScrollPane tscroll = new JScrollPane(tableTb);
    tscroll.setPreferredSize(new Dimension(tableTb.getPreferredSize().width, 300));
    toReturn.add(tscroll, BorderLayout.CENTER);

    new TableCellTipManager(tableTb);
    tableTb.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    refreshBt = new JButton();
    refreshBt.setMargin(new Insets(1, 1, 1, 1));
    JPRManagerLauncher.getResourceData().configureButton("form.dictInWeb.refreshBt", refreshBt);
    installBt = new JButton();
    installBt.setMargin(new Insets(1, 1, 1, 1));
    installBt.setEnabled(false);
    JPRManagerLauncher.getResourceData().configureButton("form.dictInWeb.indexBt", installBt);
    Box bts = Box.createVerticalBox();
    bts.add(refreshBt);
    bts.add(Box.createVerticalStrut(5));
    bts.add(installBt);
    bts.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
    toReturn.add(bts, BorderLayout.EAST);

    JPanel southPn = new JPanel(new BorderLayout());
    notesLb = new JTextPane();
    notesLb.setOpaque(false);
    notesLb.setEditable(false);
    notesLb.setFocusable(false);
    notesLb.setContentType("text/html");
    notesLb.addHyperlinkListener(
        new HyperlinkListener() {
          public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
              try {
                BrowserLauncher.openURL(e.getURL().toString());
              } catch (IOException _e) {
                JPRManagerLauncher.getMessageHandler()
                    .showMessage(
                        DictionariesInWebForm.this,
                        MessageConstants.OPEN_URL_ERROR,
                        new Object[] {e.getURL().toString()},
                        _e);
              }
            }
          }
        });
    JScrollPane nscroll = new JScrollPane(notesLb);
    nscroll.setBorder(BorderFactory.createEmptyBorder(5, 0, 6, 0));
    nscroll.setPreferredSize(new Dimension(200, 80));
    southPn.add(nscroll, BorderLayout.CENTER);

    JPanel progressPn = new JPanel(new BorderLayout());
    progressPb = new JProgressBar();
    progressPb.setStringPainted(true);
    progressPb.setString("");
    progressPb.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createEmptyBorder(2, 0, 3, 5), progressPb.getBorder()));
    cancelBt = new JButton(JPRManagerLauncher.getResourceData().getText("form.cancel"));
    progressPn.add(progressPb, BorderLayout.CENTER);
    progressPn.add(cancelBt, BorderLayout.EAST);
    southPn.add(progressPn, BorderLayout.SOUTH);
    toReturn.add(southPn, BorderLayout.SOUTH);

    return toReturn;
  }
Example #13
0
  public void show() {
    final String aboutText = Tools.getLabel(messages.getString("guiMenuAbout"));

    JTextPane aboutPane = new JTextPane();
    aboutPane.setBackground(new Color(0, 0, 0, 0));
    aboutPane.setBorder(BorderFactory.createEmptyBorder());
    aboutPane.setContentType("text/html");
    aboutPane.setEditable(false);
    aboutPane.setOpaque(false);

    aboutPane.setText(
        String.format(
            "<html>"
                + "<p>LanguageTool %s (%s)<br>"
                + "Copyright (C) 2005-2014 the LanguageTool community and Daniel Naber<br>"
                + "This software is licensed under the GNU Lesser General Public License.<br>"
                + "<a href=\"http://www.languagetool.org\">http://www.languagetool.org</a></p>"
                + "<p>Maintainers of the language modules:</p><br>"
                + "</html>",
            JLanguageTool.VERSION, JLanguageTool.BUILD_DATE));

    aboutPane.addHyperlinkListener(
        new HyperlinkListener() {
          @Override
          public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
              if (Desktop.isDesktopSupported()) {
                try {
                  Desktop.getDesktop().browse(e.getURL().toURI());
                } catch (Exception ex) {
                  Tools.showError(ex);
                }
              }
            }
          }
        });

    JTextPane maintainersPane = new JTextPane();
    maintainersPane.setBackground(new Color(0, 0, 0, 0));
    maintainersPane.setBorder(BorderFactory.createEmptyBorder());
    maintainersPane.setContentType("text/html");
    maintainersPane.setEditable(false);
    maintainersPane.setOpaque(false);

    maintainersPane.setText(getMaintainers());

    int maxHeight = java.awt.Toolkit.getDefaultToolkit().getScreenSize().height / 2;
    if (maintainersPane.getPreferredSize().height > maxHeight) {
      maintainersPane.setPreferredSize(
          new Dimension(maintainersPane.getPreferredSize().width, maxHeight));
    }

    JScrollPane scrollPane = new JScrollPane(maintainersPane);
    scrollPane.setBorder(BorderFactory.createEmptyBorder());
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
    panel.add(aboutPane);
    panel.add(scrollPane);

    JOptionPane.showMessageDialog(parent, panel, aboutText, JOptionPane.INFORMATION_MESSAGE);
  }
Example #14
0
  HtmlPanel(final Map<String, Action> actions, HtmlPage page) throws IOException {
    super(new BorderLayout());

    this.actions = actions;
    textPane = new JTextPane();
    find = new JTextField();
    matches = new JLabel();
    this.page = null;

    final Dimension d = matches.getPreferredSize();
    matches.setPreferredSize(new Dimension(100, d.height));

    textPane.setEditable(false);
    textPane.setFocusable(false);
    textPane.addHyperlinkListener(
        new HyperlinkListener() {

          public final void hyperlinkUpdate(HyperlinkEvent ev) {
            if (ev.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
              final JEditorPane pane = (JEditorPane) ev.getSource();
              if (ev instanceof HTMLFrameHyperlinkEvent) {
                final HTMLFrameHyperlinkEvent evt = (HTMLFrameHyperlinkEvent) ev;
                final HTMLDocument doc = (HTMLDocument) pane.getDocument();
                doc.processHTMLFrameHyperlinkEvent(evt);
              } else if (Desktop.isDesktopSupported())
                try {
                  Desktop.getDesktop().browse(ev.getURL().toURI());
                } catch (final Exception e) {
                  e.printStackTrace();
                }
            }
          }
        });

    final HTMLEditorKit kit =
        new HTMLEditorKit() {
          private static final long serialVersionUID = 1L;

          @Override
          public final Document createDefaultDocument() {
            final HTMLDocument doc = (HTMLDocument) super.createDefaultDocument();
            // Load synchronously.
            doc.setAsynchronousLoadPriority(-1);
            return doc;
          }
        };

    final StyleSheet styleSheet = kit.getStyleSheet();
    final InputStream is = getClass().getResourceAsStream("/doogal.css");
    try {
      styleSheet.loadRules(newBufferedReader(is), null);
    } finally {
      is.close();
    }

    textPane.setEditorKit(kit);

    final Document doc = kit.createDefaultDocument();
    textPane.setDocument(doc);
    textPane.addMouseListener(
        new MouseAdapter() {

          private final void showPopup(MouseEvent e) {
            if (e.isPopupTrigger()) {
              final JPopupMenu menu = newPopupMenu(TableType.DOCUMENT, actions);
              if (null != menu) menu.show(e.getComponent(), e.getX(), e.getY());
            }
          }

          @Override
          public final void mousePressed(MouseEvent e) {
            showPopup(e);
          }

          @Override
          public final void mouseReleased(MouseEvent e) {
            showPopup(e);
          }
        });
    find.setColumns(16);
    find.setFont(new Font("Dialog", Font.PLAIN, TINY_FONT));
    find.setMargin(new Insets(2, 2, 2, 2));
    find.addActionListener(
        new ActionListener() {
          public final void actionPerformed(ActionEvent ev) {
            find(find.getText());
          }
        });

    final JLabel label = new JLabel("Quick Find: ");
    label.setLabelFor(find);

    final JButton clear = new JButton("Clear");
    clear.setMargin(new Insets(1, 5, 0, 5));
    clear.setFont(new Font("Dialog", Font.PLAIN, TINY_FONT));
    clear.addActionListener(
        new ActionListener() {
          public final void actionPerformed(ActionEvent e) {
            find.setText("");
            find("");
          }
        });

    final JPanel findPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    findPanel.add(label);
    findPanel.add(find);
    findPanel.add(clear);
    findPanel.add(matches);

    scrollPane =
        new JScrollPane(
            textPane,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setFocusable(false);
    final JScrollBar scrollBar = scrollPane.getVerticalScrollBar();
    scrollBar.setBlockIncrement(scrollBar.getBlockIncrement() * 20);
    scrollBar.setUnitIncrement(scrollBar.getUnitIncrement() * 20);

    add(scrollPane, BorderLayout.CENTER);
    add(findPanel, BorderLayout.SOUTH);

    setPage(page);
  }
  About() {
    window = new JWindow();
    this.setPreferredSize(new Dimension(650, 550));
    this.setVisible(true);
    this.setLayout(null);

    JTextPane text = new JTextPane();
    text.setBounds(5, 150, 625, 525);
    text.setVisible(true);
    text.setEditable(false);
    text.setOpaque(false);
    HTMLEditorKit htmlKit =
        new HTMLEditorKit() {
          public Parser getParser() {
            return super.getParser();
          }
        };
    HTMLDocument htmlDoc = new HTMLDocument();
    text.addHyperlinkListener(
        new HyperlinkListener() {
          public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
              if (Desktop.isDesktopSupported()) {
                try {
                  Desktop.getDesktop().browse(e.getURL().toURI());
                  return;
                } catch (IOException e1) {
                } catch (URISyntaxException e1) {
                }
              }
              try {
                Runtime.getRuntime().exec("xdg-open ".concat(e.getURL().toString()));
              } catch (IOException ioex) {
                ControlRoom.log(
                    Level.WARNING,
                    "Failed to show file: '"
                        + e.getURL().toString()
                        + "'. Possible unsupported File Manager...",
                    null);
              }
            }
          }
        });
    text.setEditorKit(htmlKit);
    text.setDocument(htmlDoc);
    try {
      BufferedReader reader =
          new BufferedReader(
              new InputStreamReader(
                  this.getClass().getResourceAsStream("/resources/about.html"), "UTF-8"));
      htmlKit.read(reader, htmlDoc, htmlDoc.getLength());
    } catch (IOException ioex) {
      ControlRoom.log(Level.SEVERE, "Failed to read about.html", ioex);
    } catch (BadLocationException e) {
      e
          .printStackTrace(); // To change body of catch statement use File | Settings | File
                              // Templates.
    }

    text.addMouseListener(this);
    window.getContentPane().add(text);
    window.getContentPane().add(this);
    window.addMouseListener(this);
    window.pack();
    ControlRoom.setWindowRelativeToCentral(window);
    window.setVisible(true);
    window.setAlwaysOnTop(true);
  }
  /** @param plugin */
  public PluginDetailPanel(PluginDescriptor plugin) {
    super(plugin.getName() + " " + plugin.getVersion(), false, true);

    this.plugin = plugin;

    // changesLogButton = new ChangesLogActionButton();
    executeButton = new ExecuteActionButton();
    closeButton = new CloseActionButton();

    setPreferredSize(new Dimension(640, 480));

    // build top panel
    pluginDescriptionText = new JTextPane();
    pluginDescriptionText.setContentType("text/html");
    pluginDescriptionText.setEditable(false);
    pluginDescriptionText.setOpaque(false);
    pluginDescriptionText.addHyperlinkListener(this);
    ComponentUtil.setFixedHeight(pluginDescriptionText, 256);

    final JScrollPane scDescription = new JScrollPane(pluginDescriptionText);
    scDescription.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 4));

    pluginImage =
        new ImageComponent(
            plugin.isImageLoaded() ? plugin.getImage() : PluginDescriptor.DEFAULT_IMAGE);

    imagePanel = new JPanel(new BorderLayout());
    imagePanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    imagePanel.add(pluginImage, BorderLayout.CENTER);

    final JPanel topPanel = new JPanel(new BorderLayout());

    topPanel.add(imagePanel, BorderLayout.WEST);
    topPanel.add(scDescription, BorderLayout.CENTER);

    // center panel
    pluginAuthorLabel = new JLabel();
    pluginWebsiteLabel = new JLabel();
    pluginEmailLabel = new JLabel();

    final JPanel infosPanel = new JPanel();
    infosPanel.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 8));
    infosPanel.setLayout(new BoxLayout(infosPanel, BoxLayout.PAGE_AXIS));

    infosPanel.add(GuiUtil.createTabBoldLabel("Author", 1));
    infosPanel.add(GuiUtil.createTabLabel(pluginAuthorLabel, 32));
    infosPanel.add(Box.createVerticalStrut(4));
    infosPanel.add(GuiUtil.createTabBoldLabel("Web site", 1));
    infosPanel.add(GuiUtil.createTabLabel(pluginWebsiteLabel, 32));
    infosPanel.add(Box.createVerticalStrut(4));
    infosPanel.add(GuiUtil.createTabBoldLabel("Email", 1));
    infosPanel.add(GuiUtil.createTabLabel(pluginEmailLabel, 32));
    infosPanel.add(Box.createVerticalStrut(4));
    infosPanel.add(Box.createVerticalGlue());

    pluginChangeLogText = new JTextPane();
    pluginChangeLogText.setContentType("text/html");
    pluginChangeLogText.setEditable(false);
    pluginChangeLogText.setOpaque(false);
    pluginChangeLogText.addHyperlinkListener(this);

    final JScrollPane scChangeLog = new JScrollPane(pluginChangeLogText);
    scChangeLog.setBorder(BorderFactory.createEmptyBorder(4, 0, 0, 0));

    final JPanel changeLogPanel = new JPanel(new BorderLayout());
    changeLogPanel.setBorder(BorderFactory.createEmptyBorder(0, 8, 4, 4));

    changeLogPanel.add(GuiUtil.createTabBoldLabel("ChangeLog", 1), BorderLayout.NORTH);
    changeLogPanel.add(
        GuiUtil.createLineBoxPanel(Box.createHorizontalStrut(32), scChangeLog),
        BorderLayout.CENTER);

    final JPanel centerPanel = new JPanel(new BorderLayout());

    centerPanel.add(new JSeparator(SwingConstants.HORIZONTAL), BorderLayout.NORTH);
    centerPanel.add(infosPanel, BorderLayout.WEST);
    centerPanel.add(changeLogPanel, BorderLayout.CENTER);

    // bottom panel
    final JPanel buttonsPanel = new JPanel();
    buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.LINE_AXIS));
    buttonsPanel.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));

    buttonsPanel.add(executeButton);
    buttonsPanel.add(Box.createHorizontalGlue());
    buttonsPanel.add(Box.createHorizontalStrut(4));
    buttonsPanel.add(closeButton);

    final JPanel bottomPanel = new JPanel(new BorderLayout());

    bottomPanel.add(new JSeparator(SwingConstants.HORIZONTAL), BorderLayout.NORTH);
    bottomPanel.add(buttonsPanel, BorderLayout.CENTER);

    setLayout(new BorderLayout());

    add(topPanel, BorderLayout.NORTH);
    add(centerPanel, BorderLayout.CENTER);
    add(bottomPanel, BorderLayout.SOUTH);

    updateGui();

    addToDesktopPane();
    // random position for more fun
    setLocation(10 * Random.nextInt(20) + 40, 10 * Random.nextInt(10) + 40);
    setVisible(true);
    requestFocus();

    // some parts of the descriptor are not loaded --> async update
    if (!plugin.isAllLoaded()) {
      ThreadUtil.bgRun(
          new Runnable() {
            @Override
            public void run() {
              PluginDetailPanel.this.plugin.loadAll();

              // rebuild interface
              ThreadUtil.invokeLater(
                  new Runnable() {
                    @Override
                    public void run() {
                      updateGui();
                    }
                  });
            }
          });
    }
  }