Пример #1
0
  private void initLayout() {
    setBorder(Borders.createEmptyBorder(ComponentFactoryService.DEFAULT_FORM_BORDER));

    setLayout(new FormLayout("pref, 3dlu, pref", "pref"));
    final CellConstraints cellConstraints = new CellConstraints();

    add(insetLabel, cellConstraints.xy(1, 1));
    add(insetSpinner, cellConstraints.xy(3, 1));
  }
Пример #2
0
  public void init(BarFormat format) {
    if (format == null) return;
    FormFormat form = format.getForm();
    if (form == null) return;
    List boxes = form.getBoxes();
    if (boxes == null || boxes.size() == 0) {
      return;
    }
    FormBoxLayout formBoxLayout = form.getLayout(zoom);
    FormLayout layout = new FormLayout(formBoxLayout.getColumnGrid(), formBoxLayout.getRowGrid());
    /// DefaultFormBuilder builder = new DefaultFormBuilder(this,layout);
    DefaultFormBuilder builder = new DefaultFormBuilder(layout, this);
    if (formBoxLayout.getBorder() == null) builder.setDefaultDialogBorder();
    else builder.setBorder(Borders.createEmptyBorder(formBoxLayout.getBorder()));
    CellConstraints cc = new CellConstraints();
    for (Iterator i = boxes.iterator(); i.hasNext(); ) {
      FormBox box = (FormBox) i.next();
      if (zoom < box.getMinZoom()) return;
      JComponent component;
      if (box.getFieldId() == null) component = new JLabel(Messages.getString(box.getTextId()));
      else {
        if (editor && !box.getField().isReadOnly()) {
          component = new ChangeAwareTextField();
          component.setBorder(null);
          // component.setOpaque(false);
        } else component = new JLabel();

        // if (box.getRow()==1&&!editor)
        // ((JLabel)component).setHorizontalAlignment(SwingConstants.CENTER);
        // bug workaround, not possible to center with classic method when rowSpan>1

        fieldComponents.put(box.getFieldId(), component);
      }
      Font font = formBoxLayout.getFont(box.getFont());
      if (font != null) component.setFont(font);
      String ba = box.getAlignment();
      int bc = box.getColumn();
      int br = box.getRow();
      int bcs = box.getColumnSpan();
      int brs = box.getRowSpan();
      try {
        builder.add(
            component, (ba == null) ? cc.xywh(bc, br, bcs, brs) : cc.xywh(bc, br, bcs, brs, ba));
      } catch (IndexOutOfBoundsException e) {
        log.fatal("box.Column(): " + bc);
        log.fatal("box.Row(): " + br);
        log.fatal("box.ColumnSpan(): " + bcs);
        log.fatal("box.RowSpan(): " + brs);
        log.fatal("box.Alignment(): " + ba);
        log.fatal("Occur Error: ", e);
      }
    }
  }
Пример #3
0
  public ContactsView(@Service ApplicationContext context, @Uses ContactsModel model) {
    super(new BorderLayout());

    this.model = model;

    ActionMap am = context.getActionMap(this);
    setActionMap(am);
    setPreferredSize(new Dimension(200, 0));

    this.setBorder(Borders.createEmptyBorder("2dlu, 2dlu, 2dlu, 2dlu"));

    contacts = new JList(new EventListModel<ContactDTO>(model.getEventList()));
    contacts.setPreferredSize(new Dimension(200, 1000));
    contacts.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    JScrollPane contactsScrollPane = new JScrollPane();
    contactsScrollPane.setViewportView(contacts);
    contacts.setCellRenderer(
        new DefaultListCellRenderer() {

          @Override
          public Component getListCellRendererComponent(
              JList jList, Object o, int i, boolean b, boolean b1) {
            ContactDTO contact = (ContactDTO) o;
            if ("".equals(contact.name().get())) {
              Component cell =
                  super.getListCellRendererComponent(
                      jList, i18n.text(WorkspaceResources.name_label), i, b, b1);
              cell.setForeground(Color.GRAY);
              return cell;
            }

            String text = contact.name().get();

            return super.getListCellRendererComponent(jList, text, i, b, b1);
          }
        });
    add(contactsScrollPane, BorderLayout.CENTER);

    JPanel toolbar = new JPanel();
    toolbar.add(new StreamflowButton(am.get("add")));
    toolbar.add(new StreamflowButton(am.get("remove")));
    add(toolbar, BorderLayout.SOUTH);

    model.addObserver(new RefreshComponents().visibleOn("add", toolbar));

    contacts
        .getSelectionModel()
        .addListSelectionListener(new SelectionActionEnabler(am.get("remove")));

    /*
          setFocusTraversalPolicy( new LayoutFocusTraversalPolicy() );
          setFocusCycleRoot( true );
          setFocusable( true );
          addFocusListener( new FocusListener()
          {
             public void focusGained( FocusEvent e )
             {
                Component defaultComp = getFocusTraversalPolicy().getDefaultComponent( contactView );
                if (defaultComp != null)
                {
                   defaultComp.requestFocusInWindow();
                }
             }

             public void focusLost( FocusEvent e )
             {
             }
          } );
    */

    new RefreshWhenShowing(this, this);
  }
Пример #4
0
  private void initComponents() {
    // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    // Generated using JFormDesigner non-commercial license
    dialogPane = new JPanel();
    contentPanel = new JPanel();
    panel1 = new JPanel();
    label2 = new JLabel();
    ttfSizeW = new JTextField();
    label4 = new JLabel();
    ttfLongi = new JTextField();
    btnGetMap = new JButton();
    label3 = new JLabel();
    ttfSizeH = new JTextField();
    label5 = new JLabel();
    ttfLati = new JTextField();
    btnQuit = new JButton();
    label1 = new JLabel();
    ttfLicense = new JTextField();
    label6 = new JLabel();
    ttfZoom = new JTextField();
    // ComboBox for Saved Locations
    ttfSave = new JComboBox();
    scrollPane1 = new JScrollPane();
    ttaStatus = new JTextArea();
    panel2 = new JPanel();
    panel3 = new JPanel();
    checkboxRecvStatus = new JCheckBox();
    checkboxSendStatus = new JCheckBox();
    ttfProgressMsg = new JTextField();
    progressBar = new JProgressBar();
    lblProgressStatus = new JLabel();

    // ======== this ========
    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    setTitle("Google Static Maps");
    setIconImage(null);
    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());

    // ======== dialogPane ========
    {
      dialogPane.setBorder(new EmptyBorder(12, 12, 12, 12));
      dialogPane.setOpaque(false);
      dialogPane.setLayout(new BorderLayout());

      // ======== contentPanel ========
      {
        contentPanel.setOpaque(false);
        contentPanel.setLayout(
            new TableLayout(
                new double[][] {
                  {TableLayout.FILL},
                  {TableLayout.PREFERRED, TableLayout.FILL, TableLayout.PREFERRED}
                }));
        ((TableLayout) contentPanel.getLayout()).setHGap(5);
        ((TableLayout) contentPanel.getLayout()).setVGap(5);

        // ======== panel1 ========
        {
          panel1.setOpaque(false);
          panel1.setBorder(
              new CompoundBorder(
                  new TitledBorder("Configure the inputs to Google Static Maps"),
                  Borders.DLU2_BORDER));
          panel1.setLayout(
              new TableLayout(
                  new double[][] {
                    {0.17, 0.17, 0.17, 0.17, 0.05, TableLayout.FILL},
                    {TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED}
                  }));
          ((TableLayout) panel1.getLayout()).setHGap(5);
          ((TableLayout) panel1.getLayout()).setVGap(5);

          // ---- label2 ----
          label2.setText("Size Width");
          label2.setHorizontalAlignment(SwingConstants.RIGHT);
          panel1.add(
              label2,
              new TableLayoutConstraints(
                  0, 0, 0, 0, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

          // ---- ttfSizeW ----
          ttfSizeW.setText("512");
          panel1.add(
              ttfSizeW,
              new TableLayoutConstraints(
                  1, 0, 1, 0, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

          // ---- label4 ----
          label4.setText("Latitude");
          label4.setHorizontalAlignment(SwingConstants.RIGHT);
          panel1.add(
              label4,
              new TableLayoutConstraints(
                  2, 0, 2, 0, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

          // ---- ttfLongi ----
          ttfLongi.setText("38.931099");
          panel1.add(
              ttfLongi,
              new TableLayoutConstraints(
                  3, 0, 3, 0, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

          // ---- btnGetMap ----
          btnGetMap.setText("Get Map");
          btnGetMap.setHorizontalAlignment(SwingConstants.LEFT);
          btnGetMap.setMnemonic('G');
          btnGetMap.addActionListener(
              new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                  startTaskAction();
                  if (Integer.parseInt(ttfZoom.getText()) < 14) { // coding for zoom values under 14
                    for (int i = 0; i < 14; i++) {
                      if (Integer.parseInt(ttfZoom.getText()) == i) {
                        countThis = 14 - i; // gets difference
                        do {
                          counter = counter * 2; // found out code zooms in powers of 2.
                          pixelX =
                              0.000084525
                                  * counter; // Values per Latitude, trial and error method used to
                                             // find these numbers.
                          pixelY = 0.00006725 * counter; // Values per Longitude
                          counter1++;
                        } while (counter1 != countThis); // loops the amount of differences
                      }
                      counter = 1; // Resetters
                      counter1 = 0;
                    }
                  } else if (Integer.parseInt(ttfZoom.getText())
                      > 14) { // coding for zoom values over 14
                    for (int i = 14; i < 19; i++) {
                      if (Integer.parseInt(ttfZoom.getText()) == i) {
                        countThis = i - 14; // gets difference
                        do {
                          counter = counter * 2;
                          pixelX = 0.000084525 / counter; // Values per Latitude
                          pixelY = 0.00006725 / counter; // Values per Longitude	            	
                          counter1++;
                        } while (counter1 != countThis); // loops amount of differences
                      }
                      counter = 1; // Resetters
                      counter1 = 0;
                    }
                  } else { // coding for zoom default value of 14.
                    pixelX = 0.000084525;
                    pixelY = 0.00006725;
                  }

                  BigDecimal sendPixelX = new BigDecimal(pixelX);
                  BigDecimal sendPixelY = new BigDecimal(pixelY);

                  pixelX =
                      (sendPixelX.setScale(6, BigDecimal.ROUND_HALF_UP))
                          .doubleValue(); // allows for bigger decimal zoom variables
                  pixelY =
                      (sendPixelY.setScale(6, BigDecimal.ROUND_HALF_UP))
                          .doubleValue(); // Won't reach zoom 1-5 without these!
                }
              });
          panel1.add(
              btnGetMap,
              new TableLayoutConstraints(
                  5, 0, 5, 0, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

          // ---- label3 ----
          label3.setText("Size Height");
          label3.setHorizontalAlignment(SwingConstants.RIGHT);
          panel1.add(
              label3,
              new TableLayoutConstraints(
                  0, 1, 0, 1, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

          // ---- ttfSizeH ----
          ttfSizeH.setText("512");
          panel1.add(
              ttfSizeH,
              new TableLayoutConstraints(
                  1, 1, 1, 1, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

          // ---- label5 ----
          label5.setText("Longitude");
          label5.setHorizontalAlignment(SwingConstants.RIGHT);
          panel1.add(
              label5,
              new TableLayoutConstraints(
                  2, 1, 2, 1, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

          // ---- ttfLati ----
          ttfLati.setText("-77.3489");
          panel1.add(
              ttfLati,
              new TableLayoutConstraints(
                  3, 1, 3, 1, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

          // ---- btnQuit ----
          btnQuit.setText("Quit");
          btnQuit.setMnemonic('Q');
          btnQuit.setHorizontalAlignment(SwingConstants.LEFT);
          btnQuit.setHorizontalTextPosition(SwingConstants.RIGHT);
          btnQuit.addActionListener(
              new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                  quitProgram();
                }
              });
          panel1.add(
              btnQuit,
              new TableLayoutConstraints(
                  5, 1, 5, 1, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

          // ---- label1 ----
          label1.setText("License Key");
          label1.setHorizontalAlignment(SwingConstants.RIGHT);
          panel1.add(
              label1,
              new TableLayoutConstraints(
                  0, 2, 0, 2, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

          // ---- ttfLicense ----
          ttfLicense.setToolTipText("Enter your own URI for a file to download in the background");
          panel1.add(
              ttfLicense,
              new TableLayoutConstraints(
                  1, 2, 1, 2, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

          // ---- label6 ----
          label6.setText("Zoom");
          label6.setHorizontalAlignment(SwingConstants.RIGHT);
          panel1.add(
              label6,
              new TableLayoutConstraints(
                  2, 2, 2, 2, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

          // ---- ttfZoom ----
          ttfZoom.setText("14");
          panel1.add(
              ttfZoom,
              new TableLayoutConstraints(
                  3, 2, 3, 2, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

          // ---- ttfSave ----
          ttfSave.removeAllItems();
          // JComboBox ttfSave = new JComboBox();
          getSavedLocations(); // grabs a new list
          for (int i = 0; i < loc.size(); i++) // populates this list using a arrayList
          ttfSave.addItem(loc.get(i));

          ttfSave.setSelectedIndex(0);
          panel1.add(
              ttfSave,
              new TableLayoutConstraints(
                  5, 2, 5, 2, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));
          // Action Listener to update the coordinates on selected Location
          ttfSave.addActionListener(
              new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                  if (mapIsUp == 0) {
                    Object contents = ttfSave.getSelectedItem(); // grabs users selection
                    System.out.println(contents);
                    if (contents != null) {
                      stringCoords = contents.toString();
                      setCoords = stringCoords.split("\\s+");
                      ttfLongi.setText(
                          setCoords[
                              1]); // sets the texts in the longitude and latitude fields to
                                   // coordinates selected
                      ttfLati.setText(setCoords[0]);
                    }
                  }
                }
              });
        }
        contentPanel.add(
            panel1,
            new TableLayoutConstraints(
                0, 0, 0, 0, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

        // ======== scrollPane1 ========
        {
          scrollPane1.setBorder(
              new TitledBorder("System.out - displays all status and progress messages, etc."));
          scrollPane1.setOpaque(false);

          // ---- ttaStatus ----
          ttaStatus.setBorder(Borders.createEmptyBorder("1dlu, 1dlu, 1dlu, 1dlu"));
          ttaStatus.setToolTipText(
              "<html>Task progress updates (messages) are displayed here,<br>along with any other output generated by the Task.<html>");
          scrollPane1.setViewportView(ttaStatus);
        }
        contentPanel.add(
            scrollPane1,
            new TableLayoutConstraints(
                0, 1, 0, 1, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

        // ======== panel2 ========
        {
          panel2.setOpaque(false);
          panel2.setBorder(
              new CompoundBorder(
                  new TitledBorder("Status - control progress reporting"), Borders.DLU2_BORDER));
          panel2.setLayout(
              new TableLayout(
                  new double[][] {
                    {0.45, TableLayout.FILL, 0.45},
                    {TableLayout.PREFERRED, TableLayout.PREFERRED}
                  }));
          ((TableLayout) panel2.getLayout()).setHGap(5);
          ((TableLayout) panel2.getLayout()).setVGap(5);

          // ======== panel3 ========
          {
            panel3.setOpaque(false);
            panel3.setLayout(new GridLayout(1, 2));

            // ---- checkboxRecvStatus ----
            checkboxRecvStatus.setText("Enable \"Recieve\"");
            checkboxRecvStatus.setOpaque(false);
            checkboxRecvStatus.setToolTipText("Task will fire \"send\" status updates");
            checkboxRecvStatus.setSelected(true);
            panel3.add(checkboxRecvStatus);

            // ---- checkboxSendStatus ----
            checkboxSendStatus.setText("Enable \"Send\"");
            checkboxSendStatus.setOpaque(false);
            checkboxSendStatus.setToolTipText("Task will fire \"recieve\" status updates");
            panel3.add(checkboxSendStatus);
          }
          panel2.add(
              panel3,
              new TableLayoutConstraints(
                  0, 0, 0, 0, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

          // ---- ttfProgressMsg ----
          ttfProgressMsg.setText("Loading map from Google Static Maps");
          ttfProgressMsg.setToolTipText("Set the task progress message here");
          panel2.add(
              ttfProgressMsg,
              new TableLayoutConstraints(
                  2, 0, 2, 0, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

          // ---- progressBar ----
          progressBar.setStringPainted(true);
          progressBar.setString("progress %");
          progressBar.setToolTipText("% progress is displayed here");
          panel2.add(
              progressBar,
              new TableLayoutConstraints(
                  0, 1, 0, 1, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

          // ---- lblProgressStatus ----
          lblProgressStatus.setText("task status listener");
          lblProgressStatus.setHorizontalTextPosition(SwingConstants.LEFT);
          lblProgressStatus.setHorizontalAlignment(SwingConstants.LEFT);
          lblProgressStatus.setToolTipText(
              "Task status messages are displayed here when the task runs");
          panel2.add(
              lblProgressStatus,
              new TableLayoutConstraints(
                  2, 1, 2, 1, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));
        }
        contentPanel.add(
            panel2,
            new TableLayoutConstraints(
                0, 2, 0, 2, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));
      }
      dialogPane.add(contentPanel, BorderLayout.CENTER);
    }
    contentPane.add(dialogPane, BorderLayout.CENTER);
    setSize(675, 485);
    setLocationRelativeTo(null);
    // JFormDesigner - End of component initialization  //GEN-END:initComponents
  }
Пример #5
0
  private void initComponents() {
    // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    // Generated using JFormDesigner Evaluation license - Andrey Lubchuck
    dialogPane = new JPanel();
    contentPanel = new JPanel();
    scrollPane1 = new JScrollPane();
    textPane1 = new JTextPane();
    button1 = new JButton();
    buttonBar = new JPanel();
    okButton = new JButton();
    cancelButton = new JButton();

    // ======== this ========
    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());

    // ======== dialogPane ========
    {
      dialogPane.setBorder(Borders.createEmptyBorder("7dlu, 7dlu, 7dlu, 7dlu"));

      // JFormDesigner evaluation mark
      dialogPane.setBorder(
          new javax.swing.border.CompoundBorder(
              new javax.swing.border.TitledBorder(
                  new javax.swing.border.EmptyBorder(0, 0, 0, 0),
                  "JFormDesigner Evaluation",
                  javax.swing.border.TitledBorder.CENTER,
                  javax.swing.border.TitledBorder.BOTTOM,
                  new java.awt.Font("Dialog", java.awt.Font.BOLD, 12),
                  java.awt.Color.red),
              dialogPane.getBorder()));
      dialogPane.addPropertyChangeListener(
          new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent e) {
              if ("border".equals(e.getPropertyName())) throw new RuntimeException();
            }
          });

      dialogPane.setLayout(new BorderLayout());

      // ======== contentPanel ========
      {
        contentPanel.setLayout(
            new FormLayout("17*(default, $lcgap), default", "6*(default, $lgap), default"));

        // ======== scrollPane1 ========
        {
          scrollPane1.setViewportView(textPane1);
        }
        contentPanel.add(scrollPane1, CC.xywh(4, 5, 12, 1));

        // ---- button1 ----
        button1.setText("text");
        button1.setMaximumSize(new Dimension(83, 23));
        button1.setMinimumSize(new Dimension(83, 23));
        contentPanel.add(button1, CC.xywh(21, 11, 11, 1, CC.CENTER, CC.DEFAULT));
      }
      dialogPane.add(contentPanel, BorderLayout.NORTH);

      // ======== buttonBar ========
      {
        buttonBar.setBorder(Borders.createEmptyBorder("5dlu, 0dlu, 0dlu, 0dlu"));
        buttonBar.setLayout(
            new FormLayout("$lcgap, default, $glue, $button, $rgap, $button", "pref"));

        // ---- okButton ----
        okButton.setText("OK");
        buttonBar.add(okButton, CC.xy(4, 1));

        // ---- cancelButton ----
        cancelButton.setText("Cancel");
        cancelButton.setMaximumSize(new Dimension(85, 23));
        cancelButton.setMinimumSize(new Dimension(85, 23));
        buttonBar.add(cancelButton, CC.xy(6, 1));
      }
      dialogPane.add(buttonBar, BorderLayout.SOUTH);
    }
    contentPane.add(dialogPane, BorderLayout.CENTER);
    pack();
    setLocationRelativeTo(getOwner());
    // JFormDesigner - End of component initialization  //GEN-END:initComponents
  }