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();
  }
Exemple #2
0
    public DocumentPanel() {
      super(new BorderLayout());

      JLabel lblDocument = new JLabel("Document: " + document.getTitle());
      lblDocument.setBorder(new EtchedBorder());

      textPane = new JTextPane(document);
      textPane.setEditable(false);
      textPane.setMargin(new Insets(5, 20, 5, 5));
      textPane.setMaximumSize(new Dimension(364, 1000000000));
      textPane.setPreferredSize(new Dimension(364, 400));
      textPane.setMinimumSize(new Dimension(364, 10));
      textPane.addCaretListener(
          new CaretListener() {
            public void caretUpdate(CaretEvent e) {
              int length = document.getLength();
              int offset = e.getDot();

              if (e.getDot() == e.getMark()) textPane.getCaret().moveDot(offset + 1);

              Paragraph p = lockManager.getParFromOffset(offset);
              int pOffset = p.getOffset();

              lblCursor.setText(
                  "Document Length="
                      + String.valueOf(length)
                      + ", CaretOffset="
                      + String.valueOf(offset)
                      + ", Paragraph="
                      + p.toString()
                      + ", Offset in Paragraph="
                      + String.valueOf(offset - p.getOffset()));
            }
          });
      Box box = new Box(BoxLayout.X_AXIS);
      box.add(textPane);
      box.add(Box.createGlue());
      box.setBackground(Color.WHITE);
      box.setOpaque(true);
      box.setPreferredSize(new Dimension(600, 10000));

      lblCursor = new JLabel("Cursor");
      lblCursor.setBorder(new EtchedBorder());

      JPanel boxText = new JPanel(new BorderLayout());
      boxText.setBorder(new EmptyBorder(5, 5, 5, 5));
      boxText.add(lblDocument, BorderLayout.NORTH);
      boxText.add(new JScrollPane(box), BorderLayout.CENTER);
      boxText.add(lblCursor, BorderLayout.SOUTH);

      JLabel lblPars = new JLabel("Paragraphs: ");
      lblPars.setBorder(new EtchedBorder());

      parList = new JList();
      parList.setPreferredSize(new Dimension(100, 300));
      parList.setEnabled(false);

      JPanel boxPars = new JPanel(new BorderLayout());
      boxPars.setBorder(new EmptyBorder(5, 5, 5, 5));
      boxPars.add(lblPars, BorderLayout.NORTH);
      boxPars.add(new JScrollPane(parList), BorderLayout.CENTER);

      add(boxText, BorderLayout.CENTER);
      add(boxPars, BorderLayout.EAST);
    }
Exemple #3
0
  public void initComponents() {

    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    locoPane = new JScrollPane(pLocos);
    locoPane.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Engines")));

    pickupPane = new JScrollPane(pPickups);
    pickupPane.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Pickup")));

    setoutPane = new JScrollPane(pSetouts);
    setoutPane.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("SetOut")));

    movePane = new JScrollPane(pMoves);
    movePane.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("LocalMoves")));

    // Set up the panels
    pPickupLocos.setLayout(new BoxLayout(pPickupLocos, BoxLayout.Y_AXIS));
    pSetoutLocos.setLayout(new BoxLayout(pSetoutLocos, BoxLayout.Y_AXIS));
    pPickups.setLayout(new BoxLayout(pPickups, BoxLayout.Y_AXIS));
    pSetouts.setLayout(new BoxLayout(pSetouts, BoxLayout.Y_AXIS));
    pMoves.setLayout(new BoxLayout(pMoves, BoxLayout.Y_AXIS));

    // railroad name
    pRailRoadName.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("RailroadName")));
    pRailRoadName.add(textRailRoadName);

    // location name
    pLocationName.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Location")));
    pLocationName.add(textLocationName);

    // location comment
    textLocationCommentPane.setBorder(
        BorderFactory.createTitledBorder(Bundle.getMessage("LocationComment")));
    textLocationCommentPane.setBackground(null);
    textLocationCommentPane.setEditable(false);
    textLocationCommentPane.setMaximumSize(new Dimension(2000, 200));

    // train description
    pTrainDescription.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Description")));
    pTrainDescription.add(textTrainDescription);

    // train comment
    textTrainCommentPane.setBorder(
        BorderFactory.createTitledBorder(Bundle.getMessage("TrainComment")));
    textTrainCommentPane.setBackground(null);
    textTrainCommentPane.setEditable(false);
    textTrainCommentPane.setMaximumSize(new Dimension(2000, 200));

    // train route comment
    textTrainRouteCommentPane.setBorder(
        BorderFactory.createTitledBorder(Bundle.getMessage("RouteComment")));
    textTrainRouteCommentPane.setBackground(null);
    textTrainRouteCommentPane.setEditable(false);
    textTrainRouteCommentPane.setMaximumSize(new Dimension(2000, 200));

    // train route location comment
    textTrainRouteLocationCommentPane.setBorder(
        BorderFactory.createTitledBorder(Bundle.getMessage("RouteLocationComment")));
    textTrainRouteLocationCommentPane.setBackground(null);
    textTrainRouteLocationCommentPane.setEditable(false);
    textTrainRouteLocationCommentPane.setMaximumSize(new Dimension(2000, 200));

    // row 12
    if ((getPreferredSize().width > Control.panelWidth1025 && Setup.isTabEnabled())
        || (getPreferredSize().width > Control.panelWidth1025 - 200 && !Setup.isTabEnabled())) {
      pLocos.setLayout(new BoxLayout(pLocos, BoxLayout.X_AXIS));
      pWorkPanes.setLayout(new BoxLayout(pWorkPanes, BoxLayout.X_AXIS));
    } else {
      pLocos.setLayout(new BoxLayout(pLocos, BoxLayout.Y_AXIS));
      pWorkPanes.setLayout(new BoxLayout(pWorkPanes, BoxLayout.Y_AXIS));
    }

    pLocos.add(pPickupLocos);
    pLocos.add(pSetoutLocos);
    pWorkPanes.add(pickupPane);
    pWorkPanes.add(setoutPane);

    // row 13
    pStatus.setLayout(new GridBagLayout());
    pStatus.setBorder(BorderFactory.createTitledBorder(""));
    addItem(pStatus, textStatus, 0, 0);

    // row 14
    pButtons.setLayout(new GridBagLayout());
    pButtons.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Work")));
    addItem(pButtons, selectButton, 0, 0);
    addItem(pButtons, clearButton, 1, 0);
    addItem(pButtons, setButton, 2, 0);

    // setup buttons
    addButtonAction(selectButton);
    addButtonAction(clearButton);
    addButtonAction(setButton);

    setMinimumSize(new Dimension(Control.panelWidth500, Control.panelHeight500));
  }
  public YardmasterByTrackPanel(Location location) {
    super();
    initComponents();

    // this window doesn't use the set button
    setButton.setVisible(false);

    _location = location;

    textSwitchListCommentPane.setBorder(
        BorderFactory.createTitledBorder(Bundle.getMessage("Comment")));
    textSwitchListCommentPane.setBackground(null);
    textSwitchListCommentPane.setEditable(false);
    textSwitchListCommentPane.setMaximumSize(new Dimension(2000, 200));

    textTrackCommentPane.setBorder(
        BorderFactory.createTitledBorder(Bundle.getMessage("TrackComment")));
    textTrackCommentPane.setBackground(null);
    textTrackCommentPane.setEditable(false);
    textTrackCommentPane.setMaximumSize(new Dimension(2000, 200));

    textTrackCommentWorkPane.setBorder(
        BorderFactory.createTitledBorder(Bundle.getMessage("MenuItemComments")));
    textTrackCommentWorkPane.setBackground(null);
    textTrackCommentWorkPane.setEditable(false);
    textTrackCommentWorkPane.setMaximumSize(new Dimension(2000, 200));

    JPanel pTrackSelect = new JPanel();
    pTrackSelect.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Track")));
    pTrackSelect.add(trackComboBox);
    // add next button for web server
    pTrackSelect.add(nextButton);

    // work at this location by track
    pTrack.setLayout(new BoxLayout(pTrack, BoxLayout.Y_AXIS));
    pTrackPane = new JScrollPane(pTrack);

    pLocationName.setMaximumSize(new Dimension(2000, 200));
    pTrackSelect.setMaximumSize(new Dimension(2000, 200));
    pButtons.setMaximumSize(new Dimension(2000, 200));

    add(pLocationName);
    add(textLocationCommentPane);
    add(textSwitchListCommentPane);
    add(pTrackSelect);
    add(textTrackCommentPane);
    add(textTrackCommentWorkPane);
    add(pTrackPane);
    add(pButtons);

    if (_location != null) {
      textLocationName.setText(_location.getName());
      textLocationCommentPane.setText(_location.getComment());
      textLocationCommentPane.setVisible(
          !_location.getComment().equals(Location.NONE) && Setup.isPrintLocationCommentsEnabled());
      textSwitchListCommentPane.setText(_location.getSwitchListComment());
      textSwitchListCommentPane.setVisible(!_location.getSwitchListComment().equals(Location.NONE));
      updateTrackComboBox();
      _location.addPropertyChangeListener(this);
    }

    update();

    addComboBoxAction(trackComboBox);
    addButtonAction(nextButton);

    setVisible(true);
  }