Skip to content

Commit

Permalink
Reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
crschnick committed Aug 16, 2024
1 parent 6a946db commit 1ebc60c
Show file tree
Hide file tree
Showing 78 changed files with 568 additions and 394 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ bin
ComponentsGenerated.wxs
!dist/javafx/**/lib
!dist/javafx/**/bin
dev.properties
xcuserdata/
*.dylib
project.xcworkspace
8 changes: 5 additions & 3 deletions app/src/main/java/io/xpipe/app/beacon/AppBeaconServer.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package io.xpipe.app.beacon;

import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpServer;
import io.xpipe.app.core.AppResources;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.TrackEvent;
Expand All @@ -10,6 +8,9 @@
import io.xpipe.beacon.BeaconInterface;
import io.xpipe.core.process.OsType;
import io.xpipe.core.util.XPipeInstallation;

import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpServer;
import lombok.Getter;

import java.io.IOException;
Expand Down Expand Up @@ -126,7 +127,8 @@ private void deleteAuthSecret() {
}

private void start() throws IOException {
server = HttpServer.create(new InetSocketAddress(Inet4Address.getByAddress(new byte[]{ 0x7f,0x00,0x00,0x01 }), port), 10);
server = HttpServer.create(
new InetSocketAddress(Inet4Address.getByAddress(new byte[] {0x7f, 0x00, 0x00, 0x01}), port), 10);
BeaconInterface.getAll().forEach(beaconInterface -> {
server.createContext(beaconInterface.getPath(), new BeaconRequestHandler<>(beaconInterface));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ private <REQ> REQ createRawDataRequest(BeaconInterface<?> beaconInterface, byte[
&& method.getParameters()[0].getType().equals(byte[].class))
.findFirst()
.orElseThrow();
setMethod.invoke(b, (Object) s);
setMethod.invoke(b, s);

var m = b.getClass().getDeclaredMethod("build");
m.setAccessible(true);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
package io.xpipe.app.beacon.impl;

import com.sun.net.httpserver.HttpExchange;
import io.xpipe.app.util.TerminalLauncherManager;
import io.xpipe.beacon.BeaconClientException;
import io.xpipe.beacon.api.SshLaunchExchange;
import io.xpipe.core.process.ProcessControlProvider;
import io.xpipe.core.process.ShellDialects;

import com.sun.net.httpserver.HttpExchange;

public class SshLaunchExchangeImpl extends SshLaunchExchange {

@Override
public Object handle(HttpExchange exchange, Request msg) throws Exception {
var usedDialect = ShellDialects.ALL.stream().filter(dialect -> dialect.getExecutableName().equalsIgnoreCase(msg.getArguments())).findFirst();
if (msg.getArguments() != null && usedDialect.isEmpty() && !msg.getArguments().contains("SSH_ORIGINAL_COMMAND")) {
var usedDialect = ShellDialects.ALL.stream()
.filter(dialect -> dialect.getExecutableName().equalsIgnoreCase(msg.getArguments()))
.findFirst();
if (msg.getArguments() != null
&& usedDialect.isEmpty()
&& !msg.getArguments().contains("SSH_ORIGINAL_COMMAND")) {
throw new BeaconClientException("Unexpected argument: " + msg.getArguments());
}

var r = TerminalLauncherManager.waitForNextLaunch();
var c = ProcessControlProvider.get().getEffectiveLocalDialect().getOpenScriptCommand(r.toString()).buildBaseParts(null);
var c = ProcessControlProvider.get()
.getEffectiveLocalDialect()
.getOpenScriptCommand(r.toString())
.buildBaseParts(null);
return Response.builder().command(c).build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import io.xpipe.app.core.AppLayoutModel;
import io.xpipe.app.fxcomps.SimpleComp;
import io.xpipe.app.fxcomps.util.PlatformThread;

import io.xpipe.core.process.OsType;

import javafx.scene.control.Label;
import javafx.scene.layout.Region;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,12 @@ public Item(OpenFileSystemModel openFileSystemModel, String name, BrowserEntry b

public ObservableBooleanValue downloadFinished() {
synchronized (progress) {
return Bindings.createBooleanBinding(() -> {
return progress.getValue() != null && progress.getValue().done();
}, progress);
return Bindings.createBooleanBinding(
() -> {
return progress.getValue() != null
&& progress.getValue().done();
},
progress);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public interface ApplicationPathAction extends BrowserAction {
String getExecutable();

@Override
default void init(OpenFileSystemModel model) throws Exception {
default void init(OpenFileSystemModel model) {
// Cache result for later calls
model.getCache().isApplicationInPath(getExecutable());
}
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/java/io/xpipe/app/browser/action/BranchAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
import io.xpipe.app.browser.file.BrowserEntry;
import io.xpipe.app.browser.fs.OpenFileSystemModel;
import io.xpipe.app.util.LicenseProvider;

import javafx.scene.control.Menu;
import javafx.scene.control.MenuItem;

import org.kordamp.ikonli.javafx.FontIcon;

import java.util.List;
Expand All @@ -27,15 +29,13 @@ default MenuItem toMenuItem(OpenFileSystemModel model, List<BrowserEntry> select
m.setDisable(!isActive(model, selected));

if (getProFeatureId() != null
&& !LicenseProvider.get()
.getFeature(getProFeatureId())
.isSupported()) {
&& !LicenseProvider.get().getFeature(getProFeatureId()).isSupported()) {
m.setDisable(true);
m.setGraphic(new FontIcon("mdi2p-professional-hexagon"));
}

return m;
}

List<? extends BrowserAction> getBranchingActions(OpenFileSystemModel model, List<BrowserEntry> entries);
}
17 changes: 11 additions & 6 deletions app/src/main/java/io/xpipe/app/browser/action/BrowserAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,15 @@ static List<LeafAction> getFlattened(OpenFileSystemModel model, List<BrowserEntr
.toList();
}

static List<LeafAction> getFlattened(BrowserAction browserAction, OpenFileSystemModel model, List<BrowserEntry> entries) {
static List<LeafAction> getFlattened(
BrowserAction browserAction, OpenFileSystemModel model, List<BrowserEntry> entries) {
return browserAction instanceof LeafAction
? List.of((LeafAction) browserAction)
: ((BranchAction) browserAction).getBranchingActions(model, entries).stream().map(action -> getFlattened(action, model, entries)).flatMap(List::stream).toList();
? List.of((LeafAction) browserAction)
: ((BranchAction) browserAction)
.getBranchingActions(model, entries).stream()
.map(action -> getFlattened(action, model, entries))
.flatMap(List::stream)
.toList();
}

static LeafAction byId(String id, OpenFileSystemModel model, List<BrowserEntry> entries) {
Expand All @@ -41,9 +46,9 @@ static LeafAction byId(String id, OpenFileSystemModel model, List<BrowserEntry>
default List<BrowserEntry> resolveFilesIfNeeded(List<BrowserEntry> selected) {
return automaticallyResolveLinks()
? selected.stream()
.map(browserEntry ->
new BrowserEntry(browserEntry.getRawFileEntry().resolved(), browserEntry.getModel()))
.toList()
.map(browserEntry ->
new BrowserEntry(browserEntry.getRawFileEntry().resolved(), browserEntry.getModel()))
.toList()
: selected;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import io.xpipe.app.browser.fs.OpenFileSystemModel;
import io.xpipe.app.core.AppFont;
import io.xpipe.app.util.InputHelper;

import javafx.scene.control.ContextMenu;
import javafx.scene.control.SeparatorMenuItem;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,23 +157,24 @@ private void prepareTypedSelectionModel(TableView<BrowserEntry> table) {
});
}

private void updateTypedSelection(TableView<BrowserEntry> table, AtomicReference<Instant> lastType, KeyEvent event, boolean recursive) {
private void updateTypedSelection(
TableView<BrowserEntry> table, AtomicReference<Instant> lastType, KeyEvent event, boolean recursive) {
var typed = event.getText();
if (typed.isEmpty()) {
return;
}

var updated = typedSelection.get() + typed;
var found = fileList.getShown().getValue().stream()
.filter(browserEntry ->
browserEntry.getFileName().toLowerCase().startsWith(updated.toLowerCase()))
.filter(browserEntry -> browserEntry.getFileName().toLowerCase().startsWith(updated.toLowerCase()))
.findFirst();
if (found.isEmpty()) {
if (typedSelection.get().isEmpty()) {
return;
}

var inCooldown = lastType.get() != null && Duration.between(lastType.get(), Instant.now()).toMillis() < 1000;
var inCooldown = lastType.get() != null
&& Duration.between(lastType.get(), Instant.now()).toMillis() < 1000;
if (inCooldown) {
lastType.set(Instant.now());
event.consume();
Expand Down Expand Up @@ -599,7 +600,8 @@ public FilenameCell(Property<BrowserEntry> editing, TableView<BrowserEntry> tabl
browserEntry.getFileName().toLowerCase().startsWith(selection))
.findFirst();
// Ugly fix to prevent space from showing the menu when there is a file matching
// Due to the table view input map, these events always get sent and consumed, not allowing us to differentiate between these cases
// Due to the table view input map, these events always get sent and consumed, not allowing us to
// differentiate between these cases
if (found.isPresent()) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ public Comparator<BrowserEntry> order() {
}

public BrowserEntry rename(BrowserEntry old, String newName) {
if (fileSystemModel == null || fileSystemModel.isClosed() || fileSystemModel.getCurrentPath().get() == null) {
if (fileSystemModel == null
|| fileSystemModel.isClosed()
|| fileSystemModel.getCurrentPath().get() == null) {
return old;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,13 @@ root, new KeyCodeCombination(KeyCode.UP, KeyCombination.ALT_DOWN), true, keyEven
}
keyEvent.consume();
});
InputHelper.onKeyCombination(
root, new KeyCodeCombination(KeyCode.BACK_SPACE), true, keyEvent -> {
var p = model.getCurrentParentDirectory();
if (p != null) {
model.cdAsync(p.getPath());
}
keyEvent.consume();
});
InputHelper.onKeyCombination(root, new KeyCodeCombination(KeyCode.BACK_SPACE), true, keyEvent -> {
var p = model.getCurrentParentDirectory();
if (p != null) {
model.cdAsync(p.getPath());
}
keyEvent.consume();
});
return root;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package io.xpipe.app.browser.session;

import atlantafx.base.controls.RingProgressIndicator;
import atlantafx.base.theme.Styles;
import io.xpipe.app.browser.BrowserWelcomeComp;
import io.xpipe.app.comp.base.MultiContentComp;
import io.xpipe.app.core.AppI18n;
Expand All @@ -14,6 +12,7 @@
import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.util.BooleanScope;
import io.xpipe.app.util.ContextMenuHelper;

import javafx.application.Platform;
import javafx.beans.binding.Bindings;
import javafx.beans.property.SimpleBooleanProperty;
Expand All @@ -28,6 +27,9 @@
import javafx.scene.layout.Region;
import javafx.scene.layout.StackPane;

import atlantafx.base.controls.RingProgressIndicator;
import atlantafx.base.theme.Styles;

import java.util.*;

import static atlantafx.base.theme.Styles.DENSE;
Expand Down Expand Up @@ -205,7 +207,8 @@ private TabPane createTabPane() {
return;
}

if (new KeyCodeCombination(KeyCode.W, KeyCombination.SHORTCUT_DOWN, KeyCombination.SHIFT_DOWN).match(keyEvent)) {
if (new KeyCodeCombination(KeyCode.W, KeyCombination.SHORTCUT_DOWN, KeyCombination.SHIFT_DOWN)
.match(keyEvent)) {
tabs.getTabs().clear();
keyEvent.consume();
}
Expand Down
36 changes: 13 additions & 23 deletions app/src/main/java/io/xpipe/app/comp/base/SideMenuBarComp.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ public CompStructure<VBox> createBase() {
Platform.getPreferences().accentColorProperty());

var selected = PseudoClass.getPseudoClass("selected");
for (int i = 0; i < entries.size(); i++) {
var e = entries.get(i);
for (AppLayoutModel.Entry e : entries) {
var b = new IconButtonComp(e.icon(), () -> {
if (e.action() != null) {
e.action().run();
Expand All @@ -84,30 +83,21 @@ public CompStructure<VBox> createBase() {
b.accessibleText(e.name());

var indicator = Comp.empty().styleClass("indicator");
var stack = new StackComp(List.of(indicator, b))
.apply(struc -> struc.get().setAlignment(Pos.CENTER_RIGHT));
var stack = new StackComp(List.of(indicator, b)).apply(struc -> struc.get().setAlignment(Pos.CENTER_RIGHT));
stack.apply(struc -> {
var indicatorRegion = (Region) struc.get().getChildren().getFirst();
indicatorRegion.setMaxWidth(7);
indicatorRegion
.backgroundProperty()
.bind(Bindings.createObjectBinding(
() -> {
if (value.getValue().equals(e)) {
return selectedBorder.get();
}

if (struc.get().isHover()) {
return hoverBorder.get();
}

return noneBorder.get();
},
struc.get().hoverProperty(),
value,
hoverBorder,
selectedBorder,
noneBorder));
indicatorRegion.backgroundProperty().bind(Bindings.createObjectBinding(() -> {
if (value.getValue().equals(e)) {
return selectedBorder.get();
}

if (struc.get().isHover()) {
return hoverBorder.get();
}

return noneBorder.get();
}, struc.get().hoverProperty(), value, hoverBorder, selectedBorder, noneBorder));
});
if (shortcut != null) {
stack.apply(struc -> struc.get().getProperties().put("shortcut", shortcut));
Expand Down
17 changes: 6 additions & 11 deletions app/src/main/java/io/xpipe/app/comp/base/SystemStateComp.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,15 @@ protected Region createSimple() {
var success = Styles.toDataURI(
"""
.stacked-ikonli-font-icon > .outer-icon { -fx-icon-color: -color-success-emphasis; }
""");
var failure = Styles.toDataURI(
"""
);
var failure =
Styles.toDataURI(
"""
.stacked-ikonli-font-icon > .outer-icon { -fx-icon-color: -color-danger-emphasis; }
"""
);
var other =
Styles.toDataURI(
"""
""");
var other = Styles.toDataURI(
"""
.stacked-ikonli-font-icon > .outer-icon { -fx-icon-color: -color-accent-emphasis; }
"""
);
""");

var pane = new StackedFontIcon();
pane.getChildren().addAll(fi, border);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import io.xpipe.app.fxcomps.Comp;
import io.xpipe.app.fxcomps.augment.GrowAugment;
import io.xpipe.app.fxcomps.util.PlatformThread;

import javafx.beans.binding.Bindings;
import javafx.beans.property.SimpleStringProperty;
import javafx.geometry.HPos;
Expand Down Expand Up @@ -41,10 +42,9 @@ private Label createInformation(GridPane grid) {
() -> {
var val = summary.getValue();
var p = getWrapper().getEntry().getProvider();
if (val != null && grid.isHover()
&& p.alwaysShowSummary()) {
if (val != null && grid.isHover() && p.alwaysShowSummary()) {
return val;
} else if (info.getValue() == null && p.alwaysShowSummary()){
} else if (info.getValue() == null && p.alwaysShowSummary()) {
return val;
} else {
return info.getValue();
Expand Down
Loading

0 comments on commit 1ebc60c

Please sign in to comment.