private void initUI() {

    this.setLayout(new BorderLayout());

    JPanel infoPanel = new JPanel();
    infoPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
    infoPanel.setBackground(Color.WHITE);
    infoPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));

    infoPanel.add(
        new JLabel(
            new ImageIcon(
                Thread.currentThread().getContextClassLoader().getResource("siw-logo3_2.gif"))));

    JLabel infoLabel =
        new JLabel("<html>Please select a project and context<br> Version must be a number</html>");
    infoPanel.add(infoLabel);

    this.add(infoPanel, BorderLayout.NORTH);

    JPanel entryPanel = new JPanel();
    entryPanel.setLayout(null);

    projectNameField.setText("");
    JLabel projectNameLabel = new JLabel("Project Name");
    projectNameLabel.setBounds(new Rectangle(30, 80, 135, 20));
    projectNameField.setBounds(new Rectangle(180, 80, 175, 20));

    JLabel projectVersionLabel = new JLabel("Project Version");
    projectVersionLabel.setBounds(new Rectangle(30, 125, 135, 20));
    projectVersionField.setBounds(new Rectangle(180, 125, 175, 20));

    JLabel contextLabel = new JLabel("Context");
    contextLabel.setBounds(new Rectangle(30, 165, 135, 20));
    contextComboBox.setBounds(new Rectangle(180, 165, 175, 20));

    JLabel packageLabel = new JLabel("Select Package");
    packageLabel.setBounds(new Rectangle(30, 210, 135, 20));
    packageComboBox.setBounds(new Rectangle(180, 210, 250, 20));

    entryPanel.add(projectNameLabel, null);
    entryPanel.add(projectNameField, null);
    entryPanel.add(projectVersionLabel, null);
    entryPanel.add(projectVersionField, null);
    entryPanel.add(contextLabel, null);
    entryPanel.add(contextComboBox, null);
    entryPanel.add(packageLabel, null);
    entryPanel.add(packageComboBox, null);

    this.add(entryPanel, BorderLayout.CENTER);

    projectVersionField.addKeyListener(this);
    projectNameField.addKeyListener(this);
  }
示例#2
0
  private void initUI() {
    this.setLayout(new BorderLayout());

    JPanel flowPanel = new JPanel(new FlowLayout());

    JPanel mainPanel = new JPanel(new GridBagLayout());

    JPanel conceptCodeNameSummaryPanel = new JPanel(new GridBagLayout());
    JPanel topPanel = new JPanel(new BorderLayout());

    if (prefs.getShowConceptCodeNameSummary()) {
      UIUtil.insertInBag(conceptCodeNameSummaryPanel, conceptCodeSummaryLabel, 0, 1);
      UIUtil.insertInBag(conceptCodeNameSummaryPanel, conceptCodeSummaryValue, 1, 1);

      UIUtil.insertInBag(conceptCodeNameSummaryPanel, conceptNameSummaryLabel, 0, 2);
      UIUtil.insertInBag(conceptCodeNameSummaryPanel, conceptNameSummaryValue, 1, 2);
    }
    UIUtil.insertInBag(mainPanel, deLongNameTitleLabel, 0, 1);
    UIUtil.insertInBag(mainPanel, deLongNameValueLabel, 1, 1);

    UIUtil.insertInBag(mainPanel, deIdTitleLabel, 0, 2);
    UIUtil.insertInBag(mainPanel, deIdValueLabel, 1, 2);

    UIUtil.insertInBag(mainPanel, deContextNameTitleLabel, 0, 3);
    UIUtil.insertInBag(mainPanel, deContextNameValueLabel, 1, 3);

    UIUtil.insertInBag(mainPanel, vdLongNameTitleLabel, 0, 4);
    UIUtil.insertInBag(mainPanel, vdLongNameValueLabel, 1, 4);

    // Un-Comment if CDEBrowserLink can be directed to CDEBrowser application.
    //    UIUtil.insertInBag(mainPanel, cdeBrowserLinkLabel, 0, 5);
    //    UIUtil.insertInBag(mainPanel, cdeBrowserLinkValueLabel, 1, 5);

    UIUtil.insertInBag(mainPanel, clearButton, 0, 6, 2, 1);
    UIUtil.insertInBag(mainPanel, searchDeButton, 1, 6);

    cdeBrowserLinkValueLabel.addMouseListener(
        new MouseListener() {
          public void mouseClicked(MouseEvent mouseEvent) {
            String errMsg = "Error attempting to launch web browser";
            String osName = System.getProperty("os.name");
            String url = getCDEBrowserURL();
            try {
              if (osName.startsWith("Mac OS")) {
                Class fileMgr = Class.forName("com.apple.eio.FileManager");
                Method openURL = fileMgr.getDeclaredMethod("openURL", new Class[] {String.class});
                openURL.invoke(null, new Object[] {url});
              } else if (osName.startsWith("Windows"))
                Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
              else { // assume Unix or Linux
                String[] browsers = {
                  "firefox", "opera", "konqueror", "epiphany", "mozilla", "netscape"
                };
                String browser = null;
                for (int count = 0; count < browsers.length && browser == null; count++)
                  if (Runtime.getRuntime().exec(new String[] {"which", browsers[count]}).waitFor()
                      == 0) browser = browsers[count];
                if (browser == null) throw new Exception("Could not find web browser");
                else Runtime.getRuntime().exec(new String[] {browser, url});
              }
            } catch (Exception e) {
              JOptionPane.showMessageDialog(null, errMsg + ":\n" + e.getLocalizedMessage());
            }
          }

          public void mousePressed(MouseEvent e) {}

          public void mouseReleased(MouseEvent e) {}

          public void mouseEntered(MouseEvent e) {}

          public void mouseExited(MouseEvent e) {}
        });
    disableCDELinks();

    JPanel titlePanel = new JPanel();
    JLabel title = new JLabel("Map to CDE");
    titlePanel.add(title);

    flowPanel.add(mainPanel);

    topPanel.add(conceptCodeNameSummaryPanel, BorderLayout.NORTH);
    topPanel.add(titlePanel, BorderLayout.SOUTH);

    this.add(flowPanel);
    this.add(topPanel, BorderLayout.NORTH);

    searchDeButton.setActionCommand(SEARCH);
    clearButton.setActionCommand(CLEAR);

    searchDeButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            JButton button = (JButton) event.getSource();
            if (button.getActionCommand().equals(SEARCH)) {
              CadsrDialog cd = BeansAccessor.getCadsrDEDialog();

              // update dialog with current node
              cd.init(node);
              cd.setAlwaysOnTop(true);
              cd.setVisible(true);

              Object o = cd.getAdminComponent();
              if (o == null) return;

              tempDE = (DataElement) o;

              if (tempDE != null) {
                // Check for conflict
                DataElement confDe = DEMappingUtil.checkConflict(de, tempDE);
                if (confDe != null) {
                  JOptionPane.showMessageDialog(
                      null,
                      PropertyAccessor.getProperty(
                          "de.conflict",
                          new String[] {
                            de.getDataElementConcept().getProperty().getLongName(),
                            confDe.getDataElementConcept().getProperty().getLongName()
                          }),
                      "Conflict",
                      JOptionPane.ERROR_MESSAGE);
                  return;
                }
                if (tempDE != null) {
                  AdminComponent ac = DEMappingUtil.checkDuplicate(de, tempDE);
                  if (ac != null) {
                    if (ac instanceof ObjectClass)
                      JOptionPane.showMessageDialog(
                          null,
                          "This creates a duplicate mapping with "
                              + LookupUtil.lookupFullName((ObjectClass) ac),
                          "Conflict",
                          JOptionPane.ERROR_MESSAGE);
                    if (ac instanceof DataElement)
                      JOptionPane.showMessageDialog(
                          null,
                          "This creates a duplicate mapping with "
                              + ((DataElement) ac)
                                  .getDataElementConcept()
                                  .getProperty()
                                  .getLongName(),
                          "Conflict",
                          JOptionPane.ERROR_MESSAGE);
                    return;
                  }
                }
                updateFields();

                firePropertyChangeEvent(
                    new PropertyChangeEvent(this, ApplyButtonPanel.SAVE, null, true));

                //             firePropertyChangeEvent(
                //                                     new PropertyChangeEvent(this,
                // ButtonPanel.SWITCH, null, false));

                modified = true;
              }
            }
          }
        });

    clearButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            JButton button = (JButton) event.getSource();
            if (button.getActionCommand().equals(CLEAR)) {
              clear();

              firePropertyChangeEvent(
                  new PropertyChangeEvent(this, ApplyButtonPanel.SAVE, null, true));

              modified = true;
              //               fireElementChangeEvent(new ElementChangeEvent(node));

            }
          }
        });

    if ((node.getUserObject() instanceof DataElement))
      firePropertyChangeEvent(
          new PropertyChangeEvent(
              this, ButtonPanel.SWITCH, null, StringUtil.isEmpty(de.getPublicId())));
  }