📄 notesviewpanel.java
字号:
/* CRMS, customer relationship management system Copyright (C) 2003 Service To Youth Council This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA For further information contact the SYC ICT department on GPL@syc.net.au 98 Kermode Street North Adelaide South Australia SA 5006 +61 (0)8 8367 0755 *//* * CallViewPanel.java * * Created on 27 March 2003, 00:11 */package crms.applet;import javax.swing.*;import java.awt.*;import java.awt.event.*;import javax.swing.border.*;import javax.swing.event.*;import java.util.*;import crms.vo.*;import crms.ui.*;import crms.module.*;import crms.util.*;import java.text.*;import java.beans.*;import java.io.*;import java.text.*;/** * * @author dmurphy */public class NotesViewPanel extends CRMSPanel { public static final int CLOSE_WINDOW = 0; JPanel titlePanel = new JPanel(); CRMSPanel bodyPanel = CRMSPanel.getEmptyPanel();// NotesTableModel tableModel = new NotesTableModel();// JTable viewNotesTable = new JTable(tableModel); JEditorPane notesPane = new JEditorPane(); JScrollPane scrollPane = new JScrollPane(notesPane); JLabel headingLabel = new JLabel(); public static SimpleDateFormat df = new SimpleDateFormat("EEEE, d MMMM, yyyy"); public static SimpleDateFormat tf = new SimpleDateFormat("h:mm a"); JButton buttonAdd = new JButton("Add Notes"); JButton buttonClose = new JButton("Close"); JPanel buttonPanel = new JPanel(); EntityType noteType = null; int noteReference = -1; CallbackDestination destination = null; //Permission entityPermission = null; boolean readonly = false; /** Creates a new instance of CallViewPanel */ public NotesViewPanel() { } public NotesViewPanel(EntityType noteType, int noteReference, Permission entityPermission) { this.noteType = noteType; this.noteReference = noteReference; // in absence of permissions or if they can't write, make it readonly setReadonly(entityPermission == null || !entityPermission.canWrite()); } public void setNotes(EntityType noteType, int noteReference) { this.noteType = noteType; this.noteReference = noteReference; } public void setReadonly(boolean readonly) { this.readonly = readonly; buttonAdd.setVisible(!readonly); } /** Set the destination for callbacks sent from any related classes */ public void setDestination(CallbackDestination destination) { this.destination = destination; } public void init() { final Object thisobj = this; setLayout(new BorderLayout()); setBackground(Color.WHITE);/* headingLabel.setFont(new java.awt.Font("Serif", 1, 14)); headingLabel.setBackground(Color.WHITE); headingLabel.setText(noteType.getName() + " Notes"); titlePanel.add(headingLabel); titlePanel.setBackground(Color.WHITE); add(titlePanel, BorderLayout.NORTH);*/ buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT)); buttonPanel.setBackground(Color.WHITE); buttonPanel.add(buttonAdd); buttonPanel.add(buttonClose); buttonAdd.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ev) { // TODO: UPDATE PanelManager.getInstance().activatePanel(new NoteAddPanel(noteType, noteReference, "Add Note", entityPermission)); NotesAddWindow window = new NotesAddWindow(); window.setDestination(destination); window.setNotes(noteType, noteReference); window.display(); } }); buttonClose.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ev) { if (destination != null) destination.callback(thisobj, CLOSE_WINDOW, null);/* CRMSPanel panel = null; if (noteType == EntityType.CALL) { panel = new CallEditPanel(noteReference); } else if (noteType == EntityType.CONTACT) { panel = new ContactEditPanel(noteReference, null); } else if (noteType == EntityType.COMPANY) { JOptionPane.showMessageDialog(bodyPanel, "BROKEN, please fix"); //panel = new CompanyEditPanel(CompanyEditPanel.PANEL_TYPE_EDIT, noteReference); } else if (noteType == EntityType.REMINDER) { panel = new ReminderEditPanel(noteReference); } PanelManager.getInstance().activatePanel(panel);*/ } }); scrollPane.getViewport().setBackground(Color.WHITE); bodyPanel.setLayout(new BorderLayout()); bodyPanel.setBackground(Color.WHITE); bodyPanel.setBorder(new EmptyBorder(0,20,0,20)); bodyPanel.add(scrollPane, BorderLayout.CENTER); add(bodyPanel, BorderLayout.CENTER); add(buttonPanel, BorderLayout.SOUTH); //setCurrentPanel(bodyPanel); refreshData(); } public void refreshData() { notesPane.setText(""); notesPane.setContentType("text/html"); notesPane.setEditable(false); Server server = ServerFactory.getInstance().getServer(); ServerCommand command = new ServerCommand(); command.setKey(NoteModule.NOTES_VIEW); command.setParameter(NoteModule.PARAM_NOTE_TYPE, noteType); command.setParameter(NoteModule.PARAM_NOTE_REFERENCE, String.valueOf(noteReference)); ServerResponse sr = server.sendCommand(command); ArrayList notes = (ArrayList) sr.getPart("notes"); if ( notes == null || notes.size() == 0) { notesPane.setText("<i>No notes have been entered.</i>"); return; } StringBuffer buf = new StringBuffer(); for (int i=0; i < notes.size(); i++) { Note note = (Note) notes.get(i); buf.append( "<p><b>Note from <i>"); // query the server for the proper name // TODO: cache the results! (otherwise this will be slow) command = new ServerCommand(StaffModule.STAFF_SEARCH_SUBMIT); command.setParameter(StaffModule.PARAM_STAFF_UID, note.getUser()); sr = server.sendCommand(command); ArrayList staff = (ArrayList) sr.getPart("staff"); StaffMember user = null, found = null; // Multiple results may be returned as currently the particular query performed // also includes the All Staff default. This may change at a later date and so // this code will handle it. if (staff.size() >= 1) { for (int j = 0; j < staff.size(); j++) { user = (StaffMember)staff.get(j); if (user.getUID().compareTo(note.getUser()) == 0) found = user; } } if (found != null) { buf.append( found.getFirstName()); buf.append( " " ); buf.append( found.getLastName()); } else { buf.append( note.getUser() ); } buf.append(" at "); buf.append(tf.format(note.getNoteDate()) ); buf.append(", "); buf.append(df.format(note.getNoteDate()) ); buf.append(" "); buf.append("</i></b>"); if (note.getAccessLevel() >= 1) { buf.append(" (private)"); } buf.append("<br>"); buf.append( note.getNoteText()); buf.append("</p>"); } notesPane.setText(buf.toString()); } public Class getPanel(int i) { return null; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -