Skip to content

Commit

Permalink
feat(#54): install plugins in creator subdirectory
Browse files Browse the repository at this point in the history
  • Loading branch information
the-simian authored Jan 10, 2021
1 parent 5e5ed87 commit 90456d8
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/target/
/.idea/
.vscode/

.project
.classpath
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public class ApplicationDefaults {
public static final String SELECTED_ACCOUNT_KEY = "SELECTED_ACCOUNT_KEY";
public static final String SYNC_PLUGINS_STARTUP_KEY = "SYNC_PLUGINS_STARTUP_KEY";
public static final String STORE_DIRECTORY_ENABLED_KEY = "STORE_DIRECTORY_ENABLED_KEY";
public static final String STORE_BY_CREATOR_ENABLED_KEY = "STORE_BY_CREATOR_ENABLED_KEY";
public static final String STORE_DIRECTORY_KEY = "STORE_DIRECTORY_KEY";
public static final String STORE_SUBDIRECTORY_ENABLED = "STORE_SUBDIRECTORY_ENABLED";
public static final String FIRST_LAUNCH_KEY = "FIRST_LAUNCH_KEY";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,25 @@ public class OptionsController extends BaseController {
private JFXButton removeDataButton;
@FXML
private Label versionLabel;


@FXML
private JFXButton clearCacheButton;
@FXML
private JFXCheckBox storeSubDirectoryCheckBox;
@FXML
private JFXCheckBox storeByCreatorCheckBox;
@FXML
private Label storeByCreatorLabel;
@FXML
private Label warningSubDirectory;
@FXML
private JFXCheckBox storeDirectoryCheckBox;
@FXML
private JFXTextField storeDirectoryTextField;
@FXML
private Label storeDirectorySeperator;
@FXML
private Hyperlink owlplugWebsiteLink;

/**
Expand All @@ -89,6 +97,7 @@ public void initialize() {

vst2DirectoryTextField.setDisable(false);
vst2DirectoryButton.setDisable(false);
storeByCreatorLabel.setVisible(false);

vst2ToggleButton.selectedProperty().addListener((observable, oldValue, newValue) -> {
this.getPreferences().putBoolean(ApplicationDefaults.VST2_DISCOVERY_ENABLED_KEY, newValue);
Expand Down Expand Up @@ -149,7 +158,16 @@ public void initialize() {

storeDirectoryCheckBox.selectedProperty().addListener((observable, oldValue, newValue) -> {
this.getPreferences().putBoolean(ApplicationDefaults.STORE_DIRECTORY_ENABLED_KEY, newValue);
double width = newValue ? 150 : 0;
storeDirectoryTextField.setVisible(newValue);
storeDirectorySeperator.setVisible(newValue);
storeDirectoryTextField.setDisable(!newValue);
storeDirectoryTextField.setMaxWidth(width);
});

storeByCreatorCheckBox.selectedProperty().addListener((observable, oldValue, newValue) -> {
this.getPreferences().putBoolean(ApplicationDefaults.STORE_BY_CREATOR_ENABLED_KEY, newValue);
storeByCreatorLabel.setVisible(newValue);
});

storeDirectoryTextField.textProperty().addListener((observable, oldValue, newValue) -> {
Expand Down Expand Up @@ -209,12 +227,16 @@ public void refreshView() {
storeSubDirectoryCheckBox.setSelected(this.getPreferences().getBoolean(ApplicationDefaults.STORE_SUBDIRECTORY_ENABLED, true));
warningSubDirectory.setVisible(!this.getPreferences().getBoolean(ApplicationDefaults.STORE_SUBDIRECTORY_ENABLED, true));
storeDirectoryCheckBox.setSelected(this.getPreferences().getBoolean(ApplicationDefaults.STORE_DIRECTORY_ENABLED_KEY, false));
storeByCreatorCheckBox.setSelected(this.getPreferences().getBoolean(ApplicationDefaults.STORE_BY_CREATOR_ENABLED_KEY, false));
storeDirectoryTextField.setText(this.getPreferences().get(ApplicationDefaults.STORE_DIRECTORY_KEY, ""));

if (!storeDirectoryCheckBox.isSelected()) {
storeDirectoryTextField.setDisable(true);
storeDirectoryTextField.setVisible(false);
}
if(!storeByCreatorCheckBox.isSelected()){
storeByCreatorLabel.setVisible(false);
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -344,14 +344,25 @@ public boolean installBundle(ProductBundle bundle) {
bundle.getProduct().getName(),
bundle.getName());


String baseDirectoryPath = storeService.getBundleInstallFolder(bundle);
String relativeDirectoryPath = this.getPreferences().get(ApplicationDefaults.STORE_DIRECTORY_KEY, "");

Boolean shouldGroupByCreator = this.getPreferences().getBoolean(ApplicationDefaults.STORE_BY_CREATOR_ENABLED_KEY, false);

//if the enduser wishes to group plugins by their creator,
//then we need to include the subdirectory as well.
if(shouldGroupByCreator) {
String creator = FileUtils.sanitizeFileName(bundle.getProduct().getCreator());
relativeDirectoryPath = relativeDirectoryPath + File.separator + creator;
}

File selectedDirectory = null;

// A custom root directory to store plugin is defined
if (this.getPreferences().getBoolean(ApplicationDefaults.STORE_DIRECTORY_ENABLED_KEY, false)) {
// Store install target is already defined

selectedDirectory = new File(baseDirectoryPath, relativeDirectoryPath);

// A plugin root directory is not defined
Expand Down
8 changes: 5 additions & 3 deletions owlplug-client/src/main/resources/fxml/OptionsView.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -100,20 +100,22 @@
<children>
<JFXCheckBox fx:id="syncPluginsCheckBox" text="Sync plugins on application startup" />
<JFXCheckBox fx:id="storeSubDirectoryCheckBox" text="Wrap downloaded plugins in dedicated subdirectories" />

<Label fx:id="warningSubDirectory" styleClass="label-danger" text="Warning: This option is highly recommended. It prevents plugins from being overwritten due to filename collisions." wrapText="true" />
<Label fx:id="warningSubDirectory" styleClass="label-danger" text="Warning: This option is highly recommended. It prevents plugins from being overwritten due to filename collisions." wrapText="true" />
<VBox spacing="5.0" VBox.vgrow="NEVER">
<children>
<JFXCheckBox fx:id="storeDirectoryCheckBox" text="Save dowloaded plugins from store in a dedicated directory" />
<JFXCheckBox fx:id="storeByCreatorCheckBox" text="Save dowloaded plugins grouped by their creator or manufacturer" />
<HBox alignment="BASELINE_LEFT" prefWidth="200.0" VBox.vgrow="NEVER">
<VBox.margin>
<Insets left="5.0" />
</VBox.margin>
<children>
<Label text="\@plugin-directory/" />
<JFXTextField fx:id="storeDirectoryTextField" promptText="subdirectory (optional)" HBox.hgrow="ALWAYS" />
<JFXTextField fx:id="storeDirectoryTextField" promptText="subdirectory (optional)" /><Label fx:id="storeDirectorySeperator" text="/" />
<Label fx:id="storeByCreatorLabel" text="\@creator/" />
</children>
</HBox>

</children>
</VBox>
</children>
Expand Down

0 comments on commit 90456d8

Please sign in to comment.