001: //WebOnSwing - Web Application Framework
002: //Copyright (C) 2003 Fernando Damian Petrola
003: //
004: //This library is free software; you can redistribute it and/or
005: //modify it under the terms of the GNU Lesser General Public
006: //License as published by the Free Software Foundation; either
007: //version 2.1 of the License, or (at your option) any later version.
008: //
009: //This library is distributed in the hope that it will be useful,
010: //but WITHOUT ANY WARRANTY; without even the implied warranty of
011: //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: //Lesser General Public License for more details.
013: //
014: //You should have received a copy of the GNU Lesser General Public
015: //License along with this library; if not, write to the Free Software
016: //Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017:
018: package examples.inspector;
019:
020: import java.awt.*;
021: import java.util.*;
022:
023: import javax.swing.*;
024: import javax.swing.event.*;
025:
026: import net.ar.webonswing.*;
027: import net.ar.webonswing.managers.pages.*;
028: import net.ar.webonswing.managers.ui.*;
029: import net.ar.webonswing.swing.components.*;
030: import net.ar.webonswing.wrapping.*;
031:
032: public class PageInspector extends JFrame {
033: protected JList thePagesList;
034: protected VisualWindow theWindow;
035:
036: public PageInspector() {
037: initComponents();
038: }
039:
040: private void initComponents() {
041: thePagesList = new JList();
042: updatePageList();
043: theWindow = WosFramework.getInstance().getPageManager()
044: .getWindowForPath("/WosExamples/WebOnSwingDemo");
045:
046: thePagesList
047: .addListSelectionListener(new ListSelectionListener() {
048:
049: public void valueChanged(ListSelectionEvent e) {
050: if (e.getValueIsAdjusting() == false) {
051: int theIndex = thePagesList
052: .getSelectedIndex();
053:
054: String theElement = (String) ((DefaultListModel) thePagesList
055: .getModel()).getElementAt(theIndex);
056:
057: theWindow = WosFramework.getInstance()
058: .getPageManager().getWindowForPath(
059: theElement);
060:
061: updatePageList();
062: updateContentPane();
063: }
064: }
065: });
066:
067: updateContentPane();
068: }
069:
070: void updateContentPane() {
071: JPanel theBodyPanel = new JPanel();
072:
073: theBodyPanel.setLayout(WosFramework
074: .getTemplateLayoutForName("PageInspector.theTable"));
075: theBodyPanel.add(thePagesList, "theList");
076: WindowWrapper theWrapper = ((WindowWrapper) theWindow);
077:
078: Window theRealWindow = (Window) theWrapper
079: .getWrappedComponent();
080:
081: ((RootPaneContainer) theRealWindow).getContentPane().setBounds(
082: 0, 0, 640, 480);
083: theBodyPanel.add(((RootPaneContainer) theRealWindow)
084: .getContentPane(), "thePageView");
085:
086: JLink unLink = new JLink(
087: "goto page of window: "
088: + theWrapper.getWrappedComponent().getClass()
089: .getName(), theWrapper
090: .getWrappedComponent().getClass());
091: theBodyPanel.add(unLink, "theLink");
092:
093: setContentPane(new ManagementComponent(theBodyPanel,
094: "Page Inspector"));
095: }
096:
097: protected void updatePageList() {
098: DefaultListModel theListModel = new DefaultListModel();
099:
100: for (Iterator i = WosFramework.getInstance().getPageManager()
101: .getIterator(); i.hasNext();) {
102: HtmlPageManagerEntry theElement = (HtmlPageManagerEntry) i
103: .next();
104: theListModel.addElement(theElement.getPath());
105: }
106:
107: if (theListModel.getSize() != thePagesList.getModel().getSize())
108: thePagesList.setModel(theListModel);
109: }
110:
111: }
|