Пример #1
0
  private void commit() {
    String serverName = (String) server.getSelectedItem();
    if (serverName == null || serverName.equals("")) {
      vlog.error("No server name specified!");
      if (VncViewer.nViewers == 1)
        if (cc.viewer instanceof VncViewer) {
          ((VncViewer) cc.viewer).exit(1);
        }
      ret = false;
      endDialog();
    }

    // set params
    if (opts.via != null && opts.via.indexOf(':') >= 0) {
      opts.serverName = serverName;
    } else {
      opts.serverName = Hostname.getHost(serverName);
      opts.port = Hostname.getPort(serverName);
    }

    // Update the history list
    String valueStr = UserPreferences.get("ServerDialog", "history");
    String t = (valueStr == null) ? "" : valueStr;
    StringTokenizer st = new StringTokenizer(t, ",");
    StringBuffer sb = new StringBuffer().append((String) server.getSelectedItem());
    while (st.hasMoreTokens()) {
      String str = st.nextToken();
      if (!str.equals((String) server.getSelectedItem()) && !str.equals("")) {
        sb.append(',');
        sb.append(str);
      }
    }
    UserPreferences.set("ServerDialog", "history", sb.toString());
    UserPreferences.save("ServerDialog");
  }
Пример #2
0
  private void updateFields() {
    deLongNameValueLabel.setText(tempDE.getLongName());
    deIdValueLabel.setText(ConventionUtil.publicIdVersion(tempDE));
    if (tempDE.getContext() != null) deContextNameValueLabel.setText(tempDE.getContext().getName());
    else deContextNameValueLabel.setText("");

    if (tempDE.getValueDomain() != null)
      vdLongNameValueLabel.setText(tempDE.getValueDomain().getLongName());
    else vdLongNameValueLabel.setText("");

    if (prefs.getShowConceptCodeNameSummary()) {
      List<gov.nih.nci.ncicb.cadsr.domain.Concept> concepts =
          cadsrModule.getConcepts(tempDE.getDataElementConcept().getProperty());
      if (concepts != null && concepts.size() > 0) {
        StringBuffer conceptCodeSummary = new StringBuffer();
        StringBuffer conceptNameSummary = new StringBuffer();
        for (Concept con : concepts) {
          conceptCodeSummary.append(con.getPreferredName());
          conceptCodeSummary.append(" ");
          conceptNameSummary.append(con.getLongName());
          conceptNameSummary.append(" ");
        }
        conceptCodeSummaryValue.setText(conceptCodeSummary.toString());
        conceptNameSummaryValue.setText(conceptNameSummary.toString());
      }
    }
    enableCDELinks();
  }
Пример #3
0
  public void updateNode(UMLNode node) {
    this.node = node;
    if ((node.getUserObject() instanceof DataElement)) {
      de = (DataElement) node.getUserObject();
      if (de.getPublicId() != null) {
        deLongNameValueLabel.setText("<html><body>" + de.getLongName() + "</body></html>");
        deIdValueLabel.setText(de.getPublicId() + " v" + de.getVersion());
        deContextNameValueLabel.setText(de.getContext().getName());
        vdLongNameValueLabel.setText(de.getValueDomain().getLongName());

        // if preference is set to show Concept Summary, then :
        // call cadsrModulde.getConcepts(de.getDataElementConcept().getProperty())
        // and show the 2 fields
        if (prefs.getShowConceptCodeNameSummary()) {
          List<gov.nih.nci.ncicb.cadsr.domain.Concept> concepts =
              cadsrModule.getConcepts(de.getDataElementConcept().getProperty());
          if (concepts != null && concepts.size() > 0) {
            StringBuffer conceptCodeSummary = new StringBuffer();
            StringBuffer conceptNameSummary = new StringBuffer();
            for (Concept con : concepts) {
              conceptCodeSummary.append(con.getPreferredName());
              conceptCodeSummary.append(" ");
              conceptNameSummary.append(con.getLongName());
              conceptNameSummary.append(" ");
            }
            conceptCodeSummaryValue.setText(conceptCodeSummary.toString());
            conceptNameSummaryValue.setText(conceptNameSummary.toString());
          }
        }
        enableCDELinks();
      } else clear();

      firePropertyChangeEvent(
          new PropertyChangeEvent(
              this, ButtonPanel.SWITCH, null, StringUtil.isEmpty(de.getPublicId())));
    }
  }
Пример #4
0
  public ServerDialog(OptionsDialog options_, Options opts_, CConn cc_) {

    super(true);
    cc = cc_;
    opts = opts_;

    options = options_;

    JLabel serverLabel = new JLabel("VNC server:", JLabel.RIGHT);
    String valueStr = null;
    if (opts.serverName != null) {
      String[] s = new String[1];
      s[0] = opts.serverName;
      server = new JComboBox(s);
    } else if ((valueStr = UserPreferences.get("ServerDialog", "history")) != null) {
      server = new JComboBox(valueStr.split(","));
    } else {
      server = new JComboBox();
    }

    // Hack to set the left inset on editable JComboBox
    if (UIManager.getLookAndFeel().getID() == "Windows") {
      server.setBorder(
          BorderFactory.createCompoundBorder(
              server.getBorder(), BorderFactory.createEmptyBorder(0, 2, 0, 0)));
    } else if (UIManager.getLookAndFeel().getID() == "Metal") {
      ComboBoxEditor editor = server.getEditor();
      JTextField jtf = (JTextField) editor.getEditorComponent();
      jtf.setBorder(new CompoundBorder(jtf.getBorder(), new EmptyBorder(0, 2, 0, 0)));
    }

    server.setEditable(true);
    editor = server.getEditor();
    editor
        .getEditorComponent()
        .addKeyListener(
            new KeyListener() {
              public void keyTyped(KeyEvent e) {}

              public void keyReleased(KeyEvent e) {}

              public void keyPressed(KeyEvent e) {
                if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                  server.insertItemAt(editor.getItem(), 0);
                  server.setSelectedIndex(0);
                  commit();
                  endDialog();
                }
              }
            });

    topPanel = new JPanel(new GridBagLayout());

    Dialog.addGBComponent(
        new JLabel(VncViewer.logoIcon),
        topPanel,
        0,
        0,
        1,
        1,
        0,
        0,
        0,
        1,
        GridBagConstraints.HORIZONTAL,
        GridBagConstraints.LINE_START,
        new Insets(5, 5, 5, 15));
    Dialog.addGBComponent(
        serverLabel,
        topPanel,
        1,
        0,
        1,
        1,
        0,
        0,
        0,
        1,
        GridBagConstraints.HORIZONTAL,
        GridBagConstraints.LINE_END,
        new Insets(10, 0, 5, 5));
    Dialog.addGBComponent(
        server,
        topPanel,
        2,
        0,
        1,
        1,
        0,
        0,
        1,
        1,
        GridBagConstraints.HORIZONTAL,
        GridBagConstraints.CENTER,
        new Insets(10, 0, 5, 20));

    optionsButton = new JButton("Options...");
    aboutButton = new JButton("About...");
    okButton = new JButton("Connect");
    cancelButton = new JButton("Cancel");
    buttonPanel = new JPanel(new GridBagLayout());
    buttonPanel.setPreferredSize(new Dimension(350, 40));
    Dialog.addGBComponent(
        aboutButton,
        buttonPanel,
        0,
        3,
        1,
        1,
        0,
        0,
        0.8,
        1,
        GridBagConstraints.HORIZONTAL,
        GridBagConstraints.CENTER,
        new Insets(0, 2, 0, 5));
    Dialog.addGBComponent(
        optionsButton,
        buttonPanel,
        1,
        3,
        1,
        1,
        0,
        0,
        1,
        1,
        GridBagConstraints.HORIZONTAL,
        GridBagConstraints.CENTER,
        new Insets(0, 2, 0, 5));
    Dialog.addGBComponent(
        okButton,
        buttonPanel,
        2,
        3,
        1,
        1,
        0,
        0,
        0.7,
        1,
        GridBagConstraints.HORIZONTAL,
        GridBagConstraints.CENTER,
        new Insets(0, 2, 0, 5));
    Dialog.addGBComponent(
        cancelButton,
        buttonPanel,
        3,
        3,
        1,
        1,
        0,
        0,
        0.6,
        1,
        GridBagConstraints.HORIZONTAL,
        GridBagConstraints.CENTER,
        new Insets(0, 2, 0, 5));

    server.addActionListener(this);
    optionsButton.addActionListener(this);
    aboutButton.addActionListener(this);
    okButton.addActionListener(this);
    cancelButton.addActionListener(this);
  }
  MyCustomizableGUI() {

    this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    textField = new JTextField(20);
    buttonPref = new JButton("Preferences");

    this.add(textField);
    this.add(buttonPref);

    buttonPref.addActionListener(evt -> prefDialog.setVisible(true));

    frame = new JFrame("My text editor");
    frame.setContentPane(this);
    frame.pack();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);

    // Preferences dialog box
    prefDialog = new JDialog(frame, "Dialog", true);
    prefDialog.setLayout(new BorderLayout());
    JPanel p1 = new JPanel();
    p1.setLayout(new GridLayout(3, 2));
    JPanel p2 = new JPanel();
    p2.setLayout(new BoxLayout(p2, BoxLayout.X_AXIS));

    buttonSave = new JButton("Save");
    buttonCancel = new JButton("Cancel");

    buttonSave.addActionListener(
        evtSave -> {
          String fontChosen;
          int fontSizeChosen;

          prefDialog.setVisible(false);

          if ((String) color.getSelectedItem() == "Red") {
            textField.setForeground(Color.red);
          } else if ((String) color.getSelectedItem() == "Green") {
            textField.setForeground(Color.green);
          } else if ((String) color.getSelectedItem() == "Blue") {
            textField.setForeground(Color.blue);
          } else if ((String) color.getSelectedItem() == "Cyan") {
            textField.setForeground(Color.cyan);
          } else if ((String) color.getSelectedItem() == "Magenta") {
            textField.setForeground(Color.magenta);
          } else if ((String) color.getSelectedItem() == "Yellow") {
            textField.setForeground(Color.yellow);
          } else if ((String) color.getSelectedItem() == "Black") {
            textField.setForeground(Color.black);
          }

          fontChosen = (String) font.getSelectedItem();
          fontSizeChosen = Integer.parseInt((String) fontSize.getSelectedItem());
          textField.setFont(new Font(fontChosen, Font.PLAIN, fontSizeChosen));

          UserPreferences userPrefs = new UserPreferences();
          userPrefs.setColor((String) color.getSelectedItem());
          userPrefs.setFont(fontChosen);
          userPrefs.setFontSize(fontSizeChosen);

          try (FileOutputStream fileOut = new FileOutputStream("preferences.ser");
              ObjectOutputStream objectOut = new ObjectOutputStream(fileOut); ) {

            objectOut.writeObject(userPrefs);

          } catch (IOException ioe) {
            System.out.println("I/O error: " + ioe.getMessage());
          }
        });

    buttonCancel.addActionListener(evt -> prefDialog.setVisible(false));

    colorLabel = new JLabel("Color:");
    fontLabel = new JLabel("Font:");
    fontSizeLabel = new JLabel("Font size:");
    color = new JComboBox(colorList);
    font = new JComboBox(fontList);
    fontSize = new JComboBox(fontSizeList);

    p1.add(colorLabel);
    p1.add(color);
    p1.add(fontLabel);
    p1.add(font);
    p1.add(fontSizeLabel);
    p1.add(fontSize);
    p2.add(buttonCancel);
    p2.add(buttonSave);

    prefDialog.add(BorderLayout.NORTH, p1);
    prefDialog.add(BorderLayout.SOUTH, p2);

    prefDialog.pack();
  }
  public static void main(String[] args) {

    MyCustomizableGUI custGUI = new MyCustomizableGUI();
    UserPreferences savedPrefs;

    try (FileInputStream fileIn = new FileInputStream("preferences.ser");
        ObjectInputStream objectIn = new ObjectInputStream(fileIn); ) {

      savedPrefs = (UserPreferences) objectIn.readObject();

      if (savedPrefs.getColor().contains("Red")) {
        custGUI.textField.setForeground(Color.red);
        custGUI.color.setSelectedItem("Red");
      } else if (savedPrefs.getColor().contains("Green")) {
        custGUI.textField.setForeground(Color.green);
        custGUI.color.setSelectedItem("Green");
      } else if (savedPrefs.getColor().contains("Blue")) {
        custGUI.textField.setForeground(Color.blue);
        custGUI.color.setSelectedItem("Blue");
      } else if (savedPrefs.getColor().contains("Cyan")) {
        custGUI.textField.setForeground(Color.cyan);
        custGUI.color.setSelectedItem("Cyan");
      } else if (savedPrefs.getColor().contains("Magenta")) {
        custGUI.textField.setForeground(Color.magenta);
        custGUI.color.setSelectedItem("Magenta");
      } else if (savedPrefs.getColor().contains("Yellow")) {
        custGUI.textField.setForeground(Color.yellow);
        custGUI.color.setSelectedItem("Yellow");
      } else if (savedPrefs.getColor().contains("Black")) {
        custGUI.textField.setForeground(Color.black);
        custGUI.color.setSelectedItem("Black");
      }

      custGUI.setFont(savedPrefs.getFont(), savedPrefs.getFontSize());
      custGUI.font.setSelectedItem(savedPrefs.getFont());
      custGUI.fontSize.setSelectedItem("" + savedPrefs.getFontSize());

    } catch (FileNotFoundException noFile) {
      // load default font and color
      custGUI.setFont("Arial", 25);
      custGUI.textField.setForeground(Color.black);

    } catch (ClassNotFoundException noPrefs) {
      noPrefs.printStackTrace();
    } catch (IOException e) {
      System.out.println("I/O Error: " + e.getMessage());
    }
  }
Пример #7
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())));
  }
Пример #8
0
public class DEPanel extends JPanel implements Editable, CadsrModuleListener {

  private JButton searchDeButton = new JButton("Search Data Element");
  private JButton clearButton = new JButton("Clear");

  private JLabel deLongNameTitleLabel = new JLabel("Data Element Long Name"),
      deLongNameValueLabel = new JLabel(),
      deIdTitleLabel = new JLabel("Public ID / Version"),
      deIdValueLabel = new JLabel(),
      deContextNameTitleLabel = new JLabel("Data Element Context"),
      deContextNameValueLabel = new JLabel(),
      vdLongNameTitleLabel = new JLabel("Value Domain Long Name"),
      vdLongNameValueLabel = new JLabel(),
      cdeBrowserLinkLabel = new JLabel("CDE Details"),
      cdeBrowserLinkValueLabel = new JLabel(),
      conceptCodeSummaryLabel = new JLabel("Concept Code Summary"),
      conceptCodeSummaryValue = new JLabel(),
      conceptNameSummaryLabel = new JLabel("Concept Name Summary"),
      conceptNameSummaryValue = new JLabel();

  private String cdeURL = null;
  private CadsrModule cadsrModule;

  private DataElement tempDE, de;
  private UMLNode node;

  private List<PropertyChangeListener> propChangeListeners =
      new ArrayList<PropertyChangeListener>();

  private List<ElementChangeListener> changeListeners = new ArrayList<ElementChangeListener>();

  private UserPreferences prefs = UserPreferences.getInstance();

  private static final String SEARCH = "SEARCH", CLEAR = "CLEAR";

  private boolean modified = false;

  public DEPanel(UMLNode node) {
    this.node = node;

    if ((node.getUserObject() instanceof DataElement)) de = (DataElement) node.getUserObject();

    initUI();
  }

  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())));
  }

  public void updateNode(UMLNode node) {
    this.node = node;
    if ((node.getUserObject() instanceof DataElement)) {
      de = (DataElement) node.getUserObject();
      if (de.getPublicId() != null) {
        deLongNameValueLabel.setText("<html><body>" + de.getLongName() + "</body></html>");
        deIdValueLabel.setText(de.getPublicId() + " v" + de.getVersion());
        deContextNameValueLabel.setText(de.getContext().getName());
        vdLongNameValueLabel.setText(de.getValueDomain().getLongName());

        // if preference is set to show Concept Summary, then :
        // call cadsrModulde.getConcepts(de.getDataElementConcept().getProperty())
        // and show the 2 fields
        if (prefs.getShowConceptCodeNameSummary()) {
          List<gov.nih.nci.ncicb.cadsr.domain.Concept> concepts =
              cadsrModule.getConcepts(de.getDataElementConcept().getProperty());
          if (concepts != null && concepts.size() > 0) {
            StringBuffer conceptCodeSummary = new StringBuffer();
            StringBuffer conceptNameSummary = new StringBuffer();
            for (Concept con : concepts) {
              conceptCodeSummary.append(con.getPreferredName());
              conceptCodeSummary.append(" ");
              conceptNameSummary.append(con.getLongName());
              conceptNameSummary.append(" ");
            }
            conceptCodeSummaryValue.setText(conceptCodeSummary.toString());
            conceptNameSummaryValue.setText(conceptNameSummary.toString());
          }
        }
        enableCDELinks();
      } else clear();

      firePropertyChangeEvent(
          new PropertyChangeEvent(
              this, ButtonPanel.SWITCH, null, StringUtil.isEmpty(de.getPublicId())));
    }
  }

  public void addPropertyChangeListener(PropertyChangeListener l) {
    if (propChangeListeners != null) {
      propChangeListeners.add(l);
    }
  }

  public void addElementChangeListener(ElementChangeListener listener) {
    changeListeners.add(listener);
  }

  private void firePropertyChangeEvent(PropertyChangeEvent evt) {
    for (PropertyChangeListener l : propChangeListeners) l.propertyChange(evt);
  }

  private void clear() {
    disableCDELinks();
    tempDE = DomainObjectFactory.newDataElement();

    ValueDomain vd = DomainObjectFactory.newValueDomain();

    List<AttributeDatatypePair> attTypesPairs =
        ElementsLists.getInstance().getElements(new AttributeDatatypePair("", ""));
    String datatype = null;
    String attributeName = LookupUtil.lookupFullName(de);
    for (AttributeDatatypePair pair : attTypesPairs) {
      if (pair.getAttributeName().equals(attributeName)) {
        datatype = pair.getDatatype();
      }
    }

    if (datatype == null) datatype = "";
    else {
      if (DatatypeMapping.getKeys().contains(datatype.toLowerCase()))
        datatype = DatatypeMapping.getMapping().get(datatype.toLowerCase());
    }

    vd.setLongName(datatype);

    tempDE.setValueDomain(vd);

    deLongNameValueLabel.setText("");
    deIdValueLabel.setText("");
    deContextNameValueLabel.setText("");
    vdLongNameValueLabel.setText("");
    conceptCodeSummaryValue.setText("");
    conceptNameSummaryValue.setText("");
  }

  public void setEnabled(boolean enabled) {
    searchDeButton.setEnabled(enabled);
    clearButton.setEnabled(enabled);
  }

  private void updateFields() {
    deLongNameValueLabel.setText(tempDE.getLongName());
    deIdValueLabel.setText(ConventionUtil.publicIdVersion(tempDE));
    if (tempDE.getContext() != null) deContextNameValueLabel.setText(tempDE.getContext().getName());
    else deContextNameValueLabel.setText("");

    if (tempDE.getValueDomain() != null)
      vdLongNameValueLabel.setText(tempDE.getValueDomain().getLongName());
    else vdLongNameValueLabel.setText("");

    if (prefs.getShowConceptCodeNameSummary()) {
      List<gov.nih.nci.ncicb.cadsr.domain.Concept> concepts =
          cadsrModule.getConcepts(tempDE.getDataElementConcept().getProperty());
      if (concepts != null && concepts.size() > 0) {
        StringBuffer conceptCodeSummary = new StringBuffer();
        StringBuffer conceptNameSummary = new StringBuffer();
        for (Concept con : concepts) {
          conceptCodeSummary.append(con.getPreferredName());
          conceptCodeSummary.append(" ");
          conceptNameSummary.append(con.getLongName());
          conceptNameSummary.append(" ");
        }
        conceptCodeSummaryValue.setText(conceptCodeSummary.toString());
        conceptNameSummaryValue.setText(conceptNameSummary.toString());
      }
    }
    enableCDELinks();
  }

  public void applyPressed() {
    apply();
  }

  public void apply() {
    if (!modified) return;

    // uncomment to enable feature

    //     if(inheritedAttributes.isInherited(de)) {
    //       if(!userPrefs.getBoolean("de.over.vd.mapping.warning")) {
    //         DontWarnMeAgainDialog dontWarnDialog = new
    // DontWarnMeAgainDialog("de.over.vd.mapping.warning");
    //       }
    //     }

    modified = false;

    de.setLongName(tempDE.getLongName());
    de.setPublicId(tempDE.getPublicId());
    de.setVersion(tempDE.getVersion());
    de.setContext(tempDE.getContext());
    de.setValueDomain(tempDE.getValueDomain());

    fireElementChangeEvent(new ElementChangeEvent(node));

    if (tempDE.getDataElementConcept() != null) {
      if (de.getDataElementConcept().getObjectClass().getPublicId() == null
          || de.getDataElementConcept().getObjectClass().getPublicId().length() == 0) {
        JOptionPane.showMessageDialog(
            null,
            PropertyAccessor.getProperty("oc.mapping.warning"),
            "Please note",
            JOptionPane.INFORMATION_MESSAGE);
      }

      de.getDataElementConcept()
          .getObjectClass()
          .setPublicId(tempDE.getDataElementConcept().getObjectClass().getPublicId());
      de.getDataElementConcept()
          .getObjectClass()
          .setVersion(tempDE.getDataElementConcept().getObjectClass().getVersion());
      de.getDataElementConcept()
          .getObjectClass()
          .setLongName(tempDE.getDataElementConcept().getObjectClass().getLongName());

      de.getDataElementConcept()
          .getProperty()
          .setPublicId(tempDE.getDataElementConcept().getProperty().getPublicId());
      de.getDataElementConcept()
          .getProperty()
          .setVersion(tempDE.getDataElementConcept().getProperty().getVersion());

    } else {
      boolean found = false;
      List<DataElement> des =
          ElementsLists.getInstance().getElements(DomainObjectFactory.newDataElement());
      for (DataElement curDe : des) {
        if (curDe.getDataElementConcept().getObjectClass()
            == de.getDataElementConcept().getObjectClass())
          if (!StringUtil.isEmpty(curDe.getPublicId())) {
            found = true;
          }
      }
      if (!found) {
        de.getDataElementConcept().getObjectClass().setPublicId(null);
        de.getDataElementConcept().getObjectClass().setVersion(null);
      }
    }

    if (tempDE.getDataElementConcept() != null) {
      firePropertyChangeEvent(new PropertyChangeEvent(this, ButtonPanel.SWITCH, null, false));
      firePropertyChangeEvent(new PropertyChangeEvent(this, ApplyButtonPanel.REVIEW, null, true));
    } else {
      firePropertyChangeEvent(new PropertyChangeEvent(this, ButtonPanel.SWITCH, null, true));
      firePropertyChangeEvent(new PropertyChangeEvent(this, ApplyButtonPanel.REVIEW, null, false));
    }
    firePropertyChangeEvent(new PropertyChangeEvent(this, ApplyButtonPanel.SAVE, null, false));
  }

  private void fireElementChangeEvent(ElementChangeEvent event) {
    for (ElementChangeListener l : changeListeners) l.elementChanged(event);
  }

  private void enableCDELinks() {
    cdeBrowserLinkValueLabel.setVisible(true);
    cdeBrowserLinkValueLabel.setText(getCDEBrowserURL());
    cdeBrowserLinkValueLabel.setForeground(Color.BLUE);
  }

  private void disableCDELinks() {
    cdeBrowserLinkValueLabel.setVisible(false);
    cdeBrowserLinkValueLabel.setText("");
  }

  private String getCDEBrowserURL() {
    cdeURL = "http://cdebrowser.nci.nih.gov/CDEBrowser/";

    // Add code to construst URL for CDE.

    return cdeURL;
  }
  //  public static void main(String[] args)
  //  {
  ////    JFrame frame = new JFrame();
  ////    DEPanel dePanel = new DEPanel();
  ////    dePanel.setVisible(true);
  ////    frame.add(dePanel);
  ////    frame.setVisible(true);
  ////    frame.setSize(450, 350);
  //  }

  public void setCadsrModule(CadsrModule cadsrModule) {
    this.cadsrModule = cadsrModule;
  }
}