Changeset 29571 in osm for applications/editors/josm/plugins/geochat/src/geochat/ChatPaneManager.java
- Timestamp:
- 2013-05-09T21:00:19+02:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/geochat/src/geochat/ChatPaneManager.java
r29568 r29571 7 7 import javax.swing.event.ChangeEvent; 8 8 import javax.swing.event.ChangeListener; 9 import javax.swing.text.BadLocationException; 10 import javax.swing.text.DefaultCaret; 11 import javax.swing.text.Document; 9 import javax.swing.text.*; 12 10 import static org.openstreetmap.josm.tools.I18n.tr; 13 11 … … 53 51 int alarm = 0; 54 52 for( ChatPane entry : chatPanes.values() ) { 55 if( entry.notify ) { 56 if( entry.isPublic && alarm < 1 ) 57 alarm = 1; 58 else if( !entry.isPublic ) 59 alarm = 2; 60 } 53 if( entry.notify > alarm ) 54 alarm = entry.notify; 61 55 } 62 56 return alarm; … … 68 62 } 69 63 70 public void notify( String user, boolean really ) { 71 // if( user == null && !really && !collapsed ) 72 // return; 73 if( !hasUser(user) ) 64 public void notify( String user, int alarmLevel ) { 65 if( alarmLevel <= 0 || !hasUser(user) ) 74 66 return; 75 67 ChatPane entry = chatPanes.get(user == null ? PUBLIC_PANE : user); 76 System.out.println("Notifying " + user); 77 entry.notify = true; 68 entry.notify = alarmLevel; 78 69 int idx = tabs.indexOfComponent(entry.component); 79 70 if( idx >= 0 ) … … 82 73 83 74 public void addLineToChatPane( String userName, String line ) { 75 if( line.length() == 0 ) 76 return; 84 77 if( !chatPanes.containsKey(userName) ) 85 78 createChatPane(userName); … … 98 91 } 99 92 93 /** 94 * Special case: the line contains username, so it must be highlighted. 95 */ 96 public void addLineToPublicEm( String line ) { 97 if( !line.startsWith("\n") ) 98 line = "\n" + line; 99 Document doc = chatPanes.get(PUBLIC_PANE).pane.getDocument(); 100 try { 101 SimpleAttributeSet attrs = new SimpleAttributeSet(); 102 StyleConstants.setItalic(attrs, true); 103 doc.insertString(doc.getLength(), line, attrs); 104 } catch( BadLocationException ex ) { 105 // whatever 106 } 107 } 108 100 109 public void clearPublicChatPane() { 101 110 chatPanes.get(PUBLIC_PANE).pane.setText(""); … … 139 148 entry.pane = chatPane; 140 149 entry.component = scrollPane; 141 entry.notify = false;150 entry.notify = 0; 142 151 entry.userName = userName; 143 152 entry.isPublic = userName == null; … … 207 216 boldFont = getFont().deriveFont(Font.BOLD); 208 217 } 209 System.out.println("clauses: collapsed=" + collapsed + ", tabs:" + tabs.getSelectedIndex() + "=" + tabs.indexOfComponent(entry.component)); 210 if( entry.notify && !collapsed && tabs.getSelectedIndex() == tabs.indexOfComponent(entry.component) ) 211 entry.notify = false; 212 setFont(entry.notify ? boldFont : normalFont); 218 if( entry.notify > 0 && !collapsed && tabs.getSelectedIndex() == tabs.indexOfComponent(entry.component) ) 219 entry.notify = 0; 220 setFont(entry.notify > 0 ? boldFont : normalFont); 213 221 panel.updateTitleAlarm(); 214 222 } … … 220 228 public JTextPane pane; 221 229 public JScrollPane component; 222 public booleannotify;230 public int notify; 223 231 224 232 }
Note:
See TracChangeset
for help on using the changeset viewer.