diff options
author | Jiri Vanek <[email protected]> | 2014-01-06 10:51:06 +0100 |
---|---|---|
committer | Jiri Vanek <[email protected]> | 2014-01-06 10:51:06 +0100 |
commit | f9288c313418e0684e955b152ed14b2a92e3fc95 (patch) | |
tree | 919c0e7af267d8162ff7e94b7996745c341ef7a3 /netx | |
parent | 3261e3454f94f66082d97c2ba8a10cbe603dcc01 (diff) |
Copy all button in console controls sorts by date by default.
Diffstat (limited to 'netx')
-rw-r--r-- | netx/net/sourceforge/jnlp/util/logging/ConsoleOutputPane.java | 23 | ||||
-rw-r--r-- | netx/net/sourceforge/jnlp/util/logging/ConsoleOutputPaneModel.java | 16 |
2 files changed, 29 insertions, 10 deletions
diff --git a/netx/net/sourceforge/jnlp/util/logging/ConsoleOutputPane.java b/netx/net/sourceforge/jnlp/util/logging/ConsoleOutputPane.java index fe55d8e..52daba9 100644 --- a/netx/net/sourceforge/jnlp/util/logging/ConsoleOutputPane.java +++ b/netx/net/sourceforge/jnlp/util/logging/ConsoleOutputPane.java @@ -242,6 +242,7 @@ public class ConsoleOutputPane extends javax.swing.JPanel implements Observer { jPanel2 = new javax.swing.JPanel(); showHeaders = new javax.swing.JCheckBox(); showUser = new javax.swing.JCheckBox(); + sortCopyAll = new javax.swing.JCheckBox(); showOrigin = new javax.swing.JCheckBox(); showLevel = new javax.swing.JCheckBox(); showDate = new javax.swing.JCheckBox(); @@ -286,6 +287,10 @@ public class ConsoleOutputPane extends javax.swing.JPanel implements Observer { jEditorPane1 = new javax.swing.JTextPane(); showHide = new javax.swing.JButton(); + sortCopyAll.setSelected(true); + sortCopyAll.setText("sort copy all by date"); + sortCopyAll.setToolTipText("The sort by date is a bit more time consuming, but most natural for posting purposes"); + showHeaders.setSelected(true); showHeaders.setText("Show headers:"); showHeaders.addActionListener(getDefaultActionSingleton()); @@ -487,6 +492,7 @@ public class ConsoleOutputPane extends javax.swing.JPanel implements Observer { addComponent(next).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 15, Short.MAX_VALUE). addComponent(wordWrap).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED). addComponent(highLight).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED). + addComponent(sortCopyAll).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED). addComponent(copyRich).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED). addComponent(copyPlain)).addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel2Layout.createSequentialGroup(). addComponent(searchLabel).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED). @@ -568,6 +574,7 @@ public class ConsoleOutputPane extends javax.swing.JPanel implements Observer { jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING). addComponent(previous). addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE). + addComponent(sortCopyAll). addComponent(copyPlain). addComponent(copyRich). addComponent(highLight). @@ -782,13 +789,20 @@ public class ConsoleOutputPane extends javax.swing.JPanel implements Observer { } private void copyPlainActionPerformed(java.awt.event.ActionEvent evt) { - StringSelection stringSelection = new StringSelection(model.importList(false, 0)); - Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard(); - clpbrd.setContents(stringSelection, null); + fillClipBoard(false, sortCopyAll.isSelected()); } private void copyRichActionPerformed(java.awt.event.ActionEvent evt) { - StringSelection stringSelection = new StringSelection(model.importList(true, 0)); + fillClipBoard(true, sortCopyAll.isSelected()); + } + + private void fillClipBoard(boolean mark, boolean forceSort){ + StringSelection stringSelection ; + if (forceSort){ + stringSelection = new StringSelection(model.importList(mark, 0, 4/*date*/)); + } else { + stringSelection = new StringSelection(model.importList(mark, 0)); + } Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard(); clpbrd.setContents(stringSelection, null); } @@ -879,6 +893,7 @@ public class ConsoleOutputPane extends javax.swing.JPanel implements Observer { private javax.swing.JCheckBox showThread1; private javax.swing.JCheckBox showThread2; private javax.swing.JCheckBox showUser; + private javax.swing.JCheckBox sortCopyAll; private javax.swing.JComboBox sortBy; private javax.swing.JLabel sortByLabel; private javax.swing.JLabel statistics; diff --git a/netx/net/sourceforge/jnlp/util/logging/ConsoleOutputPaneModel.java b/netx/net/sourceforge/jnlp/util/logging/ConsoleOutputPaneModel.java index 79b132b..912d220 100644 --- a/netx/net/sourceforge/jnlp/util/logging/ConsoleOutputPaneModel.java +++ b/netx/net/sourceforge/jnlp/util/logging/ConsoleOutputPaneModel.java @@ -125,8 +125,12 @@ public class ConsoleOutputPaneModel { String importList(int start) { return importList(highLight, start); } - + String importList(boolean mark, int start) { + return importList(mark, start, sortBy); + } + + String importList(boolean mark, int start, int sortByLocal) { int added = start; StringBuilder sb = new StringBuilder(); if (mark) { @@ -139,9 +143,9 @@ public class ConsoleOutputPaneModel { List<MessageWithHeader> sortedList; if (start == 0) { - sortedList = preSort(dataProvider.getData()); + sortedList = preSort(dataProvider.getData(), sortByLocal); } else { - sortedList = preSort(Collections.synchronizedList(dataProvider.getData().subList(start, dataProvider.getData().size()))); + sortedList = preSort(Collections.synchronizedList(dataProvider.getData().subList(start, dataProvider.getData().size())), sortByLocal); } lastUpdateIndex = dataProvider.getData().size(); @@ -226,9 +230,9 @@ public class ConsoleOutputPaneModel { return sb.toString(); } - List<MessageWithHeader> preSort(List<MessageWithHeader> data) { + List<MessageWithHeader> preSort(List<MessageWithHeader> data, int sortByLocal) { List<MessageWithHeader> sortedData; - if (sortBy == 0) { + if (sortByLocal == 0) { if (revertSort) { sortedData = Collections.synchronizedList(new ArrayList<MessageWithHeader>(data)); Collections.reverse(sortedData); @@ -237,7 +241,7 @@ public class ConsoleOutputPaneModel { } } else { sortedData = Collections.synchronizedList(new ArrayList<MessageWithHeader>(data)); - switch (sortBy) { + switch (sortByLocal) { case 1: Collections.sort(sortedData, new CatchedMessageWithHeaderComparator() { @Override |