ExecReportsUI.java 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716
  1. /**
  2. Licensed Materials - Property of IBM
  3. IBM Cognos Products: DOCS
  4. (C) Copyright IBM Corp. 2005, 2008
  5. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with
  6. IBM Corp.
  7. */
  8. /**
  9. * ExecReportsUI.java
  10. *
  11. * Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
  12. * Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
  13. *
  14. */
  15. import java.awt.BorderLayout;
  16. import java.awt.Dimension;
  17. import java.awt.GridBagConstraints;
  18. import java.awt.GridBagLayout;
  19. import java.awt.GridLayout;
  20. import java.awt.event.ActionEvent;
  21. import java.awt.event.ActionListener;
  22. import java.awt.event.WindowAdapter;
  23. import java.awt.event.WindowEvent;
  24. import java.io.File;
  25. import java.net.URL;
  26. import javax.swing.BorderFactory;
  27. import javax.swing.ImageIcon;
  28. import javax.swing.JButton;
  29. import javax.swing.JComboBox;
  30. import javax.swing.JEditorPane;
  31. import javax.swing.JFrame;
  32. import javax.swing.JLabel;
  33. import javax.swing.JMenu;
  34. import javax.swing.JMenuBar;
  35. import javax.swing.JMenuItem;
  36. import javax.swing.JOptionPane;
  37. import javax.swing.JPanel;
  38. import javax.swing.JScrollPane;
  39. import javax.swing.JTextField;
  40. import javax.swing.JCheckBox;
  41. import com.cognos.developer.schemas.bibus._3.AuthoredReport;
  42. import com.cognos.developer.schemas.bibus._3.BaseClass;
  43. import com.cognos.developer.schemas.bibus._3.BooleanProp;
  44. import com.cognos.developer.schemas.bibus._3.OrderEnum;
  45. import com.cognos.developer.schemas.bibus._3.PropEnum;
  46. import com.cognos.developer.schemas.bibus._3.QueryOptions;
  47. import com.cognos.developer.schemas.bibus._3.SearchPathMultipleObject;
  48. import com.cognos.developer.schemas.bibus._3.Sort;
  49. // This Java class extends the JFrame class so that you can
  50. // display a window.
  51. public class ExecReportsUI extends JFrame
  52. {
  53. private CRNConnect connect;
  54. // The following variables represent the dialog components.
  55. private JEditorPane htmlAreaPane;
  56. private JTextField cmURL;
  57. private JTextField selectedSearchPath;
  58. private JButton runReportButton;
  59. private JButton firstPageButton;
  60. private JButton prevPageButton;
  61. private JButton nextPageButton;
  62. private JButton lastPageButton;
  63. private JCheckBox BurstCheckBox;
  64. private JComboBox repTypeOption;
  65. private JComboBox repSelectOption;
  66. private static Logon sessionLogon;
  67. private static final String REP_TYPE_HTML = "HTML";
  68. private static final String REP_TYPE_HTMLFRAG = "HTML Fragment";
  69. private static final String REP_TYPE_MHT = "HTML Web Archive";
  70. private static final String REP_TYPE_XML = "XML";
  71. private static final String REP_TYPE_PDF = "PDF";
  72. private static final String REP_TYPE_CSV = "CSV";
  73. private static final String REP_TYPE_XLWA = "Excel Web Archive";
  74. private static final int REP_TYPE_ENUM_HTML = 0;
  75. private static final int REP_TYPE_ENUM_XML = 1;
  76. private static final int REP_TYPE_ENUM_PDF = 2;
  77. private static final int REP_TYPE_ENUM_CSV = 3;
  78. private static final int REP_TYPE_ENUM_HTMLFRAG = 4;
  79. private static final int REP_TYPE_ENUM_MHT = 5;
  80. private static final int REP_TYPE_ENUM_XLWA = 6;
  81. private static int reportType = 0;
  82. private static boolean canBeBursted=false;
  83. private BaseClassWrapper selectedReport = null;
  84. private allButtonsHandler buttonListener = new allButtonsHandler();
  85. //private File tmpHTMLFile = null;
  86. // This is the constructor.
  87. public ExecReportsUI(String title, CRNConnect connection)
  88. {
  89. // Set the title of the frame, even before the variables are declared.
  90. super(title);
  91. connect = connection;
  92. addComponents();
  93. }
  94. // Add all components to the frame's panel.
  95. private void addComponents()
  96. {
  97. //
  98. //Create and add menu components
  99. //
  100. JMenuBar mBar = new JMenuBar();
  101. this.setJMenuBar(mBar);
  102. //declare menuItems
  103. JMenuItem exit;
  104. JMenuItem about;
  105. JMenuItem overview;
  106. //Add and populate the File menu.
  107. JMenu fileMenu = new JMenu("File");
  108. mBar.add(fileMenu);
  109. exit = new JMenuItem("Exit");
  110. fileMenu.add(exit);
  111. exit.addActionListener(new MenuHandler());
  112. //Add and populate the Help menu.
  113. JMenu helpMenu = new JMenu("Help");
  114. mBar.add(helpMenu);
  115. about = new JMenuItem("About");
  116. helpMenu.add(about);
  117. about.addActionListener(new MenuHandler());
  118. overview = new JMenuItem("Overview");
  119. helpMenu.add(overview);
  120. overview.addActionListener(new MenuHandler());
  121. //Create panels
  122. JPanel mainPanel = createMainPanel();
  123. JPanel outputNavPanel = createOutputPanel();
  124. JPanel panel = new JPanel(new BorderLayout());
  125. panel.add(mainPanel, BorderLayout.NORTH);
  126. panel.add(outputNavPanel);
  127. setContentPane(panel);
  128. }
  129. private JPanel createOutputPanel()
  130. {
  131. //Create the navigation buttons
  132. firstPageButton = new JButton("First Page");
  133. prevPageButton = new JButton("Previous Page");
  134. nextPageButton = new JButton("Next Page");
  135. lastPageButton = new JButton("Last Page");
  136. firstPageButton.setEnabled(false);
  137. prevPageButton.setEnabled(false);
  138. nextPageButton.setEnabled(false);
  139. lastPageButton.setEnabled(false);
  140. //create a panel for the buttons and add them to it
  141. JPanel navButtonPanel = new JPanel(new GridLayout(0, 1));
  142. navButtonPanel.add(firstPageButton);
  143. navButtonPanel.add(prevPageButton);
  144. navButtonPanel.add(nextPageButton);
  145. navButtonPanel.add(lastPageButton);
  146. firstPageButton.addActionListener(buttonListener);
  147. prevPageButton.addActionListener(buttonListener);
  148. nextPageButton.addActionListener(buttonListener);
  149. lastPageButton.addActionListener(buttonListener);
  150. //Create the html scrollPane
  151. htmlAreaPane = new JEditorPane();
  152. JScrollPane htmlScrollPane = new JScrollPane(htmlAreaPane);
  153. htmlScrollPane.setVerticalScrollBarPolicy(
  154. JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
  155. htmlScrollPane.setPreferredSize(new Dimension(500, 275));
  156. //Create the output panel and it's layout objects
  157. GridBagLayout layout = new GridBagLayout();
  158. JPanel outputNavPanel = new JPanel(layout);
  159. GridBagConstraints layoutConstraints = new GridBagConstraints();
  160. //Set the layout for the scroll pane and add it
  161. layoutConstraints.weightx = 1.0;
  162. layoutConstraints.weighty = 1.0;
  163. layoutConstraints.fill = GridBagConstraints.BOTH;
  164. layout.setConstraints(htmlScrollPane, layoutConstraints);
  165. outputNavPanel.add(htmlScrollPane);
  166. //set the layout for the nav button panel and add it
  167. layoutConstraints.weightx = 0;
  168. layoutConstraints.weighty = 0;
  169. layoutConstraints.fill = GridBagConstraints.HORIZONTAL;
  170. layout.setConstraints(navButtonPanel, layoutConstraints);
  171. outputNavPanel.add(navButtonPanel);
  172. //put a border around the output and nav buttons
  173. outputNavPanel.setBorder(
  174. BorderFactory.createCompoundBorder(
  175. BorderFactory.createCompoundBorder(
  176. BorderFactory.createTitledBorder("Output"),
  177. BorderFactory.createEmptyBorder(5, 5, 5, 5)),
  178. outputNavPanel.getBorder()));
  179. return outputNavPanel;
  180. }
  181. private JPanel createMainPanel()
  182. {
  183. // Create the URL text field and label
  184. cmURL = new JTextField(CRNConnect.CM_URL.length() - 10);
  185. cmURL.setText(CRNConnect.CM_URL);
  186. cmURL.setEditable(false);
  187. //Put together a panel for the URL
  188. JPanel cmURLPanel = new JPanel();
  189. cmURLPanel.add(new JLabel("Server URL:"));
  190. cmURLPanel.add(cmURL);
  191. // Create the searchPath text field and label
  192. selectedSearchPath = new JTextField(CRNConnect.CM_URL.length()+15);
  193. //same as above
  194. selectedSearchPath.setText("");
  195. selectedSearchPath.setEditable(false);
  196. selectedSearchPath.setAutoscrolls(true);
  197. //Put together a panel for the search path
  198. JPanel searchPathPanel = new JPanel();
  199. //searchPathPanel.add(new JLabel("SearchPath:"));
  200. searchPathPanel.add(selectedSearchPath);
  201. //get the button panel
  202. JPanel buttonPanel = createMainButtonPanel();
  203. // create the main panel and add the components
  204. JPanel mainPanel = new JPanel(new GridLayout(3, 0));
  205. // Add everything to the main panel
  206. mainPanel.add(cmURLPanel);
  207. mainPanel.add(buttonPanel);
  208. mainPanel.add(searchPathPanel);
  209. return mainPanel;
  210. }
  211. private JPanel createMainButtonPanel()
  212. {
  213. // Create the button Panel
  214. JPanel buttonPanel = new JPanel();
  215. //Create and add the report output type combo box
  216. String repType[] =
  217. {
  218. REP_TYPE_HTML,
  219. REP_TYPE_HTMLFRAG,
  220. REP_TYPE_MHT,
  221. REP_TYPE_XML,
  222. REP_TYPE_PDF,
  223. REP_TYPE_CSV,
  224. REP_TYPE_XLWA };
  225. repTypeOption = new JComboBox(repType);
  226. repTypeOption.setSelectedItem(null);
  227. repTypeOption.addActionListener(new ReportTypeSelectionHandler());
  228. buttonPanel.add(repTypeOption, BorderLayout.WEST);
  229. // Create and add the select report combo box
  230. BaseClassWrapper listOfReports[] = getListOfReports(connect);
  231. repSelectOption = new JComboBox(listOfReports);
  232. repSelectOption.setSelectedItem(null);
  233. repSelectOption.addActionListener(new ReportSelectionHandler());
  234. buttonPanel.add(repSelectOption, BorderLayout.CENTER);
  235. //Create the bursting check box with text
  236. BurstCheckBox=new JCheckBox("Burst the report");
  237. BurstCheckBox.addActionListener(new BurstCheckBoxHandler());
  238. buttonPanel.add(BurstCheckBox, BorderLayout.EAST);
  239. // Create and add the Button
  240. runReportButton = new JButton("Execute Report");
  241. runReportButton.addActionListener(buttonListener);
  242. buttonPanel.add(runReportButton, BorderLayout.EAST);
  243. return buttonPanel;
  244. }
  245. private class MenuHandler implements ActionListener
  246. {
  247. public void actionPerformed(ActionEvent e)
  248. {
  249. if (e.getActionCommand().startsWith("http://"))
  250. {
  251. connect.connectionChange(e.getActionCommand());
  252. }
  253. try
  254. {
  255. JMenuItem menuClicked = (JMenuItem)e.getSource();
  256. if (menuClicked.getText() == "Exit")
  257. {
  258. System.exit(0);
  259. }
  260. if (menuClicked.getText() == "About")
  261. {
  262. JOptionPane.showMessageDialog(
  263. ((JMenuItem)e.getSource()).getParent(),
  264. "IBM Cognos Sample Application\n\n"
  265. + "Version 1.0.0\n"
  266. + "This application uses the IBM Cognos Software Development Kit",
  267. "About IBM Cognos Samples",
  268. JOptionPane.INFORMATION_MESSAGE,
  269. new ImageIcon("../Common/about.gif"));
  270. }
  271. if (menuClicked.getText().compareTo("Overview") == 0)
  272. {
  273. JFrame explainWindow =
  274. new JFrame("Overview for Execute Report Sample");
  275. File explainFile =
  276. new File("Java_ExecReportsUI_Explain.html");
  277. if (!explainFile.exists())
  278. {
  279. JOptionPane.showMessageDialog(
  280. null,
  281. "Explain file not found");
  282. return;
  283. }
  284. URL explainURL =
  285. new URL("file:///" + explainFile.getAbsolutePath());
  286. JEditorPane explainPane = new JEditorPane();
  287. explainPane.setPage(explainURL);
  288. explainPane.setEditable(false);
  289. JScrollPane explainScroll =
  290. new JScrollPane(
  291. explainPane,
  292. JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
  293. JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
  294. explainWindow.getContentPane().add(explainScroll);
  295. explainWindow.setSize(640, 480);
  296. explainWindow.setVisible(true);
  297. }
  298. }
  299. catch (Exception ex)
  300. {}
  301. }
  302. }
  303. // The following is the button event handler.
  304. // Note: A SWITCH statement cannot be used here because we are comparing
  305. // objects.
  306. private class allButtonsHandler implements ActionListener
  307. {
  308. private RunReport runReport = new RunReport();
  309. public void actionPerformed(ActionEvent e)
  310. {
  311. if (!Logon.loggedIn(connect))
  312. {
  313. try
  314. {
  315. sessionLogon.logon(connect);
  316. }
  317. catch (Exception logonException)
  318. {}
  319. }
  320. JButton buttonPressed = ((JButton)e.getSource());
  321. String output = new String();
  322. try
  323. {
  324. if ((buttonPressed == runReportButton)&&(canBeBursted==false))
  325. {
  326. //Run the selected report.
  327. output =
  328. runReport.runReport(
  329. connect,
  330. selectedReport,
  331. reportType,
  332. false);
  333. }
  334. else if((buttonPressed==runReportButton)&&(canBeBursted==true))
  335. {
  336. if(canBeBursted==true && (reportType==1||reportType==3))
  337. {
  338. if(reportType==1)
  339. {
  340. htmlAreaPane.setText("The requested format 'XML' does not support bursting");
  341. return;
  342. }
  343. else if(reportType==3)
  344. {
  345. htmlAreaPane.setText("The requested format 'CSV' does not support bursting");
  346. return;
  347. }
  348. }
  349. else
  350. {
  351. output =
  352. runReport.runReport(
  353. connect,
  354. selectedReport,
  355. reportType,
  356. canBeBursted);
  357. }
  358. }
  359. else if (buttonPressed == firstPageButton)
  360. {
  361. output = runReport.firstPage(selectedReport, reportType);
  362. }
  363. else if (buttonPressed == prevPageButton)
  364. {
  365. output = runReport.previousPage(selectedReport, reportType);
  366. }
  367. else if (buttonPressed == nextPageButton)
  368. {
  369. output = runReport.nextPage(selectedReport, reportType);
  370. }
  371. else if (buttonPressed == lastPageButton)
  372. {
  373. output = runReport.lastPage(selectedReport, reportType);
  374. }
  375. if (output.compareToIgnoreCase("Bursted") != 0) {
  376. firstPageButton.setEnabled(runReport.hasFirstPage());
  377. prevPageButton.setEnabled(runReport.hasPreviousPage());
  378. nextPageButton.setEnabled(runReport.hasNextPage());
  379. lastPageButton.setEnabled(runReport.hasLastPage());
  380. }
  381. }
  382. catch (java.rmi.RemoteException remoteEx)
  383. {
  384. htmlAreaPane.setContentType("text/html");
  385. output =
  386. "<html><head><title>"
  387. + remoteEx.getMessage()
  388. + "</title></head><body><pre>"
  389. + remoteEx.toString()
  390. + "</pre></body></html>";
  391. htmlAreaPane.setText(output);
  392. return;
  393. }
  394. if (output.compareTo("") != 0 && output.compareTo("Bursted")!=0)
  395. {
  396. try
  397. {
  398. if ( reportType == REP_TYPE_ENUM_HTML
  399. || reportType == REP_TYPE_ENUM_HTMLFRAG
  400. || reportType == REP_TYPE_ENUM_XML )
  401. {
  402. URL localOutputURL =
  403. new URL("file:///" + output);
  404. htmlAreaPane.setPage(localOutputURL);
  405. }
  406. else
  407. {
  408. htmlAreaPane.setContentType("text/html");
  409. output =
  410. "<html><head><title>"
  411. + "IBM Cognos Sample -- Report Output"
  412. + "</title></head><body>"
  413. + "Output written to file: "
  414. + output
  415. + "</body></html>";
  416. htmlAreaPane.setText(output);
  417. }
  418. }
  419. catch (Exception ex)
  420. {
  421. System.out.println("Caught Exception: " + ex);
  422. }
  423. }
  424. else if(output.compareTo("Bursted")==0 && canBeBursted==true)
  425. {
  426. htmlAreaPane.setContentType("text/html");
  427. output =
  428. "<html><head><title>"
  429. + "Burst Report"
  430. + "</title></head><body><pre>"
  431. + "The report has been successfully burst. Please check the email box for details."
  432. + "</pre></body></html>";
  433. htmlAreaPane.setText(output);
  434. }
  435. }
  436. }
  437. // This is the reportType combo box event handler.
  438. private class ReportTypeSelectionHandler implements ActionListener
  439. {
  440. public void actionPerformed(ActionEvent repTypeSelectedEvent)
  441. {
  442. String chosenType = (String)repTypeOption.getSelectedItem();
  443. if (chosenType == REP_TYPE_HTML)
  444. {
  445. reportType = REP_TYPE_ENUM_HTML;
  446. }
  447. else if (chosenType == REP_TYPE_XML)
  448. {
  449. reportType = REP_TYPE_ENUM_XML;
  450. }
  451. else if (chosenType == REP_TYPE_PDF)
  452. {
  453. reportType = REP_TYPE_ENUM_PDF;
  454. }
  455. else if (chosenType == REP_TYPE_CSV)
  456. {
  457. reportType = REP_TYPE_ENUM_CSV;
  458. }
  459. else if (chosenType == REP_TYPE_HTMLFRAG)
  460. {
  461. reportType = REP_TYPE_ENUM_HTMLFRAG;
  462. }
  463. else if (chosenType == REP_TYPE_MHT)
  464. {
  465. reportType = REP_TYPE_ENUM_MHT;
  466. }
  467. else if (chosenType == REP_TYPE_XLWA)
  468. {
  469. reportType = REP_TYPE_ENUM_XLWA;
  470. }
  471. else
  472. {
  473. //error, force HTML (default) ??
  474. reportType = REP_TYPE_ENUM_HTML;
  475. }
  476. }
  477. }
  478. private class ReportSelectionHandler implements ActionListener
  479. {
  480. public void actionPerformed(ActionEvent repSelectedEvent)
  481. {
  482. selectedReport =
  483. (BaseClassWrapper)repSelectOption.getSelectedItem();
  484. selectedSearchPath.setText(
  485. selectedReport.getBaseClassObject().getSearchPath().getValue());
  486. //Check whether the selected report can be burst
  487. AuthoredReport repProp=(AuthoredReport)selectedReport.getBaseClassObject();
  488. BooleanProp canBeBurstedProp=repProp.getCanBurst();
  489. boolean burstStatusChk=canBeBurstedProp.isValue();
  490. if(!burstStatusChk)
  491. {
  492. canBeBursted=false;
  493. BurstCheckBox.setSelected(false);
  494. BurstCheckBox.setEnabled(false);
  495. htmlAreaPane.setText("The report - '"+selectedReport.toString()+"' cannot be burst.");
  496. }
  497. else
  498. {
  499. BurstCheckBox.setEnabled(true);
  500. htmlAreaPane.setText("");
  501. }
  502. }
  503. }
  504. private class BurstCheckBoxHandler implements ActionListener
  505. {
  506. public void actionPerformed(ActionEvent bstCheckBoxSelectedEvent)
  507. {
  508. Object[]selectedCheckBox=BurstCheckBox.getSelectedObjects();
  509. if(selectedCheckBox!=null && selectedCheckBox.length==1)
  510. {
  511. canBeBursted=true;
  512. }
  513. else
  514. {
  515. canBeBursted=false;
  516. }
  517. }
  518. }
  519. //This is a method for retrieving a list of the available reports to run
  520. protected BaseClassWrapper[] getListOfReports(CRNConnect connection)
  521. {
  522. BaseClassWrapper reportAndQueryList[] = null;
  523. BaseClass reports[] = new BaseClass[0];
  524. BaseClass queries[] = new BaseClass[0];
  525. int reportAndQueryIndex = 0;
  526. int reportIndex = 0;
  527. int queryIndex = 0;
  528. if (connection == null)
  529. {
  530. System.out.println(
  531. "Invalid parameter passed to getListOfReports()\n");
  532. return null;
  533. }
  534. PropEnum props[] =
  535. new PropEnum[] { PropEnum.searchPath, PropEnum.defaultName, PropEnum.canBurst, PropEnum.routingServerGroup };
  536. Sort sortOptions[] = { new Sort()};
  537. sortOptions[0].setOrder(OrderEnum.ascending);
  538. sortOptions[0].setPropName(PropEnum.defaultName);
  539. if (!Logon.loggedIn(connect))
  540. {
  541. try
  542. {
  543. sessionLogon.logon(connect);
  544. }
  545. catch (Exception logonException)
  546. {}
  547. }
  548. try
  549. {
  550. SearchPathMultipleObject reportsPath = new SearchPathMultipleObject("/content//report");
  551. SearchPathMultipleObject queriesPath = new SearchPathMultipleObject("/content//query");
  552. reports =
  553. connection.getCMService().query(
  554. reportsPath,
  555. props,
  556. sortOptions,
  557. new QueryOptions());
  558. queries =
  559. connection.getCMService().query(
  560. queriesPath,
  561. props,
  562. sortOptions,
  563. new QueryOptions());
  564. }
  565. catch (java.rmi.RemoteException remoteEx)
  566. {
  567. System.out.println("Caught Remote Exception:\n");
  568. remoteEx.printStackTrace();
  569. }
  570. //TODO
  571. // a java.io.InterruptedIOException here could trigger a retry...
  572. reportAndQueryList =
  573. new BaseClassWrapper[reports.length + queries.length];
  574. if ((reports != null) && (reports.length > 0))
  575. {
  576. for (reportIndex = 0; reportIndex < reports.length; reportIndex++)
  577. {
  578. reportAndQueryList[reportAndQueryIndex++] =
  579. new BaseClassWrapper(reports[reportIndex]);
  580. }
  581. }
  582. if ((queries != null) && (queries.length > 0))
  583. {
  584. for (queryIndex = 0; queryIndex < queries.length; queryIndex++)
  585. {
  586. reportAndQueryList[reportAndQueryIndex++] =
  587. new BaseClassWrapper(queries[queryIndex]);
  588. }
  589. }
  590. return reportAndQueryList;
  591. }
  592. // Create the main method to execute the application.
  593. public static void main(String args[])
  594. {
  595. CRNConnect connection = new CRNConnect();
  596. connection.connectToCognosServer();
  597. sessionLogon = new Logon();
  598. String output = "";
  599. while (!Logon.loggedIn(connection))
  600. {
  601. output = sessionLogon.logon(connection);
  602. if (!Logon.loggedIn(connection))
  603. {
  604. int retry =
  605. JOptionPane.showConfirmDialog(
  606. null,
  607. "Login Failed. Please try again.",
  608. "Login Failed",
  609. JOptionPane.OK_CANCEL_OPTION);
  610. if (retry != JOptionPane.OK_OPTION)
  611. {
  612. System.exit(0);
  613. }
  614. }
  615. }
  616. ExecReportsUI frame =
  617. new ExecReportsUI("IBM Cognos Sample", connection);
  618. // Create a WindowAdapter so the application
  619. // is exited when the window is closed.
  620. frame.addWindowListener(new WindowAdapter()
  621. {
  622. public void windowClosing(WindowEvent e)
  623. {
  624. System.exit(0);
  625. }
  626. });
  627. frame.htmlAreaPane.setText(
  628. output + System.getProperty("line.separator"));
  629. // Set the size of the frame and display it.
  630. frame.setSize(640, 480);
  631. frame.setVisible(true);
  632. frame.setResizable(true);
  633. }
  634. }