KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > lucane > applications > administrator > gui > ConceptPanel


1 /*
2  * Lucane - a collaborative platform
3  * Copyright (C) 2003 Vincent Fiack <vfiack@mail15.com>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */

19
20 package org.lucane.applications.administrator.gui;
21
22 import java.awt.*;
23 import javax.swing.*;
24 import javax.swing.event.*;
25
26
27 import org.lucane.common.concepts.*;
28 import org.lucane.applications.administrator.AdministratorPlugin;
29
30 public class ConceptPanel extends JPanel
31 implements ListSelectionListener
32 {
33     private ConceptListPanel conceptList;
34     private UserPanel userPanel;
35     private ServicePanel servicePanel;
36     private PluginPanel pluginPanel;
37     private GroupPanel groupPanel;
38     
39     private JSplitPane splitPane;
40     
41     public ConceptPanel(AdministratorPlugin plugin)
42     {
43         super(new BorderLayout());
44         //-- attributes
45
conceptList = new ConceptListPanel(plugin, this);
46         conceptList.addListSelectionListener(this);
47         userPanel = new UserPanel(plugin, this);
48         servicePanel = new ServicePanel(plugin, this);
49         pluginPanel = new PluginPanel(plugin, this);
50         groupPanel = new GroupPanel(plugin, this);
51             
52         //-- layout
53
splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, conceptList, new JPanel());
54         splitPane.setDividerLocation(250);
55         splitPane.setDividerSize(5);
56         this.add(splitPane, BorderLayout.CENTER);
57     }
58     
59     public void valueChanged(ListSelectionEvent e)
60     {
61         int row = conceptList.getSelectedRow();
62         if(row < 0)
63             return;
64
65         Concept concept = conceptList.getConceptAt(row);
66         showConcept(concept);
67     }
68     
69     public void refresh()
70     {
71         conceptList.refresh();
72     }
73     
74     public void showConcept(Concept concept)
75     {
76         if(concept == null)
77             splitPane.setBottomComponent(new JPanel());
78         else if(concept instanceof GroupConcept)
79         {
80             groupPanel.showConcept((GroupConcept)concept);
81             splitPane.setBottomComponent(groupPanel);
82         }
83         else if(concept instanceof UserConcept)
84         {
85             userPanel.showConcept((UserConcept)concept);
86             splitPane.setBottomComponent(userPanel);
87         }
88         else if(concept instanceof PluginConcept)
89         {
90             pluginPanel.showConcept((PluginConcept)concept);
91             splitPane.setBottomComponent(pluginPanel);
92         }
93         else if(concept instanceof ServiceConcept)
94         {
95             servicePanel.showConcept((ServiceConcept)concept);
96             splitPane.setBottomComponent(servicePanel);
97         }
98         
99         splitPane.setDividerLocation(250);
100     }
101 }
Popular Tags