List of usage examples for javax.swing JOptionPane showInputDialog
@SuppressWarnings("deprecation") public static Object showInputDialog(Component parentComponent, Object message, String title, int messageType, Icon icon, Object[] selectionValues, Object initialSelectionValue) throws HeadlessException
From source file:org.fhcrc.cpl.viewer.gui.MRMDialog.java
public void menuItemChangeStrategy_actionPerformed(ActionEvent event) { try {/* w w w . j a v a 2s . c om*/ String newStrategyName = (String) JOptionPane.showInputDialog(this, "Which elution curve strategy would you like to use?", "Elution Strategy", JOptionPane.PLAIN_MESSAGE, null, MRMCommandLineModule.strategies, MRMCommandLineModule.strategies[0]); newStrategyName = "org.fhcrc.cpl.viewer.mrm." + newStrategyName; if (newStrategyName != _ecurveclass.getName()) { Class newClass = Class.forName(newStrategyName); _ecurveclass = newClass; initStuff(); } } catch (Exception e) { ApplicationContext.infoMessage("Cannot change elution curve strategy: " + e); } }
From source file:com.mirth.connect.client.ui.SettingsPanelServer.java
private void testEmailButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_testEmailButtonActionPerformed resetInvalidSettings();//from w ww .j a va 2 s. c o m ServerSettings serverSettings = getServerSettings(); StringBuilder invalidFields = new StringBuilder(); if (StringUtils.isBlank(serverSettings.getSmtpHost())) { smtpHostField.setBackground(UIConstants.INVALID_COLOR); invalidFields.append("\"SMTP Host\" is required\n"); } if (StringUtils.isBlank(serverSettings.getSmtpPort())) { smtpPortField.setBackground(UIConstants.INVALID_COLOR); invalidFields.append("\"SMTP Port\" is required\n"); } if (StringUtils.isBlank(serverSettings.getSmtpTimeout())) { smtpTimeoutField.setBackground(UIConstants.INVALID_COLOR); invalidFields.append("\"Send Timeout\" is required\n"); } if (StringUtils.isBlank(serverSettings.getSmtpFrom())) { defaultFromAddressField.setBackground(UIConstants.INVALID_COLOR); invalidFields.append("\"Default From Address\" is required\n"); } if (serverSettings.getSmtpAuth()) { if (StringUtils.isBlank(serverSettings.getSmtpUsername())) { usernameField.setBackground(UIConstants.INVALID_COLOR); invalidFields.append("\"Username\" is required\n"); } if (StringUtils.isBlank(serverSettings.getSmtpPassword())) { passwordField.setBackground(UIConstants.INVALID_COLOR); invalidFields.append("\"Password\" is required\n"); } } String errors = invalidFields.toString(); if (StringUtils.isNotBlank(errors)) { PlatformUI.MIRTH_FRAME.alertCustomError(PlatformUI.MIRTH_FRAME, errors, "Please fix the following errors before sending a test email:"); return; } String sendToEmail = (String) JOptionPane.showInputDialog(PlatformUI.MIRTH_FRAME, "Send test email to:", "Send Test Email", JOptionPane.INFORMATION_MESSAGE, null, null, serverSettings.getSmtpFrom()); if (StringUtils.isNotBlank(sendToEmail)) { try { new InternetAddress(sendToEmail).validate(); } catch (Exception error) { PlatformUI.MIRTH_FRAME.alertWarning(PlatformUI.MIRTH_FRAME, "The Send To Address is invalid: " + error.getMessage()); return; } final Properties properties = new Properties(); properties.put("port", serverSettings.getSmtpPort()); properties.put("encryption", serverSettings.getSmtpSecure()); properties.put("host", serverSettings.getSmtpHost()); properties.put("timeout", serverSettings.getSmtpTimeout()); properties.put("authentication", String.valueOf(serverSettings.getSmtpAuth())); properties.put("username", serverSettings.getSmtpUsername()); properties.put("password", serverSettings.getSmtpPassword()); properties.put("toAddress", sendToEmail); properties.put("fromAddress", serverSettings.getSmtpFrom()); final String workingId = PlatformUI.MIRTH_FRAME.startWorking("Sending test email..."); SwingWorker worker = new SwingWorker<Void, Void>() { public Void doInBackground() { try { ConnectionTestResponse response = (ConnectionTestResponse) PlatformUI.MIRTH_FRAME.mirthClient .sendTestEmail(properties); if (response == null) { PlatformUI.MIRTH_FRAME.alertError(PlatformUI.MIRTH_FRAME, "Failed to send email."); } else if (response.getType().equals(ConnectionTestResponse.Type.SUCCESS)) { PlatformUI.MIRTH_FRAME.alertInformation(PlatformUI.MIRTH_FRAME, response.getMessage()); } else { PlatformUI.MIRTH_FRAME.alertWarning(PlatformUI.MIRTH_FRAME, response.getMessage()); } return null; } catch (Exception e) { PlatformUI.MIRTH_FRAME.alertThrowable(PlatformUI.MIRTH_FRAME, e); return null; } } public void done() { PlatformUI.MIRTH_FRAME.stopWorking(workingId); } }; worker.execute(); } }
From source file:edu.harvard.i2b2.previousquery.ui.PreviousQueryPanel.java
public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equalsIgnoreCase("Rename ...")) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getSelectionPath().getLastPathComponent(); if (node.getUserObject().getClass().getSimpleName().equalsIgnoreCase("QueryMasterData")) { QueryMasterData ndata = (QueryMasterData) node.getUserObject(); Object inputValue = JOptionPane.showInputDialog(this, "Rename this query to: ", "Rename Query Dialog", JOptionPane.PLAIN_MESSAGE, null, null, ndata.name().substring(0, ndata.name().indexOf("[") - 1)); if (inputValue != null) { String newQueryName = (String) inputValue; String requestXml = ndata.writeRenameQueryXML(newQueryName); setCursor(new Cursor(Cursor.WAIT_CURSOR)); String response = null; if (System.getProperty("webServiceMethod").equals("SOAP")) { // TO DO // response = // QueryListNamesClient.sendQueryRequestSOAP(requestXml); } else { response = QueryListNamesClient.sendQueryRequestREST(requestXml); }/* w w w.ja va 2s . c o m*/ if (response.equalsIgnoreCase("CellDown")) { final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "Trouble with connection to the remote server, " + "this is often a network error, please try again", "Network Error", JOptionPane.INFORMATION_MESSAGE); } }); setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); return; } if (response != null) { JAXBUtil jaxbUtil = PreviousQueryJAXBUtil.getJAXBUtil(); try { JAXBElement jaxbElement = jaxbUtil.unMashallFromString(response); ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue(); StatusType statusType = messageType.getResponseHeader().getResultStatus().getStatus(); String status = statusType.getType(); if (status.equalsIgnoreCase("DONE")) { // XMLGregorianCalendar cldr = // //queryMasterType.getCreateDate(); Calendar cldr = Calendar.getInstance(Locale.getDefault()); ndata.name(newQueryName + " [" + addZero(cldr.get(Calendar.MONTH) + 1) + "-" + addZero(cldr.get(Calendar.DAY_OF_MONTH)) + "-" + addZero(cldr.get(Calendar.YEAR)) + " ]" + " [" + ndata.userId() + "]"); // ndata.name(newQueryName + " [" + // ndata.userId() // + "]"); node.setUserObject(ndata); // DefaultMutableTreeNode parent = // (DefaultMutableTreeNode) node.getParent(); jTree1.repaint(); } } catch (Exception ex) { ex.printStackTrace(); } } } } else if (node.getUserObject().getClass().getSimpleName().equalsIgnoreCase("QueryResultData")) { QueryResultData rdata = (QueryResultData) node.getUserObject(); // if(!rdata.type().equalsIgnoreCase("PatientSet")) { // return; // } Object inputValue1 = JOptionPane.showInputDialog(this, "Rename this to: ", "Renaming Dialog", JOptionPane.PLAIN_MESSAGE, null, null, rdata.name()); // .substring(0, rdata.name().lastIndexOf("[") - 1)); if (inputValue1 != null) { String newQueryName = (String) inputValue1; String requestXml = rdata.writeRenameQueryXML(newQueryName); setCursor(new Cursor(Cursor.WAIT_CURSOR)); String response = null; if (System.getProperty("webServiceMethod").equals("SOAP")) { // TO DO // response = // QueryListNamesClient.sendQueryRequestSOAP(requestXml); } else { response = QueryListNamesClient.sendQueryRequestREST(requestXml); } if (response.equalsIgnoreCase("CellDown")) { final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "Trouble with connection to the remote server, " + "this is often a network error, please try again", "Network Error", JOptionPane.INFORMATION_MESSAGE); } }); setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); return; } if (response != null) { JAXBUtil jaxbUtil = PreviousQueryJAXBUtil.getJAXBUtil(); try { JAXBElement jaxbElement = jaxbUtil.unMashallFromString(response); ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue(); StatusType statusType = messageType.getResponseHeader().getResultStatus().getStatus(); String status = statusType.getType(); if (status.equalsIgnoreCase("DONE")) { rdata.name(newQueryName);// + " [" + // rdata.userId() // + "]"); node.setUserObject(rdata); // DefaultMutableTreeNode parent = // (DefaultMutableTreeNode) node.getParent(); jTree1.repaint(); } else { final String tmp = response; final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "Error message delivered from the remote server, " + "you may wish to retry your last action", "Server Error", JOptionPane.INFORMATION_MESSAGE); log.error(tmp); setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); return; } } catch (Exception ex) { ex.printStackTrace(); } } } } setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } else if (e.getActionCommand().equalsIgnoreCase("Cancel")) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getSelectionPath().getLastPathComponent(); if (node.getUserObject().getClass().getSimpleName().equalsIgnoreCase("QueryMasterData")) { DefaultMutableTreeNode node1 = (DefaultMutableTreeNode) node.getFirstChild(); if (node1.getUserObject().getClass().getSimpleName().equalsIgnoreCase("QueryMasterData")) { final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "Please expand this node then try to cancel it.", "Message", JOptionPane.INFORMATION_MESSAGE); } }); return; } QueryInstanceData rdata = (QueryInstanceData) node1.getUserObject(); String requestXml = rdata.writeCancelQueryXML(); setCursor(new Cursor(Cursor.WAIT_CURSOR)); String response = null; if (System.getProperty("webServiceMethod").equals("SOAP")) { // TO DO // response = // QueryListNamesClient.sendQueryRequestSOAP(requestXml); } else { response = QueryListNamesClient.sendQueryRequestREST(requestXml); } if (response.equalsIgnoreCase("CellDown")) { final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "Trouble with connection to the remote server, " + "this is often a network error, please try again", "Network Error", JOptionPane.INFORMATION_MESSAGE); } }); setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); return; } if (response != null) { JAXBUtil jaxbUtil = PreviousQueryJAXBUtil.getJAXBUtil(); try { JAXBElement jaxbElement = jaxbUtil.unMashallFromString(response); ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue(); StatusType statusType = messageType.getResponseHeader().getResultStatus().getStatus(); String status = statusType.getType(); final JPanel parent = this; if (status.equalsIgnoreCase("DONE")) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "The query is finished.", "Message", JOptionPane.INFORMATION_MESSAGE); // log.error(tmp); setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); rdata.name(rdata.name().substring(0, rdata.name().indexOf("-")));// + " [" + // rdata // .userId() // + "]"); node.setUserObject(rdata); // DefaultMutableTreeNode parent = // (DefaultMutableTreeNode) node.getParent(); jTree1.repaint(); } else { final String tmp = response; // final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "Error message delivered from the remote server, " + "you may wish to retry your last action", "Server Error", JOptionPane.INFORMATION_MESSAGE); log.error(tmp); setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); return; } } catch (Exception ex) { ex.printStackTrace(); } // } } } else if (node.getUserObject().getClass().getSimpleName().equalsIgnoreCase("QueryInstanceData")) { QueryInstanceData rdata = (QueryInstanceData) node.getUserObject(); String requestXml = rdata.writeCancelQueryXML(); setCursor(new Cursor(Cursor.WAIT_CURSOR)); String response = null; if (System.getProperty("webServiceMethod").equals("SOAP")) { // TO DO // response = // QueryListNamesClient.sendQueryRequestSOAP(requestXml); } else { response = QueryListNamesClient.sendQueryRequestREST(requestXml); } if (response.equalsIgnoreCase("CellDown")) { final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "Trouble with connection to the remote server, " + "this is often a network error, please try again", "Network Error", JOptionPane.INFORMATION_MESSAGE); } }); setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); return; } if (response != null) { JAXBUtil jaxbUtil = PreviousQueryJAXBUtil.getJAXBUtil(); try { JAXBElement jaxbElement = jaxbUtil.unMashallFromString(response); ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue(); StatusType statusType = messageType.getResponseHeader().getResultStatus().getStatus(); String status = statusType.getType(); final JPanel parent = this; if (status.equalsIgnoreCase("DONE")) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "The query is finished.", "Message", JOptionPane.INFORMATION_MESSAGE); // log.error(tmp); setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); rdata.name(rdata.name().substring(0, rdata.name().indexOf("-")));// + " [" + // rdata // .userId() // + "]"); node.setUserObject(rdata); // DefaultMutableTreeNode parent = // (DefaultMutableTreeNode) node.getParent(); jTree1.repaint(); } else { final String tmp = response; // final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "Error message delivered from the remote server, " + "you may wish to retry your last action", "Server Error", JOptionPane.INFORMATION_MESSAGE); log.error(tmp); setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); return; } } catch (Exception ex) { ex.printStackTrace(); } // } } } else { final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "Cancel action is not supported on this level", "Message", JOptionPane.INFORMATION_MESSAGE); setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); } setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } else if (e.getActionCommand().equalsIgnoreCase("Delete")) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getSelectionPath().getLastPathComponent(); QueryMasterData ndata = (QueryMasterData) node.getUserObject(); Object selectedValue = JOptionPane.showConfirmDialog(this, "Delete Query \"" + ndata.name() + "\"?", "Delete Query Dialog", JOptionPane.YES_NO_OPTION); if (selectedValue.equals(JOptionPane.YES_OPTION)) { System.out.println("delete " + ndata.name()); String requestXml = ndata.writeDeleteQueryXML(); // System.out.println(requestXml); setCursor(new Cursor(Cursor.WAIT_CURSOR)); String response = null; if (System.getProperty("webServiceMethod").equals("SOAP")) { // TO DO // response = // QueryListNamesClient.sendQueryRequestSOAP(requestXml); } else { response = QueryListNamesClient.sendQueryRequestREST(requestXml); } if (response.equalsIgnoreCase("CellDown")) { final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "Trouble with connection to the remote server, " + "this is often a network error, please try again", "Network Error", JOptionPane.INFORMATION_MESSAGE); } }); setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); return; } if (response != null) { JAXBUtil jaxbUtil = PreviousQueryJAXBUtil.getJAXBUtil(); try { JAXBElement jaxbElement = jaxbUtil.unMashallFromString(response); ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue(); StatusType statusType = messageType.getResponseHeader().getResultStatus().getStatus(); String status = statusType.getType(); if (status.equalsIgnoreCase("DONE")) { treeModel.removeNodeFromParent(node); // jTree1.repaint(); } } catch (Exception ex) { ex.printStackTrace(); } } setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } } else if (e.getActionCommand().equalsIgnoreCase("Refresh All")) { String status = ""; if (isManager) { status = loadPreviousQueries("all users"); } else { status = loadPreviousQueries(UserInfoBean.getInstance().getUserName()); } if (status.equalsIgnoreCase("")) { reset(200, false, false); } else if (status.equalsIgnoreCase("CellDown")) { final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "Trouble with connection to the remote server, " + "this is often a network error, please try again", "Network Error", JOptionPane.INFORMATION_MESSAGE); } }); } } }
From source file:ru.apertum.qsystem.client.forms.FAdmin.java
@Action public void addUser() { // ? ? , String userName = ""; boolean flag = true; while (flag) { userName = (String) JOptionPane.showInputDialog(this, getLocaleMessage("admin.add_user_dialog.title"), getLocaleMessage("admin.add_user_dialog.caption"), 3, null, null, userName); if (userName == null) { return; }/*from ww w. j ava 2 s. c om*/ if ("".equals(userName)) { JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_user_dialog.err1.title"), getLocaleMessage("admin.add_user_dialog.err1.caption"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); } else if (QUserList.getInstance().hasByName(userName)) { JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_user_dialog.err2.title"), getLocaleMessage("admin.add_user_dialog.err2.caption"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); } else if (userName.indexOf('\"') != -1) { JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_user_dialog.err3.title"), getLocaleMessage("admin.add_user_dialog.err3.caption"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); } else if (userName.length() > 150) { JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_user_dialog.err4.title"), getLocaleMessage("admin.add_user_dialog.err4.caption"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); } else { flag = false; } } QLog.l().logger().debug("? ? \"" + userName + "\""); final QUser user = new QUser(); user.setPlanServices(new LinkedList<>()); user.setName(userName); user.setPassword(""); user.setPoint(""); user.setAdressRS(32); QUserList.getInstance().addElement(user); listUsers.setSelectedValue(user, true); }
From source file:ru.apertum.qsystem.client.forms.FAdmin.java
@Action public void addNewUserByCopy() { if (listUsers.getSelectedIndex() != -1) { final QUser user = (QUser) listUsers.getSelectedValue(); // ? ? , String userName = ""; boolean flag = true; while (flag) { userName = (String) JOptionPane.showInputDialog(this, getLocaleMessage("admin.add_user_dialog.title"), getLocaleMessage("admin.add_user_dialog.caption"), 3, null, null, userName); if (userName == null) { return; }//w w w .ja va 2 s . com if ("".equals(userName)) { JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_user_dialog.err1.title"), getLocaleMessage("admin.add_user_dialog.err1.caption"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); } else if (QUserList.getInstance().hasByName(userName)) { JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_user_dialog.err2.title"), getLocaleMessage("admin.add_user_dialog.err2.caption"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); } else if (userName.indexOf('\"') != -1) { JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_user_dialog.err3.title"), getLocaleMessage("admin.add_user_dialog.err3.caption"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); } else if (userName.length() > 150) { JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_user_dialog.err4.title"), getLocaleMessage("admin.add_user_dialog.err4.caption"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); } else { flag = false; } } QLog.l().logger().debug("? ? \"" + userName + "\""); final QUser newUser = new QUser(); LinkedList<QPlanService> plan = new LinkedList<>(); user.getPlanServices().stream().forEach((pl) -> { plan.add(new QPlanService(pl.getService(), pl.getUser(), pl.getCoefficient())); }); newUser.setPlanServices(plan); newUser.setName(userName); newUser.setPassword(""); newUser.setPoint(user.getPoint()); newUser.setAdressRS(user.getAdressRS()); newUser.setPointExt(user.getPointExt()); newUser.setReportAccess(user.getReportAccess()); newUser.setAdminAccess(user.getAdminAccess()); newUser.setAdminAccess(user.getAdminAccess()); QUserList.getInstance().addElement(newUser); listUsers.setSelectedValue(newUser, true); } }
From source file:ru.apertum.qsystem.client.forms.FAdmin.java
@Action public void renameUser() { if (listUsers.getSelectedIndex() != -1) { final QUser user = (QUser) listUsers.getSelectedValue(); String userName = user.getName(); boolean flag = true; while (flag) { userName = (String) JOptionPane.showInputDialog(this, getLocaleMessage("admin.rename_user_dialog.title"), getLocaleMessage("admin.rename_user_dialog.caption"), 3, null, null, userName); if (userName == null) { return; }/*w ww . j a v a2s .c o m*/ if ("".equals(userName)) { JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.rename_user_dialog.err1.title"), getLocaleMessage("admin.rename_user_dialog.err1.caption"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); } else if (QUserList.getInstance().hasByName(userName)) { JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.rename_user_dialog.err2.title"), getLocaleMessage("admin.rename_user_dialog.err2.caption"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); } else if (userName.indexOf('\"') != -1) { JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.rename_user_dialog.err3.title"), getLocaleMessage("admin.rename_user_dialog.err3.caption"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); } else if (userName.length() > 150) { JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.rename_user_dialog.err4.title"), getLocaleMessage("admin.rename_user_dialog.err4.caption"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); } else { flag = false; } } user.setName(userName); textFieldUserName.setText(userName); listUsers.setSelectedValue(user, true); } }
From source file:ru.apertum.qsystem.client.forms.FAdmin.java
@Action public void addService() throws DocumentException { // ? ? ? ?, String serviceName = ""; boolean flag = true; while (flag) { serviceName = (String) JOptionPane.showInputDialog(this, getLocaleMessage("admin.add_service_dialog.title"), getLocaleMessage("admin.add_service_dialog.caption"), 3, null, null, serviceName); if (serviceName == null) { return; }//from w w w .java2 s.com if ("".equals(serviceName)) { JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_service_dialog.err1.title"), getLocaleMessage("admin.add_service_dialog.err1.caption"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); } else if (QServiceTree.getInstance().hasByName(serviceName)) { JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_service_dialog.err2.title"), getLocaleMessage("admin.add_service_dialog.err2.caption"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); } else if (serviceName.indexOf('\"') != -1) { JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_service_dialog.err3.title"), getLocaleMessage("admin.add_service_dialog.err2.caption"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); } else if (serviceName.length() > 2001) { JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_service_dialog.err4.title"), getLocaleMessage("admin.add_service_dialog.err2.caption"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); } else { flag = false; } } // ? final QService newService = new QService(); newService.setName(serviceName); newService.setDescription(serviceName); newService.setStatus(1); newService.setSoundTemplate("021111"); newService.setAdvanceTimePeriod(60); newService.setCalendar(QCalendarList.getInstance().getById(1)); if (QScheduleList.getInstance().getSize() != 0) { newService.setSchedule(QScheduleList.getInstance().getElementAt(0)); } newService.setButtonText( "<html><b><p align=center><span style='font-size:20.0pt;color:red'>" + serviceName + "</span></b>"); //? newService.setPrefix("A"); QServiceTree.sailToStorm(QServiceTree.getInstance().getRoot(), (TreeNode service) -> { if (service.isLeaf()) { String pr = ((QService) service).getPrefix(); if (!pr.isEmpty()) { if (pr.substring(pr.length() - 1).compareToIgnoreCase( newService.getPrefix().substring(newService.getPrefix().length() - 1)) >= 0) { newService.setPrefix( String.valueOf((char) (pr.substring(pr.length() - 1).charAt(0) + 1)).toUpperCase()); } } } }); final QService parentService = (QService) treeServices.getLastSelectedPathComponent(); QServiceTree.getInstance().insertNodeInto(newService, parentService, parentService.getChildCount()); final TreeNode[] nodes = QServiceTree.getInstance().getPathToRoot(newService); final TreePath path = new TreePath(nodes); treeServices.scrollPathToVisible(path); treeServices.setSelectionPath(path); // ? ? ? ? ?? ? , .. ? deleteServiceFromUsers(parentService); QLog.l().logger().debug(" ? \"" + serviceName + "\" \"" + parentService.getName() + "\""); }
From source file:ru.apertum.qsystem.client.forms.FAdmin.java
@Action public void renameService() { final QService service = (QService) treeServices.getLastSelectedPathComponent(); if (service != null) { String serviceName = service.getName(); boolean flag = true; while (flag) { serviceName = (String) JOptionPane.showInputDialog(this, getLocaleMessage("admin.rename_service_dialog.title"), getLocaleMessage("admin.rename_service_dialog.caption"), 3, null, null, serviceName); if (serviceName == null) { return; }//from w w w. j a va2 s. com if ("".equals(serviceName)) { JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.rename_service_dialog.err1.title"), getLocaleMessage("admin.rename_service_dialog.err1.caption"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); } else if (QServiceTree.getInstance().hasByName(serviceName)) { JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.rename_service_dialog.err2.title"), getLocaleMessage("admin.rename_service_dialog.err2.caption"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); } else if (serviceName.indexOf('\"') != -1) { JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.rename_service_dialog.err3.title"), getLocaleMessage("admin.rename_service_dialog.err3.caption"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); } else if (serviceName.length() > 2001) { JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.rename_service_dialog.err4.title"), getLocaleMessage("admin.rename_service_dialog.err4.caption"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); } else { flag = false; } } service.setName(serviceName); } }
From source file:edu.harvard.i2b2.patientSet.ui.PatientSetJPanel.java
@SuppressWarnings("rawtypes") public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equalsIgnoreCase("Rename ...")) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getSelectionPath().getLastPathComponent(); if (node.getUserObject().getClass().getSimpleName().equalsIgnoreCase("QueryMasterData")) { QueryMasterData ndata = (QueryMasterData) node.getUserObject(); Object inputValue = JOptionPane.showInputDialog(this, "Rename this query to: ", "Rename Query Dialog", JOptionPane.PLAIN_MESSAGE, null, null, ndata.name().substring(0, ndata.name().indexOf("[") - 1)); if (inputValue != null) { String newQueryName = (String) inputValue; String requestXml = ndata.writeRenameQueryXML(newQueryName); setCursor(new Cursor(Cursor.WAIT_CURSOR)); String response = null; if (System.getProperty("webServiceMethod").equals("SOAP")) { // TO DO // response = // QueryListNamesClient.sendQueryRequestSOAP(requestXml); } else { response = QueryListNamesClient.sendQueryRequestREST(requestXml, true); }//from w w w. java 2s.c o m if (response.equalsIgnoreCase("CellDown")) { final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "Trouble with connection to the remote server, " + "this is often a network error, please try again", "Network Error", JOptionPane.INFORMATION_MESSAGE); } }); setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); return; } if (response != null) { JAXBUtil jaxbUtil = PatientSetJAXBUtil.getJAXBUtil(); try { JAXBElement jaxbElement = jaxbUtil.unMashallFromString(response); ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue(); StatusType statusType = messageType.getResponseHeader().getResultStatus().getStatus(); String status = statusType.getType(); if (status.equalsIgnoreCase("DONE")) { // XMLGregorianCalendar cldr = // //queryMasterType.getCreateDate(); Calendar cldr = Calendar.getInstance(Locale.getDefault()); ndata.name(newQueryName + " [" + addZero(cldr.get(Calendar.MONTH) + 1) + "-" + addZero(cldr.get(Calendar.DAY_OF_MONTH)) + "-" + addZero(cldr.get(Calendar.YEAR)) + " ]" + " [" + ndata.userId() + "]"); // ndata.name(newQueryName + " [" + // ndata.userId() // + "]"); node.setUserObject(ndata); // DefaultMutableTreeNode parent = // (DefaultMutableTreeNode) node.getParent(); jTree1.repaint(); } } catch (Exception ex) { ex.printStackTrace(); } } } } else if (node.getUserObject().getClass().getSimpleName().equalsIgnoreCase("QueryResultData")) { QueryResultData rdata = (QueryResultData) node.getUserObject(); // if(!rdata.type().equalsIgnoreCase("PatientSet")) { // return; // } Object inputValue1 = JOptionPane.showInputDialog(this, "Rename this to: ", "Renaming Dialog", JOptionPane.PLAIN_MESSAGE, null, null, rdata.name()); // .substring(0, rdata.name().lastIndexOf("[") - 1)); if (inputValue1 != null) { String newQueryName = (String) inputValue1; String requestXml = rdata.writeRenameQueryXML(newQueryName); setCursor(new Cursor(Cursor.WAIT_CURSOR)); String response = null; if (System.getProperty("webServiceMethod").equals("SOAP")) { // TO DO // response = // QueryListNamesClient.sendQueryRequestSOAP(requestXml); } else { response = QueryListNamesClient.sendQueryRequestREST(requestXml, true); } if (response.equalsIgnoreCase("CellDown")) { final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "Trouble with connection to the remote server, " + "this is often a network error, please try again", "Network Error", JOptionPane.INFORMATION_MESSAGE); } }); setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); return; } if (response != null) { JAXBUtil jaxbUtil = PatientSetJAXBUtil.getJAXBUtil(); try { JAXBElement jaxbElement = jaxbUtil.unMashallFromString(response); ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue(); StatusType statusType = messageType.getResponseHeader().getResultStatus().getStatus(); String status = statusType.getType(); if (status.equalsIgnoreCase("DONE")) { rdata.name(newQueryName);// + " [" + // rdata.userId() // + "]"); node.setUserObject(rdata); // DefaultMutableTreeNode parent = // (DefaultMutableTreeNode) node.getParent(); jTree1.repaint(); } else { final String tmp = response; final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "Error message delivered from the remote server, " + "you may wish to retry your last action", "Server Error", JOptionPane.INFORMATION_MESSAGE); log.error(tmp); setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); return; } } catch (Exception ex) { ex.printStackTrace(); } } } } setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } else if (e.getActionCommand().equalsIgnoreCase("Cancel")) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getSelectionPath().getLastPathComponent(); if (node.getUserObject().getClass().getSimpleName().equalsIgnoreCase("QueryMasterData")) { DefaultMutableTreeNode node1 = (DefaultMutableTreeNode) node.getFirstChild(); if (node1.getUserObject().getClass().getSimpleName().equalsIgnoreCase("QueryMasterData")) { final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "Please expand this node then try to cancel it.", "Message", JOptionPane.INFORMATION_MESSAGE); } }); return; } QueryInstanceData rdata = (QueryInstanceData) node1.getUserObject(); String requestXml = rdata.writeCancelQueryXML(); setCursor(new Cursor(Cursor.WAIT_CURSOR)); String response = null; if (System.getProperty("webServiceMethod").equals("SOAP")) { // TO DO // response = // QueryListNamesClient.sendQueryRequestSOAP(requestXml); } else { response = QueryListNamesClient.sendQueryRequestREST(requestXml, true); } if (response.equalsIgnoreCase("CellDown")) { final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "Trouble with connection to the remote server, " + "this is often a network error, please try again", "Network Error", JOptionPane.INFORMATION_MESSAGE); } }); setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); return; } if (response != null) { JAXBUtil jaxbUtil = PatientSetJAXBUtil.getJAXBUtil(); try { JAXBElement jaxbElement = jaxbUtil.unMashallFromString(response); ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue(); StatusType statusType = messageType.getResponseHeader().getResultStatus().getStatus(); String status = statusType.getType(); final JPanel parent = this; if (status.equalsIgnoreCase("DONE")) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "The query is finished.", "Message", JOptionPane.INFORMATION_MESSAGE); // log.error(tmp); setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); rdata.name(rdata.name().substring(0, rdata.name().indexOf("-")));// + " [" + // rdata // .userId() // + "]"); node.setUserObject(rdata); // DefaultMutableTreeNode parent = // (DefaultMutableTreeNode) node.getParent(); jTree1.repaint(); } else { final String tmp = response; // final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "Error message delivered from the remote server, " + "you may wish to retry your last action", "Server Error", JOptionPane.INFORMATION_MESSAGE); log.error(tmp); setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); return; } } catch (Exception ex) { ex.printStackTrace(); } // } } } else if (node.getUserObject().getClass().getSimpleName().equalsIgnoreCase("QueryInstanceData")) { QueryInstanceData rdata = (QueryInstanceData) node.getUserObject(); String requestXml = rdata.writeCancelQueryXML(); setCursor(new Cursor(Cursor.WAIT_CURSOR)); String response = null; if (System.getProperty("webServiceMethod").equals("SOAP")) { // TO DO // response = // QueryListNamesClient.sendQueryRequestSOAP(requestXml); } else { response = QueryListNamesClient.sendQueryRequestREST(requestXml, true); } if (response.equalsIgnoreCase("CellDown")) { final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "Trouble with connection to the remote server, " + "this is often a network error, please try again", "Network Error", JOptionPane.INFORMATION_MESSAGE); } }); setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); return; } if (response != null) { JAXBUtil jaxbUtil = PatientSetJAXBUtil.getJAXBUtil(); try { JAXBElement jaxbElement = jaxbUtil.unMashallFromString(response); ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue(); StatusType statusType = messageType.getResponseHeader().getResultStatus().getStatus(); String status = statusType.getType(); final JPanel parent = this; if (status.equalsIgnoreCase("DONE")) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "The query is finished.", "Message", JOptionPane.INFORMATION_MESSAGE); // log.error(tmp); setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); rdata.name(rdata.name().substring(0, rdata.name().indexOf("-")));// + " [" + // rdata // .userId() // + "]"); node.setUserObject(rdata); // DefaultMutableTreeNode parent = // (DefaultMutableTreeNode) node.getParent(); jTree1.repaint(); } else { final String tmp = response; // final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "Error message delivered from the remote server, " + "you may wish to retry your last action", "Server Error", JOptionPane.INFORMATION_MESSAGE); log.error(tmp); setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); return; } } catch (Exception ex) { ex.printStackTrace(); } // } } } else { final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "Cancel action is not supported on this level", "Message", JOptionPane.INFORMATION_MESSAGE); setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); } setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } else if (e.getActionCommand().equalsIgnoreCase("Delete")) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getSelectionPath().getLastPathComponent(); QueryMasterData ndata = (QueryMasterData) node.getUserObject(); Object selectedValue = JOptionPane.showConfirmDialog(this, "Delete Query \"" + ndata.name() + "\"?", "Delete Query Dialog", JOptionPane.YES_NO_OPTION); if (selectedValue.equals(JOptionPane.YES_OPTION)) { System.out.println("delete " + ndata.name()); String requestXml = ndata.writeDeleteQueryXML(); // System.out.println(requestXml); setCursor(new Cursor(Cursor.WAIT_CURSOR)); String response = null; if (System.getProperty("webServiceMethod").equals("SOAP")) { // TO DO // response = // QueryListNamesClient.sendQueryRequestSOAP(requestXml); } else { response = QueryListNamesClient.sendQueryRequestREST(requestXml, true); } if (response.equalsIgnoreCase("CellDown")) { final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "Trouble with connection to the remote server, " + "this is often a network error, please try again", "Network Error", JOptionPane.INFORMATION_MESSAGE); } }); setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); return; } if (response != null) { JAXBUtil jaxbUtil = PatientSetJAXBUtil.getJAXBUtil(); try { JAXBElement jaxbElement = jaxbUtil.unMashallFromString(response); ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue(); StatusType statusType = messageType.getResponseHeader().getResultStatus().getStatus(); String status = statusType.getType(); if (status.equalsIgnoreCase("DONE")) { treeModel.removeNodeFromParent(node); // jTree1.repaint(); } } catch (Exception ex) { ex.printStackTrace(); } } setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } } else if (e.getActionCommand().equalsIgnoreCase("Refresh All")) { String status = ""; if (isManager) { status = loadPreviousQueries(true); } else { status = loadPreviousQueries(false); } loadPatientSets(); if (status.equalsIgnoreCase("")) { reset(200, false, false); } else if (status.equalsIgnoreCase("CellDown")) { final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "Trouble with connection to the remote server, " + "this is often a network error, please try again", "Network Error", JOptionPane.INFORMATION_MESSAGE); } }); } } }
From source file:ru.apertum.qsystem.client.forms.FAdmin.java
@Action public void addInfoItem() { // ? ? ?, String infoName = getLocaleMessage("admin.add_info_dialog.info"); boolean flag = true; while (flag) { infoName = (String) JOptionPane.showInputDialog(this, getLocaleMessage("admin.add_info_dialog.title"), getLocaleMessage("admin.add_info_dialog.caption"), 3, null, null, infoName); if (infoName == null) { return; }/*from w w w . j av a 2 s . com*/ if ("".equals(infoName)) { JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_info_dialog.err1.title"), getLocaleMessage("admin.add_info_dialog.err1.caption"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); } else if (infoName.indexOf('\"') != -1) { JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_info_dialog.err2.title"), getLocaleMessage("admin.add_info_dialog.err2.caption"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); } else if (infoName.length() > 100) { JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_info_dialog.err3.title"), getLocaleMessage("admin.add_info_dialog.err3.caption"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); } else { flag = false; } } // ? final QInfoItem newItem = new QInfoItem(); newItem.setName(infoName); newItem.setHTMLText( "<html><b><p align=center><span style='font-size:20.0pt;color:green'>" + infoName + "</span></b>"); newItem.setTextPrint(""); final QInfoItem parentItem = (QInfoItem) treeInfo.getLastSelectedPathComponent(); ((QInfoTree) treeInfo.getModel()).insertNodeInto(newItem, parentItem, parentItem.getChildCount()); final TreeNode[] nodes = ((QInfoTree) treeInfo.getModel()).getPathToRoot(newItem); final TreePath path = new TreePath(nodes); treeInfo.scrollPathToVisible(path); treeInfo.setSelectionPath(path); textFieldInfoItemName.setEnabled(true); //textPaneInfoItem.setEnabled(true); //textPaneInfoPrint.setEnabled(true); QLog.l().logger().debug(" \"" + infoName + "\" \"" + parentItem.getName() + "\""); }