summaryrefslogtreecommitdiffstats
path: root/base/console/src/com/netscape/admin/certsrv/CMSResourcePage.java
blob: 9ad03515deb99a32620f0d1c818ce7bf12386612 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
// --- BEGIN COPYRIGHT BLOCK ---
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 2 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// (C) 2007 Red Hat, Inc.
// All rights reserved.
// --- END COPYRIGHT BLOCK ---
package com.netscape.admin.certsrv;

import javax.swing.*;
import javax.swing.tree.*;
import javax.swing.event.*;
import com.netscape.management.client.*;
import com.netscape.management.client.util.*;

/**
 * This page creates the resource view
 *
 * @author Jack Pan-Chen
 * @version $Revision$, $Date$
 * @see com.netscape.admin.certsrv
 */
public class CMSResourcePage extends ResourcePage implements Cloneable {

    /*==========================================================
     * variables
     *==========================================================*/
    protected IMenuInfo mMenuInfo;          // menu information delegation
    
	/*==========================================================
     * constructors
     *==========================================================*/
     
    /**
     * Return ResourcePage using the data model specified.
     */
	public CMSResourcePage(CMSBaseResourceModel resourceModel) {
		super(resourceModel);
		resourceModel.setResourcePage(this);
		//we will only support single selection model
		TreeSelectionModel selectionModel = _tree.getSelectionModel();
		selectionModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION );
	}

    /*==========================================================
	 * public methods
     *==========================================================*/
    
	/**
	 * Need to overwrite this one to clone
	 * DSResourcePage instead of ResourcePage
	 * @return copy of resource page
	 */
    public Object clone() {
		CMSResourcePage rp = new CMSResourcePage((CMSBaseResourceModel)_model);
		rp.setCellRenderer( _treeRenderer );
		rp.setPageTitle(getPageTitle());
	    rp.setMenuInfo(mMenuInfo);
		return rp;
	}

	/**
     * Retrieve JTree Obejct
     * @return JTree obejct in the resource page
     */
    public JTree getTree() {
        return (JTree)_tree;
    }
    
    /**
     * Implements TreeSelectionListener.  Called when an object is selected
	 * in the resource tree.  Informs IResourceModelListeners of this event.
     */
	public void valueChanged(TreeSelectionEvent ev)
	{
		IResourceObject[] selection = getSelection();
		if(selection != null) {
			if(selection.length == 1) // single selection {
				setCustomPanel(_model.getCustomPanel(this, selection[0]));
		}
		_model.actionObjectSelected(this, selection, getPreviousSelection());
		
		//the selected node not necessary the original selection
		//in case of not allow to change
		_previousSelection = getSelection();
	}
    
    /**
     * Called internally when page is unselected
     */
	public void pageUnselected(IFramework framework) {
        super.pageUnselected(framework);
        //check if the data is not saved
	}
	
	/**
	 *	Initializes page.  Called after construction or after clonePage().
	 *  The reference to IFramework allows this page to set menu items, status
	 *  bars, and add event notification listeners. COVERWRITES the method in
	 *  the ResourcePage class to provide the menu contain separartion.
	 */
	public void initialize(IFramework framework) {
	    //Debug.println("CMSResourcePage - initialize() "+mMenuInfo);
	    super.initialize(framework);    
	    if (mMenuInfo != null)
	        addMenuItems(mMenuInfo , _menuInfoAction);
	}
	
	/**
     * Set and replace the existing menuInfo delegation object
     */
    public void setMenuInfo(IMenuInfo menuInfo) {
        //Debug.println("CMSResourcePage - setMenuInfo() "+menuInfo);
        mMenuInfo = menuInfo;
    }
    
    /**
     * Retrieve IMenuInfo object
     */
    public IMenuInfo getMenuInfo() {
        if (mMenuInfo == null) {
            mMenuInfo = new CMSBaseMenuInfo();
        }
        return mMenuInfo;
    }
	
	/**
	 * Start the zipping status bar
	 */
    public void progressStart() {
        //XXX COMEBACK AFTER UPGRADE
        _statusItemProgress.start();
    }

    /**
     * Stop the zipping status bar
     */
    public void progressStop() {
        //XXX COMEBACK AFTER UPGRADE
        _statusItemProgress.stop();
    }	
	
}