commit
47a99c4e90
7 changed files with 44 additions and 16 deletions
|
@ -43,20 +43,17 @@ public class FileChooser extends JFileChooser
|
||||||
{
|
{
|
||||||
Set<String> extensionSet = new HashSet<>(Arrays.asList(extensions));
|
Set<String> extensionSet = new HashSet<>(Arrays.asList(extensions));
|
||||||
|
|
||||||
|
setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
|
||||||
try {
|
try {
|
||||||
if(file.isDirectory())
|
|
||||||
setCurrentDirectory(file);
|
|
||||||
else
|
|
||||||
setSelectedFile(file);
|
setSelectedFile(file);
|
||||||
} catch (Exception ignored) { }
|
} catch (Exception ignored) { }
|
||||||
|
|
||||||
setDialogTitle(title);
|
setDialogTitle(title);
|
||||||
setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
|
|
||||||
setFileHidingEnabled(false);
|
setFileHidingEnabled(false);
|
||||||
setAcceptAllFileFilterUsed(false);
|
setAcceptAllFileFilterUsed(false);
|
||||||
if(!skipFileFilter)
|
if(!skipFileFilter)
|
||||||
{
|
{
|
||||||
setFileFilter(new FileFilter()
|
addChoosableFileFilter(new FileFilter()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(File f)
|
public boolean accept(File f)
|
||||||
|
|
|
@ -11,7 +11,7 @@ import the.bytecode.club.bytecodeviewer.gui.contextmenu.resourcelist.New;
|
||||||
import the.bytecode.club.bytecodeviewer.gui.contextmenu.resourcelist.Open;
|
import the.bytecode.club.bytecodeviewer.gui.contextmenu.resourcelist.Open;
|
||||||
import the.bytecode.club.bytecodeviewer.gui.contextmenu.resourcelist.QuickEdit;
|
import the.bytecode.club.bytecodeviewer.gui.contextmenu.resourcelist.QuickEdit;
|
||||||
import the.bytecode.club.bytecodeviewer.gui.contextmenu.resourcelist.QuickOpen;
|
import the.bytecode.club.bytecodeviewer.gui.contextmenu.resourcelist.QuickOpen;
|
||||||
import the.bytecode.club.bytecodeviewer.gui.contextmenu.resourcelist.Remove;
|
import the.bytecode.club.bytecodeviewer.gui.contextmenu.resourcelist.Delete;
|
||||||
import the.bytecode.club.bytecodeviewer.gui.resourcelist.ResourceTree;
|
import the.bytecode.club.bytecodeviewer.gui.resourcelist.ResourceTree;
|
||||||
import the.bytecode.club.bytecodeviewer.searching.LDCSearchTreeNodeResult;
|
import the.bytecode.club.bytecodeviewer.searching.LDCSearchTreeNodeResult;
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ public class ContextMenu
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
//resource list
|
//resource list
|
||||||
addContext(new Remove()); //TODO rename to delete and add support for resources & whole parent nodes (directories)
|
addContext(new Delete()); //TODO add support for resources & whole parent nodes (directories)
|
||||||
addContext(new New());
|
addContext(new New());
|
||||||
addContext(new Open());
|
addContext(new Open());
|
||||||
addContext(new QuickOpen());
|
addContext(new QuickOpen());
|
||||||
|
|
|
@ -29,18 +29,18 @@ import the.bytecode.club.bytecodeviewer.translation.TranslatedStrings;
|
||||||
* @author Konloch
|
* @author Konloch
|
||||||
* @since 7/26/2021
|
* @since 7/26/2021
|
||||||
*/
|
*/
|
||||||
public class Remove extends ContextMenuItem
|
public class Delete extends ContextMenuItem
|
||||||
{
|
{
|
||||||
public Remove()
|
public Delete()
|
||||||
{
|
{
|
||||||
super(ContextMenuType.CONTAINER, ((tree, selPath, result, menu) ->
|
super(ContextMenuType.CONTAINER, ((tree, selPath, result, menu) ->
|
||||||
{
|
{
|
||||||
menu.add(new AbstractAction(TranslatedStrings.REMOVE.toString())
|
menu.add(new AbstractAction(TranslatedStrings.DELETE.toString())
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e)
|
public void actionPerformed(ActionEvent e)
|
||||||
{
|
{
|
||||||
BytecodeViewer.viewer.resourcePane.expandAll(tree, selPath, false);
|
BytecodeViewer.viewer.resourcePane.removeNode(tree, selPath);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}));
|
}));
|
|
@ -19,6 +19,7 @@ import javax.swing.JPopupMenu;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
import javax.swing.JTree;
|
import javax.swing.JTree;
|
||||||
|
import javax.swing.tree.MutableTreeNode;
|
||||||
import javax.swing.tree.TreeNode;
|
import javax.swing.tree.TreeNode;
|
||||||
import javax.swing.tree.TreePath;
|
import javax.swing.tree.TreePath;
|
||||||
import me.konloch.kontainer.io.DiskWriter;
|
import me.konloch.kontainer.io.DiskWriter;
|
||||||
|
@ -262,6 +263,36 @@ public class ResourceListPane extends TranslatedVisibleComponent implements File
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
public void removeNode(final JTree tree, final TreePath nodePath) {
|
||||||
|
MutableTreeNode node = findNodeByPath(nodePath);
|
||||||
|
if (node == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
node.removeFromParent();
|
||||||
|
tree.repaint();
|
||||||
|
tree.updateUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
private MutableTreeNode findNodeByPath(TreePath path) {
|
||||||
|
MutableTreeNode node = treeRoot;
|
||||||
|
for (int pathStep = 1; pathStep < path.getPathCount(); pathStep++) {
|
||||||
|
TreeNode pathNode = (TreeNode) path.getPathComponent(pathStep);
|
||||||
|
int childIndex = node.getIndex(pathNode);
|
||||||
|
if (childIndex < 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
node = (MutableTreeNode) node.getChildAt(childIndex);
|
||||||
|
|
||||||
|
if (node == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
public void resetWorkspace()
|
public void resetWorkspace()
|
||||||
{
|
{
|
||||||
treeRoot.removeAllChildren();
|
treeRoot.removeAllChildren();
|
||||||
|
|
|
@ -62,7 +62,7 @@ public enum TranslatedStrings
|
||||||
|
|
||||||
OPEN_UNSTYLED,
|
OPEN_UNSTYLED,
|
||||||
QUICK_OPEN,
|
QUICK_OPEN,
|
||||||
REMOVE,
|
DELETE,
|
||||||
NEW,
|
NEW,
|
||||||
EXPAND,
|
EXPAND,
|
||||||
COLLAPSE,
|
COLLAPSE,
|
||||||
|
|
|
@ -99,9 +99,9 @@ public class DialogUtils
|
||||||
extensions);
|
extensions);
|
||||||
|
|
||||||
if(filter != null)
|
if(filter != null)
|
||||||
fc.setFileFilter(filter);
|
fc.addChoosableFileFilter(filter);
|
||||||
else
|
else
|
||||||
fc.setFileFilter(new FileFilter()
|
fc.addChoosableFileFilter(new FileFilter()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(File f)
|
public boolean accept(File f)
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
"OPEN": "Open...",
|
"OPEN": "Open...",
|
||||||
"OPEN_UNSTYLED": "Open",
|
"OPEN_UNSTYLED": "Open",
|
||||||
"QUICK_OPEN": "Quick Open",
|
"QUICK_OPEN": "Quick Open",
|
||||||
"REMOVE": "Remove",
|
"DELETE": "Delete",
|
||||||
"NEW": "New",
|
"NEW": "New",
|
||||||
"EXPAND": "Expand",
|
"EXPAND": "Expand",
|
||||||
"COLLAPSE": "Collapse",
|
"COLLAPSE": "Collapse",
|
||||||
|
|
Loading…
Reference in a new issue