Esempio n. 1
0
  public LoginUI(IAuthentication authentication) {
    Container container = getContentPane();
    mainPanel = new GridBagLayoutPanel();
    usernameField = new JTextField(25);
    passwordField = new JPasswordField(25);
    serverURLField = new JTextField(25);

    String server_text = (String) authentication.get("server_url");
    if (server_text != null) {
      serverURLField.setText(server_text);
    }

    buttonPanel = new JPanel();
    okButton = new JButton(PluginServices.getText(this, "login_ok"));
    okButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent e) {
            OK();
          }
        });
    exitButton = new JButton(PluginServices.getText(this, "login_exit"));
    exitButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent e) {
            Cancel();
          }
        });

    buttonPanel.add(okButton);
    buttonPanel.add(exitButton);

    JPanel logoPanel = new JPanel();
    logoPanel.add(new JLabel(gvsigIcon));
    logoPanel.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 10));
    container.add(logoPanel, BorderLayout.WEST);
    container.add(mainPanel, BorderLayout.CENTER);
    mainPanel.addComponent(PluginServices.getText(this, "login_name"), usernameField);
    mainPanel.addComponent(PluginServices.getText(this, "login_password"), passwordField);
    mainPanel.addComponent(PluginServices.getText(this, "login_name"), serverURLField);
    invalidLoginLabel = new JLabel(PluginServices.getText(this, "login_invalid_user"));
    invalidLoginLabel.setForeground(Color.RED);
    invalidLoginLabel.setVisible(false);
    mainPanel.addComponent(invalidLoginLabel, buttonPanel);
    mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    this.authentication = authentication;
    this.setBounds(400, 400, this.getWidth(), this.getHeight());
    this.setTitle("Login");
    this.setModal(true);
    this.setSize(400, 200);
    this.setResizable(false);
    pack();
    setVisible(true);
  }
  private void initialize() {
    setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10));
    GridBagLayoutPanel panel = new GridBagLayoutPanel();

    GridBagLayoutPanel aux = new GridBagLayoutPanel();
    aux.addComponent(PluginServices.getText(this, "field_to_be_labeled") + ":", getCmbTextField());
    aux.addComponent(getRdBtnHeightField(), getCmbHeightField());
    aux.addComponent(getRdBtnFixedHeight(), getTxtHeightField());
    aux.addComponent(PluginServices.getText(this, "rotation_height") + ":", getCmbRotationField());
    aux.addComponent(PluginServices.getText(this, "units") + ":", getCmbUnits());
    aux.addComponent(PluginServices.getText(this, ""), getCmbReferenceSystem());
    panel.add(aux);

    aux = new GridBagLayoutPanel();
    aux.addComponent(getChooseFontBut(), new JBlank(20, 20));
    GridBagLayoutPanel aux2 = new GridBagLayoutPanel();
    aux2.setBorder(BorderFactory.createTitledBorder(null, PluginServices.getText(this, "color")));
    aux2.addComponent(getRdBtnFixedColor(), getColorChooser());
    aux2.addComponent(getRdBtnColorField(), getCmbColorField());
    aux.addComponent(aux2);

    panel.add(new JBlank(20, 20));
    panel.add(aux);

    add(panel);

    ButtonGroup group = new ButtonGroup();
    group.add(getRdBtnFixedHeight());
    group.add(getRdBtnHeightField());

    ButtonGroup colorGroup = new ButtonGroup();
    colorGroup.add(getRdBtnFixedColor());
    colorGroup.add(getRdBtnColorField());

    // getRdBtnHeightField().setEnabled(true);
  }