| 1 7 package org.openharmonise.him.editors.report; 8 9 import java.awt.Color ; 10 import java.awt.Component ; 11 import java.awt.Container ; 12 import java.awt.Dimension ; 13 import java.awt.Font ; 14 import java.awt.LayoutManager ; 15 import java.awt.event.ActionEvent ; 16 import java.awt.event.ActionListener ; 17 18 import javax.swing.BorderFactory ; 19 import javax.swing.JComboBox ; 20 import javax.swing.JLabel ; 21 import javax.swing.JPanel ; 22 23 import org.openharmonise.him.editors.report.rqom.*; 24 25 26 34 public class ReportFooter extends JPanel implements LayoutManager , ActionListener { 35 36 39 private ReportQuery m_reportQuery = null; 40 41 44 private JLabel m_activityLabel = null; 45 46 49 private JLabel m_publishedLabel = null; 50 51 54 private JComboBox m_publishedCombo = null; 55 56 59 private JLabel m_archivedLabel = null; 60 61 64 private JComboBox m_archivedCombo = null; 65 66 69 private JLabel m_moveLabel = null; 70 71 74 private JComboBox m_moveCombo = null; 75 76 79 private JLabel m_retrievedLabel = null; 80 81 84 private JComboBox m_retrievedCombo = null; 85 86 89 private JLabel m_workflowLabel = null; 90 91 94 private JComboBox m_workflowCombo = null; 95 96 99 private JPanel m_borderPanel = null; 100 101 104 private JLabel m_propLabel = null; 105 106 109 private AttributePanel m_attributePanel; 110 111 private int m_nHeight = 100; 112 113 118 public ReportFooter(ReportQuery query) { 119 super(); 120 this.m_reportQuery = query; 121 this.setup(); 122 } 123 124 128 private void setup() { 129 this.setLayout(this); 130 131 String fontName = "Dialog"; 132 int fontSize = 11; 133 Font font = new Font (fontName, Font.PLAIN, fontSize); 134 135 String [] sData = new String []{"Yes", "No"}; 136 137 this.m_activityLabel = new JLabel ("Display Attributes"); 138 this.m_activityLabel.setFont(font); 139 this.add(this.m_activityLabel); 140 141 this.m_borderPanel = new JPanel (); 142 this.m_borderPanel.setBorder( BorderFactory.createLineBorder(Color.BLACK)); 143 this.add(this.m_borderPanel); 144 145 this.m_publishedLabel = new JLabel ("Published"); 146 this.m_publishedLabel.setFont(font); 147 this.add(this.m_publishedLabel); 148 149 this.m_publishedCombo = new JComboBox (sData); 150 this.m_publishedCombo.setActionCommand("PUBLISHED"); 151 this.m_publishedCombo.addActionListener(this); 152 this.m_publishedCombo.setBackground(Color.WHITE); 153 this.m_publishedCombo.setFont(font); 154 if(this.m_reportQuery.getActivities().contains(ReportQuery.ACTIVITY_PUBLISH)) { 155 this.m_publishedCombo.setSelectedItem("Yes"); 156 } else { 157 this.m_publishedCombo.setSelectedItem("No"); 158 } 159 this.add(this.m_publishedCombo); 160 161 this.m_archivedLabel = new JLabel ("Archived"); 162 this.m_archivedLabel.setFont(font); 163 this.add(this.m_archivedLabel); 164 165 this.m_archivedCombo = new JComboBox (sData); 166 this.m_archivedCombo.setActionCommand("ARCHIVED"); 167 this.m_archivedCombo.addActionListener(this); 168 this.m_archivedCombo.setBackground(Color.WHITE); 169 this.m_archivedCombo.setFont(font); 170 if(this.m_reportQuery.getActivities().contains(ReportQuery.ACTIVITY_ARCHIVE)) { 171 this.m_archivedCombo.setSelectedItem("Yes"); 172 } else { 173 this.m_archivedCombo.setSelectedItem("No"); 174 } 175 this.add(this.m_archivedCombo); 176 177 this.m_moveLabel = new JLabel ("Move/copy"); 178 this.m_moveLabel.setFont(font); 179 this.add(this.m_moveLabel); 180 181 this.m_moveCombo = new JComboBox (sData); 182 this.m_moveCombo.setActionCommand("MOVE"); 183 this.m_moveCombo.addActionListener(this); 184 this.m_moveCombo.setBackground(Color.WHITE); 185 this.m_moveCombo.setFont(font); 186 if(this.m_reportQuery.getActivities().contains(ReportQuery.ACTIVITY_MOVE)) { 187 this.m_moveCombo.setSelectedItem("Yes"); 188 } else { 189 this.m_moveCombo.setSelectedItem("No"); 190 } 191 this.add(this.m_moveCombo); 192 193 this.m_retrievedLabel = new JLabel ("Retrieved"); 194 this.m_retrievedLabel.setFont(font); 195 this.add(this.m_retrievedLabel); 196 197 this.m_retrievedCombo = new JComboBox (sData); 198 this.m_retrievedCombo.setActionCommand("RETRIEVED"); 199 this.m_retrievedCombo.addActionListener(this); 200 this.m_retrievedCombo.setBackground(Color.WHITE); 201 this.m_retrievedCombo.setFont(font); 202 if(this.m_reportQuery.getActivities().contains(ReportQuery.ACTIVITY_RETRIEVE)) { 203 this.m_retrievedCombo.setSelectedItem("Yes"); 204 } else { 205 this.m_retrievedCombo.setSelectedItem("No"); 206 } 207 this.add(this.m_retrievedCombo); 208 209 this.m_workflowLabel = new JLabel ("Workflow"); 210 this.m_workflowLabel.setFont(font); 211 this.add(this.m_workflowLabel); 212 213 this.m_workflowCombo = new JComboBox (sData); 214 this.m_workflowCombo.setActionCommand("WORKFLOW"); 215 this.m_workflowCombo.addActionListener(this); 216 this.m_workflowCombo.setBackground(Color.WHITE); 217 this.m_workflowCombo.setFont(font); 218 if(this.m_reportQuery.getActivities().contains(ReportQuery.ACTIVITY_WORKFLOW)) { 219 this.m_workflowCombo.setSelectedItem("Yes"); 220 } else { 221 this.m_workflowCombo.setSelectedItem("No"); 222 } 223 this.add(this.m_workflowCombo); 224 225 this.m_propLabel = new JLabel ("Properties"); 226 this.m_propLabel.setFont(font); 227 this.add(this.m_propLabel); 228 229 m_attributePanel = new AttributePanel(this.m_reportQuery, m_reportQuery.getDisplayAttributes(), null); 230 add(m_attributePanel); 231 232 } 233 234 237 public void actionPerformed(ActionEvent ae) { 238 if(ae.getActionCommand().equals("PUBLISHED")) { 239 if(((String )this.m_publishedCombo.getSelectedItem()).equals("Yes") && !this.m_reportQuery.getActivities().contains(ReportQuery.ACTIVITY_PUBLISH)) { 240 this.m_reportQuery.addActivity(ReportQuery.ACTIVITY_PUBLISH); 241 } else if(((String )this.m_publishedCombo.getSelectedItem()).equals("No")) { 242 this.m_reportQuery.removeActivity(ReportQuery.ACTIVITY_PUBLISH); 243 } 244 } else if(ae.getActionCommand().equals("ARCHIVED")) { 245 if(((String )this.m_archivedCombo.getSelectedItem()).equals("Yes") && !this.m_reportQuery.getActivities().contains(ReportQuery.ACTIVITY_ARCHIVE)) { 246 this.m_reportQuery.addActivity(ReportQuery.ACTIVITY_ARCHIVE); 247 } else if(((String )this.m_archivedCombo.getSelectedItem()).equals("No")) { 248 this.m_reportQuery.removeActivity(ReportQuery.ACTIVITY_ARCHIVE); 249 } 250 } else if(ae.getActionCommand().equals("MOVE")) { 251 if(((String )this.m_moveCombo.getSelectedItem()).equals("Yes") && !this.m_reportQuery.getActivities().contains(ReportQuery.ACTIVITY_MOVE)) { 252 this.m_reportQuery.addActivity(ReportQuery.ACTIVITY_MOVE); 253 } else if(((String )this.m_moveCombo.getSelectedItem()).equals("No")) { 254 this.m_reportQuery.removeActivity(ReportQuery.ACTIVITY_MOVE); 255 } 256 } else if(ae.getActionCommand().equals("RETRIEVED")) { 257 if(((String )this.m_retrievedCombo.getSelectedItem()).equals("Yes") && !this.m_reportQuery.getActivities().contains(ReportQuery.ACTIVITY_RETRIEVE)) { 258 this.m_reportQuery.addActivity(ReportQuery.ACTIVITY_RETRIEVE); 259 } else if(((String )this.m_retrievedCombo.getSelectedItem()).equals("No")) { 260 this.m_reportQuery.removeActivity(ReportQuery.ACTIVITY_RETRIEVE); 261 } 262 } else if(ae.getActionCommand().equals("WORKFLOW")) { 263 if(((String )this.m_workflowCombo.getSelectedItem()).equals("Yes") && !this.m_reportQuery.getActivities().contains(ReportQuery.ACTIVITY_WORKFLOW)) { 264 this.m_reportQuery.addActivity(ReportQuery.ACTIVITY_WORKFLOW); 265 } else if(((String )this.m_workflowCombo.getSelectedItem()).equals("No")) { 266 this.m_reportQuery.removeActivity(ReportQuery.ACTIVITY_WORKFLOW); 267 } 268 } 269 } 270 271 274 public void layoutContainer(Container arg0) { 275 int nHeight = 10; 276 277 this.m_activityLabel.setSize(this.m_activityLabel.getPreferredSize()); 278 this.m_activityLabel.setLocation(10, nHeight); 279 nHeight = nHeight + this.m_activityLabel.getSize().height + 5; 280 281 this.m_borderPanel.setSize(700, 1); 282 this.m_borderPanel.setLocation(10 + this.m_activityLabel.getSize().width + 5, this.m_activityLabel.getLocation().y + this.m_activityLabel.getSize().height/2); 283 284 m_propLabel.setSize(m_propLabel.getPreferredSize()); 285 m_propLabel.setLocation(20,nHeight); 286 287 m_attributePanel.setSize(m_attributePanel.getPreferredSize()); 288 m_attributePanel.setLocation(100, nHeight); 289 290 int nComboWidth = 170; 291 292 nHeight += m_propLabel.getSize().height + 10; 293 294 this.m_publishedLabel.setSize(this.m_publishedLabel.getPreferredSize()); 295 this.m_publishedLabel.setLocation(20, nHeight); 296 297 this.m_publishedCombo.setSize(nComboWidth, 20); 298 this.m_publishedCombo.setLocation(100, nHeight); 299 300 nHeight = nHeight + this.m_publishedLabel.getSize().height + 10; 301 302 this.m_archivedLabel.setSize(this.m_archivedLabel.getPreferredSize()); 303 this.m_archivedLabel.setLocation(20, nHeight); 304 305 this.m_archivedCombo.setSize(nComboWidth, 20); 306 this.m_archivedCombo.setLocation(100, nHeight); 307 308 nHeight = nHeight + this.m_archivedLabel.getSize().height + 10; 309 310 int nHeight2 = 30; 311 312 this.m_moveLabel.setSize(this.m_moveLabel.getPreferredSize()); 313 this.m_moveLabel.setLocation(340, nHeight2); 314 315 this.m_moveCombo.setSize(nComboWidth, 20); 316 this.m_moveCombo.setLocation(420, nHeight2); 317 318 nHeight2 = nHeight2 + this.m_moveLabel.getSize().height + 10; 319 320 this.m_retrievedLabel.setSize(this.m_retrievedLabel.getPreferredSize()); 321 this.m_retrievedLabel.setLocation(340, nHeight2); 322 323 this.m_retrievedCombo.setSize(nComboWidth, 20); 324 this.m_retrievedCombo.setLocation(420, nHeight2); 325 326 nHeight2 = nHeight2 + this.m_retrievedLabel.getSize().height + 10; 327 328 this.m_workflowLabel.setSize(this.m_workflowLabel.getPreferredSize()); 329 this.m_workflowLabel.setLocation(340, nHeight2); 330 331 this.m_workflowCombo.setSize(nComboWidth, 20); 332 this.m_workflowCombo.setLocation(420, nHeight2); 333 334 nHeight2 = nHeight2 + this.m_workflowLabel.getSize().height + 10; 335 336 if(nHeight>=nHeight2){ 337 m_nHeight = nHeight; 338 } else { 339 m_nHeight = nHeight2; 340 } 341 } 342 343 346 public Dimension getPreferredSize() { 347 return new Dimension (700, m_nHeight); 348 } 349 350 353 private ReportFooter() { 354 super(); 355 } 356 357 360 private ReportFooter(boolean arg0) { 361 super(arg0); 362 } 363 364 367 private ReportFooter(LayoutManager arg0) { 368 super(arg0); 369 } 370 371 375 private ReportFooter(LayoutManager arg0, boolean arg1) { 376 super(arg0, arg1); 377 } 378 379 382 public void removeLayoutComponent(Component arg0) { 383 } 384 385 388 public void addLayoutComponent(String arg0, Component arg1) { 389 } 390 391 394 public Dimension minimumLayoutSize(Container arg0) { 395 return this.getPreferredSize(); 396 } 397 398 401 public Dimension preferredLayoutSize(Container arg0) { 402 return this.getPreferredSize(); 403 } 404 405 } 406 | Popular Tags |