Mercurial > hg > release > thermostat-1.4
changeset 820:4d052647a64a
PR1067: Overview tabs should have scroll bars (if need be)
Add JScrollPanes with appropriate scrolling policies to allow
scrolling when there is too much information to be displayed in the
area available.
Change ValueField to stop forcing JScollPanes to scroll to the
ValueField with focus.
Reviewed-by: rkennke
Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2012-December/004416.html
author | Omair Majid <omajid@redhat.com> |
---|---|
date | Thu, 06 Dec 2012 18:30:10 -0500 |
parents | c563aedf9710 |
children | 2fedc9d961a0 |
files | client/swing/src/main/java/com/redhat/thermostat/client/swing/components/ValueField.java client/swing/src/main/java/com/redhat/thermostat/client/swing/views/HostInformationPanel.java host-overview/client-swing/src/main/java/com/redhat/thermostat/host/overview/client/swing/HostOverviewPanel.java vm-overview/client-swing/src/main/java/com/redhat/thermostat/vm/overview/client/swing/VmOverviewPanel.java |
diffstat | 4 files changed, 30 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/components/ValueField.java Wed Dec 05 18:16:16 2012 -0500 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/components/ValueField.java Thu Dec 06 18:30:10 2012 -0500 @@ -38,6 +38,7 @@ import javax.swing.JEditorPane; import javax.swing.UIManager; +import javax.swing.text.DefaultCaret; /** * A custom swing component meant for showing values. Use it like you would use @@ -54,6 +55,17 @@ setForeground(UIManager.getColor("Label.foreground")); setFont(UIManager.getFont("Label.font")); setEditable(false); + + /* + * The default caret update policy forces any scroll pane this + * component is added to to scroll so that this component is visible. + * Normally, the caret is placed in the last instance of this + * component created which is normally at the bottom of a scroll pane. + * This forces the scroll pane to scroll to the bottom, unexpectedly. + * This field is not meant to be editable in the first place so this + * behaviour makes no sense; turn off the scroll updates. + */ + ((DefaultCaret) getCaret()).setUpdatePolicy(DefaultCaret.NEVER_UPDATE); } }
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/views/HostInformationPanel.java Wed Dec 05 18:16:16 2012 -0500 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/views/HostInformationPanel.java Thu Dec 06 18:30:10 2012 -0500 @@ -43,7 +43,6 @@ import javax.swing.JTabbedPane; import javax.swing.SwingUtilities; -import com.redhat.thermostat.client.core.views.BasicView; import com.redhat.thermostat.client.core.views.HostInformationView; import com.redhat.thermostat.client.core.views.UIComponent; import com.redhat.thermostat.client.swing.SwingComponent;
--- a/host-overview/client-swing/src/main/java/com/redhat/thermostat/host/overview/client/swing/HostOverviewPanel.java Wed Dec 05 18:16:16 2012 -0500 +++ b/host-overview/client-swing/src/main/java/com/redhat/thermostat/host/overview/client/swing/HostOverviewPanel.java Thu Dec 06 18:30:10 2012 -0500 @@ -42,6 +42,7 @@ import javax.swing.GroupLayout; import javax.swing.GroupLayout.Alignment; import javax.swing.JPanel; +import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.LayoutStyle.ComponentPlacement; import javax.swing.SwingUtilities; @@ -63,6 +64,7 @@ private static final Translate<LocaleResources> translator = LocaleResources.createLocalizer(); private JPanel visiblePanel; + private JScrollPane scrollPane; private final ValueField hostname = new ValueField("${hostname}"); private final ValueField cpuModel = new ValueField("${cpu-model}"); @@ -202,7 +204,7 @@ @Override public Component getUiComponent() { - return visiblePanel; + return scrollPane; } private void initializePanel() { @@ -304,6 +306,9 @@ panel.add(networkTable); JTableHeader header = networkTable.getTableHeader(); panel.add(header, BorderLayout.PAGE_START); + visiblePanel.setLayout(gl_visiblePanel); + + scrollPane = new JScrollPane(visiblePanel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); } }
--- a/vm-overview/client-swing/src/main/java/com/redhat/thermostat/vm/overview/client/swing/VmOverviewPanel.java Wed Dec 05 18:16:16 2012 -0500 +++ b/vm-overview/client-swing/src/main/java/com/redhat/thermostat/vm/overview/client/swing/VmOverviewPanel.java Thu Dec 06 18:30:10 2012 -0500 @@ -37,10 +37,16 @@ package com.redhat.thermostat.vm.overview.client.swing; import java.awt.Component; +import java.awt.Point; +import java.awt.Rectangle; import java.util.ArrayList; import java.util.List; import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.SwingUtilities; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; import com.redhat.thermostat.client.swing.SwingComponent; import com.redhat.thermostat.client.swing.components.Components; @@ -58,6 +64,7 @@ private static final Translate<LocaleResources> translator = LocaleResources.createLocalizer(); private HeaderPanel visiblePanel; + private JScrollPane container; private final ChangeableText pid = new ChangeableText(""); private final ChangeableText startTimeStamp = new ChangeableText(""); @@ -69,6 +76,7 @@ private final ChangeableText vmNameAndVersion = new ChangeableText(""); private final ChangeableText vmArguments = new ChangeableText(""); + public VmOverviewPanel() { super(); initializePanel(); @@ -181,6 +189,9 @@ SimpleTable simpleTable = new SimpleTable(); JPanel table = simpleTable.createTable(allSections); table.setBorder(Components.smallBorder()); - visiblePanel.setContent(table); + + container = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); + + visiblePanel.setContent(container); } }