packageDialog.java 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. * packageDialog.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. import java.awt.Frame;
  15. import java.awt.event.ActionEvent;
  16. import java.awt.event.ActionListener;
  17. import java.awt.event.WindowAdapter;
  18. import java.awt.event.WindowEvent;
  19. import java.awt.*;
  20. import javax.swing.JOptionPane;
  21. import javax.swing.JPanel;
  22. import javax.swing.JButton;
  23. import javax.swing.JDialog;
  24. import javax.swing.JList;
  25. import javax.swing.JScrollPane;
  26. import javax.swing.*;
  27. public class packageDialog extends JDialog {
  28. // Define the components of the dialog box
  29. private JList contentList;
  30. private JButton okButton;
  31. private JButton cancelButton;
  32. private String archiveStr = null;
  33. private String deployArchiveStr=null;
  34. private String deploySpec = null;
  35. private String[] contentStr;
  36. private CRNConnect oneConnect;
  37. private Object[] publicContentList;
  38. public String stringOfID = null;
  39. public packageDialog(Frame owner, String title, boolean modal,
  40. String myArchive, String deployArchive, String[] myContent, CRNConnect myConnect,
  41. String deployType) {
  42. super(owner, title, modal);
  43. archiveStr = myArchive;
  44. deployArchiveStr=deployArchive;
  45. contentStr = myContent;
  46. oneConnect = myConnect;
  47. deploySpec = deployType;
  48. getContentPane().setLayout(new BorderLayout(2, 2));
  49. contentList = new JList(contentStr);
  50. JScrollPane scrollPane = new JScrollPane(contentList,
  51. ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
  52. ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
  53. scrollPane.setSize(230, 80);
  54. JPanel buttonPanel = new JPanel();
  55. okButton = new JButton("Ok");
  56. okButton.setSize(80, 30);
  57. buttonPanel.add(okButton);
  58. cancelButton = new JButton("Cancel");
  59. cancelButton.setSize(80, 30);
  60. buttonPanel.add(cancelButton);
  61. getContentPane().add(BorderLayout.NORTH, scrollPane);
  62. getContentPane().add(BorderLayout.SOUTH, buttonPanel);
  63. setTitle("Select the public folders contents");
  64. setSize(280, 250);
  65. setLocation(380, 250);
  66. setDefaultCloseOperation(DISPOSE_ON_CLOSE);
  67. // Listen for ok button click
  68. okButton.addActionListener(new ActionListener() {
  69. public void actionPerformed(ActionEvent event) {
  70. okButtonClicked();
  71. }
  72. });
  73. // Listen for cancel button click
  74. cancelButton.addActionListener(new ActionListener() {
  75. public void actionPerformed(ActionEvent event) {
  76. cancelButtonClicked();
  77. }
  78. });
  79. // Listen for window closing: treat like cancel button
  80. addWindowListener(new WindowAdapter() {
  81. public void windowClosing(WindowEvent event) {
  82. cancelButtonClicked();
  83. }
  84. });
  85. }
  86. /**
  87. * use to handle when OK button is clicked
  88. */
  89. private void okButtonClicked() {
  90. Deployment myDeploy = new Deployment();
  91. publicContentList = contentList.getSelectedValues();
  92. String[] contentList = new String[publicContentList.length];
  93. for (int i = 0; i < publicContentList.length; i++) {
  94. contentList[i] = (String) publicContentList[i];
  95. }
  96. if (contentList.length == 0) {
  97. int result = JOptionPane
  98. .showConfirmDialog(
  99. null,
  100. "No folder is selected. Click Yes to continue the deployment or Cancel to return to your selection.",
  101. null, JOptionPane.OK_CANCEL_OPTION);
  102. if (result != 0) {
  103. return;
  104. }
  105. }
  106. stringOfID = myDeploy.deployContent(deploySpec, archiveStr,
  107. deployArchiveStr, contentList, oneConnect);
  108. dispose();
  109. }
  110. /**
  111. * use to handle when Cancel button is clicked
  112. */
  113. private void cancelButtonClicked() {
  114. dispose(); // destroy this dialog box
  115. return;
  116. }
  117. /**
  118. * use to get the process string code
  119. */
  120. public String getDeploymentID() {
  121. return stringOfID;
  122. }
  123. }