From 0274ade54722577ea776e227934ef2988e7ef107 Mon Sep 17 00:00:00 2001 From: crschnick Date: Fri, 16 Jun 2023 03:38:39 +0000 Subject: [PATCH] Refactor and cleanup --- .../main/java/io/xpipe/api/DataSource.java | 18 +-- .../io/xpipe/api/DataTableAccumulator.java | 2 +- .../api/connector/XPipeApiConnection.java | 8 +- .../api/impl/DataTableAccumulatorImpl.java | 4 +- .../java/io/xpipe/api/impl/DataTableImpl.java | 1 - .../io/xpipe/app/browser/BrowserAlerts.java | 9 +- .../app/browser/BrowserBookmarkList.java | 4 +- .../app/browser/BrowserBreadcrumbBar.java | 4 +- .../xpipe/app/browser/BrowserClipboard.java | 2 +- .../io/xpipe/app/browser/BrowserComp.java | 15 ++- .../xpipe/app/browser/BrowserContextMenu.java | 5 +- .../app/browser/BrowserFileListCompEntry.java | 29 +++-- .../app/browser/BrowserFileListModel.java | 5 +- .../app/browser/BrowserFileOverviewComp.java | 2 +- .../io/xpipe/app/browser/BrowserModel.java | 5 +- .../io/xpipe/app/browser/BrowserNavBar.java | 41 +++++-- .../app/browser/BrowserOverviewComp.java | 7 +- .../app/browser/BrowserStatusBarComp.java | 58 +++++---- .../app/browser/BrowserTransferComp.java | 107 +++++++++-------- .../xpipe/app/browser/FileSystemHelper.java | 5 +- .../app/browser/OpenFileSystemCache.java | 3 +- .../xpipe/app/browser/OpenFileSystemComp.java | 3 +- .../app/browser/OpenFileSystemHistory.java | 8 +- .../app/browser/OpenFileSystemModel.java | 12 +- .../app/browser/OpenFileSystemSavedState.java | 4 +- .../browser/action/ApplicationPathAction.java | 4 +- .../app/browser/action/BrowserAction.java | 19 +-- .../action/ExecuteApplicationAction.java | 11 +- .../xpipe/app/browser/action/LeafAction.java | 2 +- .../browser/action/MultiExecuteAction.java | 11 +- .../browser/action/ToFileCommandAction.java | 6 +- .../xpipe/app/browser/icon/BrowserIcons.java | 2 + .../xpipe/app/browser/icon/DirectoryType.java | 17 ++- .../app/browser/icon/FileIconManager.java | 11 +- .../io/xpipe/app/browser/icon/FileType.java | 7 +- .../java/io/xpipe/app/comp/AppLayoutComp.java | 11 +- .../io/xpipe/app/comp/base/ButtonComp.java | 2 +- .../app/comp/base/DescriptionButtonComp.java | 1 - .../app/comp/base/IntegratedTextAreaComp.java | 5 +- .../app/comp/base/LazyTextFieldComp.java | 23 ++-- .../io/xpipe/app/comp/base/MultiStepComp.java | 6 +- .../xpipe/app/comp/base/SideMenuBarComp.java | 14 ++- .../source/DataSourceTargetChoiceComp.java | 10 +- .../app/comp/source/DsCollectionComp.java | 6 +- .../app/comp/source/DsDataTransferComp.java | 4 +- .../app/comp/source/DsProviderChoiceComp.java | 3 +- .../comp/source/DsStorageGroupSelector.java | 2 +- .../app/comp/source/DsStructureComp.java | 6 +- .../app/comp/source/DsTableMappingComp.java | 2 +- .../comp/source/GuiDsCreatorMultiStep.java | 6 +- .../comp/source/NamedSourceChoiceComp.java | 2 +- .../source/store/DataStoreSelectorComp.java | 15 ++- .../store/DsLocalDirectoryBrowseComp.java | 11 +- .../source/store/DsLocalFileBrowseComp.java | 3 +- .../store/DsStoreProviderChoiceComp.java | 4 +- .../source/store/DsStreamStoreChoiceComp.java | 10 +- .../comp/source/store/GuiDsStoreCreator.java | 83 ++++++++----- .../source/store/NamedStoreChoiceComp.java | 8 +- .../app/comp/storage/DataStoreTypeComp.java | 2 +- .../xpipe/app/comp/storage/StorageFilter.java | 2 +- .../SourceCollectionLayoutComp.java | 7 +- .../collection/SourceCollectionSortMode.java | 8 +- .../collection/SourceCollectionWrapper.java | 7 +- .../source/SourceEntryContextMenu.java | 1 - .../source/SourceEntryDisplayMode.java | 4 +- .../storage/source/SourceEntryWrapper.java | 12 +- .../storage/store/StoreCreationBarComp.java | 21 ++-- .../comp/storage/store/StoreEntryComp.java | 15 ++- .../store/StoreEntryFlatMiniSectionComp.java | 3 +- .../storage/store/StoreEntryListComp.java | 9 +- .../comp/storage/store/StoreEntrySection.java | 3 +- .../comp/storage/store/StoreIntroComp.java | 15 +-- .../app/comp/storage/store/StoreSection.java | 41 +++---- .../xpipe/app/core/AppActionLinkDetector.java | 3 +- .../java/io/xpipe/app/core/AppCharsets.java | 2 +- .../xpipe/app/core/AppExtensionManager.java | 6 +- .../main/java/io/xpipe/app/core/AppI18n.java | 24 ++-- .../java/io/xpipe/app/core/AppImages.java | 8 +- .../java/io/xpipe/app/core/AppMainWindow.java | 2 +- .../java/io/xpipe/app/core/AppProperties.java | 3 +- .../java/io/xpipe/app/core/AppResources.java | 3 +- .../io/xpipe/app/core/AppSocketServer.java | 14 +-- .../io/xpipe/app/core/AppSplashScreen.java | 3 +- .../main/java/io/xpipe/app/core/AppStyle.java | 1 - .../main/java/io/xpipe/app/core/AppTheme.java | 6 +- .../io/xpipe/app/core/AppWindowHelper.java | 3 +- .../io/xpipe/app/core/mode/OperationMode.java | 2 +- .../io/xpipe/app/core/mode/PlatformMode.java | 5 +- .../app/exchange/AskpassExchangeImpl.java | 19 +-- .../xpipe/app/exchange/FocusExchangeImpl.java | 2 +- .../xpipe/app/exchange/OpenExchangeImpl.java | 2 +- .../exchange/ProxyFunctionExchangeImpl.java | 2 +- .../ProxyReadConnectionExchangeImpl.java | 2 +- .../app/exchange/VersionExchangeImpl.java | 2 +- .../exchange/cli/InstanceExchangeImpl.java | 2 +- .../cli/ListCollectionsExchangeImpl.java | 2 +- .../exchange/cli/ListStoresExchangeImpl.java | 2 +- .../exchange/cli/RenameStoreExchangeImpl.java | 2 +- .../cli/SourceProviderListExchangeImpl.java | 2 +- .../app/exchange/cli/StatusExchangeImpl.java | 2 +- .../app/exchange/cli/StopExchangeImpl.java | 2 +- .../exchange/cli/StoreAddExchangeImpl.java | 4 +- .../cli/StoreProviderListExchangeImpl.java | 2 +- .../java/io/xpipe/app/ext/ActionProvider.java | 20 ++-- .../io/xpipe/app/ext/DataSourceProvider.java | 8 +- .../io/xpipe/app/ext/DataSourceTarget.java | 13 +- .../io/xpipe/app/ext/DataStoreProvider.java | 28 +++-- .../xpipe/app/ext/DownloadModuleInstall.java | 6 +- .../xpipe/app/ext/XPipeServiceProviders.java | 2 +- .../main/java/io/xpipe/app/fxcomps/Comp.java | 1 - .../app/fxcomps/impl/CharChoiceComp.java | 2 +- .../io/xpipe/app/fxcomps/impl/ChoiceComp.java | 2 +- .../app/fxcomps/impl/ChoicePaneComp.java | 2 +- .../app/fxcomps/impl/CodeSnippetComp.java | 3 +- .../app/fxcomps/impl/DataStoreChoiceComp.java | 4 +- .../app/fxcomps/impl/FancyTooltipAugment.java | 8 +- .../app/fxcomps/impl/FileStoreChoiceComp.java | 9 +- .../impl/FileSystemStoreChoiceComp.java | 5 +- .../app/fxcomps/impl/IconButtonComp.java | 2 +- .../xpipe/app/fxcomps/impl/OptionsComp.java | 13 +- .../app/fxcomps/impl/PrettyImageComp.java | 31 ++--- .../xpipe/app/fxcomps/impl/SvgCacheComp.java | 59 +++++----- .../io/xpipe/app/fxcomps/impl/SvgView.java | 12 +- .../xpipe/app/fxcomps/impl/TextFieldComp.java | 26 ++-- .../app/fxcomps/impl/WriteModeChoiceComp.java | 3 +- .../app/fxcomps/util/BindingsHelper.java | 3 +- .../io/xpipe/app/issue/AttachmentHelper.java | 9 +- .../java/io/xpipe/app/issue/ErrorAction.java | 6 +- .../io/xpipe/app/issue/ErrorDetailsComp.java | 8 +- .../java/io/xpipe/app/issue/ErrorEvent.java | 4 +- .../io/xpipe/app/issue/ErrorHandlerComp.java | 20 +++- .../java/io/xpipe/app/issue/EventHandler.java | 2 +- .../xpipe/app/issue/SentryErrorHandler.java | 6 +- .../xpipe/app/issue/TerminalErrorHandler.java | 8 +- .../java/io/xpipe/app/issue/TrackEvent.java | 1 - .../xpipe/app/launcher/LauncherCommand.java | 4 +- .../io/xpipe/app/launcher/LauncherInput.java | 2 +- .../app/launcher/LauncherModeConverter.java | 2 +- .../java/io/xpipe/app/prefs/AboutComp.java | 14 ++- .../io/xpipe/app/prefs/AppPreferencesFx.java | 8 +- .../java/io/xpipe/app/prefs/AppPrefs.java | 51 ++++---- .../io/xpipe/app/prefs/CloseBehaviour.java | 5 +- .../xpipe/app/prefs/CustomFormRenderer.java | 7 +- .../xpipe/app/prefs/CustomToggleControl.java | 111 +++++++++--------- .../xpipe/app/prefs/ExternalEditorType.java | 52 ++++---- .../xpipe/app/prefs/ExternalTerminalType.java | 8 +- .../java/io/xpipe/app/prefs/PrefFields.java | 2 +- .../xpipe/app/{comp => prefs}/PrefsComp.java | 5 +- .../io/xpipe/app/prefs/PropertiesComp.java | 8 +- .../java/io/xpipe/app/prefs/SecretField.java | 5 +- .../io/xpipe/app/prefs/UpdateCheckComp.java | 39 ++++-- .../app/storage/DataSourceCollection.java | 2 +- .../io/xpipe/app/storage/DataSourceEntry.java | 2 +- .../io/xpipe/app/storage/DataStorage.java | 24 ++-- .../xpipe/app/storage/DataStorageWriter.java | 4 +- .../io/xpipe/app/storage/DataStoreEntry.java | 24 +++- .../io/xpipe/app/storage/StandardStorage.java | 6 +- .../io/xpipe/app/storage/StorageElement.java | 2 +- .../xpipe/app/test/DaemonExtensionTest.java | 2 +- .../io/xpipe/app/test/LocalExtensionTest.java | 2 +- .../java/io/xpipe/app/test/TestModule.java | 2 +- .../io/xpipe/app/update/AppDownloads.java | 7 +- .../io/xpipe/app/update/AppInstaller.java | 41 ++++--- .../io/xpipe/app/update/ChocoUpdater.java | 8 +- .../io/xpipe/app/update/GitHubUpdater.java | 4 +- .../io/xpipe/app/update/HomebrewUpdater.java | 3 - .../io/xpipe/app/update/PortableUpdater.java | 15 +-- .../app/update/UpdateAvailableAlert.java | 11 +- .../app/update/UpdateChangelogAlert.java | 3 +- .../app/update/XPipeDistributionType.java | 5 +- .../xpipe/app/update/XPipeInstanceHelper.java | 2 +- .../io/xpipe/app/util/ApplicationHelper.java | 6 +- .../app/util/DataTypeParserInternal.java | 6 +- .../io/xpipe/app/util/DefaultSecretValue.java | 1 - .../io/xpipe/app/util/DesktopShortcuts.java | 21 ++-- .../java/io/xpipe/app/util/DialogHelper.java | 5 +- .../xpipe/app/util/DynamicOptionsBuilder.java | 5 +- .../java/io/xpipe/app/util/FileBridge.java | 3 +- .../java/io/xpipe/app/util/Hyperlinks.java | 27 ++--- .../io/xpipe/app/util/LockChangeAlert.java | 10 +- .../io/xpipe/app/util/LockedSecretValue.java | 4 +- .../io/xpipe/app/util/NamedCharacter.java | 2 +- .../io/xpipe/app/util/OptionsBuilder.java | 16 +-- .../java/io/xpipe/app/util/PlatformState.java | 1 - .../io/xpipe/app/util/PrettyListView.java | 3 +- .../app/util/ProxyManagerProviderImpl.java | 4 +- .../java/io/xpipe/app/util/ScriptHelper.java | 19 ++- .../java/io/xpipe/app/util/SmoothScroll.java | 9 +- .../io/xpipe/app/util/TerminalHelper.java | 5 +- .../java/io/xpipe/app/util/UnlockAlert.java | 6 +- .../java/io/xpipe/app/util/Validator.java | 23 ++-- .../java/io/xpipe/app/util/XPipeSession.java | 5 +- app/src/main/java/module-info.java | 6 +- .../java/io/xpipe/beacon/BeaconClient.java | 3 - .../java/io/xpipe/beacon/BeaconFormat.java | 4 +- .../java/io/xpipe/beacon/BeaconProxyImpl.java | 5 +- .../java/io/xpipe/beacon/BeaconServer.java | 11 +- .../beacon/exchange/AskpassExchange.java | 2 + .../xpipe/beacon/exchange/LaunchExchange.java | 3 +- .../io/xpipe/core/charsetter/Charsetter.java | 2 +- .../java/io/xpipe/core/dialog/Dialog.java | 23 ++-- .../io/xpipe/core/dialog/DialogElement.java | 2 +- .../io/xpipe/core/dialog/HeaderElement.java | 2 +- .../io/xpipe/core/dialog/QueryConverter.java | 53 ++++----- .../java/io/xpipe/core/impl/FileNames.java | 6 +- .../io/xpipe/core/impl/InMemoryStore.java | 4 +- .../io/xpipe/core/impl/InputStreamStore.java | 2 +- .../java/io/xpipe/core/impl/NamedStore.java | 4 +- .../io/xpipe/core/impl/OutputStreamStore.java | 4 +- .../core/impl/SimpleTableWriteConnection.java | 6 +- .../io/xpipe/core/impl/SinkDrainStore.java | 8 +- .../io/xpipe/core/impl/StdinDataStore.java | 5 +- .../io/xpipe/core/impl/StdoutDataStore.java | 7 +- .../xpipe/core/impl/TextReadConnection.java | 2 +- .../io/xpipe/core/process/CommandControl.java | 27 +++-- .../java/io/xpipe/core/process/OsType.java | 17 ++- .../core/process/PropertiesFormatsParser.java | 12 +- .../io/xpipe/core/process/ShellControl.java | 14 +-- .../io/xpipe/core/process/ShellDialect.java | 22 ++-- .../core/source/CollectionDataSource.java | 6 +- .../core/source/CollectionReadConnection.java | 2 +- .../source/CollectionWriteConnection.java | 2 +- .../core/source/DataSourceReference.java | 6 +- .../io/xpipe/core/source/RawDataSource.java | 4 +- .../core/source/StructureDataSource.java | 4 +- .../io/xpipe/core/source/TableDataSource.java | 2 +- .../core/source/TableReadConnection.java | 10 +- .../core/source/TableWriteConnection.java | 4 +- .../io/xpipe/core/source/TextDataSource.java | 4 +- .../core/store/CommandExecutionStore.java | 2 +- .../core/store/ConnectionFileSystem.java | 47 +++++--- .../java/io/xpipe/core/store/DataStore.java | 2 +- .../xpipe/core/store/DelegateShellStore.java | 2 +- .../java/io/xpipe/core/store/FileKind.java | 3 +- .../java/io/xpipe/core/store/FileSystem.java | 47 ++++---- .../io/xpipe/core/store/LeafShellStore.java | 4 +- .../java/io/xpipe/core/store/ShellStore.java | 8 +- .../io/xpipe/core/util/CoreJacksonModule.java | 9 +- .../java/io/xpipe/core/util/Deobfuscator.java | 2 +- .../io/xpipe/core/util/JacksonMapper.java | 4 +- .../io/xpipe/core/util/ModuleLayerLoader.java | 6 +- .../io/xpipe/core/util/ProxyFunction.java | 4 +- .../java/io/xpipe/core/util/SecretValue.java | 10 +- .../core/util/XPipeExecTempDirectory.java | 5 +- .../io/xpipe/core/util/XPipeInstallation.java | 11 +- core/src/main/java/module-info.java | 4 +- .../xpipe/ext/base/BinarySourceProvider.java | 2 +- .../io/xpipe/ext/base/FileStoreProvider.java | 7 +- .../java/io/xpipe/ext/base/HttpStore.java | 2 +- .../io/xpipe/ext/base/HttpStoreProvider.java | 6 +- .../xpipe/ext/base/InMemoryStoreProvider.java | 4 +- .../ext/base/InternalStreamProvider.java | 2 +- .../ext/base/SimpleCollectionSource.java | 6 +- .../base/SimpleFileDataSourceProvider.java | 2 +- .../ext/base/SinkDrainStoreProvider.java | 6 +- .../io/xpipe/ext/base/TextSourceProvider.java | 6 +- .../java/io/xpipe/ext/base/XpbsProvider.java | 2 +- .../java/io/xpipe/ext/base/XpbtProvider.java | 2 +- .../ext/base/actions/AddStoreAction.java | 5 +- .../actions/DeleteStoreChildrenAction.java | 11 +- .../ext/base/actions/EditStoreAction.java | 18 +-- .../ext/base/actions/FileBrowseAction.java | 4 +- .../ext/base/actions/FileEditAction.java | 4 +- .../xpipe/ext/base/actions/SampleAction.java | 25 ++-- .../ext/base/actions/ShareStoreAction.java | 9 +- .../ext/base/actions/StreamExportAction.java | 4 +- .../ext/base/apps/DataSourceOutputTarget.java | 12 +- .../xpipe/ext/base/apps/FileOutputTarget.java | 28 ++--- .../ext/base/apps/RawFileOutputTarget.java | 27 ++--- .../xpipe/ext/base/apps/SaveSourceTarget.java | 13 +- .../browser/BrowseInNativeManagerAction.java | 15 ++- .../io/xpipe/ext/base/browser/CopyAction.java | 5 +- .../ext/base/browser/CopyPathAction.java | 52 +++++--- .../ext/base/browser/EditFileAction.java | 2 +- .../xpipe/ext/base/browser/NewItemAction.java | 49 +++++--- .../ext/base/browser/OpenDirectoryAction.java | 5 +- .../browser/OpenDirectoryInNewTabAction.java | 12 +- .../base/browser/OpenFileDefaultAction.java | 2 +- .../ext/base/browser/OpenFileWithAction.java | 3 +- .../browser/OpenNativeFileDetailsAction.java | 11 +- .../ext/base/browser/OpenTerminalAction.java | 4 +- .../xpipe/ext/base/browser/PasteAction.java | 9 +- .../xpipe/ext/base/browser/RenameAction.java | 2 +- .../io/xpipe/ext/base/browser/RunAction.java | 7 +- .../xpipe/ext/base/browser/UnzipAction.java | 6 +- .../ext/collections/ArchiveEntryStore.java | 4 +- .../collections/ArchiveReadConnection.java | 56 +++++---- .../ext/collections/DirectoryProvider.java | 16 +-- .../java/io/xpipe/ext/csv/CsvHeaderState.java | 4 +- .../io/xpipe/ext/csv/CsvSourceProvider.java | 9 +- .../xpipe/ext/jackson/json/JsonProvider.java | 6 +- .../jackson/json_table/JsonTableProvider.java | 6 +- .../io/xpipe/ext/jackson/xml/XmlProvider.java | 4 +- .../jackson/xml_table/XmlTableProvider.java | 6 +- .../io/xpipe/ext/pdx/Eu4FileProvider.java | 2 +- .../io/xpipe/ext/pdx/PdxTextFileProvider.java | 4 +- .../ext/pdx/parser/TextFormatParser.java | 10 +- .../ext/pdx/parser/TextFormatTokenizer.java | 2 +- .../ext/pdx/savegame/SavegameParseResult.java | 8 +- 299 files changed, 1634 insertions(+), 1335 deletions(-) rename app/src/main/java/io/xpipe/app/{comp => prefs}/PrefsComp.java (94%) diff --git a/api/src/main/java/io/xpipe/api/DataSource.java b/api/src/main/java/io/xpipe/api/DataSource.java index 6ee3b73c2..b81f8233b 100644 --- a/api/src/main/java/io/xpipe/api/DataSource.java +++ b/api/src/main/java/io/xpipe/api/DataSource.java @@ -98,14 +98,14 @@ public interface DataSource { /** * Wrapper for {@link #create(DataSourceId, String, InputStream)} that creates an anonymous data source. */ - public static DataSource createAnonymous(String type, Path path) { + static DataSource createAnonymous(String type, Path path) { return create(null, type, path); } /** * Wrapper for {@link #create(DataSourceId, String, InputStream)}. */ - public static DataSource create(DataSourceId id, String type, Path path) { + static DataSource create(DataSourceId id, String type, Path path) { try (var in = Files.newInputStream(path)) { return create(id, type, in); } catch (IOException e) { @@ -116,14 +116,14 @@ public interface DataSource { /** * Wrapper for {@link #create(DataSourceId, String, InputStream)} that creates an anonymous data source. */ - public static DataSource createAnonymous(String type, URL url) { + static DataSource createAnonymous(String type, URL url) { return create(null, type, url); } /** * Wrapper for {@link #create(DataSourceId, String, InputStream)}. */ - public static DataSource create(DataSourceId id, String type, URL url) { + static DataSource create(DataSourceId id, String type, URL url) { try (var in = url.openStream()) { return create(id, type, in); } catch (IOException e) { @@ -134,7 +134,7 @@ public interface DataSource { /** * Wrapper for {@link #create(DataSourceId, String, InputStream)} that creates an anonymous data source. */ - public static DataSource createAnonymous(String type, InputStream in) { + static DataSource createAnonymous(String type, InputStream in) { return create(null, type, in); } @@ -146,7 +146,7 @@ public interface DataSource { * @param in the input stream to read * @return a {@link DataSource} instances that can be used to access the underlying data */ - public static DataSource create(DataSourceId id, String type, InputStream in) { + static DataSource create(DataSourceId id, String type, InputStream in) { return DataSourceImpl.create(id, type, in); } @@ -156,7 +156,7 @@ public interface DataSource { * @param id the data source id * @return a {@link DataSource} instances that can be used to access the underlying data */ - public static DataSource create(DataSourceId id, io.xpipe.core.source.DataSource source) { + static DataSource create(DataSourceId id, io.xpipe.core.source.DataSource source) { return DataSourceImpl.create(id, source); } @@ -169,7 +169,7 @@ public interface DataSource { * @param in the data store to add * @return a {@link DataSource} instances that can be used to access the underlying data */ - public static DataSource create(DataSourceId id, String type, DataStore in) { + static DataSource create(DataSourceId id, String type, DataStore in) { return DataSourceImpl.create(id, type, in); } @@ -177,7 +177,7 @@ public interface DataSource { void appendTo(DataSource target); - public io.xpipe.core.source.DataSource getInternalSource(); + io.xpipe.core.source.DataSource getInternalSource(); /** * Returns the id of this data source. diff --git a/api/src/main/java/io/xpipe/api/DataTableAccumulator.java b/api/src/main/java/io/xpipe/api/DataTableAccumulator.java index e8808117c..5b8897946 100644 --- a/api/src/main/java/io/xpipe/api/DataTableAccumulator.java +++ b/api/src/main/java/io/xpipe/api/DataTableAccumulator.java @@ -15,7 +15,7 @@ import io.xpipe.core.source.DataSourceId; */ public interface DataTableAccumulator { - public static DataTableAccumulator create(TupleType type) { + static DataTableAccumulator create(TupleType type) { return new DataTableAccumulatorImpl(type); } diff --git a/api/src/main/java/io/xpipe/api/connector/XPipeApiConnection.java b/api/src/main/java/io/xpipe/api/connector/XPipeApiConnection.java index 7a13756af..6cbddc497 100644 --- a/api/src/main/java/io/xpipe/api/connector/XPipeApiConnection.java +++ b/api/src/main/java/io/xpipe/api/connector/XPipeApiConnection.java @@ -137,14 +137,14 @@ public final class XPipeApiConnection extends BeaconConnection { } @FunctionalInterface - public static interface Handler { + public interface Handler { - void handle(BeaconConnection con) throws Exception; + void handle(BeaconConnection con); } @FunctionalInterface - public static interface Mapper { + public interface Mapper { - T handle(BeaconConnection con) throws Exception; + T handle(BeaconConnection con); } } diff --git a/api/src/main/java/io/xpipe/api/impl/DataTableAccumulatorImpl.java b/api/src/main/java/io/xpipe/api/impl/DataTableAccumulatorImpl.java index 3591fba67..1a9a65838 100644 --- a/api/src/main/java/io/xpipe/api/impl/DataTableAccumulatorImpl.java +++ b/api/src/main/java/io/xpipe/api/impl/DataTableAccumulatorImpl.java @@ -28,9 +28,9 @@ public class DataTableAccumulatorImpl implements DataTableAccumulator { private final XPipeApiConnection connection; private final TupleType type; private int rows; - private InternalStreamStore store; + private final InternalStreamStore store; private TupleType writtenDescriptor; - private OutputStream bodyOutput; + private final OutputStream bodyOutput; public DataTableAccumulatorImpl(TupleType type) { this.type = type; diff --git a/api/src/main/java/io/xpipe/api/impl/DataTableImpl.java b/api/src/main/java/io/xpipe/api/impl/DataTableImpl.java index 465c8fd8e..e61f3ebd7 100644 --- a/api/src/main/java/io/xpipe/api/impl/DataTableImpl.java +++ b/api/src/main/java/io/xpipe/api/impl/DataTableImpl.java @@ -70,7 +70,6 @@ public class DataTableImpl extends DataSourceImpl implements DataTable { public Iterator iterator() { return new TableIterator(); } - ; private class TableIterator implements Iterator { diff --git a/app/src/main/java/io/xpipe/app/browser/BrowserAlerts.java b/app/src/main/java/io/xpipe/app/browser/BrowserAlerts.java index 6cb4f3dfb..674d15744 100644 --- a/app/src/main/java/io/xpipe/app/browser/BrowserAlerts.java +++ b/app/src/main/java/io/xpipe/app/browser/BrowserAlerts.java @@ -19,7 +19,8 @@ public class BrowserAlerts { return AppWindowHelper.showBlockingAlert(alert -> { alert.setTitle(AppI18n.get("moveAlertTitle")); alert.setHeaderText(AppI18n.get("moveAlertHeader", source.size(), target.getPath())); - alert.getDialogPane().setContent(AppWindowHelper.alertContentText(getSelectedElementsString(source))); + alert.getDialogPane() + .setContent(AppWindowHelper.alertContentText(getSelectedElementsString(source))); alert.setAlertType(Alert.AlertType.CONFIRMATION); }) .map(b -> b.getButtonData().isDefaultButton()) @@ -34,7 +35,8 @@ public class BrowserAlerts { return AppWindowHelper.showBlockingAlert(alert -> { alert.setTitle(AppI18n.get("deleteAlertTitle")); alert.setHeaderText(AppI18n.get("deleteAlertHeader", source.size())); - alert.getDialogPane().setContent(AppWindowHelper.alertContentText(getSelectedElementsString(source))); + alert.getDialogPane() + .setContent(AppWindowHelper.alertContentText(getSelectedElementsString(source))); alert.setAlertType(Alert.AlertType.CONFIRMATION); }) .map(b -> b.getButtonData().isDefaultButton()) @@ -43,7 +45,8 @@ public class BrowserAlerts { private static String getSelectedElementsString(List source) { var namesHeader = AppI18n.get("selectedElements"); - var names = namesHeader + "\n" + source.stream().limit(10).map(entry -> "- " + entry.getPath()).collect(Collectors.joining("\n")); + var names = namesHeader + "\n" + + source.stream().limit(10).map(entry -> "- " + entry.getPath()).collect(Collectors.joining("\n")); if (source.size() > 10) { names += "\n+ " + (source.size() - 10) + " ..."; } diff --git a/app/src/main/java/io/xpipe/app/browser/BrowserBookmarkList.java b/app/src/main/java/io/xpipe/app/browser/BrowserBookmarkList.java index 0994dcf3c..2aebaab80 100644 --- a/app/src/main/java/io/xpipe/app/browser/BrowserBookmarkList.java +++ b/app/src/main/java/io/xpipe/app/browser/BrowserBookmarkList.java @@ -45,7 +45,7 @@ final class BrowserBookmarkList extends SimpleComp { @Override protected Region createSimple() { var root = StoreEntryTree.createTree(); - var view = new TreeView(root); + var view = new TreeView<>(root); view.setShowRoot(false); view.getStyleClass().add("bookmark-list"); view.setCellFactory(param -> { @@ -138,7 +138,7 @@ final class BrowserBookmarkList extends SimpleComp { }); event.consume(); }); - var icon = new SimpleObjectProperty("mdal-keyboard_arrow_right"); + var icon = new SimpleObjectProperty<>("mdal-keyboard_arrow_right"); getPseudoClassStates().addListener((SetChangeListener) change -> { if (change.getSet().contains(PseudoClass.getPseudoClass("expanded"))) { icon.set("mdal-keyboard_arrow_down"); diff --git a/app/src/main/java/io/xpipe/app/browser/BrowserBreadcrumbBar.java b/app/src/main/java/io/xpipe/app/browser/BrowserBreadcrumbBar.java index 9193a4d26..1703db3f9 100644 --- a/app/src/main/java/io/xpipe/app/browser/BrowserBreadcrumbBar.java +++ b/app/src/main/java/io/xpipe/app/browser/BrowserBreadcrumbBar.java @@ -25,9 +25,7 @@ public class BrowserBreadcrumbBar extends SimpleComp { @Override protected Region createSimple() { Callback, ButtonBase> crumbFactory = crumb -> { - var name = crumb.getValue().equals("/") - ? "/" - : FileNames.getFileName(crumb.getValue()); + var name = crumb.getValue().equals("/") ? "/" : FileNames.getFileName(crumb.getValue()); var btn = new Button(name, null); btn.setMnemonicParsing(false); btn.setFocusTraversable(false); diff --git a/app/src/main/java/io/xpipe/app/browser/BrowserClipboard.java b/app/src/main/java/io/xpipe/app/browser/BrowserClipboard.java index 85f6ca4be..b757351ea 100644 --- a/app/src/main/java/io/xpipe/app/browser/BrowserClipboard.java +++ b/app/src/main/java/io/xpipe/app/browser/BrowserClipboard.java @@ -21,7 +21,7 @@ public class BrowserClipboard { List entries; } - public static Property currentCopyClipboard = new SimpleObjectProperty<>(); + public static final Property currentCopyClipboard = new SimpleObjectProperty<>(); public static Instance currentDragClipboard; @SneakyThrows diff --git a/app/src/main/java/io/xpipe/app/browser/BrowserComp.java b/app/src/main/java/io/xpipe/app/browser/BrowserComp.java index 17dcae9aa..39ad0a00a 100644 --- a/app/src/main/java/io/xpipe/app/browser/BrowserComp.java +++ b/app/src/main/java/io/xpipe/app/browser/BrowserComp.java @@ -22,14 +22,16 @@ import javafx.beans.binding.Bindings; import javafx.beans.property.SimpleBooleanProperty; import javafx.beans.property.SimpleStringProperty; import javafx.collections.ListChangeListener; -import javafx.event.EventHandler; import javafx.geometry.Insets; import javafx.geometry.Orientation; import javafx.geometry.Pos; import javafx.scene.Node; import javafx.scene.control.*; import javafx.scene.input.DragEvent; -import javafx.scene.layout.*; +import javafx.scene.layout.HBox; +import javafx.scene.layout.Priority; +import javafx.scene.layout.Region; +import javafx.scene.layout.VBox; import java.util.HashMap; import java.util.Map; @@ -252,12 +254,9 @@ public class BrowserComp extends SimpleComp { var label = new Label(model.getName()); label.setTextOverrun(OverrunStyle.CENTER_ELLIPSIS); - label.addEventHandler(DragEvent.DRAG_ENTERED, new EventHandler() { - @Override - public void handle(DragEvent mouseEvent) { - Platform.runLater(() -> tabs.getSelectionModel().select(tab)); - } - }); + label.addEventHandler( + DragEvent.DRAG_ENTERED, + mouseEvent -> Platform.runLater(() -> tabs.getSelectionModel().select(tab))); label.graphicProperty() .bind(Bindings.createObjectBinding( diff --git a/app/src/main/java/io/xpipe/app/browser/BrowserContextMenu.java b/app/src/main/java/io/xpipe/app/browser/BrowserContextMenu.java index 2e5da48f9..6b49d7f59 100644 --- a/app/src/main/java/io/xpipe/app/browser/BrowserContextMenu.java +++ b/app/src/main/java/io/xpipe/app/browser/BrowserContextMenu.java @@ -26,7 +26,10 @@ final class BrowserContextMenu extends ContextMenu { AppFont.normal(this.getStyleableNode()); var empty = source == null; - var selected = new ArrayList<>(empty ? List.of(new BrowserEntry(model.getCurrentDirectory(), model.getFileList(), false)) : model.getFileList().getSelection()); + var selected = new ArrayList<>( + empty + ? List.of(new BrowserEntry(model.getCurrentDirectory(), model.getFileList(), false)) + : model.getFileList().getSelection()); if (source != null && !selected.contains(source)) { selected.add(source); } diff --git a/app/src/main/java/io/xpipe/app/browser/BrowserFileListCompEntry.java b/app/src/main/java/io/xpipe/app/browser/BrowserFileListCompEntry.java index a34b13611..d99153aff 100644 --- a/app/src/main/java/io/xpipe/app/browser/BrowserFileListCompEntry.java +++ b/app/src/main/java/io/xpipe/app/browser/BrowserFileListCompEntry.java @@ -49,19 +49,26 @@ public class BrowserFileListCompEntry { } if (t.getButton() == MouseButton.PRIMARY && t.isShiftDown()) { - var tv = ((TableView) row.getParent().getParent().getParent().getParent()); + var tv = ((TableView) + row.getParent().getParent().getParent().getParent()); var all = tv.getItems(); - var min = tv.getSelectionModel().getSelectedIndices().stream().mapToInt(value -> value).min().orElse(1); - var max = tv.getSelectionModel().getSelectedIndices().stream().mapToInt(value -> value).max().orElse(all.size() - 1); + var min = tv.getSelectionModel().getSelectedIndices().stream() + .mapToInt(value -> value) + .min() + .orElse(1); + var max = tv.getSelectionModel().getSelectedIndices().stream() + .mapToInt(value -> value) + .max() + .orElse(all.size() - 1); var end = tv.getSelectionModel().getFocusedIndex(); var start = end > min ? min : max; tv.getSelectionModel().selectRange(Math.min(start, end), Math.max(start, end) + 1); - return; } } public boolean isSynthetic() { - return item != null && item.getRawFileEntry().equals(model.getFileSystemModel().getCurrentParentDirectory()); + return item != null + && item.getRawFileEntry().equals(model.getFileSystemModel().getCurrentParentDirectory()); } private boolean acceptsDrop(DragEvent event) { @@ -80,8 +87,10 @@ public class BrowserFileListCompEntry { // Prevent drag and drops of files into the current directory if (BrowserClipboard.currentDragClipboard - .getBaseDirectory().getPath() - .equals(model.getFileSystemModel().getCurrentDirectory().getPath()) && (item == null || item.getRawFileEntry().getKind() != FileKind.DIRECTORY)) { + .getBaseDirectory() + .getPath() + .equals(model.getFileSystemModel().getCurrentDirectory().getPath()) + && (item == null || item.getRawFileEntry().getKind() != FileKind.DIRECTORY)) { return false; } @@ -152,7 +161,8 @@ public class BrowserFileListCompEntry { } private void acceptDrag(DragEvent event) { - model.getDraggedOverEmpty().setValue(item == null || item.getRawFileEntry().getKind() != FileKind.DIRECTORY); + model.getDraggedOverEmpty() + .setValue(item == null || item.getRawFileEntry().getKind() != FileKind.DIRECTORY); model.getDraggedOverDirectory().setValue(item); event.acceptTransferModes(TransferMode.COPY_OR_MOVE); } @@ -205,7 +215,8 @@ public class BrowserFileListCompEntry { return; } - var tv = ((TableView) row.getParent().getParent().getParent().getParent()); + var tv = ((TableView) + row.getParent().getParent().getParent().getParent()); tv.getSelectionModel().select(item); } diff --git a/app/src/main/java/io/xpipe/app/browser/BrowserFileListModel.java b/app/src/main/java/io/xpipe/app/browser/BrowserFileListModel.java index a867554ea..f30732a5b 100644 --- a/app/src/main/java/io/xpipe/app/browser/BrowserFileListModel.java +++ b/app/src/main/java/io/xpipe/app/browser/BrowserFileListModel.java @@ -38,7 +38,7 @@ public final class BrowserFileListModel { private final ObservableList selectedRaw = BindingsHelper.mappedContentBinding(selection, entry -> entry.getRawFileEntry()); - private final Property draggedOverDirectory = new SimpleObjectProperty(); + private final Property draggedOverDirectory = new SimpleObjectProperty<>(); private final Property draggedOverEmpty = new SimpleBooleanProperty(); private final Property editing = new SimpleObjectProperty<>(); @@ -113,7 +113,8 @@ public final class BrowserFileListModel { } public void onDoubleClick(BrowserEntry entry) { - if (entry.getRawFileEntry().getKind() != FileKind.DIRECTORY && getMode().equals(BrowserModel.Mode.SINGLE_FILE_CHOOSER)) { + if (entry.getRawFileEntry().getKind() != FileKind.DIRECTORY + && getMode().equals(BrowserModel.Mode.SINGLE_FILE_CHOOSER)) { getFileSystemModel().getBrowserModel().finishChooser(); return; } diff --git a/app/src/main/java/io/xpipe/app/browser/BrowserFileOverviewComp.java b/app/src/main/java/io/xpipe/app/browser/BrowserFileOverviewComp.java index 3e0c0ebb0..0bb081633 100644 --- a/app/src/main/java/io/xpipe/app/browser/BrowserFileOverviewComp.java +++ b/app/src/main/java/io/xpipe/app/browser/BrowserFileOverviewComp.java @@ -35,7 +35,7 @@ public class BrowserFileOverviewComp extends SimpleComp { event.consume(); }); l.setAlignment(Pos.CENTER_LEFT); - GrowAugment.create(true,false).augment(l); + GrowAugment.create(true, false).augment(l); return l; }); }; diff --git a/app/src/main/java/io/xpipe/app/browser/BrowserModel.java b/app/src/main/java/io/xpipe/app/browser/BrowserModel.java index 44b0654b1..0ea33550e 100644 --- a/app/src/main/java/io/xpipe/app/browser/BrowserModel.java +++ b/app/src/main/java/io/xpipe/app/browser/BrowserModel.java @@ -34,7 +34,7 @@ public class BrowserModel { } @Getter - public static enum Mode { + public enum Mode { BROWSER(false, true, true, true), SINGLE_FILE_CHOOSER(true, false, true, false), SINGLE_FILE_SAVE(true, false, true, false), @@ -80,7 +80,8 @@ public class BrowserModel { var map = new LinkedHashMap(); openFileSystems.forEach(model -> { var storageEntry = DataStorage.get().getStoreEntryIfPresent(model.getStore()); - storageEntry.ifPresent(entry -> map.put(entry.getUuid(), model.getCurrentPath().get())); + storageEntry.ifPresent( + entry -> map.put(entry.getUuid(), model.getCurrentPath().get())); }); // Don't override state if it is empty diff --git a/app/src/main/java/io/xpipe/app/browser/BrowserNavBar.java b/app/src/main/java/io/xpipe/app/browser/BrowserNavBar.java index cece59b0d..be4cf6b59 100644 --- a/app/src/main/java/io/xpipe/app/browser/BrowserNavBar.java +++ b/app/src/main/java/io/xpipe/app/browser/BrowserNavBar.java @@ -51,11 +51,16 @@ public class BrowserNavBar extends SimpleComp { .styleClass("path-text") .apply(struc -> { SimpleChangeListener.apply(struc.get().focusedProperty(), val -> { - struc.get().pseudoClassStateChanged(INVISIBLE, !val && !model.getInOverview().get()); + struc.get() + .pseudoClassStateChanged( + INVISIBLE, + !val && !model.getInOverview().get()); }); SimpleChangeListener.apply(model.getInOverview(), val -> { - struc.get().pseudoClassStateChanged(INVISIBLE, !val && !struc.get().isFocused()); + struc.get() + .pseudoClassStateChanged( + INVISIBLE, !val && !struc.get().isFocused()); }); struc.get().setOnMouseClicked(event -> { @@ -69,9 +74,11 @@ public class BrowserNavBar extends SimpleComp { }); struc.get().setPromptText("Overview of " + model.getName()); - }).shortcut(new KeyCodeCombination(KeyCode.F, KeyCombination.SHORTCUT_DOWN), s -> { + }) + .shortcut(new KeyCodeCombination(KeyCode.F, KeyCombination.SHORTCUT_DOWN), s -> { s.get().requestFocus(); - }).accessibleText("Current path"); + }) + .accessibleText("Current path"); var graphic = Bindings.createStringBinding( () -> { @@ -90,10 +97,9 @@ public class BrowserNavBar extends SimpleComp { graphicButton.setAccessibleText("Directory options"); graphicButton.getStyleClass().add(Styles.LEFT_PILL); graphicButton.getStyleClass().add("path-graphic-button"); - new ContextMenuAugment<>( - event -> event.getButton() == MouseButton.PRIMARY, () -> { - return model.getInOverview().get() ? null : new BrowserContextMenu(model, null); - }) + new ContextMenuAugment<>(event -> event.getButton() == MouseButton.PRIMARY, () -> { + return model.getInOverview().get() ? null : new BrowserContextMenu(model, null); + }) .augment(new SimpleCompStructure<>(graphicButton)); var breadcrumbs = new BrowserBreadcrumbBar(model).grow(false, true); @@ -104,17 +110,26 @@ public class BrowserNavBar extends SimpleComp { .apply(struc -> { var t = struc.get().getChildren().get(0); var b = struc.get().getChildren().get(1); - b.visibleProperty().bind(Bindings.createBooleanBinding(() -> { - return !t.isFocused() && !model.getInOverview().get(); - }, t.focusedProperty(), model.getInOverview())); + b.visibleProperty() + .bind(Bindings.createBooleanBinding( + () -> { + return !t.isFocused() + && !model.getInOverview().get(); + }, + t.focusedProperty(), + model.getInOverview())); }) .grow(false, true); var topBox = new HorizontalComp(List.of(Comp.of(() -> graphicButton), stack)) .apply(struc -> struc.get().setAlignment(Pos.CENTER_LEFT)) .apply(struc -> { - ((Region) struc.get().getChildren().get(0)).minHeightProperty().bind(((Region) struc.get().getChildren().get(1)).heightProperty()); - ((Region) struc.get().getChildren().get(0)).maxHeightProperty().bind(((Region) struc.get().getChildren().get(1)).heightProperty()); + ((Region) struc.get().getChildren().get(0)) + .minHeightProperty() + .bind(((Region) struc.get().getChildren().get(1)).heightProperty()); + ((Region) struc.get().getChildren().get(0)) + .maxHeightProperty() + .bind(((Region) struc.get().getChildren().get(1)).heightProperty()); }) .apply(struc -> { struc.get().setPickOnBounds(false); diff --git a/app/src/main/java/io/xpipe/app/browser/BrowserOverviewComp.java b/app/src/main/java/io/xpipe/app/browser/BrowserOverviewComp.java index 4e06fd587..fb388b0c9 100644 --- a/app/src/main/java/io/xpipe/app/browser/BrowserOverviewComp.java +++ b/app/src/main/java/io/xpipe/app/browser/BrowserOverviewComp.java @@ -33,7 +33,9 @@ public class BrowserOverviewComp extends SimpleComp { .map(s -> FileSystem.FileEntry.ofDirectory(model.getFileSystem(), s)) .filter(entry -> { try { - var b = sc.getShellDialect().directoryExists(sc, entry.getPath()).executeAndCheck(); + var b = sc.getShellDialect() + .directoryExists(sc, entry.getPath()) + .executeAndCheck(); return b; } catch (Exception e) { ErrorEvent.fromThrowable(e).handle(); @@ -42,7 +44,8 @@ public class BrowserOverviewComp extends SimpleComp { }) .toList(); var commonOverview = new BrowserFileOverviewComp(model, FXCollections.observableArrayList(common), false); - var commonPane = new SimpleTitledPaneComp(AppI18n.observable("common"), commonOverview).apply(struc -> VBox.setVgrow(struc.get(), Priority.NEVER)); + var commonPane = new SimpleTitledPaneComp(AppI18n.observable("common"), commonOverview) + .apply(struc -> VBox.setVgrow(struc.get(), Priority.NEVER)); var roots = sc.getShellDialect() .listRoots(sc) diff --git a/app/src/main/java/io/xpipe/app/browser/BrowserStatusBarComp.java b/app/src/main/java/io/xpipe/app/browser/BrowserStatusBarComp.java index eec14ac26..430499eda 100644 --- a/app/src/main/java/io/xpipe/app/browser/BrowserStatusBarComp.java +++ b/app/src/main/java/io/xpipe/app/browser/BrowserStatusBarComp.java @@ -22,36 +22,44 @@ public class BrowserStatusBarComp extends SimpleComp { @Override protected Region createSimple() { var cc = PlatformThread.sync(BrowserClipboard.currentCopyClipboard); - var ccCount = Bindings.createStringBinding(() -> { - if (cc.getValue() != null && cc.getValue().getEntries().size() > 0) { - return cc.getValue().getEntries().size() + " file" + (cc.getValue().getEntries().size() > 1 ? "s" : "") + " in clipboard"; - } else { - return null; - } - }, cc); + var ccCount = Bindings.createStringBinding( + () -> { + if (cc.getValue() != null && cc.getValue().getEntries().size() > 0) { + return cc.getValue().getEntries().size() + " file" + + (cc.getValue().getEntries().size() > 1 ? "s" : "") + " in clipboard"; + } else { + return null; + } + }, + cc); - var selectedCount = PlatformThread.sync(Bindings.createIntegerBinding(() -> { - return model.getFileList().getSelection().size(); - }, model.getFileList().getSelection())); + var selectedCount = PlatformThread.sync(Bindings.createIntegerBinding( + () -> { + return model.getFileList().getSelection().size(); + }, + model.getFileList().getSelection())); - var allCount = PlatformThread.sync(Bindings.createIntegerBinding(() -> { - return (int) model.getFileList().getAll().getValue().stream().filter(entry -> !entry.isSynthetic()).count(); - }, model.getFileList().getAll())); + var allCount = PlatformThread.sync(Bindings.createIntegerBinding( + () -> { + return (int) model.getFileList().getAll().getValue().stream() + .filter(entry -> !entry.isSynthetic()) + .count(); + }, + model.getFileList().getAll())); - var selectedComp = new LabelComp(Bindings.createStringBinding(() -> { - if (selectedCount.getValue().intValue() == 0) { - return null; - } else { - return selectedCount.getValue() + " / " + allCount.getValue() + " selected"; - } - }, selectedCount, allCount)); + var selectedComp = new LabelComp(Bindings.createStringBinding( + () -> { + if (selectedCount.getValue().intValue() == 0) { + return null; + } else { + return selectedCount.getValue() + " / " + allCount.getValue() + " selected"; + } + }, + selectedCount, + allCount)); var bar = new ToolBar(); - bar.getItems().setAll( - new LabelComp(ccCount).createRegion(), - new Spacer(), - selectedComp.createRegion() - ); + bar.getItems().setAll(new LabelComp(ccCount).createRegion(), new Spacer(), selectedComp.createRegion()); bar.getStyleClass().add("status-bar"); bar.setOnDragDetected(event -> { event.consume(); diff --git a/app/src/main/java/io/xpipe/app/browser/BrowserTransferComp.java b/app/src/main/java/io/xpipe/app/browser/BrowserTransferComp.java index b413c89d6..cd0b3931a 100644 --- a/app/src/main/java/io/xpipe/app/browser/BrowserTransferComp.java +++ b/app/src/main/java/io/xpipe/app/browser/BrowserTransferComp.java @@ -41,7 +41,9 @@ public class BrowserTransferComp extends SimpleComp { new StackComp(List.of(background)).grow(true, true).styleClass("download-background"); var binding = BindingsHelper.mappedContentBinding(stage.getItems(), item -> item.getFileEntry()); - var list = new BrowserSelectionListComp(binding).apply(struc -> struc.get().setMinHeight(150)).grow(false, true); + var list = new BrowserSelectionListComp(binding) + .apply(struc -> struc.get().setMinHeight(150)) + .grow(false, true); var dragNotice = new LabelComp(AppI18n.observable("dragFiles")) .apply(struc -> struc.get().setGraphic(new FontIcon("mdi2e-export"))) .hide(BindingsHelper.persist(Bindings.isEmpty(stage.getItems()))) @@ -61,59 +63,64 @@ public class BrowserTransferComp extends SimpleComp { var listBox = new VerticalComp(List.of(list, dragNotice)); var stack = new LoadingOverlayComp( - new StackComp(List.of(backgroundStack, listBox, clearPane)).apply(DragPseudoClassAugment.create()).apply(struc -> { - struc.get().setOnDragOver(event -> { - // Accept drops from inside the app window - if (event.getGestureSource() != null && event.getGestureSource() != struc.get()) { - event.acceptTransferModes(TransferMode.ANY); - event.consume(); - } - }); - struc.get().setOnDragDropped(event -> { - if (event.getGestureSource() != null) { - var files = BrowserClipboard.retrieveDrag(event.getDragboard()) - .getEntries(); - stage.drop(files); - event.setDropCompleted(true); - event.consume(); - } - }); - struc.get().setOnDragDetected(event -> { - if (stage.getDownloading().get()) { - return; - } + new StackComp(List.of(backgroundStack, listBox, clearPane)) + .apply(DragPseudoClassAugment.create()) + .apply(struc -> { + struc.get().setOnDragOver(event -> { + // Accept drops from inside the app window + if (event.getGestureSource() != null && event.getGestureSource() != struc.get()) { + event.acceptTransferModes(TransferMode.ANY); + event.consume(); + } + }); + struc.get().setOnDragDropped(event -> { + if (event.getGestureSource() != null) { + var files = BrowserClipboard.retrieveDrag(event.getDragboard()) + .getEntries(); + stage.drop(files); + event.setDropCompleted(true); + event.consume(); + } + }); + struc.get().setOnDragDetected(event -> { + if (stage.getDownloading().get()) { + return; + } - var files = stage.getItems().stream() - .map(item -> { - try { - return item.getLocalFile().toRealPath().toFile(); - } catch (IOException e) { - throw new RuntimeException(e); - } - }) - .toList(); - Dragboard db = struc.get().startDragAndDrop(TransferMode.MOVE); - var cc = new ClipboardContent(); - cc.putFiles(files); - db.setContent(cc); + var files = stage.getItems().stream() + .map(item -> { + try { + return item.getLocalFile() + .toRealPath() + .toFile(); + } catch (IOException e) { + throw new RuntimeException(e); + } + }) + .toList(); + Dragboard db = struc.get().startDragAndDrop(TransferMode.MOVE); + var cc = new ClipboardContent(); + cc.putFiles(files); + db.setContent(cc); - var image = BrowserSelectionListComp.snapshot(FXCollections.observableList(stage.getItems().stream() - .map(item -> item.getFileEntry()) - .toList())); - db.setDragView(image, -20, 15); + var image = BrowserSelectionListComp.snapshot( + FXCollections.observableList(stage.getItems().stream() + .map(item -> item.getFileEntry()) + .toList())); + db.setDragView(image, -20, 15); - event.setDragDetect(true); - event.consume(); - }); - struc.get().setOnDragDone(event -> { - if (!event.isAccepted()) { - return; - } + event.setDragDetect(true); + event.consume(); + }); + struc.get().setOnDragDone(event -> { + if (!event.isAccepted()) { + return; + } - stage.getItems().clear(); - event.consume(); - }); - }), + stage.getItems().clear(); + event.consume(); + }); + }), PlatformThread.sync(stage.getDownloading())); return stack.createRegion(); } diff --git a/app/src/main/java/io/xpipe/app/browser/FileSystemHelper.java b/app/src/main/java/io/xpipe/app/browser/FileSystemHelper.java index 73bf2b216..06dd9249d 100644 --- a/app/src/main/java/io/xpipe/app/browser/FileSystemHelper.java +++ b/app/src/main/java/io/xpipe/app/browser/FileSystemHelper.java @@ -101,8 +101,7 @@ public class FileSystemHelper { Files.isExecutable(file), Files.size(file), null, - Files.isDirectory(file) ? FileKind.DIRECTORY : FileKind.FILE - ); + Files.isDirectory(file) ? FileKind.DIRECTORY : FileKind.FILE); } public static void dropLocalFilesInto(FileSystem.FileEntry entry, List files) { @@ -122,7 +121,7 @@ public class FileSystemHelper { } } - public static void delete(List files) throws Exception { + public static void delete(List files) { if (files.size() == 0) { return; } diff --git a/app/src/main/java/io/xpipe/app/browser/OpenFileSystemCache.java b/app/src/main/java/io/xpipe/app/browser/OpenFileSystemCache.java index 7252b9297..83ebb703b 100644 --- a/app/src/main/java/io/xpipe/app/browser/OpenFileSystemCache.java +++ b/app/src/main/java/io/xpipe/app/browser/OpenFileSystemCache.java @@ -34,7 +34,8 @@ public class OpenFileSystemCache { public boolean isApplicationInPath(String app) { if (!installedApplications.containsKey(app)) { try { - var b = ApplicationHelper.isInPath(model.getFileSystem().getShell().orElseThrow(), app); + var b = ApplicationHelper.isInPath( + model.getFileSystem().getShell().orElseThrow(), app); installedApplications.put(app, b); } catch (Exception e) { installedApplications.put(app, false); diff --git a/app/src/main/java/io/xpipe/app/browser/OpenFileSystemComp.java b/app/src/main/java/io/xpipe/app/browser/OpenFileSystemComp.java index 142f27f04..1977fb5d3 100644 --- a/app/src/main/java/io/xpipe/app/browser/OpenFileSystemComp.java +++ b/app/src/main/java/io/xpipe/app/browser/OpenFileSystemComp.java @@ -83,7 +83,8 @@ public class OpenFileSystemComp extends SimpleComp { } private Region createFileListContent() { - var directoryView = new BrowserFileListComp(model.getFileList()).apply(struc -> VBox.setVgrow(struc.get(), Priority.ALWAYS)); + var directoryView = new BrowserFileListComp(model.getFileList()) + .apply(struc -> VBox.setVgrow(struc.get(), Priority.ALWAYS)); var statusBar = new BrowserStatusBarComp(model); var fileList = new VerticalComp(List.of(directoryView, statusBar)); diff --git a/app/src/main/java/io/xpipe/app/browser/OpenFileSystemHistory.java b/app/src/main/java/io/xpipe/app/browser/OpenFileSystemHistory.java index ee7b9b5cc..c93316c00 100644 --- a/app/src/main/java/io/xpipe/app/browser/OpenFileSystemHistory.java +++ b/app/src/main/java/io/xpipe/app/browser/OpenFileSystemHistory.java @@ -13,10 +13,10 @@ public final class OpenFileSystemHistory { private final IntegerProperty cursor = new SimpleIntegerProperty(-1); private final List history = new ArrayList<>(); - private final BooleanBinding canGoBack = Bindings.createBooleanBinding( - () -> cursor.get() > 0 && history.size() > 1, cursor); - private final BooleanBinding canGoForth = Bindings.createBooleanBinding( - () -> cursor.get() < history.size() - 1, cursor); + private final BooleanBinding canGoBack = + Bindings.createBooleanBinding(() -> cursor.get() > 0 && history.size() > 1, cursor); + private final BooleanBinding canGoForth = + Bindings.createBooleanBinding(() -> cursor.get() < history.size() - 1, cursor); public String getCurrent() { return history.size() > 0 ? history.get(cursor.get()) : null; diff --git a/app/src/main/java/io/xpipe/app/browser/OpenFileSystemModel.java b/app/src/main/java/io/xpipe/app/browser/OpenFileSystemModel.java index 6026cc1ab..e34eec01f 100644 --- a/app/src/main/java/io/xpipe/app/browser/OpenFileSystemModel.java +++ b/app/src/main/java/io/xpipe/app/browser/OpenFileSystemModel.java @@ -46,9 +46,11 @@ public final class OpenFileSystemModel { this.browserModel = browserModel; this.store = store; this.name = name != null ? name : DataStorage.get().getStoreEntry(store).getName(); - this.inOverview.bind(Bindings.createBooleanBinding(() -> { - return currentPath.get() == null; - }, currentPath)); + this.inOverview.bind(Bindings.createBooleanBinding( + () -> { + return currentPath.get() == null; + }, + currentPath)); fileList = new BrowserFileListModel(this); } @@ -147,7 +149,7 @@ public final class OpenFileSystemModel { return Optional.of(currentPath.get()); } - String dirPath = null; + String dirPath; try { dirPath = FileSystemHelper.validateDirectoryPath(this, normalizedPath); } catch (Exception ex) { @@ -314,7 +316,7 @@ public final class OpenFileSystemModel { cdSyncWithoutCheck(dir); } - public void initWithDefaultDirectory() throws Exception { + public void initWithDefaultDirectory() { savedState.cd(null); history.updateCurrent(null); } diff --git a/app/src/main/java/io/xpipe/app/browser/OpenFileSystemSavedState.java b/app/src/main/java/io/xpipe/app/browser/OpenFileSystemSavedState.java index 96c16fcf5..b495552c8 100644 --- a/app/src/main/java/io/xpipe/app/browser/OpenFileSystemSavedState.java +++ b/app/src/main/java/io/xpipe/app/browser/OpenFileSystemSavedState.java @@ -1,6 +1,5 @@ package io.xpipe.app.browser; -import com.fasterxml.jackson.core.JacksonException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.databind.DeserializationContext; @@ -63,8 +62,7 @@ public class OpenFileSystemSavedState { @Override @SneakyThrows - public OpenFileSystemSavedState deserialize(JsonParser p, DeserializationContext ctxt) - throws IOException, JacksonException { + public OpenFileSystemSavedState deserialize(JsonParser p, DeserializationContext ctxt) { var tree = (ObjectNode) JacksonMapper.getDefault().readTree(p); JavaType javaType = JacksonMapper.getDefault() .getTypeFactory() diff --git a/app/src/main/java/io/xpipe/app/browser/action/ApplicationPathAction.java b/app/src/main/java/io/xpipe/app/browser/action/ApplicationPathAction.java index c6ad770ed..005cab2fa 100644 --- a/app/src/main/java/io/xpipe/app/browser/action/ApplicationPathAction.java +++ b/app/src/main/java/io/xpipe/app/browser/action/ApplicationPathAction.java @@ -7,10 +7,10 @@ import java.util.List; public interface ApplicationPathAction extends BrowserAction { - public abstract String getExecutable(); + String getExecutable(); @Override - public default boolean isActive(OpenFileSystemModel model, List entries) { + default boolean isActive(OpenFileSystemModel model, List entries) { return model.getCache().isApplicationInPath(getExecutable()); } } diff --git a/app/src/main/java/io/xpipe/app/browser/action/BrowserAction.java b/app/src/main/java/io/xpipe/app/browser/action/BrowserAction.java index 27f6cc314..ab5a5d956 100644 --- a/app/src/main/java/io/xpipe/app/browser/action/BrowserAction.java +++ b/app/src/main/java/io/xpipe/app/browser/action/BrowserAction.java @@ -13,7 +13,7 @@ import java.util.ServiceLoader; public interface BrowserAction { - static enum Category { + enum Category { CUSTOM, OPEN, NATIVE, @@ -21,9 +21,9 @@ public interface BrowserAction { MUTATION } - static List ALL = new ArrayList<>(); + List ALL = new ArrayList<>(); - public static List getFlattened() { + static List getFlattened() { return ALL.stream() .map(browserAction -> browserAction instanceof LeafAction ? List.of((LeafAction) browserAction) @@ -33,7 +33,10 @@ public interface BrowserAction { } static LeafAction byId(String id) { - return getFlattened().stream().filter(browserAction -> id.equals(browserAction.getId())).findAny().orElseThrow(); + return getFlattened().stream() + .filter(browserAction -> id.equals(browserAction.getId())) + .findAny() + .orElseThrow(); } default Node getIcon(OpenFileSystemModel model, List entries) { @@ -52,17 +55,17 @@ public interface BrowserAction { return false; } - public abstract String getName(OpenFileSystemModel model, List entries); + String getName(OpenFileSystemModel model, List entries); - public default boolean isApplicable(OpenFileSystemModel model, List entries) { + default boolean isApplicable(OpenFileSystemModel model, List entries) { return true; } - public default boolean isActive(OpenFileSystemModel model, List entries) { + default boolean isActive(OpenFileSystemModel model, List entries) { return true; } - public static class Loader implements ModuleLayerLoader { + class Loader implements ModuleLayerLoader { @Override public void init(ModuleLayer layer) { diff --git a/app/src/main/java/io/xpipe/app/browser/action/ExecuteApplicationAction.java b/app/src/main/java/io/xpipe/app/browser/action/ExecuteApplicationAction.java index c38f78340..22d25ac8b 100644 --- a/app/src/main/java/io/xpipe/app/browser/action/ExecuteApplicationAction.java +++ b/app/src/main/java/io/xpipe/app/browser/action/ExecuteApplicationAction.java @@ -13,8 +13,12 @@ public abstract class ExecuteApplicationAction implements LeafAction, Applicatio public void execute(OpenFileSystemModel model, List entries) throws Exception { ShellControl sc = model.getFileSystem().getShell().orElseThrow(); for (BrowserEntry entry : entries) { - var command = detach() ? ScriptHelper.createDetachCommand(sc, createCommand(model, entry)) : createCommand(model, entry); - try (var cc = sc.command(command).withWorkingDirectory(model.getCurrentDirectory().getPath()).start()) { + var command = detach() + ? ScriptHelper.createDetachCommand(sc, createCommand(model, entry)) + : createCommand(model, entry); + try (var cc = sc.command(command) + .withWorkingDirectory(model.getCurrentDirectory().getPath()) + .start()) { cc.discardOrThrow(); } } @@ -36,6 +40,5 @@ public abstract class ExecuteApplicationAction implements LeafAction, Applicatio return false; } - protected abstract String createCommand(OpenFileSystemModel model, BrowserEntry entry); - + protected abstract String createCommand(OpenFileSystemModel model, BrowserEntry entry); } diff --git a/app/src/main/java/io/xpipe/app/browser/action/LeafAction.java b/app/src/main/java/io/xpipe/app/browser/action/LeafAction.java index 8ed18649c..31ae618d4 100644 --- a/app/src/main/java/io/xpipe/app/browser/action/LeafAction.java +++ b/app/src/main/java/io/xpipe/app/browser/action/LeafAction.java @@ -15,7 +15,7 @@ import java.util.function.UnaryOperator; public interface LeafAction extends BrowserAction { - public abstract void execute(OpenFileSystemModel model, List entries) throws Exception; + void execute(OpenFileSystemModel model, List entries) throws Exception; default Button toButton(OpenFileSystemModel model, List selected) { var b = new Button(); diff --git a/app/src/main/java/io/xpipe/app/browser/action/MultiExecuteAction.java b/app/src/main/java/io/xpipe/app/browser/action/MultiExecuteAction.java index bb5ed81da..08f8d98ec 100644 --- a/app/src/main/java/io/xpipe/app/browser/action/MultiExecuteAction.java +++ b/app/src/main/java/io/xpipe/app/browser/action/MultiExecuteAction.java @@ -25,7 +25,7 @@ public abstract class MultiExecuteAction implements BranchAction { new LeafAction() { @Override - public void execute(OpenFileSystemModel model, List entries) throws Exception { + public void execute(OpenFileSystemModel model, List entries) { model.withShell( pc -> { for (BrowserEntry entry : entries) { @@ -51,12 +51,11 @@ public abstract class MultiExecuteAction implements BranchAction { new LeafAction() { @Override - public void execute(OpenFileSystemModel model, List entries) throws Exception { + public void execute(OpenFileSystemModel model, List entries) { model.withShell( pc -> { for (BrowserEntry entry : entries) { - var cmd = ScriptHelper.createDetachCommand( - pc, createCommand(pc, model, entry)); + var cmd = ScriptHelper.createDetachCommand(pc, createCommand(pc, model, entry)); pc.command(cmd) .withWorkingDirectory(model.getCurrentDirectory() .getPath()) @@ -74,13 +73,13 @@ public abstract class MultiExecuteAction implements BranchAction { new LeafAction() { @Override - public void execute(OpenFileSystemModel model, List entries) throws Exception { + public void execute(OpenFileSystemModel model, List entries) { model.withShell( pc -> { for (BrowserEntry entry : entries) { pc.command(createCommand(pc, model, entry)) .withWorkingDirectory(model.getCurrentDirectory() - .getPath()) + .getPath()) .execute(); } }, diff --git a/app/src/main/java/io/xpipe/app/browser/action/ToFileCommandAction.java b/app/src/main/java/io/xpipe/app/browser/action/ToFileCommandAction.java index 19bbbbe1a..3202aae99 100644 --- a/app/src/main/java/io/xpipe/app/browser/action/ToFileCommandAction.java +++ b/app/src/main/java/io/xpipe/app/browser/action/ToFileCommandAction.java @@ -14,12 +14,14 @@ public abstract class ToFileCommandAction implements LeafAction, ApplicationPath ShellControl sc = model.getFileSystem().getShell().orElseThrow(); for (BrowserEntry entry : entries) { var command = createCommand(model, entry); - try (var cc = sc.command(command).withWorkingDirectory(model.getCurrentDirectory().getPath()).start()) { + try (var cc = sc.command(command) + .withWorkingDirectory(model.getCurrentDirectory().getPath()) + .start()) { cc.discardErr(); FileOpener.openCommandOutput(entry.getFileName(), entry, cc); } } } - protected abstract String createCommand(OpenFileSystemModel model, BrowserEntry entry); + protected abstract String createCommand(OpenFileSystemModel model, BrowserEntry entry); } diff --git a/app/src/main/java/io/xpipe/app/browser/icon/BrowserIcons.java b/app/src/main/java/io/xpipe/app/browser/icon/BrowserIcons.java index 3b3399f69..40dda2134 100644 --- a/app/src/main/java/io/xpipe/app/browser/icon/BrowserIcons.java +++ b/app/src/main/java/io/xpipe/app/browser/icon/BrowserIcons.java @@ -8,9 +8,11 @@ public class BrowserIcons { public static PrettyImageComp createDefaultFileIcon() { return new PrettyImageComp(new SimpleStringProperty("default_file.svg"), 22, 22); } + public static PrettyImageComp createDefaultDirectoryIcon() { return new PrettyImageComp(new SimpleStringProperty("default_folder.svg"), 22, 22); } + public static PrettyImageComp createIcon(FileType type) { return new PrettyImageComp(new SimpleStringProperty(type.getIcon()), 22, 22); } diff --git a/app/src/main/java/io/xpipe/app/browser/icon/DirectoryType.java b/app/src/main/java/io/xpipe/app/browser/icon/DirectoryType.java index 4ffc31cb5..0b91da25d 100644 --- a/app/src/main/java/io/xpipe/app/browser/icon/DirectoryType.java +++ b/app/src/main/java/io/xpipe/app/browser/icon/DirectoryType.java @@ -19,10 +19,13 @@ public interface DirectoryType { List ALL = new ArrayList<>(); static DirectoryType byId(String id) { - return ALL.stream().filter(fileType -> fileType.getId().equals(id)).findAny().orElseThrow(); + return ALL.stream() + .filter(fileType -> fileType.getId().equals(id)) + .findAny() + .orElseThrow(); } - public static void loadDefinitions() { + static void loadDefinitions() { ALL.add(new DirectoryType() { @Override @@ -43,7 +46,7 @@ public interface DirectoryType { AppResources.with(AppResources.XPIPE_MODULE, "folder_list.txt", path -> { try (var reader = - new BufferedReader(new InputStreamReader(Files.newInputStream(path), StandardCharsets.UTF_8))) { + new BufferedReader(new InputStreamReader(Files.newInputStream(path), StandardCharsets.UTF_8))) { String line; while ((line = reader.readLine()) != null) { var split = line.split("\\|"); @@ -70,7 +73,8 @@ public interface DirectoryType { var lightOpenIcon = split.length > 4 ? split[5].trim() : openIcon; ALL.add(new Simple( - id, new IconVariant(lightClosedIcon, closedIcon), + id, + new IconVariant(lightClosedIcon, closedIcon), new IconVariant(lightOpenIcon, openIcon), filter.toArray(String[]::new))); } @@ -82,6 +86,7 @@ public interface DirectoryType { @Getter private final String id; + private final IconVariant closed; private final IconVariant open; private final String[] names; @@ -99,8 +104,8 @@ public interface DirectoryType { return false; } - return Arrays.stream(names).anyMatch(name -> FileNames.getFileName(entry.getPath()) - .equalsIgnoreCase(name)); + return Arrays.stream(names) + .anyMatch(name -> FileNames.getFileName(entry.getPath()).equalsIgnoreCase(name)); } @Override diff --git a/app/src/main/java/io/xpipe/app/browser/icon/FileIconManager.java b/app/src/main/java/io/xpipe/app/browser/icon/FileIconManager.java index cc688c22c..fa2dd25bd 100644 --- a/app/src/main/java/io/xpipe/app/browser/icon/FileIconManager.java +++ b/app/src/main/java/io/xpipe/app/browser/icon/FileIconManager.java @@ -8,12 +8,15 @@ import io.xpipe.core.store.FileSystem; import javafx.scene.image.Image; import lombok.Getter; -import java.util.*; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; public class FileIconManager { @Getter - private static SvgCache svgCache = createCache(); + private static final SvgCache svgCache = createCache(); + private static boolean loaded; private static SvgCache createCache() { @@ -61,7 +64,9 @@ public class FileIconManager { } } - return entry.getKind() == FileKind.DIRECTORY ? (open ? "default_folder_opened.svg" : "default_folder.svg") : "default_file.svg"; + return entry.getKind() == FileKind.DIRECTORY + ? (open ? "default_folder_opened.svg" : "default_folder.svg") + : "default_file.svg"; } private static String getIconPath(String name) { diff --git a/app/src/main/java/io/xpipe/app/browser/icon/FileType.java b/app/src/main/java/io/xpipe/app/browser/icon/FileType.java index a42bd328d..71e803a46 100644 --- a/app/src/main/java/io/xpipe/app/browser/icon/FileType.java +++ b/app/src/main/java/io/xpipe/app/browser/icon/FileType.java @@ -18,10 +18,13 @@ public interface FileType { List ALL = new ArrayList<>(); static FileType byId(String id) { - return ALL.stream().filter(fileType -> fileType.getId().equals(id)).findAny().orElseThrow(); + return ALL.stream() + .filter(fileType -> fileType.getId().equals(id)) + .findAny() + .orElseThrow(); } - public static void loadDefinitions() { + static void loadDefinitions() { AppResources.with(AppResources.XPIPE_MODULE, "file_list.txt", path -> { try (var reader = new BufferedReader(new InputStreamReader(Files.newInputStream(path), StandardCharsets.UTF_8))) { diff --git a/app/src/main/java/io/xpipe/app/comp/AppLayoutComp.java b/app/src/main/java/io/xpipe/app/comp/AppLayoutComp.java index 6d4609f32..acb6c0f14 100644 --- a/app/src/main/java/io/xpipe/app/comp/AppLayoutComp.java +++ b/app/src/main/java/io/xpipe/app/comp/AppLayoutComp.java @@ -9,6 +9,7 @@ import io.xpipe.app.fxcomps.Comp; import io.xpipe.app.fxcomps.CompStructure; import io.xpipe.app.fxcomps.SimpleCompStructure; import io.xpipe.app.prefs.AppPrefs; +import io.xpipe.app.prefs.PrefsComp; import javafx.beans.property.Property; import javafx.beans.property.SimpleObjectProperty; import javafx.scene.input.KeyCode; @@ -41,16 +42,14 @@ public class AppLayoutComp extends Comp> { private List createEntryList() { var l = new ArrayList<>(List.of( new SideMenuBarComp.Entry( - AppI18n.observable("browser"), - "mdi2f-file-cabinet", - new BrowserComp(BrowserModel.DEFAULT)), + AppI18n.observable("browser"), "mdi2f-file-cabinet", new BrowserComp(BrowserModel.DEFAULT)), new SideMenuBarComp.Entry(AppI18n.observable("connections"), "mdi2c-connection", new StoreLayoutComp()), // new SideMenuBarComp.Entry(AppI18n.observable("data"), "mdsal-dvr", new SourceCollectionLayoutComp()), new SideMenuBarComp.Entry( AppI18n.observable("settings"), "mdsmz-miscellaneous_services", new PrefsComp(this)))); - // new SideMenuBarComp.Entry(AppI18n.observable("help"), "mdi2b-book-open-variant", new - // StorageLayoutComp()), - // new SideMenuBarComp.Entry(AppI18n.observable("account"), "mdi2a-account", new StorageLayoutComp()) + // new SideMenuBarComp.Entry(AppI18n.observable("help"), "mdi2b-book-open-variant", new + // StorageLayoutComp()), + // new SideMenuBarComp.Entry(AppI18n.observable("account"), "mdi2a-account", new StorageLayoutComp()) if (AppProperties.get().isDeveloperMode()) { l.add(new SideMenuBarComp.Entry( AppI18n.observable("developer"), "mdi2b-book-open-variant", new DeveloperTabComp())); diff --git a/app/src/main/java/io/xpipe/app/comp/base/ButtonComp.java b/app/src/main/java/io/xpipe/app/comp/base/ButtonComp.java index 2eadf8819..5b85b5fc2 100644 --- a/app/src/main/java/io/xpipe/app/comp/base/ButtonComp.java +++ b/app/src/main/java/io/xpipe/app/comp/base/ButtonComp.java @@ -55,7 +55,7 @@ public class ButtonComp extends Comp> { } var graphic = getGraphic(); if (graphic instanceof FontIcon f) { - //f.iconColorProperty().bind(button.textFillProperty()); + // f.iconColorProperty().bind(button.textFillProperty()); SimpleChangeListener.apply(button.fontProperty(), c -> { f.setIconSize((int) new Size(c.getSize(), SizeUnits.PT).pixels()); }); diff --git a/app/src/main/java/io/xpipe/app/comp/base/DescriptionButtonComp.java b/app/src/main/java/io/xpipe/app/comp/base/DescriptionButtonComp.java index 3ec4a7cd9..668af3f8b 100644 --- a/app/src/main/java/io/xpipe/app/comp/base/DescriptionButtonComp.java +++ b/app/src/main/java/io/xpipe/app/comp/base/DescriptionButtonComp.java @@ -49,7 +49,6 @@ public class DescriptionButtonComp extends SimpleComp { return bt; } - private Region createNamedEntry() { var header = new Label(); header.textProperty().bind(PlatformThread.sync(name)); diff --git a/app/src/main/java/io/xpipe/app/comp/base/IntegratedTextAreaComp.java b/app/src/main/java/io/xpipe/app/comp/base/IntegratedTextAreaComp.java index adc1e4eff..0064438b7 100644 --- a/app/src/main/java/io/xpipe/app/comp/base/IntegratedTextAreaComp.java +++ b/app/src/main/java/io/xpipe/app/comp/base/IntegratedTextAreaComp.java @@ -48,8 +48,9 @@ public class IntegratedTextAreaComp extends SimpleComp { private Region createOpenButton(Region container) { var name = identifier + (fileType != null ? "." + fileType : ""); - var button = new IconButtonComp("mdal-edit", () -> FileOpener - .openString(name, this, value.getValue(), (s) -> { + var button = new IconButtonComp( + "mdal-edit", + () -> FileOpener.openString(name, this, value.getValue(), (s) -> { Platform.runLater(() -> value.setValue(s)); })) .createRegion(); diff --git a/app/src/main/java/io/xpipe/app/comp/base/LazyTextFieldComp.java b/app/src/main/java/io/xpipe/app/comp/base/LazyTextFieldComp.java index 78a1a5aff..80c8c34de 100644 --- a/app/src/main/java/io/xpipe/app/comp/base/LazyTextFieldComp.java +++ b/app/src/main/java/io/xpipe/app/comp/base/LazyTextFieldComp.java @@ -7,9 +7,7 @@ import io.xpipe.app.fxcomps.util.PlatformThread; import io.xpipe.app.fxcomps.util.SimpleChangeListener; import javafx.beans.property.Property; import javafx.beans.property.SimpleStringProperty; -import javafx.event.EventHandler; import javafx.scene.input.KeyCode; -import javafx.scene.input.KeyEvent; import javafx.scene.layout.StackPane; import lombok.Builder; import lombok.Value; @@ -29,19 +27,16 @@ public class LazyTextFieldComp extends Comp { var sp = new StackPane(); var r = new JFXTextField(); - r.setOnKeyPressed(new EventHandler() { - @Override - public void handle(KeyEvent ke) { - if (ke.getCode().equals(KeyCode.ESCAPE)) { - currentValue.setValue(appliedValue.getValue()); - } - - if (ke.getCode().equals(KeyCode.ENTER) || ke.getCode().equals(KeyCode.ESCAPE)) { - r.getScene().getRoot().requestFocus(); - } - - ke.consume(); + r.setOnKeyPressed(ke -> { + if (ke.getCode().equals(KeyCode.ESCAPE)) { + currentValue.setValue(appliedValue.getValue()); } + + if (ke.getCode().equals(KeyCode.ENTER) || ke.getCode().equals(KeyCode.ESCAPE)) { + r.getScene().getRoot().requestFocus(); + } + + ke.consume(); }); r.focusedProperty().addListener((c, o, n) -> { diff --git a/app/src/main/java/io/xpipe/app/comp/base/MultiStepComp.java b/app/src/main/java/io/xpipe/app/comp/base/MultiStepComp.java index 922e3abdc..04b1679e3 100644 --- a/app/src/main/java/io/xpipe/app/comp/base/MultiStepComp.java +++ b/app/src/main/java/io/xpipe/app/comp/base/MultiStepComp.java @@ -200,7 +200,9 @@ public abstract class MultiStepComp extends Comp> { buttons.setAlignment(Pos.CENTER_RIGHT); var nextText = Bindings.createStringBinding( () -> isLastPage() ? AppI18n.get("finishStep") : AppI18n.get("nextStep"), currentStep); - var nextButton = new ButtonComp(nextText, null, comp::next).apply(struc -> struc.get().setDefaultButton(true)).styleClass("next"); + var nextButton = new ButtonComp(nextText, null, comp::next) + .apply(struc -> struc.get().setDefaultButton(true)) + .styleClass("next"); var previousButton = new ButtonComp(AppI18n.observable("previousStep"), null, comp::previous) .styleClass("next") @@ -283,5 +285,5 @@ public abstract class MultiStepComp extends Comp> { } } - public static record Entry(ObservableValue name, Step step) {} + public record Entry(ObservableValue name, Step step) {} } diff --git a/app/src/main/java/io/xpipe/app/comp/base/SideMenuBarComp.java b/app/src/main/java/io/xpipe/app/comp/base/SideMenuBarComp.java index 5330e48d7..f5928ef88 100644 --- a/app/src/main/java/io/xpipe/app/comp/base/SideMenuBarComp.java +++ b/app/src/main/java/io/xpipe/app/comp/base/SideMenuBarComp.java @@ -53,9 +53,15 @@ public class SideMenuBarComp extends Comp> { var fi = new FontIcon("mdi2u-update"); var b = new BigIconButton(AppI18n.observable("update"), fi, () -> UpdateAvailableAlert.showIfNeeded()); b.apply(GrowAugment.create(true, false)); - b.hide(PlatformThread.sync(Bindings.createBooleanBinding(() -> { - return XPipeDistributionType.get().getUpdateHandler().getPreparedUpdate().getValue() == null; - }, XPipeDistributionType.get().getUpdateHandler().getPreparedUpdate()))); + b.hide(PlatformThread.sync(Bindings.createBooleanBinding( + () -> { + return XPipeDistributionType.get() + .getUpdateHandler() + .getPreparedUpdate() + .getValue() + == null; + }, + XPipeDistributionType.get().getUpdateHandler().getPreparedUpdate()))); vbox.getChildren().add(b.createRegion()); } @@ -70,5 +76,5 @@ public class SideMenuBarComp extends Comp> { return new SimpleCompStructure<>(vbox); } - public static record Entry(ObservableValue name, String icon, Comp comp) {} + public record Entry(ObservableValue name, String icon, Comp comp) {} } diff --git a/app/src/main/java/io/xpipe/app/comp/source/DataSourceTargetChoiceComp.java b/app/src/main/java/io/xpipe/app/comp/source/DataSourceTargetChoiceComp.java index ee28449e1..8e7b9bf9b 100644 --- a/app/src/main/java/io/xpipe/app/comp/source/DataSourceTargetChoiceComp.java +++ b/app/src/main/java/io/xpipe/app/comp/source/DataSourceTargetChoiceComp.java @@ -33,8 +33,7 @@ public class DataSourceTargetChoiceComp extends Comp { AppCache.update("application-last-used", val != null ? val.getId() : null); }); - var all = - DataSourceTarget.getAll().stream().filter((p) -> filter.test(p)).toList(); + var all = DataSourceTarget.getAll().stream().filter(filter).toList(); if (selectedApplication.getValue() == null) { String selectedId = AppCache.get("application-last-used", String.class, () -> null); @@ -67,9 +66,10 @@ public class DataSourceTargetChoiceComp extends Comp> createBase() { var addMoreLabel = new Label(AppI18n.get("addMore"), new FontIcon("mdmz-plus")); - var builder = new CustomComboBoxBuilder( - selectedApplication, app -> createLabel(app), new Label(""), v -> true); - builder.setAccessibleNames(dataSourceTarget -> dataSourceTarget.getName().getValue()); + var builder = + new CustomComboBoxBuilder<>(selectedApplication, app -> createLabel(app), new Label(""), v -> true); + builder.setAccessibleNames( + dataSourceTarget -> dataSourceTarget.getName().getValue()); // builder.addFilter((v, s) -> v.getName().getValue().toLowerCase().contains(s)); diff --git a/app/src/main/java/io/xpipe/app/comp/source/DsCollectionComp.java b/app/src/main/java/io/xpipe/app/comp/source/DsCollectionComp.java index 331180c6d..28e0218bf 100644 --- a/app/src/main/java/io/xpipe/app/comp/source/DsCollectionComp.java +++ b/app/src/main/java/io/xpipe/app/comp/source/DsCollectionComp.java @@ -30,15 +30,15 @@ public class DsCollectionComp extends Comp>> { if (con.getValue() != null) { try { con.getValue().listEntries().forEach(e -> { -// var item = new TreeItem(e.getFileName()); -// c.add(item); + // var item = new TreeItem(e.getFileName()); + // c.add(item); }); } catch (Exception ex) { ErrorEvent.fromThrowable(ex).handle(); } } - var ar = new TreeItem(value.getValue()); + var ar = new TreeItem<>(value.getValue()); ar.getChildren().setAll(c); return ar; } diff --git a/app/src/main/java/io/xpipe/app/comp/source/DsDataTransferComp.java b/app/src/main/java/io/xpipe/app/comp/source/DsDataTransferComp.java index 91ba25a6c..cbb225538 100644 --- a/app/src/main/java/io/xpipe/app/comp/source/DsDataTransferComp.java +++ b/app/src/main/java/io/xpipe/app/comp/source/DsDataTransferComp.java @@ -116,12 +116,12 @@ public class DsDataTransferComp extends SimpleComp { if (c != null && c.getAccessType() == DataSourceTarget.AccessType.PASSIVE) { ((Region) s.get().getChildren().get(2)).setMaxHeight(0); ((Region) s.get().getChildren().get(2)).setMinHeight(0); - ((Region) s.get().getChildren().get(2)).setVisible(false); + s.get().getChildren().get(2).setVisible(false); } else { ((Region) s.get().getChildren().get(2)).setMaxHeight(Region.USE_PREF_SIZE); ((Region) s.get().getChildren().get(2)).setMinHeight(Region.USE_PREF_SIZE); - ((Region) s.get().getChildren().get(2)).setVisible(true); + s.get().getChildren().get(2).setVisible(true); } }); s.get().setPrefWidth(600); diff --git a/app/src/main/java/io/xpipe/app/comp/source/DsProviderChoiceComp.java b/app/src/main/java/io/xpipe/app/comp/source/DsProviderChoiceComp.java index 79dfcf4bb..cedcdfc61 100644 --- a/app/src/main/java/io/xpipe/app/comp/source/DsProviderChoiceComp.java +++ b/app/src/main/java/io/xpipe/app/comp/source/DsProviderChoiceComp.java @@ -73,7 +73,8 @@ public class DsProviderChoiceComp extends Comp>> im @Override public CompStructure> createBase() { var comboBox = new CustomComboBoxBuilder<>(provider, this::createGraphic, createDefaultNode(), v -> true); - comboBox.setAccessibleNames(dataSourceProvider -> dataSourceProvider != null ? dataSourceProvider.getDisplayName() : null); + comboBox.setAccessibleNames( + dataSourceProvider -> dataSourceProvider != null ? dataSourceProvider.getDisplayName() : null); comboBox.add(null); comboBox.addSeparator(); comboBox.addFilter((v, s) -> v.getDisplayName().toLowerCase().contains(s.toLowerCase())); diff --git a/app/src/main/java/io/xpipe/app/comp/source/DsStorageGroupSelector.java b/app/src/main/java/io/xpipe/app/comp/source/DsStorageGroupSelector.java index 509b03f83..4f5f2736d 100644 --- a/app/src/main/java/io/xpipe/app/comp/source/DsStorageGroupSelector.java +++ b/app/src/main/java/io/xpipe/app/comp/source/DsStorageGroupSelector.java @@ -29,7 +29,7 @@ public class DsStorageGroupSelector extends SimpleComp { @Override protected ComboBox createSimple() { - var comboBox = new CustomComboBoxBuilder( + var comboBox = new CustomComboBoxBuilder<>( selected, DsStorageGroupSelector::createGraphic, createGraphic(null), v -> true); comboBox.setAccessibleNames(dataSourceCollection -> dataSourceCollection.getName()); diff --git a/app/src/main/java/io/xpipe/app/comp/source/DsStructureComp.java b/app/src/main/java/io/xpipe/app/comp/source/DsStructureComp.java index f7747ec3a..2e824f069 100644 --- a/app/src/main/java/io/xpipe/app/comp/source/DsStructureComp.java +++ b/app/src/main/java/io/xpipe/app/comp/source/DsStructureComp.java @@ -28,7 +28,7 @@ public class DsStructureComp extends Comp>> { item.setValue("[" + i + "] = " + item.getValue()); c.add(item); } - var ar = new TreeItem("[" + n.size() + "... ]"); + var ar = new TreeItem<>("[" + n.size() + "... ]"); ar.getChildren().setAll(c); return ar; } else if (n.isTuple()) { @@ -39,11 +39,11 @@ public class DsStructureComp extends Comp>> { item.setValue((key != null ? key : "" + i) + " = " + item.getValue()); c.add(item); } - var ar = new TreeItem("( " + n.size() + "... )"); + var ar = new TreeItem<>("( " + n.size() + "... )"); ar.getChildren().setAll(c); return ar; } else { - var ar = new TreeItem(n.asValue().asString()); + var ar = new TreeItem<>(n.asValue().asString()); return ar; } } diff --git a/app/src/main/java/io/xpipe/app/comp/source/DsTableMappingComp.java b/app/src/main/java/io/xpipe/app/comp/source/DsTableMappingComp.java index bd930cb6c..574705db1 100644 --- a/app/src/main/java/io/xpipe/app/comp/source/DsTableMappingComp.java +++ b/app/src/main/java/io/xpipe/app/comp/source/DsTableMappingComp.java @@ -38,7 +38,7 @@ public class DsTableMappingComp extends SimpleComp { grid.add(output.createRegion(), 2, i); if (i % 2 != 0) { - grid.getChildren().stream().skip((i * 3)).forEach(node -> node.getStyleClass() + grid.getChildren().stream().skip((i * 3L)).forEach(node -> node.getStyleClass() .add("odd")); } } diff --git a/app/src/main/java/io/xpipe/app/comp/source/GuiDsCreatorMultiStep.java b/app/src/main/java/io/xpipe/app/comp/source/GuiDsCreatorMultiStep.java index daade5974..9439548cf 100644 --- a/app/src/main/java/io/xpipe/app/comp/source/GuiDsCreatorMultiStep.java +++ b/app/src/main/java/io/xpipe/app/comp/source/GuiDsCreatorMultiStep.java @@ -263,8 +263,8 @@ public class GuiDsCreatorMultiStep {} case CREATE -> { - list.add( - new Entry(AppI18n.observable("target"), new GuiDsCreatorTransferStep(targetGroup, store, source))); + list.add(new Entry( + AppI18n.observable("target"), new GuiDsCreatorTransferStep(targetGroup, store, source))); } } return list; @@ -287,7 +287,7 @@ public class GuiDsCreatorMultiStep> void setUpListener(ObservableValue prop) { prop.addListener((c, o, n) -> { - ((Property) selected).setValue((T) n); + ((Property) selected).setValue(n); }); } diff --git a/app/src/main/java/io/xpipe/app/comp/source/store/DataStoreSelectorComp.java b/app/src/main/java/io/xpipe/app/comp/source/store/DataStoreSelectorComp.java index e3d692d9f..918d9fc85 100644 --- a/app/src/main/java/io/xpipe/app/comp/source/store/DataStoreSelectorComp.java +++ b/app/src/main/java/io/xpipe/app/comp/source/store/DataStoreSelectorComp.java @@ -30,9 +30,15 @@ public class DataStoreSelectorComp extends Comp> { var button = new JFXButton(); button.setGraphic(getGraphic()); button.setOnAction(e -> { - GuiDsStoreCreator.show("inProgress", null, null, v -> v.getCategory().equals(category), entry -> { - chosenStore.setValue(entry.getStore()); - }, false); + GuiDsStoreCreator.show( + "inProgress", + null, + null, + v -> v.getCategory().equals(category), + entry -> { + chosenStore.setValue(entry.getStore()); + }, + false); e.consume(); }); @@ -61,8 +67,7 @@ public class DataStoreSelectorComp extends Comp> { return JfxHelper.createNamedEntry( AppI18n.get("selectStreamStore"), AppI18n.get("openStreamStoreWizard"), graphic); } else { - return JfxHelper.createNamedEntry( - f.getFileName().toString(), f.getPath().toString(), graphic); + return JfxHelper.createNamedEntry(f.getFileName(), f.getPath(), graphic); } } } diff --git a/app/src/main/java/io/xpipe/app/comp/source/store/DsLocalDirectoryBrowseComp.java b/app/src/main/java/io/xpipe/app/comp/source/store/DsLocalDirectoryBrowseComp.java index 6b28c73cc..aa88ee4a1 100644 --- a/app/src/main/java/io/xpipe/app/comp/source/store/DsLocalDirectoryBrowseComp.java +++ b/app/src/main/java/io/xpipe/app/comp/source/store/DsLocalDirectoryBrowseComp.java @@ -18,10 +18,10 @@ import java.nio.file.Path; public class DsLocalDirectoryBrowseComp extends Comp> { - private final DataSourceProvider provider; + private final DataSourceProvider provider; private final Property chosenDir; - public DsLocalDirectoryBrowseComp(DataSourceProvider provider, Property chosenDir) { + public DsLocalDirectoryBrowseComp(DataSourceProvider provider, Property chosenDir) { this.provider = provider; this.chosenDir = chosenDir; } @@ -32,8 +32,8 @@ public class DsLocalDirectoryBrowseComp extends Comp> { button.setGraphic(getGraphic()); button.setOnAction(e -> { var dirChooser = new DirectoryChooser(); - dirChooser.setTitle( - AppI18n.get("browseDirectoryTitle", provider.getFileProvider().getFileName())); + dirChooser.setTitle(AppI18n.get( + "browseDirectoryTitle", provider.getFileProvider().getFileName())); File file = dirChooser.showDialog(button.getScene().getWindow()); if (file != null && file.exists()) { chosenDir.setValue(file.toPath()); @@ -55,7 +55,8 @@ public class DsLocalDirectoryBrowseComp extends Comp> { private Region getGraphic() { var graphic = provider.getDisplayIconFileName(); if (chosenDir.getValue() == null) { - return JfxHelper.createNamedEntry(AppI18n.get("browse"), AppI18n.get("selectDirectoryFromComputer"), graphic); + return JfxHelper.createNamedEntry( + AppI18n.get("browse"), AppI18n.get("selectDirectoryFromComputer"), graphic); } else { return JfxHelper.createNamedEntry( chosenDir.getValue().getFileName().toString(), diff --git a/app/src/main/java/io/xpipe/app/comp/source/store/DsLocalFileBrowseComp.java b/app/src/main/java/io/xpipe/app/comp/source/store/DsLocalFileBrowseComp.java index fc0b86566..5540c40c3 100644 --- a/app/src/main/java/io/xpipe/app/comp/source/store/DsLocalFileBrowseComp.java +++ b/app/src/main/java/io/xpipe/app/comp/source/store/DsLocalFileBrowseComp.java @@ -68,8 +68,7 @@ public class DsLocalFileBrowseComp extends Comp> { if (chosenFile.getValue() == null || !(chosenFile.getValue() instanceof FileStore f) || f.getPath() == null) { return JfxHelper.createNamedEntry(AppI18n.get("browse"), AppI18n.get("selectFileFromComputer"), graphic); } else { - return JfxHelper.createNamedEntry( - f.getFileName().toString(), f.getPath().toString(), graphic); + return JfxHelper.createNamedEntry(f.getFileName(), f.getPath(), graphic); } } } diff --git a/app/src/main/java/io/xpipe/app/comp/source/store/DsStoreProviderChoiceComp.java b/app/src/main/java/io/xpipe/app/comp/source/store/DsStoreProviderChoiceComp.java index 0e68e3353..fcb7bf9ae 100644 --- a/app/src/main/java/io/xpipe/app/comp/source/store/DsStoreProviderChoiceComp.java +++ b/app/src/main/java/io/xpipe/app/comp/source/store/DsStoreProviderChoiceComp.java @@ -33,9 +33,7 @@ public class DsStoreProviderChoiceComp extends Comp } private List getProviders() { - return DataStoreProviders.getAll().stream() - .filter(filter) - .toList(); + return DataStoreProviders.getAll().stream().filter(filter).toList(); } private Region createGraphic(DataStoreProvider provider) { diff --git a/app/src/main/java/io/xpipe/app/comp/source/store/DsStreamStoreChoiceComp.java b/app/src/main/java/io/xpipe/app/comp/source/store/DsStreamStoreChoiceComp.java index a0ad00810..f4494132a 100644 --- a/app/src/main/java/io/xpipe/app/comp/source/store/DsStreamStoreChoiceComp.java +++ b/app/src/main/java/io/xpipe/app/comp/source/store/DsStreamStoreChoiceComp.java @@ -39,7 +39,7 @@ import java.util.function.Predicate; @EqualsAndHashCode(callSuper = true) public class DsStreamStoreChoiceComp extends SimpleComp implements Validatable { - public static enum Mode { + public enum Mode { OPEN, WRITE } @@ -71,7 +71,7 @@ public class DsStreamStoreChoiceComp extends SimpleComp implements Validatable { protected Region createSimple() { var isNamedStore = XPipeDaemon.getInstance().getStoreName(selected.getValue()).isPresent(); - var localStore = new SimpleObjectProperty( + var localStore = new SimpleObjectProperty<>( !isNamedStore && selected.getValue() instanceof FileStore fileStore && fileStore.getFileSystem() instanceof LocalStore @@ -101,7 +101,7 @@ public class DsStreamStoreChoiceComp extends SimpleComp implements Validatable { }, provider != null ? provider : new SimpleObjectProperty<>()); - var remoteStore = new SimpleObjectProperty( + var remoteStore = new SimpleObjectProperty<>( isNamedStore && selected.getValue() instanceof FileStore fileStore && !(fileStore.getFileSystem() instanceof LocalStore) @@ -110,13 +110,13 @@ public class DsStreamStoreChoiceComp extends SimpleComp implements Validatable { var remote = new TabPaneComp.Entry( AppI18n.observable("remote"), "mdi2e-earth", new DsRemoteFileChoiceComp(remoteStore)); - var namedStore = new SimpleObjectProperty(isNamedStore ? selected.getValue() : null); + var namedStore = new SimpleObjectProperty<>(isNamedStore ? selected.getValue() : null); var named = new TabPaneComp.Entry( AppI18n.observable("stored"), "mdrmz-storage", NamedStoreChoiceComp.create(filter, namedStore, DataStoreProvider.DataCategory.STREAM)); - var otherStore = new SimpleObjectProperty( + var otherStore = new SimpleObjectProperty<>( localStore.get() == null && remoteStore.get() == null && !isNamedStore ? selected.getValue() : null); var other = new TabPaneComp.Entry( AppI18n.observable("other"), diff --git a/app/src/main/java/io/xpipe/app/comp/source/store/GuiDsStoreCreator.java b/app/src/main/java/io/xpipe/app/comp/source/store/GuiDsStoreCreator.java index f1bb3e4ac..514db6bb6 100644 --- a/app/src/main/java/io/xpipe/app/comp/source/store/GuiDsStoreCreator.java +++ b/app/src/main/java/io/xpipe/app/comp/source/store/GuiDsStoreCreator.java @@ -61,8 +61,8 @@ public class GuiDsStoreCreator extends MultiStepComp.Step> { Property provider, Property store, Predicate filter, - String initialName, boolean exists - ) { + String initialName, + boolean exists) { this.parent = parent; this.provider = provider; this.store = store; @@ -97,26 +97,38 @@ public class GuiDsStoreCreator extends MultiStepComp.Step> { } public static void showEdit(DataStoreEntry e) { - show(e.getName(), e.getProvider(), e.getStore(), v -> true, newE -> { - ThreadHelper.runAsync(() -> { - e.applyChanges(newE); - if (!DataStorage.get().getStoreEntries().contains(e)) { - DataStorage.get().addStoreEntry(e); - } - DataStorage.get().refresh(); - }); - }, true); + show( + e.getName(), + e.getProvider(), + e.getStore(), + v -> true, + newE -> { + ThreadHelper.runAsync(() -> { + e.applyChanges(newE); + if (!DataStorage.get().getStoreEntries().contains(e)) { + DataStorage.get().addStoreEntry(e); + } + DataStorage.get().refresh(); + }); + }, + true); } public static void showCreation(Predicate filter) { - show(null, null, null, filter, e -> { - try { - DataStorage.get().addStoreEntry(e); - // ScanAlert.showAsync(e.getStore(), true); - } catch (Exception ex) { - ErrorEvent.fromThrowable(ex).handle(); - } - }, false); + show( + null, + null, + null, + filter, + e -> { + try { + DataStorage.get().addStoreEntry(e); + // ScanAlert.showAsync(e.getStore(), true); + } catch (Exception ex) { + ErrorEvent.fromThrowable(ex).handle(); + } + }, + false); } public static void show( @@ -126,8 +138,8 @@ public class GuiDsStoreCreator extends MultiStepComp.Step> { Predicate filter, Consumer con, boolean exists) { - var prop = new SimpleObjectProperty(provider); - var store = new SimpleObjectProperty(s); + var prop = new SimpleObjectProperty<>(provider); + var store = new SimpleObjectProperty<>(s); var loading = new SimpleBooleanProperty(); var name = "addConnection"; Platform.runLater(() -> { @@ -162,12 +174,26 @@ public class GuiDsStoreCreator extends MultiStepComp.Step> { @Override public Comp bottom() { - var disable = Bindings.createBooleanBinding(() -> { - return provider.getValue() == null || store.getValue() == null || !store.getValue().isComplete(); - }, provider, store); - return new PopupMenuButtonComp(new SimpleStringProperty("Insights >"), Comp.of(() -> { - return provider.getValue() != null ? provider.getValue().createInsightsComp(store).createRegion() : null; - }), true).disable(disable).styleClass("button-comp"); + var disable = Bindings.createBooleanBinding( + () -> { + return provider.getValue() == null + || store.getValue() == null + || !store.getValue().isComplete(); + }, + provider, + store); + return new PopupMenuButtonComp( + new SimpleStringProperty("Insights >"), + Comp.of(() -> { + return provider.getValue() != null + ? provider.getValue() + .createInsightsComp(store) + .createRegion() + : null; + }), + true) + .disable(disable) + .styleClass("button-comp"); } private static boolean showInvalidConfirmAlert() { @@ -288,7 +314,8 @@ public class GuiDsStoreCreator extends MultiStepComp.Step> { } if (!exists) { - if (name.getValue() != null && DataStorage.get().getStoreEntryIfPresent(name.getValue()).isPresent()) { + if (name.getValue() != null + && DataStorage.get().getStoreEntryIfPresent(name.getValue()).isPresent()) { messageProp.setValue("Store with name " + name.getValue() + " does already exist"); changedSinceError.setValue(false); return false; diff --git a/app/src/main/java/io/xpipe/app/comp/source/store/NamedStoreChoiceComp.java b/app/src/main/java/io/xpipe/app/comp/source/store/NamedStoreChoiceComp.java index 0b6c08cc1..3b1840385 100644 --- a/app/src/main/java/io/xpipe/app/comp/source/store/NamedStoreChoiceComp.java +++ b/app/src/main/java/io/xpipe/app/comp/source/store/NamedStoreChoiceComp.java @@ -116,8 +116,12 @@ public class NamedStoreChoiceComp extends SimpleComp implements Validatable { refreshShown(list, shown); }); - var prop = new SimpleObjectProperty<>(selected.getValue() != null ? - DataStorage.get().getStoreEntryIfPresent(selected.getValue()).orElse(null):null); + var prop = new SimpleObjectProperty<>( + selected.getValue() != null + ? DataStorage.get() + .getStoreEntryIfPresent(selected.getValue()) + .orElse(null) + : null); setUpListener(prop); var filterComp = new FilterComp(filterString) diff --git a/app/src/main/java/io/xpipe/app/comp/storage/DataStoreTypeComp.java b/app/src/main/java/io/xpipe/app/comp/storage/DataStoreTypeComp.java index eefee1d20..1eaf31b1c 100644 --- a/app/src/main/java/io/xpipe/app/comp/storage/DataStoreTypeComp.java +++ b/app/src/main/java/io/xpipe/app/comp/storage/DataStoreTypeComp.java @@ -14,7 +14,7 @@ import org.kordamp.ikonli.javafx.FontIcon; @EqualsAndHashCode(callSuper = true) public class DataStoreTypeComp extends SimpleComp { - private final DataSource source; + DataSource source; @Override protected Region createSimple() { diff --git a/app/src/main/java/io/xpipe/app/comp/storage/StorageFilter.java b/app/src/main/java/io/xpipe/app/comp/storage/StorageFilter.java index 3c2670d4c..57817642c 100644 --- a/app/src/main/java/io/xpipe/app/comp/storage/StorageFilter.java +++ b/app/src/main/java/io/xpipe/app/comp/storage/StorageFilter.java @@ -49,7 +49,7 @@ public class StorageFilter { return filter; } - public static interface Filterable { + public interface Filterable { boolean shouldShow(String filter); } diff --git a/app/src/main/java/io/xpipe/app/comp/storage/collection/SourceCollectionLayoutComp.java b/app/src/main/java/io/xpipe/app/comp/storage/collection/SourceCollectionLayoutComp.java index dc2a9e846..d1abb03e2 100644 --- a/app/src/main/java/io/xpipe/app/comp/storage/collection/SourceCollectionLayoutComp.java +++ b/app/src/main/java/io/xpipe/app/comp/storage/collection/SourceCollectionLayoutComp.java @@ -49,9 +49,10 @@ public class SourceCollectionLayoutComp extends SimpleComp { var filler = Comp.of(() -> new Region()); filler.styleClass("bar"); filler.styleClass("filler-bar"); - var button = new ButtonComp(AppI18n.observable("addCollection"), new FontIcon("mdi2f-folder-plus-outline"), () -> { - SourceCollectionViewState.get().addNewCollection(); - }) + var button = new ButtonComp( + AppI18n.observable("addCollection"), new FontIcon("mdi2f-folder-plus-outline"), () -> { + SourceCollectionViewState.get().addNewCollection(); + }) .apply(new FancyTooltipAugment<>("addCollectionFolder")); button.styleClass("intro-add-collection-button"); diff --git a/app/src/main/java/io/xpipe/app/comp/storage/collection/SourceCollectionSortMode.java b/app/src/main/java/io/xpipe/app/comp/storage/collection/SourceCollectionSortMode.java index 9bc4be53c..c9c6416a8 100644 --- a/app/src/main/java/io/xpipe/app/comp/storage/collection/SourceCollectionSortMode.java +++ b/app/src/main/java/io/xpipe/app/comp/storage/collection/SourceCollectionSortMode.java @@ -7,7 +7,7 @@ import java.util.Comparator; public interface SourceCollectionSortMode { - static SourceCollectionSortMode ALPHABETICAL_DESC = new SourceCollectionSortMode() { + SourceCollectionSortMode ALPHABETICAL_DESC = new SourceCollectionSortMode() { @Override public String getId() { return "alphabetical-desc"; @@ -21,7 +21,7 @@ public interface SourceCollectionSortMode { } }; - static SourceCollectionSortMode ALPHABETICAL_ASC = new SourceCollectionSortMode() { + SourceCollectionSortMode ALPHABETICAL_ASC = new SourceCollectionSortMode() { @Override public String getId() { return "alphabetical-asc"; @@ -34,7 +34,7 @@ public interface SourceCollectionSortMode { } }; - static SourceCollectionSortMode DATE_DESC = new SourceCollectionSortMode() { + SourceCollectionSortMode DATE_DESC = new SourceCollectionSortMode() { @Override public String getId() { return "date-desc"; @@ -48,7 +48,7 @@ public interface SourceCollectionSortMode { } }; - static SourceCollectionSortMode DATE_ASC = new SourceCollectionSortMode() { + SourceCollectionSortMode DATE_ASC = new SourceCollectionSortMode() { @Override public String getId() { return "date-asc"; diff --git a/app/src/main/java/io/xpipe/app/comp/storage/collection/SourceCollectionWrapper.java b/app/src/main/java/io/xpipe/app/comp/storage/collection/SourceCollectionWrapper.java index f4ac70113..9ae4e855e 100644 --- a/app/src/main/java/io/xpipe/app/comp/storage/collection/SourceCollectionWrapper.java +++ b/app/src/main/java/io/xpipe/app/comp/storage/collection/SourceCollectionWrapper.java @@ -35,10 +35,9 @@ public class SourceCollectionWrapper implements StorageFilter.Filterable { public SourceCollectionWrapper(DataSourceCollection collection) { this.collection = collection; - this.entries = - new SimpleListProperty(FXCollections.observableList(collection.getEntries().stream() - .map(SourceEntryWrapper::new) - .collect(Collectors.toCollection(ArrayList::new)))); + this.entries = new SimpleListProperty<>(FXCollections.observableList(collection.getEntries().stream() + .map(SourceEntryWrapper::new) + .collect(Collectors.toCollection(ArrayList::new)))); this.size = new SimpleIntegerProperty(collection.getEntries().size()); this.name = new SimpleStringProperty(collection.getName()); this.lastAccess = new SimpleObjectProperty<>(collection.getLastAccess().minus(Duration.ofMillis(500))); diff --git a/app/src/main/java/io/xpipe/app/comp/storage/source/SourceEntryContextMenu.java b/app/src/main/java/io/xpipe/app/comp/storage/source/SourceEntryContextMenu.java index f14527194..82b6345f6 100644 --- a/app/src/main/java/io/xpipe/app/comp/storage/source/SourceEntryContextMenu.java +++ b/app/src/main/java/io/xpipe/app/comp/storage/source/SourceEntryContextMenu.java @@ -18,7 +18,6 @@ import org.kordamp.ikonli.javafx.FontIcon; public class SourceEntryContextMenu> extends ContextMenuAugment { - public SourceEntryContextMenu(boolean showOnPrimaryButton, SourceEntryWrapper entry, Region renameTextField) { super(() -> createContextMenu(entry, renameTextField)); } diff --git a/app/src/main/java/io/xpipe/app/comp/storage/source/SourceEntryDisplayMode.java b/app/src/main/java/io/xpipe/app/comp/storage/source/SourceEntryDisplayMode.java index 7da23497b..4723bf91c 100644 --- a/app/src/main/java/io/xpipe/app/comp/storage/source/SourceEntryDisplayMode.java +++ b/app/src/main/java/io/xpipe/app/comp/storage/source/SourceEntryDisplayMode.java @@ -11,9 +11,9 @@ public interface SourceEntryDisplayMode { SourceEntryDisplayMode LIST = new ListMode(); SourceEntryDisplayMode TILES = new ListMode(); - public Region create(List entries); + Region create(List entries); - static class ListMode implements SourceEntryDisplayMode { + class ListMode implements SourceEntryDisplayMode { private static final double SOURCE_TYPE_WIDTH = 0.15; private static final double NAME_WIDTH = 0.4; diff --git a/app/src/main/java/io/xpipe/app/comp/storage/source/SourceEntryWrapper.java b/app/src/main/java/io/xpipe/app/comp/storage/source/SourceEntryWrapper.java index e9daa800a..ccc7abd80 100644 --- a/app/src/main/java/io/xpipe/app/comp/storage/source/SourceEntryWrapper.java +++ b/app/src/main/java/io/xpipe/app/comp/storage/source/SourceEntryWrapper.java @@ -11,7 +11,6 @@ import io.xpipe.app.fxcomps.util.PlatformThread; import io.xpipe.app.issue.ErrorEvent; import io.xpipe.app.storage.DataSourceEntry; import io.xpipe.app.storage.DataStorage; -import io.xpipe.app.storage.StorageElement; import io.xpipe.core.source.DataSource; import io.xpipe.core.store.DataFlow; import javafx.beans.property.*; @@ -37,14 +36,9 @@ public class SourceEntryWrapper implements StorageFilter.Filterable { public SourceEntryWrapper(DataSourceEntry entry) { this.entry = entry; - entry.addListener(new StorageElement.Listener() { - @Override - public void onUpdate() { - PlatformThread.runLaterIfNeeded(() -> { - update(); - }); - } - }); + entry.addListener(() -> PlatformThread.runLaterIfNeeded(() -> { + update(); + })); update(); name.addListener((c, o, n) -> { if (!entry.getName().equals(n)) { diff --git a/app/src/main/java/io/xpipe/app/comp/storage/store/StoreCreationBarComp.java b/app/src/main/java/io/xpipe/app/comp/storage/store/StoreCreationBarComp.java index 3cca49b9d..03fb60451 100644 --- a/app/src/main/java/io/xpipe/app/comp/storage/store/StoreCreationBarComp.java +++ b/app/src/main/java/io/xpipe/app/comp/storage/store/StoreCreationBarComp.java @@ -23,7 +23,8 @@ public class StoreCreationBarComp extends SimpleComp { protected Region createSimple() { var newStreamStore = new ButtonComp( AppI18n.observable("addCommand"), new FontIcon("mdi2c-code-greater-than"), () -> { - GuiDsStoreCreator.showCreation(v -> v.getDisplayCategory().equals(DataStoreProvider.DisplayCategory.COMMAND)); + GuiDsStoreCreator.showCreation( + v -> v.getDisplayCategory().equals(DataStoreProvider.DisplayCategory.COMMAND)); }) .styleClass(Styles.FLAT) .shortcut(new KeyCodeCombination(KeyCode.C, KeyCombination.SHORTCUT_DOWN)) @@ -38,22 +39,24 @@ public class StoreCreationBarComp extends SimpleComp { .apply(new FancyTooltipAugment<>("addHost")); var newShellStore = new ButtonComp( - AppI18n.observable("addShell"), new FontIcon("mdi2t-text-box-multiple"), () -> { - GuiDsStoreCreator.showCreation(v -> v.getDisplayCategory().equals(DataStoreProvider.DisplayCategory.SHELL)); - }) + AppI18n.observable("addShell"), new FontIcon("mdi2t-text-box-multiple"), () -> { + GuiDsStoreCreator.showCreation( + v -> v.getDisplayCategory().equals(DataStoreProvider.DisplayCategory.SHELL)); + }) .styleClass(Styles.FLAT) .shortcut(new KeyCodeCombination(KeyCode.S, KeyCombination.SHORTCUT_DOWN)) .apply(new FancyTooltipAugment<>("addShell")); - var newDbStore = new ButtonComp( - AppI18n.observable("addDatabase"), new FontIcon("mdi2d-database-plus"), () -> { - GuiDsStoreCreator.showCreation(v -> v.getDisplayCategory().equals(DataStoreProvider.DisplayCategory.DATABASE)); - }) + var newDbStore = new ButtonComp(AppI18n.observable("addDatabase"), new FontIcon("mdi2d-database-plus"), () -> { + GuiDsStoreCreator.showCreation( + v -> v.getDisplayCategory().equals(DataStoreProvider.DisplayCategory.DATABASE)); + }) .styleClass(Styles.FLAT) .shortcut(new KeyCodeCombination(KeyCode.D, KeyCombination.SHORTCUT_DOWN)) .apply(new FancyTooltipAugment<>("addDatabase")); - var box = new VerticalComp(List.of(newHostStore, newShellStore, newStreamStore, newDbStore)).apply(struc -> struc.get().setFillWidth(true)); + var box = new VerticalComp(List.of(newHostStore, newShellStore, newStreamStore, newDbStore)) + .apply(struc -> struc.get().setFillWidth(true)); box.apply(s -> AppFont.medium(s.get())); var bar = box.createRegion(); bar.getStyleClass().add("bar"); diff --git a/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntryComp.java b/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntryComp.java index 8a8708bb7..fb561117c 100644 --- a/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntryComp.java +++ b/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntryComp.java @@ -148,9 +148,12 @@ public class StoreEntryComp extends SimpleComp { button.getStyleClass().add("store-entry-comp"); button.setMaxWidth(2000); button.setFocusTraversable(true); - button.accessibleTextProperty().bind(Bindings.createStringBinding(() -> { - return entry.getName(); - }, entry.nameProperty())); + button.accessibleTextProperty() + .bind(Bindings.createStringBinding( + () -> { + return entry.getName(); + }, + entry.nameProperty())); button.accessibleHelpProperty().bind(entry.getInformation()); button.setOnAction(event -> { event.consume(); @@ -160,7 +163,8 @@ public class StoreEntryComp extends SimpleComp { }); }); - new ContextMenuAugment<>(() -> StoreEntryComp.this.createContextMenu()).augment(new SimpleCompStructure<>(button)); + new ContextMenuAugment<>(() -> StoreEntryComp.this.createContextMenu()) + .augment(new SimpleCompStructure<>(button)); return button; } @@ -210,7 +214,8 @@ public class StoreEntryComp extends SimpleComp { var settingsButton = new IconButtonComp("mdomz-settings"); settingsButton.styleClass("settings"); settingsButton.accessibleText("Settings"); - settingsButton.apply(new ContextMenuAugment<>(event -> event.getButton() == MouseButton.PRIMARY, () -> StoreEntryComp.this.createContextMenu())); + settingsButton.apply(new ContextMenuAugment<>( + event -> event.getButton() == MouseButton.PRIMARY, () -> StoreEntryComp.this.createContextMenu())); settingsButton.apply(GrowAugment.create(false, true)); settingsButton.apply(s -> { s.get().prefWidthProperty().bind(Bindings.divide(s.get().heightProperty(), 1.35)); diff --git a/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntryFlatMiniSectionComp.java b/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntryFlatMiniSectionComp.java index 896944edf..c6e574d3f 100644 --- a/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntryFlatMiniSectionComp.java +++ b/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntryFlatMiniSectionComp.java @@ -54,7 +54,8 @@ public class StoreEntryFlatMiniSectionComp extends SimpleComp { var image = entry.getState() == DataStoreEntry.State.LOAD_FAILED ? "disabled_icon.png" : entry.getProvider().getDisplayIconFileName(entry.getStore()); - var label = new Label(entry.getName(), new PrettyImageComp(new SimpleStringProperty(image), 20, 20).createRegion()); + var label = + new Label(entry.getName(), new PrettyImageComp(new SimpleStringProperty(image), 20, 20).createRegion()); var spacer = new Spacer(depth * 10, Orientation.HORIZONTAL); var box = new HBox(spacer, label); return box; diff --git a/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntryListComp.java b/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntryListComp.java index e29d0b1d1..62b063a17 100644 --- a/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntryListComp.java +++ b/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntryListComp.java @@ -31,9 +31,12 @@ public class StoreEntryListComp extends SimpleComp { @Override protected Region createSimple() { var initialCount = StoreViewState.get().getAllEntries().size(); - var showIntro = Bindings.createBooleanBinding(() -> { - return initialCount == StoreViewState.get().getAllEntries().size() && AppState.get().isInitialLaunch(); - }, StoreViewState.get().getAllEntries()); + var showIntro = Bindings.createBooleanBinding( + () -> { + return initialCount == StoreViewState.get().getAllEntries().size() + && AppState.get().isInitialLaunch(); + }, + StoreViewState.get().getAllEntries()); var map = new LinkedHashMap, ObservableBooleanValue>(); map.put( createList(), diff --git a/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntrySection.java b/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntrySection.java index 4b2a882a0..df0e8b169 100644 --- a/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntrySection.java +++ b/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntrySection.java @@ -40,7 +40,8 @@ public class StoreEntrySection extends Comp> { .accessibleText("Expand") .disable(BindingsHelper.persist( Bindings.size(section.getChildren()).isEqualTo(0))) - .grow(false, true).styleClass("expand-button"); + .grow(false, true) + .styleClass("expand-button"); List> topEntryList = List.of(button, root); var all = section.getChildren(); diff --git a/app/src/main/java/io/xpipe/app/comp/storage/store/StoreIntroComp.java b/app/src/main/java/io/xpipe/app/comp/storage/store/StoreIntroComp.java index 22443ebe1..40daab844 100644 --- a/app/src/main/java/io/xpipe/app/comp/storage/store/StoreIntroComp.java +++ b/app/src/main/java/io/xpipe/app/comp/storage/store/StoreIntroComp.java @@ -18,7 +18,6 @@ import javafx.scene.layout.StackPane; import javafx.scene.layout.VBox; import org.kordamp.ikonli.javafx.FontIcon; - public class StoreIntroComp extends SimpleComp { @Override @@ -53,15 +52,11 @@ public class StoreIntroComp extends SimpleComp { docLinkPane.setAlignment(Pos.CENTER); var v = new VBox( - title, - introDesc, - new Separator(Orientation.HORIZONTAL), - machine, - scanPane -// new Separator(Orientation.HORIZONTAL), -// documentation, -// docLinkPane - ); + title, introDesc, new Separator(Orientation.HORIZONTAL), machine, scanPane + // new Separator(Orientation.HORIZONTAL), + // documentation, + // docLinkPane + ); v.setMinWidth(Region.USE_PREF_SIZE); v.setMaxWidth(Region.USE_PREF_SIZE); v.setMinHeight(Region.USE_PREF_SIZE); diff --git a/app/src/main/java/io/xpipe/app/comp/storage/store/StoreSection.java b/app/src/main/java/io/xpipe/app/comp/storage/store/StoreSection.java index c25005e7f..8cd4d7755 100644 --- a/app/src/main/java/io/xpipe/app/comp/storage/store/StoreSection.java +++ b/app/src/main/java/io/xpipe/app/comp/storage/store/StoreSection.java @@ -20,28 +20,27 @@ public class StoreSection implements StorageFilter.Filterable { private static final Comparator COMPARATOR = Comparator.comparing( o -> o.wrapper.getEntry().getState().equals(DataStoreEntry.State.COMPLETE_AND_VALID) ? o.wrapper.getEntry().getLastAccess() - : Instant.EPOCH).reversed() + : Instant.EPOCH) + .reversed() .thenComparing( storeEntrySection -> storeEntrySection.wrapper.getEntry().getName()); public static StoreSection createTopLevel() { - var topLevel = BindingsHelper.mappedContentBinding(StoreViewState.get().getAllEntries(), storeEntryWrapper -> create(storeEntryWrapper)); - var filtered = - BindingsHelper.filteredContentBinding(topLevel, section -> { - if (!section.getWrapper().getEntry().getState().isUsable()) { - return true; - } + var topLevel = BindingsHelper.mappedContentBinding( + StoreViewState.get().getAllEntries(), storeEntryWrapper -> create(storeEntryWrapper)); + var filtered = BindingsHelper.filteredContentBinding(topLevel, section -> { + if (!section.getWrapper().getEntry().getState().isUsable()) { + return true; + } - var parent = section.getWrapper() - .getEntry() - .getProvider() - .getParent(section.getWrapper().getEntry().getStore()); - return parent == null - || (DataStorage.get().getStoreEntryIfPresent(parent).isEmpty()); - }); - var ordered = BindingsHelper.orderedContentBinding( - filtered, - COMPARATOR); + var parent = section.getWrapper() + .getEntry() + .getProvider() + .getParent(section.getWrapper().getEntry().getStore()); + return parent == null + || (DataStorage.get().getStoreEntryIfPresent(parent).isEmpty()); + }); + var ordered = BindingsHelper.orderedContentBinding(filtered, COMPARATOR); return new StoreSection(null, ordered); } @@ -54,14 +53,12 @@ public class StoreSection implements StorageFilter.Filterable { StoreViewState.get().getAllEntries(), other -> other.getEntry().getState().isUsable() && e.getEntry() - .getStore() - .equals(other.getEntry() + .getStore() + .equals(other.getEntry() .getProvider() .getParent(other.getEntry().getStore()))); var children = BindingsHelper.mappedContentBinding(filtered, entry1 -> create(entry1)); - var ordered = BindingsHelper.orderedContentBinding( - children, - COMPARATOR); + var ordered = BindingsHelper.orderedContentBinding(children, COMPARATOR); return new StoreSection(e, ordered); } diff --git a/app/src/main/java/io/xpipe/app/core/AppActionLinkDetector.java b/app/src/main/java/io/xpipe/app/core/AppActionLinkDetector.java index fe6480274..db7bf0fb5 100644 --- a/app/src/main/java/io/xpipe/app/core/AppActionLinkDetector.java +++ b/app/src/main/java/io/xpipe/app/core/AppActionLinkDetector.java @@ -65,7 +65,8 @@ public class AppActionLinkDetector { alert.setTitle(AppI18n.get("clipboardActionDetectedTitle")); alert.setHeaderText(AppI18n.get("clipboardActionDetectedHeader")); alert.getDialogPane() - .setContent(AppWindowHelper.alertContentText(AppI18n.get("clipboardActionDetectedContent"))); + .setContent( + AppWindowHelper.alertContentText(AppI18n.get("clipboardActionDetectedContent"))); }) .map(buttonType -> buttonType.getButtonData().isDefaultButton()) .orElse(false); diff --git a/app/src/main/java/io/xpipe/app/core/AppCharsets.java b/app/src/main/java/io/xpipe/app/core/AppCharsets.java index de833ee55..27317e659 100644 --- a/app/src/main/java/io/xpipe/app/core/AppCharsets.java +++ b/app/src/main/java/io/xpipe/app/core/AppCharsets.java @@ -11,7 +11,7 @@ import java.util.Locale; public class AppCharsets { - private static List observedCharsets = new ArrayList<>(); + private static final List observedCharsets = new ArrayList<>(); public static void init() { var system = System.getProperty("file.encoding"); diff --git a/app/src/main/java/io/xpipe/app/core/AppExtensionManager.java b/app/src/main/java/io/xpipe/app/core/AppExtensionManager.java index d11630208..5cd2f6422 100644 --- a/app/src/main/java/io/xpipe/app/core/AppExtensionManager.java +++ b/app/src/main/java/io/xpipe/app/core/AppExtensionManager.java @@ -29,7 +29,7 @@ public class AppExtensionManager { private ModuleLayer baseLayer = ModuleLayer.boot(); private ModuleLayer extendedLayer; - public static void init(boolean loadProviders) throws Exception { + public static void init(boolean loadProviders) { if (INSTANCE != null) { return; } @@ -242,12 +242,12 @@ public class AppExtensionManager { .tag("dependencies", ext.get().getDependencies()) .handle(); - return Optional.of(ext.get()); + return ext; } } } catch (Throwable t) { ErrorEvent.fromThrowable(t) - .description("Unable to load extension from " + dir.toString() + ". Is the installation corrupted?") + .description("Unable to load extension from " + dir + ". Is the installation corrupted?") .handle(); } return Optional.empty(); diff --git a/app/src/main/java/io/xpipe/app/core/AppI18n.java b/app/src/main/java/io/xpipe/app/core/AppI18n.java index fcde61e60..603369db2 100644 --- a/app/src/main/java/io/xpipe/app/core/AppI18n.java +++ b/app/src/main/java/io/xpipe/app/core/AppI18n.java @@ -40,7 +40,7 @@ public class AppI18n { private Map translations; private Map markdownDocumentations; private PrettyTime prettyTime; -private static AppI18n INSTANCE = new AppI18n(); + private static final AppI18n INSTANCE = new AppI18n(); public static void init() { var i = INSTANCE; @@ -59,7 +59,7 @@ private static AppI18n INSTANCE = new AppI18n(); } public static AppI18n getInstance() { - return ((AppI18n) INSTANCE); + return INSTANCE; } public static StringBinding readableDuration(String s, ObservableValue instant) { @@ -73,7 +73,8 @@ private static AppI18n INSTANCE = new AppI18n(); return "null"; } - return op.apply(getInstance().prettyTime.format(instant.getValue().minus(Duration.ofSeconds(1)))); + return op.apply( + getInstance().prettyTime.format(instant.getValue().minus(Duration.ofSeconds(1)))); }, instant); } @@ -209,9 +210,9 @@ private static AppI18n INSTANCE = new AppI18n(); AtomicInteger lineCounter = new AtomicInteger(); var simpleName = FilenameUtils.getExtension(module.getName()); String defaultPrefix = simpleName.equals("app") ? "app." : simpleName + "."; - Files.walkFileTree(basePath, new SimpleFileVisitor() { + Files.walkFileTree(basePath, new SimpleFileVisitor<>() { @Override - public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) { if (!matchesLocale(file)) { return FileVisitResult.CONTINUE; } @@ -227,7 +228,7 @@ private static AppI18n INSTANCE = new AppI18n(); props.forEach((key, value) -> { var hasPrefix = key.toString().contains("."); var usedPrefix = hasPrefix ? "" : defaultPrefix; - translations.put(usedPrefix + key.toString(), value.toString()); + translations.put(usedPrefix + key, value.toString()); lineCounter.incrementAndGet(); }); } catch (IOException ex) { @@ -252,9 +253,9 @@ private static AppI18n INSTANCE = new AppI18n(); } var moduleName = FilenameUtils.getExtension(module.getName()); - Files.walkFileTree(basePath, new SimpleFileVisitor() { + Files.walkFileTree(basePath, new SimpleFileVisitor<>() { @Override - public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) { if (!matchesLocale(file)) { return FileVisitResult.CONTINUE; } @@ -263,10 +264,13 @@ private static AppI18n INSTANCE = new AppI18n(); return FileVisitResult.CONTINUE; } - var name = file.getFileName().toString().substring(0, file.getFileName().toString().lastIndexOf("_")); + var name = file.getFileName() + .toString() + .substring(0, file.getFileName().toString().lastIndexOf("_")); try (var in = Files.newInputStream(file)) { var usedPrefix = moduleName + ":"; - markdownDocumentations.put(usedPrefix + name, new String(in.readAllBytes(), StandardCharsets.UTF_8)); + markdownDocumentations.put( + usedPrefix + name, new String(in.readAllBytes(), StandardCharsets.UTF_8)); } catch (IOException ex) { ErrorEvent.fromThrowable(ex).omitted(true).build().handle(); } diff --git a/app/src/main/java/io/xpipe/app/core/AppImages.java b/app/src/main/java/io/xpipe/app/core/AppImages.java index c875f230e..1582ae57e 100644 --- a/app/src/main/java/io/xpipe/app/core/AppImages.java +++ b/app/src/main/java/io/xpipe/app/core/AppImages.java @@ -38,9 +38,9 @@ public class AppImages { var simpleName = FilenameUtils.getExtension(module); String defaultPrefix = simpleName + ":"; - Files.walkFileTree(basePath, new SimpleFileVisitor() { + Files.walkFileTree(basePath, new SimpleFileVisitor<>() { @Override - public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) { var relativeFileName = FilenameUtils.separatorsToUnix( basePath.relativize(file).toString()); try { @@ -108,8 +108,8 @@ public class AppImages { } public static BufferedImage toAwtImage(Image fxImage) { - BufferedImage img = new BufferedImage( - (int) fxImage.getWidth(), (int) fxImage.getHeight(), BufferedImage.TYPE_INT_ARGB); + BufferedImage img = + new BufferedImage((int) fxImage.getWidth(), (int) fxImage.getHeight(), BufferedImage.TYPE_INT_ARGB); for (int x = 0; x < fxImage.getWidth(); x++) { for (int y = 0; y < fxImage.getHeight(); y++) { int rgb = fxImage.getPixelReader().getArgb(x, y); diff --git a/app/src/main/java/io/xpipe/app/core/AppMainWindow.java b/app/src/main/java/io/xpipe/app/core/AppMainWindow.java index db8baad25..291d10bf8 100644 --- a/app/src/main/java/io/xpipe/app/core/AppMainWindow.java +++ b/app/src/main/java/io/xpipe/app/core/AppMainWindow.java @@ -255,7 +255,7 @@ public class AppMainWindow { var awt = AppImages.toAwtImage(image); var file = Path.of(System.getProperty("user.home"), "Desktop", "xpipe-screenshot.png"); try { - ImageIO.write(awt, "png",file.toFile()); + ImageIO.write(awt, "png", file.toFile()); } catch (IOException e) { ErrorEvent.fromThrowable(e).handle(); } diff --git a/app/src/main/java/io/xpipe/app/core/AppProperties.java b/app/src/main/java/io/xpipe/app/core/AppProperties.java index 8f9810972..69ac8243c 100644 --- a/app/src/main/java/io/xpipe/app/core/AppProperties.java +++ b/app/src/main/java/io/xpipe/app/core/AppProperties.java @@ -35,7 +35,8 @@ public class AppProperties { fullVersion = Optional.ofNullable(System.getProperty("io.xpipe.app.fullVersion")) .map(Boolean::parseBoolean) .orElse(false); - version = Optional.ofNullable(System.getProperty("io.xpipe.app.version")).orElse("dev"); + version = + Optional.ofNullable(System.getProperty("io.xpipe.app.version")).orElse("dev"); build = Optional.ofNullable(System.getProperty("io.xpipe.app.build")).orElse("unknown"); buildUuid = Optional.ofNullable(System.getProperty("io.xpipe.app.buildId")) .map(UUID::fromString) diff --git a/app/src/main/java/io/xpipe/app/core/AppResources.java b/app/src/main/java/io/xpipe/app/core/AppResources.java index 46478048b..8dd414ce1 100644 --- a/app/src/main/java/io/xpipe/app/core/AppResources.java +++ b/app/src/main/java/io/xpipe/app/core/AppResources.java @@ -71,8 +71,7 @@ public class AppResources { } } - private static boolean withLocalDevResource( - String module, String file, FailableConsumer con) { + private static boolean withLocalDevResource(String module, String file, FailableConsumer con) { try (var fs = openFileSystem(module)) { var url = fs.getPath("").getWrappedPath().toUri().toURL(); if (!url.getProtocol().equals("jar")) { diff --git a/app/src/main/java/io/xpipe/app/core/AppSocketServer.java b/app/src/main/java/io/xpipe/app/core/AppSocketServer.java index 28fa6a26e..3870d7e7e 100644 --- a/app/src/main/java/io/xpipe/app/core/AppSocketServer.java +++ b/app/src/main/java/io/xpipe/app/core/AppSocketServer.java @@ -79,7 +79,7 @@ public class AppSocketServer { } try { listenerThread.join(); - } catch (InterruptedException e) { + } catch (InterruptedException ignored) { } } @@ -89,7 +89,7 @@ public class AppSocketServer { listenerThread = new Thread( () -> { while (running) { - Socket clientSocket = null; + Socket clientSocket; try { clientSocket = socket.accept(); } catch (Exception ex) { @@ -114,7 +114,7 @@ public class AppSocketServer { return false; } - JsonNode node = null; + JsonNode node; try (InputStream blockIn = BeaconFormat.readBlocks(clientSocket.getInputStream())) { node = JacksonMapper.newMapper().readTree(blockIn); } @@ -180,7 +180,7 @@ public class AppSocketServer { private void performExchanges(Socket clientSocket, int id) { try { - JsonNode informationNode = null; + JsonNode informationNode; try (InputStream blockIn = BeaconFormat.readBlocks(clientSocket.getInputStream())) { informationNode = JacksonMapper.newMapper().readTree(blockIn); } @@ -230,10 +230,8 @@ public class AppSocketServer { Deobfuscator.deobfuscate(ex); sendServerErrorResponse(clientSocket, ex); } - } catch (SocketException ex) { - // Omit it, as this might happen often - ErrorEvent.fromThrowable(ex).omitted(true).build().handle(); - } catch (Throwable ex) { + } // Omit it, as this might happen often + catch (Throwable ex) { ErrorEvent.fromThrowable(ex).build().handle(); } finally { try { diff --git a/app/src/main/java/io/xpipe/app/core/AppSplashScreen.java b/app/src/main/java/io/xpipe/app/core/AppSplashScreen.java index 3e30397a5..1cdf40aab 100644 --- a/app/src/main/java/io/xpipe/app/core/AppSplashScreen.java +++ b/app/src/main/java/io/xpipe/app/core/AppSplashScreen.java @@ -16,7 +16,8 @@ public class AppSplashScreen { stage.setResizable(false); stage.initStyle(StageStyle.TRANSPARENT); - var content = new ImageView(Main.class.getResource("resources/img/loading.gif").toString()); + var content = new ImageView( + Main.class.getResource("resources/img/loading.gif").toString()); var scene = new Scene(new Pane(content), -1, -1, false); stage.setScene(scene); stage.show(); diff --git a/app/src/main/java/io/xpipe/app/core/AppStyle.java b/app/src/main/java/io/xpipe/app/core/AppStyle.java index f7cef72f1..7cd5cd518 100644 --- a/app/src/main/java/io/xpipe/app/core/AppStyle.java +++ b/app/src/main/java/io/xpipe/app/core/AppStyle.java @@ -100,5 +100,4 @@ public class AppStyle { scenes.add(scene); } - } diff --git a/app/src/main/java/io/xpipe/app/core/AppTheme.java b/app/src/main/java/io/xpipe/app/core/AppTheme.java index 33cd9095b..3ce3f6a1b 100644 --- a/app/src/main/java/io/xpipe/app/core/AppTheme.java +++ b/app/src/main/java/io/xpipe/app/core/AppTheme.java @@ -95,9 +95,11 @@ public class AppTheme { // Animate! var transition = new Timeline( - new KeyFrame(Duration.ZERO, new KeyValue(imageView.opacityProperty(), 1, Interpolator.EASE_OUT)), new KeyFrame( - Duration.millis(1250), new KeyValue(imageView.opacityProperty(), 0, Interpolator.EASE_OUT))); + Duration.ZERO, new KeyValue(imageView.opacityProperty(), 1, Interpolator.EASE_OUT)), + new KeyFrame( + Duration.millis(1250), + new KeyValue(imageView.opacityProperty(), 0, Interpolator.EASE_OUT))); transition.setOnFinished(e -> { root.getChildren().remove(imageView); }); diff --git a/app/src/main/java/io/xpipe/app/core/AppWindowHelper.java b/app/src/main/java/io/xpipe/app/core/AppWindowHelper.java index 402ae634c..60f9be3ad 100644 --- a/app/src/main/java/io/xpipe/app/core/AppWindowHelper.java +++ b/app/src/main/java/io/xpipe/app/core/AppWindowHelper.java @@ -73,7 +73,8 @@ public class AppWindowHelper { childStage.setY(stage.getY() + stage.getHeight() / 2 - childStage.getHeight() / 2); } - public static void showAlert(Consumer c, ObservableValue loading, Consumer> bt) { + public static void showAlert( + Consumer c, ObservableValue loading, Consumer> bt) { ThreadHelper.runAsync(() -> { var r = showBlockingAlert(c); if (bt != null) { diff --git a/app/src/main/java/io/xpipe/app/core/mode/OperationMode.java b/app/src/main/java/io/xpipe/app/core/mode/OperationMode.java index 4e54bf84d..64066374d 100644 --- a/app/src/main/java/io/xpipe/app/core/mode/OperationMode.java +++ b/app/src/main/java/io/xpipe/app/core/mode/OperationMode.java @@ -264,7 +264,7 @@ public abstract class OperationMode { public abstract void onSwitchTo(); - public abstract void onSwitchFrom() throws Throwable; + public abstract void onSwitchFrom(); public abstract void initialSetup() throws Throwable; diff --git a/app/src/main/java/io/xpipe/app/core/mode/PlatformMode.java b/app/src/main/java/io/xpipe/app/core/mode/PlatformMode.java index 63ceeddcd..ba242d5f1 100644 --- a/app/src/main/java/io/xpipe/app/core/mode/PlatformMode.java +++ b/app/src/main/java/io/xpipe/app/core/mode/PlatformMode.java @@ -77,7 +77,6 @@ public abstract class PlatformMode extends OperationMode { ThreadHelper.sleep(100); } - // If we downloaded an update, and decided to no longer automatically update, don't remind us! // You can still update manually in the about tab if (AppPrefs.get().automaticallyUpdate().get()) { @@ -91,7 +90,9 @@ public abstract class PlatformMode extends OperationMode { protected void waitForPlatform() { // The platform thread waits for the shutdown hook to finish in case SIGTERM is sent. // Therefore, we do not wait for the platform when being in a shutdown hook. - if (PlatformState.getCurrent() == PlatformState.RUNNING && !Platform.isFxApplicationThread() && !OperationMode.isInShutdownHook()) { + if (PlatformState.getCurrent() == PlatformState.RUNNING + && !Platform.isFxApplicationThread() + && !OperationMode.isInShutdownHook()) { TrackEvent.info("mode", "Waiting for platform thread ..."); CountDownLatch latch = new CountDownLatch(1); Platform.runLater(latch::countDown); diff --git a/app/src/main/java/io/xpipe/app/exchange/AskpassExchangeImpl.java b/app/src/main/java/io/xpipe/app/exchange/AskpassExchangeImpl.java index 09dda3227..d721f482c 100644 --- a/app/src/main/java/io/xpipe/app/exchange/AskpassExchangeImpl.java +++ b/app/src/main/java/io/xpipe/app/exchange/AskpassExchangeImpl.java @@ -21,15 +21,15 @@ public class AskpassExchangeImpl extends AskpassExchange private final Map passwords = new HashMap<>(); @Override - public Response handleRequest(BeaconHandler handler, Request msg) throws Exception { + public Response handleRequest(BeaconHandler handler, Request msg) { if (OperationMode.get().equals(OperationMode.BACKGROUND)) { OperationMode.switchTo(OperationMode.TRAY); } -// SecretValue set = AppCache.get(msg.getId(), SecretValue.class, () -> null); -// if (set != null) { -// return Response.builder().value(set).build(); -// } + // SecretValue set = AppCache.get(msg.getId(), SecretValue.class, () -> null); + // if (set != null) { + // return Response.builder().value(set).build(); + // } if (requestToId.containsKey(msg.getRequest())) { var id = requestToId.remove(msg.getRequest()); @@ -37,11 +37,12 @@ public class AskpassExchangeImpl extends AskpassExchange } if (passwords.containsKey(msg.getId())) { - return Response.builder().value(passwords.get(msg.getId()).getSecretValue()).build(); + return Response.builder() + .value(passwords.get(msg.getId()).getSecretValue()) + .build(); } - var prop = - new SimpleObjectProperty(); + var prop = new SimpleObjectProperty(); var r = AppWindowHelper.showBlockingAlert(alert -> { alert.setTitle(AppI18n.get("askpassAlertTitle")); alert.setHeaderText(msg.getPrompt()); @@ -52,7 +53,7 @@ public class AskpassExchangeImpl extends AskpassExchange }) .filter(b -> b.getButtonData().isDefaultButton() && prop.getValue() != null) .map(t -> { - //AppCache.update(msg.getId(), prop.getValue()); + // AppCache.update(msg.getId(), prop.getValue()); return prop.getValue(); }) .orElse(null); diff --git a/app/src/main/java/io/xpipe/app/exchange/FocusExchangeImpl.java b/app/src/main/java/io/xpipe/app/exchange/FocusExchangeImpl.java index 623dd9037..2b5181d5d 100644 --- a/app/src/main/java/io/xpipe/app/exchange/FocusExchangeImpl.java +++ b/app/src/main/java/io/xpipe/app/exchange/FocusExchangeImpl.java @@ -8,7 +8,7 @@ public class FocusExchangeImpl extends FocusExchange implements MessageExchangeImpl { @Override - public Response handleRequest(BeaconHandler handler, Request msg) throws Exception { + public Response handleRequest(BeaconHandler handler, Request msg) { OperationMode.switchUp(OperationMode.map(msg.getMode())); return Response.builder().build(); } diff --git a/app/src/main/java/io/xpipe/app/exchange/OpenExchangeImpl.java b/app/src/main/java/io/xpipe/app/exchange/OpenExchangeImpl.java index 053d9436e..e9a38369b 100644 --- a/app/src/main/java/io/xpipe/app/exchange/OpenExchangeImpl.java +++ b/app/src/main/java/io/xpipe/app/exchange/OpenExchangeImpl.java @@ -9,7 +9,7 @@ public class OpenExchangeImpl extends OpenExchange implements MessageExchangeImpl { @Override - public Response handleRequest(BeaconHandler handler, Request msg) throws Exception { + public Response handleRequest(BeaconHandler handler, Request msg) { if (msg.getArguments().size() == 0) { OperationMode.switchToAsync(OperationMode.GUI); } diff --git a/app/src/main/java/io/xpipe/app/exchange/ProxyFunctionExchangeImpl.java b/app/src/main/java/io/xpipe/app/exchange/ProxyFunctionExchangeImpl.java index 84439c6d9..eeae40ab3 100644 --- a/app/src/main/java/io/xpipe/app/exchange/ProxyFunctionExchangeImpl.java +++ b/app/src/main/java/io/xpipe/app/exchange/ProxyFunctionExchangeImpl.java @@ -7,7 +7,7 @@ public class ProxyFunctionExchangeImpl extends ProxyFunctionExchange implements MessageExchangeImpl { @Override - public Response handleRequest(BeaconHandler handler, Request msg) throws Exception { + public Response handleRequest(BeaconHandler handler, Request msg) { msg.getFunction().callLocal(); return ProxyFunctionExchange.Response.builder() .function(msg.getFunction()) diff --git a/app/src/main/java/io/xpipe/app/exchange/ProxyReadConnectionExchangeImpl.java b/app/src/main/java/io/xpipe/app/exchange/ProxyReadConnectionExchangeImpl.java index 1a5ef4fbf..cccb46666 100644 --- a/app/src/main/java/io/xpipe/app/exchange/ProxyReadConnectionExchangeImpl.java +++ b/app/src/main/java/io/xpipe/app/exchange/ProxyReadConnectionExchangeImpl.java @@ -11,7 +11,7 @@ public class ProxyReadConnectionExchangeImpl extends ProxyReadConnectionExchange implements MessageExchangeImpl { @Override - public Response handleRequest(BeaconHandler handler, Request msg) throws Exception { + public Response handleRequest(BeaconHandler handler, Request msg) { handler.postResponse(() -> { var outputSource = DataSource.createInternalDataSource( msg.getSource().getType(), new OutputStreamStore(handler.sendBody())); diff --git a/app/src/main/java/io/xpipe/app/exchange/VersionExchangeImpl.java b/app/src/main/java/io/xpipe/app/exchange/VersionExchangeImpl.java index 085a7dfdb..9115b06f8 100644 --- a/app/src/main/java/io/xpipe/app/exchange/VersionExchangeImpl.java +++ b/app/src/main/java/io/xpipe/app/exchange/VersionExchangeImpl.java @@ -8,7 +8,7 @@ public class VersionExchangeImpl extends VersionExchange implements MessageExchangeImpl { @Override - public Response handleRequest(BeaconHandler handler, Request msg) throws Exception { + public Response handleRequest(BeaconHandler handler, Request msg) { var jvmVersion = System.getProperty("java.vm.vendor") + " " + System.getProperty("java.vm.name") + " (" + System.getProperty("java.vm.version") + ")"; diff --git a/app/src/main/java/io/xpipe/app/exchange/cli/InstanceExchangeImpl.java b/app/src/main/java/io/xpipe/app/exchange/cli/InstanceExchangeImpl.java index c85e6b636..4240312dc 100644 --- a/app/src/main/java/io/xpipe/app/exchange/cli/InstanceExchangeImpl.java +++ b/app/src/main/java/io/xpipe/app/exchange/cli/InstanceExchangeImpl.java @@ -10,7 +10,7 @@ public class InstanceExchangeImpl extends InstanceExchange implements MessageExchangeImpl { @Override - public Response handleRequest(BeaconHandler handler, Request msg) throws Exception { + public Response handleRequest(BeaconHandler handler, Request msg) { return Response.builder() .instance(XPipeInstanceHelper.getInstance(new LocalStore()).orElseThrow()) .build(); diff --git a/app/src/main/java/io/xpipe/app/exchange/cli/ListCollectionsExchangeImpl.java b/app/src/main/java/io/xpipe/app/exchange/cli/ListCollectionsExchangeImpl.java index a969ca82d..f15cce801 100644 --- a/app/src/main/java/io/xpipe/app/exchange/cli/ListCollectionsExchangeImpl.java +++ b/app/src/main/java/io/xpipe/app/exchange/cli/ListCollectionsExchangeImpl.java @@ -10,7 +10,7 @@ public class ListCollectionsExchangeImpl extends ListCollectionsExchange implements MessageExchangeImpl { @Override - public Response handleRequest(BeaconHandler handler, Request msg) throws Exception { + public Response handleRequest(BeaconHandler handler, Request msg) { DataStorage s = DataStorage.get(); var e = s.getSourceCollections().stream() .map(col -> CollectionListEntry.builder() diff --git a/app/src/main/java/io/xpipe/app/exchange/cli/ListStoresExchangeImpl.java b/app/src/main/java/io/xpipe/app/exchange/cli/ListStoresExchangeImpl.java index c9e088743..a672460e3 100644 --- a/app/src/main/java/io/xpipe/app/exchange/cli/ListStoresExchangeImpl.java +++ b/app/src/main/java/io/xpipe/app/exchange/cli/ListStoresExchangeImpl.java @@ -12,7 +12,7 @@ public class ListStoresExchangeImpl extends ListStoresExchange implements MessageExchangeImpl { @Override - public Response handleRequest(BeaconHandler handler, Request msg) throws Exception { + public Response handleRequest(BeaconHandler handler, Request msg) { DataStorage s = DataStorage.get(); var e = s.getStoreEntries().stream() .filter(entry -> !entry.isDisabled() && entry.getProvider().shouldShow()) diff --git a/app/src/main/java/io/xpipe/app/exchange/cli/RenameStoreExchangeImpl.java b/app/src/main/java/io/xpipe/app/exchange/cli/RenameStoreExchangeImpl.java index 7fdbb3c8f..3544fee46 100644 --- a/app/src/main/java/io/xpipe/app/exchange/cli/RenameStoreExchangeImpl.java +++ b/app/src/main/java/io/xpipe/app/exchange/cli/RenameStoreExchangeImpl.java @@ -9,7 +9,7 @@ public class RenameStoreExchangeImpl extends RenameStoreExchange implements MessageExchangeImpl { @Override - public Response handleRequest(BeaconHandler handler, Request msg) throws Exception { + public Response handleRequest(BeaconHandler handler, Request msg) { var s = DataStorage.get().getStoreEntry(msg.getStoreName(), true); DataStorage.get().renameStoreEntry(s, msg.getNewName()); return Response.builder().build(); diff --git a/app/src/main/java/io/xpipe/app/exchange/cli/SourceProviderListExchangeImpl.java b/app/src/main/java/io/xpipe/app/exchange/cli/SourceProviderListExchangeImpl.java index befa791e9..227dde193 100644 --- a/app/src/main/java/io/xpipe/app/exchange/cli/SourceProviderListExchangeImpl.java +++ b/app/src/main/java/io/xpipe/app/exchange/cli/SourceProviderListExchangeImpl.java @@ -15,7 +15,7 @@ public class SourceProviderListExchangeImpl extends SourceProviderListExchange implements MessageExchangeImpl { @Override - public Response handleRequest(BeaconHandler handler, Request msg) throws Exception { + public Response handleRequest(BeaconHandler handler, Request msg) { var all = DataSourceProviders.getAll(); var map = new LinkedHashMap>(); for (DataSourceType t : DataSourceType.values()) { diff --git a/app/src/main/java/io/xpipe/app/exchange/cli/StatusExchangeImpl.java b/app/src/main/java/io/xpipe/app/exchange/cli/StatusExchangeImpl.java index 58de02e2d..520a2e913 100644 --- a/app/src/main/java/io/xpipe/app/exchange/cli/StatusExchangeImpl.java +++ b/app/src/main/java/io/xpipe/app/exchange/cli/StatusExchangeImpl.java @@ -9,7 +9,7 @@ public class StatusExchangeImpl extends StatusExchange implements MessageExchangeImpl { @Override - public Response handleRequest(BeaconHandler handler, Request msg) throws Exception { + public Response handleRequest(BeaconHandler handler, Request msg) { String mode; if (OperationMode.get() == null) { mode = "none"; diff --git a/app/src/main/java/io/xpipe/app/exchange/cli/StopExchangeImpl.java b/app/src/main/java/io/xpipe/app/exchange/cli/StopExchangeImpl.java index 20ca353e6..df02c0b6d 100644 --- a/app/src/main/java/io/xpipe/app/exchange/cli/StopExchangeImpl.java +++ b/app/src/main/java/io/xpipe/app/exchange/cli/StopExchangeImpl.java @@ -10,7 +10,7 @@ public class StopExchangeImpl extends StopExchange implements MessageExchangeImpl { @Override - public Response handleRequest(BeaconHandler handler, Request msg) throws Exception { + public Response handleRequest(BeaconHandler handler, Request msg) { handler.postResponse(() -> { ThreadHelper.runAsync(() -> { ThreadHelper.sleep(1000); diff --git a/app/src/main/java/io/xpipe/app/exchange/cli/StoreAddExchangeImpl.java b/app/src/main/java/io/xpipe/app/exchange/cli/StoreAddExchangeImpl.java index d4b71c04c..69a79ab69 100644 --- a/app/src/main/java/io/xpipe/app/exchange/cli/StoreAddExchangeImpl.java +++ b/app/src/main/java/io/xpipe/app/exchange/cli/StoreAddExchangeImpl.java @@ -26,8 +26,8 @@ public class StoreAddExchangeImpl extends StoreAddExchange @Override @SneakyThrows - public StoreAddExchange.Response handleRequest(BeaconHandler handler, Request msg) throws Exception { - Dialog creatorDialog = null; + public StoreAddExchange.Response handleRequest(BeaconHandler handler, Request msg) { + Dialog creatorDialog; DataStoreProvider provider; if (msg.getStoreInput() != null) { creatorDialog = Dialog.empty().evaluateTo(msg::getStoreInput); diff --git a/app/src/main/java/io/xpipe/app/exchange/cli/StoreProviderListExchangeImpl.java b/app/src/main/java/io/xpipe/app/exchange/cli/StoreProviderListExchangeImpl.java index abc70cc52..81809a6f9 100644 --- a/app/src/main/java/io/xpipe/app/exchange/cli/StoreProviderListExchangeImpl.java +++ b/app/src/main/java/io/xpipe/app/exchange/cli/StoreProviderListExchangeImpl.java @@ -14,7 +14,7 @@ public class StoreProviderListExchangeImpl extends StoreProviderListExchange implements MessageExchangeImpl { @Override - public Response handleRequest(BeaconHandler handler, Request msg) throws Exception { + public Response handleRequest(BeaconHandler handler, Request msg) { var categories = DataStoreProvider.DataCategory.values(); var all = DataStoreProviders.getAll(); var map = Arrays.stream(categories) diff --git a/app/src/main/java/io/xpipe/app/ext/ActionProvider.java b/app/src/main/java/io/xpipe/app/ext/ActionProvider.java index 399215a8b..11e667992 100644 --- a/app/src/main/java/io/xpipe/app/ext/ActionProvider.java +++ b/app/src/main/java/io/xpipe/app/ext/ActionProvider.java @@ -1,9 +1,9 @@ package io.xpipe.app.ext; import io.xpipe.app.issue.ErrorEvent; -import io.xpipe.core.util.ModuleLayerLoader; import io.xpipe.core.source.DataSource; import io.xpipe.core.store.DataStore; +import io.xpipe.core.util.ModuleLayerLoader; import javafx.beans.value.ObservableValue; import java.util.ArrayList; @@ -13,9 +13,9 @@ import java.util.stream.Collectors; public interface ActionProvider { - static List ALL = new ArrayList<>(); + List ALL = new ArrayList<>(); - public static class Loader implements ModuleLayerLoader { + class Loader implements ModuleLayerLoader { @Override public void init(ModuleLayer layer) { @@ -50,7 +50,7 @@ public interface ActionProvider { void execute() throws Exception; } - default boolean isActive() throws Exception { + default boolean isActive() { return true; } @@ -68,6 +68,7 @@ public interface ActionProvider { default DataStoreCallSite getDataStoreCallSite() { return null; } + default DefaultDataStoreCallSite getDefaultDataStoreCallSite() { return null; } @@ -76,8 +77,7 @@ public interface ActionProvider { return null; } - - public static interface DefaultDataStoreCallSite { + interface DefaultDataStoreCallSite { Action createAction(T store); @@ -88,7 +88,7 @@ public interface ActionProvider { } } - public static interface DataStoreCallSite { + interface DataStoreCallSite { enum ActiveType { ONLY_SHOW_IF_ENABLED, @@ -104,7 +104,7 @@ public interface ActionProvider { return false; } - default boolean isApplicable(T o) throws Exception { + default boolean isApplicable(T o) { return true; } @@ -117,7 +117,7 @@ public interface ActionProvider { } } - public static interface DataSourceCallSite> { + interface DataSourceCallSite> { Action createAction(T source); @@ -127,7 +127,7 @@ public interface ActionProvider { return false; } - default boolean isApplicable(T o) throws Exception { + default boolean isApplicable(T o) { return true; } diff --git a/app/src/main/java/io/xpipe/app/ext/DataSourceProvider.java b/app/src/main/java/io/xpipe/app/ext/DataSourceProvider.java index 9414b434a..94cf2d524 100644 --- a/app/src/main/java/io/xpipe/app/ext/DataSourceProvider.java +++ b/app/src/main/java/io/xpipe/app/ext/DataSourceProvider.java @@ -18,7 +18,7 @@ public interface DataSourceProvider> { return null; } - default void validate() throws Exception { + default void validate() { getCategory(); getSourceClass(); } @@ -67,7 +67,7 @@ public interface DataSourceProvider> { return i != -1 ? n.substring(i + 1) : n; } - default String queryInformationString(DataStore store, int length) throws Exception { + default String queryInformationString(DataStore store, int length) { return getDisplayName(); } @@ -125,9 +125,9 @@ public interface DataSourceProvider> { List getPossibleNames(); - static enum Category { + enum Category { STREAM, - DATABASE; + DATABASE } interface FileProvider { diff --git a/app/src/main/java/io/xpipe/app/ext/DataSourceTarget.java b/app/src/main/java/io/xpipe/app/ext/DataSourceTarget.java index 2095f2ac2..720b6d9ca 100644 --- a/app/src/main/java/io/xpipe/app/ext/DataSourceTarget.java +++ b/app/src/main/java/io/xpipe/app/ext/DataSourceTarget.java @@ -1,9 +1,9 @@ package io.xpipe.app.ext; -import io.xpipe.core.util.ModuleLayerLoader; import io.xpipe.app.util.Validator; import io.xpipe.core.source.DataSource; import io.xpipe.core.source.DataSourceId; +import io.xpipe.core.util.ModuleLayerLoader; import javafx.beans.value.ObservableValue; import javafx.scene.layout.Region; import lombok.AllArgsConstructor; @@ -16,10 +16,9 @@ import java.util.ServiceLoader; public interface DataSourceTarget { - static List ALL = new ArrayList<>(); - ; + List ALL = new ArrayList<>(); - public static class Loader implements ModuleLayerLoader { + class Loader implements ModuleLayerLoader { @Override public void init(ModuleLayer layer) { @@ -40,11 +39,11 @@ public interface DataSourceTarget { } } - public static Optional byId(String id) { + static Optional byId(String id) { return ALL.stream().filter(d -> d.getId().equals(id)).findAny(); } - public static List getAll() { + static List getAll() { return ALL; } @@ -87,7 +86,7 @@ public interface DataSourceTarget { @Value @AllArgsConstructor - public static class InstructionsDisplay { + class InstructionsDisplay { Region region; Runnable onFinish; Validator validator; diff --git a/app/src/main/java/io/xpipe/app/ext/DataStoreProvider.java b/app/src/main/java/io/xpipe/app/ext/DataStoreProvider.java index d54d6f23e..810436455 100644 --- a/app/src/main/java/io/xpipe/app/ext/DataStoreProvider.java +++ b/app/src/main/java/io/xpipe/app/ext/DataStoreProvider.java @@ -21,7 +21,7 @@ public interface DataStoreProvider { return null; } - default void validate() throws Exception { + default void validate() { getCategory(); for (Class storeClass : getStoreClasses()) { if (!JacksonizedValue.class.isAssignableFrom(storeClass)) { @@ -32,14 +32,20 @@ public interface DataStoreProvider { } default Comp createInsightsComp(ObservableValue store) { - var content = Bindings.createStringBinding(() -> { - if (store.getValue() == null || !store.getValue().isComplete() || !getStoreClasses().contains(store.getValue().getClass())) { - return null; - } + var content = Bindings.createStringBinding( + () -> { + if (store.getValue() == null + || !store.getValue().isComplete() + || !getStoreClasses().contains(store.getValue().getClass())) { + return null; + } - return createInsightsMarkdown(store.getValue()); - }, store); - var markdown = new MarkdownComp(content, s -> s).apply(struc -> struc.get().setPrefWidth(450)).apply(struc -> struc.get().setPrefHeight(200)); + return createInsightsMarkdown(store.getValue()); + }, + store); + var markdown = new MarkdownComp(content, s -> s) + .apply(struc -> struc.get().setPrefWidth(450)) + .apply(struc -> struc.get().setPrefHeight(200)); return markdown; } @@ -91,7 +97,7 @@ public interface DataStoreProvider { String queryInformationString(DataStore store, int length) throws Exception; - public String toSummaryString(DataStore store, int length); + String toSummaryString(DataStore store, int length); default String i18n(String key) { return AppI18n.get(getId() + "." + key); @@ -140,7 +146,7 @@ public interface DataStoreProvider { enum DataCategory { STREAM, SHELL, - DATABASE; + DATABASE } enum DisplayCategory { @@ -148,6 +154,6 @@ public interface DataStoreProvider { DATABASE, SHELL, COMMAND, - OTHER; + OTHER } } diff --git a/app/src/main/java/io/xpipe/app/ext/DownloadModuleInstall.java b/app/src/main/java/io/xpipe/app/ext/DownloadModuleInstall.java index 9a9097b66..43dfdb7cd 100644 --- a/app/src/main/java/io/xpipe/app/ext/DownloadModuleInstall.java +++ b/app/src/main/java/io/xpipe/app/ext/DownloadModuleInstall.java @@ -6,11 +6,11 @@ import java.util.List; public abstract class DownloadModuleInstall extends ModuleInstall { - private String licenseFile; - private String vendorURL; + private final String licenseFile; + private final String vendorURL; @Getter - private List assets; + private final List assets; public DownloadModuleInstall(String id, String module, String licenseFile, String vendorURL, List assets) { super(id, module); diff --git a/app/src/main/java/io/xpipe/app/ext/XPipeServiceProviders.java b/app/src/main/java/io/xpipe/app/ext/XPipeServiceProviders.java index 2c4e631ea..7604e080d 100644 --- a/app/src/main/java/io/xpipe/app/ext/XPipeServiceProviders.java +++ b/app/src/main/java/io/xpipe/app/ext/XPipeServiceProviders.java @@ -3,10 +3,10 @@ package io.xpipe.app.ext; import com.fasterxml.jackson.databind.jsontype.NamedType; import io.xpipe.app.issue.ErrorEvent; import io.xpipe.app.issue.TrackEvent; -import io.xpipe.core.util.ModuleLayerLoader; import io.xpipe.app.util.XPipeDaemon; import io.xpipe.core.process.ProcessControlProvider; import io.xpipe.core.util.JacksonMapper; +import io.xpipe.core.util.ModuleLayerLoader; import io.xpipe.core.util.ProxyFunction; public class XPipeServiceProviders { diff --git a/app/src/main/java/io/xpipe/app/fxcomps/Comp.java b/app/src/main/java/io/xpipe/app/fxcomps/Comp.java index 8783c312a..669acb3e3 100644 --- a/app/src/main/java/io/xpipe/app/fxcomps/Comp.java +++ b/app/src/main/java/io/xpipe/app/fxcomps/Comp.java @@ -102,7 +102,6 @@ public abstract class Comp> { return apply(struc -> struc.get().setAccessibleText(text)); } - public Comp grow(boolean width, boolean height) { return apply(GrowAugment.create(width, height)); } diff --git a/app/src/main/java/io/xpipe/app/fxcomps/impl/CharChoiceComp.java b/app/src/main/java/io/xpipe/app/fxcomps/impl/CharChoiceComp.java index e2eed12a7..668757c5b 100644 --- a/app/src/main/java/io/xpipe/app/fxcomps/impl/CharChoiceComp.java +++ b/app/src/main/java/io/xpipe/app/fxcomps/impl/CharChoiceComp.java @@ -33,7 +33,7 @@ public class CharChoiceComp extends Comp> { if (customName != null) { rangeCopy.put(null, customName); } - var choice = new ChoiceComp(value, rangeCopy, false); + var choice = new ChoiceComp<>(value, rangeCopy, false); var charChoiceR = charChoice.createRegion(); var choiceR = choice.createRegion(); var box = new HBox(charChoiceR, choiceR); diff --git a/app/src/main/java/io/xpipe/app/fxcomps/impl/ChoiceComp.java b/app/src/main/java/io/xpipe/app/fxcomps/impl/ChoiceComp.java index 8df53be03..431b83a57 100644 --- a/app/src/main/java/io/xpipe/app/fxcomps/impl/ChoiceComp.java +++ b/app/src/main/java/io/xpipe/app/fxcomps/impl/ChoiceComp.java @@ -40,7 +40,7 @@ public class ChoiceComp extends Comp>> { @Override public CompStructure> createBase() { var cb = new ComboBox(); - cb.setConverter(new StringConverter() { + cb.setConverter(new StringConverter<>() { @Override public String toString(T object) { if (object == null) { diff --git a/app/src/main/java/io/xpipe/app/fxcomps/impl/ChoicePaneComp.java b/app/src/main/java/io/xpipe/app/fxcomps/impl/ChoicePaneComp.java index 3db92f7fe..c2032a1d6 100644 --- a/app/src/main/java/io/xpipe/app/fxcomps/impl/ChoicePaneComp.java +++ b/app/src/main/java/io/xpipe/app/fxcomps/impl/ChoicePaneComp.java @@ -32,7 +32,7 @@ public class ChoicePaneComp extends Comp> { @Override public CompStructure createBase() { var list = FXCollections.observableArrayList(entries); - var cb = new ComboBox(list); + var cb = new ComboBox<>(list); cb.setConverter(new StringConverter<>() { @Override public String toString(Entry object) { diff --git a/app/src/main/java/io/xpipe/app/fxcomps/impl/CodeSnippetComp.java b/app/src/main/java/io/xpipe/app/fxcomps/impl/CodeSnippetComp.java index 7e3a89b3a..3e30b0789 100644 --- a/app/src/main/java/io/xpipe/app/fxcomps/impl/CodeSnippetComp.java +++ b/app/src/main/java/io/xpipe/app/fxcomps/impl/CodeSnippetComp.java @@ -87,8 +87,7 @@ public class CodeSnippetComp extends Comp> { s.getParent().fireEvent(e); e.consume(); }); - s.prefHeightProperty() - .setValue(20 * this.value.getValue().lines().stream().count()); + s.prefHeightProperty().setValue(20 * this.value.getValue().lines().size()); var lineNumbers = new VBox(); lineNumbers.getStyleClass().add("line-numbers"); diff --git a/app/src/main/java/io/xpipe/app/fxcomps/impl/DataStoreChoiceComp.java b/app/src/main/java/io/xpipe/app/fxcomps/impl/DataStoreChoiceComp.java index 86002017a..d12b2222e 100644 --- a/app/src/main/java/io/xpipe/app/fxcomps/impl/DataStoreChoiceComp.java +++ b/app/src/main/java/io/xpipe/app/fxcomps/impl/DataStoreChoiceComp.java @@ -44,7 +44,7 @@ public class DataStoreChoiceComp extends SimpleComp { return new DataStoreChoiceComp<>(Mode.HOST, self, selected, ShellStore.class, shellStore -> true); } - public static enum Mode { + public enum Mode { HOST, ENVIRONMENT, OTHER, @@ -89,7 +89,7 @@ public class DataStoreChoiceComp extends SimpleComp { @SuppressWarnings("unchecked") protected Region createSimple() { var list = StoreEntryFlatMiniSectionComp.ALL; - var comboBox = new CustomComboBoxBuilder( + var comboBox = new CustomComboBoxBuilder<>( selected, t -> list.stream() .filter(e -> t.equals(e.getEntry().getStore())) diff --git a/app/src/main/java/io/xpipe/app/fxcomps/impl/FancyTooltipAugment.java b/app/src/main/java/io/xpipe/app/fxcomps/impl/FancyTooltipAugment.java index 74f6db578..34cdbef4e 100644 --- a/app/src/main/java/io/xpipe/app/fxcomps/impl/FancyTooltipAugment.java +++ b/app/src/main/java/io/xpipe/app/fxcomps/impl/FancyTooltipAugment.java @@ -15,7 +15,6 @@ import javafx.geometry.NodeOrientation; import javafx.scene.Node; import javafx.scene.Scene; import javafx.scene.input.MouseEvent; -import javafx.scene.layout.Region; import javafx.stage.Window; import javafx.util.Duration; @@ -38,8 +37,8 @@ public class FancyTooltipAugment> implements Augment< var region = struc.get(); var tt = new JFXTooltip(); var toDisplay = text.getValue(); - if (Shortcuts.getShortcut((Region) region) != null) { - toDisplay = toDisplay + " (" + Shortcuts.getShortcut((Region) region).getDisplayText() + ")"; + if (Shortcuts.getShortcut(region) != null) { + toDisplay = toDisplay + " (" + Shortcuts.getShortcut(region).getDisplayText() + ")"; } tt.textProperty().setValue(toDisplay); tt.setStyle("-fx-font-size: 11pt;"); @@ -138,8 +137,7 @@ public class FancyTooltipAugment> implements Augment< } hoveredNode = (Node) event.getSource(); Object property = hoveredNode.getProperties().get(TOOLTIP_PROP); - if (property instanceof JFXTooltip) { - JFXTooltip tooltip = (JFXTooltip) property; + if (property instanceof JFXTooltip tooltip) { ensureHoveredNodeIsVisible(() -> { // if a tooltip is already showing then show this tooltip immediately if (leftTimer.getStatus() == Timeline.Status.RUNNING) { diff --git a/app/src/main/java/io/xpipe/app/fxcomps/impl/FileStoreChoiceComp.java b/app/src/main/java/io/xpipe/app/fxcomps/impl/FileStoreChoiceComp.java index d00b7866b..ac1fccf88 100644 --- a/app/src/main/java/io/xpipe/app/fxcomps/impl/FileStoreChoiceComp.java +++ b/app/src/main/java/io/xpipe/app/fxcomps/impl/FileStoreChoiceComp.java @@ -41,7 +41,8 @@ public class FileStoreChoiceComp extends SimpleComp { fileProperty.setValue(newValue != null ? newValue.getPath() : null); }); - var fileSystemChoiceComp = new FileSystemStoreChoiceComp(selected).grow(false, true).styleClass(Styles.LEFT_PILL); + var fileSystemChoiceComp = + new FileSystemStoreChoiceComp(selected).grow(false, true).styleClass(Styles.LEFT_PILL); if (onlyLocal) { fileSystemChoiceComp.hide(new SimpleBooleanProperty(true)); } @@ -54,9 +55,11 @@ public class FileStoreChoiceComp extends SimpleComp { var fileBrowseButton = new ButtonComp(null, new FontIcon("mdi2f-folder-open-outline"), () -> { StandaloneFileBrowser.openSingleFile(selected); }) - .styleClass(Styles.RIGHT_PILL).grow(false, true); + .styleClass(Styles.RIGHT_PILL) + .grow(false, true); - var layout = new HorizontalComp(List.of(fileSystemChoiceComp, fileNameComp, fileBrowseButton)).apply(struc -> struc.get().setFillHeight(true)); + var layout = new HorizontalComp(List.of(fileSystemChoiceComp, fileNameComp, fileBrowseButton)) + .apply(struc -> struc.get().setFillHeight(true)); return layout.createRegion(); } diff --git a/app/src/main/java/io/xpipe/app/fxcomps/impl/FileSystemStoreChoiceComp.java b/app/src/main/java/io/xpipe/app/fxcomps/impl/FileSystemStoreChoiceComp.java index 1e525951c..9f646e34f 100644 --- a/app/src/main/java/io/xpipe/app/fxcomps/impl/FileSystemStoreChoiceComp.java +++ b/app/src/main/java/io/xpipe/app/fxcomps/impl/FileSystemStoreChoiceComp.java @@ -56,11 +56,10 @@ public class FileSystemStoreChoiceComp extends SimpleComp { }); selected.addListener((observable, oldValue, newValue) -> { - fileSystemProperty.setValue(newValue != null?newValue.getFileSystem():null); + fileSystemProperty.setValue(newValue != null ? newValue.getFileSystem() : null); }); - var comboBox = - new CustomComboBoxBuilder<>(fileSystemProperty, this::createGraphic, null, v -> true); + var comboBox = new CustomComboBoxBuilder<>(fileSystemProperty, this::createGraphic, null, v -> true); comboBox.setAccessibleNames(store -> getName(store)); comboBox.setSelectedDisplay(this::createDisplayGraphic); DataStorage.get().getUsableStores().stream() diff --git a/app/src/main/java/io/xpipe/app/fxcomps/impl/IconButtonComp.java b/app/src/main/java/io/xpipe/app/fxcomps/impl/IconButtonComp.java index 7ab40a4f1..9c11f1f23 100644 --- a/app/src/main/java/io/xpipe/app/fxcomps/impl/IconButtonComp.java +++ b/app/src/main/java/io/xpipe/app/fxcomps/impl/IconButtonComp.java @@ -42,7 +42,7 @@ public class IconButtonComp extends Comp> { button.fontProperty().addListener((c, o, n) -> { fi.setIconSize((int) new Size(n.getSize(), SizeUnits.PT).pixels()); }); - //fi.iconColorProperty().bind(button.textFillProperty()); + // fi.iconColorProperty().bind(button.textFillProperty()); button.setGraphic(fi); button.setOnAction(e -> { e.consume(); diff --git a/app/src/main/java/io/xpipe/app/fxcomps/impl/OptionsComp.java b/app/src/main/java/io/xpipe/app/fxcomps/impl/OptionsComp.java index 3859697b6..c4e9d318a 100644 --- a/app/src/main/java/io/xpipe/app/fxcomps/impl/OptionsComp.java +++ b/app/src/main/java/io/xpipe/app/fxcomps/impl/OptionsComp.java @@ -104,7 +104,7 @@ public class OptionsComp extends Comp> { HBox.setHgrow(descriptionBox, Priority.ALWAYS); descriptionBox.setAlignment(Pos.CENTER_LEFT); line.getChildren().add(descriptionBox); - }else { + } else { line.getChildren().add(description); } @@ -115,9 +115,7 @@ public class OptionsComp extends Comp> { } pane.getChildren().add(line); - } - - else if (entry.name() != null) { + } else if (entry.name() != null) { var line = new HBox(); line.setFillHeight(true); line.prefWidthProperty().bind(pane.widthProperty()); @@ -175,5 +173,10 @@ public class OptionsComp extends Comp> { return entries; } - public record Entry(String key, ObservableValue description, String longDescriptionSource, ObservableValue name, Comp comp) {} + public record Entry( + String key, + ObservableValue description, + String longDescriptionSource, + ObservableValue name, + Comp comp) {} } diff --git a/app/src/main/java/io/xpipe/app/fxcomps/impl/PrettyImageComp.java b/app/src/main/java/io/xpipe/app/fxcomps/impl/PrettyImageComp.java index cf7e6fd08..77da9ecc2 100644 --- a/app/src/main/java/io/xpipe/app/fxcomps/impl/PrettyImageComp.java +++ b/app/src/main/java/io/xpipe/app/fxcomps/impl/PrettyImageComp.java @@ -56,8 +56,9 @@ public class PrettyImageComp extends SimpleComp { var currentNode = new SimpleObjectProperty(); SimpleChangeListener.apply(PlatformThread.sync(value), val -> { image.set(val); - var requiresChange = val == null || (val.endsWith(".svg") && !(currentNode.get() instanceof WebView) || - !(currentNode.get() instanceof ImageView)); + var requiresChange = val == null + || (val.endsWith(".svg") && !(currentNode.get() instanceof WebView) + || !(currentNode.get() instanceof ImageView)); if (!requiresChange) { return; } @@ -66,17 +67,16 @@ public class PrettyImageComp extends SimpleComp { if (val == null) { currentNode.set(new Region()); - } - - else if (val.endsWith(".svg")) { - var storeIcon = SvgView.create( - Bindings.createStringBinding(() -> { + } else if (val.endsWith(".svg")) { + var storeIcon = SvgView.create(Bindings.createStringBinding( + () -> { if (!AppImages.hasSvgImage(image.getValue())) { return null; } return AppImages.svgImage(image.getValue()); - }, image)); + }, + image)); var ar = Bindings.createDoubleBinding( () -> { return storeIcon.getWidth().getValue().doubleValue() @@ -86,12 +86,12 @@ public class PrettyImageComp extends SimpleComp { storeIcon.getHeight()); aspectRatioProperty.bind(ar); var node = storeIcon.createWebview(); - ((WebView) node).prefWidthProperty().bind(widthProperty); - ((WebView) node).maxWidthProperty().bind(widthProperty); - ((WebView) node).minWidthProperty().bind(widthProperty); - ((WebView) node).prefHeightProperty().bind(heightProperty); - ((WebView) node).maxHeightProperty().bind(heightProperty); - ((WebView) node).minHeightProperty().bind(heightProperty); + node.prefWidthProperty().bind(widthProperty); + node.maxWidthProperty().bind(widthProperty); + node.minWidthProperty().bind(widthProperty); + node.prefHeightProperty().bind(heightProperty); + node.maxHeightProperty().bind(heightProperty); + node.minHeightProperty().bind(heightProperty); currentNode.set(node); } else { var storeIcon = new ImageView(); @@ -113,7 +113,8 @@ public class PrettyImageComp extends SimpleComp { return 1.0; } - return storeIcon.getImage().getWidth() / storeIcon.getImage().getHeight(); + return storeIcon.getImage().getWidth() + / storeIcon.getImage().getHeight(); }, storeIcon.imageProperty()); aspectRatioProperty.bind(ar); diff --git a/app/src/main/java/io/xpipe/app/fxcomps/impl/SvgCacheComp.java b/app/src/main/java/io/xpipe/app/fxcomps/impl/SvgCacheComp.java index 5ce1b728f..bbca92574 100644 --- a/app/src/main/java/io/xpipe/app/fxcomps/impl/SvgCacheComp.java +++ b/app/src/main/java/io/xpipe/app/fxcomps/impl/SvgCacheComp.java @@ -79,48 +79,47 @@ public class SvgCacheComp extends SimpleComp { stop(); SnapshotParameters parameters = new SnapshotParameters(); parameters.setFill(Color.TRANSPARENT); - if (!instance.equals(active.get())) { - active.set(null); - return; - } + if (!instance.equals(active.get())) { active.set(null); + return; + } + active.set(null); - WritableImage image = back.snapshot(parameters, null); - if (image.getWidth() < 10) { - return; - } + WritableImage image = back.snapshot(parameters, null); + if (image.getWidth() < 10) { + return; + } - if (cache.getCached(newValue).isPresent()) { - return; - } + if (cache.getCached(newValue).isPresent()) { + return; + } - if (!newValue.equals(svgFile.getValue())) { - return; - } + if (!newValue.equals(svgFile.getValue())) { + return; + } - var found = false; - out: - for (int x = 0; x < image.getWidth(); x++) { - for (int y = 0; y < image.getHeight(); y++) { - if (image.getPixelReader().getArgb(x, y) != 0x00000000) { - found = true; - break out; - } + var found = false; + out: + for (int x = 0; x < image.getWidth(); x++) { + for (int y = 0; y < image.getHeight(); y++) { + if (image.getPixelReader().getArgb(x, y) != 0x00000000) { + found = true; + break out; } } - if (!found) { - return; - } - - System.out.println("cache " + newValue); - cache.put(newValue, image); + } + if (!found) { return; + } + + System.out.println("cache " + newValue); + cache.put(newValue, image); } } }; Platform.runLater(() -> { -// timer.start(); -// active.set(timer); + // timer.start(); + // active.set(timer); }); }); diff --git a/app/src/main/java/io/xpipe/app/fxcomps/impl/SvgView.java b/app/src/main/java/io/xpipe/app/fxcomps/impl/SvgView.java index e55dcb0bb..f66a5a256 100644 --- a/app/src/main/java/io/xpipe/app/fxcomps/impl/SvgView.java +++ b/app/src/main/java/io/xpipe/app/fxcomps/impl/SvgView.java @@ -30,10 +30,7 @@ public class SvgView { private final ObservableValue height; private final ObservableValue svgContent; - private SvgView( - ObservableValue width, - ObservableValue height, - ObservableValue svgContent) { + private SvgView(ObservableValue width, ObservableValue height, ObservableValue svgContent) { this.width = PlatformThread.sync(width); this.height = PlatformThread.sync(height); this.svgContent = PlatformThread.sync(svgContent); @@ -68,7 +65,7 @@ public class SvgView { } private static Point2D getDimensions(String val) { - var regularExpression = Pattern.compile("]+?width=\"([^\s]+)\"", Pattern.DOTALL); + var regularExpression = Pattern.compile("]+?width=\"([^ ]+)\"", Pattern.DOTALL); var matcher = regularExpression.matcher(val); if (!matcher.find()) { @@ -83,7 +80,7 @@ public class SvgView { } var width = matcher.group(1); - regularExpression = Pattern.compile("> { currentValue.setValue(n); PlatformThread.runLaterIfNeeded(() -> { // Check if control value is the same. Then don't set it as that might cause bugs - if (Objects.equals(text.getText(), n) || (n == null && text.getText().isEmpty())) { + if (Objects.equals(text.getText(), n) + || (n == null && text.getText().isEmpty())) { return; } - + text.setText(n); }); }); - text.setOnKeyPressed(new EventHandler() { - @Override - public void handle(KeyEvent ke) { - if (ke.getCode().equals(KeyCode.ENTER)) { - text.getScene().getRoot().requestFocus(); - } - - if (lazy && ke.getCode().equals(KeyCode.ENTER)) { - lastAppliedValue.setValue(currentValue.getValue()); - } - ke.consume(); + text.setOnKeyPressed(ke -> { + if (ke.getCode().equals(KeyCode.ENTER)) { + text.getScene().getRoot().requestFocus(); } + + if (lazy && ke.getCode().equals(KeyCode.ENTER)) { + lastAppliedValue.setValue(currentValue.getValue()); + } + ke.consume(); }); text.focusedProperty().addListener((observable, oldValue, newValue) -> { diff --git a/app/src/main/java/io/xpipe/app/fxcomps/impl/WriteModeChoiceComp.java b/app/src/main/java/io/xpipe/app/fxcomps/impl/WriteModeChoiceComp.java index e8b661b62..36d4a7d4b 100644 --- a/app/src/main/java/io/xpipe/app/fxcomps/impl/WriteModeChoiceComp.java +++ b/app/src/main/java/io/xpipe/app/fxcomps/impl/WriteModeChoiceComp.java @@ -41,8 +41,7 @@ public class WriteModeChoiceComp extends SimpleComp implements Validatable { @Override protected Region createSimple() { var a = available; - Property>> map = - new SimpleObjectProperty<>(new LinkedHashMap>()); + Property>> map = new SimpleObjectProperty<>(new LinkedHashMap<>()); for (WriteMode writeMode : a) { map.getValue().put(writeMode, AppI18n.observable(writeMode.getId())); } diff --git a/app/src/main/java/io/xpipe/app/fxcomps/util/BindingsHelper.java b/app/src/main/java/io/xpipe/app/fxcomps/util/BindingsHelper.java index 63861d5cb..ee1c40309 100644 --- a/app/src/main/java/io/xpipe/app/fxcomps/util/BindingsHelper.java +++ b/app/src/main/java/io/xpipe/app/fxcomps/util/BindingsHelper.java @@ -19,8 +19,7 @@ import java.util.function.Predicate; public class BindingsHelper { - private static final Set REFERENCES = - Collections.newSetFromMap(new ConcurrentHashMap()); + private static final Set REFERENCES = Collections.newSetFromMap(new ConcurrentHashMap<>()); public static void bindExclusive( Property selected, Map> map, Property toBind) { diff --git a/app/src/main/java/io/xpipe/app/issue/AttachmentHelper.java b/app/src/main/java/io/xpipe/app/issue/AttachmentHelper.java index aeeda26f7..0ff47d5e9 100644 --- a/app/src/main/java/io/xpipe/app/issue/AttachmentHelper.java +++ b/app/src/main/java/io/xpipe/app/issue/AttachmentHelper.java @@ -2,14 +2,17 @@ package io.xpipe.app.issue; import org.apache.commons.io.IOUtils; -import java.io.*; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; import java.nio.file.Path; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; public class AttachmentHelper { - public static Path compressZipfile(Path sourceDir, Path outputFile) throws IOException, FileNotFoundException { + public static Path compressZipfile(Path sourceDir, Path outputFile) throws IOException { ZipOutputStream zipFile = new ZipOutputStream(new FileOutputStream(outputFile.toFile())); compressDirectoryToZipfile(sourceDir, sourceDir, zipFile); IOUtils.closeQuietly(zipFile); @@ -17,7 +20,7 @@ public class AttachmentHelper { } private static void compressDirectoryToZipfile(Path rootDir, Path sourceDir, ZipOutputStream out) - throws IOException, FileNotFoundException { + throws IOException { for (File file : sourceDir.toFile().listFiles()) { if (file.isDirectory()) { compressDirectoryToZipfile(rootDir, sourceDir.resolve(file.getName()), out); diff --git a/app/src/main/java/io/xpipe/app/issue/ErrorAction.java b/app/src/main/java/io/xpipe/app/issue/ErrorAction.java index f24b23ca9..2db2cb788 100644 --- a/app/src/main/java/io/xpipe/app/issue/ErrorAction.java +++ b/app/src/main/java/io/xpipe/app/issue/ErrorAction.java @@ -5,7 +5,7 @@ import io.xpipe.app.util.Hyperlinks; public interface ErrorAction { - public static ErrorAction reportOnGithub() { + static ErrorAction reportOnGithub() { return new ErrorAction() { @Override public String getName() { @@ -26,7 +26,7 @@ public interface ErrorAction { }; } - public static ErrorAction sendDiagnostics() { + static ErrorAction sendDiagnostics() { return new ErrorAction() { @Override public String getName() { @@ -46,7 +46,7 @@ public interface ErrorAction { }; } - public static ErrorAction ignore() { + static ErrorAction ignore() { return new ErrorAction() { @Override public String getName() { diff --git a/app/src/main/java/io/xpipe/app/issue/ErrorDetailsComp.java b/app/src/main/java/io/xpipe/app/issue/ErrorDetailsComp.java index f3f646e7e..8bdf9cb06 100644 --- a/app/src/main/java/io/xpipe/app/issue/ErrorDetailsComp.java +++ b/app/src/main/java/io/xpipe/app/issue/ErrorDetailsComp.java @@ -63,10 +63,10 @@ public class ErrorDetailsComp extends SimpleComp { AppI18n.observable("stackTrace"), "mdoal-code", Comp.of(this::createStrackTraceContent))); } -// if (event.getTrackEvents().size() > 0) { -// items.add(new TabPaneComp.Entry( -// AppI18n.observable("events"), "mdi2c-clipboard-list-outline", createTrackEventHistory())); -// } + // if (event.getTrackEvents().size() > 0) { + // items.add(new TabPaneComp.Entry( + // AppI18n.observable("events"), "mdi2c-clipboard-list-outline", createTrackEventHistory())); + // } var tb = new TabPaneComp(new SimpleObjectProperty<>(items.size() > 0 ? items.get(0) : null), items); tb.apply(r -> AppFont.small(r.get())); diff --git a/app/src/main/java/io/xpipe/app/issue/ErrorEvent.java b/app/src/main/java/io/xpipe/app/issue/ErrorEvent.java index 7d518208d..75dc221b2 100644 --- a/app/src/main/java/io/xpipe/app/issue/ErrorEvent.java +++ b/app/src/main/java/io/xpipe/app/issue/ErrorEvent.java @@ -17,10 +17,10 @@ public class ErrorEvent { private boolean terminal; @Builder.Default - private boolean omitted = false; + private final boolean omitted = false; @Builder.Default - private boolean reportable = true; + private final boolean reportable = true; private Throwable throwable; diff --git a/app/src/main/java/io/xpipe/app/issue/ErrorHandlerComp.java b/app/src/main/java/io/xpipe/app/issue/ErrorHandlerComp.java index 25f14bf9f..21c95777e 100644 --- a/app/src/main/java/io/xpipe/app/issue/ErrorHandlerComp.java +++ b/app/src/main/java/io/xpipe/app/issue/ErrorHandlerComp.java @@ -76,9 +76,12 @@ public class ErrorHandlerComp extends SimpleComp { if (!showing.get()) { showing.set(true); var window = AppWindowHelper.sideWindow( - AppI18n.get("errorHandler"), w -> { + AppI18n.get("errorHandler"), + w -> { return setUpComp(event, w, finishLatch); - }, true, null); + }, + true, + null); // An exception is thrown when show and wait is called // within an animation or layout processing task, so use show @@ -101,9 +104,12 @@ public class ErrorHandlerComp extends SimpleComp { if (!showing.get()) { showing.set(true); var window = AppWindowHelper.sideWindow( - AppI18n.get("errorHandler"), w -> { + AppI18n.get("errorHandler"), + w -> { return setUpComp(event, w, finishLatch); - }, true, null); + }, + true, + null); // An exception is thrown when show and wait is called // within an animation or layout processing task, so use show try { @@ -175,7 +181,8 @@ public class ErrorHandlerComp extends SimpleComp { var hbox = new HBox(graphicPane, text); HBox.setHgrow(text, Priority.ALWAYS); hbox.setSpacing(8); - graphicPane.prefHeightProperty() + graphicPane + .prefHeightProperty() .bind(Bindings.createDoubleBinding( () -> header.getHeight() + descriptionField.getHeight() + 2, header.heightProperty(), @@ -198,7 +205,8 @@ public class ErrorHandlerComp extends SimpleComp { actionBox.getStyleClass().add("actions"); actionBox.setFillWidth(true); - for (var action : List.of(ErrorAction.sendDiagnostics(), ErrorAction.reportOnGithub(), ErrorAction.ignore())) { + for (var action : + List.of(ErrorAction.sendDiagnostics(), ErrorAction.reportOnGithub(), ErrorAction.ignore())) { var ac = createActionComp(action); actionBox.getChildren().add(ac); } diff --git a/app/src/main/java/io/xpipe/app/issue/EventHandler.java b/app/src/main/java/io/xpipe/app/issue/EventHandler.java index 46b6320ef..b807f9887 100644 --- a/app/src/main/java/io/xpipe/app/issue/EventHandler.java +++ b/app/src/main/java/io/xpipe/app/issue/EventHandler.java @@ -17,7 +17,7 @@ public abstract class EventHandler { if (cat == null) { cat = "log"; } - System.out.println("[" + cat + "] " + te.toString()); + System.out.println("[" + cat + "] " + te); System.out.flush(); } diff --git a/app/src/main/java/io/xpipe/app/issue/SentryErrorHandler.java b/app/src/main/java/io/xpipe/app/issue/SentryErrorHandler.java index 7c22dcec7..ba2acc49e 100644 --- a/app/src/main/java/io/xpipe/app/issue/SentryErrorHandler.java +++ b/app/src/main/java/io/xpipe/app/issue/SentryErrorHandler.java @@ -100,7 +100,11 @@ public class SentryErrorHandler implements ErrorHandler { atts.forEach(attachment -> s.addAttachment(attachment)); s.setTag("initError", String.valueOf(OperationMode.isInStartup())); - s.setTag("developerMode", AppPrefs.get() != null ? AppPrefs.get().developerMode().getValue().toString() : "false"); + s.setTag( + "developerMode", + AppPrefs.get() != null + ? AppPrefs.get().developerMode().getValue().toString() + : "false"); s.setTag("terminal", Boolean.toString(ee.isTerminal())); s.setTag("omitted", Boolean.toString(ee.isOmitted())); if (ee.getThrowable() != null) { diff --git a/app/src/main/java/io/xpipe/app/issue/TerminalErrorHandler.java b/app/src/main/java/io/xpipe/app/issue/TerminalErrorHandler.java index b27599bd2..2ff6ae192 100644 --- a/app/src/main/java/io/xpipe/app/issue/TerminalErrorHandler.java +++ b/app/src/main/java/io/xpipe/app/issue/TerminalErrorHandler.java @@ -3,8 +3,8 @@ package io.xpipe.app.issue; import io.sentry.Sentry; import io.xpipe.app.core.*; import io.xpipe.app.core.mode.OperationMode; -import io.xpipe.app.util.Hyperlinks; import io.xpipe.app.update.XPipeDistributionType; +import io.xpipe.app.util.Hyperlinks; import io.xpipe.app.util.PlatformState; import javafx.application.Platform; import javafx.scene.control.Alert; @@ -91,9 +91,11 @@ public class TerminalErrorHandler implements ErrorHandler { alert.setTitle(AppI18n.get("updateAvailableTitle")); alert.setHeaderText(AppI18n.get("updateAvailableHeader", rel.getVersion())); alert.getDialogPane() - .setContent(AppWindowHelper.alertContentText(AppI18n.get("updateAvailableContent"))); + .setContent( + AppWindowHelper.alertContentText(AppI18n.get("updateAvailableContent"))); alert.getButtonTypes().clear(); - alert.getButtonTypes().add(new ButtonType(AppI18n.get("checkOutUpdate"), ButtonBar.ButtonData.YES)); + alert.getButtonTypes() + .add(new ButtonType(AppI18n.get("checkOutUpdate"), ButtonBar.ButtonData.YES)); alert.getButtonTypes().add(new ButtonType(AppI18n.get("ignore"), ButtonBar.ButtonData.NO)); }) .map(buttonType -> buttonType.getButtonData().isDefaultButton()) diff --git a/app/src/main/java/io/xpipe/app/issue/TrackEvent.java b/app/src/main/java/io/xpipe/app/issue/TrackEvent.java index 9408ec1a2..75bfaac2f 100644 --- a/app/src/main/java/io/xpipe/app/issue/TrackEvent.java +++ b/app/src/main/java/io/xpipe/app/issue/TrackEvent.java @@ -120,7 +120,6 @@ public class TrackEvent { var value = valueString.contains("\n") ? "\n" + (valueString - .toString() .lines() .map(line -> " | " + line) .collect(Collectors.joining("\n"))) diff --git a/app/src/main/java/io/xpipe/app/launcher/LauncherCommand.java b/app/src/main/java/io/xpipe/app/launcher/LauncherCommand.java index b3a5fcb51..47bf8c3eb 100644 --- a/app/src/main/java/io/xpipe/app/launcher/LauncherCommand.java +++ b/app/src/main/java/io/xpipe/app/launcher/LauncherCommand.java @@ -3,8 +3,8 @@ package io.xpipe.app.launcher; import io.xpipe.app.core.AppLock; import io.xpipe.app.core.AppLogs; import io.xpipe.app.core.mode.OperationMode; -import io.xpipe.app.issue.LogErrorHandler; import io.xpipe.app.issue.ErrorEvent; +import io.xpipe.app.issue.LogErrorHandler; import io.xpipe.app.issue.TrackEvent; import io.xpipe.app.util.ThreadHelper; import io.xpipe.beacon.BeaconServer; @@ -34,7 +34,7 @@ public class LauncherCommand implements Callable { XPipeDaemonMode mode; @CommandLine.Parameters(paramLabel = "") - List inputs = List.of(); + final List inputs = List.of(); public static void runLauncher(String[] args) { event("Launcher received commands: " + Arrays.asList(args)); diff --git a/app/src/main/java/io/xpipe/app/launcher/LauncherInput.java b/app/src/main/java/io/xpipe/app/launcher/LauncherInput.java index af4e52fea..59e677cb8 100644 --- a/app/src/main/java/io/xpipe/app/launcher/LauncherInput.java +++ b/app/src/main/java/io/xpipe/app/launcher/LauncherInput.java @@ -81,7 +81,7 @@ public abstract class LauncherInput { .equalsIgnoreCase(action)) .findFirst(); if (found.isPresent()) { - ActionProvider.Action a = null; + ActionProvider.Action a; try { a = found.get().getLauncherCallSite().createAction(args); } catch (Exception e) { diff --git a/app/src/main/java/io/xpipe/app/launcher/LauncherModeConverter.java b/app/src/main/java/io/xpipe/app/launcher/LauncherModeConverter.java index 2a23b617f..c8e82d242 100644 --- a/app/src/main/java/io/xpipe/app/launcher/LauncherModeConverter.java +++ b/app/src/main/java/io/xpipe/app/launcher/LauncherModeConverter.java @@ -6,7 +6,7 @@ import picocli.CommandLine; public class LauncherModeConverter implements CommandLine.ITypeConverter { @Override - public XPipeDaemonMode convert(String value) throws Exception { + public XPipeDaemonMode convert(String value) { return XPipeDaemonMode.get(value); } } diff --git a/app/src/main/java/io/xpipe/app/prefs/AboutComp.java b/app/src/main/java/io/xpipe/app/prefs/AboutComp.java index 6e0c8338e..7e4a98df9 100644 --- a/app/src/main/java/io/xpipe/app/prefs/AboutComp.java +++ b/app/src/main/java/io/xpipe/app/prefs/AboutComp.java @@ -116,10 +116,16 @@ public class AboutComp extends Comp> { .grow(true, false), null) .addComp( - new DescriptionButtonComp("thirdParty", "thirdPartyDescription", "mdi2o-open-source-initiative", e -> { - AppWindowHelper.sideWindow(AppI18n.get("openSourceNotices"), stage -> Comp.of(() -> createThirdPartyDeps()), true, null).show(); - e.consume(); - }) + new DescriptionButtonComp( + "thirdParty", "thirdPartyDescription", "mdi2o-open-source-initiative", e -> { + AppWindowHelper.sideWindow( + AppI18n.get("openSourceNotices"), + stage -> Comp.of(() -> createThirdPartyDeps()), + true, + null) + .show(); + e.consume(); + }) .grow(true, false), null) .addComp( diff --git a/app/src/main/java/io/xpipe/app/prefs/AppPreferencesFx.java b/app/src/main/java/io/xpipe/app/prefs/AppPreferencesFx.java index f0bdbcc2f..7a56c4660 100644 --- a/app/src/main/java/io/xpipe/app/prefs/AppPreferencesFx.java +++ b/app/src/main/java/io/xpipe/app/prefs/AppPreferencesFx.java @@ -19,7 +19,7 @@ import java.util.List; public class AppPreferencesFx { - private PreferencesFxModel preferencesFxModel; + private final PreferencesFxModel preferencesFxModel; private NavigationView navigationView; private NavigationPresenter navigationPresenter; @@ -61,12 +61,10 @@ public class AppPreferencesFx { breadCrumbView = new BreadCrumbView(preferencesFxModel, undoRedoBox) { @Override - public void initializeParts() { - } + public void initializeParts() {} @Override - public void layoutParts() { - } + public void layoutParts() {} }; breadCrumbPresenter = new BreadCrumbPresenter(preferencesFxModel, breadCrumbView); diff --git a/app/src/main/java/io/xpipe/app/prefs/AppPrefs.java b/app/src/main/java/io/xpipe/app/prefs/AppPrefs.java index 8a9d68c2b..f66469dce 100644 --- a/app/src/main/java/io/xpipe/app/prefs/AppPrefs.java +++ b/app/src/main/java/io/xpipe/app/prefs/AppPrefs.java @@ -91,8 +91,7 @@ public class AppPrefs { languageList, languageInternal) .render(() -> new TranslatableComboBoxControl<>()); - public final ObjectProperty theme = - typed(new SimpleObjectProperty<>(), AppTheme.Theme.class); + public final ObjectProperty theme = typed(new SimpleObjectProperty<>(), AppTheme.Theme.class); private final SingleSelectionField themeControl = Field.ofSingleSelectionType(themeList, theme).render(() -> new TranslatableComboBoxControl<>()); private final BooleanProperty useSystemFontInternal = typed(new SimpleBooleanProperty(true), Boolean.class); @@ -118,9 +117,10 @@ public class AppPrefs { // Lock // ==== - private final Property lockPassword = new SimpleObjectProperty(); + private final Property lockPassword = new SimpleObjectProperty<>(); private final StringProperty lockCrypt = typed(new SimpleStringProperty(""), String.class); - private final StringField lockCryptControl = StringField.ofStringType(lockCrypt).render(() -> new SimpleControl() { + private final StringField lockCryptControl = StringField.ofStringType(lockCrypt) + .render(() -> new SimpleControl() { private Region button; @@ -128,15 +128,20 @@ public class AppPrefs { public void initializeParts() { super.initializeParts(); this.node = new StackPane(); - button = new ButtonComp(Bindings.createStringBinding(() -> { - return lockCrypt.getValue() != null? AppI18n.get("changeLock"):AppI18n.get("createLock"); - }), () -> LockChangeAlert.show()).createRegion(); + button = new ButtonComp( + Bindings.createStringBinding(() -> { + return lockCrypt.getValue() != null + ? AppI18n.get("changeLock") + : AppI18n.get("createLock"); + }), + () -> LockChangeAlert.show()) + .createRegion(); } @Override public void layoutParts() { - ((StackPane)this.node).getChildren().addAll(this.button); - ((StackPane)this.node).setAlignment(Pos.CENTER_LEFT); + this.node.getChildren().addAll(this.button); + this.node.setAlignment(Pos.CENTER_LEFT); } }); @@ -177,8 +182,7 @@ public class AppPrefs { // Automatically update // ==================== - private final BooleanProperty automaticallyCheckForUpdates = - typed(new SimpleBooleanProperty(true), Boolean.class); + private final BooleanProperty automaticallyCheckForUpdates = typed(new SimpleBooleanProperty(true), Boolean.class); private final BooleanField automaticallyCheckForUpdatesField = BooleanField.ofBooleanType(automaticallyCheckForUpdates).render(() -> new CustomToggleControl()); @@ -289,10 +293,6 @@ public class AppPrefs { return lockPassword; } - public StringProperty lockCryptProperty() { - return lockCrypt; - } - public final ReadOnlyIntegerProperty editorReloadTimeout() { return editorReloadTimeout; } @@ -419,7 +419,7 @@ public class AppPrefs { public void setFromText(ReadOnlyProperty prop, String newValue) { var field = getFieldForEntry(prop); - if (!field.isEditable()) { + if (field == null || !field.isEditable()) { return; } @@ -450,7 +450,12 @@ public class AppPrefs { } public Class getSettingType(String breadcrumb) { - var found = classMap.get(getSetting(breadcrumb).valueProperty()); + var s = getSetting(breadcrumb); + if (s == null) { + throw new IllegalStateException("Unknown breadcrumb " + breadcrumb); + } + + var found = classMap.get(s.valueProperty()); if (found == null) { throw new IllegalStateException("Unassigned type for " + breadcrumb); } @@ -498,8 +503,7 @@ public class AppPrefs { var s = ctr.newInstance(null, new LazyNodeElement<>(() -> new AboutComp().createRegion()), null); var categories = new ArrayList<>(List.of( - Category.of( - "application", Group.of(s)), + Category.of("application", Group.of(s)), Category.of( "system", Group.of( @@ -509,12 +513,13 @@ public class AppPrefs { externalStartupBehaviourControl, externalStartupBehaviour), Setting.of("closeBehaviour", closeBehaviourControl, closeBehaviour)), - Group.of( - "security", - Setting.of("workspaceLock", lockCryptControl, lockCrypt)), + Group.of("security", Setting.of("workspaceLock", lockCryptControl, lockCrypt)), Group.of( "updates", - Setting.of("automaticallyUpdate", automaticallyCheckForUpdatesField, automaticallyCheckForUpdates), + Setting.of( + "automaticallyUpdate", + automaticallyCheckForUpdatesField, + automaticallyCheckForUpdates), Setting.of("updateToPrereleases", checkForPrereleasesField, checkForPrereleases)), Group.of( "advanced", diff --git a/app/src/main/java/io/xpipe/app/prefs/CloseBehaviour.java b/app/src/main/java/io/xpipe/app/prefs/CloseBehaviour.java index f44f31515..fee083c92 100644 --- a/app/src/main/java/io/xpipe/app/prefs/CloseBehaviour.java +++ b/app/src/main/java/io/xpipe/app/prefs/CloseBehaviour.java @@ -6,7 +6,6 @@ import lombok.Getter; @Getter public enum CloseBehaviour implements PrefsChoiceValue { - QUIT("app.quit", () -> { OperationMode.shutdown(false, false); }), @@ -15,8 +14,8 @@ public enum CloseBehaviour implements PrefsChoiceValue { OperationMode.switchToAsync(OperationMode.TRAY); }); - private String id; - private Runnable exit; + private final String id; + private final Runnable exit; CloseBehaviour(String id, Runnable exit) { this.id = id; diff --git a/app/src/main/java/io/xpipe/app/prefs/CustomFormRenderer.java b/app/src/main/java/io/xpipe/app/prefs/CustomFormRenderer.java index e6566b754..ef9b1c9a4 100644 --- a/app/src/main/java/io/xpipe/app/prefs/CustomFormRenderer.java +++ b/app/src/main/java/io/xpipe/app/prefs/CustomFormRenderer.java @@ -78,7 +78,8 @@ public class CustomFormRenderer extends PreferencesFxFormRenderer { c.getFieldLabel().setMaxHeight(AppFont.getPixelSize(1)); grid.add(c.getFieldLabel(), 0, i + rowAmount, 2, 1); - var canFocus = BindingsHelper.persist(c.getNode().disabledProperty().not()); + var canFocus = BindingsHelper.persist( + c.getNode().disabledProperty().not()); var descriptionLabel = new Label(); AppFont.medium(descriptionLabel); @@ -128,8 +129,8 @@ public class CustomFormRenderer extends PreferencesFxFormRenderer { GridPane.setMargin(c.getFieldLabel(), new Insets(SPACING, 0, 0, offset)); } - c.getFieldLabel().getStyleClass().add(styleClass.toString() + "-label"); - node.getStyleClass().add(styleClass.toString() + "-node"); + c.getFieldLabel().getStyleClass().add(styleClass + "-label"); + node.getStyleClass().add(styleClass + "-node"); } if (element instanceof LazyNodeElement nodeElement) { diff --git a/app/src/main/java/io/xpipe/app/prefs/CustomToggleControl.java b/app/src/main/java/io/xpipe/app/prefs/CustomToggleControl.java index 768c37d5b..1998a1503 100644 --- a/app/src/main/java/io/xpipe/app/prefs/CustomToggleControl.java +++ b/app/src/main/java/io/xpipe/app/prefs/CustomToggleControl.java @@ -15,68 +15,65 @@ import javafx.scene.control.Label; */ public class CustomToggleControl extends SimpleControl { - /** - * Constructs a ToggleControl of {@link ToggleControl} type, with visibility condition. - * - * @param visibilityProperty property for control visibility of this element - * - * @return the constructed ToggleControl - */ - public static ToggleControl of(VisibilityProperty visibilityProperty) { - ToggleControl toggleControl = new ToggleControl(); + /** + * Constructs a ToggleControl of {@link ToggleControl} type, with visibility condition. + * + * @param visibilityProperty property for control visibility of this element + * + * @return the constructed ToggleControl + */ + public static ToggleControl of(VisibilityProperty visibilityProperty) { + ToggleControl toggleControl = new ToggleControl(); - toggleControl.setVisibilityProperty(visibilityProperty); + toggleControl.setVisibilityProperty(visibilityProperty); - return toggleControl; - } + return toggleControl; + } - /** - * {@inheritDoc} - */ - @Override - public void initializeParts() { - super.initializeParts(); - fieldLabel = new Label(field.labelProperty().getValue()); - node = new atlantafx.base.controls.ToggleSwitch(); - node.getStyleClass().add("toggle-control"); - node.setSelected(field.getValue()); - } + /** + * {@inheritDoc} + */ + @Override + public void initializeParts() { + super.initializeParts(); + fieldLabel = new Label(field.labelProperty().getValue()); + node = new atlantafx.base.controls.ToggleSwitch(); + node.getStyleClass().add("toggle-control"); + node.setSelected(field.getValue()); + } - /** - * {@inheritDoc} - */ - @Override - public void layoutParts() { + /** + * {@inheritDoc} + */ + @Override + public void layoutParts() {} - } + /** + * {@inheritDoc} + */ + @Override + public void setupBindings() { + super.setupBindings(); + } - /** - * {@inheritDoc} - */ - @Override - public void setupBindings() { - super.setupBindings(); - } - - /** - * {@inheritDoc} - */ - @Override - public void setupValueChangedListeners() { - super.setupValueChangedListeners(); - field.userInputProperty().addListener((observable, oldValue, newValue) -> { - node.setSelected(Boolean.parseBoolean(field.getUserInput())); - }); - } - - /** - * {@inheritDoc} - */ - @Override - public void setupEventHandlers() { - node.selectedProperty().addListener((observable, oldValue, newValue) -> { - field.userInputProperty().setValue(String.valueOf(newValue)); - }); - } + /** + * {@inheritDoc} + */ + @Override + public void setupValueChangedListeners() { + super.setupValueChangedListeners(); + field.userInputProperty().addListener((observable, oldValue, newValue) -> { + node.setSelected(Boolean.parseBoolean(field.getUserInput())); + }); + } + /** + * {@inheritDoc} + */ + @Override + public void setupEventHandlers() { + node.selectedProperty().addListener((observable, oldValue, newValue) -> { + field.userInputProperty().setValue(String.valueOf(newValue)); + }); + } } diff --git a/app/src/main/java/io/xpipe/app/prefs/ExternalEditorType.java b/app/src/main/java/io/xpipe/app/prefs/ExternalEditorType.java index 38917d0bc..8284f17bd 100644 --- a/app/src/main/java/io/xpipe/app/prefs/ExternalEditorType.java +++ b/app/src/main/java/io/xpipe/app/prefs/ExternalEditorType.java @@ -14,14 +14,14 @@ import java.util.function.Supplier; public interface ExternalEditorType extends PrefsChoiceValue { - public static final ExternalEditorType NOTEPAD = new WindowsFullPathType("app.notepad") { + ExternalEditorType NOTEPAD = new WindowsFullPathType("app.notepad") { @Override protected Optional determinePath() { return Optional.of(Path.of(System.getenv("SystemRoot") + "\\System32\\notepad.exe")); } }; - public static final ExternalEditorType VSCODE_WINDOWS = new WindowsFullPathType("app.vscode") { + ExternalEditorType VSCODE_WINDOWS = new WindowsFullPathType("app.vscode") { @Override public boolean canOpenDirectory() { @@ -42,7 +42,7 @@ public interface ExternalEditorType extends PrefsChoiceValue { return false; } }; - public static final ExternalEditorType NOTEPADPLUSPLUS_WINDOWS = new WindowsFullPathType("app.notepad++") { + ExternalEditorType NOTEPADPLUSPLUS_WINDOWS = new WindowsFullPathType("app.notepad++") { @Override protected Optional determinePath() { @@ -53,7 +53,7 @@ public interface ExternalEditorType extends PrefsChoiceValue { } }; - public static final LinuxPathType VSCODE_LINUX = new LinuxPathType("app.vscode", "code") { + LinuxPathType VSCODE_LINUX = new LinuxPathType("app.vscode", "code") { @Override public boolean canOpenDirectory() { @@ -61,15 +61,15 @@ public interface ExternalEditorType extends PrefsChoiceValue { } }; - public static final LinuxPathType KATE = new LinuxPathType("app.kate", "kate"); + LinuxPathType KATE = new LinuxPathType("app.kate", "kate"); - public static final LinuxPathType GEDIT = new LinuxPathType("app.gedit", "gedit"); + LinuxPathType GEDIT = new LinuxPathType("app.gedit", "gedit"); - public static final LinuxPathType LEAFPAD = new LinuxPathType("app.leafpad", "leafpad"); + LinuxPathType LEAFPAD = new LinuxPathType("app.leafpad", "leafpad"); - public static final LinuxPathType MOUSEPAD = new LinuxPathType("app.mousepad", "mousepad"); + LinuxPathType MOUSEPAD = new LinuxPathType("app.mousepad", "mousepad"); - public static final LinuxPathType PLUMA = new LinuxPathType("app.pluma", "pluma"); + LinuxPathType PLUMA = new LinuxPathType("app.pluma", "pluma"); class MacOsEditor extends ExternalApplicationType.MacApplication implements ExternalEditorType { @@ -82,17 +82,20 @@ public interface ExternalEditorType extends PrefsChoiceValue { ApplicationHelper.executeLocalApplication( shellControl -> String.format( "open -a %s %s", - shellControl.getShellDialect().fileArgument(getApplicationPath().orElseThrow().toString()), + shellControl + .getShellDialect() + .fileArgument( + getApplicationPath().orElseThrow().toString()), shellControl.getShellDialect().fileArgument(file.toString())), false); } } - public static final ExternalEditorType TEXT_EDIT = new MacOsEditor("app.textEdit", "TextEdit"); + ExternalEditorType TEXT_EDIT = new MacOsEditor("app.textEdit", "TextEdit"); - public static final ExternalEditorType SUBLIME_MACOS = new MacOsEditor("app.sublime", "Sublime Text"); + ExternalEditorType SUBLIME_MACOS = new MacOsEditor("app.sublime", "Sublime Text"); - public static final ExternalEditorType VSCODE_MACOS = new MacOsEditor("app.vscode", "Visual Studio Code") { + ExternalEditorType VSCODE_MACOS = new MacOsEditor("app.vscode", "Visual Studio Code") { @Override public boolean canOpenDirectory() { @@ -100,7 +103,7 @@ public interface ExternalEditorType extends PrefsChoiceValue { } }; - public static final ExternalEditorType CUSTOM = new ExternalEditorType() { + ExternalEditorType CUSTOM = new ExternalEditorType() { @Override public void launch(Path file) throws Exception { @@ -125,13 +128,13 @@ public interface ExternalEditorType extends PrefsChoiceValue { } }; - public void launch(Path file) throws Exception; + void launch(Path file) throws Exception; default boolean canOpenDirectory() { return false; } - public static class LinuxPathType extends ExternalApplicationType.PathApplication implements ExternalEditorType { + class LinuxPathType extends ExternalApplicationType.PathApplication implements ExternalEditorType { public LinuxPathType(String id, String command) { super(id, command); @@ -148,7 +151,7 @@ public interface ExternalEditorType extends PrefsChoiceValue { } } - public abstract static class WindowsFullPathType extends ExternalApplicationType.WindowsFullPathType + abstract class WindowsFullPathType extends ExternalApplicationType.WindowsFullPathType implements ExternalEditorType { public WindowsFullPathType(String id) { @@ -168,17 +171,18 @@ public interface ExternalEditorType extends PrefsChoiceValue { ApplicationHelper.executeLocalApplication( sc -> String.format( - "%s %s", sc.getShellDialect().fileArgument(path.get().toString()), sc.getShellDialect().fileArgument(file.toString())), + "%s %s", + sc.getShellDialect().fileArgument(path.get().toString()), + sc.getShellDialect().fileArgument(file.toString())), detach()); } } - public static final List WINDOWS_EDITORS = List.of(VSCODE_WINDOWS, NOTEPADPLUSPLUS_WINDOWS, NOTEPAD); - public static final List LINUX_EDITORS = - List.of(VSCODE_LINUX, KATE, GEDIT, PLUMA, LEAFPAD, MOUSEPAD); - public static final List MACOS_EDITORS = List.of(VSCODE_MACOS, SUBLIME_MACOS, TEXT_EDIT); + List WINDOWS_EDITORS = List.of(VSCODE_WINDOWS, NOTEPADPLUSPLUS_WINDOWS, NOTEPAD); + List LINUX_EDITORS = List.of(VSCODE_LINUX, KATE, GEDIT, PLUMA, LEAFPAD, MOUSEPAD); + List MACOS_EDITORS = List.of(VSCODE_MACOS, SUBLIME_MACOS, TEXT_EDIT); - public static final List ALL = ((Supplier>) () -> { + List ALL = ((Supplier>) () -> { var all = new ArrayList(); if (OsType.getLocal().equals(OsType.WINDOWS)) { all.addAll(WINDOWS_EDITORS); @@ -194,7 +198,7 @@ public interface ExternalEditorType extends PrefsChoiceValue { }) .get(); - public static void detectDefault() { + static void detectDefault() { var typeProperty = AppPrefs.get().externalEditor; var customProperty = AppPrefs.get().customEditorCommand; if (OsType.getLocal().equals(OsType.WINDOWS)) { diff --git a/app/src/main/java/io/xpipe/app/prefs/ExternalTerminalType.java b/app/src/main/java/io/xpipe/app/prefs/ExternalTerminalType.java index ff378228f..74789bea1 100644 --- a/app/src/main/java/io/xpipe/app/prefs/ExternalTerminalType.java +++ b/app/src/main/java/io/xpipe/app/prefs/ExternalTerminalType.java @@ -79,7 +79,7 @@ public interface ExternalTerminalType extends PrefsChoiceValue { } }; - public abstract static class WindowsFullPathType extends ExternalApplicationType.WindowsFullPathType + abstract class WindowsFullPathType extends ExternalApplicationType.WindowsFullPathType implements ExternalTerminalType { public WindowsFullPathType(String id) { @@ -312,9 +312,11 @@ public interface ExternalTerminalType extends PrefsChoiceValue { public void launch(String name, String file, boolean elevated) throws Exception { try (ShellControl pc = LocalStore.getShell()) { pc.osascriptCommand(String.format( - """ + """ %s/Contents/MacOS/Tabby run %s - """, getApplicationPath().orElseThrow(), pc.getShellDialect().fileArgument(file))) + """, + getApplicationPath().orElseThrow(), + pc.getShellDialect().fileArgument(file))) .execute(); } } diff --git a/app/src/main/java/io/xpipe/app/prefs/PrefFields.java b/app/src/main/java/io/xpipe/app/prefs/PrefFields.java index b7e92c4d4..e82464bb1 100644 --- a/app/src/main/java/io/xpipe/app/prefs/PrefFields.java +++ b/app/src/main/java/io/xpipe/app/prefs/PrefFields.java @@ -15,7 +15,7 @@ public class PrefFields { public static StringField ofPath(ObjectProperty fileProperty) { StringProperty stringProperty = new SimpleStringProperty(); - stringProperty.bindBidirectional(fileProperty, new StringConverter() { + stringProperty.bindBidirectional(fileProperty, new StringConverter<>() { @Override public String toString(Path file) { if (Objects.isNull(file)) { diff --git a/app/src/main/java/io/xpipe/app/comp/PrefsComp.java b/app/src/main/java/io/xpipe/app/prefs/PrefsComp.java similarity index 94% rename from app/src/main/java/io/xpipe/app/comp/PrefsComp.java rename to app/src/main/java/io/xpipe/app/prefs/PrefsComp.java index 9c1ba13ae..e87dd599c 100644 --- a/app/src/main/java/io/xpipe/app/comp/PrefsComp.java +++ b/app/src/main/java/io/xpipe/app/prefs/PrefsComp.java @@ -1,11 +1,10 @@ -package io.xpipe.app.comp; +package io.xpipe.app.prefs; +import io.xpipe.app.comp.AppLayoutComp; import io.xpipe.app.comp.base.ButtonComp; import io.xpipe.app.core.AppFont; import io.xpipe.app.core.AppI18n; import io.xpipe.app.fxcomps.SimpleComp; -import io.xpipe.app.prefs.AppPrefs; -import io.xpipe.app.prefs.ClearCacheAlert; import javafx.geometry.Pos; import javafx.scene.layout.AnchorPane; import javafx.scene.layout.HBox; diff --git a/app/src/main/java/io/xpipe/app/prefs/PropertiesComp.java b/app/src/main/java/io/xpipe/app/prefs/PropertiesComp.java index 5f0b29605..3c67a9079 100644 --- a/app/src/main/java/io/xpipe/app/prefs/PropertiesComp.java +++ b/app/src/main/java/io/xpipe/app/prefs/PropertiesComp.java @@ -31,13 +31,17 @@ public class PropertiesComp extends SimpleComp { .addComp(title, null) .addComp( AppI18n.observable("version"), - new LabelComp(AppProperties.get().getVersion() + " (" + AppProperties.get().getArch() + ")"), + new LabelComp(AppProperties.get().getVersion() + " (" + + AppProperties.get().getArch() + ")"), null) .addComp( AppI18n.observable("build"), new LabelComp(AppProperties.get().getBuild()), null) - .addComp(AppI18n.observable("runtimeVersion"), new LabelComp(System.getProperty("java.vm.version")), null) + .addComp( + AppI18n.observable("runtimeVersion"), + new LabelComp(System.getProperty("java.vm.version")), + null) .addComp( AppI18n.observable("virtualMachine"), new LabelComp(System.getProperty("java.vm.vendor") + " " + System.getProperty("java.vm.name")), diff --git a/app/src/main/java/io/xpipe/app/prefs/SecretField.java b/app/src/main/java/io/xpipe/app/prefs/SecretField.java index 2e64d987a..860ea5d00 100644 --- a/app/src/main/java/io/xpipe/app/prefs/SecretField.java +++ b/app/src/main/java/io/xpipe/app/prefs/SecretField.java @@ -6,12 +6,13 @@ import io.xpipe.app.util.SecretHelper; import io.xpipe.core.util.SecretValue; import javafx.beans.property.Property; -public class SecretField extends DataField, SecretValue, com.dlsc.formsfx.model.structure.PasswordField> { +public class SecretField + extends DataField, SecretValue, com.dlsc.formsfx.model.structure.PasswordField> { protected SecretField(Property valueProperty, Property persistentValueProperty) { super(valueProperty, persistentValueProperty); - stringConverter = new AbstractStringConverter() { + stringConverter = new AbstractStringConverter<>() { @Override public SecretValue fromString(String string) { return SecretHelper.encrypt(string); diff --git a/app/src/main/java/io/xpipe/app/prefs/UpdateCheckComp.java b/app/src/main/java/io/xpipe/app/prefs/UpdateCheckComp.java index e571cb16a..ab41e3366 100644 --- a/app/src/main/java/io/xpipe/app/prefs/UpdateCheckComp.java +++ b/app/src/main/java/io/xpipe/app/prefs/UpdateCheckComp.java @@ -4,8 +4,8 @@ import io.xpipe.app.core.AppI18n; import io.xpipe.app.fxcomps.SimpleComp; import io.xpipe.app.fxcomps.util.PlatformThread; import io.xpipe.app.update.UpdateAvailableAlert; -import io.xpipe.app.util.ThreadHelper; import io.xpipe.app.update.XPipeDistributionType; +import io.xpipe.app.util.ThreadHelper; import javafx.beans.binding.Bindings; import javafx.beans.property.SimpleObjectProperty; import javafx.beans.value.ObservableValue; @@ -23,7 +23,11 @@ public class UpdateCheckComp extends SimpleComp { public UpdateCheckComp() { updateReady = PlatformThread.sync(Bindings.createBooleanBinding( () -> { - return XPipeDistributionType.get().getUpdateHandler().getPreparedUpdate().getValue() != null; + return XPipeDistributionType.get() + .getUpdateHandler() + .getPreparedUpdate() + .getValue() + != null; }, XPipeDistributionType.get().getUpdateHandler().getPreparedUpdate())); } @@ -43,26 +47,41 @@ public class UpdateCheckComp extends SimpleComp { private ObservableValue descriptionText() { return PlatformThread.sync(Bindings.createStringBinding( () -> { - if (XPipeDistributionType.get().getUpdateHandler().getPreparedUpdate().getValue() != null) { + if (XPipeDistributionType.get() + .getUpdateHandler() + .getPreparedUpdate() + .getValue() + != null) { return null; } - if (XPipeDistributionType.get().getUpdateHandler().getLastUpdateCheckResult().getValue() != null - && XPipeDistributionType.get().getUpdateHandler() + if (XPipeDistributionType.get() + .getUpdateHandler() + .getLastUpdateCheckResult() + .getValue() + != null + && XPipeDistributionType.get() + .getUpdateHandler() .getLastUpdateCheckResult() .getValue() .isUpdate()) { return AppI18n.get( "updateAvailable", - XPipeDistributionType.get().getUpdateHandler() + XPipeDistributionType.get() + .getUpdateHandler() .getLastUpdateCheckResult() .getValue() .getVersion()); } - if (XPipeDistributionType.get().getUpdateHandler().getLastUpdateCheckResult().getValue() != null) { + if (XPipeDistributionType.get() + .getUpdateHandler() + .getLastUpdateCheckResult() + .getValue() + != null) { return AppI18n.readableDuration( - new SimpleObjectProperty<>(XPipeDistributionType.get().getUpdateHandler() + new SimpleObjectProperty<>(XPipeDistributionType.get() + .getUpdateHandler() .getLastUpdateCheckResult() .getValue() .getCheckTime()), @@ -80,7 +99,9 @@ public class UpdateCheckComp extends SimpleComp { @Override protected Region createSimple() { var button = new Button(); - button.disableProperty().bind(PlatformThread.sync(XPipeDistributionType.get().getUpdateHandler().getBusy())); + button.disableProperty() + .bind(PlatformThread.sync( + XPipeDistributionType.get().getUpdateHandler().getBusy())); button.textProperty() .bind(Bindings.createStringBinding( () -> { diff --git a/app/src/main/java/io/xpipe/app/storage/DataSourceCollection.java b/app/src/main/java/io/xpipe/app/storage/DataSourceCollection.java index 1d49875c5..126111f10 100644 --- a/app/src/main/java/io/xpipe/app/storage/DataSourceCollection.java +++ b/app/src/main/java/io/xpipe/app/storage/DataSourceCollection.java @@ -114,7 +114,7 @@ public class DataSourceCollection extends StorageElement { } @Override - public void refresh(boolean deep) throws Exception {} + public void refresh(boolean deep) {} public void setName(String name) { if (name.equals(this.name)) { diff --git a/app/src/main/java/io/xpipe/app/storage/DataSourceEntry.java b/app/src/main/java/io/xpipe/app/storage/DataSourceEntry.java index 792a54a07..1626b636e 100644 --- a/app/src/main/java/io/xpipe/app/storage/DataSourceEntry.java +++ b/app/src/main/java/io/xpipe/app/storage/DataSourceEntry.java @@ -225,7 +225,7 @@ public class DataSourceEntry extends StorageElement { } @Getter - public static enum State { + public enum State { @JsonProperty("loadFailed") LOAD_FAILED(false), @JsonProperty("incomplete") diff --git a/app/src/main/java/io/xpipe/app/storage/DataStorage.java b/app/src/main/java/io/xpipe/app/storage/DataStorage.java index 0d66a59c5..850bce171 100644 --- a/app/src/main/java/io/xpipe/app/storage/DataStorage.java +++ b/app/src/main/java/io/xpipe/app/storage/DataStorage.java @@ -116,8 +116,8 @@ public abstract class DataStorage { } } - public synchronized void deleteChildren(DataStoreEntry e, boolean deep) { - getStoreChildren(e,deep).forEach(entry -> { + public synchronized void deleteChildren(DataStoreEntry e, boolean deep) { + getStoreChildren(e, deep).forEach(entry -> { if (!entry.getConfiguration().isDeletable()) { return; } @@ -126,17 +126,17 @@ public abstract class DataStorage { }); } - public synchronized List getStoreChildren(DataStoreEntry entry, boolean deep) { - var children = new ArrayList<>(getStoreEntries().stream().filter(other -> { - if (!other.getState().isUsable()) { - return false; - } + public synchronized List getStoreChildren(DataStoreEntry entry, boolean deep) { + var children = new ArrayList<>(getStoreEntries().stream() + .filter(other -> { + if (!other.getState().isUsable()) { + return false; + } - var parent = other - .getProvider() - .getParent(other.getStore()); - return entry.getStore().equals(parent); - }).toList()); + var parent = other.getProvider().getParent(other.getStore()); + return entry.getStore().equals(parent); + }) + .toList()); if (deep) { for (DataStoreEntry dataStoreEntry : new ArrayList<>(children)) { diff --git a/app/src/main/java/io/xpipe/app/storage/DataStorageWriter.java b/app/src/main/java/io/xpipe/app/storage/DataStorageWriter.java index 867bac95b..1da32b2fe 100644 --- a/app/src/main/java/io/xpipe/app/storage/DataStorageWriter.java +++ b/app/src/main/java/io/xpipe/app/storage/DataStorageWriter.java @@ -46,7 +46,7 @@ public class DataStorageWriter { var found = DataStorage.get().getStoreEntryIfPresent(store); return found.map(dataSourceEntry -> dataSourceEntry.getUuid()); } - } catch (JsonProcessingException e) { + } catch (JsonProcessingException ignored) { } return Optional.empty(); }, @@ -62,7 +62,7 @@ public class DataStorageWriter { var found = DataStorage.get().getSourceEntry(source); return found.map(dataSourceEntry -> dataSourceEntry.getUuid()); } - } catch (JsonProcessingException e) { + } catch (JsonProcessingException ignored) { } return Optional.empty(); }, diff --git a/app/src/main/java/io/xpipe/app/storage/DataStoreEntry.java b/app/src/main/java/io/xpipe/app/storage/DataStoreEntry.java index 2d878ae24..a18a694ba 100644 --- a/app/src/main/java/io/xpipe/app/storage/DataStoreEntry.java +++ b/app/src/main/java/io/xpipe/app/storage/DataStoreEntry.java @@ -58,8 +58,7 @@ public class DataStoreEntry extends StorageElement { boolean dirty, State state, Configuration configuration, - boolean expanded) - throws Exception { + boolean expanded) { super(directory, uuid, name, lastUsed, lastModified, dirty); this.information = information; this.store = DataStorageParser.storeFromNode(storeNode); @@ -100,7 +99,17 @@ public class DataStoreEntry extends StorageElement { Configuration configuration, boolean expanded) { var entry = new DataStoreEntry( - directory, uuid, name, lastUsed, lastModified, information, storeNode, false, state, configuration, expanded); + directory, + uuid, + name, + lastUsed, + lastModified, + information, + storeNode, + false, + state, + configuration, + expanded); return entry; } @@ -140,7 +149,9 @@ public class DataStoreEntry extends StorageElement { } }) .orElse(Configuration.defaultConfiguration()); - var expanded = Optional.ofNullable(json.get("expanded")).map(jsonNode -> jsonNode.booleanValue()).orElse(true); + var expanded = Optional.ofNullable(json.get("expanded")) + .map(jsonNode -> jsonNode.booleanValue()) + .orElse(true); // Store loading is prone to errors. JsonNode storeNode = null; @@ -149,7 +160,8 @@ public class DataStoreEntry extends StorageElement { } catch (Exception e) { ErrorEvent.fromThrowable(e).handle(); } - return createExisting(dir, uuid, name, lastUsed, lastModified, information, storeNode, state, configuration, expanded); + return createExisting( + dir, uuid, name, lastUsed, lastModified, information, storeNode, state, configuration, expanded); } public void setConfiguration(Configuration configuration) { @@ -310,7 +322,7 @@ public class DataStoreEntry extends StorageElement { } @Getter - public static enum State { + public enum State { @JsonProperty("loadFailed") LOAD_FAILED(false), @JsonProperty("incomplete") diff --git a/app/src/main/java/io/xpipe/app/storage/StandardStorage.java b/app/src/main/java/io/xpipe/app/storage/StandardStorage.java index 88177ed95..fedb22b4f 100644 --- a/app/src/main/java/io/xpipe/app/storage/StandardStorage.java +++ b/app/src/main/java/io/xpipe/app/storage/StandardStorage.java @@ -37,7 +37,7 @@ public class StandardStorage extends DataStorage { var name = file.getFileName().toString(); try { - UUID uuid = null; + UUID uuid; try { uuid = UUID.fromString(name); } catch (Exception ex) { @@ -69,7 +69,7 @@ public class StandardStorage extends DataStorage { var name = file.getFileName().toString(); try { - UUID uuid = null; + UUID uuid; try { uuid = UUID.fromString(name); } catch (Exception ex) { @@ -101,7 +101,7 @@ public class StandardStorage extends DataStorage { var name = file.getFileName().toString(); try { - UUID uuid = null; + UUID uuid; try { uuid = UUID.fromString(name); } catch (Exception ex) { diff --git a/app/src/main/java/io/xpipe/app/storage/StorageElement.java b/app/src/main/java/io/xpipe/app/storage/StorageElement.java index 15125aefb..e565df681 100644 --- a/app/src/main/java/io/xpipe/app/storage/StorageElement.java +++ b/app/src/main/java/io/xpipe/app/storage/StorageElement.java @@ -113,7 +113,7 @@ public abstract class StorageElement { return lastModified; } - public static interface Listener { + public interface Listener { void onUpdate(); } diff --git a/app/src/main/java/io/xpipe/app/test/DaemonExtensionTest.java b/app/src/main/java/io/xpipe/app/test/DaemonExtensionTest.java index 20c9a7b3d..e028d25f4 100644 --- a/app/src/main/java/io/xpipe/app/test/DaemonExtensionTest.java +++ b/app/src/main/java/io/xpipe/app/test/DaemonExtensionTest.java @@ -2,11 +2,11 @@ package io.xpipe.app.test; import io.xpipe.api.DataSource; import io.xpipe.app.ext.XPipeServiceProviders; +import io.xpipe.app.util.XPipeSession; import io.xpipe.beacon.BeaconDaemonController; import io.xpipe.core.store.DataStore; import io.xpipe.core.util.JacksonMapper; import io.xpipe.core.util.XPipeDaemonMode; -import io.xpipe.app.util.XPipeSession; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; diff --git a/app/src/main/java/io/xpipe/app/test/LocalExtensionTest.java b/app/src/main/java/io/xpipe/app/test/LocalExtensionTest.java index 15cd6a0aa..d0f0e0a1f 100644 --- a/app/src/main/java/io/xpipe/app/test/LocalExtensionTest.java +++ b/app/src/main/java/io/xpipe/app/test/LocalExtensionTest.java @@ -11,7 +11,7 @@ import java.util.UUID; public class LocalExtensionTest extends ExtensionTest { @BeforeAll - public static void setup() throws Exception { + public static void setup() { JacksonMapper.initModularized(ModuleLayer.boot()); XPipeServiceProviders.load(ModuleLayer.boot()); AppProperties.init(); diff --git a/app/src/main/java/io/xpipe/app/test/TestModule.java b/app/src/main/java/io/xpipe/app/test/TestModule.java index e408ed0cf..afbe91020 100644 --- a/app/src/main/java/io/xpipe/app/test/TestModule.java +++ b/app/src/main/java/io/xpipe/app/test/TestModule.java @@ -11,7 +11,7 @@ public abstract class TestModule { private static final Map, Map> values = new LinkedHashMap<>(); - @SuppressWarnings({"unchecked"}) + @SuppressWarnings({"unchecked", "rawtypes"}) public static Map get(Class c, String... classes) { if (!values.containsKey(c)) { List> loadedClasses = (List>) Arrays.stream(classes) diff --git a/app/src/main/java/io/xpipe/app/update/AppDownloads.java b/app/src/main/java/io/xpipe/app/update/AppDownloads.java index a7e4fbc25..f87eeb936 100644 --- a/app/src/main/java/io/xpipe/app/update/AppDownloads.java +++ b/app/src/main/java/io/xpipe/app/update/AppDownloads.java @@ -33,7 +33,8 @@ public class AppDownloads { .withRateLimitHandler(RateLimitHandler.FAIL) .withAuthorizationProvider(AuthorizationProvider.ANONYMOUS) .build(); - repository = github.getRepository(AppProperties.get().isStaging() ? "xpipe-io/xpipe_staging" : "xpipe-io/xpipe"); + repository = + github.getRepository(AppProperties.get().isStaging() ? "xpipe-io/xpipe_staging" : "xpipe-io/xpipe"); return repository; } @@ -103,7 +104,6 @@ public class AppDownloads { .orElse("?"); } - public static Optional getLatestIncludingPreRelease() throws IOException { var repo = getRepository(); return Optional.ofNullable(repo.listReleases().iterator().next()); @@ -122,7 +122,8 @@ public class AppDownloads { } // If we are currently running a prerelease, always return this as the suitable release! - if (preIncluding.isPresent() && AppProperties.get().getVersion().equals(preIncluding.get().getTagName())) { + if (preIncluding.isPresent() + && AppProperties.get().getVersion().equals(preIncluding.get().getTagName())) { return preIncluding; } diff --git a/app/src/main/java/io/xpipe/app/update/AppInstaller.java b/app/src/main/java/io/xpipe/app/update/AppInstaller.java index 93e15453e..745c55dee 100644 --- a/app/src/main/java/io/xpipe/app/update/AppInstaller.java +++ b/app/src/main/java/io/xpipe/app/update/AppInstaller.java @@ -37,14 +37,16 @@ public class AppInstaller { } public static void installFile(ShellControl s, InstallerAssetType asset, Path localFile) throws Exception { - String targetFile = null; + String targetFile; if (s.isLocal()) { targetFile = localFile.toString(); } else { targetFile = FileNames.join( s.getSubTemporaryDirectory(), localFile.getFileName().toString()); try (InputStream in = Files.newInputStream(localFile)) { - in.transferTo(s.getShellDialect().createStreamFileWriteCommand(s, targetFile).startExternalStdin()); + in.transferTo(s.getShellDialect() + .createStreamFileWriteCommand(s, targetFile) + .startExternalStdin()); } } @@ -75,7 +77,8 @@ public class AppInstaller { } if (p.getOsType().equals(OsType.LINUX)) { - try (CommandControl c = p.getShellDialect().createFileExistsCommand(p, "/etc/debian_version") + try (CommandControl c = p.getShellDialect() + .createFileExistsCommand(p, "/etc/debian_version") .start()) { return c.discardAndCheckExit() ? new InstallerAssetType.Debian() : new InstallerAssetType.Rpm(); } @@ -103,7 +106,8 @@ public class AppInstaller { public abstract void installLocal(String file) throws Exception; public boolean isCorrectAsset(String name) { - return name.endsWith(getExtension()) && name.contains(AppProperties.get().getArch()); + return name.endsWith(getExtension()) + && name.contains(AppProperties.get().getArch()); } public abstract String getExtension(); @@ -119,8 +123,7 @@ public class AppInstaller { @Override public void installRemote(ShellControl shellControl, String file) throws Exception { var exec = XPipeInstallation.getInstallationExecutable( - shellControl, - XPipeInstallation.getDefaultInstallationBasePath(shellControl, false)); + shellControl, XPipeInstallation.getDefaultInstallationBasePath(shellControl, false)); var logsDir = FileNames.join(XPipeInstallation.getDataBasePath(shellControl), "logs"); var cmd = new ArrayList<>(java.util.List.of( "start", @@ -148,13 +151,15 @@ public class AppInstaller { XPipeInstallation.getDefaultInstallationBasePath(shellProcessControl, false)); var logsDir = FileNames.join(XPipeInstallation.getDataBasePath(shellProcessControl), "logs"); var logFile = FileNames.join(logsDir, "installer_" + FileNames.getFileName(file) + ".log"); - var script = ScriptHelper.createExecScript(shellProcessControl, String.format( - """ + var script = ScriptHelper.createExecScript( + shellProcessControl, + String.format( + """ cd /D "%%HOMEDRIVE%%%%HOMEPATH%%" start "" /wait msiexec /i "%s" /l* "%s" /qb start "" "%s" """, - file, logFile, exec)); + file, logFile, exec)); shellProcessControl.executeSimpleCommand("start \"\" /min \"" + script + "\""); } } @@ -229,8 +234,11 @@ public class AppInstaller { @Override public void installLocal(String file) throws Exception { - var command = ShellStore.createLocal().control().subShell(ShellDialects.BASH).command(String.format( - """ + var command = ShellStore.createLocal() + .control() + .subShell(ShellDialects.BASH) + .command(String.format( + """ function exec { echo "+ sudo rpm -U -v --force \\"%s\\"" sudo rpm -U -v --force "%s" || return 1 @@ -240,7 +248,7 @@ public class AppInstaller { cd ~ exec || read -rsp "Update failed ..."$'\\n' -n 1 key """, - file, file)); + file, file)); TerminalHelper.open("XPipe Updater", command); } } @@ -267,8 +275,11 @@ public class AppInstaller { @Override public void installLocal(String file) throws Exception { - var command = ShellStore.createLocal().control().subShell(ShellDialects.BASH).command(String.format( - """ + var command = ShellStore.createLocal() + .control() + .subShell(ShellDialects.BASH) + .command(String.format( + """ function exec { echo "+ sudo installer -verboseR -allowUntrusted -pkg \\"%s\\" -target /" sudo installer -verboseR -allowUntrusted -pkg "%s" -target / || return 1 @@ -278,7 +289,7 @@ public class AppInstaller { cd ~ exec || read -rsp "Update failed ..."$'\\n' -n 1 key """, - file, file)); + file, file)); TerminalHelper.open("XPipe Updater", command); } } diff --git a/app/src/main/java/io/xpipe/app/update/ChocoUpdater.java b/app/src/main/java/io/xpipe/app/update/ChocoUpdater.java index 082dcf424..7aed7a548 100644 --- a/app/src/main/java/io/xpipe/app/update/ChocoUpdater.java +++ b/app/src/main/java/io/xpipe/app/update/ChocoUpdater.java @@ -31,8 +31,12 @@ public class ChocoUpdater extends UpdateHandler { public AvailableRelease refreshUpdateCheckImpl() throws Exception { try (var sc = ShellStore.createLocal().control().start()) { - var latest = sc.executeSimpleStringCommand( - "choco outdated -r --nocolor").lines().filter(s -> s.startsWith("xpipe")).findAny().orElseThrow().split("\\|")[2]; + var latest = sc.executeSimpleStringCommand("choco outdated -r --nocolor") + .lines() + .filter(s -> s.startsWith("xpipe")) + .findAny() + .orElseThrow() + .split("\\|")[2]; var isUpdate = isUpdate(latest); var rel = new AvailableRelease( AppProperties.get().getVersion(), diff --git a/app/src/main/java/io/xpipe/app/update/GitHubUpdater.java b/app/src/main/java/io/xpipe/app/update/GitHubUpdater.java index 8dab29e87..35716f689 100644 --- a/app/src/main/java/io/xpipe/app/update/GitHubUpdater.java +++ b/app/src/main/java/io/xpipe/app/update/GitHubUpdater.java @@ -27,8 +27,8 @@ public class GitHubUpdater extends UpdateHandler { return; } - var changelogString = AppDownloads.downloadChangelog( - lastUpdateCheckResult.getValue().getVersion(), false); + var changelogString = + AppDownloads.downloadChangelog(lastUpdateCheckResult.getValue().getVersion(), false); var changelog = changelogString.orElse(null); var rel = new PreparedUpdate( AppProperties.get().getVersion(), diff --git a/app/src/main/java/io/xpipe/app/update/HomebrewUpdater.java b/app/src/main/java/io/xpipe/app/update/HomebrewUpdater.java index e59693b7e..d5dfe054a 100644 --- a/app/src/main/java/io/xpipe/app/update/HomebrewUpdater.java +++ b/app/src/main/java/io/xpipe/app/update/HomebrewUpdater.java @@ -3,12 +3,9 @@ package io.xpipe.app.update; import io.xpipe.app.core.AppProperties; import io.xpipe.app.fxcomps.impl.CodeSnippet; import io.xpipe.app.fxcomps.impl.CodeSnippetComp; -import io.xpipe.core.store.ShellStore; import javafx.beans.property.SimpleObjectProperty; import javafx.scene.layout.Region; -import java.time.Instant; - public class HomebrewUpdater extends GitHubUpdater { public HomebrewUpdater() { diff --git a/app/src/main/java/io/xpipe/app/update/PortableUpdater.java b/app/src/main/java/io/xpipe/app/update/PortableUpdater.java index bc9fa131d..d48ad8e5b 100644 --- a/app/src/main/java/io/xpipe/app/update/PortableUpdater.java +++ b/app/src/main/java/io/xpipe/app/update/PortableUpdater.java @@ -18,15 +18,16 @@ public class PortableUpdater extends UpdateHandler { @Override public Region createInterface() { return new ButtonComp(AppI18n.observable("checkOutUpdate"), () -> { - Hyperlinks.open(XPipeDistributionType.get() - .getUpdateHandler() - .getPreparedUpdate() - .getValue() - .getReleaseUrl()); - }).createRegion(); + Hyperlinks.open(XPipeDistributionType.get() + .getUpdateHandler() + .getPreparedUpdate() + .getValue() + .getReleaseUrl()); + }) + .createRegion(); } - public void executeUpdateAndCloseImpl() throws Exception { + public void executeUpdateAndCloseImpl() { throw new UnsupportedOperationException(); } diff --git a/app/src/main/java/io/xpipe/app/update/UpdateAvailableAlert.java b/app/src/main/java/io/xpipe/app/update/UpdateAvailableAlert.java index 1ffb187b2..93edc7a44 100644 --- a/app/src/main/java/io/xpipe/app/update/UpdateAvailableAlert.java +++ b/app/src/main/java/io/xpipe/app/update/UpdateAvailableAlert.java @@ -24,10 +24,10 @@ public class UpdateAvailableAlert { alert.setAlertType(Alert.AlertType.NONE); var markdown = new MarkdownComp(u.getBody() != null ? u.getBody() : "", s -> { - var header = "

" + AppI18n.get("whatsNew", u.getVersion()) + "

"; - return header + s; - }) - .createRegion(); + var header = "

" + AppI18n.get("whatsNew", u.getVersion()) + "

"; + return header + s; + }) + .createRegion(); alert.getButtonTypes().clear(); var updaterContent = uh.createInterface(); if (updaterContent != null) { @@ -39,7 +39,8 @@ public class UpdateAvailableAlert { alert.getDialogPane().setContent(box); } else { alert.getDialogPane().setContent(markdown); - alert.getButtonTypes().add(new ButtonType(AppI18n.get("install"), ButtonBar.ButtonData.OK_DONE)); + alert.getButtonTypes() + .add(new ButtonType(AppI18n.get("install"), ButtonBar.ButtonData.OK_DONE)); } alert.getButtonTypes().add(new ButtonType(AppI18n.get("ignore"), ButtonBar.ButtonData.NO)); diff --git a/app/src/main/java/io/xpipe/app/update/UpdateChangelogAlert.java b/app/src/main/java/io/xpipe/app/update/UpdateChangelogAlert.java index de3691794..8392ef473 100644 --- a/app/src/main/java/io/xpipe/app/update/UpdateChangelogAlert.java +++ b/app/src/main/java/io/xpipe/app/update/UpdateChangelogAlert.java @@ -36,7 +36,8 @@ public class UpdateChangelogAlert { alert.getDialogPane().setContent(markdown); alert.getButtonTypes().add(new ButtonType(AppI18n.get("gotIt"), ButtonBar.ButtonData.OK_DONE)); - },null, + }, + null, r -> r.filter(b -> b.getButtonData().isDefaultButton()).ifPresent(t -> {})); } } diff --git a/app/src/main/java/io/xpipe/app/update/XPipeDistributionType.java b/app/src/main/java/io/xpipe/app/update/XPipeDistributionType.java index da7a7cca1..8d9cf2df6 100644 --- a/app/src/main/java/io/xpipe/app/update/XPipeDistributionType.java +++ b/app/src/main/java/io/xpipe/app/update/XPipeDistributionType.java @@ -81,7 +81,9 @@ public enum XPipeDistributionType { if (brewOut.getExitCode() == 0) { if (out.lines().anyMatch(s -> { var split = s.split(" "); - return split.length == 2 && split[0].equals("xpipe") && split[1].equals(AppProperties.get().getVersion()); + return split.length == 2 + && split[0].equals("xpipe") + && split[1].equals(AppProperties.get().getVersion()); })) { return HOMEBREW; } @@ -97,6 +99,7 @@ public enum XPipeDistributionType { @Getter private final String id; + private UpdateHandler updateHandler; private final Supplier updateHandlerSupplier; diff --git a/app/src/main/java/io/xpipe/app/update/XPipeInstanceHelper.java b/app/src/main/java/io/xpipe/app/update/XPipeInstanceHelper.java index b992ead25..0aeb8e133 100644 --- a/app/src/main/java/io/xpipe/app/update/XPipeInstanceHelper.java +++ b/app/src/main/java/io/xpipe/app/update/XPipeInstanceHelper.java @@ -36,7 +36,7 @@ public class XPipeInstanceHelper { public static boolean isSupported(ShellStore host) { try (var pc = host.control().start(); - var cmd = pc.command(List.of("xpipe"))) { + var cmd = pc.command(List.of("xpipe"))) { cmd.discardOrThrow(); return true; } catch (Exception e) { diff --git a/app/src/main/java/io/xpipe/app/util/ApplicationHelper.java b/app/src/main/java/io/xpipe/app/util/ApplicationHelper.java index aa1354246..cd85fcb26 100644 --- a/app/src/main/java/io/xpipe/app/util/ApplicationHelper.java +++ b/app/src/main/java/io/xpipe/app/util/ApplicationHelper.java @@ -27,10 +27,12 @@ public class ApplicationHelper { processControl.getShellDialect().getWhichCommand(executable)); } - public static void checkSupport(ShellControl processControl, String executable, String displayName, String connectionName) + public static void checkSupport( + ShellControl processControl, String executable, String displayName, String connectionName) throws Exception { if (!isInPath(processControl, executable)) { - throw new IOException(displayName + " executable " + executable + " not found in PATH" + (connectionName != null ? " on system " + connectionName : "")); + throw new IOException(displayName + " executable " + executable + " not found in PATH" + + (connectionName != null ? " on system " + connectionName : "")); } } } diff --git a/app/src/main/java/io/xpipe/app/util/DataTypeParserInternal.java b/app/src/main/java/io/xpipe/app/util/DataTypeParserInternal.java index 201b5fe47..d16f8c1a2 100644 --- a/app/src/main/java/io/xpipe/app/util/DataTypeParserInternal.java +++ b/app/src/main/java/io/xpipe/app/util/DataTypeParserInternal.java @@ -39,7 +39,7 @@ public class DataTypeParserInternal { try { var bigDecimal = new BigDecimal(val); return Optional.of(ValueNode.ofDecimal(bigDecimal)); - } catch (Exception e) { + } catch (Exception ignored) { } return Optional.empty(); @@ -89,14 +89,14 @@ public class DataTypeParserInternal { try { var bigInteger = new BigInteger(val); return Optional.of(ValueNode.ofInteger(bigInteger)); - } catch (Exception e) { + } catch (Exception ignored) { } // Big decimal value try { var bigDecimal = new BigDecimal(val); return Optional.of(ValueNode.ofDecimal(bigDecimal)); - } catch (Exception e) { + } catch (Exception ignored) { } return Optional.empty(); diff --git a/app/src/main/java/io/xpipe/app/util/DefaultSecretValue.java b/app/src/main/java/io/xpipe/app/util/DefaultSecretValue.java index ec1e45509..e644ad251 100644 --- a/app/src/main/java/io/xpipe/app/util/DefaultSecretValue.java +++ b/app/src/main/java/io/xpipe/app/util/DefaultSecretValue.java @@ -15,7 +15,6 @@ import java.security.spec.InvalidKeySpecException; import java.security.spec.KeySpec; import java.util.Random; - @JsonTypeName("default") @SuperBuilder @Jacksonized diff --git a/app/src/main/java/io/xpipe/app/util/DesktopShortcuts.java b/app/src/main/java/io/xpipe/app/util/DesktopShortcuts.java index a0418ea18..e9ea1ff0f 100644 --- a/app/src/main/java/io/xpipe/app/util/DesktopShortcuts.java +++ b/app/src/main/java/io/xpipe/app/util/DesktopShortcuts.java @@ -11,7 +11,8 @@ public class DesktopShortcuts { private static void createWindowsShortcut(String target, String name) throws Exception { var icon = XPipeInstallation.getLocalDefaultInstallationIcon(); - var shortcutTarget = XPipeInstallation.getCurrentInstallationBasePath().resolve(XPipeInstallation.getRelativeCliExecutablePath(OsType.WINDOWS)); + var shortcutTarget = XPipeInstallation.getCurrentInstallationBasePath() + .resolve(XPipeInstallation.getRelativeCliExecutablePath(OsType.WINDOWS)); var content = String.format( """ set "TARGET=%s" @@ -20,12 +21,13 @@ public class DesktopShortcuts { %%PWS%% -Command "$ws = New-Object -ComObject WScript.Shell; $s = $ws.CreateShortcut('%%SHORTCUT%%'); $S.IconLocation='%s'; $S.WindowStyle=7; $S.TargetPath = '%%TARGET%%'; $S.Arguments = 'open %s'; $S.Save()" """, - shortcutTarget, name, icon.toString(), target); + shortcutTarget, name, icon, target); LocalStore.getShell().executeSimpleCommand(content); } private static void createLinuxShortcut(String target, String name) throws Exception { - var exec = XPipeInstallation.getCurrentInstallationBasePath().resolve(XPipeInstallation.getRelativeCliExecutablePath(OsType.LINUX)); + var exec = XPipeInstallation.getCurrentInstallationBasePath() + .resolve(XPipeInstallation.getRelativeCliExecutablePath(OsType.LINUX)); var icon = XPipeInstallation.getLocalDefaultInstallationIcon(); var content = String.format( """ @@ -38,14 +40,15 @@ public class DesktopShortcuts { Terminal=false Categories=Utility;Development;Office; """, - name, exec, target, icon.toString()); + name, exec, target, icon); var file = Path.of(System.getProperty("user.home") + "/Desktop/" + name + ".desktop"); Files.writeString(file, content); file.toFile().setExecutable(true); } private static void createMacOSShortcut(String target, String name) throws Exception { - var exec = XPipeInstallation.getCurrentInstallationBasePath().resolve(XPipeInstallation.getRelativeCliExecutablePath(OsType.MACOS)); + var exec = XPipeInstallation.getCurrentInstallationBasePath() + .resolve(XPipeInstallation.getRelativeCliExecutablePath(OsType.MACOS)); var icon = XPipeInstallation.getLocalDefaultInstallationIcon(); var base = System.getProperty("user.home") + "/Desktop/" + name + ".app"; var content = String.format( @@ -60,10 +63,14 @@ public class DesktopShortcuts { pc.executeSimpleCommand(pc.getShellDialect().getMkdirsCommand(base + "/Contents/Resources")); var executable = base + "/Contents/MacOS/" + name; - pc.getShellDialect().createScriptTextFileWriteCommand(pc, content, executable).execute(); + pc.getShellDialect() + .createScriptTextFileWriteCommand(pc, content, executable) + .execute(); pc.executeSimpleCommand("chmod ugo+x \"" + executable + "\""); - pc.getShellDialect().createScriptTextFileWriteCommand(pc, "APPL????", base + "/PkgInfo").execute(); + pc.getShellDialect() + .createScriptTextFileWriteCommand(pc, "APPL????", base + "/PkgInfo") + .execute(); pc.executeSimpleCommand("cp \"" + icon + "\" \"" + base + "/Contents/Resources/" + name + ".icns\""); } } diff --git a/app/src/main/java/io/xpipe/app/util/DialogHelper.java b/app/src/main/java/io/xpipe/app/util/DialogHelper.java index c939796cf..cdc98dfb4 100644 --- a/app/src/main/java/io/xpipe/app/util/DialogHelper.java +++ b/app/src/main/java/io/xpipe/app/util/DialogHelper.java @@ -99,7 +99,10 @@ public class DialogHelper { var name = XPipeDaemon.getInstance().getStoreName(store).orElse(null); return Dialog.query("Store", false, true, false, name, QueryConverter.STRING) .map((String newName) -> { - var found = DataStorage.get().getStoreEntryIfPresent(newName).map(entry -> entry.getStore()).orElseThrow(); + var found = DataStorage.get() + .getStoreEntryIfPresent(newName) + .map(entry -> entry.getStore()) + .orElseThrow(); if (!filter.isAssignableFrom(found.getClass())) { throw new IllegalArgumentException("Incompatible store type"); } diff --git a/app/src/main/java/io/xpipe/app/util/DynamicOptionsBuilder.java b/app/src/main/java/io/xpipe/app/util/DynamicOptionsBuilder.java index 960466c79..e08372e94 100644 --- a/app/src/main/java/io/xpipe/app/util/DynamicOptionsBuilder.java +++ b/app/src/main/java/io/xpipe/app/util/DynamicOptionsBuilder.java @@ -98,10 +98,7 @@ public class DynamicOptionsBuilder { var comp = new ToggleGroupComp<>( prop, new SimpleObjectProperty<>(Map.of( - Boolean.TRUE, - AppI18n.observable("app.yes"), - Boolean.FALSE, - AppI18n.observable("app.no")))); + Boolean.TRUE, AppI18n.observable("app.yes"), Boolean.FALSE, AppI18n.observable("app.no")))); entries.add(new DynamicOptionsComp.Entry(nameKey, AppI18n.observable(nameKey), comp)); props.add(prop); return this; diff --git a/app/src/main/java/io/xpipe/app/util/FileBridge.java b/app/src/main/java/io/xpipe/app/util/FileBridge.java index f4fc063bd..b77817102 100644 --- a/app/src/main/java/io/xpipe/app/util/FileBridge.java +++ b/app/src/main/java/io/xpipe/app/util/FileBridge.java @@ -121,7 +121,8 @@ public class FileBridge { return Optional.empty(); } - public void openString(String keyName, Object key, String input, Consumer output, Consumer consumer) { + public void openString( + String keyName, Object key, String input, Consumer output, Consumer consumer) { if (input == null) { input = ""; } diff --git a/app/src/main/java/io/xpipe/app/util/Hyperlinks.java b/app/src/main/java/io/xpipe/app/util/Hyperlinks.java index 26a2488af..b9a309d31 100644 --- a/app/src/main/java/io/xpipe/app/util/Hyperlinks.java +++ b/app/src/main/java/io/xpipe/app/util/Hyperlinks.java @@ -14,31 +14,26 @@ public class Hyperlinks { "https://join.slack.com/t/XPipe/shared_invite/zt-1awjq0t5j-5i4UjNJfNe1VN4b_auu6Cg"; public static final String DOCS_PRIVACY = "https://xpipe.io/docs/privacy"; - static final String[] browsers = { - "xdg-open", - "google-chrome", - "firefox", - "opera", - "konqueror", - "mozilla" - }; + static final String[] browsers = {"xdg-open", "google-chrome", "firefox", "opera", "konqueror", "mozilla"}; @SuppressWarnings("deprecation") public static void open(String uri) { String osName = System.getProperty("os.name"); try { if (osName.startsWith("Mac OS")) { - Runtime.getRuntime().exec( - "open " + uri); + Runtime.getRuntime().exec("open " + uri); } else if (osName.startsWith("Windows")) { - Runtime.getRuntime().exec( - "rundll32 url.dll,FileProtocolHandler " + uri); - } else { //assume Unix or Linux + Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + uri); + } else { // assume Unix or Linux String browser = null; for (String b : browsers) { - if (browser == null && Runtime.getRuntime().exec( - new String[]{"which", b}).getInputStream().read() != -1) { - Runtime.getRuntime().exec(new String[]{browser = b, uri}); + if (browser == null + && Runtime.getRuntime() + .exec(new String[] {"which", b}) + .getInputStream() + .read() + != -1) { + Runtime.getRuntime().exec(new String[] {browser = b, uri}); } } if (browser == null) { diff --git a/app/src/main/java/io/xpipe/app/util/LockChangeAlert.java b/app/src/main/java/io/xpipe/app/util/LockChangeAlert.java index 1c83613e1..b216c3b63 100644 --- a/app/src/main/java/io/xpipe/app/util/LockChangeAlert.java +++ b/app/src/main/java/io/xpipe/app/util/LockChangeAlert.java @@ -48,9 +48,13 @@ public class LockChangeAlert { alert.getDialogPane().setContent(content); var button = alert.getDialogPane().lookupButton(ButtonType.OK); - button.disableProperty().bind(Bindings.createBooleanBinding(() -> { - return !Objects.equals(prop1.getValue(), prop2.getValue()); - }, prop1, prop2)); + button.disableProperty() + .bind(Bindings.createBooleanBinding( + () -> { + return !Objects.equals(prop1.getValue(), prop2.getValue()); + }, + prop1, + prop2)); }) .filter(b -> b.getButtonData().isDefaultButton()) .ifPresent(t -> { diff --git a/app/src/main/java/io/xpipe/app/util/LockedSecretValue.java b/app/src/main/java/io/xpipe/app/util/LockedSecretValue.java index 9f0b74eed..792a134df 100644 --- a/app/src/main/java/io/xpipe/app/util/LockedSecretValue.java +++ b/app/src/main/java/io/xpipe/app/util/LockedSecretValue.java @@ -32,7 +32,9 @@ public class LockedSecretValue extends AesSecretValue { } protected SecretKey getAESKey(int keysize) throws NoSuchAlgorithmException, InvalidKeySpecException { - var chars = AppPrefs.get().getLockPassword().getValue() != null ? AppPrefs.get().getLockPassword().getValue().getSecret() : new char[0]; + var chars = AppPrefs.get().getLockPassword().getValue() != null + ? AppPrefs.get().getLockPassword().getValue().getSecret() + : new char[0]; SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256"); var salt = new byte[16]; new Random(keysize).nextBytes(salt); diff --git a/app/src/main/java/io/xpipe/app/util/NamedCharacter.java b/app/src/main/java/io/xpipe/app/util/NamedCharacter.java index 63a37d8aa..c58a8b91c 100644 --- a/app/src/main/java/io/xpipe/app/util/NamedCharacter.java +++ b/app/src/main/java/io/xpipe/app/util/NamedCharacter.java @@ -13,7 +13,7 @@ public class NamedCharacter { String translationKey; public static QueryConverter converter(List chars, boolean allowOthers) { - return new QueryConverter() { + return new QueryConverter<>() { @Override protected Character fromString(String s) { if (s.length() == 0) { diff --git a/app/src/main/java/io/xpipe/app/util/OptionsBuilder.java b/app/src/main/java/io/xpipe/app/util/OptionsBuilder.java index df5f20976..bbc80ff3f 100644 --- a/app/src/main/java/io/xpipe/app/util/OptionsBuilder.java +++ b/app/src/main/java/io/xpipe/app/util/OptionsBuilder.java @@ -49,7 +49,11 @@ public class OptionsBuilder { public OptionsBuilder addTitle(ObservableValue title) { finishCurrent(); entries.add(new OptionsComp.Entry( - null, null, null, null, Comp.of(() -> new Label(title.getValue())).styleClass("title-header"))); + null, + null, + null, + null, + Comp.of(() -> new Label(title.getValue())).styleClass("title-header"))); return this; } @@ -82,21 +86,21 @@ public class OptionsBuilder { props.add(prop); return this; } + public OptionsBuilder addToggle(Property prop) { var comp = new ToggleGroupComp<>( prop, new SimpleObjectProperty<>(Map.of( - Boolean.TRUE, - AppI18n.observable("app.yes"), - Boolean.FALSE, - AppI18n.observable("app.no")))); + Boolean.TRUE, AppI18n.observable("app.yes"), Boolean.FALSE, AppI18n.observable("app.no")))); pushComp(comp); props.add(prop); return this; } + public OptionsBuilder addString(Property prop) { return addString(prop, false); } + public OptionsBuilder addString(Property prop, boolean lazy) { var comp = new TextFieldComp(prop, lazy); pushComp(comp); @@ -104,7 +108,6 @@ public class OptionsBuilder { return this; } - public OptionsBuilder name(String nameKey) { finishCurrent(); name = AppI18n.observable(nameKey); @@ -139,7 +142,6 @@ public class OptionsBuilder { return this; } - public OptionsBuilder addSecret(Property prop) { var comp = new SecretFieldComp(prop); pushComp(comp); diff --git a/app/src/main/java/io/xpipe/app/util/PlatformState.java b/app/src/main/java/io/xpipe/app/util/PlatformState.java index 126c4f3de..f6be54155 100644 --- a/app/src/main/java/io/xpipe/app/util/PlatformState.java +++ b/app/src/main/java/io/xpipe/app/util/PlatformState.java @@ -4,7 +4,6 @@ import lombok.Getter; import lombok.Setter; public enum PlatformState { - NOT_INITIALIZED, RUNNING, EXITED; diff --git a/app/src/main/java/io/xpipe/app/util/PrettyListView.java b/app/src/main/java/io/xpipe/app/util/PrettyListView.java index f2c687aa0..63e0d8a25 100644 --- a/app/src/main/java/io/xpipe/app/util/PrettyListView.java +++ b/app/src/main/java/io/xpipe/app/util/PrettyListView.java @@ -42,8 +42,7 @@ public class PrettyListView extends ListView { private void bindScrollBars() { final Set nodes = lookupAll("VirtualScrollBar"); for (Node node : nodes) { - if (node instanceof ScrollBar) { - ScrollBar bar = (ScrollBar) node; + if (node instanceof ScrollBar bar) { if (bar.getOrientation().equals(Orientation.VERTICAL)) { bindScrollBars(vBar, bar, true); } else if (bar.getOrientation().equals(Orientation.HORIZONTAL)) { diff --git a/app/src/main/java/io/xpipe/app/util/ProxyManagerProviderImpl.java b/app/src/main/java/io/xpipe/app/util/ProxyManagerProviderImpl.java index 9955d632c..574a640ad 100644 --- a/app/src/main/java/io/xpipe/app/util/ProxyManagerProviderImpl.java +++ b/app/src/main/java/io/xpipe/app/util/ProxyManagerProviderImpl.java @@ -41,7 +41,9 @@ public class ProxyManagerProviderImpl extends ProxyManagerProvider { var defaultInstallationExecutable = FileNames.join( XPipeInstallation.getDefaultInstallationBasePath(s, false), XPipeInstallation.getDaemonExecutablePath(s.getOsType())); - if (!s.getShellDialect().createFileExistsCommand(s, defaultInstallationExecutable).executeAndCheck()) { + if (!s.getShellDialect() + .createFileExistsCommand(s, defaultInstallationExecutable) + .executeAndCheck()) { return Optional.of(AppI18n.get("noInstallationFound")); } diff --git a/app/src/main/java/io/xpipe/app/util/ScriptHelper.java b/app/src/main/java/io/xpipe/app/util/ScriptHelper.java index c252f0e5a..91bfdbbd3 100644 --- a/app/src/main/java/io/xpipe/app/util/ScriptHelper.java +++ b/app/src/main/java/io/xpipe/app/util/ScriptHelper.java @@ -18,7 +18,9 @@ public class ScriptHelper { public static String createDetachCommand(ShellControl pc, String command) { if (pc.getShellDialect().equals(ShellDialects.POWERSHELL)) { var script = ScriptHelper.createExecScript(pc, command); - return String.format("Start-Process -WindowStyle Minimized -FilePath powershell.exe -ArgumentList \"-NoProfile\", \"-File\", %s", ShellDialects.POWERSHELL.fileArgument(script)); + return String.format( + "Start-Process -WindowStyle Minimized -FilePath powershell.exe -ArgumentList \"-NoProfile\", \"-File\", %s", + ShellDialects.POWERSHELL.fileArgument(script)); } if (pc.getOsType().equals(OsType.WINDOWS)) { @@ -43,7 +45,8 @@ public class ScriptHelper { } public static String constructInitFile( - ShellControl processControl, List init, String toExecuteInShell, boolean login, String displayName) throws Exception { + ShellControl processControl, List init, String toExecuteInShell, boolean login, String displayName) + throws Exception { ShellDialect t = processControl.getShellDialect(); String nl = t.getNewLine().getNewLineString(); var content = String.join(nl, init.stream().filter(s -> s != null).toList()) + nl; @@ -145,14 +148,22 @@ public class ScriptHelper { try (var sub = parent.subShell(type).start()) { var content = sub.getShellDialect() .prepareAskpassContent( - sub, file, pass.stream().map(secretValue -> secretValue.getSecretValue()).toList()); + sub, + file, + pass.stream() + .map(secretValue -> secretValue.getSecretValue()) + .toList()); var exec = createExecScript(sub, file, content); return exec; } } else { var content = parent.getShellDialect() .prepareAskpassContent( - parent, file, pass.stream().map(secretValue -> secretValue.getSecretValue()).toList()); + parent, + file, + pass.stream() + .map(secretValue -> secretValue.getSecretValue()) + .toList()); var exec = createExecScript(parent, file, content); return exec; } diff --git a/app/src/main/java/io/xpipe/app/util/SmoothScroll.java b/app/src/main/java/io/xpipe/app/util/SmoothScroll.java index 5f7851fd7..5c19f6d28 100644 --- a/app/src/main/java/io/xpipe/app/util/SmoothScroll.java +++ b/app/src/main/java/io/xpipe/app/util/SmoothScroll.java @@ -20,8 +20,7 @@ public class SmoothScroll { private static ScrollBar getScrollbarComponent(Node no, Orientation orientation) { Node n = no.lookup(".scroll-bar"); - if (n instanceof ScrollBar) { - final ScrollBar bar = (ScrollBar) n; + if (n instanceof final ScrollBar bar) { if (bar.getOrientation().equals(orientation)) { return bar; } @@ -40,7 +39,7 @@ public class SmoothScroll { private static void smoothScrollingListView( Node n, double speed, Orientation orientation, Function sizeFunc) { - ((TableView) n).skinProperty().addListener((observable, oldValue, newValue) -> { + ((TableView) n).skinProperty().addListener((observable, oldValue, newValue) -> { if (newValue != null) { ScrollBar scrollBar = getScrollbarComponent(n, orientation); if (scrollBar == null) { @@ -48,8 +47,8 @@ public class SmoothScroll { } scrollBar.setUnitIncrement(1); final double[] frictions = { - 0.99, 0.1, 0.05, 0.04, 0.03, 0.02, 0.01, 0.04, 0.01, 0.008, 0.008, 0.008, 0.008, 0.0006, 0.0005, 0.00003, - 0.00001 + 0.99, 0.1, 0.05, 0.04, 0.03, 0.02, 0.01, 0.04, 0.01, 0.008, 0.008, 0.008, 0.008, 0.0006, 0.0005, + 0.00003, 0.00001 }; final double[] pushes = {speed}; final double[] derivatives = new double[frictions.length]; diff --git a/app/src/main/java/io/xpipe/app/util/TerminalHelper.java b/app/src/main/java/io/xpipe/app/util/TerminalHelper.java index 5f8fab94b..5570c106a 100644 --- a/app/src/main/java/io/xpipe/app/util/TerminalHelper.java +++ b/app/src/main/java/io/xpipe/app/util/TerminalHelper.java @@ -24,7 +24,10 @@ public class TerminalHelper { try { type.launch(title, command, false); } catch (Exception ex) { - throw new IOException("Unable to launch terminal " + type.toTranslatedString() + ": " + ex.getMessage() + ". Maybe try to use a different one in the settings.", ex); + throw new IOException( + "Unable to launch terminal " + type.toTranslatedString() + ": " + ex.getMessage() + + ". Maybe try to use a different one in the settings.", + ex); } } } diff --git a/app/src/main/java/io/xpipe/app/util/UnlockAlert.java b/app/src/main/java/io/xpipe/app/util/UnlockAlert.java index 5e9a4525d..e86b160bc 100644 --- a/app/src/main/java/io/xpipe/app/util/UnlockAlert.java +++ b/app/src/main/java/io/xpipe/app/util/UnlockAlert.java @@ -14,7 +14,8 @@ import javafx.scene.layout.VBox; public class UnlockAlert { public static void showIfNeeded() { - if (AppPrefs.get().getLockCrypt().getValue() == null || AppPrefs.get().getLockCrypt().getValue().isEmpty()) { + if (AppPrefs.get().getLockCrypt().getValue() == null + || AppPrefs.get().getLockCrypt().getValue().isEmpty()) { return; } @@ -34,8 +35,7 @@ public class UnlockAlert { alert.getDialogPane().setContent(content); }) .filter(b -> b.getButtonData().isDefaultButton()) - .ifPresentOrElse(t -> { - }, () -> canceled.set(true)); + .ifPresentOrElse(t -> {}, () -> canceled.set(true)); if (canceled.get()) { ErrorEvent.fromMessage("Unlock cancelled").term().omit().handle(); diff --git a/app/src/main/java/io/xpipe/app/util/Validator.java b/app/src/main/java/io/xpipe/app/util/Validator.java index b464d15ad..74ce4d41b 100644 --- a/app/src/main/java/io/xpipe/app/util/Validator.java +++ b/app/src/main/java/io/xpipe/app/util/Validator.java @@ -12,7 +12,8 @@ import org.apache.commons.lang3.function.FailableRunnable; public interface Validator { static Check nonNull(Validator v, ObservableValue name, ObservableValue s) { - return v.createCheck().dependsOn("val", s).withMethod(c -> { if (c.get("val") == null) { + return v.createCheck().dependsOn("val", s).withMethod(c -> { + if (c.get("val") == null) { c.error(AppI18n.get("app.mustNotBeEmpty", name.getValue())); } }); @@ -30,49 +31,49 @@ public interface Validator { }); } - public Check createCheck(); + Check createCheck(); /** * Add another check to the checker. Changes in the check's validationResultProperty will be reflected in the checker. * * @param check The check to add. */ - public void add(Check check); + void add(Check check); /** * Removes a check from this validator. * * @param check The check to remove from this validator. */ - public void remove(Check check); + void remove(Check check); /** * Retrieves current validation result * * @return validation result */ - public ValidationResult getValidationResult(); + ValidationResult getValidationResult(); /** * Can be used to track validation result changes * * @return The Validation result property. */ - public ReadOnlyObjectProperty validationResultProperty(); + ReadOnlyObjectProperty validationResultProperty(); /** * A read-only boolean property indicating whether any of the checks of this validator emitted an error. */ - public ReadOnlyBooleanProperty containsErrorsProperty(); + ReadOnlyBooleanProperty containsErrorsProperty(); - public boolean containsErrors(); + boolean containsErrors(); /** * Run all checks (decorating nodes if appropriate) * * @return true if no errors were found, false otherwise */ - public boolean validate(); + boolean validate(); /** * Create a string property that depends on the validation result. @@ -80,7 +81,7 @@ public interface Validator { * * @return */ - public StringBinding createStringBinding(); + StringBinding createStringBinding(); /** * Create a string property that depends on the validation result. @@ -89,5 +90,5 @@ public interface Validator { * @param separator The string to separate consecutive validation messages with * @return */ - public StringBinding createStringBinding(String prefix, String separator); + StringBinding createStringBinding(String prefix, String separator); } diff --git a/app/src/main/java/io/xpipe/app/util/XPipeSession.java b/app/src/main/java/io/xpipe/app/util/XPipeSession.java index d59771979..4ab9f4db0 100644 --- a/app/src/main/java/io/xpipe/app/util/XPipeSession.java +++ b/app/src/main/java/io/xpipe/app/util/XPipeSession.java @@ -47,7 +47,7 @@ public class XPipeSession { : UuidHelper.parse(() -> Files.readString(sessionFile)).orElse(UUID.randomUUID()); try { - //TODO: People might move their page file to another drive + // TODO: People might move their page file to another drive if (OsType.getLocal().equals(OsType.WINDOWS)) { var pf = Path.of("C:\\pagefile.sys"); BasicFileAttributes attr = Files.readAttributes(pf, BasicFileAttributes.class); @@ -70,7 +70,8 @@ public class XPipeSession { var isBuildChanged = !buildSessionId.toString().equals(s); AppCache.update("lastBuild", AppProperties.get().getVersion()); - INSTANCE = new XPipeSession(isNewSystemSession, isBuildChanged, UUID.randomUUID(), buildSessionId, systemSessionId); + INSTANCE = new XPipeSession( + isNewSystemSession, isBuildChanged, UUID.randomUUID(), buildSessionId, systemSessionId); } public static XPipeSession get() { diff --git a/app/src/main/java/module-info.java b/app/src/main/java/module-info.java index 69dd3b9ca..b350f7c98 100644 --- a/app/src/main/java/module-info.java +++ b/app/src/main/java/module-info.java @@ -7,7 +7,10 @@ import io.xpipe.app.ext.*; import io.xpipe.app.issue.EventHandler; import io.xpipe.app.issue.EventHandlerImpl; import io.xpipe.app.storage.DataStateProviderImpl; -import io.xpipe.app.util.*; +import io.xpipe.app.util.ProxyManagerProviderImpl; +import io.xpipe.app.util.TerminalHelper; +import io.xpipe.app.util.XPipeDaemon; +import io.xpipe.app.util.XPipeDaemonProvider; import io.xpipe.core.util.DataStateProvider; import io.xpipe.core.util.ModuleLayerLoader; import io.xpipe.core.util.ProxyFunction; @@ -113,7 +116,6 @@ open module io.xpipe.app { uses MessageExchangeImpl; uses TerminalHelper; uses io.xpipe.app.ext.ActionProvider; - uses DataSourceProvider; uses DataSourceTarget; uses EventHandler; diff --git a/beacon/src/main/java/io/xpipe/beacon/BeaconClient.java b/beacon/src/main/java/io/xpipe/beacon/BeaconClient.java index 21b91e221..8cdb1e98c 100644 --- a/beacon/src/main/java/io/xpipe/beacon/BeaconClient.java +++ b/beacon/src/main/java/io/xpipe/beacon/BeaconClient.java @@ -24,7 +24,6 @@ import lombok.extern.jackson.Jacksonized; import java.io.*; import java.net.InetAddress; import java.net.Socket; -import java.net.SocketException; import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.Optional; @@ -188,8 +187,6 @@ public class BeaconClient implements AutoCloseable { JsonNode node; try (InputStream blockIn = BeaconFormat.readBlocks(in)) { node = JacksonMapper.newMapper().readTree(blockIn); - } catch (SocketException ex) { - throw new ConnectorException("Connection to xpipe daemon closed unexpectedly", ex); } catch (IOException ex) { throw new ConnectorException("Couldn't read from socket", ex); } diff --git a/beacon/src/main/java/io/xpipe/beacon/BeaconFormat.java b/beacon/src/main/java/io/xpipe/beacon/BeaconFormat.java index ecca47589..1ca9f29f6 100644 --- a/beacon/src/main/java/io/xpipe/beacon/BeaconFormat.java +++ b/beacon/src/main/java/io/xpipe/beacon/BeaconFormat.java @@ -12,7 +12,7 @@ public class BeaconFormat { private static final int SEGMENT_SIZE = 65536; - public static OutputStream writeBlocks(OutputStream out) throws IOException { + public static OutputStream writeBlocks(OutputStream out) { return new OutputStream() { private final byte[] currentBytes = new byte[SEGMENT_SIZE]; private int index; @@ -64,7 +64,7 @@ public class BeaconFormat { }; } - public static InputStream readBlocks(InputStream in) throws IOException { + public static InputStream readBlocks(InputStream in) { return new InputStream() { private byte[] currentBytes; diff --git a/beacon/src/main/java/io/xpipe/beacon/BeaconProxyImpl.java b/beacon/src/main/java/io/xpipe/beacon/BeaconProxyImpl.java index 305582ea9..6b2198d50 100644 --- a/beacon/src/main/java/io/xpipe/beacon/BeaconProxyImpl.java +++ b/beacon/src/main/java/io/xpipe/beacon/BeaconProxyImpl.java @@ -20,7 +20,6 @@ import lombok.SneakyThrows; import java.io.FilterInputStream; import java.io.FilterOutputStream; -import java.io.IOException; import java.util.Optional; import java.util.function.Function; @@ -89,7 +88,7 @@ public class BeaconProxyImpl extends ProxyProvider { var inputStream = new FilterInputStream(finalClient.receiveBody()) { @Override @SneakyThrows - public void close() throws IOException { + public void close() { super.close(); finalClient.close(); } @@ -120,7 +119,7 @@ public class BeaconProxyImpl extends ProxyProvider { var outputStream = new FilterOutputStream(client.sendBody()) { @Override @SneakyThrows - public void close() throws IOException { + public void close() { super.close(); finalClient.receiveResponse(); finalClient.close(); diff --git a/beacon/src/main/java/io/xpipe/beacon/BeaconServer.java b/beacon/src/main/java/io/xpipe/beacon/BeaconServer.java index 24f40210e..e83b8c6fa 100644 --- a/beacon/src/main/java/io/xpipe/beacon/BeaconServer.java +++ b/beacon/src/main/java/io/xpipe/beacon/BeaconServer.java @@ -25,17 +25,16 @@ public class BeaconServer { } private static List toProcessCommand(String toExec) { - var command = OsType.getLocal().equals(OsType.WINDOWS) ? List.of("cmd", "/c", toExec) : List.of("sh", "-c", toExec); + var command = + OsType.getLocal().equals(OsType.WINDOWS) ? List.of("cmd", "/c", toExec) : List.of("sh", "-c", toExec); return command; } public static Process tryStartCustom() throws Exception { var custom = BeaconConfig.getCustomDaemonCommand(); if (custom != null) { - var toExec = custom - + (BeaconConfig.getDaemonArguments() != null - ? " " + BeaconConfig.getDaemonArguments() - : ""); + var toExec = + custom + (BeaconConfig.getDaemonArguments() != null ? " " + BeaconConfig.getDaemonArguments() : ""); var command = toProcessCommand(toExec); Process process = Runtime.getRuntime().exec(command.toArray(String[]::new)); printDaemonOutput(process, command); @@ -113,7 +112,7 @@ public class BeaconServer { return res.isSuccess(); } - public static String getDaemonDebugExecutable(String installationBase) throws Exception { + public static String getDaemonDebugExecutable(String installationBase) { var osType = OsType.getLocal(); var debug = BeaconConfig.launchDaemonInDebugMode(); if (!debug) { diff --git a/beacon/src/main/java/io/xpipe/beacon/exchange/AskpassExchange.java b/beacon/src/main/java/io/xpipe/beacon/exchange/AskpassExchange.java index 795b8e6df..bb15c824c 100644 --- a/beacon/src/main/java/io/xpipe/beacon/exchange/AskpassExchange.java +++ b/beacon/src/main/java/io/xpipe/beacon/exchange/AskpassExchange.java @@ -20,8 +20,10 @@ public class AskpassExchange implements MessageExchange { public static class Request implements RequestMessage { @NonNull String id; + @NonNull String request; + String prompt; } diff --git a/beacon/src/main/java/io/xpipe/beacon/exchange/LaunchExchange.java b/beacon/src/main/java/io/xpipe/beacon/exchange/LaunchExchange.java index f0f659032..aebe1a9eb 100644 --- a/beacon/src/main/java/io/xpipe/beacon/exchange/LaunchExchange.java +++ b/beacon/src/main/java/io/xpipe/beacon/exchange/LaunchExchange.java @@ -28,6 +28,7 @@ public class LaunchExchange implements MessageExchange { @Builder @Value public static class Response implements ResponseMessage { - @NonNull List command; + @NonNull + List command; } } diff --git a/core/src/main/java/io/xpipe/core/charsetter/Charsetter.java b/core/src/main/java/io/xpipe/core/charsetter/Charsetter.java index e44680e2e..eb5726f4c 100644 --- a/core/src/main/java/io/xpipe/core/charsetter/Charsetter.java +++ b/core/src/main/java/io/xpipe/core/charsetter/Charsetter.java @@ -69,7 +69,7 @@ public abstract class Charsetter { if (charset.hasByteOrderMark()) { var bom = stream.readNBytes(charset.getByteOrderMark().length); if (bom.length != 0 && !Arrays.equals(bom, charset.getByteOrderMark())) { - throw new IllegalStateException("Charset does not match: " + charset.toString()); + throw new IllegalStateException("Charset does not match: " + charset); } } diff --git a/core/src/main/java/io/xpipe/core/dialog/Dialog.java b/core/src/main/java/io/xpipe/core/dialog/Dialog.java index 43c94eb0c..847d2f428 100644 --- a/core/src/main/java/io/xpipe/core/dialog/Dialog.java +++ b/core/src/main/java/io/xpipe/core/dialog/Dialog.java @@ -86,7 +86,7 @@ public abstract class Dialog { .toList(); var index = Arrays.asList(vals).indexOf(def); if (def != null && index == -1) { - throw new IllegalArgumentException("Default value " + def.toString() + " is not in possible values"); + throw new IllegalArgumentException("Default value " + def + " is not in possible values"); } var c = choice(description, elements, required, quiet, index); @@ -164,7 +164,6 @@ public abstract class Dialog { if (currentElement == null) { DialogElement next = null; while (current < ds.length - 1 && (next = ds[++current].start()) == null) {} - ; return next; } @@ -213,13 +212,13 @@ public abstract class Dialog { final String[] msgEval = {null}; return new Dialog() { @Override - public DialogElement start() throws Exception { + public DialogElement start() { msgEval[0] = msg.get(); return new HeaderElement(msgEval[0]); } @Override - protected DialogElement next(String answer) throws Exception { + protected DialogElement next(String answer) { return null; } }.evaluateTo(() -> msgEval[0]); @@ -264,13 +263,13 @@ public abstract class Dialog { return new Dialog() { @Override - public DialogElement start() throws Exception { + public DialogElement start() { eval = null; return e; } @Override - protected DialogElement next(String answer) throws Exception { + protected DialogElement next(String answer) { if (e.apply(answer)) { return null; } @@ -365,7 +364,7 @@ public abstract class Dialog { } @Override - public DialogElement start() throws Exception { + public DialogElement start() { choiceMade = null; eval = null; return choice; @@ -458,7 +457,7 @@ public abstract class Dialog { protected abstract DialogElement next(String answer) throws Exception; - public static interface FailableSupplier { + public interface FailableSupplier { T get() throws Exception; } @@ -477,12 +476,12 @@ public abstract class Dialog { } @Override - public DialogElement start() throws Exception { + public DialogElement start() { return element; } @Override - protected DialogElement next(String answer) throws Exception { + protected DialogElement next(String answer) { if (element.apply(answer)) { return null; } @@ -511,12 +510,12 @@ public abstract class Dialog { } @Override - public DialogElement start() throws Exception { + public DialogElement start() { return element; } @Override - protected DialogElement next(String answer) throws Exception { + protected DialogElement next(String answer) { if (element.requiresExplicitUserInput() && (answer == null || answer.trim().length() == 0)) { return element; diff --git a/core/src/main/java/io/xpipe/core/dialog/DialogElement.java b/core/src/main/java/io/xpipe/core/dialog/DialogElement.java index 736025d10..5421e2d28 100644 --- a/core/src/main/java/io/xpipe/core/dialog/DialogElement.java +++ b/core/src/main/java/io/xpipe/core/dialog/DialogElement.java @@ -11,7 +11,7 @@ import java.util.UUID; @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") public abstract class DialogElement { - protected String id; + protected final String id; public DialogElement() { this.id = UUID.randomUUID().toString(); diff --git a/core/src/main/java/io/xpipe/core/dialog/HeaderElement.java b/core/src/main/java/io/xpipe/core/dialog/HeaderElement.java index 55acf5c6f..5a4f16d02 100644 --- a/core/src/main/java/io/xpipe/core/dialog/HeaderElement.java +++ b/core/src/main/java/io/xpipe/core/dialog/HeaderElement.java @@ -10,7 +10,7 @@ import lombok.ToString; @ToString public class HeaderElement extends DialogElement { - protected String header; + protected final String header; @JsonCreator public HeaderElement(String header) { diff --git a/core/src/main/java/io/xpipe/core/dialog/QueryConverter.java b/core/src/main/java/io/xpipe/core/dialog/QueryConverter.java index 727acd800..819dbc745 100644 --- a/core/src/main/java/io/xpipe/core/dialog/QueryConverter.java +++ b/core/src/main/java/io/xpipe/core/dialog/QueryConverter.java @@ -11,7 +11,7 @@ import java.util.Map; public abstract class QueryConverter { - public static final QueryConverter NEW_LINE = new QueryConverter() { + public static final QueryConverter NEW_LINE = new QueryConverter<>() { @Override protected NewLine fromString(String s) { return NewLine.byId(s); @@ -23,7 +23,7 @@ public abstract class QueryConverter { } }; - public static final QueryConverter CHARSET = new QueryConverter() { + public static final QueryConverter CHARSET = new QueryConverter<>() { @Override protected StreamCharset fromString(String s) { return StreamCharset.get(s); @@ -35,7 +35,7 @@ public abstract class QueryConverter { } }; - public static final QueryConverter STRING = new QueryConverter() { + public static final QueryConverter STRING = new QueryConverter<>() { @Override protected String fromString(String s) { return s; @@ -47,10 +47,10 @@ public abstract class QueryConverter { } }; - public static final QueryConverter SECRET = new QueryConverter() { + public static final QueryConverter SECRET = new QueryConverter<>() { @Override protected SecretValue fromString(String s) { - //TODO + // TODO return null; } @@ -60,29 +60,28 @@ public abstract class QueryConverter { } }; - public static final QueryConverter> HTTP_HEADER = - new QueryConverter>() { - @Override - protected Map.Entry fromString(String s) { - if (!s.contains(":")) { - throw new IllegalArgumentException("Missing colon"); - } + public static final QueryConverter> HTTP_HEADER = new QueryConverter<>() { + @Override + protected Map.Entry fromString(String s) { + if (!s.contains(":")) { + throw new IllegalArgumentException("Missing colon"); + } - var split = s.split(":"); - if (split.length != 2) { - throw new IllegalArgumentException("Too many colons"); - } + var split = s.split(":"); + if (split.length != 2) { + throw new IllegalArgumentException("Too many colons"); + } - return new AbstractMap.SimpleEntry<>(split[0].trim(), split[1].trim()); - } + return new AbstractMap.SimpleEntry<>(split[0].trim(), split[1].trim()); + } - @Override - protected String toString(Map.Entry value) { - return value.getKey() + ": " + value.getValue(); - } - }; + @Override + protected String toString(Map.Entry value) { + return value.getKey() + ": " + value.getValue(); + } + }; - public static final QueryConverter URI = new QueryConverter() { + public static final QueryConverter URI = new QueryConverter<>() { @Override protected URI fromString(String s) { try { @@ -98,7 +97,7 @@ public abstract class QueryConverter { } }; - public static final QueryConverter INTEGER = new QueryConverter() { + public static final QueryConverter INTEGER = new QueryConverter<>() { @Override protected Integer fromString(String s) { return Integer.parseInt(s); @@ -110,7 +109,7 @@ public abstract class QueryConverter { } }; - public static final QueryConverter CHARACTER = new QueryConverter() { + public static final QueryConverter CHARACTER = new QueryConverter<>() { @Override protected Character fromString(String s) { if (s.length() != 1) { @@ -126,7 +125,7 @@ public abstract class QueryConverter { } }; - public static final QueryConverter BOOLEAN = new QueryConverter() { + public static final QueryConverter BOOLEAN = new QueryConverter<>() { @Override protected Boolean fromString(String s) { if (s.equalsIgnoreCase("y") || s.equalsIgnoreCase("yes") || s.equalsIgnoreCase("true")) { diff --git a/core/src/main/java/io/xpipe/core/impl/FileNames.java b/core/src/main/java/io/xpipe/core/impl/FileNames.java index 751063186..d2a66cfa6 100644 --- a/core/src/main/java/io/xpipe/core/impl/FileNames.java +++ b/core/src/main/java/io/xpipe/core/impl/FileNames.java @@ -46,7 +46,7 @@ public class FileNames { if (split.length == 0) { return ""; } - var components = Arrays.stream(split).filter(s -> !s.isEmpty()).toList(); + var components = Arrays.stream(split).filter(s -> !s.isEmpty()).toList(); if (components.size() == 0) { return ""; } @@ -134,7 +134,7 @@ public class FileNames { } public static String relativize(String from, String to) { - return normalize(to).substring(normalize(from).length()); + return normalize(to).substring(normalize(from).length()); } public static String normalize(String file) { @@ -149,7 +149,7 @@ public class FileNames { public static String toUnix(String file) { var joined = String.join("/", split(file)); - var prefix = file.startsWith("/") ? "/" : ""; + var prefix = file.startsWith("/") ? "/" : ""; var suffix = file.endsWith("/") || file.endsWith("\\") ? "/" : ""; return prefix + joined + suffix; } diff --git a/core/src/main/java/io/xpipe/core/impl/InMemoryStore.java b/core/src/main/java/io/xpipe/core/impl/InMemoryStore.java index 48872983f..8284bb0b7 100644 --- a/core/src/main/java/io/xpipe/core/impl/InMemoryStore.java +++ b/core/src/main/java/io/xpipe/core/impl/InMemoryStore.java @@ -35,12 +35,12 @@ public class InMemoryStore extends JacksonizedValue implements StreamDataStore { } @Override - public InputStream openInput() throws Exception { + public InputStream openInput() { return value != null ? new ByteArrayInputStream(value) : InputStream.nullInputStream(); } @Override - public OutputStream openOutput() throws Exception { + public OutputStream openOutput() { return new ByteArrayOutputStream() { @Override public void close() throws IOException { diff --git a/core/src/main/java/io/xpipe/core/impl/InputStreamStore.java b/core/src/main/java/io/xpipe/core/impl/InputStreamStore.java index 223befa2a..c04cf6991 100644 --- a/core/src/main/java/io/xpipe/core/impl/InputStreamStore.java +++ b/core/src/main/java/io/xpipe/core/impl/InputStreamStore.java @@ -17,7 +17,7 @@ public class InputStreamStore implements StreamDataStore { } @Override - public InputStream openInput() throws Exception { + public InputStream openInput() { return in; } diff --git a/core/src/main/java/io/xpipe/core/impl/NamedStore.java b/core/src/main/java/io/xpipe/core/impl/NamedStore.java index b4d7d58a3..ff1e9dd2f 100644 --- a/core/src/main/java/io/xpipe/core/impl/NamedStore.java +++ b/core/src/main/java/io/xpipe/core/impl/NamedStore.java @@ -22,12 +22,12 @@ public final class NamedStore implements DataStore { private final String name; @Override - public void validate() throws Exception { + public void validate() { throw new UnsupportedOperationException(); } @Override - public boolean delete() throws Exception { + public boolean delete() { throw new UnsupportedOperationException(); } diff --git a/core/src/main/java/io/xpipe/core/impl/OutputStreamStore.java b/core/src/main/java/io/xpipe/core/impl/OutputStreamStore.java index 6353c518a..7a0f881ff 100644 --- a/core/src/main/java/io/xpipe/core/impl/OutputStreamStore.java +++ b/core/src/main/java/io/xpipe/core/impl/OutputStreamStore.java @@ -25,12 +25,12 @@ public class OutputStreamStore implements StreamDataStore { } @Override - public InputStream openInput() throws Exception { + public InputStream openInput() { throw new UnsupportedOperationException("No input available"); } @Override - public OutputStream openOutput() throws Exception { + public OutputStream openOutput() { return out; } diff --git a/core/src/main/java/io/xpipe/core/impl/SimpleTableWriteConnection.java b/core/src/main/java/io/xpipe/core/impl/SimpleTableWriteConnection.java index 0391ed44e..3f570ea61 100644 --- a/core/src/main/java/io/xpipe/core/impl/SimpleTableWriteConnection.java +++ b/core/src/main/java/io/xpipe/core/impl/SimpleTableWriteConnection.java @@ -9,13 +9,13 @@ import java.util.Optional; public interface SimpleTableWriteConnection> extends TableWriteConnection { - public T getSource(); + T getSource(); - public default Optional getType() throws Exception { + default Optional getType() throws Exception { return getSource().determineDataType(); } - public default Optional createMapping(TupleType inputType) throws Exception { + default Optional createMapping(TupleType inputType) throws Exception { var outputType = getType(); if (outputType.isEmpty() || outputType.get().getSize() == 0) { return Optional.of(TableMapping.createIdentity(inputType)); diff --git a/core/src/main/java/io/xpipe/core/impl/SinkDrainStore.java b/core/src/main/java/io/xpipe/core/impl/SinkDrainStore.java index 0fca4509d..4bfa2427e 100644 --- a/core/src/main/java/io/xpipe/core/impl/SinkDrainStore.java +++ b/core/src/main/java/io/xpipe/core/impl/SinkDrainStore.java @@ -80,12 +80,12 @@ public class SinkDrainStore extends JacksonizedValue implements KnownFormatStrea } @Override - public boolean canOpen() throws Exception { + public boolean canOpen() { return getState() == State.PRODUCER_CONNECTED; } @Override - public InputStream openInput() throws Exception { + public InputStream openInput() { checkState(false); if (getState() == State.PRODUCER_CONNECTED) { @@ -112,7 +112,7 @@ public class SinkDrainStore extends JacksonizedValue implements KnownFormatStrea } @Override - public OutputStream openOutput() throws Exception { + public OutputStream openOutput() { checkState(true); if (getState() == State.CONSUMER_CONNECTED) { @@ -157,7 +157,7 @@ public class SinkDrainStore extends JacksonizedValue implements KnownFormatStrea } } - public static enum State { + public enum State { NONE_CONNECTED, PRODUCER_CONNECTED, CONSUMER_CONNECTED, diff --git a/core/src/main/java/io/xpipe/core/impl/StdinDataStore.java b/core/src/main/java/io/xpipe/core/impl/StdinDataStore.java index 4f3d3f2f2..4f9b75c5f 100644 --- a/core/src/main/java/io/xpipe/core/impl/StdinDataStore.java +++ b/core/src/main/java/io/xpipe/core/impl/StdinDataStore.java @@ -7,7 +7,6 @@ import lombok.experimental.SuperBuilder; import lombok.extern.jackson.Jacksonized; import java.io.FilterInputStream; -import java.io.IOException; import java.io.InputStream; @JsonTypeName("stdin") @@ -21,12 +20,12 @@ public class StdinDataStore extends JacksonizedValue implements StreamDataStore } @Override - public InputStream openInput() throws Exception { + public InputStream openInput() { var in = System.in; // Prevent closing the standard in when the returned input stream is closed return new FilterInputStream(in) { @Override - public void close() throws IOException {} + public void close() {} }; } } diff --git a/core/src/main/java/io/xpipe/core/impl/StdoutDataStore.java b/core/src/main/java/io/xpipe/core/impl/StdoutDataStore.java index 799c98f78..3c3d62369 100644 --- a/core/src/main/java/io/xpipe/core/impl/StdoutDataStore.java +++ b/core/src/main/java/io/xpipe/core/impl/StdoutDataStore.java @@ -7,7 +7,6 @@ import lombok.experimental.SuperBuilder; import lombok.extern.jackson.Jacksonized; import java.io.FilterOutputStream; -import java.io.IOException; import java.io.OutputStream; @JsonTypeName("stdout") @@ -16,7 +15,7 @@ import java.io.OutputStream; public class StdoutDataStore extends JacksonizedValue implements StreamDataStore { @Override - public boolean canOpen() throws Exception { + public boolean canOpen() { return false; } @@ -26,11 +25,11 @@ public class StdoutDataStore extends JacksonizedValue implements StreamDataStore } @Override - public OutputStream openOutput() throws Exception { + public OutputStream openOutput() { // Create an output stream that will write to standard out but will not close it return new FilterOutputStream(System.out) { @Override - public void close() throws IOException {} + public void close() {} }; } } diff --git a/core/src/main/java/io/xpipe/core/impl/TextReadConnection.java b/core/src/main/java/io/xpipe/core/impl/TextReadConnection.java index e0b2a26fd..dbb402be4 100644 --- a/core/src/main/java/io/xpipe/core/impl/TextReadConnection.java +++ b/core/src/main/java/io/xpipe/core/impl/TextReadConnection.java @@ -18,7 +18,7 @@ public class TextReadConnection extends StreamReadConnection implements io.xpipe } @Override - public Stream lines() throws Exception { + public Stream lines() { return bufferedReader.lines(); } diff --git a/core/src/main/java/io/xpipe/core/process/CommandControl.java b/core/src/main/java/io/xpipe/core/process/CommandControl.java index ae578b5c2..0b62f1018 100644 --- a/core/src/main/java/io/xpipe/core/process/CommandControl.java +++ b/core/src/main/java/io/xpipe/core/process/CommandControl.java @@ -12,11 +12,11 @@ import java.util.function.Function; public interface CommandControl extends ProcessControl { - public static final int UNASSIGNED_EXIT_CODE = -1; - public static final int EXIT_TIMEOUT_EXIT_CODE = -2; - public static final int START_FAILED_EXIT_CODE = -3; + int UNASSIGNED_EXIT_CODE = -1; + int EXIT_TIMEOUT_EXIT_CODE = -2; + int START_FAILED_EXIT_CODE = -3; - static enum TerminalExitMode { + enum TerminalExitMode { KEEP_OPEN, CLOSE } @@ -25,10 +25,10 @@ public interface CommandControl extends ProcessControl { CommandControl terminalExitMode(TerminalExitMode mode); - public CommandControl doesNotObeyReturnValueConvention(); + CommandControl doesNotObeyReturnValueConvention(); @Override - public CommandControl sensitive(); + CommandControl sensitive(); CommandControl complex(); @@ -54,7 +54,7 @@ public interface CommandControl extends ProcessControl { OutputStream startExternalStdin() throws Exception; - public boolean waitFor(); + boolean waitFor(); CommandControl withCustomCharset(Charset charset); @@ -71,24 +71,25 @@ public interface CommandControl extends ProcessControl { CommandControl exitTimeout(Integer timeout); - public void withStdoutOrThrow(Charsetter.FailableConsumer c) throws Exception; + void withStdoutOrThrow(Charsetter.FailableConsumer c); + String readStdoutDiscardErr() throws Exception; - public void discardOrThrow() throws Exception; + void discardOrThrow() throws Exception; void accumulateStdout(Consumer con); void accumulateStderr(Consumer con); - public byte[] readRawBytesOrThrow() throws Exception; + byte[] readRawBytesOrThrow() throws Exception; - public String readStdoutOrThrow() throws Exception; + String readStdoutOrThrow() throws Exception; - public default boolean discardAndCheckExit() throws ProcessOutputException { + default boolean discardAndCheckExit() throws ProcessOutputException { try { discardOrThrow(); return true; - } catch (ProcessOutputException ex) { + } catch (ProcessOutputException ex) { if (ex.isTimeOut()) { throw ex; } diff --git a/core/src/main/java/io/xpipe/core/process/OsType.java b/core/src/main/java/io/xpipe/core/process/OsType.java index b9944ac37..365bb3881 100644 --- a/core/src/main/java/io/xpipe/core/process/OsType.java +++ b/core/src/main/java/io/xpipe/core/process/OsType.java @@ -13,7 +13,7 @@ public sealed interface OsType permits OsType.Windows, OsType.Linux, OsType.MacO Linux LINUX = new Linux(); MacOs MACOS = new MacOs(); - public static OsType getLocal() { + static OsType getLocal() { String osName = System.getProperty("os.name", "generic").toLowerCase(Locale.ENGLISH); if ((osName.contains("mac")) || (osName.contains("darwin"))) { return MACOS; @@ -48,7 +48,7 @@ public sealed interface OsType permits OsType.Windows, OsType.Linux, OsType.MacO String determineOperatingSystemName(ShellControl pc) throws Exception; - static final class Windows implements OsType { + final class Windows implements OsType { @Override public List determineInterestingPaths(ShellControl pc) throws Exception { @@ -90,7 +90,7 @@ public sealed interface OsType permits OsType.Windows, OsType.Linux, OsType.MacO } @Override - public String determineOperatingSystemName(ShellControl pc) throws Exception { + public String determineOperatingSystemName(ShellControl pc) { try { return pc.executeSimpleStringCommand("wmic os get Caption") .lines() @@ -110,7 +110,7 @@ public sealed interface OsType permits OsType.Windows, OsType.Linux, OsType.MacO } } - static final class Linux implements OsType { + final class Linux implements OsType { @Override public List determineInterestingPaths(ShellControl pc) throws Exception { @@ -130,7 +130,7 @@ public sealed interface OsType permits OsType.Windows, OsType.Linux, OsType.MacO } @Override - public String getTempDirectory(ShellControl pc) throws Exception { + public String getTempDirectory(ShellControl pc) { return "/tmp/"; } @@ -140,7 +140,7 @@ public sealed interface OsType permits OsType.Windows, OsType.Linux, OsType.MacO } @Override - public Map getProperties(ShellControl pc) throws Exception { + public Map getProperties(ShellControl pc) { return null; } @@ -180,7 +180,7 @@ public sealed interface OsType permits OsType.Windows, OsType.Linux, OsType.MacO } } - static final class MacOs implements OsType { + final class MacOs implements OsType { @Override public List determineInterestingPaths(ShellControl pc) throws Exception { @@ -193,8 +193,7 @@ public sealed interface OsType permits OsType.Windows, OsType.Linux, OsType.MacO "/Applications", "/Library", "/System", - "/etc" - ); + "/etc"); } @Override diff --git a/core/src/main/java/io/xpipe/core/process/PropertiesFormatsParser.java b/core/src/main/java/io/xpipe/core/process/PropertiesFormatsParser.java index a10c14139..5b83f8970 100644 --- a/core/src/main/java/io/xpipe/core/process/PropertiesFormatsParser.java +++ b/core/src/main/java/io/xpipe/core/process/PropertiesFormatsParser.java @@ -17,10 +17,10 @@ public class PropertiesFormatsParser { String line; String currentKey = null; - String currentValue = ""; + StringBuilder currentValue = new StringBuilder(); while ((line = reader.readLine()) != null) { - if (line.startsWith("\s") || line.startsWith("\t")) { - currentValue += line; + if (line.startsWith(" ") || line.startsWith("\t")) { + currentValue.append(line); continue; } @@ -35,15 +35,15 @@ public class PropertiesFormatsParser { } if (currentKey != null) { - map.put(currentKey, currentValue); + map.put(currentKey, currentValue.toString()); } currentKey = keyName; - currentValue = value; + currentValue = new StringBuilder(value); } if (currentKey != null) { - map.put(currentKey, currentValue); + map.put(currentKey, currentValue.toString()); } return map; diff --git a/core/src/main/java/io/xpipe/core/process/ShellControl.java b/core/src/main/java/io/xpipe/core/process/ShellControl.java index fd20f0bd9..2aeb47cb2 100644 --- a/core/src/main/java/io/xpipe/core/process/ShellControl.java +++ b/core/src/main/java/io/xpipe/core/process/ShellControl.java @@ -37,7 +37,7 @@ public interface ShellControl extends ProcessControl { String getSubTemporaryDirectory(); - public void checkRunning(); + void checkRunning(); default CommandControl osascriptCommand(String script) { return command(String.format( @@ -45,7 +45,8 @@ public interface ShellControl extends ProcessControl { osascript - "$@" < command) { - return command( - shellProcessControl -> ShellDialect.flatten(command)); + return command(shellProcessControl -> ShellDialect.flatten(command)); } void exitAndWait() throws IOException; diff --git a/core/src/main/java/io/xpipe/core/process/ShellDialect.java b/core/src/main/java/io/xpipe/core/process/ShellDialect.java index 25915734c..a4e075827 100644 --- a/core/src/main/java/io/xpipe/core/process/ShellDialect.java +++ b/core/src/main/java/io/xpipe/core/process/ShellDialect.java @@ -15,23 +15,23 @@ import java.util.stream.Stream; @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") public interface ShellDialect { - public static String flatten(List command) { + static String flatten(List command) { return command.stream() .map(s -> s.contains(" ") - && !(s.startsWith("\"") && s.endsWith("\"")) - && !(s.startsWith("'") && s.endsWith("'")) + && !(s.startsWith("\"") && s.endsWith("\"")) + && !(s.startsWith("'") && s.endsWith("'")) ? "\"" + s + "\"" : s) .collect(Collectors.joining(" ")); } - CommandControl prepareTempDirectory(ShellControl shellControl, String directory); + CommandControl prepareTempDirectory(ShellControl shellControl, String directory); String initFileName(ShellControl sc) throws Exception; - CommandControl directoryExists(ShellControl shellControl, String directory); + CommandControl directoryExists(ShellControl shellControl, String directory); - CommandControl normalizeDirectory(ShellControl shellControl, String directory); + CommandControl normalizeDirectory(ShellControl shellControl, String directory); String fileArgument(String s); @@ -53,15 +53,15 @@ public interface ShellDialect { CommandControl createStreamFileWriteCommand(ShellControl shellControl, String file); - default String getCdCommand(String directory){ + default String getCdCommand(String directory) { return "cd \"" + directory + "\""; } - default String getPushdCommand(String directory){ + default String getPushdCommand(String directory) { return "pushd \"" + directory + "\""; } - default String getPopdCommand(){ + default String getPopdCommand() { return "popd"; } @@ -113,7 +113,7 @@ public interface ShellDialect { String getOpenCommand(); - String prepareTerminalInitFileOpenCommand(ShellDialect parentDialect, ShellControl sc, String file) throws Exception; + String prepareTerminalInitFileOpenCommand(ShellDialect parentDialect, ShellControl sc, String file); String runScript(ShellControl parent, String file); @@ -149,7 +149,7 @@ public interface ShellDialect { String getWhichCommand(String executable); - Charset determineCharset(ShellControl control) throws Exception; + Charset determineCharset(ShellControl control); NewLine getNewLine(); diff --git a/core/src/main/java/io/xpipe/core/source/CollectionDataSource.java b/core/src/main/java/io/xpipe/core/source/CollectionDataSource.java index 3e2910fab..88e5e854f 100644 --- a/core/src/main/java/io/xpipe/core/source/CollectionDataSource.java +++ b/core/src/main/java/io/xpipe/core/source/CollectionDataSource.java @@ -11,7 +11,7 @@ public abstract class CollectionDataSource extends DataSou return DataSourceType.COLLECTION; } - public final CollectionReadConnection openReadConnection() throws Exception { + public final CollectionReadConnection openReadConnection() { if (!isComplete()) { throw new UnsupportedOperationException(); } @@ -19,7 +19,7 @@ public abstract class CollectionDataSource extends DataSou return newReadConnection(); } - public final CollectionWriteConnection openWriteConnection(WriteMode mode) throws Exception { + public final CollectionWriteConnection openWriteConnection(WriteMode mode) { var con = newWriteConnection(mode); if (con == null) { throw new UnsupportedOperationException(mode.getId()); @@ -30,5 +30,5 @@ public abstract class CollectionDataSource extends DataSou protected abstract CollectionWriteConnection newWriteConnection(WriteMode mode); - protected abstract CollectionReadConnection newReadConnection() throws Exception; + protected abstract CollectionReadConnection newReadConnection(); } diff --git a/core/src/main/java/io/xpipe/core/source/CollectionReadConnection.java b/core/src/main/java/io/xpipe/core/source/CollectionReadConnection.java index cde2e8baf..fb0c9059b 100644 --- a/core/src/main/java/io/xpipe/core/source/CollectionReadConnection.java +++ b/core/src/main/java/io/xpipe/core/source/CollectionReadConnection.java @@ -9,7 +9,7 @@ public interface CollectionReadConnection extends DataSourceReadConnection { Stream> listEntries() throws Exception; @SneakyThrows - default void forward(DataSourceConnection con) throws Exception { + default void forward(DataSourceConnection con) { try (var tCon = (CollectionWriteConnection) con) { tCon.init(); listEntries().forEach(s -> { diff --git a/core/src/main/java/io/xpipe/core/source/CollectionWriteConnection.java b/core/src/main/java/io/xpipe/core/source/CollectionWriteConnection.java index 2597f5c36..14d2bebd0 100644 --- a/core/src/main/java/io/xpipe/core/source/CollectionWriteConnection.java +++ b/core/src/main/java/io/xpipe/core/source/CollectionWriteConnection.java @@ -4,5 +4,5 @@ import java.io.InputStream; public interface CollectionWriteConnection extends DataSourceConnection { - void write(String entry, InputStream content) throws Exception; + void write(String entry, InputStream content); } diff --git a/core/src/main/java/io/xpipe/core/source/DataSourceReference.java b/core/src/main/java/io/xpipe/core/source/DataSourceReference.java index 74dcde308..3508e131a 100644 --- a/core/src/main/java/io/xpipe/core/source/DataSourceReference.java +++ b/core/src/main/java/io/xpipe/core/source/DataSourceReference.java @@ -89,7 +89,7 @@ public interface DataSourceReference { */ @Value @AllArgsConstructor - static class Id implements DataSourceReference { + class Id implements DataSourceReference { @NonNull DataSourceId value; @@ -143,7 +143,7 @@ public interface DataSourceReference { */ @Value @AllArgsConstructor - static class Name implements DataSourceReference { + class Name implements DataSourceReference { @NonNull String value; @@ -195,7 +195,7 @@ public interface DataSourceReference { * Data source referral this way is unstable however as adding or * removing data sources might change the referral behaviour and is therefore not recommended. */ - static class Latest implements DataSourceReference { + class Latest implements DataSourceReference { @Override public String toRefString() { diff --git a/core/src/main/java/io/xpipe/core/source/RawDataSource.java b/core/src/main/java/io/xpipe/core/source/RawDataSource.java index 6965e56f6..be8d9b4d2 100644 --- a/core/src/main/java/io/xpipe/core/source/RawDataSource.java +++ b/core/src/main/java/io/xpipe/core/source/RawDataSource.java @@ -14,7 +14,7 @@ public abstract class RawDataSource extends DataSource } @Override - public final RawReadConnection openReadConnection() throws Exception { + public final RawReadConnection openReadConnection() { if (!isComplete()) { throw new UnsupportedOperationException(); } @@ -23,7 +23,7 @@ public abstract class RawDataSource extends DataSource } @Override - public final RawWriteConnection openWriteConnection(WriteMode mode) throws Exception { + public final RawWriteConnection openWriteConnection(WriteMode mode) { var con = newWriteConnection(mode); if (con == null) { throw new UnsupportedOperationException(mode.getId()); diff --git a/core/src/main/java/io/xpipe/core/source/StructureDataSource.java b/core/src/main/java/io/xpipe/core/source/StructureDataSource.java index 222937645..de92ecdeb 100644 --- a/core/src/main/java/io/xpipe/core/source/StructureDataSource.java +++ b/core/src/main/java/io/xpipe/core/source/StructureDataSource.java @@ -24,7 +24,7 @@ public abstract class StructureDataSource extends DataSour return c; } - public final StructureReadConnection openReadConnection() throws Exception { + public final StructureReadConnection openReadConnection() { if (!isComplete()) { throw new UnsupportedOperationException(); } @@ -32,7 +32,7 @@ public abstract class StructureDataSource extends DataSour return newReadConnection(); } - public final StructureWriteConnection openWriteConnection(WriteMode mode) throws Exception { + public final StructureWriteConnection openWriteConnection(WriteMode mode) { var con = newWriteConnection(mode); if (con == null) { throw new UnsupportedOperationException(mode.getId()); diff --git a/core/src/main/java/io/xpipe/core/source/TableDataSource.java b/core/src/main/java/io/xpipe/core/source/TableDataSource.java index 3653a4dd3..0923703e5 100644 --- a/core/src/main/java/io/xpipe/core/source/TableDataSource.java +++ b/core/src/main/java/io/xpipe/core/source/TableDataSource.java @@ -45,7 +45,7 @@ public abstract class TableDataSource extends DataSource createMapping(TupleType inputType) throws Exception { + public final Optional createMapping(TupleType inputType) { return Optional.ofNullable(new CreateMappingFunction(this, inputType).callAndGet()); } diff --git a/core/src/main/java/io/xpipe/core/source/TableReadConnection.java b/core/src/main/java/io/xpipe/core/source/TableReadConnection.java index e2911b8e0..7212f1bb9 100644 --- a/core/src/main/java/io/xpipe/core/source/TableReadConnection.java +++ b/core/src/main/java/io/xpipe/core/source/TableReadConnection.java @@ -19,10 +19,10 @@ import java.util.concurrent.atomic.AtomicInteger; */ public interface TableReadConnection extends DataSourceReadConnection { - public static TableReadConnection empty() { + static TableReadConnection empty() { return new TableReadConnection() { @Override - public boolean canRead() throws Exception { + public boolean canRead() { return true; } @@ -32,15 +32,15 @@ public interface TableReadConnection extends DataSourceReadConnection { } @Override - public OptionalInt getRowCount() throws Exception { + public OptionalInt getRowCount() { return OptionalInt.empty(); } @Override - public void withRows(DataStructureNodeAcceptor lineAcceptor) throws Exception {} + public void withRows(DataStructureNodeAcceptor lineAcceptor) {} @Override - public ArrayNode readRows(int maxLines) throws Exception { + public ArrayNode readRows(int maxLines) { return ArrayNode.of(); } }; diff --git a/core/src/main/java/io/xpipe/core/source/TableWriteConnection.java b/core/src/main/java/io/xpipe/core/source/TableWriteConnection.java index ecec7735c..ebaa6cb71 100644 --- a/core/src/main/java/io/xpipe/core/source/TableWriteConnection.java +++ b/core/src/main/java/io/xpipe/core/source/TableWriteConnection.java @@ -11,10 +11,10 @@ import java.util.Optional; */ public interface TableWriteConnection extends DataSourceConnection { - public static TableWriteConnection empty() { + static TableWriteConnection empty() { return new TableWriteConnection() { @Override - public Optional createMapping(TupleType inputType) throws Exception { + public Optional createMapping(TupleType inputType) { return Optional.of(TableMapping.empty(inputType)); } diff --git a/core/src/main/java/io/xpipe/core/source/TextDataSource.java b/core/src/main/java/io/xpipe/core/source/TextDataSource.java index 4b5dbcd3b..754cf32d9 100644 --- a/core/src/main/java/io/xpipe/core/source/TextDataSource.java +++ b/core/src/main/java/io/xpipe/core/source/TextDataSource.java @@ -15,7 +15,7 @@ public abstract class TextDataSource extends DataSource extends DataSource - proc.getShellDialect().getFileReadCommand(file)) + return shellControl + .command(proc -> proc.getShellDialect().getFileReadCommand(file)) .startExternalStdout(); } @Override public OutputStream openOutput(String file) throws Exception { - return shellControl.getShellDialect() - .createStreamFileWriteCommand(shellControl, file) + return shellControl + .getShellDialect() + .createStreamFileWriteCommand(shellControl, file) .startExternalStdin(); } @Override public boolean fileExists(String file) throws Exception { - try (var pc = shellControl.getShellDialect() - .createFileExistsCommand(shellControl, file).complex() + try (var pc = shellControl + .getShellDialect() + .createFileExistsCommand(shellControl, file) + .complex() .start()) { return pc.discardAndCheckExit(); } @@ -86,8 +92,9 @@ public class ConnectionFileSystem implements FileSystem { @Override public void delete(String file) throws Exception { - try (var pc = shellControl.command(proc -> proc.getShellDialect() - .getFileDeleteCommand(file)).complex() + try (var pc = shellControl + .command(proc -> proc.getShellDialect().getFileDeleteCommand(file)) + .complex() .start()) { pc.discardOrThrow(); } @@ -95,8 +102,9 @@ public class ConnectionFileSystem implements FileSystem { @Override public void copy(String file, String newFile) throws Exception { - try (var pc = shellControl.command(proc -> proc.getShellDialect() - .getFileCopyCommand(file, newFile)).complex() + try (var pc = shellControl + .command(proc -> proc.getShellDialect().getFileCopyCommand(file, newFile)) + .complex() .start()) { pc.discardOrThrow(); } @@ -104,8 +112,9 @@ public class ConnectionFileSystem implements FileSystem { @Override public void move(String file, String newFile) throws Exception { - try (var pc = shellControl.command(proc -> proc.getShellDialect() - .getFileMoveCommand(file, newFile)).complex() + try (var pc = shellControl + .command(proc -> proc.getShellDialect().getFileMoveCommand(file, newFile)) + .complex() .start()) { pc.discardOrThrow(); } @@ -113,8 +122,9 @@ public class ConnectionFileSystem implements FileSystem { @Override public void mkdirs(String file) throws Exception { - try (var pc = shellControl.command(proc -> proc.getShellDialect() - .getMkdirsCommand(file)).complex() + try (var pc = shellControl + .command(proc -> proc.getShellDialect().getMkdirsCommand(file)) + .complex() .start()) { pc.discardOrThrow(); } @@ -122,8 +132,9 @@ public class ConnectionFileSystem implements FileSystem { @Override public void touch(String file) throws Exception { - try (var pc = shellControl.command(proc -> proc.getShellDialect() - .getFileTouchCommand(file)).complex() + try (var pc = shellControl + .command(proc -> proc.getShellDialect().getFileTouchCommand(file)) + .complex() .start()) { pc.discardOrThrow(); } diff --git a/core/src/main/java/io/xpipe/core/store/DataStore.java b/core/src/main/java/io/xpipe/core/store/DataStore.java index 450f36cdf..78384b554 100644 --- a/core/src/main/java/io/xpipe/core/store/DataStore.java +++ b/core/src/main/java/io/xpipe/core/store/DataStore.java @@ -79,7 +79,7 @@ public interface DataStore { default void checkComplete() throws Exception {} - default boolean delete() throws Exception { + default boolean delete() { return false; } diff --git a/core/src/main/java/io/xpipe/core/store/DelegateShellStore.java b/core/src/main/java/io/xpipe/core/store/DelegateShellStore.java index 555916b37..0520812c1 100644 --- a/core/src/main/java/io/xpipe/core/store/DelegateShellStore.java +++ b/core/src/main/java/io/xpipe/core/store/DelegateShellStore.java @@ -2,7 +2,7 @@ package io.xpipe.core.store; import io.xpipe.core.process.ShellControl; -public interface DelegateShellStore extends ShellStore { +public interface DelegateShellStore extends ShellStore { @Override default ShellControl createBasicControl() { diff --git a/core/src/main/java/io/xpipe/core/store/FileKind.java b/core/src/main/java/io/xpipe/core/store/FileKind.java index b71fc8d01..716d6478d 100644 --- a/core/src/main/java/io/xpipe/core/store/FileKind.java +++ b/core/src/main/java/io/xpipe/core/store/FileKind.java @@ -1,9 +1,8 @@ package io.xpipe.core.store; public enum FileKind { - FILE, DIRECTORY, LINK, - OTHER; + OTHER } diff --git a/core/src/main/java/io/xpipe/core/store/FileSystem.java b/core/src/main/java/io/xpipe/core/store/FileSystem.java index d204440b1..9e019e2ca 100644 --- a/core/src/main/java/io/xpipe/core/store/FileSystem.java +++ b/core/src/main/java/io/xpipe/core/store/FileSystem.java @@ -17,25 +17,31 @@ import java.util.stream.Stream; public interface FileSystem extends Closeable, AutoCloseable { @Value - static class FileEntry { + class FileEntry { @NonNull FileSystem fileSystem; + @NonNull String path; + Instant date; boolean hidden; Boolean executable; long size; String mode; + @NonNull FileKind kind; public FileEntry( - @NonNull FileSystem fileSystem, @NonNull String path, Instant date, boolean hidden, Boolean executable, + @NonNull FileSystem fileSystem, + @NonNull String path, + Instant date, + boolean hidden, + Boolean executable, long size, String mode, - @NonNull FileKind kind - ) { + @NonNull FileKind kind) { this.fileSystem = fileSystem; this.mode = mode; this.kind = kind; @@ -49,7 +55,6 @@ public interface FileSystem extends Closeable, AutoCloseable { public static FileEntry ofDirectory(FileSystem fileSystem, String path) { return new FileEntry(fileSystem, path, Instant.now(), true, false, 0, null, FileKind.DIRECTORY); } - } FileSystemStore getStore(); @@ -62,9 +67,9 @@ public interface FileSystem extends Closeable, AutoCloseable { OutputStream openOutput(String file) throws Exception; - public boolean fileExists(String file) throws Exception; + boolean fileExists(String file) throws Exception; - public void delete(String file) throws Exception; + void delete(String file) throws Exception; void copy(String file, String newFile) throws Exception; @@ -82,20 +87,22 @@ public interface FileSystem extends Closeable, AutoCloseable { default List listFilesRecursively(String file) throws Exception { var base = listFiles(file).toList(); - return base.stream().flatMap(fileEntry -> { - if (fileEntry.getKind() != FileKind.DIRECTORY) { - return Stream.of(fileEntry); - } + return base.stream() + .flatMap(fileEntry -> { + if (fileEntry.getKind() != FileKind.DIRECTORY) { + return Stream.of(fileEntry); + } - try { - var list = new ArrayList(); - list.add(fileEntry); - list.addAll(listFilesRecursively(fileEntry.getPath())); - return list.stream(); - } catch (Exception e) { - throw new RuntimeException(e); - } - }).toList(); + try { + var list = new ArrayList(); + list.add(fileEntry); + list.addAll(listFilesRecursively(fileEntry.getPath())); + return list.stream(); + } catch (Exception e) { + throw new RuntimeException(e); + } + }) + .toList(); } List listRoots() throws Exception; diff --git a/core/src/main/java/io/xpipe/core/store/LeafShellStore.java b/core/src/main/java/io/xpipe/core/store/LeafShellStore.java index f0c22bc62..5674907bd 100644 --- a/core/src/main/java/io/xpipe/core/store/LeafShellStore.java +++ b/core/src/main/java/io/xpipe/core/store/LeafShellStore.java @@ -1,5 +1,3 @@ package io.xpipe.core.store; -public interface LeafShellStore extends DataStore { - -} +public interface LeafShellStore extends DataStore {} diff --git a/core/src/main/java/io/xpipe/core/store/ShellStore.java b/core/src/main/java/io/xpipe/core/store/ShellStore.java index aa560a8ee..adb8cb554 100644 --- a/core/src/main/java/io/xpipe/core/store/ShellStore.java +++ b/core/src/main/java/io/xpipe/core/store/ShellStore.java @@ -2,14 +2,14 @@ package io.xpipe.core.store; import io.xpipe.core.impl.LocalStore; import io.xpipe.core.process.OsType; -import io.xpipe.core.process.ShellDialect; import io.xpipe.core.process.ShellControl; +import io.xpipe.core.process.ShellDialect; import java.nio.charset.Charset; public interface ShellStore extends DataStore, StatefulDataStore, LaunchableStore, FileSystemStore { - public static ShellStore createLocal() { + static ShellStore createLocal() { return new LocalStore(); } @@ -57,7 +57,7 @@ public interface ShellStore extends DataStore, StatefulDataStore, LaunchableStor ShellControl createBasicControl(); - public default ShellDialect determineType() throws Exception { + default ShellDialect determineType() throws Exception { try (var pc = control().start()) { return pc.getShellDialect(); } @@ -68,7 +68,7 @@ public interface ShellStore extends DataStore, StatefulDataStore, LaunchableStor try (ShellControl pc = control().start()) {} } - public default String queryMachineName() throws Exception { + default String queryMachineName() throws Exception { try (var pc = control().start()) { var operatingSystem = pc.getOsType(); return operatingSystem.determineOperatingSystemName(pc); diff --git a/core/src/main/java/io/xpipe/core/util/CoreJacksonModule.java b/core/src/main/java/io/xpipe/core/util/CoreJacksonModule.java index ba477bdaf..369100599 100644 --- a/core/src/main/java/io/xpipe/core/util/CoreJacksonModule.java +++ b/core/src/main/java/io/xpipe/core/util/CoreJacksonModule.java @@ -4,7 +4,6 @@ import com.fasterxml.jackson.annotation.JsonIdentityInfo; import com.fasterxml.jackson.annotation.ObjectIdGenerators; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.JsonDeserializer; import com.fasterxml.jackson.databind.JsonSerializer; @@ -87,10 +86,11 @@ public class CoreJacksonModule extends SimpleModule { } } + @SuppressWarnings("rawtypes") public static class NullDeserializer extends JsonDeserializer { @Override - public DataSource deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public DataSource deserialize(JsonParser p, DeserializationContext ctxt) { return null; } } @@ -186,9 +186,8 @@ public class CoreJacksonModule extends SimpleModule { @JsonSerialize(as = DataSourceReference.class) public abstract static class DataSourceReferenceTypeMixIn {} - public class NullSerializer extends JsonSerializer { - public void serialize(Object value, JsonGenerator jgen, SerializerProvider provider) - throws IOException, JsonProcessingException { + public static class NullSerializer extends JsonSerializer { + public void serialize(Object value, JsonGenerator jgen, SerializerProvider provider) throws IOException { jgen.writeNull(); } } diff --git a/core/src/main/java/io/xpipe/core/util/Deobfuscator.java b/core/src/main/java/io/xpipe/core/util/Deobfuscator.java index a3d7bdb44..0e327babb 100644 --- a/core/src/main/java/io/xpipe/core/util/Deobfuscator.java +++ b/core/src/main/java/io/xpipe/core/util/Deobfuscator.java @@ -92,7 +92,7 @@ public class Deobfuscator { System.err.println(s); } - private static boolean canDeobfuscate() throws Exception { + private static boolean canDeobfuscate() { if (!System.getenv().containsKey("XPIPE_MAPPING")) { return false; } diff --git a/core/src/main/java/io/xpipe/core/util/JacksonMapper.java b/core/src/main/java/io/xpipe/core/util/JacksonMapper.java index 732950fb6..deb065797 100644 --- a/core/src/main/java/io/xpipe/core/util/JacksonMapper.java +++ b/core/src/main/java/io/xpipe/core/util/JacksonMapper.java @@ -57,7 +57,7 @@ public class JacksonMapper { } private static List findModules(ModuleLayer layer) { - ArrayList modules = new ArrayList(); + ArrayList modules = new ArrayList<>(); ServiceLoader loader = layer != null ? ServiceLoader.load(layer, Module.class) : ServiceLoader.load(Module.class); for (Module module : loader) { @@ -81,7 +81,7 @@ public class JacksonMapper { if (!JacksonMapper.isInit()) { return BASE; } - + return INSTANCE; } diff --git a/core/src/main/java/io/xpipe/core/util/ModuleLayerLoader.java b/core/src/main/java/io/xpipe/core/util/ModuleLayerLoader.java index 8ff81ce4d..1be9e5e63 100644 --- a/core/src/main/java/io/xpipe/core/util/ModuleLayerLoader.java +++ b/core/src/main/java/io/xpipe/core/util/ModuleLayerLoader.java @@ -1,12 +1,12 @@ package io.xpipe.core.util; - import java.util.ServiceLoader; import java.util.function.Consumer; public interface ModuleLayerLoader { - public static void loadAll(ModuleLayer layer, boolean hasDaemon, boolean prioritization, Consumer errorHandler) { + static void loadAll( + ModuleLayer layer, boolean hasDaemon, boolean prioritization, Consumer errorHandler) { ServiceLoader.load(layer, ModuleLayerLoader.class).stream().forEach(moduleLayerLoaderProvider -> { var instance = moduleLayerLoaderProvider.get(); try { @@ -25,7 +25,7 @@ public interface ModuleLayerLoader { }); } - public void init(ModuleLayer layer); + void init(ModuleLayer layer); boolean requiresFullDaemon(); diff --git a/core/src/main/java/io/xpipe/core/util/ProxyFunction.java b/core/src/main/java/io/xpipe/core/util/ProxyFunction.java index 7d0589ade..1ad3684a1 100644 --- a/core/src/main/java/io/xpipe/core/util/ProxyFunction.java +++ b/core/src/main/java/io/xpipe/core/util/ProxyFunction.java @@ -1,6 +1,5 @@ package io.xpipe.core.util; -import com.fasterxml.jackson.core.JacksonException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.databind.DeserializationContext; @@ -67,8 +66,7 @@ public abstract class ProxyFunction { @Override @SneakyThrows - public ProxyFunction deserialize(JsonParser p, DeserializationContext ctxt) - throws IOException, JacksonException { + public ProxyFunction deserialize(JsonParser p, DeserializationContext ctxt) { var tree = (ObjectNode) JacksonMapper.getDefault().readTree(p); var moduleReference = tree.remove("module").asText(); var classReference = tree.remove("class").asText(); diff --git a/core/src/main/java/io/xpipe/core/util/SecretValue.java b/core/src/main/java/io/xpipe/core/util/SecretValue.java index b7e13e1bf..94c80fe2c 100644 --- a/core/src/main/java/io/xpipe/core/util/SecretValue.java +++ b/core/src/main/java/io/xpipe/core/util/SecretValue.java @@ -9,25 +9,25 @@ import java.util.function.Consumer; @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") public interface SecretValue { - public static String toBase64e(byte[] b) { + static String toBase64e(byte[] b) { var base64 = Base64.getEncoder().encodeToString(b); return base64.replace("/", "-"); } - public static byte[] fromBase64e(String s) { + static byte[] fromBase64e(String s) { var bytes = Base64.getDecoder().decode(s.replace("-", "/")); return bytes; } - public default void withSecretValue(Consumer con) { + default void withSecretValue(Consumer con) { var chars = getSecret(); con.accept(chars); Arrays.fill(chars, (char) 0); } - public abstract char[] getSecret(); + char[] getSecret(); - public default String getSecretValue() { + default String getSecretValue() { return new String(getSecret()); } } diff --git a/core/src/main/java/io/xpipe/core/util/XPipeExecTempDirectory.java b/core/src/main/java/io/xpipe/core/util/XPipeExecTempDirectory.java index 0b142b630..7139de647 100644 --- a/core/src/main/java/io/xpipe/core/util/XPipeExecTempDirectory.java +++ b/core/src/main/java/io/xpipe/core/util/XPipeExecTempDirectory.java @@ -44,12 +44,13 @@ public class XPipeExecTempDirectory { public static String getSubDirectory(ShellControl proc, String... sub) throws Exception { var base = proc.getOsType().getTempDirectory(proc); - var arr = Stream.concat(Stream.of(base, "xpipe", "exec"), Arrays.stream(sub)).toArray(String[]::new); + var arr = Stream.concat(Stream.of(base, "xpipe", "exec"), Arrays.stream(sub)) + .toArray(String[]::new); var dir = FileNames.join(arr); var existsCommand = proc.getShellDialect().createFileExistsCommand(proc, dir); if (!existsCommand.executeAndCheck()) { - proc.getShellDialect().prepareTempDirectory(proc,dir).execute(); + proc.getShellDialect().prepareTempDirectory(proc, dir).execute(); } return dir; diff --git a/core/src/main/java/io/xpipe/core/util/XPipeInstallation.java b/core/src/main/java/io/xpipe/core/util/XPipeInstallation.java index e0c47cc4d..56c317163 100644 --- a/core/src/main/java/io/xpipe/core/util/XPipeInstallation.java +++ b/core/src/main/java/io/xpipe/core/util/XPipeInstallation.java @@ -123,7 +123,7 @@ public class XPipeInstallation { } } - public static String getLocalInstallationBasePathForCLI(String cliExecutable) throws Exception { + public static String getLocalInstallationBasePathForCLI(String cliExecutable) { var defaultInstallation = getLocalDefaultInstallationBasePath(true); // Can be empty in development mode @@ -162,7 +162,7 @@ public class XPipeInstallation { } } - public static String getInstallationExecutable(ShellControl p, String installation) throws Exception { + public static String getInstallationExecutable(ShellControl p, String installation) { var executable = getDaemonExecutablePath(p.getOsType()); var file = FileNames.join(installation, executable); return file; @@ -206,7 +206,7 @@ public class XPipeInstallation { return customHome; } - String path = null; + String path; if (OsType.getLocal().equals(OsType.WINDOWS)) { var base = System.getenv("LOCALAPPDATA"); path = FileNames.join(base, "XPipe"); @@ -219,8 +219,7 @@ public class XPipeInstallation { return path; } - public static String getDefaultInstallationBasePath(ShellControl p, boolean acceptPortable) - throws Exception { + public static String getDefaultInstallationBasePath(ShellControl p, boolean acceptPortable) throws Exception { if (acceptPortable) { var customHome = p.executeSimpleStringCommand(p.getShellDialect().getPrintVariableCommand("XPIPE_HOME")); if (!customHome.isEmpty()) { @@ -228,7 +227,7 @@ public class XPipeInstallation { } } - String path = null; + String path; if (p.getOsType().equals(OsType.WINDOWS)) { var base = p.executeSimpleStringCommand(p.getShellDialect().getPrintVariableCommand("LOCALAPPDATA")); path = FileNames.join(base, "XPipe"); diff --git a/core/src/main/java/module-info.java b/core/src/main/java/module-info.java index c01be83ef..8a0e20b04 100644 --- a/core/src/main/java/module-info.java +++ b/core/src/main/java/module-info.java @@ -35,8 +35,8 @@ open module io.xpipe.core { uses ModuleLayerLoader; uses ShellDialect; - provides ModuleLayerLoader with ShellDialects.Loader; - + provides ModuleLayerLoader with + ShellDialects.Loader; provides WriteMode with WriteMode.Replace, WriteMode.Append, diff --git a/ext/base/src/main/java/io/xpipe/ext/base/BinarySourceProvider.java b/ext/base/src/main/java/io/xpipe/ext/base/BinarySourceProvider.java index d91c75aa7..d4f5ff216 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/BinarySourceProvider.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/BinarySourceProvider.java @@ -13,7 +13,7 @@ public class BinarySourceProvider implements UniformDataSourceProvider, SimpleFileDataSourceProvider { @Override - public BinarySource createDefaultSource(DataStore input) throws Exception { + public BinarySource createDefaultSource(DataStore input) { return BinarySource.builder().store(input.asNeeded()).build(); } diff --git a/ext/base/src/main/java/io/xpipe/ext/base/FileStoreProvider.java b/ext/base/src/main/java/io/xpipe/ext/base/FileStoreProvider.java index f1cb0a380..81e64d4c4 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/FileStoreProvider.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/FileStoreProvider.java @@ -24,13 +24,12 @@ public class FileStoreProvider implements DataStoreProvider { @Override public GuiDialog guiDialog(Property store) { var val = new SimpleValidator(); - var comp = new DsStreamStoreChoiceComp( - store, null, false, false, DsStreamStoreChoiceComp.Mode.WRITE); + var comp = new DsStreamStoreChoiceComp(store, null, false, false, DsStreamStoreChoiceComp.Mode.WRITE); return new GuiDialog(comp, val); } @Override - public String queryInformationString(DataStore store, int length) throws Exception { + public String queryInformationString(DataStore store, int length) { return getDisplayName(); } @@ -53,7 +52,7 @@ public class FileStoreProvider implements DataStoreProvider { } var rest = Math.max(0, length - 3); - return input.substring(0, rest / 2) + "..." + input.substring(input.length() - (rest / 2), input.length()); + return input.substring(0, rest / 2) + "..." + input.substring(input.length() - (rest / 2)); } @Override diff --git a/ext/base/src/main/java/io/xpipe/ext/base/HttpStore.java b/ext/base/src/main/java/io/xpipe/ext/base/HttpStore.java index 6ddd7865a..f41c52161 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/HttpStore.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/HttpStore.java @@ -89,7 +89,7 @@ public class HttpStore extends JacksonizedValue implements StreamDataStore, Stat } @Override - public boolean canOpen() throws Exception { + public boolean canOpen() { return flow == DataFlow.INPUT; } diff --git a/ext/base/src/main/java/io/xpipe/ext/base/HttpStoreProvider.java b/ext/base/src/main/java/io/xpipe/ext/base/HttpStoreProvider.java index 0a2cfebff..534dd1a80 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/HttpStoreProvider.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/HttpStoreProvider.java @@ -38,8 +38,8 @@ public class HttpStoreProvider implements DataStoreProvider { HttpStore st = (HttpStore) store.getValue(); Property methodProp = new SimpleObjectProperty<>(st != null ? st.getMethod() : null); - Property requestProp = new SimpleObjectProperty<>( - st != null && st.getUriString() != null ? st.getUriString().toString() : null); + Property requestProp = + new SimpleObjectProperty<>(st != null && st.getUriString() != null ? st.getUriString() : null); Property flowProperty = new SimpleObjectProperty<>(st.getFlow()); @@ -64,7 +64,7 @@ public class HttpStoreProvider implements DataStoreProvider { } @Override - public String queryInformationString(DataStore store, int length) throws Exception { + public String queryInformationString(DataStore store, int length) { return getDisplayName(); } diff --git a/ext/base/src/main/java/io/xpipe/ext/base/InMemoryStoreProvider.java b/ext/base/src/main/java/io/xpipe/ext/base/InMemoryStoreProvider.java index f28245940..b7cd5b764 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/InMemoryStoreProvider.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/InMemoryStoreProvider.java @@ -34,7 +34,7 @@ public class InMemoryStoreProvider implements DataStoreProvider { var q = new DynamicOptionsBuilder(AppI18n.observable("configuration")) .addCharset(charset) - .addStringArea((String) null, valProp, false) + .addStringArea(null, valProp, false) .bind( () -> { return new InMemoryStore( @@ -49,7 +49,7 @@ public class InMemoryStoreProvider implements DataStoreProvider { } @Override - public String queryInformationString(DataStore store, int length) throws Exception { + public String queryInformationString(DataStore store, int length) { return getDisplayName(); } diff --git a/ext/base/src/main/java/io/xpipe/ext/base/InternalStreamProvider.java b/ext/base/src/main/java/io/xpipe/ext/base/InternalStreamProvider.java index 18a2188de..b4ad6cd97 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/InternalStreamProvider.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/InternalStreamProvider.java @@ -21,7 +21,7 @@ public class InternalStreamProvider implements DataStoreProvider { } @Override - public String queryInformationString(DataStore store, int length) throws Exception { + public String queryInformationString(DataStore store, int length) { return getDisplayName(); } diff --git a/ext/base/src/main/java/io/xpipe/ext/base/SimpleCollectionSource.java b/ext/base/src/main/java/io/xpipe/ext/base/SimpleCollectionSource.java index a94060a05..fc94828cf 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/SimpleCollectionSource.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/SimpleCollectionSource.java @@ -9,18 +9,18 @@ import java.util.stream.Stream; @SuperBuilder public abstract class SimpleCollectionSource extends ReadOnlyCollectionSource { - protected abstract List> get() throws Exception; + protected abstract List> get(); @Override protected CollectionReadConnection newReadConnection() { return new CollectionReadConnection() { @Override - public Stream> listEntries() throws Exception { + public Stream> listEntries() { return get().stream(); } @Override - public boolean canRead() throws Exception { + public boolean canRead() { return true; } }; diff --git a/ext/base/src/main/java/io/xpipe/ext/base/SimpleFileDataSourceProvider.java b/ext/base/src/main/java/io/xpipe/ext/base/SimpleFileDataSourceProvider.java index 891551152..68e585a06 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/SimpleFileDataSourceProvider.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/SimpleFileDataSourceProvider.java @@ -68,7 +68,7 @@ public interface SimpleFileDataSourceProvider> extends D Map> getSupportedExtensions(); - public default List getSupportedMimeTypes() { + default List getSupportedMimeTypes() { return List.of(); } diff --git a/ext/base/src/main/java/io/xpipe/ext/base/SinkDrainStoreProvider.java b/ext/base/src/main/java/io/xpipe/ext/base/SinkDrainStoreProvider.java index 45859b794..094bfb430 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/SinkDrainStoreProvider.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/SinkDrainStoreProvider.java @@ -23,8 +23,8 @@ public class SinkDrainStoreProvider implements DataStoreProvider { var val = new SimpleValidator(); SinkDrainStore st = (SinkDrainStore) store.getValue(); - var charset = new SimpleObjectProperty(st.getCharset()); - var newLine = new SimpleObjectProperty(st.getNewLine()); + var charset = new SimpleObjectProperty<>(st.getCharset()); + var newLine = new SimpleObjectProperty<>(st.getNewLine()); var q = new DynamicOptionsBuilder(AppI18n.observable("configuration")) .addCharset(charset) @@ -47,7 +47,7 @@ public class SinkDrainStoreProvider implements DataStoreProvider { } @Override - public String queryInformationString(DataStore store, int length) throws Exception { + public String queryInformationString(DataStore store, int length) { return null; } diff --git a/ext/base/src/main/java/io/xpipe/ext/base/TextSourceProvider.java b/ext/base/src/main/java/io/xpipe/ext/base/TextSourceProvider.java index a7a14054b..4420a1e07 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/TextSourceProvider.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/TextSourceProvider.java @@ -3,8 +3,6 @@ package io.xpipe.ext.base; import io.xpipe.app.util.DialogHelper; import io.xpipe.app.util.DynamicOptionsBuilder; import io.xpipe.core.charsetter.Charsetter; -import io.xpipe.core.charsetter.NewLine; -import io.xpipe.core.charsetter.StreamCharset; import io.xpipe.core.dialog.Dialog; import io.xpipe.core.impl.TextSource; import io.xpipe.core.source.DataSourceType; @@ -35,8 +33,8 @@ public class TextSourceProvider implements SimpleFileDataSourceProvider source, boolean preferQuiet) { - var charset = new SimpleObjectProperty(source.getValue().getCharset()); - var newLine = new SimpleObjectProperty(source.getValue().getNewLine()); + var charset = new SimpleObjectProperty<>(source.getValue().getCharset()); + var newLine = new SimpleObjectProperty<>(source.getValue().getNewLine()); return new DynamicOptionsBuilder() .addCharset(charset) .addNewLine(newLine) diff --git a/ext/base/src/main/java/io/xpipe/ext/base/XpbsProvider.java b/ext/base/src/main/java/io/xpipe/ext/base/XpbsProvider.java index ba8025a6e..85cc84d50 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/XpbsProvider.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/XpbsProvider.java @@ -11,7 +11,7 @@ import java.util.Map; public class XpbsProvider implements SimpleFileDataSourceProvider, UniformDataSourceProvider { @Override - public XpbsSource createDefaultSource(DataStore input) throws Exception { + public XpbsSource createDefaultSource(DataStore input) { return XpbsSource.builder().store(input.asNeeded()).build(); } diff --git a/ext/base/src/main/java/io/xpipe/ext/base/XpbtProvider.java b/ext/base/src/main/java/io/xpipe/ext/base/XpbtProvider.java index 099fd7bfa..c6d7a6d28 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/XpbtProvider.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/XpbtProvider.java @@ -16,7 +16,7 @@ public class XpbtProvider implements SimpleFileDataSourceProvider, U } @Override - public XpbtSource createDefaultSource(DataStore input) throws Exception { + public XpbtSource createDefaultSource(DataStore input) { return XpbtSource.builder().store(input.asNeeded()).build(); } diff --git a/ext/base/src/main/java/io/xpipe/ext/base/actions/AddStoreAction.java b/ext/base/src/main/java/io/xpipe/ext/base/actions/AddStoreAction.java index 4a6533e6a..d2d86882d 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/actions/AddStoreAction.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/actions/AddStoreAction.java @@ -23,7 +23,7 @@ public class AddStoreAction implements ActionProvider { } @Override - public void execute() throws Exception { + public void execute() { if (store == null) { return; } @@ -43,7 +43,8 @@ public class AddStoreAction implements ActionProvider { @Override public Action createAction(List args) throws Exception { - var storeString = DefaultSecretValue.builder().encryptedValue(args.get(0)).build(); + var storeString = + DefaultSecretValue.builder().encryptedValue(args.get(0)).build(); var store = JacksonMapper.parse(storeString.getSecretValue(), DataStore.class); return new Action(store); } diff --git a/ext/base/src/main/java/io/xpipe/ext/base/actions/DeleteStoreChildrenAction.java b/ext/base/src/main/java/io/xpipe/ext/base/actions/DeleteStoreChildrenAction.java index 649c38541..203a553d6 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/actions/DeleteStoreChildrenAction.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/actions/DeleteStoreChildrenAction.java @@ -21,14 +21,14 @@ public class DeleteStoreChildrenAction implements ActionProvider { } @Override - public void execute() throws Exception { + public void execute() { DataStorage.get().deleteChildren(store, true); } } @Override public DataStoreCallSite getDataStoreCallSite() { - return new DataStoreCallSite() { + return new DataStoreCallSite<>() { @Override public boolean isMajor() { @@ -46,8 +46,11 @@ public class DeleteStoreChildrenAction implements ActionProvider { } @Override - public boolean isApplicable(DataStore o) throws Exception { - return DataStorage.get().getStoreChildren(DataStorage.get().getStoreEntry(o),true).size() > 1; + public boolean isApplicable(DataStore o) { + return DataStorage.get() + .getStoreChildren(DataStorage.get().getStoreEntry(o), true) + .size() + > 1; } @Override diff --git a/ext/base/src/main/java/io/xpipe/ext/base/actions/EditStoreAction.java b/ext/base/src/main/java/io/xpipe/ext/base/actions/EditStoreAction.java index cdbf6ea82..aa5c7c29b 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/actions/EditStoreAction.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/actions/EditStoreAction.java @@ -22,23 +22,27 @@ public class EditStoreAction implements ActionProvider { } @Override - public void execute() throws Exception { + public void execute() { GuiDsStoreCreator.showEdit(store); } } - @Override public DefaultDataStoreCallSite getDefaultDataStoreCallSite() { - return new DefaultDataStoreCallSite() { + return new DefaultDataStoreCallSite<>() { @Override public boolean isApplicable(DataStore o) { - return DataStorage.get().getStoreEntryIfPresent(o).orElseThrow().getState().equals(DataStoreEntry.State.INCOMPLETE); + return DataStorage.get() + .getStoreEntryIfPresent(o) + .orElseThrow() + .getState() + .equals(DataStoreEntry.State.INCOMPLETE); } @Override public ActionProvider.Action createAction(DataStore store) { - return new Action(DataStorage.get().getStoreEntryIfPresent(store).orElseThrow()); + return new Action( + DataStorage.get().getStoreEntryIfPresent(store).orElseThrow()); } @Override @@ -50,7 +54,7 @@ public class EditStoreAction implements ActionProvider { @Override public DataStoreCallSite getDataStoreCallSite() { - return new DataStoreCallSite() { + return new DataStoreCallSite<>() { @Override public boolean isMajor() { @@ -73,7 +77,7 @@ public class EditStoreAction implements ActionProvider { } @Override - public boolean isApplicable(DataStore o) throws Exception { + public boolean isApplicable(DataStore o) { return DataStorage.get().getStoreEntry(o).getConfiguration().isEditable(); } diff --git a/ext/base/src/main/java/io/xpipe/ext/base/actions/FileBrowseAction.java b/ext/base/src/main/java/io/xpipe/ext/base/actions/FileBrowseAction.java index 678d718be..628154748 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/actions/FileBrowseAction.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/actions/FileBrowseAction.java @@ -24,7 +24,7 @@ public class FileBrowseAction implements ActionProvider { } @Override - public void execute() throws Exception { + public void execute() { DesktopHelper.browseFileInDirectory(Path.of(store.getPath())); } } @@ -44,7 +44,7 @@ public class FileBrowseAction implements ActionProvider { } @Override - public boolean isApplicable(FileStore o) throws Exception { + public boolean isApplicable(FileStore o) { return o.getFileSystem().equals(new LocalStore()) && Files.exists(Path.of(o.getPath())); } diff --git a/ext/base/src/main/java/io/xpipe/ext/base/actions/FileEditAction.java b/ext/base/src/main/java/io/xpipe/ext/base/actions/FileEditAction.java index 7c4db1417..0c0902966 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/actions/FileEditAction.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/actions/FileEditAction.java @@ -22,7 +22,7 @@ public class FileEditAction implements ActionProvider { } @Override - public void execute() throws Exception { + public void execute() { if (store.getFileSystem().equals(new LocalStore())) { FileOpener.openInTextEditor(store.getPath()); } @@ -44,7 +44,7 @@ public class FileEditAction implements ActionProvider { } @Override - public boolean isApplicable(FileStore o) throws Exception { + public boolean isApplicable(FileStore o) { return o.getFlow().equals(DataFlow.INPUT_OUTPUT); } diff --git a/ext/base/src/main/java/io/xpipe/ext/base/actions/SampleAction.java b/ext/base/src/main/java/io/xpipe/ext/base/actions/SampleAction.java index f86693644..e3d311864 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/actions/SampleAction.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/actions/SampleAction.java @@ -42,8 +42,10 @@ public class SampleAction implements ActionProvider { System.out.println(sc.getOsType()); // Simple commands can be executed in one line - // The shell dialects also provide the appropriate commands for common operations like echo for all supported shells - String echoOut = sc.executeSimpleStringCommand(sc.getShellDialect().getEchoCommand("hello!", false)); + // The shell dialects also provide the appropriate commands for common operations like echo for all + // supported shells + String echoOut = + sc.executeSimpleStringCommand(sc.getShellDialect().getEchoCommand("hello!", false)); // You can also implement custom handling for more complex commands try (CommandControl cc = sc.command("ls").start()) { @@ -52,7 +54,8 @@ public class SampleAction implements ActionProvider { // Read the stdout lines as a stream BufferedReader reader = new BufferedReader(new InputStreamReader(cc.getStdout(), cc.getCharset())); - // We don't have to close this stream here, that will be automatically done by the command control after the try-with block + // We don't have to close this stream here, that will be automatically done by the command control + // after the try-with block reader.lines().filter(s -> !s.isBlank()).forEach(s -> { System.out.println(s); }); @@ -66,12 +69,13 @@ public class SampleAction implements ActionProvider { // Commands can also be more complex and span multiple lines. // In this case, XPipe will internally write a command to a script file and then execute the script try (CommandControl cc = sc.command( - """ + """ VAR="value" echo "$VAR" - """ - ).start()) { - // Reads stdout, stashes stderr. If the exit code is not 0, it will throw an exception with the stderr contents. + """) + .start()) { + // Reads stdout, stashes stderr. If the exit code is not 0, it will throw an exception with the + // stderr contents. var output = cc.readStdoutOrThrow(); } @@ -80,7 +84,10 @@ public class SampleAction implements ActionProvider { // sudo and the optional sudo password automatically provided by XPipe // by using the information from the connection store. // You can also set a custom working directory. - try (CommandControl cc = sc.command("kill ").elevated("kill").withWorkingDirectory("/").start()) { + try (CommandControl cc = sc.command("kill ") + .elevated("kill") + .withWorkingDirectory("/") + .start()) { // Discard any output but throw an exception with the stderr contents if the exit code is not 0 cc.discardOrThrow(); } @@ -117,7 +124,7 @@ public class SampleAction implements ActionProvider { } @Override - public boolean isApplicable(ShellStore o) throws Exception { + public boolean isApplicable(ShellStore o) { // Allows you to individually check whether this action should be available for the specific store. // In this case it should only be available for remote shell connections, not local ones. return !ShellStore.isLocal(o); diff --git a/ext/base/src/main/java/io/xpipe/ext/base/actions/ShareStoreAction.java b/ext/base/src/main/java/io/xpipe/ext/base/actions/ShareStoreAction.java index a3eecb901..2d63833b0 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/actions/ShareStoreAction.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/actions/ShareStoreAction.java @@ -26,11 +26,12 @@ public class ShareStoreAction implements ActionProvider { } public static String create(DataStore store) { - return "xpipe://addStore/" + SecretHelper.encryptInPlace(store.toString()).getEncryptedValue(); + return "xpipe://addStore/" + + SecretHelper.encryptInPlace(store.toString()).getEncryptedValue(); } @Override - public void execute() throws Exception { + public void execute() { var string = create(store); var selection = new StringSelection(string); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); @@ -41,7 +42,7 @@ public class ShareStoreAction implements ActionProvider { @Override public DataStoreCallSite getDataStoreCallSite() { - return new DataStoreCallSite() { + return new DataStoreCallSite<>() { @Override public ActionProvider.Action createAction(DataStore store) { @@ -54,7 +55,7 @@ public class ShareStoreAction implements ActionProvider { } @Override - public boolean isApplicable(DataStore o) throws Exception { + public boolean isApplicable(DataStore o) { return DataStoreProviders.byStore(o).isShareable(); } diff --git a/ext/base/src/main/java/io/xpipe/ext/base/actions/StreamExportAction.java b/ext/base/src/main/java/io/xpipe/ext/base/actions/StreamExportAction.java index 903d0a30b..a74d78832 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/actions/StreamExportAction.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/actions/StreamExportAction.java @@ -27,7 +27,7 @@ public class StreamExportAction implements ActionProvider { } @Override - public void execute() throws Exception { + public void execute() { var outputFile = new SimpleObjectProperty(); StandaloneFileBrowser.saveSingleFile(outputFile); if (outputFile.get() == null) { @@ -56,7 +56,7 @@ public class StreamExportAction implements ActionProvider { } @Override - public boolean isApplicable(StreamDataStore o) throws Exception { + public boolean isApplicable(StreamDataStore o) { return o.getFlow() != null && o.getFlow().hasInput(); } diff --git a/ext/base/src/main/java/io/xpipe/ext/base/apps/DataSourceOutputTarget.java b/ext/base/src/main/java/io/xpipe/ext/base/apps/DataSourceOutputTarget.java index 709f5b33f..70441cc34 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/apps/DataSourceOutputTarget.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/apps/DataSourceOutputTarget.java @@ -35,13 +35,11 @@ public class DataSourceOutputTarget implements DataSourceTarget { var sourceType = DataSourceProviders.byDataSourceClass(source.getClass()).getPrimaryType(); var chooser = new NamedSourceChoiceComp( - new SimpleObjectProperty<>(s -> s != source - && s.getFlow().hasOutput() - && DataSourceProviders.byDataSourceClass(s.getClass()) - .getPrimaryType() - == sourceType), - target, - DataSourceProvider.Category.STREAM); + new SimpleObjectProperty<>(s -> s != source + && s.getFlow().hasOutput() + && DataSourceProviders.byDataSourceClass(s.getClass()).getPrimaryType() == sourceType), + target, + DataSourceProvider.Category.STREAM); chooser.apply(struc -> VBox.setVgrow(struc.get(), Priority.ALWAYS)); var mode = new SimpleObjectProperty(); diff --git a/ext/base/src/main/java/io/xpipe/ext/base/apps/FileOutputTarget.java b/ext/base/src/main/java/io/xpipe/ext/base/apps/FileOutputTarget.java index a4d2bbac3..e1f17592a 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/apps/FileOutputTarget.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/apps/FileOutputTarget.java @@ -68,7 +68,8 @@ public class FileOutputTarget implements DataSourceTarget { }); var layout = new BorderPane(); - var providerChoice = new DsProviderChoiceComp(DataSourceProvider.Category.STREAM, provider, sourceProvider.getPrimaryType()); + var providerChoice = + new DsProviderChoiceComp(DataSourceProvider.Category.STREAM, provider, sourceProvider.getPrimaryType()); providerChoice.apply(GrowAugment.create(true, false)); var providerChoiceRegion = providerChoice.createRegion(); var top = new VBox(providerChoiceRegion, new Separator()); @@ -108,22 +109,19 @@ public class FileOutputTarget implements DataSourceTarget { List.of(providerChoice.getValidator(), chooser.getValidator(), modeComp.getValidator())); return new InstructionsDisplay( layout, - new Runnable() { - @Override - public void run() { - try { - AppCache.update( - "lastStreamOutputProvider", provider.get().getId()); - try (var connection = targetSource.getValue().openWriteConnection(mode.get())) { - connection.init(); - try (var readConnection = source.openReadConnection()) { - readConnection.init(); - readConnection.forward(connection); - } + () -> { + try { + AppCache.update( + "lastStreamOutputProvider", provider.get().getId()); + try (var connection = targetSource.getValue().openWriteConnection(mode.get())) { + connection.init(); + try (var readConnection = source.openReadConnection()) { + readConnection.init(); + readConnection.forward(connection); } - } catch (Exception e) { - throw new RuntimeException(e); } + } catch (Exception e) { + throw new RuntimeException(e); } }, validator); diff --git a/ext/base/src/main/java/io/xpipe/ext/base/apps/RawFileOutputTarget.java b/ext/base/src/main/java/io/xpipe/ext/base/apps/RawFileOutputTarget.java index ba187343e..ba246f26e 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/apps/RawFileOutputTarget.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/apps/RawFileOutputTarget.java @@ -26,10 +26,10 @@ public class RawFileOutputTarget implements DataSourceTarget { var target = new SimpleObjectProperty(); var storeChoice = new NamedStoreChoiceComp( - new SimpleObjectProperty<>(store -> store instanceof StreamDataStore - && (store.getFlow().hasOutput())), - target, - DataStoreProvider.DataCategory.STREAM); + new SimpleObjectProperty<>(store -> + store instanceof StreamDataStore && (store.getFlow().hasOutput())), + target, + DataStoreProvider.DataCategory.STREAM); storeChoice .apply(GrowAugment.create(true, true)) .apply(struc -> GridPane.setVgrow(struc.get(), Priority.ALWAYS)); @@ -40,19 +40,16 @@ public class RawFileOutputTarget implements DataSourceTarget { return new InstructionsDisplay( layout, - new Runnable() { - @Override - public void run() { - try { - StreamDataStore inputStore = (StreamDataStore) source.getStore(); - try (var in = inputStore.openInput()) { - try (var out = target.get().openOutput()) { - in.transferTo(out); - } + () -> { + try { + StreamDataStore inputStore = (StreamDataStore) source.getStore(); + try (var in = inputStore.openInput()) { + try (var out = target.get().openOutput()) { + in.transferTo(out); } - } catch (Exception e) { - throw new RuntimeException(e); } + } catch (Exception e) { + throw new RuntimeException(e); } }, storeChoice.getValidator()); diff --git a/ext/base/src/main/java/io/xpipe/ext/base/apps/SaveSourceTarget.java b/ext/base/src/main/java/io/xpipe/ext/base/apps/SaveSourceTarget.java index f28d461b3..8ead39352 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/apps/SaveSourceTarget.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/apps/SaveSourceTarget.java @@ -53,14 +53,11 @@ public class SaveSourceTarget implements DataSourceTarget { var validator = new SimpleValidator(); return new InstructionsDisplay( storeSettings.createRegion(), - new Runnable() { - @Override - public void run() { - var e = dataSourceEntry.getValue(); - var c = storageGroup.getValue(); - if (!c.getEntries().contains(e)) { - DataStorage.get().add(e, c); - } + () -> { + var e = dataSourceEntry.getValue(); + var c = storageGroup.getValue(); + if (!c.getEntries().contains(e)) { + DataStorage.get().add(e, c); } }, validator); diff --git a/ext/base/src/main/java/io/xpipe/ext/base/browser/BrowseInNativeManagerAction.java b/ext/base/src/main/java/io/xpipe/ext/base/browser/BrowseInNativeManagerAction.java index 8c5f5dbed..1dca415a1 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/browser/BrowseInNativeManagerAction.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/browser/BrowseInNativeManagerAction.java @@ -27,15 +27,20 @@ public class BrowseInNativeManagerAction implements LeafAction { } } case OsType.Linux linux -> { - var action = entry.getRawFileEntry().getKind() == FileKind.DIRECTORY ? "org.freedesktop.FileManager1.ShowFolders" : "org.freedesktop.FileManager1.ShowItems"; - var dbus = String.format(""" + var action = entry.getRawFileEntry().getKind() == FileKind.DIRECTORY + ? "org.freedesktop.FileManager1.ShowFolders" + : "org.freedesktop.FileManager1.ShowItems"; + var dbus = String.format( + """ dbus-send --session --print-reply --dest=org.freedesktop.FileManager1 --type=method_call /org/freedesktop/FileManager1 %s array:string:"file://%s" string:"" - """, action, entry.getRawFileEntry().getPath()); + """, + action, entry.getRawFileEntry().getPath()); sc.executeSimpleCommand(dbus); } case OsType.MacOs macOs -> { - sc.executeSimpleCommand("open " + (entry.getRawFileEntry().getKind() == FileKind.DIRECTORY ? "" : "-R ") - + d.fileArgument(entry.getRawFileEntry().getPath())); + sc.executeSimpleCommand( + "open " + (entry.getRawFileEntry().getKind() == FileKind.DIRECTORY ? "" : "-R ") + + d.fileArgument(entry.getRawFileEntry().getPath())); } } } diff --git a/ext/base/src/main/java/io/xpipe/ext/base/browser/CopyAction.java b/ext/base/src/main/java/io/xpipe/ext/base/browser/CopyAction.java index 382446d25..830bd46ba 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/browser/CopyAction.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/browser/CopyAction.java @@ -15,9 +15,10 @@ import java.util.List; public class CopyAction implements LeafAction { @Override - public void execute(OpenFileSystemModel model, List entries) throws Exception { + public void execute(OpenFileSystemModel model, List entries) { BrowserClipboard.startCopy( - model.getCurrentDirectory(), entries.stream().map(entry -> entry.getRawFileEntry()).toList()); + model.getCurrentDirectory(), + entries.stream().map(entry -> entry.getRawFileEntry()).toList()); } @Override diff --git a/ext/base/src/main/java/io/xpipe/ext/base/browser/CopyPathAction.java b/ext/base/src/main/java/io/xpipe/ext/base/browser/CopyPathAction.java index 585d09f63..b0fd85c70 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/browser/CopyPathAction.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/browser/CopyPathAction.java @@ -41,7 +41,9 @@ public class CopyPathAction implements BrowserAction, BranchAction { @Override public String getName(OpenFileSystemModel model, List entries) { if (entries.size() == 1) { - return " " + BrowserActionFormatter.centerEllipsis(entries.get(0).getRawFileEntry().getPath(), 50); + return " " + + BrowserActionFormatter.centerEllipsis( + entries.get(0).getRawFileEntry().getPath(), 50); } return "Absolute Path"; @@ -53,7 +55,7 @@ public class CopyPathAction implements BrowserAction, BranchAction { } @Override - public void execute(OpenFileSystemModel model, List entries) throws Exception { + public void execute(OpenFileSystemModel model, List entries) { var s = entries.stream() .map(entry -> entry.getRawFileEntry().getPath()) .collect(Collectors.joining("\n")); @@ -66,7 +68,10 @@ public class CopyPathAction implements BrowserAction, BranchAction { @Override public String getName(OpenFileSystemModel model, List entries) { if (entries.size() == 1) { - return "\"" + BrowserActionFormatter.centerEllipsis(entries.get(0).getRawFileEntry().getPath(), 50) + "\""; + return "\"" + + BrowserActionFormatter.centerEllipsis( + entries.get(0).getRawFileEntry().getPath(), 50) + + "\""; } return "Absolute Path (Quoted)"; @@ -74,11 +79,13 @@ public class CopyPathAction implements BrowserAction, BranchAction { @Override public boolean isApplicable(OpenFileSystemModel model, List entries) { - return entries.stream().anyMatch(entry -> entry.getRawFileEntry().getPath().contains(" ")); + return entries.stream() + .anyMatch(entry -> + entry.getRawFileEntry().getPath().contains(" ")); } @Override - public void execute(OpenFileSystemModel model, List entries) throws Exception { + public void execute(OpenFileSystemModel model, List entries) { var s = entries.stream() .map(entry -> "\"" + entry.getRawFileEntry().getPath() + "\"") .collect(Collectors.joining("\n")); @@ -91,7 +98,12 @@ public class CopyPathAction implements BrowserAction, BranchAction { @Override public String getName(OpenFileSystemModel model, List entries) { if (entries.size() == 1) { - return " " + BrowserActionFormatter.centerEllipsis(FileNames.getFileName(entries.get(0).getRawFileEntry().getPath()), 50); + return " " + + BrowserActionFormatter.centerEllipsis( + FileNames.getFileName(entries.get(0) + .getRawFileEntry() + .getPath()), + 50); } return "File Name"; @@ -99,14 +111,15 @@ public class CopyPathAction implements BrowserAction, BranchAction { @Override public KeyCombination getShortcut() { - return new KeyCodeCombination(KeyCode.C, KeyCombination.SHIFT_DOWN, KeyCombination.SHORTCUT_DOWN); + return new KeyCodeCombination( + KeyCode.C, KeyCombination.SHIFT_DOWN, KeyCombination.SHORTCUT_DOWN); } @Override - public void execute(OpenFileSystemModel model, List entries) throws Exception { + public void execute(OpenFileSystemModel model, List entries) { var s = entries.stream() - .map(entry -> - FileNames.getFileName(entry.getRawFileEntry().getPath())) + .map(entry -> FileNames.getFileName( + entry.getRawFileEntry().getPath())) .collect(Collectors.joining("\n")); var selection = new StringSelection(s); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); @@ -117,7 +130,13 @@ public class CopyPathAction implements BrowserAction, BranchAction { @Override public String getName(OpenFileSystemModel model, List entries) { if (entries.size() == 1) { - return "\"" + BrowserActionFormatter.centerEllipsis(FileNames.getFileName(entries.get(0).getRawFileEntry().getPath()), 50) + "\""; + return "\"" + + BrowserActionFormatter.centerEllipsis( + FileNames.getFileName(entries.get(0) + .getRawFileEntry() + .getPath()), + 50) + + "\""; } return "File Name (Quoted)"; @@ -125,14 +144,17 @@ public class CopyPathAction implements BrowserAction, BranchAction { @Override public boolean isApplicable(OpenFileSystemModel model, List entries) { - return entries.stream().anyMatch(entry -> FileNames.getFileName(entry.getRawFileEntry().getPath()).contains(" ")); + return entries.stream().anyMatch(entry -> FileNames.getFileName( + entry.getRawFileEntry().getPath()) + .contains(" ")); } @Override - public void execute(OpenFileSystemModel model, List entries) throws Exception { + public void execute(OpenFileSystemModel model, List entries) { var s = entries.stream() - .map(entry -> - "\"" + FileNames.getFileName(entry.getRawFileEntry().getPath()) + "\"") + .map(entry -> "\"" + + FileNames.getFileName( + entry.getRawFileEntry().getPath()) + "\"") .collect(Collectors.joining("\n")); var selection = new StringSelection(s); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); diff --git a/ext/base/src/main/java/io/xpipe/ext/base/browser/EditFileAction.java b/ext/base/src/main/java/io/xpipe/ext/base/browser/EditFileAction.java index da6659a4f..3701a6ed3 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/browser/EditFileAction.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/browser/EditFileAction.java @@ -14,7 +14,7 @@ import java.util.List; public class EditFileAction implements LeafAction { @Override - public void execute(OpenFileSystemModel model, List entries) throws Exception { + public void execute(OpenFileSystemModel model, List entries) { for (BrowserEntry entry : entries) { FileOpener.openInTextEditor(entry.getRawFileEntry()); } diff --git a/ext/base/src/main/java/io/xpipe/ext/base/browser/NewItemAction.java b/ext/base/src/main/java/io/xpipe/ext/base/browser/NewItemAction.java index be09d2a55..bb70d2ffa 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/browser/NewItemAction.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/browser/NewItemAction.java @@ -34,7 +34,11 @@ public class NewItemAction implements BrowserAction, BranchAction { @Override public boolean isApplicable(OpenFileSystemModel model, List entries) { - return entries.size() == 1 && entries.get(0).getRawFileEntry().getPath().equals(model.getCurrentPath().get()); + return entries.size() == 1 + && entries.get(0) + .getRawFileEntry() + .getPath() + .equals(model.getCurrentPath().get()); } @Override @@ -52,15 +56,20 @@ public class NewItemAction implements BrowserAction, BranchAction { } @Override - public void execute(OpenFileSystemModel model, List entries) throws Exception { + public void execute(OpenFileSystemModel model, List entries) { var name = new SimpleStringProperty(); - model.getOverlay().setValue(new ModalOverlayComp.OverlayContent("newFile", Comp.of(() -> { - var creationName = new TextField(); - creationName.textProperty().bindBidirectional(name); - return creationName; - }), "finish", () -> { - model.createFileAsync(name.getValue()); - })); + model.getOverlay() + .setValue(new ModalOverlayComp.OverlayContent( + "newFile", + Comp.of(() -> { + var creationName = new TextField(); + creationName.textProperty().bindBidirectional(name); + return creationName; + }), + "finish", + () -> { + model.createFileAsync(name.getValue()); + })); } @Override @@ -75,16 +84,22 @@ public class NewItemAction implements BrowserAction, BranchAction { } @Override - public void execute(OpenFileSystemModel model, List entries) throws Exception { + public void execute(OpenFileSystemModel model, List entries) { var name = new SimpleStringProperty(); - model.getOverlay().setValue(new ModalOverlayComp.OverlayContent("newDirectory", Comp.of(() -> { - var creationName = new TextField(); - creationName.textProperty().bindBidirectional(name); - return creationName; - }), "finish", () -> { - model.createDirectoryAsync(name.getValue()); - })); + model.getOverlay() + .setValue(new ModalOverlayComp.OverlayContent( + "newDirectory", + Comp.of(() -> { + var creationName = new TextField(); + creationName.textProperty().bindBidirectional(name); + return creationName; + }), + "finish", + () -> { + model.createDirectoryAsync(name.getValue()); + })); } + @Override public Node getIcon(OpenFileSystemModel model, List entries) { return BrowserIcons.createDefaultDirectoryIcon().createRegion(); diff --git a/ext/base/src/main/java/io/xpipe/ext/base/browser/OpenDirectoryAction.java b/ext/base/src/main/java/io/xpipe/ext/base/browser/OpenDirectoryAction.java index 4532a8958..b0af3bbcc 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/browser/OpenDirectoryAction.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/browser/OpenDirectoryAction.java @@ -15,7 +15,7 @@ import java.util.List; public class OpenDirectoryAction implements LeafAction { @Override - public void execute(OpenFileSystemModel model, List entries) throws Exception { + public void execute(OpenFileSystemModel model, List entries) { model.cd(entries.get(0).getRawFileEntry().getPath()); } @@ -31,7 +31,8 @@ public class OpenDirectoryAction implements LeafAction { @Override public boolean isApplicable(OpenFileSystemModel model, List entries) { - return entries.size() == 1 && entries.stream().allMatch(entry -> entry.getRawFileEntry().getKind() == FileKind.DIRECTORY); + return entries.size() == 1 + && entries.stream().allMatch(entry -> entry.getRawFileEntry().getKind() == FileKind.DIRECTORY); } @Override diff --git a/ext/base/src/main/java/io/xpipe/ext/base/browser/OpenDirectoryInNewTabAction.java b/ext/base/src/main/java/io/xpipe/ext/base/browser/OpenDirectoryInNewTabAction.java index 22c74311e..0eacfb31c 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/browser/OpenDirectoryInNewTabAction.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/browser/OpenDirectoryInNewTabAction.java @@ -15,8 +15,13 @@ import java.util.List; public class OpenDirectoryInNewTabAction implements LeafAction { @Override - public void execute(OpenFileSystemModel model, List entries) throws Exception { - model.getBrowserModel().openFileSystemAsync(model.getName(), model.getStore().asNeeded(), entries.get(0).getRawFileEntry().getPath(), null); + public void execute(OpenFileSystemModel model, List entries) { + model.getBrowserModel() + .openFileSystemAsync( + model.getName(), + model.getStore().asNeeded(), + entries.get(0).getRawFileEntry().getPath(), + null); } @Override @@ -31,7 +36,8 @@ public class OpenDirectoryInNewTabAction implements LeafAction { @Override public boolean isApplicable(OpenFileSystemModel model, List entries) { - return entries.size() == 1 && entries.stream().allMatch(entry -> entry.getRawFileEntry().getKind() == FileKind.DIRECTORY); + return entries.size() == 1 + && entries.stream().allMatch(entry -> entry.getRawFileEntry().getKind() == FileKind.DIRECTORY); } @Override diff --git a/ext/base/src/main/java/io/xpipe/ext/base/browser/OpenFileDefaultAction.java b/ext/base/src/main/java/io/xpipe/ext/base/browser/OpenFileDefaultAction.java index 72d6e85c9..ef619d444 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/browser/OpenFileDefaultAction.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/browser/OpenFileDefaultAction.java @@ -16,7 +16,7 @@ import java.util.List; public class OpenFileDefaultAction implements LeafAction { @Override - public void execute(OpenFileSystemModel model, List entries) throws Exception { + public void execute(OpenFileSystemModel model, List entries) { for (var entry : entries) { FileOpener.openInDefaultApplication(entry.getRawFileEntry()); } diff --git a/ext/base/src/main/java/io/xpipe/ext/base/browser/OpenFileWithAction.java b/ext/base/src/main/java/io/xpipe/ext/base/browser/OpenFileWithAction.java index ef562cc55..ccb8c5941 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/browser/OpenFileWithAction.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/browser/OpenFileWithAction.java @@ -35,7 +35,8 @@ public class OpenFileWithAction implements LeafAction { case OsType.Linux linux -> { ShellControl sc = model.getFileSystem().getShell().get(); ShellDialect d = sc.getShellDialect(); - sc.executeSimpleCommand("mimeopen -a " + d.fileArgument(entries.get(0).getRawFileEntry().getPath())); + sc.executeSimpleCommand("mimeopen -a " + + d.fileArgument(entries.get(0).getRawFileEntry().getPath())); } case OsType.MacOs macOs -> { throw new UnsupportedOperationException(); diff --git a/ext/base/src/main/java/io/xpipe/ext/base/browser/OpenNativeFileDetailsAction.java b/ext/base/src/main/java/io/xpipe/ext/base/browser/OpenNativeFileDetailsAction.java index 6dd7db6c3..339a9b1fe 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/browser/OpenNativeFileDetailsAction.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/browser/OpenNativeFileDetailsAction.java @@ -29,18 +29,21 @@ public class OpenNativeFileDetailsAction implements LeafAction { } } case OsType.Linux linux -> { - var dbus = String.format(""" + var dbus = String.format( + """ dbus-send --session --print-reply --dest=org.freedesktop.FileManager1 --type=method_call /org/freedesktop/FileManager1 org.freedesktop.FileManager1.ShowItemProperties array:string:"file://%s" string:"" - """, entry.getRawFileEntry().getPath()); + """, + entry.getRawFileEntry().getPath()); sc.executeSimpleCommand(dbus); } case OsType.MacOs macOs -> { sc.osascriptCommand(String.format( - """ + """ set fileEntry to (POSIX file "%s") as text tell application "Finder" to open information window of file fileEntry """, - entry.getRawFileEntry().getPath())).execute(); + entry.getRawFileEntry().getPath())) + .execute(); } } } diff --git a/ext/base/src/main/java/io/xpipe/ext/base/browser/OpenTerminalAction.java b/ext/base/src/main/java/io/xpipe/ext/base/browser/OpenTerminalAction.java index 78060ccde..5f8be179b 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/browser/OpenTerminalAction.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/browser/OpenTerminalAction.java @@ -22,7 +22,9 @@ public class OpenTerminalAction implements LeafAction { @Override public void execute(OpenFileSystemModel model, List entries) throws Exception { if (model.getInOverview().get()) { - TerminalHelper.open(model.getName(), model.getFileSystem().getShell().orElseThrow().prepareTerminalOpen(model.getName())); + TerminalHelper.open( + model.getName(), + model.getFileSystem().getShell().orElseThrow().prepareTerminalOpen(model.getName())); return; } diff --git a/ext/base/src/main/java/io/xpipe/ext/base/browser/PasteAction.java b/ext/base/src/main/java/io/xpipe/ext/base/browser/PasteAction.java index d41707c0b..a0d671874 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/browser/PasteAction.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/browser/PasteAction.java @@ -16,13 +16,15 @@ import java.util.List; public class PasteAction implements LeafAction { @Override - public void execute(OpenFileSystemModel model, List entries) throws Exception { + public void execute(OpenFileSystemModel model, List entries) { var clipboard = BrowserClipboard.retrieveCopy(); if (clipboard == null) { return; } - var target = entries.size() == 1 && entries.get(0).getRawFileEntry().getKind() == FileKind.DIRECTORY ? entries.get(0).getRawFileEntry() : model.getCurrentDirectory(); + var target = entries.size() == 1 && entries.get(0).getRawFileEntry().getKind() == FileKind.DIRECTORY + ? entries.get(0).getRawFileEntry() + : model.getCurrentDirectory(); var files = clipboard.getEntries(); model.dropFilesIntoAsync(target, files, true); } @@ -39,7 +41,8 @@ public class PasteAction implements LeafAction { @Override public boolean isApplicable(OpenFileSystemModel model, List entries) { - return entries.size() < 2 && entries.stream().allMatch(entry -> entry.getRawFileEntry().getKind() == FileKind.DIRECTORY); + return entries.size() < 2 + && entries.stream().allMatch(entry -> entry.getRawFileEntry().getKind() == FileKind.DIRECTORY); } @Override diff --git a/ext/base/src/main/java/io/xpipe/ext/base/browser/RenameAction.java b/ext/base/src/main/java/io/xpipe/ext/base/browser/RenameAction.java index a9e7ff2d7..1fb8cf895 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/browser/RenameAction.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/browser/RenameAction.java @@ -14,7 +14,7 @@ import java.util.List; public class RenameAction implements LeafAction { @Override - public void execute(OpenFileSystemModel model, List entries) throws Exception { + public void execute(OpenFileSystemModel model, List entries) { model.getFileList().getEditing().setValue(entries.get(0)); } diff --git a/ext/base/src/main/java/io/xpipe/ext/base/browser/RunAction.java b/ext/base/src/main/java/io/xpipe/ext/base/browser/RunAction.java index 263e222a1..cd3da2501 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/browser/RunAction.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/browser/RunAction.java @@ -11,6 +11,7 @@ import javafx.scene.Node; import org.kordamp.ikonli.javafx.FontIcon; import java.util.List; +import java.util.stream.Stream; public class RunAction extends MultiExecuteAction { @@ -29,11 +30,13 @@ public class RunAction extends MultiExecuteAction { } var os = shell.get().getOsType(); - if (os.equals(OsType.WINDOWS) && List.of("exe", "bat", "ps1", "cmd").stream().anyMatch(s -> e.getPath().endsWith(s))) { + if (os.equals(OsType.WINDOWS) + && Stream.of("exe", "bat", "ps1", "cmd") + .anyMatch(s -> e.getPath().endsWith(s))) { return true; } - if (List.of("sh", "command").stream().anyMatch(s -> e.getPath().endsWith(s))) { + if (Stream.of("sh", "command").anyMatch(s -> e.getPath().endsWith(s))) { return true; } diff --git a/ext/base/src/main/java/io/xpipe/ext/base/browser/UnzipAction.java b/ext/base/src/main/java/io/xpipe/ext/base/browser/UnzipAction.java index ff3ec430d..dfdfee877 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/browser/UnzipAction.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/browser/UnzipAction.java @@ -18,12 +18,14 @@ public class UnzipAction extends ExecuteApplicationAction implements FileTypeAct @Override public boolean isApplicable(OpenFileSystemModel model, List entries) { - return FileTypeAction.super.isApplicable(model, entries) && !model.getFileSystem().getShell().orElseThrow().getOsType().equals(OsType.WINDOWS); + return FileTypeAction.super.isApplicable(model, entries) + && !model.getFileSystem().getShell().orElseThrow().getOsType().equals(OsType.WINDOWS); } @Override protected String createCommand(OpenFileSystemModel model, BrowserEntry entry) { - return "unzip -o " + entry.getOptionallyQuotedFileName() + " -d " + FileNames.quoteIfNecessary(FileNames.getBaseName(entry.getFileName())); + return "unzip -o " + entry.getOptionallyQuotedFileName() + " -d " + + FileNames.quoteIfNecessary(FileNames.getBaseName(entry.getFileName())); } @Override diff --git a/ext/collections/src/main/java/io/xpipe/ext/collections/ArchiveEntryStore.java b/ext/collections/src/main/java/io/xpipe/ext/collections/ArchiveEntryStore.java index a44489230..4aa97768f 100644 --- a/ext/collections/src/main/java/io/xpipe/ext/collections/ArchiveEntryStore.java +++ b/ext/collections/src/main/java/io/xpipe/ext/collections/ArchiveEntryStore.java @@ -15,12 +15,12 @@ public class ArchiveEntryStore extends ArchiveEntryDataStore { } @Override - public InputStream openInput() throws Exception { + public InputStream openInput() { return con.getInputStream(); } @Override - public OutputStream openOutput() throws Exception { + public OutputStream openOutput() { return null; } diff --git a/ext/collections/src/main/java/io/xpipe/ext/collections/ArchiveReadConnection.java b/ext/collections/src/main/java/io/xpipe/ext/collections/ArchiveReadConnection.java index 19428baf9..917305725 100644 --- a/ext/collections/src/main/java/io/xpipe/ext/collections/ArchiveReadConnection.java +++ b/ext/collections/src/main/java/io/xpipe/ext/collections/ArchiveReadConnection.java @@ -34,33 +34,39 @@ public class ArchiveReadConnection implements CollectionReadConnection { } return Stream.iterate( - entry.get(), - e -> { - ArchiveEntry next = null; + entry.get(), + e -> { + ArchiveEntry next; + try { + next = inputStream.getNextEntry(); + } catch (IOException ex) { + throw new UncheckedIOException(ex); + } + + if (next == null) { + return false; + } + + var dir = next.isDirectory(); + entry.set(new ArchiveEntryStore(store, dir, this, next.getName())); + return true; + }, + e -> { + return entry.get(); + }) + .map(archiveEntryStore -> { + var preferred = DataSourceProviders.byPreferredStore(archiveEntryStore, null); try { - next = inputStream.getNextEntry(); - } catch (IOException ex) { - throw new UncheckedIOException(ex); + return preferred.isPresent() + ? preferred + .get() + .createDefaultSource(archiveEntryStore) + .asNeeded() + : null; + } catch (Exception e) { + throw new RuntimeException(e); } - - if (next == null) { - return false; - } - - var dir = next.isDirectory(); - entry.set(new ArchiveEntryStore(store, dir, this, next.getName())); - return true; - }, - e -> { - return entry.get(); - }).map(archiveEntryStore -> { - var preferred = DataSourceProviders.byPreferredStore(archiveEntryStore, null); - try { - return preferred.isPresent() ? preferred.get().createDefaultSource(archiveEntryStore).asNeeded() : null; - } catch (Exception e) { - throw new RuntimeException(e); - } - }); + }); } @Override diff --git a/ext/collections/src/main/java/io/xpipe/ext/collections/DirectoryProvider.java b/ext/collections/src/main/java/io/xpipe/ext/collections/DirectoryProvider.java index 1df22b4e1..17a27daa3 100644 --- a/ext/collections/src/main/java/io/xpipe/ext/collections/DirectoryProvider.java +++ b/ext/collections/src/main/java/io/xpipe/ext/collections/DirectoryProvider.java @@ -7,7 +7,6 @@ import io.xpipe.core.source.*; import io.xpipe.core.store.DataStore; import lombok.experimental.SuperBuilder; -import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.nio.file.FileVisitResult; @@ -23,7 +22,7 @@ import java.util.stream.Stream; public class DirectoryProvider implements UniformDataSourceProvider { @Override - public Source createDefaultSource(DataStore input) throws Exception { + public Source createDefaultSource(DataStore input) { return Source.builder().store(input.asNeeded()).build(); } @@ -69,13 +68,13 @@ public class DirectoryProvider implements UniformDataSourceProvider(); Files.walkFileTree(store.getPath(), new SimpleFileVisitor<>() { @Override - public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) { var rel = store.getPath().relativize(file); var name = rel.toString(); var dir = Files.isDirectory(file); @@ -116,7 +115,8 @@ public class DirectoryProvider implements UniformDataSourceProvider DataSourceProviders.createDefault(archiveEntryDataStore)); + return entries.stream() + .map(archiveEntryDataStore -> DataSourceProviders.createDefault(archiveEntryDataStore)); } }; } diff --git a/ext/csv/src/main/java/io/xpipe/ext/csv/CsvHeaderState.java b/ext/csv/src/main/java/io/xpipe/ext/csv/CsvHeaderState.java index 7247d21d0..5cb5d7e21 100644 --- a/ext/csv/src/main/java/io/xpipe/ext/csv/CsvHeaderState.java +++ b/ext/csv/src/main/java/io/xpipe/ext/csv/CsvHeaderState.java @@ -98,9 +98,9 @@ public enum CsvHeaderState { throw new IllegalStateException(); } - private static interface GeneralType { + private interface GeneralType { - static List TYPES = List.of(new NumberType(), new TextType()); + List TYPES = List.of(new NumberType(), new TextType()); boolean matches(String s); } diff --git a/ext/csv/src/main/java/io/xpipe/ext/csv/CsvSourceProvider.java b/ext/csv/src/main/java/io/xpipe/ext/csv/CsvSourceProvider.java index e9fc302be..f20b8e52c 100644 --- a/ext/csv/src/main/java/io/xpipe/ext/csv/CsvSourceProvider.java +++ b/ext/csv/src/main/java/io/xpipe/ext/csv/CsvSourceProvider.java @@ -4,7 +4,6 @@ import io.xpipe.app.core.AppI18n; import io.xpipe.app.util.DialogHelper; import io.xpipe.app.util.DynamicOptionsBuilder; import io.xpipe.app.util.NamedCharacter; -import io.xpipe.core.charsetter.NewLine; import io.xpipe.core.dialog.Dialog; import io.xpipe.core.impl.TextSource; import io.xpipe.core.source.DataSource; @@ -53,14 +52,14 @@ public class CsvSourceProvider implements SimpleFileDataSourceProvider source, boolean preferQuiet) { var s = source.getValue(); var charset = new SimpleObjectProperty<>(s.getCharset()); - var newLine = new SimpleObjectProperty(s.getNewLine()); + var newLine = new SimpleObjectProperty<>(s.getNewLine()); - var headerState = new SimpleObjectProperty(s.getHeaderState()); + var headerState = new SimpleObjectProperty<>(s.getHeaderState()); var headerStateNames = new LinkedHashMap>(); headerStateNames.put(CsvHeaderState.INCLUDED, AppI18n.observable("csv.included")); headerStateNames.put(CsvHeaderState.OMITTED, AppI18n.observable("csv.omitted")); - var delimiter = new SimpleObjectProperty(s.getDelimiter()); + var delimiter = new SimpleObjectProperty<>(s.getDelimiter()); var delimiterNames = new LinkedHashMap>(); CsvDelimiter.ALL.forEach(d -> { delimiterNames.put( @@ -69,7 +68,7 @@ public class CsvSourceProvider implements SimpleFileDataSourceProvider delimiterCustom = AppI18n.observable("csv.custom"); - var quote = new SimpleObjectProperty(s.getQuote()); + var quote = new SimpleObjectProperty<>(s.getQuote()); var quoteNames = new LinkedHashMap>(); CsvQuoteChar.CHARS.forEach(d -> { quoteNames.put(d.getCharacter(), AppI18n.observable(d.getTranslationKey())); diff --git a/ext/jackson/src/main/java/io/xpipe/ext/jackson/json/JsonProvider.java b/ext/jackson/src/main/java/io/xpipe/ext/jackson/json/JsonProvider.java index 4e3eb3ba7..d90b54701 100644 --- a/ext/jackson/src/main/java/io/xpipe/ext/jackson/json/JsonProvider.java +++ b/ext/jackson/src/main/java/io/xpipe/ext/jackson/json/JsonProvider.java @@ -25,8 +25,6 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -; - public class JsonProvider implements UniformDataSourceProvider, SimpleFileDataSourceProvider { @@ -91,8 +89,8 @@ public class JsonProvider @Override public Region configGui(Property source, boolean preferQuiet) { - var charset = new SimpleObjectProperty(source.getValue().getCharset()); - var newLine = new SimpleObjectProperty(source.getValue().getNewLine()); + var charset = new SimpleObjectProperty<>(source.getValue().getCharset()); + var newLine = new SimpleObjectProperty<>(source.getValue().getNewLine()); if (preferQuiet) { return new DynamicOptionsBuilder() .addCharset(charset) diff --git a/ext/jackson/src/main/java/io/xpipe/ext/jackson/json_table/JsonTableProvider.java b/ext/jackson/src/main/java/io/xpipe/ext/jackson/json_table/JsonTableProvider.java index 5ac662ee4..b7f799fb7 100644 --- a/ext/jackson/src/main/java/io/xpipe/ext/jackson/json_table/JsonTableProvider.java +++ b/ext/jackson/src/main/java/io/xpipe/ext/jackson/json_table/JsonTableProvider.java @@ -27,7 +27,7 @@ import java.util.Map; public class JsonTableProvider implements UniformDataSourceProvider, - SimpleFileDataSourceProvider { + SimpleFileDataSourceProvider { @Override public boolean supportsConversion(JsonTableProvider.Source in, DataSourceType t) { @@ -108,8 +108,8 @@ public class JsonTableProvider @Override public Region configGui(Property source, boolean preferQuiet) { - var charset = new SimpleObjectProperty(source.getValue().getCharset()); - var newLine = new SimpleObjectProperty(source.getValue().getNewLine()); + var charset = new SimpleObjectProperty<>(source.getValue().getCharset()); + var newLine = new SimpleObjectProperty<>(source.getValue().getNewLine()); if (preferQuiet) { return new DynamicOptionsBuilder() .addCharset(charset) diff --git a/ext/jackson/src/main/java/io/xpipe/ext/jackson/xml/XmlProvider.java b/ext/jackson/src/main/java/io/xpipe/ext/jackson/xml/XmlProvider.java index 9c1253630..7373190ad 100644 --- a/ext/jackson/src/main/java/io/xpipe/ext/jackson/xml/XmlProvider.java +++ b/ext/jackson/src/main/java/io/xpipe/ext/jackson/xml/XmlProvider.java @@ -83,8 +83,8 @@ public class XmlProvider implements SimpleFileDataSourceProvider source, boolean preferQuiet) { - var charset = new SimpleObjectProperty(source.getValue().getCharset()); - var newLine = new SimpleObjectProperty(source.getValue().getNewLine()); + var charset = new SimpleObjectProperty<>(source.getValue().getCharset()); + var newLine = new SimpleObjectProperty<>(source.getValue().getNewLine()); return new DynamicOptionsBuilder() .addCharset(charset) .addNewLine(newLine) diff --git a/ext/jackson/src/main/java/io/xpipe/ext/jackson/xml_table/XmlTableProvider.java b/ext/jackson/src/main/java/io/xpipe/ext/jackson/xml_table/XmlTableProvider.java index a28bef938..cb4073126 100644 --- a/ext/jackson/src/main/java/io/xpipe/ext/jackson/xml_table/XmlTableProvider.java +++ b/ext/jackson/src/main/java/io/xpipe/ext/jackson/xml_table/XmlTableProvider.java @@ -29,7 +29,7 @@ import java.util.Map; public class XmlTableProvider implements UniformDataSourceProvider, - SimpleFileDataSourceProvider { + SimpleFileDataSourceProvider { @Override public boolean shouldShow(DataSourceType type) { @@ -106,8 +106,8 @@ public class XmlTableProvider @Override public Region configGui(Property source, boolean preferQuiet) { - var charset = new SimpleObjectProperty(source.getValue().getCharset()); - var newLine = new SimpleObjectProperty(source.getValue().getNewLine()); + var charset = new SimpleObjectProperty<>(source.getValue().getCharset()); + var newLine = new SimpleObjectProperty<>(source.getValue().getNewLine()); var rootName = new SimpleStringProperty(source.getValue().getRootName()); var entryName = new SimpleStringProperty(source.getValue().getEntryName()); return new DynamicOptionsBuilder() diff --git a/ext/pdx/src/main/java/io/xpipe/ext/pdx/Eu4FileProvider.java b/ext/pdx/src/main/java/io/xpipe/ext/pdx/Eu4FileProvider.java index e22073a28..718b1498a 100644 --- a/ext/pdx/src/main/java/io/xpipe/ext/pdx/Eu4FileProvider.java +++ b/ext/pdx/src/main/java/io/xpipe/ext/pdx/Eu4FileProvider.java @@ -14,7 +14,7 @@ import java.util.Map; public class Eu4FileProvider extends PdxFileProvider { @Override - public Source createDefaultSource(DataStore input) throws Exception { + public Source createDefaultSource(DataStore input) { return Source.builder().store(input.asNeeded()).build(); } diff --git a/ext/pdx/src/main/java/io/xpipe/ext/pdx/PdxTextFileProvider.java b/ext/pdx/src/main/java/io/xpipe/ext/pdx/PdxTextFileProvider.java index 79086b337..a5b997e36 100644 --- a/ext/pdx/src/main/java/io/xpipe/ext/pdx/PdxTextFileProvider.java +++ b/ext/pdx/src/main/java/io/xpipe/ext/pdx/PdxTextFileProvider.java @@ -18,10 +18,10 @@ import java.util.Map; public class PdxTextFileProvider implements UniformDataSourceProvider, - SimpleFileDataSourceProvider { + SimpleFileDataSourceProvider { @Override - public Source createDefaultSource(DataStore input) throws Exception { + public Source createDefaultSource(DataStore input) { return Source.builder().store(input.asNeeded()).build(); } diff --git a/ext/pdx/src/main/java/io/xpipe/ext/pdx/parser/TextFormatParser.java b/ext/pdx/src/main/java/io/xpipe/ext/pdx/parser/TextFormatParser.java index 2f1d841c5..85e14c28a 100644 --- a/ext/pdx/src/main/java/io/xpipe/ext/pdx/parser/TextFormatParser.java +++ b/ext/pdx/src/main/java/io/xpipe/ext/pdx/parser/TextFormatParser.java @@ -84,21 +84,19 @@ public final class TextFormatParser { } } - public final synchronized TupleNode parse(Path file) throws IOException, ParseException { + public synchronized TupleNode parse(Path file) throws IOException, ParseException { return parse(file.getFileName().toString(), Files.readAllBytes(file), 0, false); } - public final synchronized TupleNode parse(String name, Path file, boolean strict) - throws IOException, ParseException { + public synchronized TupleNode parse(String name, Path file, boolean strict) throws IOException, ParseException { return parse(name, Files.readAllBytes(file), 0, strict); } - public final synchronized TupleNode parse(String name, byte[] input, int start) throws ParseException { + public synchronized TupleNode parse(String name, byte[] input, int start) throws ParseException { return parse(name, input, start, false); } - public final synchronized TupleNode parse(String name, byte[] input, int start, boolean strict) - throws ParseException { + public synchronized TupleNode parse(String name, byte[] input, int start, boolean strict) throws ParseException { try { verifyTextFormat(input); diff --git a/ext/pdx/src/main/java/io/xpipe/ext/pdx/parser/TextFormatTokenizer.java b/ext/pdx/src/main/java/io/xpipe/ext/pdx/parser/TextFormatTokenizer.java index ef80c325c..0768609fc 100644 --- a/ext/pdx/src/main/java/io/xpipe/ext/pdx/parser/TextFormatTokenizer.java +++ b/ext/pdx/src/main/java/io/xpipe/ext/pdx/parser/TextFormatTokenizer.java @@ -234,7 +234,7 @@ public class TextFormatTokenizer { } } - private boolean checkForControlTokenKey(byte controlToken) throws ParseException { + private boolean checkForControlTokenKey(byte controlToken) { if (controlToken == CLOSE_GROUP) { if (getSuccessorByte() == EQUALS_CHAR) { if (nextScalarStart == i) { diff --git a/ext/pdx/src/main/java/io/xpipe/ext/pdx/savegame/SavegameParseResult.java b/ext/pdx/src/main/java/io/xpipe/ext/pdx/savegame/SavegameParseResult.java index 920c8a3ea..81f98d554 100644 --- a/ext/pdx/src/main/java/io/xpipe/ext/pdx/savegame/SavegameParseResult.java +++ b/ext/pdx/src/main/java/io/xpipe/ext/pdx/savegame/SavegameParseResult.java @@ -24,7 +24,7 @@ public abstract class SavegameParseResult { public static class Success extends SavegameParseResult { - public SavegameContent content; + public final SavegameContent content; public Success(SavegameContent content) { this.content = content; @@ -52,7 +52,7 @@ public abstract class SavegameParseResult { public static class Error extends SavegameParseResult { - public Exception error; + public final Exception error; public Error(Exception error) { this.error = error; @@ -76,14 +76,14 @@ public abstract class SavegameParseResult { public static class Invalid extends SavegameParseResult { - public String message; + public final String message; public Invalid(String message) { this.message = message; } @Override - public Success orThrow() throws Exception { + public Success orThrow() { throw new IllegalArgumentException(message); }