Source Code Cross Referenced for SentencesTableModel.java in  » IDE » Schmortopf » Language » Editor » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE » Schmortopf » Language.Editor 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package Language.Editor;
002:
003:        import Schmortopf.Utility.SortableTable.*;
004:        import Language.*;
005:
006:        import java.util.*;
007:        import java.awt.event.*;
008:        import javax.swing.event.*;
009:
010:        /** used to display sentences for editing
011:         */
012:        public class SentencesTableModel extends FineGrainTableModel implements 
013:                ChangeListener {
014:            final static int COLUMN_SENTENCE = 0;
015:            final static int COLUMN_TRANSLATION = 1;
016:            final static int COLUMN_SOURCEFILE = 2;
017:            final static int COLUMN_SOURCELINE = 3;
018:
019:            final Vector sentences = new Vector();
020:            SentenceDictionary actualDic;
021:
022:            boolean editable = true;
023:
024:            public SentencesTableModel() {
025:
026:            } // Constructor
027:
028:            public void setDictionary(SentenceDictionary dic, boolean editable) {
029:                this .editable = editable;
030:                if (actualDic != null)
031:                    actualDic.removeChangeListener(this );
032:
033:                actualDic = dic;
034:                sentences.removeAllElements();
035:                //
036:                Vector v = dic.getAllSentences();
037:                for (int i = 0; i < v.size(); i++) {
038:                    sentences.addElement(v.elementAt(i));
039:                }
040:
041:                this .fireTableDataChanged();
042:
043:                dic.addChangeListener(this );
044:
045:            }
046:
047:            // called when actualDic changed
048:            public void stateChanged(ChangeEvent e) {
049:                fireTableDataChanged();
050:            }
051:
052:            public String getColumnName(int col) {
053:                if (col == COLUMN_SENTENCE)
054:                    return "English";
055:                if (col == COLUMN_TRANSLATION)
056:                    return "Translation";
057:                if (col == COLUMN_SOURCEFILE)
058:                    return "Found in source";
059:                return "?";
060:            }
061:
062:            public Sentence getSentenceAt(int pos) {
063:                return (Sentence) sentences.elementAt(pos);
064:            }
065:
066:            public int getColumnCount() {
067:                return 3;
068:            }
069:
070:            public int getRowCount() {
071:                return sentences.size();
072:            }
073:
074:            public boolean isCellEditable(int rowIndex, int columnIndex) {
075:                return false;
076:            }
077:
078:            public Object getValueAt(int row, int col) {
079:                Sentence s = (Sentence) sentences.elementAt(row);
080:
081:                if (col == COLUMN_SENTENCE) {
082:                    return s.getSentence();
083:                } else if (col == COLUMN_TRANSLATION) {
084:                    return s.getTranslation();
085:                } else if (col == COLUMN_SOURCEFILE) {
086:                    int line = s.getLinePosition();
087:                    String loc = s.getLocationClass();
088:                    if (loc.equals(""))
089:                        return "";
090:                    return loc + " : " + (line == -1 ? "?" : "" + line);
091:                } else if (col == COLUMN_SOURCELINE) {
092:                    return "" + s.getLinePosition();
093:                }
094:                return "?";
095:            }
096:
097:            public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
098:                // not editable                           
099:            }
100:
101:            public Class getColumnClass(int column) {
102:                Object obj = getValueAt(0, column);
103:                return obj.getClass();
104:            }
105:
106:            public int compareForColumnSort(int pos1, int pos2, int col) {
107:                Sentence s1 = (Sentence) sentences.elementAt(pos1);
108:                Sentence s2 = (Sentence) sentences.elementAt(pos2);
109:
110:                if (col == COLUMN_SENTENCE) {
111:                    return s1.getSentence().compareToIgnoreCase(
112:                            s2.getSentence());
113:                } else if (col == COLUMN_TRANSLATION) {
114:                    return s1.getTranslation().compareToIgnoreCase(
115:                            s2.getTranslation());
116:                } else if (col == COLUMN_SOURCEFILE) {
117:                    return s1.getLocationClass().compareToIgnoreCase(
118:                            s2.getLocationClass());
119:                } else if (col == COLUMN_SOURCELINE) {
120:                    int l1 = s1.getLinePosition();
121:                    int l2 = s2.getLinePosition();
122:                    if (l1 == l2)
123:                        return 0;
124:                    if (l1 < l2)
125:                        return -1;
126:                    return 1;
127:                }
128:                return 0;
129:            }
130:
131:            public boolean hitForTextSearch(int row, String txt) {
132:                String upt = txt.toUpperCase();
133:                Sentence s = (Sentence) sentences.elementAt(row);
134:
135:                if (s.getSentence().toUpperCase().indexOf(upt) != -1)
136:                    return true;
137:                if (s.getTranslation().toUpperCase().indexOf(upt) != -1)
138:                    return true;
139:
140:                return false;
141:            }
142:
143:        } // SentencesTableModel
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.