mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-25 00:50:31 +00:00
Rename share to sync
This commit is contained in:
parent
41d419f19d
commit
6044cd3ead
7 changed files with 41 additions and 41 deletions
|
@ -26,7 +26,7 @@ public class StoreCategoryWrapper {
|
||||||
private final DataStoreCategory category;
|
private final DataStoreCategory category;
|
||||||
private final Property<Instant> lastAccess;
|
private final Property<Instant> lastAccess;
|
||||||
private final Property<StoreSortMode> sortMode;
|
private final Property<StoreSortMode> sortMode;
|
||||||
private final Property<Boolean> share;
|
private final Property<Boolean> sync;
|
||||||
private final ObservableList<StoreCategoryWrapper> children;
|
private final ObservableList<StoreCategoryWrapper> children;
|
||||||
private final ObservableList<StoreEntryWrapper> containedEntries;
|
private final ObservableList<StoreEntryWrapper> containedEntries;
|
||||||
private final BooleanProperty expanded = new SimpleBooleanProperty();
|
private final BooleanProperty expanded = new SimpleBooleanProperty();
|
||||||
|
@ -50,7 +50,7 @@ public class StoreCategoryWrapper {
|
||||||
this.name = new SimpleStringProperty(category.getName());
|
this.name = new SimpleStringProperty(category.getName());
|
||||||
this.lastAccess = new SimpleObjectProperty<>(category.getLastAccess());
|
this.lastAccess = new SimpleObjectProperty<>(category.getLastAccess());
|
||||||
this.sortMode = new SimpleObjectProperty<>(category.getSortMode());
|
this.sortMode = new SimpleObjectProperty<>(category.getSortMode());
|
||||||
this.share = new SimpleObjectProperty<>(category.isShare());
|
this.sync = new SimpleObjectProperty<>(category.isSync());
|
||||||
this.children = FXCollections.observableArrayList();
|
this.children = FXCollections.observableArrayList();
|
||||||
this.containedEntries = FXCollections.observableArrayList();
|
this.containedEntries = FXCollections.observableArrayList();
|
||||||
this.color.setValue(category.getColor());
|
this.color.setValue(category.getColor());
|
||||||
|
@ -108,8 +108,8 @@ public class StoreCategoryWrapper {
|
||||||
category.setSortMode(newValue);
|
category.setSortMode(newValue);
|
||||||
});
|
});
|
||||||
|
|
||||||
share.addListener((observable, oldValue, newValue) -> {
|
sync.addListener((observable, oldValue, newValue) -> {
|
||||||
DataStorage.get().shareCategory(category, newValue);
|
DataStorage.get().syncCategory(category, newValue);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ public class StoreCategoryWrapper {
|
||||||
|
|
||||||
lastAccess.setValue(category.getLastAccess().minus(Duration.ofMillis(500)));
|
lastAccess.setValue(category.getLastAccess().minus(Duration.ofMillis(500)));
|
||||||
sortMode.setValue(category.getSortMode());
|
sortMode.setValue(category.getSortMode());
|
||||||
share.setValue(category.isShare());
|
sync.setValue(category.isSync());
|
||||||
expanded.setValue(category.isExpanded());
|
expanded.setValue(category.isExpanded());
|
||||||
color.setValue(category.getColor());
|
color.setValue(category.getColor());
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ import io.xpipe.app.ext.DataStoreProviders;
|
||||||
import io.xpipe.app.issue.TrackEvent;
|
import io.xpipe.app.issue.TrackEvent;
|
||||||
import io.xpipe.app.prefs.AppPrefs;
|
import io.xpipe.app.prefs.AppPrefs;
|
||||||
import io.xpipe.app.storage.DataStorage;
|
import io.xpipe.app.storage.DataStorage;
|
||||||
import io.xpipe.app.storage.GitStorageHandler;
|
import io.xpipe.app.storage.DataStorageSyncHandler;
|
||||||
import io.xpipe.app.update.XPipeDistributionType;
|
import io.xpipe.app.update.XPipeDistributionType;
|
||||||
import io.xpipe.app.util.*;
|
import io.xpipe.app.util.*;
|
||||||
|
|
||||||
|
@ -54,8 +54,8 @@ public class BaseMode extends OperationMode {
|
||||||
AppPrefs.setLocalDefaultsIfNeeded();
|
AppPrefs.setLocalDefaultsIfNeeded();
|
||||||
// Initialize beacon server as we should be prepared for git askpass commands
|
// Initialize beacon server as we should be prepared for git askpass commands
|
||||||
AppBeaconServer.init();
|
AppBeaconServer.init();
|
||||||
GitStorageHandler.getInstance().init();
|
DataStorageSyncHandler.getInstance().init();
|
||||||
GitStorageHandler.getInstance().setupRepositoryAndPull();
|
DataStorageSyncHandler.getInstance().retrieveSyncedData();
|
||||||
AppPrefs.initSharedRemote();
|
AppPrefs.initSharedRemote();
|
||||||
UnlockAlert.showIfNeeded();
|
UnlockAlert.showIfNeeded();
|
||||||
DataStorage.init();
|
DataStorage.init();
|
||||||
|
|
|
@ -89,9 +89,9 @@ public class StoreCategoryComp extends SimpleComp {
|
||||||
return "mdi2a-account-lock";
|
return "mdi2a-account-lock";
|
||||||
}
|
}
|
||||||
|
|
||||||
return category.getShare().getValue() ? "mdi2g-git" : "mdi2a-account-cancel";
|
return category.getSync().getValue() ? "mdi2g-git" : "mdi2a-account-cancel";
|
||||||
},
|
},
|
||||||
category.getShare(),
|
category.getSync(),
|
||||||
hover);
|
hover);
|
||||||
var statusButton = new IconButtonComp(statusIcon)
|
var statusButton = new IconButtonComp(statusIcon)
|
||||||
.apply(struc -> AppFont.small(struc.get()))
|
.apply(struc -> AppFont.small(struc.get()))
|
||||||
|
@ -217,25 +217,25 @@ public class StoreCategoryComp extends SimpleComp {
|
||||||
share.textProperty()
|
share.textProperty()
|
||||||
.bind(Bindings.createStringBinding(
|
.bind(Bindings.createStringBinding(
|
||||||
() -> {
|
() -> {
|
||||||
if (category.getShare().getValue()) {
|
if (category.getSync().getValue()) {
|
||||||
return AppI18n.get("unshare");
|
return AppI18n.get("unshare");
|
||||||
} else {
|
} else {
|
||||||
return AppI18n.get("share");
|
return AppI18n.get("share");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
category.getShare()));
|
category.getSync()));
|
||||||
share.graphicProperty()
|
share.graphicProperty()
|
||||||
.bind(Bindings.createObjectBinding(
|
.bind(Bindings.createObjectBinding(
|
||||||
() -> {
|
() -> {
|
||||||
if (category.getShare().getValue()) {
|
if (category.getSync().getValue()) {
|
||||||
return new FontIcon("mdi2b-block-helper");
|
return new FontIcon("mdi2b-block-helper");
|
||||||
} else {
|
} else {
|
||||||
return new FontIcon("mdi2g-git");
|
return new FontIcon("mdi2g-git");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
category.getShare()));
|
category.getSync()));
|
||||||
share.setOnAction(event -> {
|
share.setOnAction(event -> {
|
||||||
category.getShare().setValue(!category.getShare().getValue());
|
category.getSync().setValue(!category.getSync().getValue());
|
||||||
});
|
});
|
||||||
contextMenu.getItems().add(share);
|
contextMenu.getItems().add(share);
|
||||||
}
|
}
|
||||||
|
|
|
@ -315,8 +315,8 @@ public abstract class DataStorage {
|
||||||
saveAsync();
|
saveAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void shareCategory(DataStoreCategory category, boolean share) {
|
public void syncCategory(DataStoreCategory category, boolean share) {
|
||||||
category.setShare(share);
|
category.setSync(share);
|
||||||
|
|
||||||
DataStoreCategory p = category;
|
DataStoreCategory p = category;
|
||||||
if (share) {
|
if (share) {
|
||||||
|
@ -324,7 +324,7 @@ public abstract class DataStorage {
|
||||||
.getStoreCategoryIfPresent(p.getParentCategory())
|
.getStoreCategoryIfPresent(p.getParentCategory())
|
||||||
.orElse(null))
|
.orElse(null))
|
||||||
!= null) {
|
!= null) {
|
||||||
p.setShare(true);
|
p.setSync(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,17 +4,17 @@ import io.xpipe.core.process.ProcessControlProvider;
|
||||||
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
|
||||||
public interface GitStorageHandler {
|
public interface DataStorageSyncHandler {
|
||||||
|
|
||||||
static GitStorageHandler getInstance() {
|
static DataStorageSyncHandler getInstance() {
|
||||||
return (GitStorageHandler) ProcessControlProvider.get().getGitStorageHandler();
|
return (DataStorageSyncHandler) ProcessControlProvider.get().getGitStorageHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean supportsShare();
|
boolean supportsSync();
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
void setupRepositoryAndPull();
|
void retrieveSyncedData();
|
||||||
|
|
||||||
void afterStorageLoad();
|
void afterStorageLoad();
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class DataStoreCategory extends StorageElement {
|
||||||
StoreSortMode sortMode;
|
StoreSortMode sortMode;
|
||||||
|
|
||||||
@NonFinal
|
@NonFinal
|
||||||
boolean share;
|
boolean sync;
|
||||||
|
|
||||||
public DataStoreCategory(
|
public DataStoreCategory(
|
||||||
Path directory,
|
Path directory,
|
||||||
|
@ -43,12 +43,12 @@ public class DataStoreCategory extends StorageElement {
|
||||||
boolean dirty,
|
boolean dirty,
|
||||||
UUID parentCategory,
|
UUID parentCategory,
|
||||||
StoreSortMode sortMode,
|
StoreSortMode sortMode,
|
||||||
boolean share,
|
boolean sync,
|
||||||
boolean expanded) {
|
boolean expanded) {
|
||||||
super(directory, uuid, name, lastUsed, lastModified, color, expanded, dirty);
|
super(directory, uuid, name, lastUsed, lastModified, color, expanded, dirty);
|
||||||
this.parentCategory = parentCategory;
|
this.parentCategory = parentCategory;
|
||||||
this.sortMode = sortMode;
|
this.sortMode = sortMode;
|
||||||
this.share = share;
|
this.sync = sync;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DataStoreCategory createNew(UUID parentCategory, @NonNull String name) {
|
public static DataStoreCategory createNew(UUID parentCategory, @NonNull String name) {
|
||||||
|
@ -140,10 +140,10 @@ public class DataStoreCategory extends StorageElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setShare(boolean newShare) {
|
public void setSync(boolean newShare) {
|
||||||
var changed = share != newShare;
|
var changed = sync != newShare;
|
||||||
if (changed) {
|
if (changed) {
|
||||||
this.share = newShare;
|
this.sync = newShare;
|
||||||
notifyUpdate(false, true);
|
notifyUpdate(false, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -174,7 +174,7 @@ public class DataStoreCategory extends StorageElement {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return isShare();
|
return isSync();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -192,7 +192,7 @@ public class DataStoreCategory extends StorageElement {
|
||||||
ObjectNode stateObj = JsonNodeFactory.instance.objectNode();
|
ObjectNode stateObj = JsonNodeFactory.instance.objectNode();
|
||||||
obj.put("uuid", uuid.toString());
|
obj.put("uuid", uuid.toString());
|
||||||
obj.put("name", name);
|
obj.put("name", name);
|
||||||
obj.put("share", share);
|
obj.put("share", sync);
|
||||||
obj.set("color", mapper.valueToTree(color));
|
obj.set("color", mapper.valueToTree(color));
|
||||||
stateObj.put("lastUsed", lastUsed.toString());
|
stateObj.put("lastUsed", lastUsed.toString());
|
||||||
stateObj.put("lastModified", lastModified.toString());
|
stateObj.put("lastModified", lastModified.toString());
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class StandardStorage extends DataStorage {
|
||||||
private final List<Path> directoriesToKeep = new ArrayList<>();
|
private final List<Path> directoriesToKeep = new ArrayList<>();
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final GitStorageHandler gitStorageHandler;
|
private final DataStorageSyncHandler dataStorageSyncHandler;
|
||||||
|
|
||||||
private String vaultKey;
|
private String vaultKey;
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ public class StandardStorage extends DataStorage {
|
||||||
private boolean disposed;
|
private boolean disposed;
|
||||||
|
|
||||||
StandardStorage() {
|
StandardStorage() {
|
||||||
this.gitStorageHandler = GitStorageHandler.getInstance();
|
this.dataStorageSyncHandler = DataStorageSyncHandler.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -263,7 +263,7 @@ public class StandardStorage extends DataStorage {
|
||||||
|
|
||||||
loaded = true;
|
loaded = true;
|
||||||
busyIo.unlock();
|
busyIo.unlock();
|
||||||
this.gitStorageHandler.afterStorageLoad();
|
this.dataStorageSyncHandler.afterStorageLoad();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void callProviders() {
|
private void callProviders() {
|
||||||
|
@ -297,7 +297,7 @@ public class StandardStorage extends DataStorage {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.gitStorageHandler.beforeStorageSave();
|
this.dataStorageSyncHandler.beforeStorageSave();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
FileUtils.forceMkdir(getStoresDir().toFile());
|
FileUtils.forceMkdir(getStoresDir().toFile());
|
||||||
|
@ -317,7 +317,7 @@ public class StandardStorage extends DataStorage {
|
||||||
var exists = Files.exists(e.getDirectory());
|
var exists = Files.exists(e.getDirectory());
|
||||||
var dirty = e.isDirty();
|
var dirty = e.isDirty();
|
||||||
e.writeDataToDisk();
|
e.writeDataToDisk();
|
||||||
gitStorageHandler.handleCategory(e, exists, dirty);
|
dataStorageSyncHandler.handleCategory(e, exists, dirty);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
// IO exceptions are not expected
|
// IO exceptions are not expected
|
||||||
exception.set(ex);
|
exception.set(ex);
|
||||||
|
@ -334,7 +334,7 @@ public class StandardStorage extends DataStorage {
|
||||||
var exists = Files.exists(e.getDirectory());
|
var exists = Files.exists(e.getDirectory());
|
||||||
var dirty = e.isDirty();
|
var dirty = e.isDirty();
|
||||||
e.writeDataToDisk();
|
e.writeDataToDisk();
|
||||||
gitStorageHandler.handleEntry(e, exists, dirty);
|
dataStorageSyncHandler.handleEntry(e, exists, dirty);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
// Data corruption and schema changes are expected
|
// Data corruption and schema changes are expected
|
||||||
exception.set(ex);
|
exception.set(ex);
|
||||||
|
@ -348,7 +348,7 @@ public class StandardStorage extends DataStorage {
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteLeftovers();
|
deleteLeftovers();
|
||||||
gitStorageHandler.afterStorageSave();
|
dataStorageSyncHandler.afterStorageSave();
|
||||||
if (dispose) {
|
if (dispose) {
|
||||||
disposed = true;
|
disposed = true;
|
||||||
}
|
}
|
||||||
|
@ -357,7 +357,7 @@ public class StandardStorage extends DataStorage {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsSharing() {
|
public boolean supportsSharing() {
|
||||||
return gitStorageHandler.supportsShare();
|
return dataStorageSyncHandler.supportsSync();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteLeftovers() {
|
private void deleteLeftovers() {
|
||||||
|
@ -387,7 +387,7 @@ public class StandardStorage extends DataStorage {
|
||||||
.tag("uuid", uuid)
|
.tag("uuid", uuid)
|
||||||
.handle();
|
.handle();
|
||||||
FileUtils.forceDelete(file.toFile());
|
FileUtils.forceDelete(file.toFile());
|
||||||
gitStorageHandler.handleDeletion(file, uuid.toString());
|
dataStorageSyncHandler.handleDeletion(file, uuid.toString());
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ErrorEvent.fromThrowable(ex).expected().omit().build().handle();
|
ErrorEvent.fromThrowable(ex).expected().omit().build().handle();
|
||||||
|
@ -420,7 +420,7 @@ public class StandardStorage extends DataStorage {
|
||||||
.tag("uuid", uuid)
|
.tag("uuid", uuid)
|
||||||
.handle();
|
.handle();
|
||||||
FileUtils.forceDelete(file.toFile());
|
FileUtils.forceDelete(file.toFile());
|
||||||
gitStorageHandler.handleDeletion(file, uuid.toString());
|
dataStorageSyncHandler.handleDeletion(file, uuid.toString());
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ErrorEvent.fromThrowable(ex).expected().omit().build().handle();
|
ErrorEvent.fromThrowable(ex).expected().omit().build().handle();
|
||||||
|
|
Loading…
Reference in a new issue