[Mc4j-cvs] mc4j/src/org/mc4j/console/dashboard DashboardContainer.java,1.1,1.2 BorderFactory.java,1.
Brought to you by:
ghinkl
From: Greg H. <gh...@us...> - 2006-04-12 19:14:30
|
Update of /cvsroot/mc4j/mc4j/src/org/mc4j/console/dashboard In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20162/src/org/mc4j/console/dashboard Modified Files: BorderFactory.java DashboardManager.java DashboardTopComponent.java DashboardComponentFactory.java DashboardFactory.java AttributeFactory.java Dashboard.java DashboardLoader.java Added Files: DashboardContainer.java Removed Files: DashboardHolder.java Tester.java Log Message: Merging EMS into head for the 2.0 release work Index: DashboardManager.java =================================================================== RCS file: /cvsroot/mc4j/mc4j/src/org/mc4j/console/dashboard/DashboardManager.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** DashboardManager.java 5 Oct 2004 05:16:01 -0000 1.4 --- DashboardManager.java 12 Apr 2006 19:13:51 -0000 1.5 *************** *** 20,26 **** --- 20,30 ---- import org.openide.modules.InstalledFileLocator; import org.openide.windows.IOProvider; + import org.openide.windows.TopComponent; + import org.openide.nodes.Node; + import org.openide.ErrorManager; import org.mc4j.console.bean.MBeanNode; + import javax.swing.*; import java.io.File; import java.io.FileFilter; *************** *** 42,48 **** public class DashboardManager { ! ! private Set dashboardDocuments = new TreeSet(); ! private static DashboardManager INSTANCE = new DashboardManager(); --- 46,52 ---- public class DashboardManager { ! ! private Set<Dashboard> dashboardDocuments = new TreeSet(); ! private static DashboardManager INSTANCE = new DashboardManager(); *************** *** 50,62 **** initialize(); } ! public static DashboardManager getInstance() { return DashboardManager.INSTANCE; } ! public Set getDashboards() { return dashboardDocuments; } ! /** * Retrieves the set of dashboards appropriate for a particular bean --- 54,66 ---- initialize(); } ! public static DashboardManager getInstance() { return DashboardManager.INSTANCE; } ! public Set getDashboards() { return dashboardDocuments; } ! /** * Retrieves the set of dashboards appropriate for a particular bean *************** *** 64,75 **** * @return */ ! public Set getDashboards(MBeanNode mBeanNode) { ! Set results = new TreeSet(); ! Iterator dashboardIterator = this.dashboardDocuments.iterator(); while (dashboardIterator.hasNext()) { Dashboard dashboard = (Dashboard) dashboardIterator.next(); ! ! if (dashboard.matches(mBeanNode)) { results.add(dashboard); } --- 68,79 ---- * @return */ ! public Set<Dashboard> getDashboards(MBeanNode mBeanNode) { ! Set<Dashboard> results = new TreeSet<Dashboard>(); ! Iterator dashboardIterator = this.dashboardDocuments.iterator(); while (dashboardIterator.hasNext()) { Dashboard dashboard = (Dashboard) dashboardIterator.next(); ! ! if (dashboard.matches(mBeanNode.getEmsBean())) { results.add(dashboard); } *************** *** 77,81 **** return results; } ! public final void initialize() { //File dashboardDir = new File("./dashboards"); --- 81,85 ---- return results; } ! public final void initialize() { //File dashboardDir = new File("./dashboards"); *************** *** 106,111 **** List fileList = new ArrayList(); ! File dashboardDir = ! InstalledFileLocator.getDefault().locate("dashboards","org.mc4j.console",false); if (dashboardDir.exists() && dashboardDir.isDirectory()) { --- 110,116 ---- List fileList = new ArrayList(); ! File dashboardDir = new File("dashboards"); ! // InstalledFileLocator.getDefault().locate("dashboards","org.mc4j.console",false); ! if (dashboardDir.exists() && dashboardDir.isDirectory()) { *************** *** 141,143 **** --- 146,172 ---- } + + public void launch(final Dashboard dashboard) { + + + try { + final TopComponent tc = new DashboardTopComponent(dashboard, dashboard.getName()); + SwingUtilities.invokeLater(new Runnable() { + public void run() { + // tc.setActivatedNodes(new Node[] { node }); + tc.setDisplayName(dashboard.getName()); + tc.open(); + tc.requestActive(); + } + }); + + // TODO: Is this done in the launchers? + // node.getConnectionNode().registerDashboard(tc); + } catch (Exception e) { + ErrorManager.getDefault().notify(e); + } + + + } + } --- DashboardHolder.java DELETED --- Index: AttributeFactory.java =================================================================== RCS file: /cvsroot/mc4j/mc4j/src/org/mc4j/console/dashboard/AttributeFactory.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** AttributeFactory.java 5 Oct 2004 05:16:01 -0000 1.8 --- AttributeFactory.java 12 Apr 2006 19:13:52 -0000 1.9 *************** *** 17,37 **** package org.mc4j.console.dashboard; ! import java.beans.PropertyDescriptor; ! import java.beans.PropertyEditor; ! import java.beans.PropertyEditorManager; ! import java.util.Map; ! ! import javax.swing.JComponent; ! import org.openide.ErrorManager; import org.openide.windows.IOProvider; - - import org.mc4j.console.dashboard.context.ContextHelper; - import org.mc4j.console.util.BeanUtil; - import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; /** * --- 17,34 ---- package org.mc4j.console.dashboard; ! import org.mc4j.console.dashboard.context.OgnlHelper; ! import org.mc4j.console.util.BeanUtil; import org.openide.ErrorManager; import org.openide.windows.IOProvider; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; + import javax.swing.*; + import java.beans.PropertyDescriptor; + import java.beans.PropertyEditor; + import java.beans.PropertyEditorManager; + import java.util.Map; + /** * *************** *** 41,85 **** public class AttributeFactory { ! public static void loadAttributes(Element parent, Object object, Map context) { NodeList children = parent.getChildNodes(); for (int j = 0; j < children.getLength(); j++) { Node childNode = children.item(j); if ("Attribute".equals(childNode.getNodeName())) { ! setAttribute((Element)childNode, object, context); } } } ! private static void setAttribute(Element attribute, Object object, Map context) { String name = attribute.getAttribute("name"); String valueString = attribute.getAttribute("value"); try { ! Object value = null; ! IOProvider.getDefault().getIO("Dashboard debugging",false).getOut().println("Introspecting: " + object.getClass().getName() + ", name = " + name + ", value = " + valueString); ! PropertyDescriptor desc = BeanUtil.getPropertyDescriptor(name, object.getClass()); if ((valueString == null) || (valueString.length() < 1) || (JComponent.class.isAssignableFrom(desc.getPropertyType()))) { ! // Use content Element childComponentElement = DashboardFactory.findChild(attribute, "Component"); ! ! DashboardFactory factory = new DashboardFactory(); ! ! JComponent childComponent = factory.buildV1Component(childComponentElement, context); ! ! value = childComponent; } else { ! try { ! //IOProvider.getDefault().getIO("Dashboard debugging",false).getOut().println("Checking context for value: " + valueString); ! value = ContextHelper.getValue(valueString, context); ! //IOProvider.getDefault().getIO("Dashboard debugging",false).getOut().println("Got back: " + value); ! } catch (RuntimeException re) { ! ErrorManager.getDefault().notify(re); } ! ! if (value instanceof String) { valueString = (String) value; try { --- 38,96 ---- public class AttributeFactory { ! public static void loadAttributes(Element parent, Object component, Map context) { NodeList children = parent.getChildNodes(); for (int j = 0; j < children.getLength(); j++) { Node childNode = children.item(j); if ("Attribute".equals(childNode.getNodeName())) { ! setAttribute((Element)childNode, component, context); } } } ! private static void setAttribute(Element attribute, Object component, Map context) { String name = attribute.getAttribute("name"); String valueString = attribute.getAttribute("value"); + try { ! ! Object value = null; ! IOProvider.getDefault().getIO("Dashboard debugging",false).getOut().println("Introspecting: " + component.getClass().getName() + ", name = " + name + ", value = " + valueString); ! PropertyDescriptor desc = BeanUtil.getPropertyDescriptor(name, component.getClass()); if ((valueString == null) || (valueString.length() < 1) || (JComponent.class.isAssignableFrom(desc.getPropertyType()))) { ! // In these cases, we're looking at the contents of the attribute tag not the xml attributes Element childComponentElement = DashboardFactory.findChild(attribute, "Component"); ! if (childComponentElement != null) { ! // This is an object attribute that happens to take a component as its type ! DashboardFactory factory = new DashboardFactory(); ! ! value = factory.buildV1Component(childComponentElement, context); ! } else { ! // We're going to assume the actual tag content is what we want ! // Set it as a string ! value = attribute.getTextContent(); ! ! } } else { ! ! // If the user marks it a literal, don't use Ognl ! String literal = attribute.getAttribute("literal"); ! if (literal != null && Boolean.valueOf(literal)) { ! value = valueString; ! } else { ! // We're going to try and figure out the value ! IOProvider.getDefault().getIO("Dashboard debugging",false).getOut().println("Checking context for value: " + valueString); ! value = OgnlHelper.getValue(valueString, context, component, desc.getPropertyType()); ! //ContextHelper.getValue(valueString, context); Old way ! IOProvider.getDefault().getIO("Dashboard debugging",false).getOut().println("Got back: " + value); } ! ! // This is a second chance to convert values using the PropertyEditor system... ! // Shouldn't be necessary... but hey, its cheap to try if we're not ! if (value instanceof String && desc.getPropertyType() != String.class) { valueString = (String) value; try { *************** *** 89,93 **** } catch (IllegalArgumentException iae) { // Perhaps its a constant? ! Object constValue = BeanUtil.getStaticFieldValue(object.getClass(),valueString); if (constValue != null) value = constValue; --- 100,104 ---- } catch (IllegalArgumentException iae) { // Perhaps its a constant? ! Object constValue = BeanUtil.getStaticFieldValue(component.getClass(),valueString); if (constValue != null) value = constValue; *************** *** 96,104 **** } ! IOProvider.getDefault().getIO("Dashboard debugging",false).getOut().println("Setting attribute [" + name + "] = [" + value + "] on object: " + object); ! BeanUtil.setObjectAttribute(object, name, value); } catch (Exception e) { ! IOProvider.getDefault().getIO("Dashboard debugging",false).getOut().println("*** Exception while setting attribute [" + name + "] = [" + valueString + "] on object: " + object); ErrorManager.getDefault().notify(e); --- 107,115 ---- } ! IOProvider.getDefault().getIO("Dashboard debugging",false).getOut().println("Setting attribute [" + name + "] = [" + value + "] on object: " + component); ! BeanUtil.setObjectAttribute(component, name, value); } catch (Exception e) { ! IOProvider.getDefault().getIO("Dashboard debugging",false).getOut().println("*** Exception while setting attribute [" + name + "] = [" + valueString + "] on object: " + component); ErrorManager.getDefault().notify(e); --- Tester.java DELETED --- Index: DashboardComponentFactory.java =================================================================== RCS file: /cvsroot/mc4j/mc4j/src/org/mc4j/console/dashboard/DashboardComponentFactory.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** DashboardComponentFactory.java 13 Oct 2004 04:59:37 -0000 1.11 --- DashboardComponentFactory.java 12 Apr 2006 19:13:52 -0000 1.12 *************** *** 17,37 **** package org.mc4j.console.dashboard; ! import java.awt.Color; ! import java.awt.Graphics; ! import java.awt.Graphics2D; ! import java.awt.RenderingHints; ! import java.util.Map; ! ! import javax.swing.JComponent; ! import javax.swing.JEditorPane; ! import javax.swing.JLabel; ! import javax.swing.JScrollPane; ! import org.openide.windows.IOProvider; - - import org.mc4j.console.util.ExceptionUtility; - import org.w3c.dom.Element; /** * --- 17,28 ---- package org.mc4j.console.dashboard; ! import org.mc4j.console.dashboard.components.ErrorComponent; import org.openide.windows.IOProvider; import org.w3c.dom.Element; + import javax.swing.*; + import java.awt.*; + import java.util.Map; + /** * *************** *** 70,77 **** AttributeFactory.loadAttributes(node, component, context); - if (component instanceof DashboardComponent) { - ((DashboardComponent)component).setContext(context); - } if (component instanceof JScrollPane) { ((JScrollPane)component).getVerticalScrollBar().setUnitIncrement(10); --- 61,66 ---- AttributeFactory.loadAttributes(node, component, context); + // This is a hack to improve the usability of the scrollwheel... could be intelligent if (component instanceof JScrollPane) { ((JScrollPane)component).getVerticalScrollBar().setUnitIncrement(10); *************** *** 86,92 **** } catch (Exception e) { System.out.println(e); ! JEditorPane errorPane = new JEditorPane("text/plain", ExceptionUtility.printStackTracesToString(e)); ! errorPane.setBackground(Color.yellow); ! return errorPane; } } --- 75,82 ---- } catch (Exception e) { System.out.println(e); ! // JEditorPane errorPane = new JEditorPane("text/plain", ExceptionUtility.printStackTracesToString(e)); ! // errorPane.setBackground(Color.yellow); ! // return errorPane; ! return new ErrorComponent(e); } } Index: BorderFactory.java =================================================================== RCS file: /cvsroot/mc4j/mc4j/src/org/mc4j/console/dashboard/BorderFactory.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** BorderFactory.java 5 Oct 2004 05:16:01 -0000 1.8 --- BorderFactory.java 12 Apr 2006 19:13:51 -0000 1.9 *************** *** 17,20 **** --- 17,29 ---- package org.mc4j.console.dashboard; + import ognl.OgnlException; + import org.mc4j.console.dashboard.context.OgnlHelper; + import org.mc4j.console.util.BeanUtil; + import org.openide.ErrorManager; + import org.openide.windows.IOProvider; + import org.w3c.dom.Element; + + import javax.swing.border.Border; + import javax.swing.border.TitledBorder; import java.awt.Color; import java.beans.PropertyEditor; *************** *** 22,36 **** import java.util.Map; - import javax.swing.border.Border; - import javax.swing.border.TitledBorder; - - import org.openide.ErrorManager; - import org.openide.windows.IOProvider; - - import org.mc4j.console.dashboard.context.ContextHelper; - import org.mc4j.console.util.BeanUtil; - - import org.w3c.dom.Element; - /** * --- 31,34 ---- *************** *** 39,54 **** */ public class BorderFactory { ! /** Creates a new instance of ConstraintFactory */ public BorderFactory() { } ! public static final String TYPE = "type"; ! public Border buildBorder(Element element, Map context) { ! String type = element.getAttribute(TYPE); if (type.equals("javax.swing.border.TitledBorder")) { ! TitledBorder border = new TitledBorder("Initial"); return border; --- 37,52 ---- */ public class BorderFactory { ! /** Creates a new instance of ConstraintFactory */ public BorderFactory() { } ! public static final String TYPE = "type"; ! public Border buildBorder(Element element, Map context) { ! String type = element.getAttribute(TYPE); if (type.equals("javax.swing.border.TitledBorder")) { ! TitledBorder border = new TitledBorder("Initial"); return border; *************** *** 100,106 **** try { ! value = ContextHelper.getValue(attributeString, context); ! } catch (RuntimeException re) { ! ErrorManager.getDefault().notify(re); } --- 98,105 ---- try { ! value = OgnlHelper.getValue(attributeString, context, attributeType); ! //ContextHelper.getValue(attributeString, context); ! } catch (OgnlException oe) { ! ErrorManager.getDefault().notify(oe); } *************** *** 109,114 **** try { PropertyEditor editor = PropertyEditorManager.findEditor(attributeType); ! editor.setAsText(valueString); ! value = editor.getValue(); } catch (IllegalArgumentException iae) { // Perhaps its a constant? --- 108,118 ---- try { PropertyEditor editor = PropertyEditorManager.findEditor(attributeType); ! // TODO: Figure out why there are missing primitive property editors ! if (editor != null) { ! editor.setAsText(valueString); ! value = editor.getValue(); ! } else { ! value = null; ! } } catch (IllegalArgumentException iae) { // Perhaps its a constant? Index: DashboardLoader.java =================================================================== RCS file: /cvsroot/mc4j/mc4j/src/org/mc4j/console/dashboard/DashboardLoader.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** DashboardLoader.java 15 Jan 2005 03:51:07 -0000 1.8 --- DashboardLoader.java 12 Apr 2006 19:13:52 -0000 1.9 *************** *** 84,89 **** --- 84,115 ---- document); + String val = rootElement.getAttribute("standardHeader"); + if (val != null && Boolean.valueOf(val)) { + dashboard.setStandardHeader(true); + } + + val = rootElement.getAttribute("refreshControl"); + if (val != null && val.length() > 0) { + if (Character.isDigit(val.charAt(0))) { + int time = Integer.parseInt(val); + dashboard.setRefreshControl(true); + dashboard.setRefreshTime(time); + } else { + dashboard.setRefreshControl(Boolean.valueOf(val)); + } + } else { + dashboard.setRefreshControl(true); + } + + val = rootElement.getAttribute("autoRefresh"); + if (val != null && Boolean.valueOf(val)) { + dashboard.setAutoBeanRefresh(true); + } + + dashboard.setDescription(rootElement.getElementsByTagName("Description").item(0).getNodeValue()); + dashboard.putContext(Dashboard.CONTEXT_DASHBOARD_FILE, dashboardFile); + assignDashboardMatch(dashboard, rootElement); *************** *** 254,257 **** --- 280,301 ---- inputSource = new InputSource(inputStream); } + } else if ("http://mc4j.org/Dashboard_2_0.dtd".equals(systemId)) { + + InputStream inputStream = + getClass().getClassLoader().getResourceAsStream("dashboards/Dashboard_2_0.dtd"); + + if (inputStream != null) { + inputSource = new InputSource(inputStream); + } + + + } else { + String filePath = "dashboards" + systemId.substring(systemId.lastIndexOf("/")); + InputStream inputStream = + getClass().getClassLoader().getResourceAsStream(filePath); + + if (inputStream != null) { + inputSource = new InputSource(inputStream); + } } if (inputSource != null) { Index: DashboardFactory.java =================================================================== RCS file: /cvsroot/mc4j/mc4j/src/org/mc4j/console/dashboard/DashboardFactory.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** DashboardFactory.java 13 Oct 2004 04:59:37 -0000 1.15 --- DashboardFactory.java 12 Apr 2006 19:13:52 -0000 1.16 *************** *** 26,29 **** --- 26,30 ---- import org.mc4j.console.dashboard.components.ForEachPanelComponent; import org.mc4j.console.util.ExceptionUtility; + import org.mc4j.ems.connection.bean.EmsBean; import java.awt.Color; *************** *** 153,157 **** ! if (rootElement.getAttribute("version").equals("1.0")) { NodeList nodes = rootElement.getChildNodes(); --- 154,158 ---- ! if (true) { // maybe use this later rootElement.getAttribute("version").equals("1.0")) { NodeList nodes = rootElement.getChildNodes(); *************** *** 278,282 **** //loadAttributes(node, component, context); ! component.doLayout(); return component; --- 279,288 ---- //loadAttributes(node, component, context); ! ! // Delayed context setting (after children have been loaded ! if (component instanceof DashboardComponent) { ! ((DashboardComponent)component).setContext(context); ! } ! component.doLayout(); return component; *************** *** 288,297 **** Integer baseIndex = (Integer) context.get("index"); ! List beanList = forEachPanelComponent.getBeanList(); for (int i = 0; i < beanList.size(); i++) { ! MBeanNode mBeanNode = (MBeanNode) beanList.get(i); context.put("index", new Integer(i)); ! context.put(forEachPanelComponent.getIdKey(), mBeanNode); buildV1Content(element, context); --- 294,303 ---- Integer baseIndex = (Integer) context.get("index"); ! List<EmsBean> beanList = forEachPanelComponent.getBeanList(); for (int i = 0; i < beanList.size(); i++) { ! EmsBean emsBean = beanList.get(i); context.put("index", new Integer(i)); ! context.put(forEachPanelComponent.getIdKey(), emsBean); buildV1Content(element, context); --- NEW FILE: DashboardContainer.java --- /* * Copyright 2002-2005 Greg Hinkle * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.mc4j.console.dashboard; /** * This is the root container panel for dashboards. It is laoded into * * @author Greg Hinkle (gh...@us...), Dec 30, 2005 * @version $Revision: 1.2 $($Author: ghinkl $ / $Date: 2006/04/12 19:13:51 $) */ public class DashboardContainer { } Index: Dashboard.java =================================================================== RCS file: /cvsroot/mc4j/mc4j/src/org/mc4j/console/dashboard/Dashboard.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** Dashboard.java 5 Oct 2004 05:16:01 -0000 1.17 --- Dashboard.java 12 Apr 2006 19:13:52 -0000 1.18 *************** *** 17,25 **** package org.mc4j.console.dashboard; - import org.w3c.dom.Document; - - import org.mc4j.console.bean.MBeanNode; import org.mc4j.console.dashboard.match.DashboardMatch; import org.mc4j.console.dashboard.match.MatchExecutor; import java.util.HashMap; --- 17,24 ---- package org.mc4j.console.dashboard; import org.mc4j.console.dashboard.match.DashboardMatch; import org.mc4j.console.dashboard.match.MatchExecutor; + import org.mc4j.ems.connection.bean.EmsBean; + import org.w3c.dom.Document; import java.util.HashMap; *************** *** 28,35 **** /** * Represents a dashboard that can be invoked for an MBean or server. This is ! * not the dashboard itself, but the data representing a class of dashboard, ! * but not a specific instance. Instances of the dashboards themselves are * created by the DashboardFactory. * * @author Greg Hinkle (gh...@us...), September 2002 * @version $Revision$($Author$ / $Date$) --- 27,36 ---- /** * Represents a dashboard that can be invoked for an MBean or server. This is ! * not the dashboard view itself, but the data representing the xml information ! * in a dashboard XML document. Instances of the dashboards themselves are * created by the DashboardFactory. * + * + * * @author Greg Hinkle (gh...@us...), September 2002 * @version $Revision$($Author$ / $Date$) *************** *** 56,59 **** --- 57,65 ---- + private boolean standardHeader = false; + private boolean refreshControl = false; + private boolean autoBeanRefresh = false; + private int refreshTime = 5000; + public static final String CONTEXT_CONNECTION_NODE = "ConnectionNode"; public static final String CONTEXT_MBEAN_NODE = "MBeanNode"; *************** *** 65,68 **** --- 71,77 ---- public static final String CONTEXT_DASHBOARD_NAME = "DashboardName"; public static final String CONTEXT_DASHBOARD_DESCRIPTION = "DashboardDescription"; + public static final String CONTEXT_DASHBOARD_FILE = "DashboardFile"; + + public static final String CONTEXT_CONNECTION = "Connection"; public Dashboard( *************** *** 160,166 **** } ! public boolean matches(MBeanNode mBeanNode) { ! return MatchExecutor.getInstance().matchSingle(this, mBeanNode); } } --- 169,207 ---- } ! public boolean matches(EmsBean bean) { ! return MatchExecutor.getInstance().matchSingle(this, bean); ! } ! ! ! public boolean isStandardHeader() { ! return standardHeader; } + public void setStandardHeader(boolean standardHeader) { + this.standardHeader = standardHeader; + } + + public boolean isRefreshControl() { + return refreshControl; + } + + public void setRefreshControl(boolean refreshControl) { + this.refreshControl = refreshControl; + } + + public boolean isAutoBeanRefresh() { + return autoBeanRefresh; + } + + public void setAutoBeanRefresh(boolean autoBeanRefresh) { + this.autoBeanRefresh = autoBeanRefresh; + } + + public int getRefreshTime() { + return refreshTime; + } + + public void setRefreshTime(int refreshTime) { + this.refreshTime = refreshTime; + } } Index: DashboardTopComponent.java =================================================================== RCS file: /cvsroot/mc4j/mc4j/src/org/mc4j/console/dashboard/DashboardTopComponent.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** DashboardTopComponent.java 5 Oct 2004 05:16:01 -0000 1.15 --- DashboardTopComponent.java 12 Apr 2006 19:13:52 -0000 1.16 *************** *** 17,20 **** --- 17,22 ---- package org.mc4j.console.dashboard; + import org.mc4j.console.dashboard.components.ErrorComponent; + import org.mc4j.console.dashboard.components.RefreshControlComponent; import org.openide.util.actions.SystemAction; import org.openide.windows.TopComponent; *************** *** 26,41 **** - /** - * * @author Greg Hinkle (gh...@us...), September 2002 * @version $Revision$($Author$ / $Date$) */ public class DashboardTopComponent extends TopComponent implements DashboardComponent { ! public DashboardTopComponent() { // For serialization ! putClientProperty("PersistenceType","Never"); ! } --- 28,45 ---- /** * @author Greg Hinkle (gh...@us...), September 2002 * @version $Revision$($Author$ / $Date$) */ public class DashboardTopComponent extends TopComponent implements DashboardComponent { ! ! private Dashboard dashboard; ! private String name; ! private JScrollPane scrollPane; ! public DashboardTopComponent() { // For serialization ! putClientProperty("PersistenceType", "Never"); ! } *************** *** 45,80 **** ! // REMEMBER: You should have a public default constructor! ! // This is for externalization. If you have a nondefault ! // constructor for normal creation of the component, leave ! // in a default constructor that will put the component into ! // a consistent but unconfigured state, and make sure readExternal ! // initializes it properly. Or, be creative with writeReplace(). ! public DashboardTopComponent(JComponent component, String name) { ! setLayout(new BorderLayout()); - - add(component,BorderLayout.CENTER); ! //setCloseOperation(CLOSE_EACH); // or CLOSE_EACH ! // Display name of this window (not needed if you use the DataObject constructor): ! // GH: Can't do this outside the event thread anymore ! //setDisplayName(name); ! ! // You may set the icon, but often it is better to set the icon for an associated mode instead: ! // setIcon(Utilities.loadImage("org/mc4j/console/dashboard/DashboardHolderIcon.gif")); ! // Use the Component Inspector to set tool-tip text. This will be saved ! // automatically. Other JComponent properties you may need to save yuorself. ! // At any time you can affect the node selection: ! // setActivatedNodes(new Node[] {...}); ! // Don't ever persist... ! //putClientProperty("PersistenceType","Never"); ! // TODO GH: Get the refresh action connected } public int getPersistenceType() { return TopComponent.PERSISTENCE_NEVER; --- 49,143 ---- ! public DashboardTopComponent(Dashboard dashboard, String name) { ! this.dashboard = dashboard; ! this.name = name; ! ! // Don't ever persist... ! putClientProperty("PersistenceType", "Never"); ! ! // TODO GH: Get the refresh action connected ! init(); ! } ! ! JPanel header; ! ! private void init() { setLayout(new BorderLayout()); ! Map context = dashboard.getContextStarter(); ! DashboardFactory factory = new DashboardFactory(); ! JComponent component = null; ! try { ! component = factory.buildDashboard(dashboard, context); ! } catch (Exception e) { ! component = new ErrorComponent(e); ! } ! if (dashboard.isStandardHeader()) { ! header = new GradientPanel(); ! header.setLayout(new BorderLayout()); ! ! JLabel title = new JLabel(getTitle()) { ! public void paintComponent(Graphics g) { ! Graphics2D g2 = (Graphics2D)g; ! g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, ! RenderingHints.VALUE_ANTIALIAS_ON); ! super.paintComponent(g); ! } ! }; ! ! title.setBorder(javax.swing.BorderFactory.createEmptyBorder(0,6,0,0)); ! header.add(title, BorderLayout.CENTER); ! if (dashboard.isRefreshControl()) { ! RefreshControlComponent refresher = new RefreshControlComponent(); ! refresher.setContext(context); ! refresher.setRefreshDelay(dashboard.getRefreshTime()); ! header.add(refresher, BorderLayout.EAST); ! } ! add(header, BorderLayout.NORTH); ! } ! ! scrollPane = new JScrollPane(component); ! ! add(scrollPane, BorderLayout.CENTER); ! } ! ! public static class GradientPanel extends JPanel { ! public static final Color START = new Color(128, 172, 209); //119,175,208); // 188, 218, 231); ! public static final Color END = new Color(214, 218, 219); ! ! public void paintComponent(Graphics g) { ! super.paintComponent(g); ! // Cast to Graphics2D so we can set composite information. ! Graphics2D g2d = (Graphics2D) g; ! ! g2d.setPaint(new GradientPaint(0, 0, START /* Color.WHITE*/, getWidth()-64, 0, getBackground())); // END)); ! g2d.fill(getVisibleRect()); ! } } + public String getTitle() { + return + "<html><font size=\"+1\">" + + dashboard.getDisplayName() + + "</font><br>" + + dashboard.getDescription() + + "</html>"; + } + + + public void launch() { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + setDisplayName(dashboard.getDisplayName()); + open(); + requestActive(); + } + }); + } + public int getPersistenceType() { return TopComponent.PERSISTENCE_NEVER; *************** *** 88,92 **** - public void setContext(Map context) { //To change body of implemented methods use File | Settings | File Templates. --- 151,154 ---- *************** *** 106,110 **** if (container instanceof DashboardComponent) ! ((DashboardComponent)container).refresh(); } } --- 168,172 ---- if (container instanceof DashboardComponent) ! ((DashboardComponent) container).refresh(); } } *************** *** 113,117 **** private void closeChildren(Component comp) { if (comp instanceof Container) { ! Component[] children = ((Container)comp).getComponents(); for (int i = 0; i < children.length; i++) { Component child = children[i]; --- 175,179 ---- private void closeChildren(Component comp) { if (comp instanceof Container) { ! Component[] children = ((Container) comp).getComponents(); for (int i = 0; i < children.length; i++) { Component child = children[i]; *************** *** 120,125 **** } if (comp instanceof TopComponent) { ! ((TopComponent)comp).setCloseOperation(CLOSE_EACH); ! ((TopComponent)comp).close(); } } --- 182,187 ---- } if (comp instanceof TopComponent) { ! ((TopComponent) comp).setCloseOperation(CLOSE_EACH); ! ((TopComponent) comp).close(); } } *************** *** 130,136 **** } */ ! // MODES AND WORKSPACES - --- 192,197 ---- } */ ! // MODES AND WORKSPACES *************** *** 155,160 **** - - // Use this to discard the component after restarts (make it nonpersistent): private Object readResolve() throws ObjectStreamException { --- 216,219 ---- *************** *** 192,206 **** } */ ! /* ! // If you want UndoAction and RedoAction to be enabled on this component: ! public UndoRedo getUndoRedo() { ! return new MyUndoRedo(this); ! } ! */ ! // Printing, saving, compiling, etc.: use cookies on some appropriate node and // use this node as the node selection. ! } --- 251,285 ---- } */ ! /* ! // If you want UndoAction and RedoAction to be enabled on this component: ! public UndoRedo getUndoRedo() { ! return new MyUndoRedo(this); ! } ! */ ! // Printing, saving, compiling, etc.: use cookies on some appropriate node and // use this node as the node selection. ! ! ! public static class DashboardHeaderComponent extends JPanel { ! private Label label; ! private RefreshControlComponent refreshControl; ! ! public DashboardHeaderComponent() { ! setLayout(new BorderLayout()); ! } ! ! private void init() { ! setLayout(new BorderLayout()); ! ! setLayout(new java.awt.BorderLayout()); ! label = new Label("<html><font size=\"+1\">Garbage Collection</font><br>Information about the various garbage collectors for the VM, including space collected during the last execution.</html> "); ! add(label, java.awt.BorderLayout.CENTER); ! ! refreshControl = new RefreshControlComponent(); ! // add(jToggleButton1, java.awt.BorderLayout.EAST); ! } ! } } |