Skip to content

Commit

Permalink
Reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
crschnick committed Oct 13, 2024
1 parent d4ad1d2 commit e894390
Show file tree
Hide file tree
Showing 35 changed files with 286 additions and 174 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import lombok.SneakyThrows;
import lombok.Value;

import java.util.ArrayList;
import java.util.List;

@Value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ public void downloadSingle(Item item) {
public void transferToDownloads() throws Exception {
List<Item> toMove;
synchronized (items) {
toMove = items.stream().filter(item -> item.downloadFinished().get()).toList();
toMove =
items.stream().filter(item -> item.downloadFinished().get()).toList();
if (toMove.isEmpty()) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ 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()))
.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 @@ -42,8 +42,12 @@ public static FileConflictChoice showFileConflictAlert(String file, boolean mult
alert.setHeaderText(AppI18n.get("fileConflictAlertHeader"));
alert.setAlertType(Alert.AlertType.CONFIRMATION);
alert.getButtonTypes().clear();
alert.getDialogPane().setContent(AppWindowHelper.alertContentText(AppI18n.get(
multiple ? "fileConflictAlertContentMultiple" : "fileConflictAlertContent", file), w - 50));
alert.getDialogPane()
.setContent(AppWindowHelper.alertContentText(
AppI18n.get(
multiple ? "fileConflictAlertContentMultiple" : "fileConflictAlertContent",
file),
w - 50));
alert.getDialogPane().setMinWidth(w);
alert.getDialogPane().setPrefWidth(w);
alert.getDialogPane().setMaxWidth(w);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import java.util.List;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.Consumer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class BrowserFileTransferOperation {
Expand Down Expand Up @@ -65,7 +64,8 @@ private void updateProgress(BrowserTransferProgress progress) {
this.progress.accept(progress);
}

private BrowserAlerts.FileConflictChoice handleChoice(FileSystem fileSystem, String target, boolean multiple) throws Exception {
private BrowserAlerts.FileConflictChoice handleChoice(FileSystem fileSystem, String target, boolean multiple)
throws Exception {
if (lastConflictChoice == BrowserAlerts.FileConflictChoice.CANCEL) {
return BrowserAlerts.FileConflictChoice.CANCEL;
}
Expand Down Expand Up @@ -168,7 +168,8 @@ private void handleSingleOnSameFileSystem(FileEntry source) throws Exception {

if (checkConflicts) {
var fileConflictChoice = handleChoice(target.getFileSystem(), targetFile, files.size() > 1);
if (fileConflictChoice == BrowserAlerts.FileConflictChoice.SKIP || fileConflictChoice == BrowserAlerts.FileConflictChoice.CANCEL) {
if (fileConflictChoice == BrowserAlerts.FileConflictChoice.SKIP
|| fileConflictChoice == BrowserAlerts.FileConflictChoice.CANCEL) {
return;
}

Expand Down Expand Up @@ -204,9 +205,11 @@ private String renameFile(String target) {
if (matcher.matches()) {
try {
var number = Integer.parseInt(matcher.group(2));
var newFile = targetFile.getParent().join(matcher.group(1) + " (" + (number + 1) + ")." + matcher.group(3));
var newFile =
targetFile.getParent().join(matcher.group(1) + " (" + (number + 1) + ")." + matcher.group(3));
return newFile.toString();
} catch (NumberFormatException e) {}
} catch (NumberFormatException e) {
}
}

var noExt = targetFile.getFileName().equals(targetFile.getExtension());
Expand Down Expand Up @@ -275,8 +278,10 @@ private void handleSingleAcrossFileSystems(FileEntry source) throws Exception {
target.getFileSystem().mkdirs(targetFile);
} else if (sourceFile.getKind() == FileKind.FILE) {
if (checkConflicts) {
var fileConflictChoice = handleChoice(target.getFileSystem(), targetFile, files.size() > 1 || flatFiles.size() > 1);
if (fileConflictChoice == BrowserAlerts.FileConflictChoice.SKIP || fileConflictChoice == BrowserAlerts.FileConflictChoice.CANCEL) {
var fileConflictChoice =
handleChoice(target.getFileSystem(), targetFile, files.size() > 1 || flatFiles.size() > 1);
if (fileConflictChoice == BrowserAlerts.FileConflictChoice.SKIP
|| fileConflictChoice == BrowserAlerts.FileConflictChoice.CANCEL) {
continue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import io.xpipe.app.browser.BrowserSavedState;
import io.xpipe.app.browser.BrowserSavedStateImpl;
import io.xpipe.app.browser.BrowserTransferProgress;
import io.xpipe.app.browser.action.BranchAction;
import io.xpipe.app.browser.action.BrowserAction;
import io.xpipe.app.browser.file.BrowserFileListModel;
import io.xpipe.app.browser.file.BrowserFileTransferMode;
Expand All @@ -26,8 +25,8 @@
import io.xpipe.core.process.ShellOpenFunction;
import io.xpipe.core.store.*;
import io.xpipe.core.util.FailableConsumer;

import io.xpipe.core.util.FailableRunnable;

import javafx.beans.binding.Bindings;
import javafx.beans.property.*;

Expand Down Expand Up @@ -451,15 +450,19 @@ public void runCommandAsync(CommandBuilder command, boolean refresh) {
return;
}

fileSystem.getShell().orElseThrow().command(command).withWorkingDirectory(getCurrentDirectory().getPath()).execute();
fileSystem
.getShell()
.orElseThrow()
.command(command)
.withWorkingDirectory(getCurrentDirectory().getPath())
.execute();
if (refresh) {
refreshSync();
}
});
});
}


public void runAsync(FailableRunnable<Exception> r, boolean refresh) {
if (name == null || name.isBlank()) {
return;
Expand Down
13 changes: 7 additions & 6 deletions app/src/main/java/io/xpipe/app/comp/base/SideMenuBarComp.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
import io.xpipe.app.fxcomps.util.PlatformThread;
import io.xpipe.app.update.UpdateAvailableAlert;
import io.xpipe.app.update.XPipeDistributionType;

import io.xpipe.app.util.Hyperlinks;

import javafx.application.Platform;
import javafx.beans.binding.Bindings;
import javafx.beans.property.Property;
Expand Down Expand Up @@ -146,15 +146,16 @@ public CompStructure<VBox> createBase() {
var now = Instant.now();
var phStart = ZonedDateTime.of(2024, 10, 22, 0, 1, 0, 0, zone).toInstant();
var phEnd = ZonedDateTime.of(2024, 10, 23, 0, 1, 0, 0, zone).toInstant();
var clicked = AppCache.get("phClicked",Boolean.class,() -> false);
var clicked = AppCache.get("phClicked", Boolean.class, () -> false);
var phShow = now.isAfter(phStart) && now.isBefore(phEnd) && !clicked;
if (phShow) {
var hide = new SimpleBooleanProperty(false);
var b = new IconButtonComp(new LabelGraphic.ImageGraphic("app:producthunt-color.png", 24), () -> {
AppCache.update("phClicked", true);
Hyperlinks.open(Hyperlinks.PRODUCT_HUNT);
hide.set(true);
}).tooltip(new SimpleStringProperty("Product Hunt"));
AppCache.update("phClicked", true);
Hyperlinks.open(Hyperlinks.PRODUCT_HUNT);
hide.set(true);
})
.tooltip(new SimpleStringProperty("Product Hunt"));
b.apply(struc -> {
AppFont.setSize(struc.get(), 1);
});
Expand Down
6 changes: 2 additions & 4 deletions app/src/main/java/io/xpipe/app/core/AppExtensionManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ public static void init(boolean loadProviders) throws Exception {
ErrorEvent.fromThrowable(t).handle();
});
} catch (Throwable t) {
throw ExtensionException.corrupt(
"Service provider initialization failed", t);
throw ExtensionException.corrupt("Service provider initialization failed", t);
}
}
}
Expand Down Expand Up @@ -206,8 +205,7 @@ private Optional<Extension> parseExtensionDirectory(Path dir, ModuleLayer parent
var ext = getExtensionFromDir(layer, dir);
if (ext.isEmpty()) {
if (AppProperties.get().isFullVersion()) {
throw ExtensionException.corrupt(
"Unable to load extension from directory " + dir);
throw ExtensionException.corrupt("Unable to load extension from directory " + dir);
}
} else {
if (loadedExtensions.stream()
Expand Down
1 change: 0 additions & 1 deletion app/src/main/java/io/xpipe/app/core/AppLayoutModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import javafx.beans.property.Property;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.value.ObservableValue;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyCodeCombination;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
public class AppJavaOptionsCheck {

public static void check() {
if (AppCache.get("javaOptionsWarningShown", Boolean.class,() -> false)) {
if (AppCache.get("javaOptionsWarningShown", Boolean.class, () -> false)) {
return;
}

Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/io/xpipe/app/core/check/AppShellCheck.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ public static void check() throws Exception {

// We don't want to fall back on macOS as occasional zsh spawn issues would cause many users to use sh
var canFallback = !ProcessControlProvider.get()
.getEffectiveLocalDialect()
.equals(ProcessControlProvider.get().getFallbackDialect()) &&
OsType.getLocal() != OsType.MACOS;
.getEffectiveLocalDialect()
.equals(ProcessControlProvider.get().getFallbackDialect())
&& OsType.getLocal() != OsType.MACOS;
if (err.isPresent() && canFallback) {
var msg = formatMessage(err.get().getMessage());
ErrorEvent.fromThrowable(new IllegalStateException(msg)).handle();
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/io/xpipe/app/ext/ExtensionException.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ public ExtensionException(String message, Throwable cause, boolean enableSuppres
public static ExtensionException corrupt(String message, Throwable cause) {
try {
var loc = XPipeInstallation.getCurrentInstallationBasePath();
var full = message + ".\n\n" + "Please check whether the XPipe installation data at " + loc + " is corrupted.";
var full =
message + ".\n\n" + "Please check whether the XPipe installation data at " + loc + " is corrupted.";
return new ExtensionException(full, cause);
} catch (Throwable t) {
var full = message + ".\n\n" + "Please check whether the XPipe installation data is corrupted.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
import io.xpipe.app.fxcomps.CompStructure;
import io.xpipe.app.fxcomps.SimpleCompStructure;
import io.xpipe.app.fxcomps.util.PlatformThread;

import javafx.beans.property.Property;
import javafx.collections.FXCollections;
import javafx.scene.control.ComboBox;
import javafx.scene.control.ListCell;
import javafx.scene.control.ListView;
import javafx.scene.control.TextField;
import javafx.scene.input.KeyCode;
import javafx.util.Callback;

Expand All @@ -22,7 +22,10 @@ public class ComboTextFieldComp extends Comp<CompStructure<ComboBox<String>>> {
private final List<String> predefinedValues;
private final Callback<ListView<String>, ListCell<String>> customCellFactory;

public ComboTextFieldComp(Property<String> value, List<String> predefinedValues, Callback<ListView<String>, ListCell<String>> customCellFactory) {
public ComboTextFieldComp(
Property<String> value,
List<String> predefinedValues,
Callback<ListView<String>, ListCell<String>> customCellFactory) {
this.value = value;
this.predefinedValues = predefinedValues;
this.customCellFactory = customCellFactory;
Expand All @@ -40,7 +43,8 @@ public CompStructure<ComboBox<String>> createBase() {
value.addListener((c, o, n) -> {
PlatformThread.runLaterIfNeeded(() -> {
// Check if control value is the same. Then don't set it as that might cause bugs
if (Objects.equals(text.getValue(), n) || (n == null && text.getValue().isEmpty())) {
if (Objects.equals(text.getValue(), n)
|| (n == null && text.getValue().isEmpty())) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,22 @@
import io.xpipe.app.fxcomps.Comp;
import io.xpipe.app.fxcomps.CompStructure;
import io.xpipe.app.fxcomps.SimpleCompStructure;
import io.xpipe.app.fxcomps.augment.GrowAugment;
import io.xpipe.app.fxcomps.util.PlatformThread;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.storage.ContextualFileReference;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.storage.DataStoreEntryRef;
import io.xpipe.app.terminal.ExternalTerminalType;
import io.xpipe.core.store.FileNames;
import io.xpipe.core.store.FileSystemStore;

import javafx.application.Platform;
import javafx.beans.property.Property;
import javafx.beans.property.SimpleObjectProperty;
import javafx.scene.control.Cell;
import javafx.scene.control.ComboBox;
import javafx.scene.control.ListCell;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;

import atlantafx.base.theme.Styles;
import javafx.scene.paint.Color;
import lombok.Value;
import org.kordamp.ikonli.javafx.FontIcon;

Expand All @@ -53,9 +47,10 @@ public static class PreviousFileReference {
private final List<PreviousFileReference> previousFileReferences;

public <T extends FileSystemStore> ContextualFileReferenceChoiceComp(
Property<DataStoreEntryRef<T>> fileSystem, Property<String> filePath, boolean allowSync,
List<PreviousFileReference> previousFileReferences
) {
Property<DataStoreEntryRef<T>> fileSystem,
Property<String> filePath,
boolean allowSync,
List<PreviousFileReference> previousFileReferences) {
this.allowSync = allowSync;
this.previousFileReferences = previousFileReferences;
this.fileSystem = new SimpleObjectProperty<>();
Expand Down Expand Up @@ -145,7 +140,9 @@ public CompStructure<HBox> createBase() {
}

private Comp<?> createComboBox() {
var items = previousFileReferences.stream().map(previousFileReference -> previousFileReference.getPath().toString()).toList();
var items = previousFileReferences.stream()
.map(previousFileReference -> previousFileReference.getPath().toString())
.toList();
var combo = new ComboTextFieldComp(filePath, items, param -> {
return new ListCell<>() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@ protected Region createSimple() {
sp.styleClass("store-category-bar");
sp.apply(struc -> {
Region content = (Region) struc.get().getContent();
struc.get().minHeightProperty().bind(Bindings.createDoubleBinding(() -> {
var h = content.getHeight();
return Math.min(200, h + 2);
}, content.heightProperty()));
struc.get()
.minHeightProperty()
.bind(Bindings.createDoubleBinding(
() -> {
var h = content.getHeight();
return Math.min(200, h + 2);
},
content.heightProperty()));
});
return sp.createRegion();
}
Expand Down
7 changes: 5 additions & 2 deletions app/src/main/java/io/xpipe/app/issue/SentryErrorHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import io.xpipe.app.core.AppProperties;
import io.xpipe.app.core.AppState;
import io.xpipe.app.core.mode.OperationMode;
import io.xpipe.app.ext.ProcessControlProvider;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.update.XPipeDistributionType;
import io.xpipe.app.util.LicenseProvider;
Expand Down Expand Up @@ -164,7 +163,11 @@ private static void fillScope(ErrorEvent ee, IScope s) {

s.setTag("diagnostics", Boolean.toString(ee.isShouldSendDiagnostics()));
s.setTag("licenseRequired", Boolean.toString(ee.isLicenseRequired()));
s.setTag("fallbackShell", AppPrefs.get() != null ? String.valueOf(AppPrefs.get().useLocalFallbackShell().get()) : "unknown");
s.setTag(
"fallbackShell",
AppPrefs.get() != null
? String.valueOf(AppPrefs.get().useLocalFallbackShell().get())
: "unknown");

var exMessage = ee.getThrowable() != null ? ee.getThrowable().getMessage() : null;
if (ee.getDescription() != null
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/io/xpipe/app/launcher/LauncherCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ public static void runLauncher(String[] args) {
cmd.execute(args);
} catch (Throwable t) {
// Fix serialization issues with exception class
var converted = t instanceof CommandLine.UnmatchedArgumentException u ? new IllegalArgumentException(u.getMessage()) : t;
var converted = t instanceof CommandLine.UnmatchedArgumentException u
? new IllegalArgumentException(u.getMessage())
: t;
var e = ErrorEvent.fromThrowable(converted).term().build();
// Print error in case we launched from the command-line
new LogErrorHandler().handle(e);
Expand Down
7 changes: 6 additions & 1 deletion app/src/main/java/io/xpipe/app/prefs/AppPrefs.java
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,12 @@ private void fixInvalidLocalValues() {
}

// Fix erroneous fallback shell set on macOS
if (OsType.getLocal() == OsType.MACOS && AppProperties.get().getCanonicalVersion().map(v -> v.getMajor() == 12 && v.getMinor() == 2).orElse(false) && XPipeSession.get().isNewBuildSession()) {
if (OsType.getLocal() == OsType.MACOS
&& AppProperties.get()
.getCanonicalVersion()
.map(v -> v.getMajor() == 12 && v.getMinor() == 2)
.orElse(false)
&& XPipeSession.get().isNewBuildSession()) {
useLocalFallbackShell.setValue(false);
}

Expand Down
Loading

0 comments on commit e894390

Please sign in to comment.