|
25 | 25 |
|
26 | 26 | package com.oracle.coherence.plugin.visualvm.panel;
|
27 | 27 |
|
28 |
| -import com.oracle.coherence.plugin.visualvm.GlobalPreferences; |
29 | 28 | import com.oracle.coherence.plugin.visualvm.Localization;
|
30 | 29 | import com.oracle.coherence.plugin.visualvm.helper.DialogHelper;
|
31 | 30 | import com.oracle.coherence.plugin.visualvm.helper.GraphHelper;
|
32 | 31 | import com.oracle.coherence.plugin.visualvm.helper.HttpRequestSender;
|
33 | 32 | import com.oracle.coherence.plugin.visualvm.helper.RenderHelper;
|
34 | 33 | import com.oracle.coherence.plugin.visualvm.helper.RequestSender;
|
35 | 34 | import com.oracle.coherence.plugin.visualvm.panel.util.MenuOption;
|
| 35 | +import com.oracle.coherence.plugin.visualvm.panel.util.SeparatorMenuOption; |
36 | 36 | import com.oracle.coherence.plugin.visualvm.tablemodel.CacheDetailTableModel;
|
37 | 37 | import com.oracle.coherence.plugin.visualvm.tablemodel.CacheStorageManagerTableModel;
|
38 | 38 | import com.oracle.coherence.plugin.visualvm.tablemodel.CacheTableModel;
|
@@ -206,16 +206,14 @@ public CoherenceCachePanel(VisualVMModel model)
|
206 | 206 | table.setIntercellSpacing(new Dimension(6, 3));
|
207 | 207 | table.setRowHeight(table.getRowHeight() + 4);
|
208 | 208 |
|
209 |
| - // experimental heat map |
210 |
| - if (GlobalPreferences.sharedInstance().isHeatMapEnabled()) |
211 |
| - { |
212 |
| - table.setMenuOptions( |
213 |
| - new MenuOption[]{new ShowHeatMapMenuOption(model, m_requestSender, |
214 |
| - table, |
215 |
| - ShowHeatMapMenuOption.TYPE_SIZE), |
216 |
| - new ShowHeatMapMenuOption(model, m_requestSender, table, |
217 |
| - ShowHeatMapMenuOption.TYPE_MEMORY)}); |
218 |
| - } |
| 209 | + table.setMenuOptions( |
| 210 | + new MenuOption[]{ |
| 211 | + new ShowHeatMapMenuOption(model, m_requestSender, table, ShowHeatMapMenuOption.TYPE_SIZE), |
| 212 | + new ShowHeatMapMenuOption(model, m_requestSender, table, ShowHeatMapMenuOption.TYPE_MEMORY), |
| 213 | + new SeparatorMenuOption(model, m_requestSender, table), |
| 214 | + new InvokeCacheOperationMenuOpen(model, m_requestSender, table, TRUNCATE), |
| 215 | + new InvokeCacheOperationMenuOpen(model, m_requestSender, table, CLEAR) |
| 216 | + }); |
219 | 217 |
|
220 | 218 | setTablePadding(f_tableDetail);
|
221 | 219 | f_tableDetail.setMenuOptions(new MenuOption[] {new ShowDetailMenuOption(model, f_tableDetail, SELECTED_CACHE)});
|
@@ -673,14 +671,69 @@ public void actionPerformed(ActionEvent e)
|
673 | 671 | * Menu option description.
|
674 | 672 | */
|
675 | 673 | private final String f_sMenuItem;
|
| 674 | + } |
| 675 | + |
| 676 | + /** |
| 677 | + * Menu option to invoke clear or truncate against a cache. Only available in most recent versions of Coherence. |
| 678 | + */ |
| 679 | + protected class InvokeCacheOperationMenuOpen |
| 680 | + extends AbstractMenuOption |
| 681 | + { |
| 682 | + // ----- constructors ----------------------------------------------- |
| 683 | + |
| 684 | + public InvokeCacheOperationMenuOpen(VisualVMModel model, RequestSender requestSender, |
| 685 | + ExportableJTable jtable, String sOperation) |
| 686 | + { |
| 687 | + super(model, requestSender, jtable); |
| 688 | + f_sOperation = sOperation; |
| 689 | + } |
| 690 | + |
| 691 | + @Override |
| 692 | + public String getMenuItem() |
| 693 | + { |
| 694 | + return getLocalizedText(f_sOperation.equals(TRUNCATE) ? "LBL_truncate" : "LBL_clear"); |
| 695 | + } |
| 696 | + |
| 697 | + @Override |
| 698 | + public void actionPerformed(ActionEvent e) |
| 699 | + { |
| 700 | + int nRow = getSelectedRow(); |
676 | 701 |
|
| 702 | + if (nRow == -1) |
| 703 | + { |
| 704 | + DialogHelper.showInfoDialog(Localization.getLocalText("LBL_must_select_row")); |
| 705 | + } |
| 706 | + else |
| 707 | + { |
| 708 | + Pair<String, String> selectedCache = f_model.getSelectedCache(); |
| 709 | + String sQuestion = Localization.getLocalText("LBL_confirm_cache_operation", f_sOperation, selectedCache.toString()); |
677 | 710 |
|
| 711 | + if (!DialogHelper.showConfirmDialog(sQuestion)) |
| 712 | + { |
| 713 | + return; |
| 714 | + } |
| 715 | + try |
| 716 | + { |
| 717 | + m_requestSender.invokeStorageManagerOperation(selectedCache.getX(), selectedCache.getY(), f_sOperation); |
| 718 | + showMessageDialog(Localization.getLocalText("LBL_result"), Localization.getLocalText("LBL_cache_operation_completed", f_sOperation), |
| 719 | + JOptionPane.INFORMATION_MESSAGE); |
| 720 | + } |
| 721 | + catch (Exception ee) |
| 722 | + { |
| 723 | + showMessageDialog(Localization.getLocalText("ERR_cannot_run_cache_operation", selectedCache.toString()), |
| 724 | + ee.getMessage() + "\n" + ee.getCause(), JOptionPane.ERROR_MESSAGE); |
| 725 | + } |
| 726 | + } |
| 727 | + } |
| 728 | + |
| 729 | + // ----- data members ------------------------------------------------ |
| 730 | + |
| 731 | + private final String f_sOperation; |
678 | 732 | }
|
679 | 733 |
|
680 | 734 | /**
|
681 |
| - * An experimental menu option to display a heat map for the cache sizes or |
682 |
| - * primary storage used. To enable, set the following system property<br> |
683 |
| - * coherence.jvisualvm.heatmap.enabled=true |
| 735 | + * A menu option to display a heat map for the cache sizes or |
| 736 | + * primary storage used. |
684 | 737 | */
|
685 | 738 | protected class ShowHeatMapMenuOption
|
686 | 739 | extends AbstractMenuOption
|
@@ -1072,6 +1125,9 @@ private Color getColour()
|
1072 | 1125 |
|
1073 | 1126 | private static final long serialVersionUID = -7612569043492412496L;
|
1074 | 1127 |
|
| 1128 | + public static final String TRUNCATE = "truncateCache"; |
| 1129 | + public static final String CLEAR = "clearCache"; |
| 1130 | + |
1075 | 1131 | // ----- data members ---------------------------------------------------
|
1076 | 1132 |
|
1077 | 1133 | /**
|
|
0 commit comments