summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2016-09-06 16:46:26 -0400
committerBernard Normier <bernard@zeroc.com>2016-09-06 16:46:26 -0400
commit20d569fca80bcefdcbef14a5d226526ca0a092e0 (patch)
treee42f5653623df4980bb6e32c575a5eb766f557e4 /java
parentRevert "Do not create slice symbolic link" (diff)
downloadice-20d569fca80bcefdcbef14a5d226526ca0a092e0.tar.bz2
ice-20d569fca80bcefdcbef14a5d226526ca0a092e0.tar.xz
ice-20d569fca80bcefdcbef14a5d226526ca0a092e0.zip
Save location and size of LogFile and IceLog dialogs
Diffstat (limited to 'java')
-rw-r--r--java/src/IceGridGUI/src/main/java/IceGridGUI/Coordinator.java47
-rw-r--r--java/src/IceGridGUI/src/main/java/IceGridGUI/LiveDeployment/GraphView.java161
-rwxr-xr-xjava/src/IceGridGUI/src/main/java/IceGridGUI/LiveDeployment/ShowIceLogDialog.java184
-rw-r--r--java/src/IceGridGUI/src/main/java/IceGridGUI/LiveDeployment/ShowLogFileDialog.java12
-rw-r--r--java/src/IceGridGUI/src/main/java/IceGridGUI/Utils.java97
5 files changed, 264 insertions, 237 deletions
diff --git a/java/src/IceGridGUI/src/main/java/IceGridGUI/Coordinator.java b/java/src/IceGridGUI/src/main/java/IceGridGUI/Coordinator.java
index 5c0e854c4e9..7e00cdf45d1 100644
--- a/java/src/IceGridGUI/src/main/java/IceGridGUI/Coordinator.java
+++ b/java/src/IceGridGUI/src/main/java/IceGridGUI/Coordinator.java
@@ -3393,11 +3393,8 @@ public class Coordinator
void showMainFrame()
{
- if(!loadWindowPrefs())
- {
- _mainFrame.setLocation(100, 100);
- _mainFrame.pack();
- }
+ Utils.restoreWindowBounds(_mainFrame, _prefs, "Window", null);
+ _mainFrame.pack();
_mainFrame.setVisible(true);
}
@@ -3429,7 +3426,7 @@ public class Coordinator
}
}
- storeWindowPrefs();
+ Utils.storeWindowBounds(_mainFrame, _prefs.node("Window"));
_sessionKeeper.logout(true);
@@ -3462,44 +3459,6 @@ public class Coordinator
}
}
- private boolean loadWindowPrefs()
- {
- try
- {
- if(!_prefs.nodeExists("Window"))
- {
- return false;
- }
- }
- catch(BackingStoreException e)
- {
- return false;
- }
-
- Preferences windowPrefs = _prefs.node("Window");
- int x = windowPrefs.getInt("x", 0);
- int y = windowPrefs.getInt("y", 0);
- int width = windowPrefs.getInt("width", 0);
- int height = windowPrefs.getInt("height", 0);
- _mainFrame.setBounds(new Rectangle(x, y, width, height));
- if(windowPrefs.getBoolean("maximized", false))
- {
- _mainFrame.setExtendedState(Frame.MAXIMIZED_BOTH);
- }
- return true;
- }
-
- private void storeWindowPrefs()
- {
- Preferences windowPrefs = _prefs.node("Window");
- Rectangle rect = _mainFrame.getBounds();
- windowPrefs.putInt("x", rect.x);
- windowPrefs.putInt("y", rect.y);
- windowPrefs.putInt("width", rect.width);
- windowPrefs.putInt("height", rect.height);
- windowPrefs.putBoolean("maximized", _mainFrame.getExtendedState() == Frame.MAXIMIZED_BOTH);
- }
-
public AdminSessionPrx getSession()
{
return _sessionKeeper.getSession();
diff --git a/java/src/IceGridGUI/src/main/java/IceGridGUI/LiveDeployment/GraphView.java b/java/src/IceGridGUI/src/main/java/IceGridGUI/LiveDeployment/GraphView.java
index 0276ee8ce03..d57226b0995 100644
--- a/java/src/IceGridGUI/src/main/java/IceGridGUI/LiveDeployment/GraphView.java
+++ b/java/src/IceGridGUI/src/main/java/IceGridGUI/LiveDeployment/GraphView.java
@@ -155,7 +155,7 @@ public class GraphView extends JFrame implements MetricsFieldContext, Coordinato
class TransferHandler extends javax.swing.TransferHandler
{
@Override
- public boolean
+ public boolean
canImport(TransferHandler.TransferSupport support)
{
boolean supported = false;
@@ -180,7 +180,7 @@ public class GraphView extends JFrame implements MetricsFieldContext, Coordinato
}
Transferable t = support.getTransferable();
-
+
for(DataFlavor flavor : support.getDataFlavors())
{
try
@@ -219,7 +219,7 @@ public class GraphView extends JFrame implements MetricsFieldContext, Coordinato
addWindowListener(new WindowAdapter()
{
@Override
- public void windowClosing(WindowEvent e)
+ public void windowClosing(WindowEvent e)
{
close();
}
@@ -231,7 +231,7 @@ public class GraphView extends JFrame implements MetricsFieldContext, Coordinato
Action preferences = new AbstractAction("Preferences")
{
@Override
- public void actionPerformed(ActionEvent event)
+ public void actionPerformed(ActionEvent event)
{
//
// Set the title
@@ -248,13 +248,13 @@ public class GraphView extends JFrame implements MetricsFieldContext, Coordinato
//
// SpinnerNumberModel to set a refresh period.
//
- SpinnerNumberModel refreshPeriod = new SpinnerNumberModel(getRefreshPeriod(), _minRefreshPeriod,
+ SpinnerNumberModel refreshPeriod = new SpinnerNumberModel(getRefreshPeriod(), _minRefreshPeriod,
_maxRefreshPeriod, 1);
//
// SpinnerNumberModel to set the maximum number of samples to keep in X axis.
//
- final SpinnerNumberModel samples = new SpinnerNumberModel(_samples, _minSamples,
+ final SpinnerNumberModel samples = new SpinnerNumberModel(_samples, _minSamples,
_maxSamples, 1);
JPanel refreshPanel;
@@ -276,7 +276,7 @@ public class GraphView extends JFrame implements MetricsFieldContext, Coordinato
dateFormats.setSelectedItem(getDateFormat());
JPanel xAxisPanel;
{
- DefaultFormBuilder builder =
+ DefaultFormBuilder builder =
new DefaultFormBuilder(new FormLayout("pref,2dlu,pref:grow", "pref"));
builder.append("Samples displayed:", new JSpinner(samples));
builder.append("", new JLabel("<html><p>The number of samples displayed on a graph;" +
@@ -295,7 +295,7 @@ public class GraphView extends JFrame implements MetricsFieldContext, Coordinato
builder.nextLine();
builder.append(xAxisPanel);
- if(JOptionPane.showConfirmDialog(GraphView.this, builder.getPanel(), "Metrics Graph Preferences",
+ if(JOptionPane.showConfirmDialog(GraphView.this, builder.getPanel(), "Metrics Graph Preferences",
JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE) != JOptionPane.OK_OPTION)
{
return;
@@ -325,7 +325,7 @@ public class GraphView extends JFrame implements MetricsFieldContext, Coordinato
}
}
};
-
+
//
// Adjust row height for larger fonts
//
@@ -335,14 +335,14 @@ public class GraphView extends JFrame implements MetricsFieldContext, Coordinato
{
_legendTable.setRowHeight(minRowHeight);
}
-
+
//
// Graph preferences.
//
final Action delete = new AbstractAction("Delete")
{
@Override
- public void actionPerformed(ActionEvent event)
+ public void actionPerformed(ActionEvent event)
{
int[] selectedRows = _legendTable.getSelectedRows();
for(int i = 0; i < selectedRows.length; ++i)
@@ -486,7 +486,7 @@ public class GraphView extends JFrame implements MetricsFieldContext, Coordinato
//
_legendTable.setDefaultRenderer(Color.class, new ColorRenderer(true));
_legendTable.setDefaultEditor(Color.class, new ColorEditor());
-
+
_legendTable.setAutoCreateRowSorter(true);
final JFXPanel fxPanel = new JFXPanel();
@@ -502,7 +502,7 @@ public class GraphView extends JFrame implements MetricsFieldContext, Coordinato
scrollPane.setMinimumSize(new Dimension(0, 50));
scrollPane.setPreferredSize(new Dimension(800, 200));
_splitPane.setBottomComponent(scrollPane);
-
+
DefaultFormBuilder builder = new DefaultFormBuilder(new FormLayout("fill:pref:grow", "fill:pref:grow, pref"));
builder.append(_splitPane);
builder.nextLine();
@@ -566,7 +566,7 @@ public class GraphView extends JFrame implements MetricsFieldContext, Coordinato
if(object instanceof MetricsViewTransferableData)
{
addSeries((MetricsViewTransferableData)object);
- success = true;
+ success = true;
}
}
event.setDropCompleted(success);
@@ -580,16 +580,6 @@ public class GraphView extends JFrame implements MetricsFieldContext, Coordinato
pack();
if(!loadPreferences())
{
- Rectangle otherRect = _coordinator.getMainFrame().getBounds();
- Rectangle thisRect = getBounds();
- if(otherRect.width < thisRect.width || otherRect.height < thisRect.height)
- {
- setLocationRelativeTo(null);
- }
- else
- {
- setLocationRelativeTo(_coordinator.getMainFrame());
- }
_splitPane.setDividerLocation(400);
}
setVisible(true);
@@ -599,11 +589,11 @@ public class GraphView extends JFrame implements MetricsFieldContext, Coordinato
//
if(showInfo())
{
- JCheckBox checkbox = new JCheckBox("Do not show this message again.");
- String message = "Drop metrics cells to add them to the graph.";
+ JCheckBox checkbox = new JCheckBox("Do not show this message again.");
+ String message = "Drop metrics cells to add them to the graph.";
- JOptionPane.showConfirmDialog(this, new Object[]{message, checkbox}, "Information",
- JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE);
+ JOptionPane.showConfirmDialog(this, new Object[]{message, checkbox}, "Information",
+ JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE);
if(checkbox.isSelected())
{
_preferences.node("GraphView").putBoolean("showInfo", false);
@@ -627,10 +617,10 @@ public class GraphView extends JFrame implements MetricsFieldContext, Coordinato
return _preferences.node("GraphView").getBoolean("showInfo", true);
}
- public void storePreferences()
+ private void storePreferences()
{
Preferences preferences = _preferences.node("GraphView");
- Rectangle rect = getBounds();
+ Utils.storeWindowBounds(this, preferences);
for(int i = _columnNames.length -1; i >= 0; --i)
{
@@ -638,11 +628,6 @@ public class GraphView extends JFrame implements MetricsFieldContext, Coordinato
preferences.putInt("colWidth" + Integer.toString(i), _legendTable.getColumnModel().getColumn(i).getWidth());
}
- preferences.putInt("x", rect.x);
- preferences.putInt("y", rect.y);
- preferences.putInt("width", rect.width);
- preferences.putInt("height", rect.height);
- preferences.putBoolean("maximized", getExtendedState() == Frame.MAXIMIZED_BOTH);
preferences.putInt("splitLocation", _splitPane.getDividerLocation());
preferences.putInt("sampleInterval", getRefreshPeriod());
@@ -650,46 +635,29 @@ public class GraphView extends JFrame implements MetricsFieldContext, Coordinato
preferences.put("dateFormat", getDateFormat());
}
- public boolean loadPreferences()
+ private boolean loadPreferences()
{
- try
- {
- if(!_preferences.nodeExists("GraphView"))
- {
- return false;
- }
- }
- catch(BackingStoreException ex)
+ Preferences preferences = Utils.restoreWindowBounds(this, _preferences, "GraphView", _coordinator.getMainFrame());
+ if(preferences == null)
{
return false;
}
- Preferences preferences = _preferences.node("GraphView");
-
- int x = preferences.getInt("x", 0);
- int y = preferences.getInt("y", 0);
- int width = preferences.getInt("width", 0);
- int height = preferences.getInt("height", 0);
- setBounds(new Rectangle(x, y, width, height));
- if(preferences.getBoolean("maximized", false))
- {
- setExtendedState(Frame.MAXIMIZED_BOTH);
- }
- _splitPane.setDividerLocation(_preferences.node("GraphView").getInt("splitLocation", 600));
+ _splitPane.setDividerLocation(preferences.getInt("splitLocation", 600));
for(int i = _columnNames.length -1; i >= 0; --i)
{
int pos = _legendTable.convertColumnIndexToView(preferences.getInt("columnPos" + Integer.toString(i), i));
if(i != pos)
{
_legendTable.getColumnModel().moveColumn(pos, i);
- }
+ }
int columnWidth = preferences.getInt("colWidth" + Integer.toString(i), -1);
if(columnWidth != -1)
{
_legendTable.getColumnModel().getColumn(i).setPreferredWidth(columnWidth);
}
}
-
+
int refreshPeriod = preferences.getInt("refreshPeriod", _defaultRefreshPeriod);
if(refreshPeriod < _minRefreshPeriod)
{
@@ -766,7 +734,7 @@ public class GraphView extends JFrame implements MetricsFieldContext, Coordinato
if(columns.get(j.getField().getFieldName()) == null)
{
String color = DefaultColors[_chart.getData().size() % DefaultColors.length];
- final MetricsRow row = new MetricsRow(data.info, j, color,
+ final MetricsRow row = new MetricsRow(data.info, j, color,
new XYChart.Series<Number, Number>());
XYChart.Series<Number, Number> series = row.series.peek();
@@ -786,7 +754,7 @@ public class GraphView extends JFrame implements MetricsFieldContext, Coordinato
{
n.setOnMousePressed(new EventHandler<MouseEvent>()
{
- @Override public void
+ @Override public void
handle(MouseEvent e)
{
if(e.getEventType() == MouseEvent.MOUSE_PRESSED &&
@@ -823,7 +791,7 @@ public class GraphView extends JFrame implements MetricsFieldContext, Coordinato
_legendModel.addRow(row);
}
});
- }
+ }
}
}
if(_chart.getData().size() > 0)
@@ -836,7 +804,7 @@ public class GraphView extends JFrame implements MetricsFieldContext, Coordinato
//
// Added a new chart series to an existing row, the graph series will use the
- // same configuration, the row cell field must be reset so calculations doesn't
+ // same configuration, the row cell field must be reset so calculations doesn't
// take into account previous data. If we don't reset fields here caculations
// can be bogus in case the view was disabled and the data in the view was reset.
//
@@ -860,9 +828,9 @@ public class GraphView extends JFrame implements MetricsFieldContext, Coordinato
row.cell.resetField();
//
- // We need also a new click handler so click works in all segments
+ // We need also a new click handler so click works in all segments
// of the line.
- //
+ //
// When a line is clicked we select the correspoding row in the legend table.
//
javafx.scene.Node n = _chart.lookup(".chart-series-line." + styleClass);
@@ -870,7 +838,7 @@ public class GraphView extends JFrame implements MetricsFieldContext, Coordinato
{
n.setOnMousePressed(new EventHandler<MouseEvent>()
{
- @Override public void
+ @Override public void
handle(MouseEvent e)
{
if(e.getEventType() == MouseEvent.MOUSE_PRESSED &&
@@ -898,7 +866,7 @@ public class GraphView extends JFrame implements MetricsFieldContext, Coordinato
}
}
- private void addData(final MetricsViewInfo info, final Map<String, IceMX.Metrics[]> data,
+ private void addData(final MetricsViewInfo info, final Map<String, IceMX.Metrics[]> data,
final long timestamp)
{
//
@@ -997,7 +965,7 @@ public class GraphView extends JFrame implements MetricsFieldContext, Coordinato
}
//
- // Remove the vertices from the beginning of the series that exceeded
+ // Remove the vertices from the beginning of the series that exceeded
// the maximum number of samples.
//
adjustSize(row);
@@ -1013,8 +981,8 @@ public class GraphView extends JFrame implements MetricsFieldContext, Coordinato
public void run()
{
_legendModel.fireTableChanged(
- new TableModelEvent(_legendModel, 0, _legendModel.getRowCount() - 1,
- TableModelEvent.ALL_COLUMNS,
+ new TableModelEvent(_legendModel, 0, _legendModel.getRowCount() - 1,
+ TableModelEvent.ALL_COLUMNS,
TableModelEvent.UPDATE));
}
});
@@ -1391,7 +1359,7 @@ public class GraphView extends JFrame implements MetricsFieldContext, Coordinato
@Override
public boolean isCellEditable(int row, int col)
{
- if(col < _columnNames.length && (_columnNames[col].equals("Show") ||
+ if(col < _columnNames.length && (_columnNames[col].equals("Show") ||
_columnNames[col].equals("Scale") ||
_columnNames[col].equals("Color")))
{
@@ -1441,7 +1409,7 @@ public class GraphView extends JFrame implements MetricsFieldContext, Coordinato
// Convert color to the CSS representation used by JavaFX style.
// example: #ff00aa
//
- row.color = "#" + String.format("%02X", color.getRed()) +
+ row.color = "#" + String.format("%02X", color.getRed()) +
String.format("%02X", color.getGreen()) +
String.format("%02X", color.getBlue());
for(int i = 0; i < row.series.size(); ++i)
@@ -1616,7 +1584,7 @@ public class GraphView extends JFrame implements MetricsFieldContext, Coordinato
sb.append(color);
sb.append(", white;");
sb.append("-fx-stroke-width: 3;");
- _styles.put(seriesClass, sb.toString());
+ _styles.put(seriesClass, sb.toString());
}
private void enqueueJFX(final Runnable runnable) {
@@ -1671,14 +1639,14 @@ public class GraphView extends JFrame implements MetricsFieldContext, Coordinato
});
}
- @SuppressWarnings("rawtypes")
+ @SuppressWarnings("rawtypes")
static class DecimalRenderer extends DefaultListCellRenderer
- {
+ {
public DecimalRenderer(ListCellRenderer renderer)
{
this._renderer = renderer;
}
-
+
@Override
public Component
getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus)
@@ -1722,7 +1690,7 @@ public class GraphView extends JFrame implements MetricsFieldContext, Coordinato
}
_dialog = JColorChooser.createDialog(_button, "Select the metrics color", true, _colorChooser, this, null);
-
+
}
@Override
@@ -1768,13 +1736,13 @@ public class GraphView extends JFrame implements MetricsFieldContext, Coordinato
Border unselectedBorder = null;
Border selectedBorder = null;
boolean isBordered = true;
-
+
public ColorRenderer(boolean isBordered)
{
this.isBordered = isBordered;
setOpaque(true); //MUST do this for background to show up.
}
-
+
@Override
public Component getTableCellRendererComponent(JTable table, Object color, boolean isSelected, boolean hasFocus,
int row, int column)
@@ -1825,8 +1793,8 @@ public class GraphView extends JFrame implements MetricsFieldContext, Coordinato
private NumberAxis _xAxis;
private NumberAxis _yAxis;
- private final static String[] _columnNames = new String[]{"Show", "Node", "Server", "Metrics View Name",
- "Metrics Name", "Metrics Id", "Metrics Field", "Scale",
+ private final static String[] _columnNames = new String[]{"Show", "Node", "Server", "Metrics View Name",
+ "Metrics Name", "Metrics Id", "Metrics Field", "Scale",
"Last", "Average", "Minimum", "Maximum", "Color"};
@@ -1841,8 +1809,8 @@ public class GraphView extends JFrame implements MetricsFieldContext, Coordinato
// Field name
//
private final Map<MetricsViewInfo,
- Map<String,
- Map<String,
+ Map<String,
+ Map<String,
Map<String, MetricsRow>>>> _series =
new HashMap<MetricsViewInfo, Map<String, Map<String, Map<String, MetricsRow>>>>();
@@ -1872,27 +1840,27 @@ public class GraphView extends JFrame implements MetricsFieldContext, Coordinato
private final Map<String, String> _styles = new HashMap<String, String>();
- private final Double[] _scales = new Double[]{0.000000001d,
+ private final Double[] _scales = new Double[]{0.000000001d,
0.00000001d,
- 0.0000001d,
- 0.000001d,
+ 0.0000001d,
+ 0.000001d,
0.00001d,
- 0.0001d,
- 0.001d,
- 0.01d,
- 0.1d,
- 1.0d,
- 10.0d,
+ 0.0001d,
+ 0.001d,
+ 0.01d,
+ 0.1d,
+ 1.0d,
+ 10.0d,
100.0d,
1000.0d,
- 10000.0d,
- 100000.0d,
- 1000000.0d,
+ 10000.0d,
+ 100000.0d,
+ 1000000.0d,
10000000.0d,
100000000.0d,
1000000000.0d};
-
- private final java.util.concurrent.Semaphore _sem = new java.util.concurrent.Semaphore(0);
+
+ private final java.util.concurrent.Semaphore _sem = new java.util.concurrent.Semaphore(0);
private final java.util.concurrent.ExecutorService _queue = java.util.concurrent.Executors.newSingleThreadExecutor(
new java.util.concurrent.ThreadFactory()
{
@@ -1909,4 +1877,3 @@ public class GraphView extends JFrame implements MetricsFieldContext, Coordinato
private final static DataFormat LocalObjectMimeType = new DataFormat("application/x-java-jvm-local-objectref");
}
-
diff --git a/java/src/IceGridGUI/src/main/java/IceGridGUI/LiveDeployment/ShowIceLogDialog.java b/java/src/IceGridGUI/src/main/java/IceGridGUI/LiveDeployment/ShowIceLogDialog.java
index d94d0671b26..1b1e609edaf 100755
--- a/java/src/IceGridGUI/src/main/java/IceGridGUI/LiveDeployment/ShowIceLogDialog.java
+++ b/java/src/IceGridGUI/src/main/java/IceGridGUI/LiveDeployment/ShowIceLogDialog.java
@@ -15,6 +15,8 @@ import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
+import java.util.prefs.Preferences;
+
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.ButtonGroup;
@@ -108,7 +110,7 @@ class ShowIceLogDialog extends JDialog
try
{
os = new java.io.OutputStreamWriter(new java.io.FileOutputStream(file));
-
+
for(Object p : _tableModel.getDataVector())
{
@SuppressWarnings("unchecked")
@@ -117,7 +119,7 @@ class ShowIceLogDialog extends JDialog
renderLogMessageType((LogMessageType) row.elementAt(1)) + ",\"" +
row.elementAt(2).toString().replace("\"", "\"\"") + "\",\"" +
row.elementAt(3).toString().replace("\"", "\"\"") + "\"";
-
+
txt += "\r\n";
os.write(txt, 0, txt.length());
}
@@ -178,15 +180,15 @@ class ShowIceLogDialog extends JDialog
for(int i : _table.getSelectedRows())
{
int j = _table.convertRowIndexToModel(i);
-
+
txt += renderDate((java.util.Date)_tableModel.getValueAt(j, 0)) + "\t" +
renderLogMessageType((LogMessageType)_tableModel.getValueAt(j, 1)) + "\t" +
_tableModel.getValueAt(j, 2).toString() + "\t" +
renderMessage(_tableModel.getValueAt(j, 3).toString()) + "\n";
}
-
+
java.awt.datatransfer.StringSelection ss = new java.awt.datatransfer.StringSelection(txt);
-
+
java.awt.Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, null);
}
@@ -194,7 +196,7 @@ class ShowIceLogDialog extends JDialog
copy.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_C, MENU_MASK));
copy.putValue(Action.SHORT_DESCRIPTION, "Copy");
_table.getActionMap().put("copy", copy);
-
+
editMenu.add(copy);
editMenu.addSeparator();
@@ -260,26 +262,26 @@ class ShowIceLogDialog extends JDialog
bg.add(_stopButton);
}
}
-
- private class RemoteLoggerI extends Ice._RemoteLoggerDisp
+
+ private class RemoteLoggerI extends Ice._RemoteLoggerDisp
{
@Override
public synchronized void init(String prefix, LogMessage[] logMessages, Current current)
- {
+ {
// Ignore prefix
-
+
if(!_destroyed)
- {
+ {
_rowCount = logMessages.length + _queue.size() < _maxRows ? logMessages.length + _queue.size() : _maxRows;
final Object[][] data = new Object[_rowCount][];
-
+
int i = _rowCount - 1;
-
+
for(java.util.Iterator<LogMessage> p = _queue.descendingIterator(); p.hasNext() && i >= 0; i--)
{
data[i] = logMessageToRow(p.next());
}
-
+
int j = logMessages.length - 1;
while(i >= 0 && j >= 0)
{
@@ -287,10 +289,10 @@ class ShowIceLogDialog extends JDialog
i--;
j--;
}
-
+
_queue.clear();
_paused = false;
-
+
SwingUtilities.invokeLater(
new Runnable()
{
@@ -299,11 +301,11 @@ class ShowIceLogDialog extends JDialog
{
_tableModel.setDataVector(data, _columnNames);
_table.scrollRectToVisible(_table.getCellRect(_table.getRowCount() - 1, 0, true));
- _pause.setEnabled(true);
+ _pause.setEnabled(true);
}
});
}
-
+
}
@Override
@@ -327,40 +329,40 @@ class ShowIceLogDialog extends JDialog
showLogMessage(message);
}
}
-
+
private synchronized void setMaxRows(int maxRows)
{
_maxRows = maxRows;
-
+
final int rowsToRemove = _rowCount - _maxRows;
-
+
if(rowsToRemove > 0)
{
_rowCount -= rowsToRemove;
-
+
SwingUtilities.invokeLater(
new Runnable()
{
@Override
public void run()
{
-
+
int i = rowsToRemove;
while(i-- > 0)
{
_tableModel.removeRow(0);
}
- }
+ }
});
}
}
-
+
private synchronized void pause()
{
assert(!_destroyed);
_paused = true;
}
-
+
private synchronized void play()
{
assert(!_destroyed);
@@ -371,22 +373,22 @@ class ShowIceLogDialog extends JDialog
_queue.clear();
_paused = false;
}
-
+
private synchronized void stop()
{
_destroyed = true;
}
-
+
private void showLogMessage(LogMessage msg)
{
final Object[] row = logMessageToRow(msg);
_rowCount++;
- final int rowsToRemove = _rowCount - _maxRows;
+ final int rowsToRemove = _rowCount - _maxRows;
if(rowsToRemove > 0)
{
_rowCount -= rowsToRemove;
}
-
+
SwingUtilities.invokeLater(
new Runnable()
{
@@ -403,18 +405,18 @@ class ShowIceLogDialog extends JDialog
}
});
}
-
+
private boolean _paused = true;
private boolean _destroyed = false;
private final java.util.Deque<LogMessage> _queue = new java.util.ArrayDeque<LogMessage>();
private int _rowCount = 0;
private int _maxRows = _maxMessages;
}
-
- static private class DateRenderer extends DefaultTableCellRenderer
+
+ static private class DateRenderer extends DefaultTableCellRenderer
{
@Override
- public void setValue(Object value)
+ public void setValue(Object value)
{
if(value == null)
{
@@ -426,11 +428,11 @@ class ShowIceLogDialog extends JDialog
}
}
}
-
- static private class LogMessageTypeRenderer extends DefaultTableCellRenderer
+
+ static private class LogMessageTypeRenderer extends DefaultTableCellRenderer
{
@Override
- public void setValue(Object value)
+ public void setValue(Object value)
{
if(value == null)
{
@@ -442,11 +444,11 @@ class ShowIceLogDialog extends JDialog
}
}
}
-
- static private class MessageRenderer extends DefaultTableCellRenderer
+
+ static private class MessageRenderer extends DefaultTableCellRenderer
{
@Override
- public void setValue(Object value)
+ public void setValue(Object value)
{
if(value == null)
{
@@ -458,7 +460,7 @@ class ShowIceLogDialog extends JDialog
}
}
}
-
+
ShowIceLogDialog(TreeNode parent, String title, Ice.LoggerAdminPrx loggerAdmin, String defaultFileName, int maxMessages, int initialMessages)
{
super(parent.getRoot().getCoordinator().getMainFrame(), title + " - IceGrid Admin", false);
@@ -469,7 +471,8 @@ class ShowIceLogDialog extends JDialog
_defaultFileName = defaultFileName;
_maxMessages = maxMessages;
_initialMessages = initialMessages;
-
+ _preferences = Preferences.userNodeForPackage(getClass());
+
setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
addWindowListener(new java.awt.event.WindowAdapter()
{
@@ -506,24 +509,24 @@ class ShowIceLogDialog extends JDialog
stop();
}
};
-
-
+
+
_tableModel = new DefaultTableModel(_columnNames, 0)
{
@Override
public boolean isCellEditable(int row, int column)
{
return false;
- }
- };
-
+ }
+ };
+
_table = new JTable(_tableModel)
{
@Override
public java.awt.Component prepareRenderer(javax.swing.table.TableCellRenderer renderer, int row, int column)
{
java.awt.Component c = super.prepareRenderer(renderer, row, column);
-
+
if (!isRowSelected(row))
{
int modelRow = convertRowIndexToModel(row);
@@ -536,7 +539,7 @@ class ShowIceLogDialog extends JDialog
{
c.setBackground(Color.RED);
break;
- }
+ }
case WarningMessage:
{
c.setBackground(Color.ORANGE);
@@ -557,7 +560,7 @@ class ShowIceLogDialog extends JDialog
}
return c;
}
-
+
@Override
public String getToolTipText(java.awt.event.MouseEvent e)
{
@@ -565,9 +568,9 @@ class ShowIceLogDialog extends JDialog
java.awt.Point p = e.getPoint();
int row = rowAtPoint(p);
int col = columnAtPoint(p);
-
+
if(col == 3 && row >= 0) // Log message
- {
+ {
Object obj = getValueAt(row, col);
if(obj != null)
{
@@ -576,7 +579,7 @@ class ShowIceLogDialog extends JDialog
}
return tip;
}
-
+
};
_table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
@@ -603,7 +606,7 @@ class ShowIceLogDialog extends JDialog
{
_table.setRowHeight(minRowHeight);
}
-
+
_table.setRowSelectionAllowed(true);
_table.setOpaque(false);
_table.setPreferredScrollableViewportSize(new Dimension(800, 400));
@@ -611,22 +614,18 @@ class ShowIceLogDialog extends JDialog
setJMenuBar(new MenuBar());
getContentPane().add(new ToolBar(), BorderLayout.PAGE_START);
-
+
JScrollPane scrollPane = new JScrollPane(_table,
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
getContentPane().add(scrollPane);
- pack();
setResizable(true);
-
- setLocationRelativeTo(_parent.getRoot().getCoordinator().getMainFrame());
-
- _parent.getRoot().addShowIceLogDialog(_title, this);
-
+ pack();
+ Utils.restoreWindowBounds(this, _preferences, "IceLogDialog", _parent.getRoot().getCoordinator().getMainFrame());
setVisible(true);
-
+
play();
}
@@ -642,7 +641,7 @@ class ShowIceLogDialog extends JDialog
{
if(_remoteLogger == null)
{
- _tableModel.setRowCount(0);
+ _tableModel.setRowCount(0);
if(_messageTypeFilter != null || _traceCategoryFilter != null)
{
setTitle(_title + " (Filtered) - IceGrid Admin");
@@ -651,19 +650,19 @@ class ShowIceLogDialog extends JDialog
{
setTitle(_title + " (No filter) - IceGrid Admin");
}
-
+
_playItem.setSelected(true);
_playButton.setSelected(true);
_pause.setEnabled(false); // Init will enable Pause
-
+
String id = _loggerAdmin.ice_getIdentity().name + "-" + java.util.UUID.randomUUID().toString();
_remoteLogger = new RemoteLoggerI();
_remoteLoggerPrx = RemoteLoggerPrxHelper.uncheckedCast(_parent.getRoot().getCoordinator().addCallback(_remoteLogger, id, ""));
-
+
final String prefix = "Attaching remote logger to " + _loggerAdmin.ice_getIdentity().name + "...";
final String errorTitle = "Failed to attach remote logger to " + _loggerAdmin.ice_getIdentity().name;
_parent.getRoot().getCoordinator().getStatusBar().setText(prefix);
-
+
Ice.Callback_LoggerAdmin_attachRemoteLogger cb = new Ice.Callback_LoggerAdmin_attachRemoteLogger()
{
@Override
@@ -700,7 +699,7 @@ class ShowIceLogDialog extends JDialog
});
}
};
-
+
try
{
_loggerAdmin.begin_attachRemoteLogger(_remoteLoggerPrx, _messageTypeFilter, _traceCategoryFilter, _initialMessages, cb);
@@ -714,10 +713,10 @@ class ShowIceLogDialog extends JDialog
else
{
_remoteLogger.play();
- _pause.setEnabled(true);
+ _pause.setEnabled(true);
}
}
-
+
private void stop(boolean detach)
{
if(_remoteLogger != null)
@@ -726,7 +725,7 @@ class ShowIceLogDialog extends JDialog
{
final String prefix = "Detaching remote logger from " + _loggerAdmin.ice_getIdentity().name + "...";
_parent.getRoot().getCoordinator().getStatusBar().setText(prefix);
-
+
Ice.Callback_LoggerAdmin_detachRemoteLogger cb = new Ice.Callback_LoggerAdmin_detachRemoteLogger()
{
@Override
@@ -748,7 +747,7 @@ class ShowIceLogDialog extends JDialog
_parent.getRoot().amiSuccess(prefix, ex.ice_name());
}
};
-
+
try
{
_loggerAdmin.begin_detachRemoteLogger(_remoteLoggerPrx, cb);
@@ -800,25 +799,25 @@ class ShowIceLogDialog extends JDialog
{
_remoteLogger.setMaxRows(_maxMessages);
}
-
+
_parent.getRoot().setLogPrefs(_maxMessages, _initialMessages);
}
-
+
LogMessageType[] getMessageTypeFilter()
{
return _messageTypeFilter;
}
-
+
String[] getTraceCategoryFilter()
{
return _traceCategoryFilter;
}
-
+
void setFilters(LogMessageType[] messageTypeFilter, String[] traceCategoryFilter)
{
_messageTypeFilter = messageTypeFilter;
_traceCategoryFilter = traceCategoryFilter;
-
+
if(_remoteLogger != null)
{
stop();
@@ -845,36 +844,39 @@ class ShowIceLogDialog extends JDialog
{
_parent.getRoot().removeShowIceLogDialog(_title);
}
+
+ Utils.storeWindowBounds(this, _preferences.node("IceLogDialog"));
+
dispose();
}
-
+
private Object[] logMessageToRow(LogMessage msg)
{
Object[] row = new Object[4];
-
+
row[0] = new java.util.Date(msg.timestamp / 1000);
row[1] = msg.type;
row[2] = msg.traceCategory;
row[3] = msg.message;
-
+
return row;
}
-
+
private final TreeNode _parent;
private final Ice.LoggerAdminPrx _loggerAdmin;
private final String _title;
private final String _defaultFileName;
-
+
private RemoteLoggerI _remoteLogger;
private Ice.RemoteLoggerPrx _remoteLoggerPrx;
-
+
private int _maxMessages;
private int _initialMessages;
-
+
private LogMessageType[] _messageTypeFilter;
private String[] _traceCategoryFilter;
-
+
private Action _play;
private Action _pause;
private Action _stop;
@@ -890,12 +892,15 @@ class ShowIceLogDialog extends JDialog
private final Object[] _columnNames = new Object[]{"Timestamp", "Type", "Trace Category", "Log Message"};
private final DefaultTableModel _tableModel;
private final JTable _table;
-
+
+ private final Preferences _preferences;
+
+
private static String renderDate(java.util.Date date)
{
return _dateFormat.format(date) + _timeFormat.format(date);
}
-
+
private static String renderLogMessageType(LogMessageType type)
{
// Remove "Message" from end of string.
@@ -903,13 +908,12 @@ class ShowIceLogDialog extends JDialog
assert(s.length() > 7);
return s.substring(0, s.length() - 7);
}
-
+
private static String renderMessage(String msg)
{
return msg.replace("\n", " ");
}
-
+
private static final java.text.DateFormat _dateFormat = java.text.DateFormat.getDateInstance(java.text.DateFormat.SHORT);
private static final java.text.DateFormat _timeFormat = new java.text.SimpleDateFormat(" HH:mm:ss:SSS");
}
-
diff --git a/java/src/IceGridGUI/src/main/java/IceGridGUI/LiveDeployment/ShowLogFileDialog.java b/java/src/IceGridGUI/src/main/java/IceGridGUI/LiveDeployment/ShowLogFileDialog.java
index 574c972fbdf..ce9fd144d27 100644
--- a/java/src/IceGridGUI/src/main/java/IceGridGUI/LiveDeployment/ShowLogFileDialog.java
+++ b/java/src/IceGridGUI/src/main/java/IceGridGUI/LiveDeployment/ShowLogFileDialog.java
@@ -13,6 +13,8 @@ import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
+import java.util.prefs.Preferences;
+
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.ButtonGroup;
@@ -565,6 +567,7 @@ class ShowLogFileDialog extends JDialog
_period = period;
_factory = factory;
_root = root;
+ _preferences = Preferences.userNodeForPackage(getClass());
setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
addWindowListener(new java.awt.event.WindowAdapter()
@@ -612,10 +615,10 @@ class ShowLogFileDialog extends JDialog
getContentPane().add(scrollPane);
- pack();
setResizable(true);
+ pack();
+ Utils.restoreWindowBounds(this, _preferences, "LogFileDialog", _root.getCoordinator().getMainFrame());
- setLocationRelativeTo(root.getCoordinator().getMainFrame());
play();
}
@@ -740,6 +743,9 @@ class ShowLogFileDialog extends JDialog
{
_root.removeShowLogFileDialog(_factory.getTitle());
}
+
+ Utils.storeWindowBounds(this, _preferences.node("LogFileDialog"));
+
dispose();
}
@@ -766,4 +772,6 @@ class ShowLogFileDialog extends JDialog
private FIFOTextArea _textArea = new FIFOTextArea(20, 45);
private ReaderThread _thread;
+
+ private final Preferences _preferences;
}
diff --git a/java/src/IceGridGUI/src/main/java/IceGridGUI/Utils.java b/java/src/IceGridGUI/src/main/java/IceGridGUI/Utils.java
index 9ae439c5d52..f2e9418905e 100644
--- a/java/src/IceGridGUI/src/main/java/IceGridGUI/Utils.java
+++ b/java/src/IceGridGUI/src/main/java/IceGridGUI/Utils.java
@@ -11,7 +11,10 @@ package IceGridGUI;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.awt.Graphics2D;
+import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
+import java.awt.Rectangle;
+
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
@@ -50,8 +53,8 @@ public class Utils
try
{
BufferedImage image = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().
- getDefaultConfiguration().createCompatibleImage(
- icon.getIconWidth(), icon.getIconHeight());
+ getDefaultConfiguration().createCompatibleImage(
+ icon.getIconWidth(), icon.getIconHeight());
g = image.createGraphics();
icon.paintIcon(null, g, 0, 0);
return image;
@@ -66,7 +69,7 @@ public class Utils
}
}
- public static void addEscapeListener(final JDialog dialog)
+ static public void addEscapeListener(final JDialog dialog)
{
dialog.getRootPane().registerKeyboardAction(
new ActionListener()
@@ -131,6 +134,93 @@ public class Utils
return result;
}
+ static public void
+ storeWindowBounds(java.awt.Window window, java.util.prefs.Preferences prefs)
+ {
+ Rectangle rect = window.getBounds();
+ prefs.putInt("x", rect.x);
+ prefs.putInt("y", rect.y);
+ prefs.putInt("width", rect.width);
+ prefs.putInt("height", rect.height);
+
+ if(window instanceof java.awt.Frame)
+ {
+ prefs.putBoolean("maximized", ((java.awt.Frame)window).getExtendedState() == java.awt.Frame.MAXIMIZED_BOTH);
+ }
+ }
+
+ static public java.util.prefs.Preferences
+ restoreWindowBounds(java.awt.Window window, java.util.prefs.Preferences parent, String node, java.awt.Component parentComponent)
+ {
+ java.util.prefs.Preferences prefs = null;
+
+ try
+ {
+ if(parent.nodeExists(node))
+ {
+ prefs = parent.node(node);
+ }
+ }
+ catch(java.util.prefs.BackingStoreException ex)
+ {
+ }
+
+ boolean locationVisible = false;
+
+ if(prefs != null)
+ {
+ int x = prefs.getInt("x", 0);
+ int y = prefs.getInt("y", 0);
+ int width = prefs.getInt("width", 0);
+ int height = prefs.getInt("height", 0);
+
+ Rectangle visibleBounds = new Rectangle();
+ GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
+ GraphicsDevice screens[] = ge.getScreenDevices();
+ for(GraphicsDevice s : screens)
+ {
+ visibleBounds.add(s.getDefaultConfiguration().getBounds());
+ }
+ locationVisible = visibleBounds.contains(x, y);
+
+ if(locationVisible)
+ {
+ window.setBounds(new Rectangle(x, y, width, height));
+ if(prefs.getBoolean("maximized", false))
+ {
+ ((java.awt.Frame)window).setExtendedState(java.awt.Frame.MAXIMIZED_BOTH);
+ }
+ }
+ else
+ {
+ window.setSize(width, height);
+ }
+ }
+
+ if(!locationVisible)
+ {
+ if(parentComponent != null)
+ {
+ java.awt.Dimension parentSize = parentComponent.getSize();
+ java.awt.Dimension thisSize = window.getSize();
+ if(parentSize.width < thisSize.width || parentSize.height < thisSize.height)
+ {
+ window.setLocationRelativeTo(null);
+ }
+ else
+ {
+ window.setLocationRelativeTo(parentComponent);
+ }
+ }
+ else
+ {
+ window.setLocation(100, 100);
+ }
+ }
+
+ return prefs;
+ }
+
static public interface Stringifier
{
public String toString(Object obj);
@@ -537,4 +627,3 @@ public class Utils
}
}
}
-