private static void appendHTML(JEditorPane editor, String html) {
   try {
     html = StringUtil.replaceAll(html, "\t", "    ");
     html = StringUtil.replaceAll(html, "\r\n", "\n");
     html = StringUtil.replaceAll(html, "\r", "");
     Vector vt = StringUtil.toStringVector(html, "\n");
     HTMLEditorKit kit = (HTMLEditorKit) editor.getEditorKit();
     HTMLDocument doc = (HTMLDocument) editor.getDocument();
     for (int iIndex = 0; iIndex < vt.size(); iIndex++)
       kit.insertHTML(doc, doc.getLength(), (String) vt.elementAt(iIndex), 0, 0, null);
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
 public boolean isVerified() {
   boolean enable = !StringUtil.isEmpty(getProjectName());
   try {
     enable = (new Float(getProjectVersion()) > 0);
   } catch (NumberFormatException e) {
     enable = false;
   } // end of try-catch
   return enable;
 }
Example #3
0
  public void setNoteName(String noteName) {
    int idx = 0;
    int i = 0;
    for (int c = _lstFile.getElementCount() - 1; i < c; i++) {
      ListElement le = (ListElement) _lstFile.getElement(i);
      if (StringUtil.equalsIgnoreCase(le.getName(), noteName)) idx = i;
    }

    _lstFile.setSelectedIndex(idx);
    super.btnOk.setEnabled(idx != -1);
  }
Example #4
0
 public String toString() {
   if (StringUtil.isEmptyString(alias)) return name;
   if (isShowFileName()) {
     StringBuffer sb = new StringBuffer();
     sb.append(alias);
     sb.append("(");
     sb.append(name);
     sb.append(")");
     return sb.toString();
   } else {
     return alias;
   }
 }
Example #5
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())));
    }
  }
Example #6
0
 void insertMatchButton_actionPerformed(ActionEvent e) {
   String key = (String) matchComboBox.getSelectedItem();
   String format = (String) matchesKeys.get(key);
   if (key.equals(STRING_LITERAL)) {
     format =
         escapeReservedChars(
             (String)
                 JOptionPane.showInputDialog(
                     this,
                     "Enter the string you wish to match",
                     "String Literal Input",
                     JOptionPane.OK_CANCEL_OPTION));
     if (StringUtil.isNullString(format)) {
       return;
     }
   }
   if (selectedPane == 0) {
     insertText(format, PLAIN_ATTR, editorPane.getSelectionStart());
   } else {
     // add the combobox data value to the edit box
     int pos = formatTextArea.getCaretPosition();
     formatTextArea.insert(format, pos);
   }
 }
 /*.................................................................................................................*/
 public String preparePreferencesForXML() {
   StringBuffer buffer = new StringBuffer(200);
   StringUtil.appendXMLTag(buffer, 2, "availMemory", availMemory);
   buffer.append(super.preparePreferencesForXML());
   return buffer.toString();
 }
 private void jbInit() throws Exception {
   ////////////////////////////////////////////////////////
   // Init LAF
   ////////////////////////////////////////////////////////
   ButtonGroup grpLAF = new ButtonGroup();
   ActionListener lsnLAF =
       new ActionListener() {
         public void actionPerformed(ActionEvent evt) {
           int iIndex = mvtLAFItem.indexOf(evt.getSource());
           if (iIndex >= 0) changeLAF(iIndex);
         }
       };
   ////////////////////////////////////////////////////////
   UIManager.LookAndFeelInfo laf =
       new UIManager.LookAndFeelInfo(
           "Kunststoff", "com.incors.plaf.kunststoff.KunststoffLookAndFeel");
   marrLaf = UIManager.getInstalledLookAndFeels();
   int iIndex = 0;
   while (iIndex < marrLaf.length && !marrLaf[iIndex].getName().equals(laf.getName())) iIndex++;
   if (iIndex >= marrLaf.length) {
     UIManager.installLookAndFeel(laf);
     marrLaf = UIManager.getInstalledLookAndFeels();
   }
   for (iIndex = 0; iIndex < marrLaf.length; iIndex++) {
     JMenuItem mnu = new JRadioButtonMenuItem(marrLaf[iIndex].getName());
     mnu.addActionListener(lsnLAF);
     mvtLAFItem.addElement(mnu);
     mnuUI.add(mnu);
     grpLAF.add(mnu);
   }
   mnuUI.addSeparator();
   ////////////////////////////////////////////////////////
   // Init language
   ////////////////////////////////////////////////////////
   ButtonGroup grpLanguage = new ButtonGroup();
   ActionListener lsnLanguage =
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           int iIndex = mvtLanguageItem.indexOf(e.getSource());
           if (iIndex >= 0) changeDictionary((String) mvtLanguage.elementAt(iIndex));
         }
       };
   ////////////////////////////////////////////////////////
   String[] str = MonitorDictionary.getSupportedLanguage();
   for (iIndex = 0; iIndex < str.length; iIndex++) {
     JMenuItem mnu =
         new JRadioButtonMenuItem(MonitorDictionary.getDictionary(str[iIndex]).getLanguage());
     mnu.addActionListener(lsnLanguage);
     mvtLanguage.addElement(str[iIndex]);
     mvtLanguageItem.addElement(mnu);
     mnuUI.add(mnu);
     grpLanguage.add(mnu);
   }
   ////////////////////////////////////////////////////////
   // Add to main menu
   ////////////////////////////////////////////////////////
   mnuMain.removeAll();
   mnuMain.add(mnuSystem);
   mnuSystem.add(mnuSystem_Login);
   mnuSystem.add(mnuSystem_ChangePassword);
   mnuSystem.addSeparator();
   mnuSystem.add(mnuSystem_StopServer);
   mnuSystem.add(mnuSystem_EnableThreads);
   mnuMain.add(mnuUI);
   mnuMain.add(mnuHelp);
   mnuHelp.add(mnuHelp_About);
   ////////////////////////////////////////////////////////
   mnuMain.add(chkVietnamese);
   mnuMain.add(lblStatus);
   ////////////////////////////////////////////////////////
   pnlThread.setTabPlacement(JTabbedPane.LEFT);
   pnlThread.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
   ////////////////////////////////////////////////////////
   tblUser.addColumn("", 1, false);
   tblUser.addColumn("", 2, false, Global.FORMAT_DATE_TIME);
   tblUser.addColumn("", 3, false);
   ////////////////////////////////////////////////////////
   JPanel pnlMessage = new JPanel();
   pnlMessage.setLayout(new GridBagLayout());
   pnlMessage.add(
       new JScrollPane(txtBoard),
       new GridBagConstraints(
           0,
           0,
           2,
           1,
           1.0,
           1.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.BOTH,
           new Insets(2, 2, 2, 2),
           0,
           0));
   pnlMessage.add(
       txtMessage,
       new GridBagConstraints(
           0,
           1,
           1,
           1,
           1.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.BOTH,
           new Insets(2, 2, 2, 2),
           0,
           0));
   pnlMessage.add(
       btnSend,
       new GridBagConstraints(
           1,
           1,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.NONE,
           new Insets(2, 2, 2, 2),
           0,
           0));
   txtBoard.setEditable(false);
   txtBoard.setAutoscrolls(true);
   txtBoard.setContentType("text/html");
   clearAll(txtBoard);
   ////////////////////////////////////////////////////////
   JPanel pnlUserButton = new JPanel(new GridLayout(1, 2, 4, 4));
   pnlUserButton.add(btnKick);
   pnlUserButton.add(btnRefresh);
   ////////////////////////////////////////////////////////
   JPanel pnlManager = new JPanel(new GridBagLayout());
   pnlManager.add(
       new JScrollPane(tblUser),
       new GridBagConstraints(
           0,
           0,
           1,
           1,
           1.0,
           1.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.BOTH,
           new Insets(2, 2, 2, 2),
           0,
           0));
   pnlManager.add(
       pnlUserButton,
       new GridBagConstraints(
           0,
           1,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.NONE,
           new Insets(4, 2, 4, 2),
           0,
           0));
   ////////////////////////////////////////////////////////
   pnlUser.setDividerLocation(320);
   pnlUser.setLeftComponent(pnlManager);
   pnlUser.setRightComponent(pnlMessage);
   pnlUser.setOneTouchExpandable(true);
   ////////////////////////////////////////////////////////
   setOrientation(JSplitPane.VERTICAL_SPLIT);
   setOneTouchExpandable(true);
   pnlThread.setVisible(false);
   pnlUser.setVisible(false);
   setTopComponent(pnlThread);
   setBottomComponent(pnlUser);
   ////////////////////////////////////////////////////////
   pmn.add(mnuSelectAll);
   pmn.addSeparator();
   pmn.add(mnuClearSelected);
   pmn.add(mnuClearAll);
   ////////////////////////////////////////////////////////
   setBorder(BorderFactory.createEmptyBorder());
   pnlUser.setBorder(BorderFactory.createEmptyBorder());
   pnlManager.setBorder(
       BorderFactory.createBevelBorder(
           javax.swing.border.BevelBorder.RAISED,
           Color.white,
           UIManager.getColor("Panel.background"),
           UIManager.getColor("Panel.background"),
           UIManager.getColor("Panel.background")));
   pnlMessage.setBorder(
       BorderFactory.createBevelBorder(
           javax.swing.border.BevelBorder.RAISED,
           Color.white,
           UIManager.getColor("Panel.background"),
           UIManager.getColor("Panel.background"),
           UIManager.getColor("Panel.background")));
   ////////////////////////////////////////////////////////
   Skin.applySkin(mnuMain);
   Skin.applySkin(tblUser);
   Skin.applySkin(pmn);
   Skin.applySkin(this);
   ////////////////////////////////////////////////////////
   // Default setting
   ////////////////////////////////////////////////////////
   Hashtable prt = null;
   try {
     prt = Global.loadHashtable(Global.FILE_CONFIG);
   } catch (Exception e) {
     prt = new Hashtable();
   }
   changeLAF(Integer.parseInt(StringUtil.nvl(prt.get("LAF"), "0")));
   changeDictionary(StringUtil.nvl(prt.get("Language"), "VN"));
   Skin.LANGUAGE_CHANGE_LISTENER = this;
   MonitorProcessor.setRootObject(this);
   updateKeyboardUI();
   ////////////////////////////////////////////////////////
   // Event handler
   ////////////////////////////////////////////////////////
   tblUser.addMouseListener(
       new MouseAdapter() {
         public void mouseClicked(MouseEvent e) {
           if (e.getClickCount() > 1) btnKick.doClick();
         }
       });
   ////////////////////////////////////////////////////////
   btnRefresh.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent evt) {
           try {
             DDTP request = new DDTP();
             request.setRequestID(String.valueOf(System.currentTimeMillis()));
             DDTP response = channel.sendRequest("ThreadProcessor", "queryUserList", request);
             if (response != null) {
               tblUser.setData((Vector) response.getReturn());
               if (mstrChannel != null) removeUser(mstrChannel);
             }
           } catch (Exception e) {
             e.printStackTrace();
             MessageBox.showMessageDialog(pnlThread, e, Global.APP_NAME, MessageBox.ERROR_MESSAGE);
           }
         }
       });
   ////////////////////////////////////////////////////////
   btnKick.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent evt) {
           int iSelected = tblUser.getSelectedRow();
           if (iSelected < 0) return;
           int iResult =
               MessageBox.showConfirmDialog(
                   pnlThread,
                   mdic.getString("ConfirmKick"),
                   Global.APP_NAME,
                   MessageBox.YES_NO_OPTION);
           if (iResult == MessageBox.NO_OPTION) return;
           try {
             String strChannel = (String) tblUser.getRow(iSelected).elementAt(0);
             DDTP request = new DDTP();
             request.setRequestID(String.valueOf(System.currentTimeMillis()));
             request.setString("strChannel", strChannel);
             DDTP response = channel.sendRequest("ThreadProcessor", "kickUser", request);
           } catch (Exception e) {
             e.printStackTrace();
             MessageBox.showMessageDialog(pnlThread, e, Global.APP_NAME, MessageBox.ERROR_MESSAGE);
           }
         }
       });
   ////////////////////////////////////////////////////////
   txtMessage.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent evt) {
           btnSend.doClick();
         }
       });
   ////////////////////////////////////////////////////////
   btnSend.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent evt) {
           if (txtMessage.getText().length() == 0) return;
           try {
             DDTP request = new DDTP();
             request.setString("strMessage", txtMessage.getText());
             channel.sendRequest("ThreadProcessor", "sendMessage", request);
             txtMessage.setText("");
           } catch (Exception e) {
             e.printStackTrace();
             MessageBox.showMessageDialog(pnlThread, e, Global.APP_NAME, MessageBox.ERROR_MESSAGE);
           }
         }
       });
   ////////////////////////////////////////////////////////
   mnuClearAll.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent e) {
           clearAll(txtBoard);
         }
       });
   ////////////////////////////////////////////////////////
   mnuClearSelected.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent e) {
           txtBoard.setEditable(true);
           txtBoard.replaceSelection("");
           txtBoard.setEditable(false);
         }
       });
   ////////////////////////////////////////////////////////
   mnuSelectAll.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent e) {
           txtBoard.requestFocus();
           txtBoard.selectAll();
         }
       });
   ////////////////////////////////////////////////////////
   txtBoard.addMouseListener(
       new MouseAdapter() {
         public void mouseClicked(MouseEvent e) {
           if (e.getButton() == e.BUTTON3) pmn.show(txtBoard, e.getX(), e.getY());
         }
       });
   ////////////////////////////////////////////////////////
   mnuSystem_Login.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           login();
         }
       });
   ////////////////////////////////////////////////////////
   mnuSystem_ChangePassword.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           changePassword();
         }
       });
   ////////////////////////////////////////////////////////
   mnuSystem_StopServer.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           stopServer();
         }
       });
   ////////////////////////////////////////////////////////
   mnuSystem_EnableThreads.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           manageThreads();
         }
       });
   ////////////////////////////////////////////////////////
   mnuHelp_About.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           WindowManager.centeredWindow(new DialogAbout(PanelThreadManager.this));
         }
       });
   ////////////////////////////////////////////////////////
   chkVietnamese.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent e) {
           switchKeyboard();
         }
       });
 }
 public String getAppVersion() {
   return StringUtil.nvl(mstrAppVersion, "Unknown version");
 }
 public String getAppName() {
   return StringUtil.nvl(mstrAppName, "Unknown application");
 }
 public String getThreadAppName() {
   return StringUtil.nvl(mstrThreadAppName, "Unknown platform");
 }
  public void login() {
    mbAutoLogIn = false;
    while (!mbAutoLogIn) {
      try {
        // Confirm logout
        if (isOpen()) {
          if (MessageBox.showConfirmDialog(
                  this,
                  MonitorDictionary.getString("Confirm.Exit"),
                  Global.APP_NAME,
                  MessageBox.YES_NO_OPTION)
              == MessageBox.NO_OPTION) return;

          // Disconnect from server
          disconnect();
        }

        // Login
        DialogLogin dlgLogin = new DialogLogin(this);
        WindowManager.centeredWindow(dlgLogin);

        if (dlgLogin.miReturn == JOptionPane.OK_OPTION) {
          // Update UI
          SwingUtilities.updateComponentTreeUI(pnlUser);
          SwingUtilities.updateComponentTreeUI(pnlThread);

          // Request to connect
          Socket sck = new Socket(dlgLogin.mstrHost, Integer.parseInt(dlgLogin.mstrPort));
          sck.setSoLinger(true, 0);

          // Start up a channel thread that reads messages from the server
          channel =
              new SocketTransmitter(sck) {
                public void close() {
                  if (msckMain != null) {
                    super.close();
                    closeAll();
                    if (mbAutoLogIn) login();
                  }
                }
              };
          channel.setUserName(dlgLogin.mstrUserName);
          channel.setPackage("com.fss.thread.");
          channel.start();

          // Request to Server
          DDTP request = new DDTP();
          request.setRequestID(String.valueOf(System.currentTimeMillis()));
          request.setString("UserName", dlgLogin.mstrUserName);
          request.setString("Password", dlgLogin.mstrPassword);

          // Response from Server
          DDTP response = channel.sendRequest("ThreadProcessor", "login", request);
          mstrThreadAppName = response.getString("strThreadAppName");
          mstrThreadAppVersion = response.getString("strThreadAppVersion");
          mstrAppName = response.getString("strAppName");
          mstrAppVersion = response.getString("strAppVersion");
          if (response != null) {
            if (response.getString("PasswordExpired") != null) {
              DialogChangePassword frm = new DialogChangePassword(this, channel);
              WindowManager.centeredWindow(frm);
              if (frm.miReturnValue != JOptionPane.OK_OPTION) throw new AppException("FSS-10003");
            }
            String strLog = StringUtil.nvl(response.getString("strLog"), "");
            showResult(txtBoard, strLog);
            Vector vtThread = response.getVector("vtThread");
            updateTabBar(vtThread);

            mstrChannel = response.getString("strChannel");
            if (mstrChannel != null) removeUser(mstrChannel);
          }
          btnRefresh.doClick();
          pnlThread.setVisible(true);
          pnlUser.setVisible(true);
          setResizeWeight(1);
          setDividerLocation((int) (getSize().getHeight() - 160));
        }
        mbAutoLogIn = true;
        updateLanguage();
      } catch (Exception e) {
        e.printStackTrace();
        MessageBox.showMessageDialog(this, e, Global.APP_NAME, MessageBox.ERROR_MESSAGE);

        // Disconnect from server
        mstrChannel = null;
        disconnect();
      }
    }
  }
Example #13
0
  void insertButton_actionPerformed(ActionEvent e) {
    Object selected = paramComboBox.getSelectedItem();
    ConfigParamDescr descr;
    String key;
    int type = 0;
    String format = "";
    if (selected instanceof ConfigParamDescr) {
      descr = (ConfigParamDescr) selected;
      key = descr.getKey();
      type = descr.getType();
      switch (type) {
        case ConfigParamDescr.TYPE_STRING:
        case ConfigParamDescr.TYPE_URL:
        case ConfigParamDescr.TYPE_BOOLEAN:
          format = "%s";
          break;
        case ConfigParamDescr.TYPE_INT:
        case ConfigParamDescr.TYPE_LONG:
        case ConfigParamDescr.TYPE_POS_INT:
          NumericPaddingDialog dialog = new NumericPaddingDialog();
          Point pos = this.getLocationOnScreen();
          dialog.setLocation(pos.x, pos.y);
          dialog.pack();
          dialog.setVisible(true);
          StringBuilder fbuf = new StringBuilder("%");
          int width = dialog.getPaddingSize();
          boolean is_zero = dialog.useZero();
          if (width > 0) {
            fbuf.append(".");
            if (is_zero) {
              fbuf.append(0);
            }
            fbuf.append(width);
          }
          if (type == ConfigParamDescr.TYPE_LONG) {
            fbuf.append("ld");
          } else {
            fbuf.append("d");
          }
          format = fbuf.toString();
          break;
        case ConfigParamDescr.TYPE_YEAR:
          if (key.startsWith(DefinableArchivalUnit.PREFIX_AU_SHORT_YEAR)) {
            format = "%02d";
          } else {
            format = "%d";
          }
          break;
        case ConfigParamDescr.TYPE_RANGE:
        case ConfigParamDescr.TYPE_NUM_RANGE:
        case ConfigParamDescr.TYPE_SET:
          format = "%s";
          break;
      }
      if (selectedPane == 0) {
        insertParameter(descr, format, editorPane.getSelectionStart());
      } else if (selectedPane == 1) {
        // add the combobox data value to the edit box
        int pos = formatTextArea.getCaretPosition();
        formatTextArea.insert(format, pos);

        pos = parameterTextArea.getCaretPosition();
        parameterTextArea.insert(", " + key, pos);
      }
    } else {
      key = selected.toString();
      format =
          escapePrintfChars(
              (String)
                  JOptionPane.showInputDialog(
                      this,
                      "Enter the string you wish to input",
                      "String Literal Input",
                      JOptionPane.OK_CANCEL_OPTION));
      if (StringUtil.isNullString(format)) {
        return;
      }
      if (selectedPane == 0) {
        insertText(format, PLAIN_ATTR, editorPane.getSelectionStart());
      } else if (selectedPane == 1) {
        // add the combobox data value to the edit box
        formatTextArea.insert(format, formatTextArea.getCaretPosition());
      }
    }
  }
Example #14
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())));
  }
Example #15
0
  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));
  }