Skip to content

Commit

Permalink
Main module converted to root module and testing is done
Browse files Browse the repository at this point in the history
  • Loading branch information
Nafeez Abrar committed Oct 6, 2016
1 parent 9d56646 commit da3dc0f
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 14 deletions.
4 changes: 2 additions & 2 deletions main/build.gradle → build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
group 'com.nafeezabrar'
version '1.0-SNAPSHOT'
version '0.0.0-Alpha-Testing'

apply plugin: 'java'
apply plugin: 'application'

mainClassName = "com.nafeezabrar.mqtt.client.Main"
mainClassName = "Main"

repositories {
mavenCentral()
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include 'main'
rootProject.name = 'mqtt-client'
include 'ui'
include 'core'
include 'paho-mqtt'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.nafeezabrar.mqtt.client;

import com.nafeezabrar.mqtt.client.MqttClient;
import com.nafeezabrar.mqtt.client.PahoMqttClientWrapper;
import com.nafeezabrar.mqtt.client.conversion.AnySeparatorStringToBytesConverter;
import com.nafeezabrar.mqtt.client.conversion.BytesToStringConverter;
import com.nafeezabrar.mqtt.client.conversion.DecimalColonSeparatorBytesToStringConverter;
Expand All @@ -8,23 +8,24 @@
import com.nafeezabrar.mqtt.client.ui.MqttClientWindow;
import com.nafeezabrar.mqtt.client.ui.UiApplication;

import java.io.IOException;
import java.util.UUID;

public class Main {

public static void main(String[] args) {
public static void main(String[] args) throws IOException {
String serverURI = "tcp://iot.eclipse.org:1883";
String clientId = UUID.randomUUID().toString();
MqttClient mqttClient = new PahoMqttClientWrapper(serverURI, clientId);

UiApplication.viewActivatedListener = () -> {
MqttClientWindow mqttClientWindow = UiApplication.ActualWindow;
StringToBytesConverter stringToBytesConverter = new AnySeparatorStringToBytesConverter();
BytesToStringConverter bytesToStringConverter = new DecimalColonSeparatorBytesToStringConverter();
MqttClient mqttClient = new PahoMqttClientWrapper(serverURI, clientId);
MqttClientWindowPresenter mqttClientWindowPresenter = new MqttClientWindowPresenter(mqttClientWindow, stringToBytesConverter, bytesToStringConverter, mqttClient);
mqttClientWindowPresenter.initialize();
};

UiApplication.run(args);
UiApplication.run(args, (Class) Main.class);
mqttClient.close();
}
}
File renamed without changes.
22 changes: 22 additions & 0 deletions src/main/resources/main.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.ListView?>
<?import javafx.scene.control.TextArea?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>

<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="631.0" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.nafeezabrar.mqtt.client.ui.controllers.MainController">
<children>
<Label layoutX="23.0" layoutY="37.0" text="Topic" />
<TextField fx:id="topicTextField" layoutX="99.0" layoutY="32.0" prefHeight="27.0" prefWidth="286.0" promptText="Topic of sending message" />
<Label layoutX="23.0" layoutY="89.0" text="Message" />
<TextField fx:id="messageTextField" layoutX="99.0" layoutY="84.0" prefHeight="27.0" prefWidth="286.0" promptText="Message to send" />
<Button fx:id="sendButton" layoutX="335.0" layoutY="124.0" mnemonicParsing="false" onAction="#sendButtonAction" text="Send" />
<Label layoutX="23.0" layoutY="183.0" text="Topic Filters" />
<TextArea fx:id="topicFiltersTextArea" layoutX="23.0" layoutY="216.0" prefHeight="112.0" prefWidth="361.0" promptText="Topics to subscribed" />
<Button fx:id="subscribeButton" layoutX="305.0" layoutY="335.0" mnemonicParsing="false" onAction="#subscribedButtonAction" text="Subscribe" />
<ListView fx:id="receivedMessagesListView" layoutX="403.0" layoutY="17.0" prefHeight="366.0" prefWidth="208.0" />
</children>
</AnchorPane>
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
import com.nafeezabrar.mqtt.client.ui.libs.ViewRenderer;
import com.nafeezabrar.mqtt.client.ui.libs.ViewSwitcher;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.stage.Stage;

public class UiApplication extends Application {

public static MqttClientWindow ActualWindow;
public static ViewActivatedListener viewActivatedListener;
private static Class loaderClass;

@Override
public void start(Stage primaryStage) throws Exception {
SceneLoader sceneLoader = new SceneLoader();
SceneLoader sceneLoader = new SceneLoader(loaderClass);
SceneFactory sceneFactory = new SceneFactory();
ViewRenderer viewRender = new ViewRenderer(primaryStage, sceneLoader, sceneFactory);
ViewSwitcher viewSwitcher = new ViewSwitcher(viewRender);
Expand All @@ -25,7 +25,8 @@ public void start(Stage primaryStage) throws Exception {
primaryStage.show();
}

public static void run(String[] args) {
public static void run(String[] args, Class loaderClass) {
UiApplication.loaderClass = loaderClass;
launch(args);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@


public class SceneLoader {
private Class loaderClass;

public SceneLoader(Class loaderClass) {
this.loaderClass = loaderClass;
}

public Parent loadView(String fxmlFileName) {
try {
return FXMLLoader.load(getClass().getResource(fxmlFileName));
return FXMLLoader.load(loaderClass.getResource(fxmlFileName));
} catch (IOException e) {
e.printStackTrace();
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public ViewSwitcher(ViewRenderer renderer) {
}

public void switchToMainView() {
renderer.renderView("../../../../../../main.fxml", 950, 700);
renderer.renderView("main.fxml", 950, 700);
renderer.setTitle("MQTT Client");
}
}

0 comments on commit da3dc0f

Please sign in to comment.