?? calleditpanel.java
字號(hào):
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); buttonPanel.setBackground(Color.WHITE); buttonPanel.add(buttonAdd); buttonPanel.add(buttonReset); buttonPanel.add(buttonDelete); buttonPanel.add(buttonCancel); //wrapper.add(bodyPanel, BorderLayout.CENTER); add(bodyPanel, BorderLayout.CENTER); add(buttonPanel, BorderLayout.SOUTH); init_done = true; // default to not being able to SMS checkSMS.setEnabled(false); } loadData(); //securePanel(); //setCurrentPanel(bodyPanel); //bodyPanel.revalidate(); } public void setDestination(CallbackDestination destination) { this.destination = destination; } // staff member searching facilities public void activateStaffSearch() { // TODO: do new stuff (create new StaffSearchWindow) StaffMemberSearchWindow window = new StaffMemberSearchWindow(textFor.getText()); window.setDestination(this); window.display(); /* setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); CallEditPanel returnPanel = new CallEditPanel(callID); returnPanel.textNote.setText(textNote.getText()); // returnPanel.textFrom.setText(textFrom.getText()); returnPanel.contact = contact; returnPanel.textPhone.setText(textPhone.getText()); returnPanel.textFirstName.setText(textFirstName.getText()); returnPanel.textLastName.setText(textLastName.getText()); try { returnPanel.dateField.setValue(dateField.getValue()); returnPanel.timeField.setValue(timeField.getValue()); } catch (java.text.ParseException ex) { // This shouldn't happen! } StaffMemberSearchPanel panel = new StaffMemberSearchPanel("Select Staff Member", returnPanel, returnPanel, textFor.getText() ); setCursor(Cursor.getDefaultCursor()); PanelManager.getInstance().activatePanel(panel);*/ } public void setStaffMemberFound(StaffMember staffMember) { this.staffMember = staffMember; textFor.setText(staffMember.getFirstName() + " " + staffMember.getLastName()); System.out.println("Can SMS: " +staffMember.getCanSMS()); checkSMS.setEnabled(staffMember.getCanSMS()); if (staffMember.getCanSMS() == false) checkSMS.setSelected(false); } // company searching facilities public void activateCompanySearch() { CompanySearchWindow search = new CompanySearchWindow(this, "Search for Call"); search.setSearchCompany(textCompany.getText()); search.display(); } public void callback(Object source, int mode, Object data) { System.out.println("CallWindow -- callback received"); if (source instanceof CompanySearchWindow) { if (!(data instanceof Company)) { JOptionPane.showMessageDialog(this, "Company search did not return a company."); } setCompanyFound((Company)data); } else if (source instanceof StaffMemberSearchWindow) { setStaffMemberFound((StaffMember) data); } } public void setCompanyFound(Company company) { this.company = company; if (this.company != null) { textCompany.setText(company.getCompanyName()); } } public void setEditable(boolean editable) { textFor.setEditable(editable); buttonStaffSearch.setVisible(editable); textFirstName.setEditable(editable); textLastName.setEditable(editable); textCompany.setEditable(editable); textPhone.setEditable(editable); textNote.setEditable(editable); buttonAdd.setVisible(editable); buttonReset.setVisible(editable); companySearchButton.setVisible(editable); dateField.setEnabled(editable); timeField.setEnabled(editable); checkSMS.setEnabled(editable); checkEmail.setEnabled(editable); checkWillCallBack.setEnabled(editable); checkPleaseCall.setEnabled(editable); checkUrgent.setEnabled(editable); } /*public void securePanel() { if (entityPermission != null && !entityPermission.canWrite()) { setEditable(false); } System.out.println(entityPermission); System.out.println(callID); if (entityPermission != null && entityPermission.canDelete() && callID > -1) { buttonDelete.setVisible(true); } else { buttonDelete.setVisible(false); } //utilityToolbar.setEntityPermission(entityPermission); }*/ public void setCallID(int new_callID) { callID = new_callID; loadData(); //securePanel(); } /** * Load the form data from the server. When editing it will query the server based * on the given callID. */ public void loadData() { // load using the locally sourced information before trying to download if (call_data != null) { loadData(call_data); return; } Server server = ServerFactory.getInstance().getServer(); ServerCommand command = null; ServerResponse response = null; if (callID == -1) { command = new ServerCommand(CallModule.CALLS_ADD_FORM); response = server.sendCommand(command); Date date = (Date) response.getPart("date"); dateField.setValue(date); timeField.setValue(date); } else { buttonAdd.setText("Save"); command = new ServerCommand(CallModule.CALL_EDIT_FORM); command.setParameter(CallModule.PARAM_CALL_ID, String.valueOf(callID)); response = server.sendCommand(command); /*Permission permission = (Permission) response.getPart("permission"); entityPermission = permission;*/ call_data = (Call) response.getPart("call"); /*call_data.setPermission(entityPermission);*/ loadData(call_data); } } /** * Load the fields within the form based on the given call and company * * @param call The call details to load */ protected void loadData(Call call) { if (call == null) { return; } dateField.setValue(call.getDate()); timeField.setValue(call.getDate()); textPhone.setText(call.getNumber()); textNote.setText(call.getNote()); textFirstName.setText(call.getFromFirstName()); textLastName.setText(call.getFromLastName()); this.staffMember = call.getOwnerObj(); this.company = call.getCompany(); if (this.company != null) { textCompany.setText(company.getCompanyName()); } System.out.println("StaffMemb er is " + staffMember); if (this.staffMember != null) { setStaffMemberFound(staffMember); } //this.entityPermission = call.getPermission(); checkSMS.setSelected( call.checkFlag(Call.CALL_FLAG_SMS)); checkEmail.setSelected( call.checkFlag(Call.CALL_FLAG_EMAIL)); checkWillCallBack.setSelected(call.checkFlag(Call.CALL_FLAG_CALLBACK)); checkPleaseCall.setSelected(call.checkFlag(Call.CALL_FLAG_PLEASECALL)); checkUrgent.setSelected( call.checkFlag(Call.CALL_FLAG_URGENT)); } public void deleteCall() { Server server = ServerFactory.getInstance().getServer(); ServerCommand command = null; command = new ServerCommand(CallModule.CALL_DELETE); command.setParameter(CallModule.PARAM_CALL_ID, String.valueOf(callID)); server.sendCommand(command); if (destination == null) { PanelManager.getInstance().activatePanel(new CallViewPanel()); } else { destination.callback(this, CLOSE_WINDOW_DELETE, new Integer(callID)); } } public boolean validateForm() { StringBuffer buf = new StringBuffer(); boolean valid = true; Server server = ServerFactory.getInstance().getServer(); ServerResponse sr = null; ServerCommand command = null; if (staffMember == null) { valid = false; buf.append( "- You must select the staff member to direct this message.\n"); } if (dateField.getText().trim().equals("")) { valid = false; buf.append( "- You must enter a Date.\n"); } if (textFirstName.getText().trim().equals("") && textLastName.getText().trim().equals("") && textPhone.getText().trim().equals("") && textNote.getText().trim().equals("") && company == null) { valid = false; buf.append( "- Please enter some details about the message.\n"); } // CRMS Logic: // - If a company has been entered, and company==null do a quick search for the company // - if not found, create an incomplete company if (company == null && textCompany.getText().trim().length() > 0) { command = new ServerCommand(CompanyModule.COMPANY_ADD_AUTO); command.setParameter(CompanyModule.PARAM_COMPANY_NAME, textCompany.getText()); if (staffMember != null) { command.setParameter(CompanyModule.PARAM_COMPANY_AUTO_OWNER, staffMember.getUID()); } if (textPhone.getText().trim().length() > 0) { ArrayList phones = new ArrayList(); phones.add(textPhone.getText()); Location loc = new Location(); loc.setPhone(phones); loc.setTitle("Message Location"); ArrayList locations = new ArrayList(); locations.add(loc); command.setParameter(CompanyModule.PARAM_COMPANY_LOCATIONS, locations); } String notes = "Message received " + dateField.getText() + " from " + textFirstName.getText() +" " + textLastName.getText(); command.setParameter(CompanyModule.PARAM_COMPANY_NOTES, notes); sr = server.sendCommand(command); if (sr != null) { company = (Company)sr.getPart("company"); textCompany.setText(company.getCompanyName()); } } if (!valid) { buf.insert(0, "There were errors on the form you have submitted:\n\n"); buf.append("\n"); JOptionPane.showMessageDialog(this, buf.toString(),"Invalid Form Data", JOptionPane.ERROR_MESSAGE); } return valid; } public void updateCallData() { final SimpleDateFormat df = new SimpleDateFormat("d MMMM, yyyy h:mm a"); if (call_data == null) call_data = new Call(); call_data.setNumber(textPhone.getText()); call_data.setNote(textNote.getText()); call_data.setFromFirstName(textFirstName.getText()); call_data.setFromLastName(textLastName.getText()); call_data.setCompany(company); call_data.setOwnerObj(staffMember); call_data.setOwner(staffMember.getUID()); //call_data.setPermission(entityPermission); //System.out.println("Flags before: " + call_data.getFlags()); call_data.changeFlag(Call.CALL_FLAG_SMS, checkSMS.isSelected()); call_data.changeFlag(Call.CALL_FLAG_EMAIL, checkEmail.isSelected()); call_data.changeFlag(Call.CALL_FLAG_CALLBACK, checkWillCallBack.isSelected()); call_data.changeFlag(Call.CALL_FLAG_PLEASECALL, checkPleaseCall.isSelected()); call_data.changeFlag(Call.CALL_FLAG_URGENT, checkUrgent.isSelected()); //System.out.println("Flags after: " + call_data.getFlags()); try { call_data.setDate(df.parse(dateField.getText() + " " + timeField.getFormatter().format(timeField.getValue()))); } catch (ParseException e) {} } public void updateCall() { updateCallData(); Server server = ServerFactory.getInstance().getServer(); ServerCommand command = null; if (callID == -1) { command = new ServerCommand(CallModule.CALLS_ADD_SUBMIT); } else { command = new ServerCommand(CallModule.CALL_EDIT_SUBMIT); // preserve the call ID for those that exist already command.setParameter(CallModule.PARAM_CALL_ID, String.valueOf(callID)); } command.setParameter(CallModule.PARAM_CALL_DATE, dateField.getText()); command.setParameter(CallModule.PARAM_CALL_FOR, String.valueOf(staffMember.getUID())); command.setParameter(CallModule.PARAM_CALL_NUMBER, textPhone.getText()); command.setParameter(CallModule.PARAM_CALL_NOTE, textNote.getText()); command.setParameter(CallModule.PARAM_CALL_FIRST_NAME, textFirstName.getText()); command.setParameter(CallModule.PARAM_CALL_LAST_NAME, textLastName.getText()); command.setParameter(CallModule.PARAM_CALL_FLAGS, new Integer(call_data.getFlags())); try { Date time = timeField.getValue(); command.setParameter(CallModule.PARAM_CALL_TIME, timeField.getFormatter().format(time)); } catch (java.text.ParseException ex) { throw new RuntimeException(ex); } if (company != null) { command.setParameter(CallModule.PARAM_COMPANY_ID, new Integer(company.getCompanyID())); } ServerResponse result = server.sendCommand(command); System.out.println(result); if (result != null && callID < 0) { Call retCall = (Call)result.getPart("call"); callID = retCall.getCallID(); call_data = retCall; call_data.setCompany(company); } } public void setPanelType(int panelType, int callID) { this.panelType = panelType; // for a new panel, it is invalid to set this if (panelType == PANEL_TYPE_EDIT) { this.callID = callID; } } public Class getPanel(int i) { return null; } // public void setContactFound(Contact contact) { // this.contact = contact; // textFrom.setText(contact.getFirstName() + " " + contact.getLastName()); // } }
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -