From 4f798839f23e6a410019e0515154e0ea17c5ee42 Mon Sep 17 00:00:00 2001 From: Manfred Karrer Date: Wed, 4 Mar 2015 10:45:22 +0100 Subject: [PATCH] Remove unused files --- .../io/bitsquare/app/gui/UpdateProcess.java | 2 +- .../gui/components/InfoDisplay2.java | 247 ------------------ .../gui/components/dialogs/CustomPopups.java | 105 -------- .../gui/components/dialogs/InfoDialog.java | 131 ---------- .../io/bitsquare/network/NetworkModule.java | 49 ---- 5 files changed, 1 insertion(+), 533 deletions(-) delete mode 100644 gui/src/main/java/io/bitsquare/gui/components/InfoDisplay2.java delete mode 100644 gui/src/main/java/io/bitsquare/gui/components/dialogs/CustomPopups.java delete mode 100644 gui/src/main/java/io/bitsquare/gui/components/dialogs/InfoDialog.java delete mode 100644 gui/src/main/java/io/bitsquare/network/NetworkModule.java diff --git a/gui/src/main/java/io/bitsquare/app/gui/UpdateProcess.java b/gui/src/main/java/io/bitsquare/app/gui/UpdateProcess.java index 174c2bf974..ac573d4c4a 100644 --- a/gui/src/main/java/io/bitsquare/app/gui/UpdateProcess.java +++ b/gui/src/main/java/io/bitsquare/app/gui/UpdateProcess.java @@ -52,7 +52,7 @@ public class UpdateProcess { private static final Logger log = LoggerFactory.getLogger(UpdateProcess.class); // Edit version for updateFX - private static final int VERSION = 12; + private static final int VERSION = 1; private static final List UPDATE_SIGNING_KEYS = Crypto.decode("032D7B4073B0B94F0B0AAD72D4CC2B86FDDE7AAE334DE4BE448B0983D887975289"); private static final String UPDATES_BASE_URL = "http://localhost:8000/"; diff --git a/gui/src/main/java/io/bitsquare/gui/components/InfoDisplay2.java b/gui/src/main/java/io/bitsquare/gui/components/InfoDisplay2.java deleted file mode 100644 index 47ac1424a8..0000000000 --- a/gui/src/main/java/io/bitsquare/gui/components/InfoDisplay2.java +++ /dev/null @@ -1,247 +0,0 @@ -/* - * This file is part of Bitsquare. - * - * Bitsquare is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Bitsquare is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Bitsquare. If not, see . - */ - -package io.bitsquare.gui.components; - -import io.bitsquare.locale.BSResources; - -import javafx.application.Platform; -import javafx.beans.property.IntegerProperty; -import javafx.beans.property.ObjectProperty; -import javafx.beans.property.SimpleIntegerProperty; -import javafx.beans.property.SimpleObjectProperty; -import javafx.beans.property.SimpleStringProperty; -import javafx.beans.property.StringProperty; -import javafx.beans.value.ChangeListener; -import javafx.event.ActionEvent; -import javafx.event.EventHandler; -import javafx.geometry.Insets; -import javafx.geometry.VPos; -import javafx.scene.*; -import javafx.scene.control.*; -import javafx.scene.layout.*; -import javafx.scene.text.*; - -import de.jensd.fx.fontawesome.AwesomeDude; -import de.jensd.fx.fontawesome.AwesomeIcon; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Convenience Component for info icon, info text and link display in a GridPane. - * Only the properties needed are supported. - * We need to extend from Parent so we can use it in FXML, but the InfoDisplay is not used as node, - * but add the children nodes to the gridPane. - */ -public class InfoDisplay2 extends Parent { - private static final Logger log = LoggerFactory.getLogger(InfoDisplay2.class); - - private final StringProperty text = new SimpleStringProperty(); - private final IntegerProperty rowIndex = new SimpleIntegerProperty(0); - private final IntegerProperty columnIndex = new SimpleIntegerProperty(0); - private final ObjectProperty> onAction = new SimpleObjectProperty<>(); - private final ObjectProperty gridPane = new SimpleObjectProperty<>(); - private final Label testLabel; - - private boolean useReadMore; - - private final Label icon = AwesomeDude.createIconLabel(AwesomeIcon.INFO_SIGN); - private final TextFlow textFlow; - private final Label label; - private final Hyperlink link; - private final ChangeListener listener; - - /////////////////////////////////////////////////////////////////////////////////////////// - // Constructor - /////////////////////////////////////////////////////////////////////////////////////////// - - public InfoDisplay2() { - icon.setId("non-clickable-icon"); - icon.visibleProperty().bind(visibleProperty()); - GridPane.setValignment(icon, VPos.TOP); - GridPane.setMargin(icon, new Insets(-2, 0, 0, 0)); - GridPane.setRowSpan(icon, 2); - - label = new Label(); - label.textProperty().bind(text); - label.setTextOverrun(OverrunStyle.WORD_ELLIPSIS); - // width is set a frame later so we hide it first - label.setVisible(false); - - link = new Hyperlink(BSResources.get("shared.readMore")); - link.setPadding(new Insets(0, 0, 0, -2)); - - // We need that to know if we have a wrapping or not. - // Did not find a way to get that from the API. - testLabel = new Label(); - testLabel.textProperty().bind(text); - - textFlow = new TextFlow(); - textFlow.visibleProperty().bind(visibleProperty()); - textFlow.getChildren().addAll(testLabel); - - // update the width when the window gets resized - listener = (ov2, oldValue2, windowWidth) -> { - if (label.prefWidthProperty().isBound()) - label.prefWidthProperty().unbind(); - label.setPrefWidth((double) windowWidth - localToScene(0, 0).getX() - 35); - }; - - - // when clicking "Read more..." we expand and change the link to the Help - link.setOnAction(new EventHandler() { - @Override - public void handle(ActionEvent actionEvent) { - if (useReadMore) { - - label.setWrapText(true); - link.setText(BSResources.get("shared.openHelp")); - getScene().getWindow().widthProperty().removeListener(listener); - if (label.prefWidthProperty().isBound()) - label.prefWidthProperty().unbind(); - label.prefWidthProperty().bind(textFlow.widthProperty()); - link.setVisited(false); - // focus border is a bit confusing here so we remove it - link.setStyle("-fx-focus-color: transparent;"); - link.setOnAction(onAction.get()); - } - else { - onAction.get().handle(actionEvent); - } - } - }); - - managedProperty().addListener((ov, oldValue, newValue) -> { - if (newValue) - layoutItems(); - }); - } - - private void layoutItems() { - testLabel.widthProperty().addListener((ov, o, n) -> { - log.debug("#### testLabel.heightProperty " + testLabel.getHeight()); - log.debug("#### testLabel.widthProperty " + testLabel.getText()); - log.debug("#### testLabel.widthProperty " + n); - log.debug("#### textFlow.getWidth() " + textFlow.getWidth()); - useReadMore = (double) n > textFlow.getWidth(); - link.setText(BSResources.get(useReadMore ? "shared.readMore" : "shared.openHelp")); - - Platform.runLater(() -> textFlow.getChildren().setAll(label, link)); - }); - - sceneProperty().addListener((ov, oldValue, newValue) -> { - if (oldValue == null && newValue != null && newValue.getWindow() != null) { - newValue.getWindow().widthProperty().addListener(listener); - // localToScene does deliver 0 instead of the correct x position when scene property gets set, - // so we delay for 1 render cycle - Platform.runLater(() -> { - log.debug("#### label.setVisible() "); - label.setVisible(true); - label.prefWidthProperty().unbind(); - label.setPrefWidth(newValue.getWindow().getWidth() - localToScene(0, 0).getX() - 35); - }); - } - }); - } - - - /////////////////////////////////////////////////////////////////////////////////////////// - // Setters - /////////////////////////////////////////////////////////////////////////////////////////// - - public void setText(String text) { - this.text.set(text); - layout(); - } - - public void setGridPane(GridPane gridPane) { - this.gridPane.set(gridPane); - - gridPane.getChildren().addAll(icon, textFlow); - - GridPane.setColumnIndex(icon, columnIndex.get()); - GridPane.setColumnIndex(textFlow, columnIndex.get() + 1); - - GridPane.setRowIndex(icon, rowIndex.get()); - GridPane.setRowIndex(textFlow, rowIndex.get()); - } - - public void setRowIndex(int rowIndex) { - this.rowIndex.set(rowIndex); - - GridPane.setRowIndex(icon, rowIndex); - GridPane.setRowIndex(textFlow, rowIndex); - } - - public void setColumnIndex(int columnIndex) { - this.columnIndex.set(columnIndex); - - GridPane.setColumnIndex(icon, columnIndex); - GridPane.setColumnIndex(textFlow, columnIndex + 1); - } - - public final void setOnAction(EventHandler eventHandler) { - onAction.set(eventHandler); - } - - - /////////////////////////////////////////////////////////////////////////////////////////// - // Getters - /////////////////////////////////////////////////////////////////////////////////////////// - - public String getText() { - return text.get(); - } - - public StringProperty textProperty() { - return text; - } - - public int getColumnIndex() { - return columnIndex.get(); - } - - public IntegerProperty columnIndexProperty() { - return columnIndex; - } - - public int getRowIndex() { - return rowIndex.get(); - } - - public IntegerProperty rowIndexProperty() { - return rowIndex; - } - - public EventHandler getOnAction() { - return onAction.get(); - } - - public ObjectProperty> onActionProperty() { - return onAction; - } - - public GridPane getGridPane() { - return gridPane.get(); - } - - public ObjectProperty gridPaneProperty() { - return gridPane; - } - -} diff --git a/gui/src/main/java/io/bitsquare/gui/components/dialogs/CustomPopups.java b/gui/src/main/java/io/bitsquare/gui/components/dialogs/CustomPopups.java deleted file mode 100644 index ac77811946..0000000000 --- a/gui/src/main/java/io/bitsquare/gui/components/dialogs/CustomPopups.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * This file is part of Bitsquare. - * - * Bitsquare is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Bitsquare is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Bitsquare. If not, see . - */ - -package io.bitsquare.gui.components.dialogs; - -import io.bitsquare.gui.OverlayManager; - -import javafx.geometry.Insets; -import javafx.geometry.Pos; -import javafx.scene.*; -import javafx.scene.control.*; -import javafx.scene.layout.*; -import javafx.stage.Modality; -import javafx.stage.Stage; -import javafx.stage.StageStyle; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class CustomPopups { - private static final Logger log = LoggerFactory.getLogger(CustomPopups.class); - - private final Stage rootStage; - private final OverlayManager overlayManager; - private final Stage stage = new Stage(); - private StackPane sceneRootPane; - - public CustomPopups(Stage rootStage, OverlayManager overlayManager) { - this.rootStage = rootStage; - this.overlayManager = overlayManager; - - setupStage(); - } - - public void showInfoPopup(String title, String message) { - BorderPane borderPane = new BorderPane(); - borderPane.setMinWidth(400); - borderPane.setMinHeight(150); - borderPane.setMaxWidth(rootStage.getWidth() / 2); - borderPane.setMaxHeight(rootStage.getHeight() / 2); - borderPane.setPadding(new Insets(20, 20, 20, 20)); - borderPane.setStyle("-fx-background-color: #ffffff;"); - - Label titleLabel = new Label(title); - titleLabel.setMouseTransparent(true); - BorderPane.setAlignment(titleLabel, Pos.TOP_CENTER); - borderPane.setTop(titleLabel); - titleLabel.setStyle("-fx-font-size: 16; -fx-font-weight: bold; -fx-text-fill: #333333;"); - - Label messageLabel = new Label(message); - messageLabel.setWrapText(true); - messageLabel.setMouseTransparent(true); - borderPane.setCenter(messageLabel); - messageLabel.setStyle("-fx-font-size: 12; -fx-text-fill: #000000;"); - messageLabel.setPadding(new Insets(20, 0, 30, 0)); - - Button closeButton = getCloseButton(); - BorderPane.setAlignment(closeButton, Pos.BOTTOM_RIGHT); - borderPane.setBottom(closeButton); - - show(borderPane); - } - - private void setupStage() { - stage.initModality(Modality.WINDOW_MODAL); - stage.initStyle(StageStyle.UNDECORATED); - stage.initOwner(rootStage); - - sceneRootPane = new StackPane(); - Scene scene = new Scene(sceneRootPane); - scene.getStylesheets().setAll(getClass().getResource("/io/bitsquare/gui/bitsquare.css").toExternalForm(), - getClass().getResource("/io/bitsquare/gui/images.css").toExternalForm()); - stage.setScene(scene); - } - - private void hide() { - stage.hide(); - } - - private void show(Pane pane) { - sceneRootPane.getChildren().setAll(pane); - stage.show(); - } - - private Button getCloseButton() { - Button closeButton = new Button("Close"); - closeButton.setDefaultButton(true); - closeButton.setOnAction(e -> hide()); - return closeButton; - } -} diff --git a/gui/src/main/java/io/bitsquare/gui/components/dialogs/InfoDialog.java b/gui/src/main/java/io/bitsquare/gui/components/dialogs/InfoDialog.java deleted file mode 100644 index 4f2b5947a7..0000000000 --- a/gui/src/main/java/io/bitsquare/gui/components/dialogs/InfoDialog.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * This file is part of Bitsquare. - * - * Bitsquare is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Bitsquare is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Bitsquare. If not, see . - */ - -package io.bitsquare.gui.components.dialogs; - -import io.bitsquare.locale.BSResources; - -import java.util.ArrayList; -import java.util.List; - -import javax.inject.Inject; - -import javafx.application.Platform; -import javafx.event.ActionEvent; -import javafx.geometry.Insets; -import javafx.scene.control.*; -import javafx.scene.image.*; -import javafx.scene.layout.*; -import javafx.stage.Stage; - -import org.controlsfx.control.ButtonBar; -import org.controlsfx.control.action.AbstractAction; -import org.controlsfx.control.action.Action; -import org.controlsfx.dialog.Dialog; -import org.controlsfx.dialog.DialogStyle; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -// TODO under construction -public class InfoDialog { - private static final Logger log = LoggerFactory.getLogger(InfoDialog.class); - - /////////////////////////////////////////////////////////////////////////////////////////// - // Constructor - /////////////////////////////////////////////////////////////////////////////////////////// - - @Inject - public InfoDialog(Stage stage) { - - final TextField username = new TextField(); - final PasswordField password = new PasswordField(); - final Action actionLogin = new AbstractAction("Login") { - // This method is called when the login button is clicked ... - public void handle(ActionEvent ae) { - Dialog d = (Dialog) ae.getSource(); - // Do the login here. - d.hide(); - } - }; - - // Create the custom dialog. - Dialog dlg = new Dialog(stage, "Login Dialog"); - dlg.setIconifiable(false); - dlg.setClosable(false); - dlg.setResizable(false); - GridPane grid = new GridPane(); - grid.setHgap(10); - grid.setVgap(10); - grid.setPadding(new Insets(0, 10, 0, 10)); - - username.setPromptText("Username"); - password.setPromptText("Password"); - - grid.add(new Label("Username:"), 0, 0); - grid.add(username, 1, 0); - grid.add(new Label("Password:"), 0, 1); - grid.add(password, 1, 1); - - ButtonBar.setType(actionLogin, ButtonBar.ButtonType.OK_DONE); - actionLogin.disabledProperty().set(true); - - // Do some validation (using the Java 8 lambda syntax). - username.textProperty().addListener((observable, oldValue, newValue) -> actionLogin.disabledProperty().set(newValue.trim().isEmpty())); - - dlg.setMasthead("Look, a Custom Login Dialog"); - dlg.setContent(grid); - dlg.getActions().addAll(actionLogin, Dialog.Actions.CANCEL); - - // Request focus on the username field by default. - Platform.runLater(username::requestFocus); - - dlg.show(); - } - - - /////////////////////////////////////////////////////////////////////////////////////////// - // Public methods - /////////////////////////////////////////////////////////////////////////////////////////// - - public void show(Object owner, String title, String masthead, String message) { - - Dialog dlg = new Dialog(owner, title, false, DialogStyle.CROSS_PLATFORM_DARK); - dlg.setResizable(false); - dlg.setIconifiable(false); - dlg.setClosable(false); - - Image image = new Image(InfoDialog.class.getResource - ("/impl/org/controlsfx/dialog/resources/oxygen/48/dialog-information.png").toString()); - if (image != null) { - dlg.setGraphic(new ImageView(image)); - } - dlg.setMasthead(masthead); - List actions = new ArrayList<>(); - actions.add(new AbstractAction(BSResources.get("shared.close")) { - @Override - public void handle(ActionEvent actionEvent) { - getProperties().put("type", "CLOSE"); - Dialog.Actions.CLOSE.handle(actionEvent); - // overlayManager.removeBlurContent(); - } - }); - dlg.getActions().addAll(actions); - // dlg.setBackgroundEffect(backgroundEffect); - } - -} diff --git a/gui/src/main/java/io/bitsquare/network/NetworkModule.java b/gui/src/main/java/io/bitsquare/network/NetworkModule.java deleted file mode 100644 index 788af27a63..0000000000 --- a/gui/src/main/java/io/bitsquare/network/NetworkModule.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * This file is part of Bitsquare. - * - * Bitsquare is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Bitsquare is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Bitsquare. If not, see . - */ - -package io.bitsquare.network; - -import io.bitsquare.BitsquareModule; -import io.bitsquare.msg.MessageService; - -import com.google.inject.Injector; - -import org.springframework.core.env.Environment; - -public abstract class NetworkModule extends BitsquareModule { - - protected NetworkModule(Environment env) { - super(env); - } - - @Override - protected final void configure() { - bind(MessageService.class).to(messageService()).asEagerSingleton(); - - doConfigure(); - } - - protected void doConfigure() { - } - - protected abstract Class messageService(); - - @Override - protected void doClose(Injector injector) { - injector.getInstance(MessageService.class).shutDown(); - } -}