001: package org.airtodo.headers;
002:
003: import java.awt.Component;
004:
005: import javax.swing.Icon;
006: import javax.swing.JLabel;
007: import javax.swing.JProgressBar;
008: import javax.swing.table.DefaultTableCellRenderer;
009:
010: import org.air.framework.core.ColumnDecorations;
011: import org.air.framework.core.Header;
012: import org.air.framework.core.Utils;
013: import org.air.framework.gui.lookup.LookupObject;
014: import org.air.framework.gui.table_view.table.Table;
015: import org.air.framework.properties.Icons;
016: import org.airtodo.db.types.Freezed;
017: import org.airtodo.db.types.Period;
018: import org.airtodo.db.types.PeriodUtils;
019: import org.airtodo.db.types.Progress;
020: import org.airtodo.gui_common.components.lookup_data.LookupDataPriority;
021: import org.airtodo.gui_common.components.lookup_data.LookupDataPriorityCustomer;
022: import org.airtodo.gui_common.components.lookup_data.LookupDataPriorityProject;
023: import org.airtodo.gui_common.components.lookup_data.LookupDataStage;
024: import org.airtodo.records.Customers;
025: import org.airtodo.records.Employees;
026: import org.airtodo.records.Initiators;
027: import org.airtodo.records.Modules;
028: import org.airtodo.records.Projects;
029: import org.airtodo.records.TaskTypes;
030: import org.airtodo.records.Tasks;
031:
032: public class Task extends Header {
033: public Task() {
034: put(Tasks.NAME, new ColumnDecorations(true, 150));
035: put(Tasks.PRIORITY, new ColumnDecorations(true, 60));
036: put(Tasks.TIME, new ColumnDecorations(true, 100));
037: put(Tasks.TIME_END, new ColumnDecorations(false, 100));
038: put(Tasks.PERIOD, new ColumnDecorations(true, 100));
039: put(Tasks.FREEZED, new ColumnDecorations(true, 100));
040: put(Tasks.PROGRESS, new ColumnDecorations(true, 100));
041: put(Tasks.COMMENT, new ColumnDecorations(false, 300));
042: put(TaskTypes.NAME, new ColumnDecorations(false, 200));
043: put(TaskTypes.COMMENT, new ColumnDecorations(false, 200));
044: put(Projects.NAME, new ColumnDecorations(false, 200));
045: put(Projects.PRIORITY, new ColumnDecorations(false, 200));
046: put(Projects.DATE_START, new ColumnDecorations(false, 200));
047: put(Projects.DATE_END, new ColumnDecorations(false, 200));
048: put(Projects.PERIOD, new ColumnDecorations(false, 200));
049: put(Projects.FREEZED, new ColumnDecorations(false, 200));
050: put(Projects.PROGRESS, new ColumnDecorations(false, 200));
051: put(Projects.REMAIN, new ColumnDecorations(false, 200));
052: put(Projects.STAGE, new ColumnDecorations(false, 200));
053: put(Projects.COMMENT, new ColumnDecorations(false, 200));
054: put(Customers.NAME, new ColumnDecorations(false, 200));
055: put(Customers.PRIORITY, new ColumnDecorations(false, 200));
056: put(Customers.ADDRESS, new ColumnDecorations(false, 200));
057: put(Customers.EMAIL, new ColumnDecorations(false, 200));
058: put(Customers.PHONE, new ColumnDecorations(false, 200));
059: put(Customers.COMMENT, new ColumnDecorations(false, 200));
060: put(Modules.NAME, new ColumnDecorations(false, 200));
061: put(Modules.COMMENT, new ColumnDecorations(false, 200));
062: put(Initiators.NAME, new ColumnDecorations(false, 200));
063: put(Initiators.ADDRESS, new ColumnDecorations(false, 200));
064: put(Initiators.EMAIL, new ColumnDecorations(false, 200));
065: put(Initiators.PHONE, new ColumnDecorations(false, 200));
066: put(Initiators.COMMENT, new ColumnDecorations(false, 200));
067: put(Employees.NAME, new ColumnDecorations(false, 200));
068: put(Employees.ADDRESS, new ColumnDecorations(false, 200));
069: put(Employees.EMAIL, new ColumnDecorations(false, 200));
070: put(Employees.PHONE, new ColumnDecorations(false, 200));
071: put(Employees.COMMENT, new ColumnDecorations(false, 200));
072: }
073:
074: @Override
075: public Class getRecordClass() {
076: return Tasks.class;
077: }
078:
079: public Component getCellRendererComponent(
080: DefaultTableCellRenderer defaultTableCellRenderer,
081: Object columnIdentifier, Object recordId, Table table,
082: Object value, boolean isSelected, int row, int column) {
083: if (value == null)
084: return null;
085: if (columnIdentifier.equals(Utils
086: .getColumnIdentifier(Tasks.PROGRESS))) {
087: JProgressBar bar = new JProgressBar();
088: bar.setValue(((Progress) value).getValue());
089: bar.setOpaque(false);
090: bar.setStringPainted(true);
091: bar.setBorderPainted(false);
092: return bar;
093: } else if (columnIdentifier.equals(Utils
094: .getColumnIdentifier(Tasks.PRIORITY))) {
095: int intValue = ((LookupObject) value).getValue();
096: LookupDataPriority lookupData = new LookupDataPriorityProject();
097: Icon icon = (Icon) lookupData.getTextsAndIcons()[intValue][1];
098: defaultTableCellRenderer.setIcon(icon);
099: defaultTableCellRenderer
100: .setHorizontalAlignment(JLabel.CENTER);
101: return defaultTableCellRenderer;
102: } else if (columnIdentifier.equals(Utils
103: .getColumnIdentifier(Tasks.PERIOD))) {
104: defaultTableCellRenderer.setText(((Period) value)
105: .toString());
106: defaultTableCellRenderer
107: .setHorizontalAlignment(JLabel.RIGHT);
108: return defaultTableCellRenderer;
109: } else if (columnIdentifier.equals(Utils
110: .getColumnIdentifier(Tasks.FREEZED))) {
111: boolean freezed = ((Freezed) value).getValue();
112: if (freezed) {
113: defaultTableCellRenderer
114: .setHorizontalAlignment(JLabel.CENTER);
115: defaultTableCellRenderer.setIcon(Icons.STOP);
116: }
117: return defaultTableCellRenderer;
118: } else if (columnIdentifier.equals(Utils
119: .getColumnIdentifier(Projects.REMAIN))) {
120: Period period = (Period) value;
121: PeriodUtils.remainPeriodDecorator(defaultTableCellRenderer,
122: period);
123: defaultTableCellRenderer
124: .setHorizontalAlignment(JLabel.LEFT);
125: return defaultTableCellRenderer;
126: } else if (columnIdentifier.equals(Utils
127: .getColumnIdentifier(Projects.PROGRESS))) {
128: JProgressBar bar = new JProgressBar();
129: bar.setValue(((Progress) value).getValue());
130: bar.setOpaque(false);
131: bar.setStringPainted(true);
132: bar.setBorderPainted(false);
133: return bar;
134: } else if (columnIdentifier.equals(Utils
135: .getColumnIdentifier(Projects.PRIORITY))) {
136: int intValue = ((LookupObject) value).getValue();
137: LookupDataPriority lookupData = new LookupDataPriorityProject();
138: Icon icon = (Icon) lookupData.getTextsAndIcons()[intValue][1];
139: defaultTableCellRenderer.setIcon(icon);
140: defaultTableCellRenderer
141: .setHorizontalAlignment(JLabel.CENTER);
142: return defaultTableCellRenderer;
143: } else if (columnIdentifier.equals(Utils
144: .getColumnIdentifier(Projects.STAGE))) {
145: int intValue = ((LookupObject) value).getValue();
146: LookupDataStage lookupData = new LookupDataStage();
147: String text = (String) lookupData.getTextsAndIcons()[intValue][0];
148: Icon icon = (Icon) lookupData.getTextsAndIcons()[intValue][1];
149: defaultTableCellRenderer.setIcon(icon);
150: defaultTableCellRenderer.setText(text);
151: defaultTableCellRenderer
152: .setHorizontalAlignment(JLabel.LEFT);
153: return defaultTableCellRenderer;
154: } else if (columnIdentifier.equals(Utils
155: .getColumnIdentifier(Projects.PERIOD))) {
156: defaultTableCellRenderer.setText(((Period) value)
157: .toString());
158: defaultTableCellRenderer
159: .setHorizontalAlignment(JLabel.RIGHT);
160: return defaultTableCellRenderer;
161: } else if (columnIdentifier.equals(Utils
162: .getColumnIdentifier(Projects.FREEZED))) {
163: boolean freezed = ((Freezed) value).getValue();
164: if (freezed) {
165: defaultTableCellRenderer
166: .setHorizontalAlignment(JLabel.CENTER);
167: defaultTableCellRenderer.setIcon(Icons.STOP);
168: }
169: return defaultTableCellRenderer;
170: } else if (columnIdentifier.equals(Utils
171: .getColumnIdentifier(Customers.PRIORITY))) {
172: int intValue = ((LookupObject) value).getValue();
173: LookupDataPriority lookupData = new LookupDataPriorityCustomer();
174: Icon icon = (Icon) lookupData.getTextsAndIcons()[intValue][1];
175: defaultTableCellRenderer.setIcon(icon);
176: defaultTableCellRenderer
177: .setHorizontalAlignment(JLabel.CENTER);
178: return defaultTableCellRenderer;
179: }
180: return null;
181: }
182: }
|