Skip to content

Commit

Permalink
7.95
Browse files Browse the repository at this point in the history
Improve folder load tree
  • Loading branch information
tonikelope committed Oct 19, 2023
1 parent 5667ab9 commit 754ae6a
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 18 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.tonikelope</groupId>
<artifactId>MegaBasterd</artifactId>
<version>7.94</version>
<version>7.95</version>
<packaging>jar</packaging>
<repositories>
<repository>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ private void account_comboboxItemStateChanged(java.awt.event.ItemEvent evt) {//G

private void skip_rest_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_skip_rest_buttonActionPerformed

if (deleteAllExceptSelectedTreeItems(file_tree, null)) {
if (deleteAllExceptSelectedTreeItems(file_tree)) {

_genFileList();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ public class FolderLinkDialog extends javax.swing.JDialog {

private volatile boolean exit = false;

private volatile MegaMutableTreeNode _subfolder_node = null;

public List<HashMap> getDownload_links() {
return Collections.unmodifiableList(_download_links);
}
Expand Down Expand Up @@ -323,7 +321,7 @@ private void dance_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-

private void skip_rest_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_skip_rest_buttonActionPerformed

if (deleteAllExceptSelectedTreeItems(file_tree, _subfolder_node)) {
if (deleteAllExceptSelectedTreeItems(file_tree)) {
file_tree.setEnabled(false);
node_bar.setVisible(true);
skip_rest_button.setEnabled(false);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/tonikelope/megabasterd/MainPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
*/
public final class MainPanel {

public static final String VERSION = "7.94";
public static final String VERSION = "7.95";
public static final boolean FORCE_SMART_PROXY = false; //TRUE FOR DEBUGING SMART PROXY
public static final int THROTTLE_SLICE_SIZE = 16 * 1024;
public static final int DEFAULT_BYTE_BUFFER_SIZE = 16 * 1024;
Expand Down
23 changes: 11 additions & 12 deletions src/main/java/com/tonikelope/megabasterd/MiscTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import java.io.ObjectOutputStream;
import java.io.UnsupportedEncodingException;
import java.lang.management.ManagementFactory;
import java.lang.reflect.InvocationTargetException;
import java.math.BigInteger;
import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
Expand Down Expand Up @@ -807,7 +808,7 @@ public static boolean isDirEmpty(Path path) {
return false;
}

public static boolean deleteAllExceptSelectedTreeItems(JTree tree, DefaultMutableTreeNode custom_root) {
public static boolean deleteAllExceptSelectedTreeItems(JTree tree) {

TreePath[] paths = tree.getSelectionPaths();

Expand All @@ -823,12 +824,14 @@ public static boolean deleteAllExceptSelectedTreeItems(JTree tree, DefaultMutabl

try {

new_root = node_class.newInstance();
new_root = node_class.getDeclaredConstructor().newInstance();

((MutableTreeNode) new_root).setUserObject(((DefaultMutableTreeNode) tree_model.getRoot()).getUserObject());
((DefaultMutableTreeNode) new_root).setUserObject(((DefaultMutableTreeNode) tree_model.getRoot()).getUserObject());

} catch (InstantiationException | IllegalAccessException ex) {
Logger.getLogger(MiscTools.class.getName()).log(Level.SEVERE, ex.getMessage());
} catch (NoSuchMethodException | SecurityException | IllegalArgumentException | InvocationTargetException ex) {
Logger.getLogger(MiscTools.class.getName()).log(Level.SEVERE, null, ex);
}

for (TreePath path : paths) {
Expand All @@ -838,13 +841,13 @@ public static boolean deleteAllExceptSelectedTreeItems(JTree tree, DefaultMutabl

for (Object path_element : path.getPath()) {

if ((MutableTreeNode) path_element != (MutableTreeNode) tree_model.getRoot()) {
if ((DefaultMutableTreeNode) path_element != (DefaultMutableTreeNode) tree_model.getRoot()) {

if (hashmap_old.get(path_element) == null) {

Object node = null;

if ((MutableTreeNode) path_element == (MutableTreeNode) path.getLastPathComponent()) {
if ((DefaultMutableTreeNode) path_element == (DefaultMutableTreeNode) path.getLastPathComponent()) {

node = path_element;

Expand All @@ -854,7 +857,7 @@ public static boolean deleteAllExceptSelectedTreeItems(JTree tree, DefaultMutabl

node = node_class.newInstance();

((MutableTreeNode) node).setUserObject(((DefaultMutableTreeNode) path_element).getUserObject());
((DefaultMutableTreeNode) node).setUserObject(((DefaultMutableTreeNode) path_element).getUserObject());

} catch (InstantiationException | IllegalAccessException ex) {
Logger.getLogger(MiscTools.class.getName()).log(Level.SEVERE, ex.getMessage());
Expand All @@ -863,11 +866,11 @@ public static boolean deleteAllExceptSelectedTreeItems(JTree tree, DefaultMutabl

if (parent != null) {

((DefaultMutableTreeNode) parent).add((MutableTreeNode) node);
((DefaultMutableTreeNode) parent).add((DefaultMutableTreeNode) node);

if (!((TreeNode) path_element).isLeaf()) {

hashmap_old.put((MutableTreeNode) path_element, (MutableTreeNode) node);
hashmap_old.put((DefaultMutableTreeNode) path_element, (DefaultMutableTreeNode) node);

parent = node;
}
Expand All @@ -886,10 +889,6 @@ public static boolean deleteAllExceptSelectedTreeItems(JTree tree, DefaultMutabl
}
}

if (custom_root != null) {
new_root = custom_root;
}

tree.setModel(new DefaultTreeModel(sortTree((DefaultMutableTreeNode) new_root)));

tree.setRootVisible(new_root != null ? ((TreeNode) new_root).getChildCount() > 0 : false);
Expand Down
Binary file modified src/main/resources/images/mbasterd_screen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 754ae6a

Please sign in to comment.