Skip to content

Commit

Permalink
Reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
crschnick committed Dec 13, 2024
1 parent d584a2f commit ed24ad9
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ private boolean showContextMenu(MouseEvent event) {

if (item.getRawFileEntry().resolved().getKind() != FileKind.DIRECTORY) {
return event.getButton() == MouseButton.SECONDARY
|| !AppPrefs.get().editFilesWithDoubleClick().get() && event.getButton() == MouseButton.PRIMARY && event.getClickCount() == 2;
|| !AppPrefs.get().editFilesWithDoubleClick().get()
&& event.getButton() == MouseButton.PRIMARY
&& event.getClickCount() == 2;
}

return false;
Expand Down
6 changes: 4 additions & 2 deletions app/src/main/java/io/xpipe/app/comp/store/StoreEntryComp.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ protected final Region createSimple() {
});
});
button.addEventFilter(MouseEvent.MOUSE_CLICKED, event -> {
var notOnButton = NodeHelper.isParent(iconChooser, event.getTarget()) || NodeHelper.isParent(buttonBar, event.getTarget());
var notOnButton = NodeHelper.isParent(iconChooser, event.getTarget())
|| NodeHelper.isParent(buttonBar, event.getTarget());
if (AppPrefs.get().requireDoubleClickForConnections().get() && !notOnButton) {
if (event.getButton() == MouseButton.PRIMARY && event.getClickCount() != 2) {
event.consume();
Expand All @@ -117,7 +118,8 @@ protected final Region createSimple() {
}
});
button.addEventFilter(MouseEvent.MOUSE_PRESSED, event -> {
var notOnButton = NodeHelper.isParent(iconChooser, event.getTarget()) || NodeHelper.isParent(buttonBar, event.getTarget());
var notOnButton = NodeHelper.isParent(iconChooser, event.getTarget())
|| NodeHelper.isParent(buttonBar, event.getTarget());
if (AppPrefs.get().requireDoubleClickForConnections().get() && !notOnButton) {
if (event.getButton() == MouseButton.PRIMARY && event.getClickCount() != 2) {
event.consume();
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/io/xpipe/app/core/AppCache.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package io.xpipe.app.core;

import com.fasterxml.jackson.databind.ObjectMapper;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.util.JsonConfigHelper;
import io.xpipe.core.util.JacksonMapper;

import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.io.FileUtils;
Expand Down
38 changes: 18 additions & 20 deletions app/src/main/java/io/xpipe/app/prefs/ExternalRdpClientType.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
package io.xpipe.app.prefs;

import io.xpipe.app.ext.PrefsChoiceValue;
import io.xpipe.app.ext.ProcessControlProvider;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.terminal.ExternalTerminalType;
import io.xpipe.app.util.*;
import io.xpipe.core.process.CommandBuilder;
import io.xpipe.core.process.OsType;
import io.xpipe.core.process.ShellDialects;
import io.xpipe.core.util.SecretValue;

import lombok.Value;
Expand Down Expand Up @@ -149,24 +146,23 @@ public boolean supportsPasswordPassing() {
}
};

ExternalRdpClientType WINDOWS_APP_MACOS =
new MacOsType("app.windowsApp", "Windows App") {
ExternalRdpClientType WINDOWS_APP_MACOS = new MacOsType("app.windowsApp", "Windows App") {

@Override
public void launch(LaunchConfiguration configuration) throws Exception {
var file = writeConfig(configuration.getConfig());
LocalShell.getShell()
.executeSimpleCommand(CommandBuilder.of()
.add("open", "-a")
.addQuoted("Windows App.app")
.addFile(file.toString()));
}
@Override
public void launch(LaunchConfiguration configuration) throws Exception {
var file = writeConfig(configuration.getConfig());
LocalShell.getShell()
.executeSimpleCommand(CommandBuilder.of()
.add("open", "-a")
.addQuoted("Windows App.app")
.addFile(file.toString()));
}

@Override
public boolean supportsPasswordPassing() {
return false;
}
};
@Override
public boolean supportsPasswordPassing() {
return false;
}
};

ExternalRdpClientType CUSTOM = new CustomType();
List<ExternalRdpClientType> WINDOWS_CLIENTS = List.of(MSTSC, DEVOLUTIONS);
Expand Down Expand Up @@ -204,7 +200,9 @@ static ExternalRdpClientType determineDefault(ExternalRdpClientType existing) {

// Check if detection failed for some reason
if (r == null) {
var def = OsType.getLocal() == OsType.WINDOWS ? MSTSC : OsType.getLocal() == OsType.MACOS ? WINDOWS_APP_MACOS : REMMINA;
var def = OsType.getLocal() == OsType.WINDOWS
? MSTSC
: OsType.getLocal() == OsType.MACOS ? WINDOWS_APP_MACOS : REMMINA;
r = def;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ protected Comp<?> create() {
.pref(prefs.downloadsDirectory)
.addString(prefs.downloadsDirectory)
.pref(prefs.pinLocalMachineOnStartup)
.addToggle(prefs.pinLocalMachineOnStartup)
)
.addToggle(prefs.pinLocalMachineOnStartup))
.buildComp();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ public interface WindowsTerminalType extends ExternalTerminalType, TrackableTerm
static AtomicInteger windowCounter = new AtomicInteger(2);

private static CommandBuilder toCommand(TerminalLaunchConfiguration configuration) throws Exception {
var cmd = CommandBuilder.of().addIf(configuration.isPreferTabs(), "-w", "1", "nt")
.addIf(!configuration.isPreferTabs(),"-w", "" + windowCounter.getAndIncrement());
var cmd = CommandBuilder.of()
.addIf(configuration.isPreferTabs(), "-w", "1", "nt")
.addIf(!configuration.isPreferTabs(), "-w", "" + windowCounter.getAndIncrement());

if (configuration.getColor() != null) {
cmd.add("--tabColor").addQuoted(configuration.getColor().toHexString());
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/java/io/xpipe/app/util/NodeHelper.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package io.xpipe.app.util;

import javafx.scene.Node;
import javafx.scene.Parent;

import java.util.Set;

public class NodeHelper {


public static boolean isParent(Set<Node> parent, Object child) {
return parent.stream().anyMatch(node -> isParent(node, child));
}
Expand Down
37 changes: 20 additions & 17 deletions ext/base/src/main/java/io/xpipe/ext/base/browser/ChgrpAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.value.ObservableValue;
import javafx.scene.Node;

import javafx.scene.control.TextField;

import org.kordamp.ikonli.javafx.FontIcon;

import java.util.List;
Expand Down Expand Up @@ -45,13 +45,15 @@ public boolean isApplicable(BrowserFileSystemTabModel model, List<BrowserEntry>

@Override
public List<BrowserLeafAction> getBranchingActions(BrowserFileSystemTabModel model, List<BrowserEntry> entries) {
return Stream.concat(model.getCache().getGroups().entrySet().stream()
.filter(e -> !e.getValue().equals("nohome")
&& !e.getValue().equals("nogroup")
&& !e.getValue().equals("nobody")
&& (e.getKey().equals(0) || e.getKey() >= 900))
.map(e -> e.getValue())
.map(s -> (BrowserLeafAction) new Chgrp(s)), Stream.of(new Custom()))
return Stream.concat(
model.getCache().getGroups().entrySet().stream()
.filter(e -> !e.getValue().equals("nohome")
&& !e.getValue().equals("nogroup")
&& !e.getValue().equals("nobody")
&& (e.getKey().equals(0) || e.getKey() >= 900))
.map(e -> e.getValue())
.map(s -> (BrowserLeafAction) new Chgrp(s)),
Stream.of(new Custom()))
.toList();
}

Expand Down Expand Up @@ -82,7 +84,6 @@ public void execute(BrowserFileSystemTabModel model, List<BrowserEntry> entries)
}
}


private static class Custom implements BrowserLeafAction {
@Override
public void execute(BrowserFileSystemTabModel model, List<BrowserEntry> entries) {
Expand All @@ -99,19 +100,21 @@ public void execute(BrowserFileSystemTabModel model, List<BrowserEntry> entries)
null,
"finish",
() -> {
model.runCommandAsync(CommandBuilder.of()
.add("chgrp", group.getValue())
.addFiles(entries.stream()
.map(browserEntry ->
browserEntry.getRawFileEntry().getPath())
.toList()), false);
model.runCommandAsync(
CommandBuilder.of()
.add("chgrp", group.getValue())
.addFiles(entries.stream()
.map(browserEntry -> browserEntry
.getRawFileEntry()
.getPath())
.toList()),
false);
},
true));
}

@Override
public ObservableValue<String> getName(
BrowserFileSystemTabModel model, List<BrowserEntry> entries) {
public ObservableValue<String> getName(BrowserFileSystemTabModel model, List<BrowserEntry> entries) {
return new SimpleStringProperty("...");
}
}
Expand Down
21 changes: 11 additions & 10 deletions ext/base/src/main/java/io/xpipe/ext/base/browser/ChmodAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import io.xpipe.app.browser.action.BrowserLeafAction;
import io.xpipe.app.browser.file.BrowserEntry;
import io.xpipe.app.browser.file.BrowserFileSystemTabModel;
import io.xpipe.app.browser.icon.BrowserIcons;
import io.xpipe.app.comp.Comp;
import io.xpipe.app.comp.base.ModalOverlayComp;
import io.xpipe.app.core.AppI18n;
Expand All @@ -14,8 +13,8 @@
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.value.ObservableValue;
import javafx.scene.Node;

import javafx.scene.control.TextField;

import org.kordamp.ikonli.javafx.FontIcon;

import java.util.List;
Expand Down Expand Up @@ -100,19 +99,21 @@ public void execute(BrowserFileSystemTabModel model, List<BrowserEntry> entries)
null,
"finish",
() -> {
model.runCommandAsync(CommandBuilder.of()
.add("chmod", permissions.getValue())
.addFiles(entries.stream()
.map(browserEntry ->
browserEntry.getRawFileEntry().getPath())
.toList()), false);
model.runCommandAsync(
CommandBuilder.of()
.add("chmod", permissions.getValue())
.addFiles(entries.stream()
.map(browserEntry -> browserEntry
.getRawFileEntry()
.getPath())
.toList()),
false);
},
true));
}

@Override
public ObservableValue<String> getName(
BrowserFileSystemTabModel model, List<BrowserEntry> entries) {
public ObservableValue<String> getName(BrowserFileSystemTabModel model, List<BrowserEntry> entries) {
return new SimpleStringProperty("...");
}
}
Expand Down
35 changes: 19 additions & 16 deletions ext/base/src/main/java/io/xpipe/ext/base/browser/ChownAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.value.ObservableValue;
import javafx.scene.Node;

import javafx.scene.control.TextField;

import org.kordamp.ikonli.javafx.FontIcon;

import java.util.List;
Expand Down Expand Up @@ -45,12 +45,14 @@ public boolean isApplicable(BrowserFileSystemTabModel model, List<BrowserEntry>

@Override
public List<BrowserLeafAction> getBranchingActions(BrowserFileSystemTabModel model, List<BrowserEntry> entries) {
return Stream.concat(model.getCache().getUsers().entrySet().stream()
.filter(e -> !e.getValue().equals("nohome")
&& !e.getValue().equals("nobody")
&& (e.getKey().equals(0) || e.getKey() >= 900))
.map(e -> e.getValue())
.map(s -> (BrowserLeafAction) new Chown(s)), Stream.of(new Custom()))
return Stream.concat(
model.getCache().getUsers().entrySet().stream()
.filter(e -> !e.getValue().equals("nohome")
&& !e.getValue().equals("nobody")
&& (e.getKey().equals(0) || e.getKey() >= 900))
.map(e -> e.getValue())
.map(s -> (BrowserLeafAction) new Chown(s)),
Stream.of(new Custom()))
.toList();
}

Expand Down Expand Up @@ -81,7 +83,6 @@ public void execute(BrowserFileSystemTabModel model, List<BrowserEntry> entries)
}
}


private static class Custom implements BrowserLeafAction {
@Override
public void execute(BrowserFileSystemTabModel model, List<BrowserEntry> entries) {
Expand All @@ -98,19 +99,21 @@ public void execute(BrowserFileSystemTabModel model, List<BrowserEntry> entries)
null,
"finish",
() -> {
model.runCommandAsync(CommandBuilder.of()
.add("chown", user.getValue())
.addFiles(entries.stream()
.map(browserEntry ->
browserEntry.getRawFileEntry().getPath())
.toList()), false);
model.runCommandAsync(
CommandBuilder.of()
.add("chown", user.getValue())
.addFiles(entries.stream()
.map(browserEntry -> browserEntry
.getRawFileEntry()
.getPath())
.toList()),
false);
},
true));
}

@Override
public ObservableValue<String> getName(
BrowserFileSystemTabModel model, List<BrowserEntry> entries) {
public ObservableValue<String> getName(BrowserFileSystemTabModel model, List<BrowserEntry> entries) {
return new SimpleStringProperty("...");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,11 @@ public static List<DataStoreEntryRef<ScriptStore>> getEnabledScripts() {

public static List<DataStoreEntryRef<SimpleScriptStore>> flatten(List<DataStoreEntryRef<ScriptStore>> scripts) {
var seen = new LinkedHashSet<DataStoreEntryRef<SimpleScriptStore>>();
scripts.stream().filter(scriptStoreDataStoreEntryRef -> scriptStoreDataStoreEntryRef.get().getValidity().isUsable())
.forEach(scriptStoreDataStoreEntryRef -> scriptStoreDataStoreEntryRef.getStore().queryFlattenedScripts(seen));
scripts.stream()
.filter(scriptStoreDataStoreEntryRef ->
scriptStoreDataStoreEntryRef.get().getValidity().isUsable())
.forEach(scriptStoreDataStoreEntryRef ->
scriptStoreDataStoreEntryRef.getStore().queryFlattenedScripts(seen));

var dependencies =
new HashMap<DataStoreEntryRef<? extends ScriptStore>, Set<DataStoreEntryRef<SimpleScriptStore>>>();
Expand Down

0 comments on commit ed24ad9

Please sign in to comment.