Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion owlplug-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,23 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
Expand All @@ -72,6 +84,11 @@
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand Down
11 changes: 10 additions & 1 deletion owlplug-client/src/main/java/com/owlplug/OwlPlug.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public class OwlPlug extends Application {
@Autowired
private Environment environment;

private Preferences preferences = Preferences.userRoot().node("com.owlplug.user");
private ConfigurableApplicationContext context;
private Parent rootNode;

Expand All @@ -73,6 +74,10 @@ public void init() throws Exception {
try {
SpringApplicationBuilder builder = new SpringApplicationBuilder(OwlPlug.class);
builder.headless(false);

if(preferences.getBoolean(ApplicationDefaults.DEVELOPER_MODE_ENABLED_KEY, false)) {
builder.profiles("dev-mode");
}
context = builder.run(getParameters().getRaw().toArray(new String[0]));

FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/MainView.fxml"));
Expand All @@ -93,6 +98,10 @@ public void init() throws Exception {
throw e;
} catch (Exception e) {
log.error("OwlPlug could not be started", e);
if(preferences.getBoolean(ApplicationDefaults.DEVELOPER_MODE_ENABLED_KEY, false)) {
log.info("Disabling developer mode after unexpected error during startup");
preferences.putBoolean(ApplicationDefaults.DEVELOPER_MODE_ENABLED_KEY, false);
}
notifyPreloader(new PreloaderProgressMessage("error", "OwlPlug could not be started"));
throw e;
}
Expand Down Expand Up @@ -146,7 +155,7 @@ public DataSource datasource() throws PropertyVetoException {
*/
@Bean
public Preferences getPreference() {
return Preferences.userRoot().node("com.owlplug.user");
return preferences;

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public class ApplicationDefaults {
public static final String STORE_SUBDIRECTORY_ENABLED = "STORE_SUBDIRECTORY_ENABLED";
public static final String FIRST_LAUNCH_KEY = "FIRST_LAUNCH_KEY";
public static final String APPLICATION_STATE_KEY = "APPLICATION_STATE_KEY";
public static final String DEVELOPER_MODE_ENABLED_KEY = "DEVELOPER_MODE_ENABLED_KEY";

/**
* Creates a new ApplicationDefaults.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.owlplug.core.components;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class WebServerContext {

private int port;
@Value("${server.host:@null}")
private String host;
@Value("${server.contextPath:/}")
private String contextPath;

private boolean serverStarted;

public int getPort() {
return port;
}

public void setPort(int port) {
this.port = port;
}

public String getHost() {
return host;
}

public void setHost(String host) {
this.host = host;
}

public String getContextPath() {
return contextPath;
}

public void setContextPath(String contextPath) {
this.contextPath = contextPath;
}

public boolean isServerStarted() {
return serverStarted;
}

public void setServerStarted(boolean serverStarted) {
this.serverStarted = serverStarted;
}

public String getUrl() {
return "http://" + this.host + ":" + this.port + this.contextPath;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.owlplug.core.components;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.context.WebServerInitializedEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

@Component
public class WebServerEventListener implements ApplicationListener<WebServerInitializedEvent> {

@Autowired
private WebServerContext webServerContext;

@Override
public void onApplicationEvent(WebServerInitializedEvent event) {
webServerContext.setPort(event.getWebServer().getPort());
webServerContext.setServerStarted(true);


}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.jfoenix.controls.JFXTextField;
import com.jfoenix.controls.JFXToggleButton;
import com.owlplug.core.components.ApplicationDefaults;
import com.owlplug.core.components.WebServerContext;
import com.owlplug.core.services.NativeHostService;
import com.owlplug.core.services.OptionsService;
import com.owlplug.core.utils.PlatformUtils;
Expand All @@ -46,6 +47,8 @@ public class OptionsController extends BaseController {
private OptionsService optionsService;
@Autowired
private NativeHostService nativeHostService;
@Autowired
private WebServerContext webServerContext;

@FXML
private JFXToggleButton vst2ToggleButton;
Expand Down Expand Up @@ -88,6 +91,14 @@ public class OptionsController extends BaseController {
private Label storeDirectorySeperator;
@FXML
private Hyperlink owlplugWebsiteLink;

@FXML
private JFXCheckBox devModeCheckBox;
@FXML
private JFXTextField devModeTextField;
@FXML
private JFXButton devModeButton;


/**
* FXML initialize method.
Expand Down Expand Up @@ -211,6 +222,19 @@ public void initialize() {
owlplugWebsiteLink.setOnAction(e -> {
PlatformUtils.openDefaultBrowser(owlplugWebsiteLink.getText());
});


devModeCheckBox.selectedProperty().addListener((observable, oldValue, newValue) -> {
this.getPreferences().putBoolean(ApplicationDefaults.DEVELOPER_MODE_ENABLED_KEY, newValue);
devModeTextField.setVisible(newValue);
devModeButton.setVisible(newValue);
});

devModeButton.setOnAction(e -> {
if(webServerContext.isServerStarted()) {
PlatformUtils.openDefaultBrowser(webServerContext.getUrl());
}
});

refreshView();
}
Expand All @@ -237,6 +261,21 @@ public void refreshView() {
if(!storeByCreatorCheckBox.isSelected()){
storeByCreatorLabel.setVisible(false);
}

devModeCheckBox.setSelected(this.getPreferences().getBoolean(ApplicationDefaults.DEVELOPER_MODE_ENABLED_KEY, false));
if(devModeCheckBox.isSelected()) {
devModeTextField.setVisible(true);
devModeButton.setVisible(true);

} else {
devModeTextField.setVisible(false);
devModeButton.setVisible(false);
}

if(webServerContext.isServerStarted()) {
devModeTextField.setText(webServerContext.getUrl());
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,25 @@

package com.owlplug.core.controllers;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.prefs.Preferences;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import com.jfoenix.controls.JFXButton;
import com.jfoenix.controls.JFXTabPane;
import com.jfoenix.controls.JFXTextField;
import com.jfoenix.controls.JFXTreeView;
import com.owlplug.core.components.ApplicationDefaults;
import com.owlplug.core.components.CoreTaskFactory;
import com.owlplug.core.controllers.dialogs.NewLinkController;
import com.owlplug.core.dao.PluginDAO;
import com.owlplug.core.dao.SymlinkDAO;
import com.owlplug.core.model.IDirectory;
import com.owlplug.core.model.Plugin;
Expand All @@ -36,23 +47,14 @@
import com.owlplug.core.ui.CustomTreeCell;
import com.owlplug.core.ui.FilterableTreeItem;
import com.owlplug.core.utils.FileUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.prefs.Preferences;

import javafx.beans.binding.Bindings;
import javafx.fxml.FXML;
import javafx.scene.control.TreeCell;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeView;
import javafx.scene.image.ImageView;
import javafx.util.Callback;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

@Controller
public class PluginsController extends BaseController {
Expand All @@ -62,8 +64,6 @@ public class PluginsController extends BaseController {
@Autowired
private PluginService pluginService;
@Autowired
private PluginDAO pluginDAO;
@Autowired
private SymlinkDAO symlinkDAO;
@Autowired
private NodeInfoController nodeInfoController;
Expand Down Expand Up @@ -159,7 +159,7 @@ public TreeCell<Object> call(TreeView<Object> p) {
public void refreshPlugins() {

treePluginNode.getInternalChildren().clear();
this.pluginList = pluginDAO.findAll();
this.pluginList = pluginService.findAll();

for (Plugin plugin : pluginList) {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.owlplug.core.controllers.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import com.owlplug.core.model.Plugin;
import com.owlplug.core.services.PluginService;

@RestController
public class PluginRestController {

@Autowired
private PluginService pluginService;

@GetMapping("/plugins")
public Iterable<Plugin> plugins() {
return pluginService.findAll();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ public String resolveImageUrl(Plugin plugin) {

}

public Iterable<Plugin> findAll() {
return pluginDAO.findAll();
}

/**
* Removes a plugin reference from database.
* @param plugin - plugin to remoeve
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
spring.main.web-application-type=SERVLET
spring.main.web-environment=true

server.host=127.0.0.1
server.port=0
14 changes: 13 additions & 1 deletion owlplug-client/src/main/resources/fxml/OptionsView.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
</VBox.margin>
<children>
<Label text="\@plugin-directory/" />
<JFXTextField fx:id="storeDirectoryTextField" promptText="subdirectory (optional)" /><Label fx:id="storeDirectorySeperator" text="/" />
<JFXTextField fx:id="storeDirectoryTextField" promptText="subdirectory (optional)" /><Label fx:id="storeDirectorySeperator" text="/" />
<Label fx:id="storeByCreatorLabel" text="\@creator/" />
</children>
</HBox>
Expand All @@ -138,6 +138,18 @@
<Insets />
</VBox.margin>
</VBox>
<VBox spacing="10.0">
<children>
<Label styleClass="heading-2" text="Developer Tools " />
<JFXCheckBox fx:id="devModeCheckBox" text="Enable developer mode" />
<HBox>
<children>
<JFXTextField fx:id="devModeTextField" editable="false" promptText="OwlPlug must be restarted to access developer server" HBox.hgrow="ALWAYS" />
<JFXButton fx:id="devModeButton" text="Access" />
</children>
</HBox>
</children>
</VBox>
<VBox alignment="BOTTOM_LEFT" layoutX="10.0" layoutY="145.0" VBox.vgrow="SOMETIMES">
<children>
<Label styleClass="heading-2" text="About" />
Expand Down