Made client compatible with new provider

This commit is contained in:
JKetelaar
2015-04-12 15:59:59 +02:00
parent 749e5baa1d
commit 4ecee0e9b8
10 changed files with 222 additions and 418 deletions
+3
View File
@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: org.parabot.Landing
@@ -7,7 +7,6 @@ import org.parabot.core.ui.utils.UILog;
import org.parabot.environment.api.utils.WebUtil;
import javax.swing.*;
import java.io.BufferedReader;
import java.net.MalformedURLException;
import java.net.URL;
@@ -21,27 +20,35 @@ import java.util.Properties;
*
*/
public class ServerProviderInfo {
private Properties settings;
private Properties properties;
public ServerProviderInfo(URL providerInfo, String username, String password) {
this.properties = new Properties();
this.settings = new Properties();
try {
String line;
Core.verbose("Reading info: " + providerInfo);
BufferedReader br = WebUtil.getReader(new URL(providerInfo.toString()), username, password);
//TODO Make this one line (web sided)
JSONParser parser = new JSONParser();
if ((line = br.readLine()) != null) {
JSONObject jsonObject = (JSONObject) parser.parse(line);
for (Object o : jsonObject.entrySet()) {
Map.Entry<?, ?> pairs = (Map.Entry<?, ?>) o;
properties.put(String.valueOf(pairs.getKey()), String.valueOf(pairs.getValue()));
if (String.valueOf(pairs.getKey()).equalsIgnoreCase("settings")){
settings.putAll((JSONObject) pairs.getValue());
}else {
properties.put(String.valueOf(pairs.getKey()), String.valueOf(pairs.getValue()));
}
}
} else {
UILog.log(
"Error",
"Failed to load server provider, error: [No information about the provider found.]",
JOptionPane.ERROR_MESSAGE);
"Error",
"Failed to load server provider, error: [No information about the provider found.]",
JOptionPane.ERROR_MESSAGE);
return;
}
br.close();
@@ -100,4 +107,8 @@ public class ServerProviderInfo {
public Properties getProperties() {
return this.properties;
}
public Properties getSettings(){
return this.settings;
}
}
@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="500.0" minWidth="500.0" prefHeight="503.0" prefWidth="735.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
<top>
<MenuBar BorderPane.alignment="CENTER">
<menus>
<Menu mnemonicParsing="false" text="File">
<items>
<MenuItem mnemonicParsing="false" text="Close" />
</items>
</Menu>
<Menu mnemonicParsing="false" text="Edit">
<items>
<MenuItem mnemonicParsing="false" text="Delete" />
</items>
</Menu>
<Menu mnemonicParsing="false" text="Help">
<items>
<MenuItem mnemonicParsing="false" text="About" />
</items>
</Menu>
</menus>
</MenuBar>
</top>
<center>
<TabPane>
<tabs>
<Tab closable="false" text="Scripts">
<content>
<BorderPane prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER">
<top>
<ToolBar prefHeight="40.0" prefWidth="200.0" BorderPane.alignment="CENTER">
<items>
<TextField promptText="Search query" />
<Separator prefHeight="30.0" prefWidth="25.0" visible="false" />
<ComboBox prefWidth="150.0" promptText="Category" />
<Separator prefHeight="30.0" prefWidth="25.0" visible="false" />
<CheckBox mnemonicParsing="false" text="All servers" />
<Separator prefHeight="30.0" prefWidth="25.0" visible="false" />
<CheckBox mnemonicParsing="false" text="Include local scripts" />
<Separator prefHeight="30.0" prefWidth="25.0" visible="false" />
<Button alignment="CENTER_RIGHT" mnemonicParsing="false" text="Search" />
</items>
</ToolBar>
</top>
<center>
<TableView prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER">
<columns>
<TableColumn prefWidth="75.0" text="Name" />
<TableColumn prefWidth="75.0" text="Category" />
<TableColumn prefWidth="75.0" text="Price" />
</columns>
<contextMenu>
<ContextMenu>
<items>
<MenuItem mnemonicParsing="false" text="View information" />
</items>
</ContextMenu>
</contextMenu>
</TableView>
</center>
<bottom>
<HBox alignment="CENTER_RIGHT" prefHeight="35.0" prefWidth="735.0" BorderPane.alignment="CENTER">
<children>
<Button mnemonicParsing="false" prefHeight="25.0" prefWidth="83.0" text="Start" />
<Separator prefHeight="4.0" prefWidth="35.0" visible="false" />
</children>
</HBox>
</bottom>
</BorderPane>
</content>
</Tab>
<Tab text="JKChicken">
<content>
<BorderPane prefHeight="200.0" prefWidth="200.0" />
</content>
</Tab>
</tabs>
</TabPane>
</center>
</BorderPane>