/** Creates the error area component. */
 private void initErrorArea() {
   SimpleAttributeSet attribs = new SimpleAttributeSet();
   StyleConstants.setAlignment(attribs, StyleConstants.ALIGN_RIGHT);
   StyleConstants.setFontFamily(attribs, errorPane.getFont().getFamily());
   StyleConstants.setForeground(attribs, Color.RED);
   errorPane.setParagraphAttributes(attribs, true);
   errorPane.setPreferredSize(new Dimension(100, 50));
   errorPane.setMinimumSize(new Dimension(100, 50));
   errorPane.setOpaque(false);
 }
  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);
  }
Пример #3
0
  private void initPanel() {
    masterPanel.add(initPanel, SELECTSARTYPE);

    initPanel.setBorder(new EmptyBorder(5, 5, 5, 5));

    initPanel.setLayout(null);

    JPanel panel = new JPanel();
    panel.setBorder(
        new TitledBorder(
            null,
            "Inititate New SAR Operation",
            TitledBorder.LEADING,
            TitledBorder.TOP,
            null,
            null));
    panel.setBounds(10, 11, 523, 340);
    initPanel.add(panel);
    panel.setLayout(null);

    typeSelectionComboBox = new JComboBox<String>();
    typeSelectionComboBox.setBounds(126, 21, 102, 20);
    panel.add(typeSelectionComboBox);
    typeSelectionComboBox.setModel(
        new DefaultComboBoxModel<String>(
            new String[] {
              "Simple SAR", "Rapid Response", "Datum Point", "Datum Line", "Back Track"
            }));

    typeSelectionComboBox.addActionListener(this);

    JLabel lblSelectSarType = new JLabel("Select SAR Type");
    lblSelectSarType.setBounds(10, 24, 140, 14);
    panel.add(lblSelectSarType);

    descriptiveText = new JTextPane();

    descriptiveText.setBounds(10, 52, 503, 112);
    panel.add(descriptiveText);
    // descriptiveText.setBackground(UIManager.getColor("Button.background"));
    descriptiveText.setOpaque(false);
    descriptiveText.setEditable(false);
    descriptiveText.setText(rapidresponseTxt);

    descriptiveImage = new JLabel(" ");
    descriptiveImage.setHorizontalAlignment(SwingConstants.CENTER);
    descriptiveImage.setBounds(20, 131, 493, 200);
    panel.add(descriptiveImage);
    descriptiveImage.setIcon(simpleSarIcon);

    lblOrImportSar = new JLabel("Or import SAR from external file:");
    lblOrImportSar.setBounds(238, 24, 176, 14);
    panel.add(lblOrImportSar);

    btnImport = new JButton("Import");
    btnImport.setBounds(408, 20, 89, 23);
    panel.add(btnImport);

    btnImport.addActionListener(this);
  }
Пример #4
0
 private void initGUI() {
   try {
     BorderLayout thisLayout = new BorderLayout();
     this.setLayout(thisLayout);
     this.setPreferredSize(new java.awt.Dimension(691, 416));
     {
       tiltePnl = new JPanel();
       BorderLayout tiltePnlLayout = new BorderLayout();
       tiltePnl.setLayout(tiltePnlLayout);
       this.add(tiltePnl, BorderLayout.NORTH);
       tiltePnl.setPreferredSize(new java.awt.Dimension(691, 51));
       {
         titleTxt = new JTextPane();
         tiltePnl.add(titleTxt, BorderLayout.WEST);
         titleTxt.setText("Welche Art von Event moechten Sie besuchen?");
         titleTxt.setPreferredSize(new java.awt.Dimension(626, 58));
         titleTxt.setBackground(new java.awt.Color(212, 208, 200));
         titleTxt.setEditable(false);
         titleTxt.setOpaque(false);
         titleTxt.setFont(new java.awt.Font("Segoe UI", 0, 18));
       }
     }
     {
       contentPnl = new JPanel();
       this.add(contentPnl, BorderLayout.CENTER);
       GridBagLayout contentPnlLayout = new GridBagLayout();
       contentPnlLayout.rowWeights = new double[] {0.0, 0.0, 0.1};
       contentPnlLayout.rowHeights = new int[] {20, 300, 7};
       contentPnlLayout.columnWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.1};
       contentPnlLayout.columnWidths = new int[] {30, 200, 200, 200, 7};
       contentPnl.setLayout(contentPnlLayout);
       contentPnl.setPreferredSize(new java.awt.Dimension(691, 365));
       {
         kindOfEventList = new LikeSelectionList();
         contentPnl.add(
             kindOfEventList,
             new GridBagConstraints(
                 1,
                 1,
                 1,
                 1,
                 0.0,
                 0.0,
                 GridBagConstraints.NORTH,
                 GridBagConstraints.NONE,
                 new Insets(0, 0, 0, 0),
                 0,
                 0));
       }
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
Пример #5
0
  @Override
  public JComponent layoutDialogContent() {
    final JPanel contentpane = new JPanel(new MigLayout("ins 0,wrap 2", "[fill,grow]"));
    messageArea = new JTextPane();
    messageArea.setBorder(null);
    messageArea.setBackground(null);
    messageArea.setOpaque(false);
    messageArea.setText(message);
    messageArea.setEditable(false);
    messageArea.putClientProperty("Synthetica.opaque", Boolean.FALSE);

    contentpane.add("span 2", messageArea);
    contentpane.add(new JLabel(_AWU.T.PASSWORDDIALOG_PASSWORDCHANGE_OLDPASSWORD()));
    if (BinaryLogic.containsAll(flagMask, Dialog.STYLE_LARGE)) {
      input1 = new JPasswordField();
      input1.addKeyListener(this);
      input1.addMouseListener(this);
      contentpane.add(new JScrollPane(input1), "height 20:60:n,pushy,growy,w 250");
    } else {
      input1 = new JPasswordField();
      input1.setBorder(BorderFactory.createEtchedBorder());
      input1.addKeyListener(this);
      input1.addMouseListener(this);
      contentpane.add(input1, "pushy,growy,w 250");
    }
    contentpane.add(new JLabel(_AWU.T.PASSWORDDIALOG_PASSWORDCHANGE_NEWPASSWORD()));
    if (BinaryLogic.containsAll(flagMask, Dialog.STYLE_LARGE)) {
      input2 = new JPasswordField();
      input2.addKeyListener(this);
      input2.addMouseListener(this);
      contentpane.add(new JScrollPane(input2), "height 20:60:n,pushy,growy,w 250");
    } else {
      input2 = new JPasswordField();
      input2.setBorder(BorderFactory.createEtchedBorder());
      input2.addKeyListener(this);
      input2.addMouseListener(this);
      contentpane.add(input2, "pushy,growy,w 250");
    }
    contentpane.add(new JLabel(_AWU.T.PASSWORDDIALOG_PASSWORDCHANGE_NEWPASSWORD_REPEAT()));
    if (BinaryLogic.containsAll(flagMask, Dialog.STYLE_LARGE)) {
      input3 = new JPasswordField();
      input3.addKeyListener(this);
      input3.addMouseListener(this);
      contentpane.add(new JScrollPane(input3), "height 20:60:n,pushy,growy,w 250");
    } else {
      input3 = new JPasswordField();
      input3.setBorder(BorderFactory.createEtchedBorder());
      input3.addKeyListener(this);
      input3.addMouseListener(this);
      contentpane.add(input3, "pushy,growy,w 250");
    }

    return contentpane;
  }
Пример #6
0
  /** Creates the text area. */
  private void initTextArea() {
    textArea.setOpaque(false);
    textArea.setEditable(false);
    StyledDocument doc = textArea.getStyledDocument();

    MutableAttributeSet standard = new SimpleAttributeSet();
    StyleConstants.setAlignment(standard, StyleConstants.ALIGN_CENTER);
    StyleConstants.setFontFamily(standard, textArea.getFont().getFamily());
    StyleConstants.setFontSize(standard, 12);
    doc.setParagraphAttributes(0, 0, standard, true);

    parentWindow.addSearchFieldListener(this);
  }
Пример #7
0
  @Override
  public JComponent layoutDialogContent() {
    final JPanel panel = new JPanel(new MigLayout("ins 5,wrap 1", "[fill,grow]"));

    ImageIcon imageIcon = null;

    if (this.imagefile != null && this.imagefile.exists()) {
      imageIcon = new ImageIcon(this.imagefile.getAbsolutePath());
    } else {
      imageIcon = NewTheme.I().getIcon("ocr", 0);
    }

    final int size =
        SubConfiguration.getConfig("JAC").getIntegerProperty(Configuration.PARAM_CAPTCHA_SIZE, 100);
    if (size != 100) {
      imageIcon =
          new ImageIcon(
              imageIcon
                  .getImage()
                  .getScaledInstance(
                      (int) (imageIcon.getIconWidth() * size / 100.0f),
                      (int) (imageIcon.getIconHeight() * size / 100.0f),
                      Image.SCALE_SMOOTH));
    }

    final JLabel captcha = new JLabel(imageIcon);
    captcha.addMouseListener(this);
    captcha.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
    captcha.setToolTipText(this.explain);

    if (this.explain != null) {
      final JTextPane tf = new JTextPane();
      tf.setBorder(null);
      tf.setBackground(null);
      tf.setContentType("text/html");
      tf.setOpaque(false);
      tf.putClientProperty("Synthetica.opaque", Boolean.FALSE);
      tf.setText(this.explain);
      tf.setEditable(false);
      panel.add(tf, "");
    }
    panel.add(captcha, "w pref!, h pref!, alignx center");

    return panel;
  }
Пример #8
0
  /**
   * Sets the reason of a call failure if one occurs. The renderer should display this reason to the
   * user.
   *
   * @param reason the reason to display
   */
  public void setErrorReason(final String reason) {
    if (!SwingUtilities.isEventDispatchThread()) {
      SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {
              setErrorReason(reason);
            }
          });
      return;
    }

    if (errorMessageComponent == null) {
      errorMessageComponent = new JTextPane();

      JTextPane textPane = (JTextPane) errorMessageComponent;
      textPane.setEditable(false);
      textPane.setOpaque(false);

      StyledDocument doc = textPane.getStyledDocument();

      MutableAttributeSet standard = new SimpleAttributeSet();
      StyleConstants.setAlignment(standard, StyleConstants.ALIGN_CENTER);
      StyleConstants.setFontFamily(standard, textPane.getFont().getFamily());
      StyleConstants.setFontSize(standard, 12);
      doc.setParagraphAttributes(0, 0, standard, true);

      GridBagConstraints constraints = new GridBagConstraints();
      constraints.fill = GridBagConstraints.HORIZONTAL;
      constraints.gridx = 0;
      constraints.gridy = 4;
      constraints.weightx = 1;
      constraints.weighty = 0;
      constraints.insets = new Insets(5, 0, 0, 0);

      add(errorMessageComponent, constraints);
      this.revalidate();
    }

    errorMessageComponent.setText(reason);

    if (isVisible()) errorMessageComponent.repaint();
  }
Пример #9
0
  public static void main(String[] args) {
    JFrame fenster = new JFrame("test");
    JButton button = new JButton("Rot");
    JTextPane jtp = new JTextPane();
    jtp.setOpaque(true);

    button.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (jtp.getBackground() == Color.RED) jtp.setBackground(null);
            else jtp.setBackground(Color.RED);
          }
        });

    fenster.add(button, BorderLayout.NORTH);
    fenster.add(jtp, BorderLayout.CENTER);

    fenster.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    fenster.setSize(300, 300);
    fenster.setVisible(true);
  }
Пример #10
0
  /**
   * Lays out the widgets and positions the window in the middle of the screen.
   *
   * @param logo The Frame's background logo.
   * @param version The version of the software.
   * @param serverAvailable Pass <code>true</code> if the client needs to connect to a server,
   *     <code>false</code> otherwise.
   */
  private void buildGUI(Icon logo, String version, boolean serverAvailable) {
    JLabel splash = new JLabel(logo);
    layers = new JLayeredPane();
    layers.add(splash, Integer.valueOf(0));
    getContentPane().add(layers);
    int width = logo.getIconWidth();
    int height = logo.getIconHeight();
    layers.setBounds(0, 0, width, height);
    splash.setBounds(0, 0, width, height);
    int h = progressBar.getFontMetrics(progressBar.getFont()).getHeight();
    int top = 120;
    int bottom = 100;
    currentTask.setBounds(TEXT_INDENT, top, width - 2 * TEXT_INDENT, h);
    top += 20;
    progressBar.setBounds(TEXT_INDENT, top, width - 2 * TEXT_INDENT, h);

    addToLayer(currentTask);
    addToLayer(progressBar);

    mainPanel = new JPanel();
    mainPanel.setOpaque(false);
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
    Font f;
    versionInfo = UIUtilities.buildTextPane(version, FOOT_NOTE_COLOR);
    f = versionInfo.getFont();
    versionInfo.setFont(f.deriveFont(VERSION_FONT_STYLE, f.getSize() - 4));
    versionInfo.setOpaque(false);
    // Add login details.
    int y = height - bottom - 10;
    y = top + 2 * h;
    buildLogin();
    displayComponents(serverAvailable);
    mainPanel.add(UIUtilities.buildComponentPanelCenter(versionInfo, 0, 0, false));
    mainPanel.setBounds(0, y, width, height - top - bottom);
    addToLayer(mainPanel);
  }
Пример #11
0
    @SuppressWarnings("unchecked") // we must be compatible with 1.6
    public VersionManagementPanel(final VisualCanvas canvas) {

      super(canvas);

      setLayout(new GridLayout());

      // TODO @Christian Poliwoda what does manual testing mean?
      // numbers tested manually
      Dimension prefScrollPaneDim = new Dimension(100, 30);
      Dimension visibleRectDim = canvas.getVisibleRect().getSize();

      final VersionController controller =
          canvas.getProjectController().getProject().getProjectFile();

      final int numVersions = controller.getNumberOfVersions() - 1;

      versionData = new Object[numVersions];

      ArrayList<RevCommit> versions = new ArrayList<RevCommit>();

      try {
        versions = controller.getVersions();
      } catch (IOException ex) {
        Logger.getLogger(VersionManagementPanel.class.getName()).log(Level.SEVERE, null, ex);
      }

      int maxTextwidth = 0;
      String longestText = null;

      // the history with timestamp and a short commit message
      for (int i = 1; i < versions.size(); i++) {
        String text =
            // + Message.generateHTMLSpace(3)
            new Date(versions.get(i).getCommitTime() * 1000L)
                + ": "
                + versions.get(i).getShortMessage();

        // truncate texts that are too long
        int maxTextLength = 100;
        String dots = "...";

        int textLength = text.length() - dots.length();

        if (textLength > maxTextLength) {
          text = text.substring(0, maxTextLength) + dots;
        }

        versionData[versions.size() - i - 1] = new Version(text, i);

        if (text.length() > maxTextwidth) {
          maxTextwidth = text.length();
          longestText = text;
        }
      }

      resultModel = new DefaultListModel();

      // first init to show all if search not started yet
      for (int i = 0; i < versionData.length; i++) {
        resultModel.addElement(versionData[i]);
      }

      versionList = new JList(resultModel);

      // set the width of version managment window
      // dependent on largest git short message length
      double maxFontWidth =
          versionList
              .getFontMetrics(versionList.getFont())
              .getStringBounds(longestText, versionList.getGraphics())
              .getWidth();

      if (maxFontWidth <= visibleRectDim.width) {

        prefScrollPaneDim.width = (int) maxFontWidth;
      } else {

        if (visibleRectDim.width < 400) {
          prefScrollPaneDim.width = visibleRectDim.width;
        } else {
          prefScrollPaneDim.width = 400;
        }
      }

      versionList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

      versionList.setOpaque(false);

      versionList.setBackground(VSwingUtil.TRANSPARENT_COLOR);
      versionList.setBorder(new EmptyBorder(3, 3, 3, 3));

      Box upperTopBox = Box.createVerticalBox();

      // press the commits to top with VerticalGlue
      // contains search area at top and
      // search results at the botton
      Box upperOuterBox = Box.createVerticalBox();

      JButton searchButton = new JButton("search");
      searchButton.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent ae) {
              searchAndAddToResultList();
            }
          });

      searchField = new JTextArea();

      // search area box
      Box upperBox1 = Box.createHorizontalBox();

      upperBox1.add(searchField);
      upperBox1.add(searchButton);

      Dimension fieldDim = new Dimension(Short.MAX_VALUE, searchField.getPreferredSize().height);
      searchField.setMaximumSize(fieldDim);

      searchField.addKeyListener(
          new KeyAdapter() {
            String tmp = "";

            @Override
            public void keyReleased(KeyEvent ke) {

              searchAndAddToResultList();
            }
          });

      //            upperOuterBox.add(upperBox1);
      upperTopBox.add(upperBox1);
      upperTopBox.add(upperOuterBox);

      // result area box
      Box upperBox2 = Box.createHorizontalBox();

      upperBox2.add(Box.createHorizontalGlue());
      upperBox2.add(versionList);
      upperBox2.add(Box.createHorizontalGlue());

      upperOuterBox.add(upperBox2);
      upperOuterBox.add(Box.createVerticalGlue());

      // added for optical reasons to force correct scrollbar position
      Box upperInnerBorderPane = Box.createHorizontalBox();
      upperInnerBorderPane.add(upperOuterBox);
      upperInnerBorderPane.setBorder(new EmptyBorder(5, 15, 5, 15));
      upperInnerBorderPane.setBackground(VSwingUtil.TRANSPARENT_COLOR);

      VScrollPane upperScrollPane = new VScrollPane(upperInnerBorderPane);
      upperScrollPane.setHorizontalScrollBarPolicy(VScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
      upperScrollPane.setVerticalScrollBarPolicy(VScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
      upperScrollPane.setMinimumSize(prefScrollPaneDim);

      JSplitPane splitPane = new VSplitPane(JSplitPane.VERTICAL_SPLIT);
      splitPane.setEnabled(true); // true = transparent
      splitPane.setBackground(VSwingUtil.TRANSPARENT_COLOR);
      splitPane.setBorder(new EmptyBorder(5, 5, 5, 5));
      splitPane.setDividerLocation(0.5);

      upperTopBox.add(upperScrollPane);
      splitPane.add(upperTopBox); // add in the upper part

      htmlCommit.setBackground(VSwingUtil.TRANSPARENT_COLOR);
      htmlCommit.setContentType("text/html");
      htmlCommit.setOpaque(false);
      htmlCommit.setEditable(false);
      htmlCommit.setBorder(new EmptyBorder(0, 15, 0, 15));

      Box lowerBox = Box.createVerticalBox();
      lowerBox.setAlignmentX(Component.LEFT_ALIGNMENT);
      lowerBox.add(htmlCommit);
      lowerBox.add(Box.createVerticalGlue());

      VScrollPane lowerScrollPane = new VScrollPane(lowerBox);

      lowerScrollPane.setHorizontalScrollBarPolicy(VScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
      lowerScrollPane.setVerticalScrollBarPolicy(VScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
      lowerScrollPane.setMinimumSize(new Dimension(0, 0));

      // add in the lower part
      splitPane.setBottomComponent(lowerScrollPane);

      add(splitPane);

      versionList.addMouseListener(
          new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {

              // show commit message in lower part if clicked on a row
              // in upper part
              if (e.getClickCount() == 1) {

                final VersionController controller =
                    canvas.getProjectController().getProject().getProjectFile();

                final int numVersions = controller.getNumberOfVersions() - 1;

                ArrayList<RevCommit> versions = new ArrayList<RevCommit>();

                try {
                  versions = controller.getVersions();
                } catch (IOException ex) {
                  Logger.getLogger(VersionManagementPanel.class.getName())
                      .log(Level.SEVERE, null, ex);
                }

                int versionIndex = ((Version) versionList.getSelectedValue()).getVersion();

                htmlCommit.setText(
                    "<html>"
                        + "<pre> <font color=white><br>"
                        + "<b>SHA-1:</b> "
                        + versions.get(versionIndex).getName()
                        + "<br><br>"
                        + "<b>Message:</b><br><br>"
                        + versions.get(versionIndex).getFullMessage()
                        + "</pre></p>"
                        + "</html>");
                htmlCommit.setCaretPosition(0);
              }

              if (e.getClickCount() == 2 && SwingUtilities.isLeftMouseButton(e)) {

                if (((Version) versionList.getSelectedValue()).getVersion() < 2) {
                  VDialog.showMessageDialog(
                      canvas,
                      "Cannot Load Version",
                      "The first version in a project contains no"
                          + " sessions and cannot be loaded!");
                  return;
                }

                //                        if (VDialog.showConfirmDialog(canvas,
                //                                "Checkout Version:",
                //                                "<html><div align=Center>"
                //                                + "<p>Do you want to checkout the selected"
                //                                + " version?<p>"
                //                                + "<p><b>Unsaved changes will be lost!</b></p>"
                //                                + "</div></html>",
                //                                VDialog.DialogType.YES_NO) != VDialog.YES) {
                //                            return;
                //                        }

                int answer =
                    VDialog.showConfirmDialog(
                        canvas,
                        "Checkout Version:",
                        "<html><div align=Center>"
                            + "<p>Checking out selected version.<p><br>"
                            + "<p>Do you want to save the current session?</p><br>"
                            + "<p><b>Unsaved changes will be lost!</b></p>"
                            + "</div></html>",
                        new String[] {"Save", "Discard", "Cancel"});

                if (answer == 0) {
                  try {
                    canvas.getProjectController().saveProject(false);
                  } catch (IOException ex) {
                    Logger.getLogger(VersionManagement.class.getName()).log(Level.SEVERE, null, ex);

                    VDialog.showMessageDialog(
                        canvas,
                        "Cannot save Project:",
                        "<html><div align=Center>" + "Project cannot be saved!" + "</div></html>");
                  }
                } else if (answer == 1) {
                  // nothing to do
                } else if (answer == 2) {
                  return;
                }

                try {

                  int versionIndex = ((Version) versionList.getSelectedValue()).getVersion();

                  canvas.setActive(false);

                  String currentSessionName = canvas.getProjectController().getCurrentSession();

                  canvas.getProjectController().close(currentSessionName);

                  controller.checkoutVersion(versionIndex);

                  if (dialog != null) {
                    dialog.close();
                    dialog = null;
                  }

                  if (canvas
                      .getProjectController()
                      .getProject()
                      .getSessionFileByEntryName(currentSessionName)
                      .exists()) {
                    canvas.getProjectController().open(currentSessionName, false, true);
                  } else {
                    //                                VDialog.showMessageDialog(canvas,
                    //                                        "Cannot load \""
                    //                                        + currentSessionName
                    //                                        +"\":", "<html><div align=Center>"
                    //                                        + "<p>The Session "
                    //                                        + Message.EMPHASIZE_BEGIN
                    //                                        + currentSessionName
                    //                                         +  Message.EMPHASIZE_END
                    //                                        + " does not exist in the current"
                    //                                        + " version."
                    //                                        + "<p>The <b>Main</b>-Session will"
                    //                                        + "be loaded instead</div></html>");
                    canvas.getProjectController().open("Main", false, true);
                  }

                } catch (IOException ex) {
                  Logger.getLogger(VersionManagementPanel.class.getName())
                      .log(Level.SEVERE, null, ex);
                }
              }
            }
          });

      //            setMinimumSize(visibleRectDim);
      setMaximumSize(visibleRectDim);

      int width = getPreferredSize().width;
      setPreferredSize(new Dimension(width, (int) (visibleRectDim.height * 0.5)));
    } // end constructure
Пример #12
0
 private void initGUI() {
   try {
     BorderLayout thisLayout = new BorderLayout();
     this.setLayout(thisLayout);
     this.setPreferredSize(new java.awt.Dimension(691, 416));
     {
       tiltePnl = new JPanel();
       BorderLayout tiltePnlLayout = new BorderLayout();
       tiltePnl.setLayout(tiltePnlLayout);
       this.add(tiltePnl, BorderLayout.NORTH);
       tiltePnl.setPreferredSize(new java.awt.Dimension(691, 51));
       {
         titleTxt = new JTextPane();
         tiltePnl.add(titleTxt, BorderLayout.WEST);
         titleTxt.setText("In welchem Zeitraum soll das Event statt finden?");
         titleTxt.setPreferredSize(new java.awt.Dimension(626, 58));
         titleTxt.setBackground(new java.awt.Color(212, 208, 200));
         titleTxt.setEditable(false);
         titleTxt.setOpaque(false);
         titleTxt.setFont(new java.awt.Font("Segoe UI", 0, 18));
       }
     }
     {
       contentPnl = new JPanel();
       this.add(contentPnl, BorderLayout.CENTER);
       GridBagLayout contentPnlLayout = new GridBagLayout();
       contentPnlLayout.rowWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.1};
       contentPnlLayout.rowHeights = new int[] {20, 50, 50, 50, 50, 50, 50, 5};
       contentPnlLayout.columnWeights = new double[] {0.0, 0.0, 0.2};
       contentPnlLayout.columnWidths = new int[] {30, 400, 5};
       contentPnl.setLayout(contentPnlLayout);
       contentPnl.setPreferredSize(new java.awt.Dimension(635, 277));
       {
         summerbreakBtn = new JRadioButton();
         contentPnl.add(
             summerbreakBtn,
             new GridBagConstraints(
                 1,
                 4,
                 1,
                 1,
                 0.0,
                 0.0,
                 GridBagConstraints.WEST,
                 GridBagConstraints.NONE,
                 new Insets(0, 0, 0, 0),
                 0,
                 0));
         summerbreakBtn.setText("Sommerferien");
         getTimeRangeGroup().add(summerbreakBtn);
       }
       {
         autumbreakBtn = new JRadioButton();
         contentPnl.add(
             autumbreakBtn,
             new GridBagConstraints(
                 1,
                 1,
                 1,
                 1,
                 0.0,
                 0.0,
                 GridBagConstraints.WEST,
                 GridBagConstraints.NONE,
                 new Insets(0, 0, 0, 0),
                 0,
                 0));
         contentPnl.add(
             getWinterbreakBtn(),
             new GridBagConstraints(
                 1,
                 2,
                 1,
                 1,
                 0.0,
                 0.0,
                 GridBagConstraints.WEST,
                 GridBagConstraints.NONE,
                 new Insets(0, 0, 0, 0),
                 0,
                 0));
         contentPnl.add(
             getEasterbreak(),
             new GridBagConstraints(
                 1,
                 3,
                 1,
                 1,
                 0.0,
                 0.0,
                 GridBagConstraints.WEST,
                 GridBagConstraints.NONE,
                 new Insets(0, 0, 0, 0),
                 0,
                 0));
         contentPnl.add(
             getMiscTimeRange(),
             new GridBagConstraints(
                 1,
                 5,
                 1,
                 1,
                 0.0,
                 0.0,
                 GridBagConstraints.WEST,
                 GridBagConstraints.NONE,
                 new Insets(0, 0, 0, 0),
                 0,
                 0));
         contentPnl.add(
             getMiscTimeRangePnl(),
             new GridBagConstraints(
                 1,
                 6,
                 1,
                 1,
                 0.0,
                 0.0,
                 GridBagConstraints.CENTER,
                 GridBagConstraints.BOTH,
                 new Insets(0, 0, 0, 0),
                 0,
                 0));
         autumbreakBtn.setText("Herbstferien");
         getTimeRangeGroup().add(autumbreakBtn);
       }
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
  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;
  }
Пример #14
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);
  }
Пример #15
0
  /** @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();
                    }
                  });
            }
          });
    }
  }
Пример #16
0
  /**
   * Creates an instance of <tt>ShowPreviewDialog</tt>
   *
   * @param chatPanel The <tt>ChatConversationPanel</tt> that is associated with this dialog.
   */
  ShowPreviewDialog(final ChatConversationPanel chatPanel) {
    this.chatPanel = chatPanel;

    this.setTitle(
        GuiActivator.getResources().getI18NString("service.gui.SHOW_PREVIEW_DIALOG_TITLE"));
    okButton = new JButton(GuiActivator.getResources().getI18NString("service.gui.OK"));
    cancelButton = new JButton(GuiActivator.getResources().getI18NString("service.gui.CANCEL"));

    JPanel mainPanel = new TransparentPanel();
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
    mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    // mainPanel.setPreferredSize(new Dimension(200, 150));
    this.getContentPane().add(mainPanel);

    JTextPane descriptionMsg = new JTextPane();
    descriptionMsg.setEditable(false);
    descriptionMsg.setOpaque(false);
    descriptionMsg.setText(
        GuiActivator.getResources().getI18NString("service.gui.SHOW_PREVIEW_WARNING_DESCRIPTION"));

    Icon warningIcon = null;
    try {
      warningIcon =
          new ImageIcon(
              ImageIO.read(
                  GuiActivator.getResources().getImageURL("service.gui.icons.WARNING_ICON")));
    } catch (IOException e) {
      logger.debug("failed to load the warning icon");
    }
    JLabel warningSign = new JLabel(warningIcon);

    JPanel warningPanel = new TransparentPanel();
    warningPanel.setLayout(new BoxLayout(warningPanel, BoxLayout.X_AXIS));
    warningPanel.add(warningSign);
    warningPanel.add(Box.createHorizontalStrut(10));
    warningPanel.add(descriptionMsg);

    enableReplacement =
        new JCheckBox(
            GuiActivator.getResources()
                .getI18NString("plugin.chatconfig.replacement.ENABLE_REPLACEMENT_STATUS"));
    enableReplacement.setOpaque(false);
    enableReplacement.setSelected(cfg.getBoolean(ReplacementProperty.REPLACEMENT_ENABLE, true));
    enableReplacementProposal =
        new JCheckBox(
            GuiActivator.getResources()
                .getI18NString("plugin.chatconfig.replacement.ENABLE_REPLACEMENT_PROPOSAL"));
    enableReplacementProposal.setOpaque(false);

    JPanel checkBoxPanel = new TransparentPanel();
    checkBoxPanel.setLayout(new BoxLayout(checkBoxPanel, BoxLayout.Y_AXIS));
    checkBoxPanel.add(enableReplacement);
    checkBoxPanel.add(enableReplacementProposal);

    JPanel buttonsPanel = new TransparentPanel(new FlowLayout(FlowLayout.CENTER));
    buttonsPanel.add(okButton);
    buttonsPanel.add(cancelButton);

    mainPanel.add(warningPanel);
    mainPanel.add(Box.createVerticalStrut(10));
    mainPanel.add(checkBoxPanel);
    mainPanel.add(buttonsPanel);

    okButton.addActionListener(this);
    cancelButton.addActionListener(this);

    this.setPreferredSize(new Dimension(390, 230));
  }
  /**
   * Instantiates a new movie information panel.
   *
   * @param movieSelectionModel the movie selection model
   */
  public MovieInformationPanel(MovieSelectionModel movieSelectionModel) {
    this.movieSelectionModel = movieSelectionModel;

    setLayout(
        new FormLayout(
            new ColumnSpec[] {
              ColumnSpec.decode("450px:grow"),
            },
            new RowSpec[] {
              RowSpec.decode("fill:default:grow"),
            }));

    splitPaneVertical = new JSplitPane();
    splitPaneVertical.setBorder(null);
    splitPaneVertical.setResizeWeight(0.9);
    splitPaneVertical.setContinuousLayout(true);
    splitPaneVertical.setOneTouchExpandable(true);
    splitPaneVertical.setOrientation(JSplitPane.VERTICAL_SPLIT);
    add(splitPaneVertical, "1, 1, fill, fill");

    panelTop = new JPanel();
    panelTop.setBorder(null);
    splitPaneVertical.setTopComponent(panelTop);
    panelTop.setLayout(
        new FormLayout(
            new ColumnSpec[] {
              FormFactory.RELATED_GAP_COLSPEC,
              ColumnSpec.decode("200px:grow"),
              FormFactory.RELATED_GAP_COLSPEC,
              FormFactory.DEFAULT_COLSPEC,
            },
            new RowSpec[] {
              RowSpec.decode("fill:default"), RowSpec.decode("top:pref:grow"),
            }));

    JPanel panelMovieHeader = new JPanel();
    panelTop.add(panelMovieHeader, "2, 1, 3, 1, fill, top");
    panelMovieHeader.setBorder(null);
    panelMovieHeader.setLayout(new BorderLayout(0, 0));

    JPanel panelMovieTitle = new JPanel();
    panelMovieHeader.add(panelMovieTitle, BorderLayout.NORTH);
    panelMovieTitle.setLayout(new BorderLayout(0, 0));
    lblMovieName = new JLabel("");
    TmmFontHelper.changeFont(lblMovieName, 1.33, Font.BOLD);
    panelMovieTitle.add(lblMovieName);

    JPanel panelRatingTagline = new JPanel();
    panelMovieHeader.add(panelRatingTagline, BorderLayout.CENTER);
    panelRatingTagline.setLayout(
        new FormLayout(
            new ColumnSpec[] {
              FormFactory.DEFAULT_COLSPEC,
              FormFactory.DEFAULT_COLSPEC,
              FormFactory.DEFAULT_COLSPEC,
              FormFactory.UNRELATED_GAP_COLSPEC,
              ColumnSpec.decode("25px:grow"),
            },
            new RowSpec[] {
              FormFactory.LINE_GAP_ROWSPEC, RowSpec.decode("24px"), FormFactory.DEFAULT_ROWSPEC,
            }));

    lblRating = new JLabel("");
    panelRatingTagline.add(lblRating, "2, 2, left, center");

    lblVoteCount = new JLabel("");
    panelRatingTagline.add(lblVoteCount, "3, 2, left, center");

    panelRatingStars = new StarRater(10, 1);
    panelRatingTagline.add(panelRatingStars, "1, 2, left, top");
    panelRatingStars.setEnabled(false);

    lblTop250 = new JLabel("");
    panelRatingTagline.add(lblTop250, "5, 2, left, default");

    lblTagline = new JLabel();
    panelRatingTagline.add(lblTagline, "1, 3, 5, 1, default, center");

    panelMovieLogos = new JPanel();
    panelMovieHeader.add(panelMovieLogos, BorderLayout.EAST);

    lblCertificationImage = new JLabel();
    panelMovieLogos.add(lblCertificationImage);

    JLayeredPane layeredPaneImages = new JLayeredPane();
    panelTop.add(layeredPaneImages, "1, 2, 4, 1, fill, fill");
    layeredPaneImages.setLayout(
        new FormLayout(
            new ColumnSpec[] {
              ColumnSpec.decode("max(10px;default)"),
              ColumnSpec.decode("left:120px:grow"),
              ColumnSpec.decode("default:grow(10)"),
            },
            new RowSpec[] {
              RowSpec.decode("max(10px;default)"),
              RowSpec.decode("top:180px:grow"),
              RowSpec.decode("fill:80px:grow(3)"),
            }));

    lblMovieBackground = new ImageLabel(false, true);
    lblMovieBackground.setAlternativeText(BUNDLE.getString("image.notfound.fanart")); // $NON-NLS-1$
    lblMovieBackground.enableLightbox();
    layeredPaneImages.add(lblMovieBackground, "1, 1, 3, 3, fill, fill");

    lblMoviePoster = new ImageLabel();
    lblMoviePoster.setAlternativeText(BUNDLE.getString("image.notfound.poster")); // $NON-NLS-1$
    lblMoviePoster.enableLightbox();
    layeredPaneImages.setLayer(lblMoviePoster, 1);
    layeredPaneImages.add(lblMoviePoster, "2, 2, fill, fill");

    lblWatchedImage = new JLabel();
    lblWatchedImage.setOpaque(false);
    layeredPaneImages.setLayer(lblWatchedImage, 2);
    layeredPaneImages.add(lblWatchedImage, "2, 2, left, top");

    JPanel panelGenres = new MovieGenresPanel(movieSelectionModel);
    layeredPaneImages.setLayer(panelGenres, 2);
    layeredPaneImages.add(panelGenres, "2, 2, 2, 2, right, bottom");

    JPanel panelLogos = new JPanel();
    panelLogos.setOpaque(false);
    layeredPaneImages.setLayer(panelLogos, 2);
    layeredPaneImages.add(panelLogos, "2, 2, 2, 2, right, top");
    panelLogos.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));

    lblMediaLogoResolution = new JLabel("");
    panelLogos.add(lblMediaLogoResolution);

    lblMediaLogoVideoCodec = new JLabel("");
    panelLogos.add(lblMediaLogoVideoCodec);

    lblMediaLogoAudio = new JLabel("");
    panelLogos.add(lblMediaLogoAudio);

    JPanel panelBottom = new JPanel();
    panelBottom.setLayout(
        new FormLayout(
            new ColumnSpec[] {
              ColumnSpec.decode("300px:grow"),
            },
            new RowSpec[] {
              FormFactory.LINE_GAP_ROWSPEC, RowSpec.decode("fill:min:grow"),
            }));

    tabbedPaneMovieDetails = new JTabbedPane(JTabbedPane.TOP);
    panelBottom.add(tabbedPaneMovieDetails, "1, 2, fill, fill");
    splitPaneVertical.setBottomComponent(panelBottom);

    panelDetails = new MovieDetailsPanel(movieSelectionModel);
    tabbedPaneMovieDetails.addTab(
        BUNDLE.getString("metatag.details"), null, panelDetails, null); // $NON-NLS-1$

    panelOverview = new JPanel();
    tabbedPaneMovieDetails.addTab(
        BUNDLE.getString("metatag.plot"), null, panelOverview, null); // $NON-NLS-1$
    panelOverview.setLayout(
        new FormLayout(
            new ColumnSpec[] {
              ColumnSpec.decode("200px:grow"),
            },
            new RowSpec[] {
              FormFactory.LINE_GAP_ROWSPEC, RowSpec.decode("fill:default:grow"),
            }));
    // panelMovieDetails.add(tabbedPaneMovieDetails, "2, 3, fill, fill");

    JScrollPane scrollPaneOverview = new JScrollPane();
    scrollPaneOverview.setBorder(null);
    panelOverview.add(scrollPaneOverview, "1, 2, fill, fill");

    tpOverview = new JTextPane();
    tpOverview.setOpaque(false);
    tpOverview.setEditable(false);
    scrollPaneOverview.setViewportView(tpOverview);

    panelMovieCrew = new MovieCrewPanel(movieSelectionModel);
    tabbedPaneMovieDetails.addTab(
        BUNDLE.getString("metatag.crew"), null, panelMovieCrew, null); // $NON-NLS-1$

    MovieActorPanel panelMovieActors = new MovieActorPanel(movieSelectionModel);
    tabbedPaneMovieDetails.addTab(
        BUNDLE.getString("metatag.cast"), null, panelMovieActors, null); // $NON-NLS-1$

    panelMediaInformation = new MovieMediaInformationPanel(movieSelectionModel);
    tabbedPaneMovieDetails.addTab(
        BUNDLE.getString("metatag.mediainformation"),
        null,
        panelMediaInformation,
        null); //$NON-NLS-1$

    panelMediaFiles = new MovieMediaFilesPanel(movieSelectionModel);
    tabbedPaneMovieDetails.addTab(
        BUNDLE.getString("metatag.mediafiles"), null, panelMediaFiles, null); // $NON-NLS-1$

    final List<MediaFile> mediaFiles = new ArrayList<MediaFile>();
    final ImagePanel panelArtwork = new ImagePanel(mediaFiles);
    tabbedPaneMovieDetails.addTab(
        BUNDLE.getString("metatag.artwork"), null, panelArtwork, null); // $NON-NLS-1$

    panelMovieTrailer = new MovieTrailerPanel(movieSelectionModel);
    tabbedPaneMovieDetails.addTab(
        BUNDLE.getString("metatag.trailer"), null, panelMovieTrailer, null); // $NON-NLS-1$

    // beansbinding init
    initDataBindings();

    // manual coded binding
    PropertyChangeListener propertyChangeListener =
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent propertyChangeEvent) {
            String property = propertyChangeEvent.getPropertyName();
            Object source = propertyChangeEvent.getSource();
            // react on selection of a movie and change of a movie
            if (source instanceof MovieSelectionModel
                || (source instanceof Movie && MEDIA_FILES.equals(property))) {
              Movie movie = null;
              if (source instanceof MovieSelectionModel) {
                movie = ((MovieSelectionModel) source).getSelectedMovie();
              }
              if (source instanceof Movie) {
                movie = (Movie) source;
              }

              if (movie != null) {
                if (movie.getTop250() > 0) {
                  lblTop250.setText("Top 250: #" + movie.getTop250());
                } else {
                  lblTop250.setText("");
                }
                lblMovieBackground.setImagePath(movie.getArtworkFilename(MediaFileType.FANART));
                lblMoviePoster.setImagePath(movie.getArtworkFilename(MediaFileType.POSTER));

                synchronized (mediaFiles) {
                  mediaFiles.clear();
                  for (MediaFile mediafile : movie.getMediaFiles()) {
                    if (mediafile.isGraphic()) {
                      mediaFiles.add(mediafile);
                    }
                  }
                  panelArtwork.rebuildPanel();
                }
              }
            }
            if ((source.getClass() == Movie.class && FANART.equals(property))) {
              Movie movie = (Movie) source;
              lblMovieBackground.clearImage();
              lblMovieBackground.setImagePath(movie.getArtworkFilename(MediaFileType.FANART));
            }
            if ((source.getClass() == Movie.class && POSTER.equals(property))) {
              Movie movie = (Movie) source;
              lblMoviePoster.clearImage();
              lblMoviePoster.setImagePath(movie.getArtworkFilename(MediaFileType.POSTER));
            }
            if ((source.getClass() == Movie.class && TOP250.equals(property))) {
              Movie movie = (Movie) source;
              if (movie.getTop250() > 0) {
                lblTop250.setText(
                    BUNDLE.getString("metatag.top250") + ": #" + movie.getTop250()); // $NON-NLS-1$
              } else {
                lblTop250.setText("");
              }
            }
          }
        };

    movieSelectionModel.addPropertyChangeListener(propertyChangeListener);
  }
Пример #18
0
 void formatTextAreaAsLabel(JTextPane pane) {
   pane.setOpaque(false);
   pane.setEditable(false);
   pane.setBorder(null);
 }
Пример #19
0
  // Experience suggests that one should avoid using weights when using the
  // GridBagLayout. I find that nonzero weights can cause layout bugs that are
  // hard to track down. [Jon Aquino]
  void jbInit() throws Exception {
    _descriptionTextArea.setOpaque(false);
    get_okCancelPanel()
        .addActionListener(
            new java.awt.event.ActionListener() {
              public void actionPerformed(ActionEvent e) {
                okCancelPanel_actionPerformed(e);
              }
            });
    this.addComponentListener(
        new java.awt.event.ComponentAdapter() {
          public void componentShown(ComponentEvent e) {
            this_componentShown(e);
          }
        });

    // _outerMainPanel.setLayout(new GridBagLayout());
    // _outerMainPanel.setAlignmentX((float) 0.7);
    _outerMainPanel.setLayout(new BorderLayout());
    this.setResizable(true);
    this.getContentPane().setLayout(new BorderLayout());
    _imagePanel.setBorder(BorderFactory.createEtchedBorder());
    _imagePanel.setLayout(new GridBagLayout());
    _mainPanel.setLayout(new BorderLayout());
    try {
      _descriptionTextArea.setPreferredSize(new Dimension(100, 100));
      _descriptionTextArea.setOpaque(false);
      _descriptionTextArea.setEnabled(false);
      _descriptionTextArea.setEditable(false);
      _descriptionTextArea.setContentType("text/html");
    } catch (RuntimeException e1) {
      // Problemas para instanciar el kit text/html en el Plugin
      logger.error("jbInit()", e1);
      if (logger.isDebugEnabled()) {
        logger.debug(
            "jbInit() - La clase a instanciar para html es:"
                + _descriptionTextArea.getEditorKitForContentType("text/html"));
      }
    }

    documentExtendedForm = new DocumentExtendedForm();
    documentExtendedForm.initialize(this);
    setDescription();
    _imagePanel.add(
        _descriptionTextArea,
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            0.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH,
            new Insets(10, 10, 10, 10),
            0,
            0));

    _imagePanel.add(
        _infoFeatures,
        new GridBagConstraints(
            0,
            2,
            1,
            1,
            0.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH,
            new Insets(10, 10, 10, 10),
            0,
            0));
    _imagePanel.add(
        _strutPanel,
        new GridBagConstraints(
            0,
            20,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 0, 0, 0),
            0,
            0));
    _outerMainPanel.add(_mainPanel, BorderLayout.CENTER);
    _outerMainPanel.add(_imagePanel, BorderLayout.WEST);

    _descriptionTextArea.setFont(_imageLabel.getFont());
    _descriptionTextArea.setDisabledTextColor(_imageLabel.getForeground());
    if (features.size() > 1) _infoFeatures.add(getFeaturesComboBox(), null);
    this.setContentPane(getContentPanel()); // Generated
    _strutPanel.add(getZoomFeatureButton(), null); // Generated
    _strutPanel.add(getFlashFeatureButton(), null); // Generated
  }
  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);
  }
Пример #21
0
  private void initialize() {
    setFont(new Font("Arial", Font.PLAIN, 14));
    setBackground(new Color(204, 51, 153));
    setSize(new Dimension(750, 500));
    setLayout(null);

    // main pic
    final JLabel lblMainPic = new JLabel("");
    lblMainPic.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0)));
    lblMainPic.setIcon(new ImageIcon(Packages.class.getResource("/images/wedding.jpg")));
    lblMainPic.setOpaque(true);
    lblMainPic.setHorizontalTextPosition(SwingConstants.CENTER);
    lblMainPic.setForeground(new Color(0, 0, 0));
    lblMainPic.setHorizontalAlignment(SwingConstants.CENTER);
    lblMainPic.setBackground(new Color(240, 255, 255));
    lblMainPic.setBounds(304, 53, 200, 200);
    add(lblMainPic);

    // wedding button
    JButton btnNewButton = new JButton("");

    btnNewButton.setIcon(new ImageIcon(Packages.class.getResource("/images/wedding resized.jpg")));
    btnNewButton.setMargin(new Insets(2, 0, 2, 0));
    btnNewButton.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0)));
    btnNewButton.setAlignmentX(Component.CENTER_ALIGNMENT);
    btnNewButton.setHorizontalTextPosition(SwingConstants.CENTER);
    btnNewButton.setBounds(304, 264, 50, 50);
    add(btnNewButton);
    btnNewButton.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent arg0) {
            lblMainPic.setIcon(new ImageIcon(Packages.class.getResource("/images/wedding.jpg")));
          }
        });

    // party button
    JButton button = new JButton("");

    button.setIcon(new ImageIcon(Packages.class.getResource("/images/party resized.jpg")));
    button.setMargin(new Insets(2, 0, 2, 0));
    button.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0)));
    button.setHorizontalTextPosition(SwingConstants.CENTER);
    button.setAlignmentX(0.5f);
    button.setBounds(376, 264, 50, 50);
    add(button);
    button.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            lblMainPic.setIcon(new ImageIcon(Packages.class.getResource("/images/party.jpg")));
          }
        });

    // company dinner button
    JButton button_1 = new JButton("");

    button_1.setIcon(
        new ImageIcon(Packages.class.getResource("/images/company dinner resized.jpg")));
    button_1.setMargin(new Insets(2, 0, 2, 0));
    button_1.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0)));
    button_1.setHorizontalTextPosition(SwingConstants.CENTER);
    button_1.setAlignmentX(0.5f);
    button_1.setBounds(454, 264, 50, 50);
    add(button_1);
    button_1.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            lblMainPic.setIcon(
                new ImageIcon(Packages.class.getResource("/images/company dinner.jpg")));
          }
        });

    JLabel lblPackages = new JLabel("Packages");
    lblPackages.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0)));
    lblPackages.setForeground(new Color(255, 255, 255));
    lblPackages.setBackground(new Color(153, 51, 153));
    lblPackages.setFont(new Font("Arial", Font.BOLD, 15));
    lblPackages.setHorizontalTextPosition(SwingConstants.CENTER);
    lblPackages.setHorizontalAlignment(SwingConstants.CENTER);
    lblPackages.setAlignmentX(Component.CENTER_ALIGNMENT);
    lblPackages.setOpaque(true);
    lblPackages.setBounds(89, 327, 100, 40);
    add(lblPackages);

    JLabel lblMeetingRm = new JLabel("\u2022\tWeddings");
    lblMeetingRm.setHorizontalAlignment(SwingConstants.LEFT);
    lblMeetingRm.setFont(new Font("Arial", Font.PLAIN, 14));
    lblMeetingRm.setForeground(new Color(0, 0, 0));
    lblMeetingRm.setHorizontalTextPosition(SwingConstants.CENTER);
    lblMeetingRm.setBounds(89, 378, 100, 24);
    add(lblMeetingRm);

    JLabel lblActivityRm = new JLabel("\u2022\tParty");
    lblActivityRm.setHorizontalTextPosition(SwingConstants.CENTER);
    lblActivityRm.setHorizontalAlignment(SwingConstants.LEFT);
    lblActivityRm.setForeground(new Color(0, 0, 0));
    lblActivityRm.setFont(new Font("Arial", Font.PLAIN, 14));
    lblActivityRm.setBounds(89, 413, 100, 24);
    add(lblActivityRm);

    JLabel lblHall = new JLabel("\u2022\tCompany Dinner");
    lblHall.setHorizontalTextPosition(SwingConstants.CENTER);
    lblHall.setHorizontalAlignment(SwingConstants.LEFT);
    lblHall.setForeground(new Color(0, 0, 0));
    lblHall.setFont(new Font("Arial", Font.PLAIN, 14));
    lblHall.setBounds(89, 448, 119, 24);
    add(lblHall);

    JLabel lblPrices = new JLabel("Prices");
    lblPrices.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0)));
    lblPrices.setHorizontalTextPosition(SwingConstants.CENTER);
    lblPrices.setHorizontalAlignment(SwingConstants.CENTER);
    lblPrices.setForeground(new Color(255, 255, 255));
    lblPrices.setFont(new Font("Arial", Font.BOLD, 15));
    lblPrices.setOpaque(true);
    lblPrices.setBackground(new Color(153, 51, 153));
    lblPrices.setBounds(234, 327, 100, 40);
    add(lblPrices);

    JLabel lblMeetingPrice = new JLabel("$40,000");
    lblMeetingPrice.setForeground(new Color(0, 0, 0));
    lblMeetingPrice.setFont(new Font("Arial", Font.PLAIN, 14));
    lblMeetingPrice.setBounds(244, 378, 90, 24);
    add(lblMeetingPrice);

    JLabel lblActivityPrice = new JLabel("$6,000");
    lblActivityPrice.setFont(new Font("Arial", Font.PLAIN, 14));
    lblActivityPrice.setForeground(new Color(0, 0, 0));
    lblActivityPrice.setBounds(244, 416, 90, 19);
    add(lblActivityPrice);

    JLabel lblHallPrice = new JLabel("$15,000");
    lblHallPrice.setFont(new Font("Arial", Font.PLAIN, 14));
    lblHallPrice.setForeground(new Color(0, 0, 0));
    lblHallPrice.setBounds(244, 451, 90, 19);
    add(lblHallPrice);

    JLabel lblDesc = new JLabel("Description");
    lblDesc.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0)));
    lblDesc.setBackground(new Color(153, 51, 153));
    lblDesc.setOpaque(true);
    lblDesc.setHorizontalTextPosition(SwingConstants.CENTER);
    lblDesc.setHorizontalAlignment(SwingConstants.CENTER);
    lblDesc.setForeground(new Color(255, 255, 255));
    lblDesc.setFont(new Font("Arial", Font.BOLD, 15));
    lblDesc.setBounds(416, 325, 306, 40);
    add(lblDesc);

    JTextPane txtpnDescTxt = new JTextPane();
    txtpnDescTxt.setFont(new Font("Arial", Font.PLAIN, 14));
    txtpnDescTxt.setForeground(new Color(0, 0, 0));
    txtpnDescTxt.setOpaque(false);
    txtpnDescTxt.setText(
        "Our packages includes services from our experienced staff and the venue where is occasion is taking place. Please approach the receptionist to book a package or for further enquires.");
    txtpnDescTxt.setBounds(416, 377, 306, 112);
    add(txtpnDescTxt);

    JLabel lblPackages_1 = new JLabel("Packages");
    lblPackages_1.setFont(new Font("Tahoma", Font.PLAIN, 30));
    lblPackages_1.setBounds(484, 0, 157, 43);
    add(lblPackages_1);
  }
Пример #22
0
  private void addCenterPanel(GridBagConstraints mainPanelConstraints) {
    JPanel panel = new JPanel(new GridBagLayout());
    panel.setBorder(BorderFactory.createEtchedBorder());
    add(panel, mainPanelConstraints);

    GridBagConstraints panelConstraints = new GridBagConstraints();

    panelConstraints.gridx = 0;
    panelConstraints.gridy = 0;
    panelConstraints.fill = GridBagConstraints.HORIZONTAL;
    panelConstraints.anchor = GridBagConstraints.PAGE_START;
    panelConstraints.weighty = 0;
    panelConstraints.weightx = 0;
    panelConstraints.insets = new Insets(10, 10, 10, 10);

    panelConstraints.gridwidth = 2;

    SimpleAttributeSet plain = new SimpleAttributeSet();
    StyleConstants.setForeground(plain, Color.black);
    StyleConstants.setBold(plain, false);

    SimpleAttributeSet bold = new SimpleAttributeSet();
    StyleConstants.setForeground(bold, Color.black);
    StyleConstants.setBold(bold, true);

    JTextPane header = new JTextPane();
    header.setEditable(false);
    header.setOpaque(false);
    Document doc = header.getDocument();
    try {
      doc.insertString(0, "A new version of JPedal is available.", bold);
    } catch (BadLocationException e) {
      e.printStackTrace();
    }
    panel.add(header, panelConstraints);

    panelConstraints.gridwidth = 1;
    panelConstraints.gridy = 1;
    panelConstraints.insets = new Insets(10, 10, 0, 10);
    JTextPane currentVersionLabel = new JTextPane();
    currentVersionLabel.setEditable(false);
    currentVersionLabel.setOpaque(false);
    doc = currentVersionLabel.getDocument();
    try {
      doc.insertString(0, "Your current version:", plain);
    } catch (BadLocationException e) {
      e.printStackTrace();
    }
    currentVersionLabel.setMinimumSize(currentVersionLabel.getPreferredSize());
    panel.add(currentVersionLabel, panelConstraints);

    panelConstraints.weightx = 1;
    panelConstraints.gridx = 1;
    JTextPane currentVersionPane = new JTextPane();
    currentVersionPane.setEditable(false);
    currentVersionPane.setOpaque(false);
    doc = currentVersionPane.getDocument();
    try {
      doc.insertString(0, currentVersion, plain);
    } catch (BadLocationException e) {
      e.printStackTrace();
    }
    panel.add(currentVersionPane, panelConstraints);

    panelConstraints.insets = new Insets(0, 10, 10, 10);
    panelConstraints.weightx = 0;
    panelConstraints.gridx = 0;
    panelConstraints.gridy = 2;
    JTextPane availableVersionLabel = new JTextPane();
    availableVersionLabel.setEditable(false);
    availableVersionLabel.setOpaque(false);
    doc = availableVersionLabel.getDocument();
    try {
      doc.insertString(0, "Available Version:", plain);
    } catch (BadLocationException e) {
      e.printStackTrace();
    }
    panel.add(availableVersionLabel, panelConstraints);

    panelConstraints.gridwidth = 2;
    panelConstraints.weightx = 1;
    panelConstraints.gridx = 1;
    JTextPane availableVersionPane = new JTextPane();
    availableVersionPane.setEditable(false);
    availableVersionPane.setOpaque(false);
    doc = availableVersionPane.getDocument();
    try {
      doc.insertString(0, availableVersion, plain);
    } catch (BadLocationException e) {
      e.printStackTrace();
    }
    panel.add(availableVersionPane, panelConstraints);

    panelConstraints.insets = new Insets(10, 10, 10, 10);
    panelConstraints.weightx = 0;
    panelConstraints.gridx = 0;
    panelConstraints.gridy = 3;
    JTextPane moreInfo = new JTextPane();
    moreInfo.setEditable(false);
    moreInfo.setOpaque(false);
    doc = moreInfo.getDocument();
    try {
      doc.insertString(0, "Press ", plain);
      doc.insertString(doc.getLength(), "More info... ", bold);
      doc.insertString(
          doc.getLength(),
          "to open a web page where you can download JPedal or learn more about the new version",
          plain);
    } catch (BadLocationException e) {
      e.printStackTrace();
    }

    panel.add(moreInfo, panelConstraints);

    panelConstraints.gridy = 4;
    JTextPane configure = new JTextPane();
    doc = configure.getDocument();
    try {
      doc.insertString(0, "To configure automatic updates settings, see ", plain);
      doc.insertString(doc.getLength(), "View | Preferences", bold);
    } catch (BadLocationException e) {
      e.printStackTrace();
    }
    configure.setEditable(false);
    configure.setOpaque(false);

    panel.add(configure, panelConstraints);

    panelConstraints.weighty = 1;
    panelConstraints.gridy = 5;
    JTextPane manual = new JTextPane();
    doc = manual.getDocument();
    try {
      doc.insertString(0, "To check for new updates manually, use ", plain);
      doc.insertString(doc.getLength(), "Help | Check for Updates", bold);
    } catch (BadLocationException e) {
      e.printStackTrace();
    }
    manual.setEditable(false);
    manual.setOpaque(false);

    panel.add(manual, panelConstraints);
  }
Пример #23
0
  protected void buildErrorPanel() {
    errorPanel = new JPanel();
    GroupLayout layout = new GroupLayout(errorPanel);
    layout.setAutoCreateGaps(true);
    layout.setAutoCreateContainerGaps(true);
    errorPanel.setLayout(layout);
    //    errorPanel.setBorder(BorderFactory.createMatteBorder(2, 0, 0, 0, Color.BLACK));
    errorMessage = new JTextPane();
    errorMessage.setEditable(false);
    errorMessage.setContentType("text/html");
    errorMessage.setText(
        "<html><body>Could not connect to the Processing server.<br>"
            + "Contributions cannot be installed or updated without an Internet connection.<br>"
            + "Please verify your network connection again, then try connecting again.</body></html>");
    errorMessage.setFont(Toolkit.getSansFont(14, Font.PLAIN));
    errorMessage.setMaximumSize(new Dimension(550, 50));
    errorMessage.setOpaque(false);

    StyledDocument doc = errorMessage.getStyledDocument();
    SimpleAttributeSet center = new SimpleAttributeSet();
    StyleConstants.setAlignment(center, StyleConstants.ALIGN_CENTER);
    doc.setParagraphAttributes(0, doc.getLength(), center, false);

    closeButton = new JButton("X");
    closeButton.setContentAreaFilled(false);
    closeButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            contribDialog.makeAndShowTab(false, false);
          }
        });
    tryAgainButton = new JButton("Try Again");
    tryAgainButton.setFont(Toolkit.getSansFont(14, Font.PLAIN));
    tryAgainButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            contribDialog.makeAndShowTab(false, true);
            contribDialog.downloadAndUpdateContributionListing(editor.getBase());
          }
        });
    layout.setHorizontalGroup(
        layout
            .createSequentialGroup()
            .addPreferredGap(
                LayoutStyle.ComponentPlacement.RELATED, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.CENTER)
                    .addComponent(errorMessage)
                    .addComponent(
                        tryAgainButton,
                        StatusPanel.BUTTON_WIDTH,
                        StatusPanel.BUTTON_WIDTH,
                        StatusPanel.BUTTON_WIDTH))
            .addPreferredGap(
                LayoutStyle.ComponentPlacement.RELATED, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)
            .addComponent(closeButton));
    layout.setVerticalGroup(
        layout
            .createSequentialGroup()
            .addGroup(
                layout.createParallelGroup().addComponent(errorMessage).addComponent(closeButton))
            .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
            .addComponent(tryAgainButton));
    errorPanel.setBackground(Color.PINK);
    errorPanel.validate();
  }
Пример #24
0
    public ChatPanel(final Client client) {
        this.client = client;

        input = new JTextField();
        //prevent unintended focus (by window activate etc. - allow focus just on direct click)
        input.setFocusable(false);
        input.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                activateChat();
            }
        });
        input.addKeyListener(new KeyAdapter() {
            @Override
            public void keyPressed(KeyEvent e) {
                if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
                    clean();
                }
            }
        });
        input.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                String msg = input.getText();
                if (!"".equals(msg)) {
                    forceFocus = true; //prevent panel flashing
                    client.getConnection().send(createPostChatMessage(msg));
                }
                clean();
            }
        });
        input.addFocusListener(new FocusListener() {
            @Override
            public void focusLost(FocusEvent e) {
                updateMessaagesVisibility();
            }

            @Override
            public void focusGained(FocusEvent e) {
                updateMessaagesVisibility();
            }
        });

        input.setOpaque(false);
        input.setBackground(client.getTheme().getTransparentInputBg());
        Color textColor = client.getTheme().getTextColor();
        if (textColor != null) {
            input.setForeground(client.getTheme().getTextColor());
            input.setCaretColor(client.getTheme().getTextColor());
        }
        TextPrompt tp = new TextPrompt(_("Type to chat"), input);
        tp.setShow(Show.FOCUS_LOST);
        tp.changeStyle(Font.ITALIC);
        tp.changeAlpha(0.4f);

        messagesPane = new JTextPane();
        messagesPane.setEditorKit(new WrapEditorKit());
        messagesPane.setFocusable(false);
        messagesPane.setOpaque(false);

        setBackground(client.getTheme().getTransparentPanelBg());
        setLayout(new MigLayout(""));
        add(messagesPane, "pos 10 n (100%-10) (100%-35)");
        add(input, "pos 10 (100%-35) (100%-10) (100%-10)");
    }