123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- /**
- Licensed Materials - Property of IBM
- IBM Cognos Products: DOCS
- (C) Copyright IBM Corp. 2005, 2008
- US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with
- IBM Corp.
- */
- /**
- * packageDialog.java
- *
- * Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
- * Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
- */
- import java.awt.Frame;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.WindowAdapter;
- import java.awt.event.WindowEvent;
- import java.awt.*;
- import javax.swing.JOptionPane;
- import javax.swing.JPanel;
- import javax.swing.JButton;
- import javax.swing.JDialog;
- import javax.swing.JList;
- import javax.swing.JScrollPane;
- import javax.swing.*;
- public class packageDialog extends JDialog {
- // Define the components of the dialog box
- private JList contentList;
- private JButton okButton;
- private JButton cancelButton;
- private String archiveStr = null;
- private String deployArchiveStr=null;
- private String deploySpec = null;
- private String[] contentStr;
- private CRNConnect oneConnect;
- private Object[] publicContentList;
- public String stringOfID = null;
- public packageDialog(Frame owner, String title, boolean modal,
- String myArchive, String deployArchive, String[] myContent, CRNConnect myConnect,
- String deployType) {
- super(owner, title, modal);
- archiveStr = myArchive;
- deployArchiveStr=deployArchive;
- contentStr = myContent;
- oneConnect = myConnect;
- deploySpec = deployType;
- getContentPane().setLayout(new BorderLayout(2, 2));
- contentList = new JList(contentStr);
- JScrollPane scrollPane = new JScrollPane(contentList,
- ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
- ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
- scrollPane.setSize(230, 80);
- JPanel buttonPanel = new JPanel();
- okButton = new JButton("Ok");
- okButton.setSize(80, 30);
- buttonPanel.add(okButton);
- cancelButton = new JButton("Cancel");
- cancelButton.setSize(80, 30);
- buttonPanel.add(cancelButton);
- getContentPane().add(BorderLayout.NORTH, scrollPane);
- getContentPane().add(BorderLayout.SOUTH, buttonPanel);
- setTitle("Select the public folders contents");
- setSize(280, 250);
- setLocation(380, 250);
- setDefaultCloseOperation(DISPOSE_ON_CLOSE);
- // Listen for ok button click
- okButton.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- okButtonClicked();
- }
- });
- // Listen for cancel button click
- cancelButton.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- cancelButtonClicked();
- }
- });
- // Listen for window closing: treat like cancel button
- addWindowListener(new WindowAdapter() {
- public void windowClosing(WindowEvent event) {
- cancelButtonClicked();
- }
- });
- }
- /**
- * use to handle when OK button is clicked
- */
- private void okButtonClicked() {
- Deployment myDeploy = new Deployment();
- publicContentList = contentList.getSelectedValues();
- String[] contentList = new String[publicContentList.length];
- for (int i = 0; i < publicContentList.length; i++) {
- contentList[i] = (String) publicContentList[i];
- }
- if (contentList.length == 0) {
- int result = JOptionPane
- .showConfirmDialog(
- null,
- "No folder is selected. Click Yes to continue the deployment or Cancel to return to your selection.",
- null, JOptionPane.OK_CANCEL_OPTION);
- if (result != 0) {
- return;
- }
- }
- stringOfID = myDeploy.deployContent(deploySpec, archiveStr,
- deployArchiveStr, contentList, oneConnect);
- dispose();
- }
- /**
- * use to handle when Cancel button is clicked
- */
- private void cancelButtonClicked() {
- dispose(); // destroy this dialog box
- return;
- }
- /**
- * use to get the process string code
- */
- public String getDeploymentID() {
- return stringOfID;
- }
- }
|