# HG changeset patch # User Jiri Vanek # Date 1549476305 -3600 # Node ID 3a3e13df995c092c7814ca092272b2f892e986b1 # Parent 3bb7eb063740aa2ebabd7361bece4d376a9d29cf Delete-by app dialogue split keys to two groups instead of mixing them * netx/net/sourceforge/jnlp/cache/CacheUtil.java: clearCache(String) changed to (String,bool,bool) to allow by-key access. (listCacheIds) - same. (getCacheIds) - same plus used those two booleasn to select what keys to include in filtering * netx/net/sourceforge/jnlp/controlpanel/CacheAppViewer.java: the deleteByApp dialog enhanced by TabView. Each tab holds one family of keys. * netx/net/sourceforge/jnlp/runtime/Boot.java: adapted to new signature of (CacheUtil.listCacheIds) diff -r 3bb7eb063740 -r 3a3e13df995c ChangeLog --- a/ChangeLog Mon Feb 04 17:50:17 2019 +0100 +++ b/ChangeLog Wed Feb 06 19:05:05 2019 +0100 @@ -1,3 +1,12 @@ +2019-02-06 Jiri Vanek + + Delete-by app dialogue split keys to two groups instead of mixing them + * netx/net/sourceforge/jnlp/cache/CacheUtil.java: clearCache(String) changed to (String,bool,bool) to allow by-key access. + (listCacheIds) - same. (getCacheIds) - same plus used those two booleasn to select what keys to include in filtering + * netx/net/sourceforge/jnlp/controlpanel/CacheAppViewer.java: the deleteByApp dialog enhanced by TabView. Each tab holds + one family of keys. + * netx/net/sourceforge/jnlp/runtime/Boot.java: adapted to new signature of (CacheUtil.listCacheIds) + 2019-02-04 Jiri Vanek Native launchers got splash support diff -r 3bb7eb063740 -r 3a3e13df995c netx/net/sourceforge/jnlp/cache/CacheUtil.java --- a/netx/net/sourceforge/jnlp/cache/CacheUtil.java Mon Feb 04 17:50:17 2019 +0100 +++ b/netx/net/sourceforge/jnlp/cache/CacheUtil.java Wed Feb 06 19:05:05 2019 +0100 @@ -179,14 +179,14 @@ return true; } - public static boolean clearCache(final String application) { + public static boolean clearCache(final String application, boolean jnlpPath, boolean domain) { // clear one app if (!checkToClearCache()) { return false; } OutputController.getLogger().log(OutputController.Level.WARNING_ALL, Translator.R("BXSingleCacheCleared", application)); - List ids = getCacheIds(".*"); + List ids = getCacheIds(".*", jnlpPath, domain); int found = 0; int files = 0; for (CacheId id : ids) { @@ -289,8 +289,8 @@ } - public static void listCacheIds(String filter) { - List items = getCacheIds(filter); + public static void listCacheIds(String filter, boolean jnlpPath, boolean domain) { + List items = getCacheIds(filter, jnlpPath, domain); if (JNLPRuntime.isDebug()) { for (CacheId id : items) { OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, id.getId()+" ("+id.getType()+") ["+id.files.size()+"]"); @@ -315,11 +315,12 @@ /** * This method load all known IDs of applications and will gather all members, which share the id + * @param filter - regex to filter keys * @return */ - public static List getCacheIds(final String filter) { + public static List getCacheIds(final String filter, final boolean jnlpPath, final boolean domain) { CacheLRUWrapper.getInstance().lock(); - final List r = new ArrayList(); + final List r = new ArrayList<>(); try { Files.walk(Paths.get(CacheLRUWrapper.getInstance().getCacheDir().getFile().getCanonicalPath())).filter(new Predicate() { @Override @@ -331,23 +332,27 @@ public void accept(Path path) { if (path.getFileName().toString().endsWith(CacheDirectory.INFO_SUFFIX)) { PropertiesFile pf = new PropertiesFile(new File(path.toString())); - // if jnlp-path in .info equals path of app to delete mark to delete - String jnlpPath = pf.getProperty(CacheEntry.KEY_JNLP_PATH); - if (jnlpPath != null && jnlpPath.matches(filter)) { - CacheId jnlpPathId = new CacheJnlpId(jnlpPath); - if (!r.contains(jnlpPathId)) { - r.add(jnlpPathId); - jnlpPathId.populate(); + if (jnlpPath) { + // if jnlp-path in .info equals path of app to delete mark to delete + String jnlpPath = pf.getProperty(CacheEntry.KEY_JNLP_PATH); + if (jnlpPath != null && jnlpPath.matches(filter)) { + CacheId jnlpPathId = new CacheJnlpId(jnlpPath); + if (!r.contains(jnlpPathId)) { + r.add(jnlpPathId); + jnlpPathId.populate(); + } } } - String domain = getDomain(path); - if (domain != null && domain.matches(filter)) { - CacheId doaminId = new CacheDomainId(domain); - if (!r.contains(doaminId)) { - r.add(doaminId); - doaminId.populate(); + if (domain) { + String domain = getDomain(path); + if (domain != null && domain.matches(filter)) { + CacheId doaminId = new CacheDomainId(domain); + if (!r.contains(doaminId)) { + r.add(doaminId); + doaminId.populate(); + } } } } diff -r 3bb7eb063740 -r 3a3e13df995c netx/net/sourceforge/jnlp/controlpanel/CacheAppViewer.java --- a/netx/net/sourceforge/jnlp/controlpanel/CacheAppViewer.java Mon Feb 04 17:50:17 2019 +0100 +++ b/netx/net/sourceforge/jnlp/controlpanel/CacheAppViewer.java Wed Feb 06 19:05:05 2019 +0100 @@ -31,9 +31,12 @@ import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JScrollPane; +import javax.swing.JTabbedPane; import javax.swing.JTextArea; import javax.swing.ListModel; import javax.swing.ListSelectionModel; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; import javax.swing.event.ListDataListener; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; @@ -80,9 +83,22 @@ parentPane.setLayout(new BorderLayout()); mainPane.setLayout(new GridLayout(2, 1)); parentPane.add(mainPane); - final JList apps = new JList<>(); - apps.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + final JTextArea info = new JTextArea(); + info.setEditable(false); + final JTabbedPane idTabs = new JTabbedPane(); + final JPanel jnlpPaths = new JPanel(new BorderLayout()); + jnlpPaths.setName("jnlp-path"); + final JPanel domains = new JPanel(new BorderLayout()); + domains.setName("domain"); + idTabs.add(jnlpPaths); + idTabs.add(domains); final JButton delete = new JButton(Translator.R("TIFPDeleteFiles")); + DummyCacheIdListModel jnlpPathsIds = new DummyCacheIdListModel(CacheUtil.getCacheIds(".*", true, false)); + DummyCacheIdListModel domainIds = new DummyCacheIdListModel(CacheUtil.getCacheIds(".*", false, true)); + final JList appsByJnlpPath = new JList<>(); + final JList appsByDomain = new JList<>(); + appsByJnlpPath.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + appsByDomain.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); delete.setEnabled(false); delete.addActionListener(new ActionListener() { @Override @@ -91,7 +107,12 @@ SwingUtils.invokeLater(new Runnable() { @Override public void run() { - CacheUtil.clearCache(apps.getSelectedValue().getId()); + if (idTabs.getSelectedComponent()==jnlpPaths){ + CacheUtil.clearCache(appsByJnlpPath.getSelectedValue().getId(), true, false); + } + if (idTabs.getSelectedComponent()==domains){ + CacheUtil.clearCache(appsByDomain.getSelectedValue().getId(), false, true); + } CacheAppViewer.this.getContentPane().removeAll(); CacheAppViewer.this.pack(); create(); @@ -100,33 +121,42 @@ }); } }); - final List content = CacheUtil.getCacheIds(".*"); - ListModel m = new ListModel() { - @Override - public int getSize() { - return content.size(); - } - - @Override - public CacheUtil.CacheId getElementAt(int index) { - return content.get(index); - } - + appsByJnlpPath.setModel(jnlpPathsIds); + appsByDomain.setModel(domainIds); + appsByJnlpPath.addListSelectionListener(new DummyListSelectionListenerWithModel(info, appsByJnlpPath, delete)); + appsByDomain.addListSelectionListener(new DummyListSelectionListenerWithModel(info, appsByDomain, delete)); + jnlpPaths.add(mainPane.add(new JScrollPane(appsByJnlpPath))); + domains.add(mainPane.add(new JScrollPane(appsByDomain))); + mainPane.add(idTabs); + idTabs.addChangeListener(new ChangeListener() { @Override - public void addListDataListener(ListDataListener l) { - + public void stateChanged(ChangeEvent e) { + appsByDomain.clearSelection(); + appsByJnlpPath.clearSelection(); } + }); + mainPane.add(new JScrollPane(info)); + parentPane.add(delete, BorderLayout.SOUTH); + pack(); - @Override - public void removeListDataListener(ListDataListener l) { + } - } + public void centerDialog() { + ScreenFinder.centerWindowsToCurrentScreen(this); + } + + private static class DummyListSelectionListenerWithModel implements ListSelectionListener { - }; - apps.setModel(m); - final JTextArea info = new JTextArea(); - info.setEditable(false); - apps.addListSelectionListener(new ListSelectionListener() { + private final JTextArea info; + private final JList apps; + private final JButton delete; + + public DummyListSelectionListenerWithModel(JTextArea info, JList apps, JButton delete) { + this.info = info; + this.apps = apps; + this.delete = delete; + } + @Override public void valueChanged(ListSelectionEvent e) { info.setText(""); @@ -149,15 +179,34 @@ delete.setText(Translator.R("TIFPDeleteFiles")); } } - }); - mainPane.add(new JScrollPane(apps)); - mainPane.add(new JScrollPane(info)); - parentPane.add(delete, BorderLayout.SOUTH); - pack(); + } + + private static class DummyCacheIdListModel implements ListModel { + + List content; + public DummyCacheIdListModel(List content){ + this.content = content; + } + @Override + public int getSize() { + return content.size(); + } - } + @Override + public CacheUtil.CacheId getElementAt(int index) { + return content.get(index); + } + + @Override + public void addListDataListener(ListDataListener l) { - public void centerDialog() { - ScreenFinder.centerWindowsToCurrentScreen(this); - } + } + + @Override + public void removeListDataListener(ListDataListener l) { + + } + + }; } + diff -r 3bb7eb063740 -r 3a3e13df995c netx/net/sourceforge/jnlp/runtime/Boot.java --- a/netx/net/sourceforge/jnlp/runtime/Boot.java Mon Feb 04 17:50:17 2019 +0100 +++ b/netx/net/sourceforge/jnlp/runtime/Boot.java Wed Feb 06 19:05:05 2019 +0100 @@ -352,10 +352,10 @@ List optionArgs = optionParser.getMainArgs(); if (optionArgs.size() > 0) { //clear one app - CacheUtil.listCacheIds(optionArgs.get(0)); + CacheUtil.listCacheIds(optionArgs.get(0), true, true); } else { // clear all cache - CacheUtil.listCacheIds(".*"); + CacheUtil.listCacheIds(".*", true, true); } return null; } @@ -370,7 +370,7 @@ List optionArgs = optionParser.getMainArgs(); if (optionArgs.size() > 0) { //clear one app - CacheUtil.clearCache(optionArgs.get(0)); + CacheUtil.clearCache(optionArgs.get(0), true, true); } else { // clear all cache CacheUtil.clearCache();