Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added File Browser / File Tree panel #2460

Merged
merged 20 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
aaa9074
created FileBrowser Panel and TopComponent
andrewmurraydavid Feb 8, 2024
ec686ea
added localization strings for FileBrowserPanel
andrewmurraydavid Feb 8, 2024
58e0183
added user setting for last working directory
andrewmurraydavid Feb 8, 2024
b0655b1
added FileBrowserPanel to WidgetPreviewer
andrewmurraydavid Feb 8, 2024
5a8587e
a bit of cleanup in FileBrowserPanel
andrewmurraydavid Feb 8, 2024
ada8873
add key listeners to FileBrowserPanel tree
andrewmurraydavid Feb 8, 2024
3529550
nicer icons
andrewmurraydavid Feb 8, 2024
c2c7aa7
added ancestor listener to focus tree when panel is visible
andrewmurraydavid Feb 8, 2024
09c6244
show root handles
andrewmurraydavid Feb 8, 2024
e9e7ad3
moved FileBrowserPanel to `ugs-platform-ugscore`
andrewmurraydavid Feb 8, 2024
4cbe349
fixed localization issue on FileBrowserTopComponent
andrewmurraydavid Feb 8, 2024
ff2588b
fixed file open action on FileBrowserPanel
andrewmurraydavid Feb 8, 2024
12597cd
fixed icons defaulting to system icons when disabled
andrewmurraydavid Feb 9, 2024
8adb2fa
small cleanup
andrewmurraydavid Feb 9, 2024
1205f8c
disable/enable file tree on certain UGSEvents
andrewmurraydavid Feb 9, 2024
98b5ad5
removed netbeans dependency from `ugs-core`
andrewmurraydavid Feb 9, 2024
2123874
give MachineStatusTopComponent lower position
andrewmurraydavid Feb 12, 2024
1a31abe
FileBrowserTopComponent high position and disable openAtStartup
andrewmurraydavid Feb 12, 2024
3e0ccf9
cleanup FileTreeCellRenderer
andrewmurraydavid Feb 12, 2024
c19521a
fix issue with trying to open the `.` folder as a file
andrewmurraydavid Feb 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2014-2023 Will Winder
Copyright 2014-2024 Will Winder

This file is part of Universal Gcode Sender (UGS).

Expand Down Expand Up @@ -29,8 +29,20 @@ This file is part of Universal Gcode Sender (UGS).

import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;
import java.util.logging.Logger;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Deque;
import java.util.ArrayDeque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.List;



public class Settings {
private static final Logger logger = Logger.getLogger(Settings.class.getName());
Expand Down Expand Up @@ -120,6 +132,11 @@ public class Settings {
*/
private boolean showTranslationsWarning = true;

/**
* The last working directory used by the file browser
*/
private String lastWorkingDirectory = System.getProperty("user.home");

/**
* The GSON deserialization doesn't do anything beyond initialize what's in the json document. Call finalizeInitialization() before using the Settings.
*/
Expand Down Expand Up @@ -556,6 +573,14 @@ public void setShowTranslationsWarning(boolean showTranslationsWarning) {
this.showTranslationsWarning = showTranslationsWarning;
}

public String getLastWorkingDirectory() {
return lastWorkingDirectory;
}

public void setLastWorkingDirectory(String lastWorkingDirectory) {
this.lastWorkingDirectory = lastWorkingDirectory;
}

public static class FileStats {
public Position minCoordinate;
public Position maxCoordinate;
Expand Down
2 changes: 2 additions & 0 deletions ugs-core/src/resources/MessagesBundle_en_US.properties
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,8 @@ platform.window.serialconsole = Console
platform.window.serialconsole.tooltip = Console displaying messages to and from the controller.
platform.window.visualizer = Visualizer
platform.window.visualizer.tooltip = 3D view of the current operation.
platform.window.fileBrowser = File Browser
platform.window.fileBrowser.tooltip = Load a folder to view and work with files.
platform.visualizer.edit.options.title = Visualizer options
platform.visualizer.color.background = Background Color
platform.visualizer.tool = Show tool location
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ This file is part of Universal Gcode Sender (UGS).
)
@TopComponent.Registration(
mode = Mode.LEFT_TOP,
openAtStartup = true
openAtStartup = true,
position = 100
)
@ActionID(
category = LocalizingService.LocationStatusCategory,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
Copyright 2016-2024 Will Winder

This file is part of Universal Gcode Sender (UGS).

UGS is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

UGS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with UGS. If not, see <http://www.gnu.org/licenses/>.
*/
package com.willwinder.ugs.nbp.core.control;

import com.willwinder.ugs.nbp.lib.Mode;
import com.willwinder.ugs.nbp.lib.lookup.CentralLookup;
import com.willwinder.ugs.nbp.lib.services.TopComponentLocalizer;
import com.willwinder.universalgcodesender.model.BackendAPI;
import com.willwinder.ugs.nbp.core.panels.FileBrowserPanel;
import static com.willwinder.ugs.nbp.lib.services.LocalizingService.FileBrowserPanelCategory;
import static com.willwinder.ugs.nbp.lib.services.LocalizingService.FileBrowserPanelActionId;
import static com.willwinder.ugs.nbp.lib.services.LocalizingService.FileBrowserPanelWindowPath;
import static com.willwinder.ugs.nbp.lib.services.LocalizingService.FileBrowserPanelTitle;
import static com.willwinder.ugs.nbp.lib.services.LocalizingService.FileBrowserPanelTooltip;


import java.awt.BorderLayout;

import org.openide.awt.ActionID;
import org.openide.awt.ActionReference;
import org.openide.modules.OnStart;
import org.openide.windows.TopComponent;

/**
* Top component which displays something.
*/
@TopComponent.Description(
preferredID = "FileBrowserTopComponent"
)
@TopComponent.Registration(mode = Mode.LEFT_TOP, openAtStartup = false, position = 2200)
@ActionID(category = FileBrowserPanelCategory, id = FileBrowserPanelActionId)
@ActionReference(path = FileBrowserPanelWindowPath)
@TopComponent.OpenActionRegistration(
displayName = "<Not localized:FileBrowserTopComponent>",
preferredID = "FileBrowserTopComponent"
)
public final class FileBrowserTopComponent extends TopComponent {

public FileBrowserTopComponent() {
this.setLayout(new BorderLayout());
BackendAPI backend = CentralLookup.getDefault().lookup(BackendAPI.class);
FileBrowserPanel panel = new FileBrowserPanel(backend);
this.add(panel, BorderLayout.CENTER);
}

@Override
public void componentOpened() {
setName(FileBrowserPanelTitle);
setToolTipText(FileBrowserPanelTooltip);
}

@Override
public void componentClosed() {
// TODO add custom code on component closing
}

public void writeProperties(java.util.Properties p) {
// better to version settings since initial version as advocated at
// http://wiki.apidesign.org/wiki/PropertyFiles
p.setProperty("version", "1.0");
}

public void readProperties(java.util.Properties p) {
}

@OnStart
public static class Localizer extends TopComponentLocalizer {
public Localizer() {
super(FileBrowserPanelCategory, FileBrowserPanelActionId, FileBrowserPanelTitle);
}
}
}
Loading
Loading