You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by lk...@apache.org on 2022/08/09 19:18:47 UTC
[netbeans] branch master updated: Better messages from Janitor on abandoned cache dirs.
This is an automated email from the ASF dual-hosted git repository.
lkishalmi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git
The following commit(s) were added to refs/heads/master by this push:
new 33faa158a5 Better messages from Janitor on abandoned cache dirs.
33faa158a5 is described below
commit 33faa158a52ef25d9e235e04f9a229690829f1ff
Author: Laszlo Kishalmi <la...@gmail.com>
AuthorDate: Sun Jul 31 17:26:51 2022 -0700
Better messages from Janitor on abandoned cache dirs.
---
.../src/org/netbeans/modules/janitor/Janitor.java | 61 ++++++++++++++++------
.../org/netbeans/modules/janitor/JanitorPanel.form | 2 +-
.../org/netbeans/modules/janitor/JanitorPanel.java | 2 +-
3 files changed, 47 insertions(+), 18 deletions(-)
diff --git a/platform/janitor/src/org/netbeans/modules/janitor/Janitor.java b/platform/janitor/src/org/netbeans/modules/janitor/Janitor.java
index 0d2ee6fe4a..66882b4b28 100644
--- a/platform/janitor/src/org/netbeans/modules/janitor/Janitor.java
+++ b/platform/janitor/src/org/netbeans/modules/janitor/Janitor.java
@@ -58,11 +58,33 @@ import org.openide.windows.OnShowing;
"# {1} - the days of abandonement",
"# {2} - the disk space can be reclaimed (in megabytes)",
"TIT_ABANDONED_USERDIR=NetBeans {0} was last used {1} days ago.",
+
+ "# {0} - the name of the abandoned cache dir.",
+ "# {1} - the disk space can be reclaimed (in megabytes)",
+ "TIT_ABANDONED_CACHEDIR=NetBeans cache directory {0} seems to be abandoned.",
+
"# {0} - is the user directory name",
"# {1} - the days of abandonement",
"# {2} - the disk space can be reclaimed (in megabytes)",
"DESC_ABANDONED_USERDIR=Remove unused data and cache directories of NetBeans {0}. "
+ "Free up {2} MB of disk space.",
+
+ "# {0} - is the cache directory name",
+ "# {1} - the disk space can be reclaimed (in megabytes)",
+ "DESC_ABANDONED_CACHEDIR=NetBeans could not find a user dir for cache dir {0}, so it is probably abandoned. "
+ + "Remove abandoned cache dir, "
+ + "free up {1} MB of disk space.",
+
+ "TIT_CONFIRM_CLEANUP=Confirm Cleanup",
+
+ "# {0} - the dirname to be cleaned up",
+ "TXT_CONFIRM_CLEANUP=Remove user and cache data for NetBeans {0}?",
+
+ "# {0} - the dirname to be cleaned up",
+ "TXT_CONFIRM_CACHE_CLEANUP=Remove abandoned cache dir?",
+
+ "# {0} - the dirname to be cleaned up",
+ "LBL_CLEANUP=Removing unused/abandoned user and/or cache dirs."
})
public class Janitor {
@@ -87,30 +109,37 @@ public class Janitor {
List<Pair<String, Integer>> otherVersions = getOtherVersions();
for (Pair<String, Integer> ver : otherVersions) {
- long toFree = size(getUserDir(ver.first())) + size(getCacheDir(ver.first()));
+ String name = ver.first();
+ Integer age = ver.second();
+ long toFree = size(getUserDir(name)) + size(getCacheDir(name));
toFree = toFree / (1_000_000) + 1;
- ActionListener cleanupListener = cleanupAction(ver.first());
- Notification nf = NotificationDisplayer.getDefault().notify(
- Bundle.TIT_ABANDONED_USERDIR(ver.first(), ver.second(), toFree),
- clean,
- Bundle.DESC_ABANDONED_USERDIR(ver.first(), ver.second(), toFree),
- cleanupListener);
+ ActionListener cleanupListener;
+ Notification nf;
+ if (getUserDir(name) != null) {
+ cleanupListener = cleanupAction(name, Bundle.TXT_CONFIRM_CLEANUP(name));
+ nf = NotificationDisplayer.getDefault().notify(
+ Bundle.TIT_ABANDONED_USERDIR(name, age, toFree),
+ clean,
+ Bundle.DESC_ABANDONED_USERDIR(name, age, toFree),
+ cleanupListener);
+
+ } else {
+ cleanupListener = cleanupAction(name, Bundle.TXT_CONFIRM_CACHE_CLEANUP(name));
+ nf = NotificationDisplayer.getDefault().notify(
+ Bundle.TIT_ABANDONED_CACHEDIR(name, toFree),
+ clean,
+ Bundle.DESC_ABANDONED_CACHEDIR(name, toFree),
+ cleanupListener);
+ }
CLEANUP_TASKS.put(cleanupListener, nf);
}
};
- @Messages({
- "TIT_CONFIRM_CLEANUP=Confirm Cleanup",
- "# {0} - the dirname to be cleaned up",
- "TXT_CONFIRM_CLEANUP=Remove user and cache data for NetBeans {0}?",
- "# {0} - the dirname to be cleaned up",
- "LBL_CLEANUP=Removing user and cache dirs of {0}"
- })
- static ActionListener cleanupAction(String name) {
+ static ActionListener cleanupAction(String name, String label) {
return new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
- JanitorPanel panel = new JanitorPanel(Bundle.TXT_CONFIRM_CLEANUP(name));
+ JanitorPanel panel = new JanitorPanel(label);
DialogDescriptor descriptor = new DialogDescriptor(
panel,
Bundle.TIT_CONFIRM_CLEANUP(),
diff --git a/platform/janitor/src/org/netbeans/modules/janitor/JanitorPanel.form b/platform/janitor/src/org/netbeans/modules/janitor/JanitorPanel.form
index a1ac91630e..6d7df9cd4f 100644
--- a/platform/janitor/src/org/netbeans/modules/janitor/JanitorPanel.form
+++ b/platform/janitor/src/org/netbeans/modules/janitor/JanitorPanel.form
@@ -65,7 +65,7 @@
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
- <Property name="verticalAlignment" type="int" value="1"/>
+ <Property name="horizontalAlignment" type="int" value="0"/>
</Properties>
</Component>
<Component class="javax.swing.JCheckBox" name="cbEnabled">
diff --git a/platform/janitor/src/org/netbeans/modules/janitor/JanitorPanel.java b/platform/janitor/src/org/netbeans/modules/janitor/JanitorPanel.java
index da15afab30..0190caee27 100644
--- a/platform/janitor/src/org/netbeans/modules/janitor/JanitorPanel.java
+++ b/platform/janitor/src/org/netbeans/modules/janitor/JanitorPanel.java
@@ -49,7 +49,7 @@ public class JanitorPanel extends javax.swing.JPanel {
jLabel1 = new javax.swing.JLabel();
cbEnabled = new javax.swing.JCheckBox();
- jLabel1.setVerticalAlignment(javax.swing.SwingConstants.TOP);
+ jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
org.openide.awt.Mnemonics.setLocalizedText(cbEnabled, org.openide.util.NbBundle.getMessage(JanitorPanel.class, "JanitorPanel.cbEnabled.text")); // NOI18N
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists