diff --git a/gui/src/main/java/com/repoachiever/entity/PropertiesEntity.java b/gui/src/main/java/com/repoachiever/entity/PropertiesEntity.java index 3065a25..9fd0cf1 100644 --- a/gui/src/main/java/com/repoachiever/entity/PropertiesEntity.java +++ b/gui/src/main/java/com/repoachiever/entity/PropertiesEntity.java @@ -161,12 +161,21 @@ public class PropertiesEntity { @Value(value = "${image.download.name}") private String imageDownloadName; + @Value(value = "${image.topology.name}") + private String imageTopologyName; + @Value(value = "${image.edit.name}") private String imageEditName; @Value(value = "${image.open.name}") private String imageOpenName; + @Value(value = "${image.active.name}") + private String imageActiveName; + + @Value(value = "${image.non-active.name}") + private String imageNonActiveName; + @Value(value = "${image.bar.width}") private Integer imageBarWidth; @@ -191,12 +200,21 @@ public class PropertiesEntity { @Value(value = "${button.download.description}") private String buttonDownloadDescription; + @Value(value = "${button.topology.description}") + private String buttonTopologyDescription; + @Value(value = "${button.edit.description}") private String buttonEditDescription; @Value(value = "${button.open.description}") private String buttonOpenDescription; + @Value(value = "${label.active.description}") + private String labelActiveDescription; + + @Value(value = "${label.non-active.description}") + private String labelNonActiveDescription; + @Value(value = "${label.connection-status-success.description}") private String labelConnectionStatusSuccessDescription; @@ -233,12 +251,6 @@ public class PropertiesEntity { @Value(value = "${alert.editor-close-reminder.message}") private String alertEditorCloseReminderMessage; - @Value(value = "${graph.css.location}") - private String graphCssFileLocation; - - @Value(value = "${graph.properties.location}") - private String graphPropertiesLocation; - @Value(value = "${config.default.directory}") private String configDefaultDirectory; diff --git a/gui/src/main/java/com/repoachiever/exception/SmartGraphCssFileNotFoundException.java b/gui/src/main/java/com/repoachiever/exception/SmartGraphCssFileNotFoundException.java deleted file mode 100644 index 73390d6..0000000 --- a/gui/src/main/java/com/repoachiever/exception/SmartGraphCssFileNotFoundException.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.repoachiever.exception; - -import java.io.FileNotFoundException; -import java.util.Arrays; -import java.util.Formatter; - -/** - * Represents exception used when smart graph css file was not found. - */ -public class SmartGraphCssFileNotFoundException extends FileNotFoundException { - public SmartGraphCssFileNotFoundException(Object... message) { - super( - new Formatter() - .format("SmartGraph CSS file at the given location is not found: %s", - Arrays.stream(message).toArray()) - .toString()); - } -} diff --git a/gui/src/main/java/com/repoachiever/exception/SmartGraphPropertiesFileNotFoundException.java b/gui/src/main/java/com/repoachiever/exception/SmartGraphPropertiesFileNotFoundException.java deleted file mode 100644 index 3f85db0..0000000 --- a/gui/src/main/java/com/repoachiever/exception/SmartGraphPropertiesFileNotFoundException.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.repoachiever.exception; - -import java.io.FileNotFoundException; -import java.util.Arrays; -import java.util.Formatter; - -/** - * Represents exception used when smart graph properties file was not found. - */ -public class SmartGraphPropertiesFileNotFoundException extends FileNotFoundException { - public SmartGraphPropertiesFileNotFoundException(Object... message) { - super( - new Formatter() - .format("SmartGraph properties file at the given location is not found: %s", - Arrays.stream(message).toArray()) - .toString()); - } -} diff --git a/gui/src/main/java/com/repoachiever/service/element/graph/GraphVisualizer.java b/gui/src/main/java/com/repoachiever/service/element/graph/GraphVisualizer.java deleted file mode 100644 index 0eae3bc..0000000 --- a/gui/src/main/java/com/repoachiever/service/element/graph/GraphVisualizer.java +++ /dev/null @@ -1,109 +0,0 @@ -package com.repoachiever.service.element.graph; - -import com.brunomnsilva.smartgraph.graph.Graph; -import com.brunomnsilva.smartgraph.graph.GraphEdgeList; -import com.brunomnsilva.smartgraph.graphview.SmartCircularSortedPlacementStrategy; -import com.brunomnsilva.smartgraph.graphview.SmartGraphPanel; -import com.brunomnsilva.smartgraph.graphview.SmartGraphProperties; -import com.brunomnsilva.smartgraph.graphview.SmartPlacementStrategy; -import com.repoachiever.entity.PropertiesEntity; -import com.repoachiever.exception.SmartGraphCssFileNotFoundException; -import com.repoachiever.exception.SmartGraphPropertiesFileNotFoundException; -import com.repoachiever.service.element.storage.ElementStorage; -import com.repoachiever.service.element.text.common.IElement; -import com.repoachiever.service.element.text.common.IElementResizable; -import java.io.InputStream; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; -import java.util.Objects; -import java.util.UUID; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service -public class GraphVisualizer - implements IElementResizable, IElement> { - private final UUID id = UUID.randomUUID(); - - public GraphVisualizer(@Autowired PropertiesEntity properties) - throws SmartGraphCssFileNotFoundException, SmartGraphPropertiesFileNotFoundException { - Graph g = new GraphEdgeList<>(); - g.insertVertex("A"); - g.insertVertex("B"); - g.insertVertex("C"); - g.insertVertex("D"); - g.insertVertex("E"); - g.insertVertex("F"); - g.insertVertex("G"); - - g.insertEdge("A", "B", "1"); - g.insertEdge("A", "C", "2"); - g.insertEdge("A", "D", "3"); - g.insertEdge("A", "E", "4"); - g.insertEdge("A", "F", "5"); - g.insertEdge("A", "G", "6"); - - g.insertVertex("H"); - g.insertVertex("I"); - g.insertVertex("J"); - g.insertVertex("K"); - g.insertVertex("L"); - g.insertVertex("M"); - g.insertVertex("N"); - - g.insertEdge("H", "I", "7"); - g.insertEdge("H", "J", "8"); - g.insertEdge("H", "K", "9"); - g.insertEdge("H", "L", "10"); - g.insertEdge("H", "M", "11"); - g.insertEdge("H", "N", "12"); - - g.insertEdge("A", "H", "0"); - - SmartPlacementStrategy strategy = new SmartCircularSortedPlacementStrategy(); - - ClassLoader classLoader = getClass().getClassLoader(); - - InputStream smartGraphPropertiesInputStream = - classLoader.getResourceAsStream(properties.getGraphPropertiesLocation()); - if (Objects.isNull(smartGraphPropertiesInputStream)) { - throw new SmartGraphPropertiesFileNotFoundException(); - } - - SmartGraphProperties smartGraphProperties = - new SmartGraphProperties(smartGraphPropertiesInputStream); - - URL smartGraphCssFileLocationURL = - classLoader.getResource(properties.getGraphCssFileLocation()); - if (Objects.isNull(smartGraphCssFileLocationURL)) { - throw new SmartGraphCssFileNotFoundException(); - } - - URI smartGraphCssFileLocationURI; - try { - smartGraphCssFileLocationURI = smartGraphCssFileLocationURL.toURI(); - } catch (URISyntaxException e) { - throw new SmartGraphCssFileNotFoundException(e.getMessage()); - } - - ElementStorage.setElement( - id, new SmartGraphPanel<>(g, smartGraphProperties, strategy, smartGraphCssFileLocationURI)); - } - - /** - * @return - */ - @Override - public SmartGraphPanel getContent() { - return ElementStorage.getElement(id); - } - - /** */ - @Override - public void handlePrefWidth() {} - - /** */ - @Override - public void handlePrefHeight() {} -} diff --git a/gui/src/main/java/com/repoachiever/service/element/image/view/common/ActiveImageView.java b/gui/src/main/java/com/repoachiever/service/element/image/view/common/ActiveImageView.java new file mode 100644 index 0000000..3ba7d88 --- /dev/null +++ b/gui/src/main/java/com/repoachiever/service/element/image/view/common/ActiveImageView.java @@ -0,0 +1,77 @@ +package com.repoachiever.service.element.image.view.common; + +import com.repoachiever.entity.PropertiesEntity; +import com.repoachiever.exception.ApplicationImageFileNotFoundException; +import com.repoachiever.service.element.common.ElementHelper; +import com.repoachiever.service.element.image.collection.ConnectionStatusImageCollection; +import com.repoachiever.service.element.storage.ElementStorage; +import com.repoachiever.service.element.text.common.IElement; +import com.repoachiever.service.element.text.common.IElementActualizable; +import com.repoachiever.service.element.text.common.IElementResizable; +import com.repoachiever.service.state.StateService; +import javafx.application.Platform; +import javafx.geometry.Pos; +import javafx.scene.control.Button; +import javafx.scene.control.SplitPane; +import javafx.scene.control.Tooltip; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; +import javafx.scene.layout.Background; +import javafx.scene.layout.BorderPane; +import javafx.scene.paint.Color; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.io.InputStream; +import java.util.Objects; +import java.util.UUID; + +/** + * Represents active image view. + */ +public class ActiveImageView implements IElement { + private final UUID id = UUID.randomUUID(); + + public ActiveImageView(PropertiesEntity properties) throws ApplicationImageFileNotFoundException { + Button button = new Button(); + + button.setDisable(true); + + InputStream imageSource = + getClass().getClassLoader().getResourceAsStream(properties.getImageActiveName()); + if (Objects.isNull(imageSource)) { + throw new ApplicationImageFileNotFoundException(); + } + + ImageView imageView = new ImageView(new Image(imageSource)); + imageView.setFitHeight(properties.getImageBarHeight()); + imageView.setFitWidth(properties.getImageBarWidth()); + + button.setGraphic(imageView); + + button.setAlignment(Pos.CENTER_RIGHT); + + SplitPane splitPane = new SplitPane(button); + splitPane.setTooltip(new Tooltip(properties.getLabelActiveDescription())); + + splitPane.setBackground( + Background.fill( + Color.rgb( + properties.getCommonSceneHeaderConnectionStatusBackgroundColorR(), + properties.getCommonSceneHeaderConnectionStatusBackgroundColorG(), + properties.getCommonSceneHeaderConnectionStatusBackgroundColorB()))); + + BorderPane borderPane = new BorderPane(); + borderPane.setRight(splitPane); + + ElementStorage.setElement(id, borderPane); + } + + /** + * @see IElementActualizable + */ + @Override + public BorderPane getContent() { + return ElementStorage.getElement(id); + } +} diff --git a/gui/src/main/java/com/repoachiever/service/element/image/view/common/ApplyImageView.java b/gui/src/main/java/com/repoachiever/service/element/image/view/common/ApplyImageView.java index 5556b7b..19b641d 100644 --- a/gui/src/main/java/com/repoachiever/service/element/image/view/common/ApplyImageView.java +++ b/gui/src/main/java/com/repoachiever/service/element/image/view/common/ApplyImageView.java @@ -26,7 +26,7 @@ /** Represents apply image view. */ @Service -public class ApplyImageView implements IElementResizable, IElement { +public class ApplyImageView implements IElement { private final UUID id = UUID.randomUUID(); public ApplyImageView( @@ -64,7 +64,6 @@ public ApplyImageView( borderPane.setRight(splitPane); ElementStorage.setElement(id, borderPane); - ElementStorage.setResizable(this); } /** @@ -74,16 +73,4 @@ public ApplyImageView( public BorderPane getContent() { return ElementStorage.getElement(id); } - - /** - * @see IElementResizable - */ - @Override - public void handlePrefWidth() {} - - /** - * @see IElementResizable - */ - @Override - public void handlePrefHeight() {} } diff --git a/gui/src/main/java/com/repoachiever/service/element/image/view/common/CleanAllImageView.java b/gui/src/main/java/com/repoachiever/service/element/image/view/common/CleanAllImageView.java index 896b77e..2d86560 100644 --- a/gui/src/main/java/com/repoachiever/service/element/image/view/common/CleanAllImageView.java +++ b/gui/src/main/java/com/repoachiever/service/element/image/view/common/CleanAllImageView.java @@ -28,7 +28,7 @@ /** Represents cleanall image view. */ @Service -public class CleanAllImageView implements IElementResizable, IElement { +public class CleanAllImageView implements IElement { private final UUID id = UUID.randomUUID(); public CleanAllImageView( @@ -66,7 +66,6 @@ public CleanAllImageView( borderPane.setRight(splitPane); ElementStorage.setElement(id, borderPane); - ElementStorage.setResizable(this); } /** @@ -76,16 +75,4 @@ public CleanAllImageView( public BorderPane getContent() { return ElementStorage.getElement(id); } - - /** - * @see IElementResizable - */ - @Override - public void handlePrefWidth() {} - - /** - * @see IElementResizable - */ - @Override - public void handlePrefHeight() {} } diff --git a/gui/src/main/java/com/repoachiever/service/element/image/view/common/CleanImageView.java b/gui/src/main/java/com/repoachiever/service/element/image/view/common/CleanImageView.java index c67fef6..fc1a223 100644 --- a/gui/src/main/java/com/repoachiever/service/element/image/view/common/CleanImageView.java +++ b/gui/src/main/java/com/repoachiever/service/element/image/view/common/CleanImageView.java @@ -27,7 +27,7 @@ import java.util.UUID; /** Represents clean image view. */ -public class CleanImageView implements IElementResizable, IElement { +public class CleanImageView implements IElement { private final UUID id = UUID.randomUUID(); public CleanImageView( @@ -66,7 +66,6 @@ public CleanImageView( borderPane.setRight(splitPane); ElementStorage.setElement(id, borderPane); - ElementStorage.setResizable(this); } /** @@ -76,16 +75,4 @@ public CleanImageView( public BorderPane getContent() { return ElementStorage.getElement(id); } - - /** - * @see IElementResizable - */ - @Override - public void handlePrefWidth() {} - - /** - * @see IElementResizable - */ - @Override - public void handlePrefHeight() {} } diff --git a/gui/src/main/java/com/repoachiever/service/element/image/view/common/ConnectionStatusImageView.java b/gui/src/main/java/com/repoachiever/service/element/image/view/common/ConnectionStatusImageView.java index db8084b..f180e13 100644 --- a/gui/src/main/java/com/repoachiever/service/element/image/view/common/ConnectionStatusImageView.java +++ b/gui/src/main/java/com/repoachiever/service/element/image/view/common/ConnectionStatusImageView.java @@ -31,6 +31,7 @@ public class ConnectionStatusImageView public ConnectionStatusImageView(@Autowired PropertiesEntity properties) { Button button = new Button(); + button.setDisable(true); button.setAlignment(Pos.CENTER_RIGHT); diff --git a/gui/src/main/java/com/repoachiever/service/element/image/view/common/DownloadImageView.java b/gui/src/main/java/com/repoachiever/service/element/image/view/common/DownloadImageView.java index 8131869..75d503d 100644 --- a/gui/src/main/java/com/repoachiever/service/element/image/view/common/DownloadImageView.java +++ b/gui/src/main/java/com/repoachiever/service/element/image/view/common/DownloadImageView.java @@ -29,7 +29,7 @@ /** * Represents download image view. */ -public class DownloadImageView implements IElementResizable, IElement { +public class DownloadImageView implements IElement { private final UUID id = UUID.randomUUID(); public DownloadImageView( @@ -77,7 +77,6 @@ public DownloadImageView( borderPane.setRight(splitPane); ElementStorage.setElement(id, borderPane); - ElementStorage.setResizable(this); } /** @@ -87,18 +86,4 @@ public DownloadImageView( public BorderPane getContent() { return ElementStorage.getElement(id); } - - /** - * @see IElementResizable - */ - @Override - public void handlePrefWidth() { - } - - /** - * @see IElementResizable - */ - @Override - public void handlePrefHeight() { - } } diff --git a/gui/src/main/java/com/repoachiever/service/element/image/view/common/EditImageView.java b/gui/src/main/java/com/repoachiever/service/element/image/view/common/EditImageView.java index e27cfac..eaafcbe 100644 --- a/gui/src/main/java/com/repoachiever/service/element/image/view/common/EditImageView.java +++ b/gui/src/main/java/com/repoachiever/service/element/image/view/common/EditImageView.java @@ -26,7 +26,7 @@ /** Represents edit image view. */ @Service -public class EditImageView implements IElementResizable, IElement { +public class EditImageView implements IElement { private final UUID id = UUID.randomUUID(); public EditImageView( @@ -64,7 +64,6 @@ public EditImageView( borderPane.setRight(splitPane); ElementStorage.setElement(id, borderPane); - ElementStorage.setResizable(this); } /** @@ -74,16 +73,4 @@ public EditImageView( public BorderPane getContent() { return ElementStorage.getElement(id); } - - /** - * @see IElementResizable - */ - @Override - public void handlePrefWidth() {} - - /** - * @see IElementResizable - */ - @Override - public void handlePrefHeight() {} } diff --git a/gui/src/main/java/com/repoachiever/service/element/image/view/common/NonActiveImageView.java b/gui/src/main/java/com/repoachiever/service/element/image/view/common/NonActiveImageView.java new file mode 100644 index 0000000..5642f48 --- /dev/null +++ b/gui/src/main/java/com/repoachiever/service/element/image/view/common/NonActiveImageView.java @@ -0,0 +1,72 @@ +package com.repoachiever.service.element.image.view.common; + +import com.repoachiever.entity.PropertiesEntity; +import com.repoachiever.exception.ApplicationImageFileNotFoundException; +import com.repoachiever.service.element.storage.ElementStorage; +import com.repoachiever.service.element.text.common.IElement; +import com.repoachiever.service.element.text.common.IElementActualizable; +import javafx.geometry.Pos; +import javafx.scene.control.Button; +import javafx.scene.control.SplitPane; +import javafx.scene.control.Tooltip; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; +import javafx.scene.layout.Background; +import javafx.scene.layout.BorderPane; +import javafx.scene.paint.Color; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.io.InputStream; +import java.util.Objects; +import java.util.UUID; + +/** + * Represents non active image view. + */ +public class NonActiveImageView implements IElement { + private final UUID id = UUID.randomUUID(); + + public NonActiveImageView(PropertiesEntity properties) throws ApplicationImageFileNotFoundException { + Button button = new Button(); + + button.setDisable(true); + + InputStream imageSource = + getClass().getClassLoader().getResourceAsStream(properties.getImageNonActiveName()); + if (Objects.isNull(imageSource)) { + throw new ApplicationImageFileNotFoundException(); + } + + ImageView imageView = new ImageView(new Image(imageSource)); + imageView.setFitHeight(properties.getImageBarHeight()); + imageView.setFitWidth(properties.getImageBarWidth()); + + button.setGraphic(imageView); + + button.setAlignment(Pos.CENTER_RIGHT); + + SplitPane splitPane = new SplitPane(button); + splitPane.setTooltip(new Tooltip(properties.getLabelNonActiveDescription())); + + splitPane.setBackground( + Background.fill( + Color.rgb( + properties.getCommonSceneHeaderConnectionStatusBackgroundColorR(), + properties.getCommonSceneHeaderConnectionStatusBackgroundColorG(), + properties.getCommonSceneHeaderConnectionStatusBackgroundColorB()))); + + BorderPane borderPane = new BorderPane(); + borderPane.setRight(splitPane); + + ElementStorage.setElement(id, borderPane); + } + + /** + * @see IElementActualizable + */ + @Override + public BorderPane getContent() { + return ElementStorage.getElement(id); + } +} diff --git a/gui/src/main/java/com/repoachiever/service/element/image/view/common/OpenImageView.java b/gui/src/main/java/com/repoachiever/service/element/image/view/common/OpenImageView.java index c39f341..51b9353 100644 --- a/gui/src/main/java/com/repoachiever/service/element/image/view/common/OpenImageView.java +++ b/gui/src/main/java/com/repoachiever/service/element/image/view/common/OpenImageView.java @@ -32,7 +32,7 @@ /** Represents open image view. */ @Service -public class OpenImageView implements IElementResizable, IElement { +public class OpenImageView implements IElement { private final UUID id = UUID.randomUUID(); @Lazy @@ -80,7 +80,6 @@ public OpenImageView( borderPane.setRight(splitPane); ElementStorage.setElement(id, borderPane); - ElementStorage.setResizable(this); } /** @@ -90,16 +89,4 @@ public OpenImageView( public BorderPane getContent() { return ElementStorage.getElement(id); } - - /** - * @see IElementResizable - */ - @Override - public void handlePrefWidth() {} - - /** - * @see IElementResizable - */ - @Override - public void handlePrefHeight() {} } diff --git a/gui/src/main/java/com/repoachiever/service/element/image/view/common/RetrieveContentImageView.java b/gui/src/main/java/com/repoachiever/service/element/image/view/common/RetrieveContentImageView.java index a986138..31f8efe 100644 --- a/gui/src/main/java/com/repoachiever/service/element/image/view/common/RetrieveContentImageView.java +++ b/gui/src/main/java/com/repoachiever/service/element/image/view/common/RetrieveContentImageView.java @@ -26,7 +26,7 @@ /** Represents retrieve content image view. */ @Service -public class RetrieveContentImageView implements IElementResizable, IElement { +public class RetrieveContentImageView implements IElement { private final UUID id = UUID.randomUUID(); public RetrieveContentImageView( @@ -64,7 +64,6 @@ public RetrieveContentImageView( borderPane.setRight(splitPane); ElementStorage.setElement(id, borderPane); - ElementStorage.setResizable(this); } /** @@ -74,16 +73,4 @@ public RetrieveContentImageView( public BorderPane getContent() { return ElementStorage.getElement(id); } - - /** - * @see IElementResizable - */ - @Override - public void handlePrefWidth() {} - - /** - * @see IElementResizable - */ - @Override - public void handlePrefHeight() {} } diff --git a/gui/src/main/java/com/repoachiever/service/element/image/view/common/TopologyImageView.java b/gui/src/main/java/com/repoachiever/service/element/image/view/common/TopologyImageView.java new file mode 100644 index 0000000..318d998 --- /dev/null +++ b/gui/src/main/java/com/repoachiever/service/element/image/view/common/TopologyImageView.java @@ -0,0 +1,78 @@ +package com.repoachiever.service.element.image.view.common; + +import com.repoachiever.entity.PropertiesEntity; +import com.repoachiever.exception.ApplicationImageFileNotFoundException; +import com.repoachiever.service.element.storage.ElementStorage; +import com.repoachiever.service.element.text.common.IElement; +import com.repoachiever.service.element.text.common.IElementActualizable; +import com.repoachiever.service.element.text.common.IElementResizable; +import com.repoachiever.service.event.payload.CleanEvent; +import com.repoachiever.service.event.payload.TopologySwapEvent; +import ink.bluecloud.css.CssResources; +import ink.bluecloud.css.ElementButton; +import ink.bluecloud.css.ElementButtonKt; +import javafx.geometry.Pos; +import javafx.scene.control.Button; +import javafx.scene.control.SplitPane; +import javafx.scene.control.Tooltip; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; +import javafx.scene.layout.BorderPane; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationEventPublisher; +import org.springframework.stereotype.Service; + +import java.io.InputStream; +import java.util.Objects; +import java.util.UUID; + +/** Represents topology image view. */ +@Service +public class TopologyImageView implements IElement { + private final UUID id = UUID.randomUUID(); + + public TopologyImageView( + @Autowired PropertiesEntity properties, + @Autowired ApplicationEventPublisher applicationEventPublisher) + throws ApplicationImageFileNotFoundException { + Button button = new Button(); + + ElementButtonKt.theme(button, ElementButton.greenButton); + button.getStylesheets().add(CssResources.globalCssFile); + button.getStylesheets().add(CssResources.buttonCssFile); + button.getStylesheets().add(CssResources.textFieldCssFile); + + button.setOnMouseClicked( + event -> applicationEventPublisher.publishEvent(new TopologySwapEvent())); + + InputStream imageSource = + getClass().getClassLoader().getResourceAsStream(properties.getImageTopologyName()); + if (Objects.isNull(imageSource)) { + throw new ApplicationImageFileNotFoundException(); + } + + ImageView imageView = new ImageView(new Image(imageSource)); + imageView.setFitHeight(properties.getImageBarHeight()); + imageView.setFitWidth(properties.getImageBarWidth()); + + button.setGraphic(imageView); + + button.setAlignment(Pos.CENTER_RIGHT); + + SplitPane splitPane = new SplitPane(button); + splitPane.setTooltip(new Tooltip(properties.getButtonTopologyDescription())); + + BorderPane borderPane = new BorderPane(); + borderPane.setRight(splitPane); + + ElementStorage.setElement(id, borderPane); + } + + /** + * @see IElementActualizable + */ + @Override + public BorderPane getContent() { + return ElementStorage.getElement(id); + } +} diff --git a/gui/src/main/java/com/repoachiever/service/element/image/view/common/WithdrawImageView.java b/gui/src/main/java/com/repoachiever/service/element/image/view/common/WithdrawImageView.java index 991692e..6c5c131 100644 --- a/gui/src/main/java/com/repoachiever/service/element/image/view/common/WithdrawImageView.java +++ b/gui/src/main/java/com/repoachiever/service/element/image/view/common/WithdrawImageView.java @@ -27,7 +27,7 @@ /** Represents withdraw image view. */ @Service -public class WithdrawImageView implements IElementResizable, IElement { +public class WithdrawImageView implements IElement { private final UUID id = UUID.randomUUID(); public WithdrawImageView( @@ -65,7 +65,6 @@ public WithdrawImageView( borderPane.setRight(splitPane); ElementStorage.setElement(id, borderPane); - ElementStorage.setResizable(this); } /** @@ -75,16 +74,4 @@ public WithdrawImageView( public BorderPane getContent() { return ElementStorage.getElement(id); } - - /** - * @see IElementResizable - */ - @Override - public void handlePrefWidth() {} - - /** - * @see IElementResizable - */ - @Override - public void handlePrefHeight() {} } diff --git a/gui/src/main/java/com/repoachiever/service/element/layout/scene/main/application/common/MainApplicationBarGrid.java b/gui/src/main/java/com/repoachiever/service/element/layout/scene/main/application/common/MainApplicationBarGrid.java index 70b4a27..0555207 100644 --- a/gui/src/main/java/com/repoachiever/service/element/layout/scene/main/application/common/MainApplicationBarGrid.java +++ b/gui/src/main/java/com/repoachiever/service/element/layout/scene/main/application/common/MainApplicationBarGrid.java @@ -27,6 +27,7 @@ public MainApplicationBarGrid( @Autowired WithdrawImageView withdrawImageView, @Autowired RetrieveContentImageView retrieveContentImageView, @Autowired CleanAllImageView cleanAllImageView, + @Autowired TopologyImageView topologyImageView, @Autowired EditImageView editImageView, @Autowired OpenImageView openImageView) { GridPane grid = new GridPane(); @@ -63,9 +64,13 @@ public MainApplicationBarGrid( ColumnConstraints column7 = new ColumnConstraints(); column7.setHgrow(Priority.ALWAYS); - column7.setPercentWidth(40); + column7.setPercentWidth(10); - grid.getColumnConstraints().addAll(column1, column2, column3, column4, column5, column6, column7); + ColumnConstraints column8 = new ColumnConstraints(); + column8.setHgrow(Priority.ALWAYS); + column8.setPercentWidth(30); + + grid.getColumnConstraints().addAll(column1, column2, column3, column4, column5, column6, column7, column8); grid.addRow( 0, @@ -73,6 +78,7 @@ public MainApplicationBarGrid( withdrawImageView.getContent(), retrieveContentImageView.getContent(), cleanAllImageView.getContent(), + topologyImageView.getContent(), editImageView.getContent(), openImageView.getContent()); diff --git a/gui/src/main/java/com/repoachiever/service/element/list/cell/ListVisualizerCell.java b/gui/src/main/java/com/repoachiever/service/element/list/cell/ListVisualizerCell.java index 799bbb7..55dff3a 100644 --- a/gui/src/main/java/com/repoachiever/service/element/list/cell/ListVisualizerCell.java +++ b/gui/src/main/java/com/repoachiever/service/element/list/cell/ListVisualizerCell.java @@ -2,8 +2,10 @@ import com.repoachiever.dto.ListVisualizerCellInputDto; import com.repoachiever.entity.PropertiesEntity; +import com.repoachiever.service.element.image.view.common.ActiveImageView; import com.repoachiever.service.element.image.view.common.CleanImageView; import com.repoachiever.service.element.image.view.common.DownloadImageView; +import com.repoachiever.service.element.image.view.common.NonActiveImageView; import com.repoachiever.service.element.scene.main.deployment.MainDeploymentScene; import com.repoachiever.service.state.StateService; import javafx.scene.control.Label; @@ -24,6 +26,10 @@ public class ListVisualizerCell extends ListCell { private Label label; + private ActiveImageView activeImageView; + + private NonActiveImageView nonActiveImageView; + private final Pane pane = new Pane(); private CleanImageView cleanImageView; @@ -36,6 +42,8 @@ public class ListVisualizerCell extends ListCell { private final MainDeploymentScene deploymentScene; + private Boolean prevActive = false; + public ListVisualizerCell( PropertiesEntity properties, ApplicationEventPublisher applicationEventPublisher, @@ -57,11 +65,6 @@ public ListVisualizerCell( protected void updateItem(ListVisualizerCellInputDto item, boolean empty) { super.updateItem(item, empty); -// if (hbox != null) { -// getItem -// System.out.println(String.format("%d-%b", hbox.hashCode(), empty)); -// } - if (!empty) { if (Objects.isNull(StateService.getConfigLocation())) { if (Objects.isNull(label)) { @@ -71,6 +74,8 @@ protected void updateItem(ListVisualizerCellInputDto item, boolean empty) { if (Objects.isNull(hbox)) { hbox = new HBox(); + hbox.setSpacing(properties.getSceneCommonContentBarHorizontalGap()); + hbox.getChildren().addAll(label); } } else if (item.getStub()) { @@ -81,6 +86,8 @@ protected void updateItem(ListVisualizerCellInputDto item, boolean empty) { if (Objects.isNull(hbox)) { hbox = new HBox(); + hbox.setSpacing(properties.getSceneCommonContentBarHorizontalGap()); + hbox.getChildren().addAll(label); } @@ -100,16 +107,36 @@ protected void updateItem(ListVisualizerCellInputDto item, boolean empty) { label.setText(item.getName()); } + if (item.getActive()) { + if (Objects.isNull(activeImageView)) { + this.activeImageView = new ActiveImageView(properties); + } + } else { + if (Objects.isNull(nonActiveImageView)) { + this.nonActiveImageView = new NonActiveImageView(properties); + } + } + if (Objects.isNull(hbox)) { hbox = new HBox(); - hbox.getChildren().addAll(label); + hbox.setSpacing(properties.getSceneCommonContentBarHorizontalGap()); + + if (item.getActive()) { + hbox.getChildren().addAll(label, activeImageView.getContent()); + } else { + hbox.getChildren().addAll(label, nonActiveImageView.getContent()); + } } - if (hbox.getChildren().size() > 1) { + if (hbox.getChildren().size() > 2 || hbox.getChildren().size() == 1) { hbox.getChildren().clear(); - hbox.getChildren().addAll(label); + if (item.getActive()) { + hbox.getChildren().addAll(label, activeImageView.getContent()); + } else { + hbox.getChildren().addAll(label, nonActiveImageView.getContent()); + } } } else { if (Objects.isNull(label)) { @@ -122,11 +149,12 @@ protected void updateItem(ListVisualizerCellInputDto item, boolean empty) { if (Objects.isNull(hbox)) { hbox = new HBox(); + + hbox.setSpacing(properties.getSceneCommonContentBarHorizontalGap()); } if (Objects.isNull(cleanImageView)) { - this.cleanImageView = new CleanImageView( - properties, applicationEventPublisher, item.getName()); + this.cleanImageView = new CleanImageView(properties, applicationEventPublisher, item.getName()); } if (Objects.isNull(downloadImageView)) { @@ -134,10 +162,36 @@ protected void updateItem(ListVisualizerCellInputDto item, boolean empty) { properties, applicationEventPublisher, deploymentScene, item.getName()); } - if (hbox.getChildren().size() < 3) { + if (item.getActive()) { + if (Objects.isNull(activeImageView)) { + this.activeImageView = new ActiveImageView(properties); + } + } else { + if (Objects.isNull(nonActiveImageView)) { + this.nonActiveImageView = new NonActiveImageView(properties); + } + } + + if (hbox.getChildren().size() < 5 || prevActive != item.getActive()) { hbox.getChildren().clear(); - hbox.getChildren().addAll(label, pane, cleanImageView.getContent(), downloadImageView.getContent()); + if (item.getActive()) { + hbox.getChildren().addAll( + label, + activeImageView.getContent(), + pane, + cleanImageView.getContent(), + downloadImageView.getContent()); + } else { + hbox.getChildren().addAll( + label, + nonActiveImageView.getContent(), + pane, + cleanImageView.getContent(), + downloadImageView.getContent()); + } + + prevActive = item.getActive(); } } @@ -146,6 +200,7 @@ protected void updateItem(ListVisualizerCellInputDto item, boolean empty) { setGraphic(hbox); } else { setText(null); + setGraphic(null); } } diff --git a/gui/src/main/java/com/repoachiever/service/event/payload/TopologySwapEvent.java b/gui/src/main/java/com/repoachiever/service/event/payload/TopologySwapEvent.java index 61f20aa..a2b297b 100644 --- a/gui/src/main/java/com/repoachiever/service/event/payload/TopologySwapEvent.java +++ b/gui/src/main/java/com/repoachiever/service/event/payload/TopologySwapEvent.java @@ -11,12 +11,8 @@ /** Represents topology swap file open window event used for state management. */ @Getter public class TopologySwapEvent extends ApplicationEvent implements IEvent { - private final List content; - - public TopologySwapEvent(List content) { - super(content); - - this.content = content; + public TopologySwapEvent() { + super(new Object()); } /** diff --git a/gui/src/main/java/com/repoachiever/service/integration/event/EventConfigService.java b/gui/src/main/java/com/repoachiever/service/integration/event/EventConfigService.java index 9ec1e68..7f8056b 100644 --- a/gui/src/main/java/com/repoachiever/service/integration/event/EventConfigService.java +++ b/gui/src/main/java/com/repoachiever/service/integration/event/EventConfigService.java @@ -1,12 +1,14 @@ package com.repoachiever.service.integration.event; import com.repoachiever.converter.ContentRetrievalUnitToJsonConverter; +import com.repoachiever.converter.TopologyInfoUnitsToJsonConverter; import com.repoachiever.dto.CleanExternalCommandDto; import com.repoachiever.dto.DownloadExternalCommandDto; import com.repoachiever.entity.PropertiesEntity; import com.repoachiever.exception.*; import com.repoachiever.model.ContentRetrievalResult; import com.repoachiever.model.HealthCheckResult; +import com.repoachiever.model.TopologyInfoUnit; import com.repoachiever.model.VersionInfoResult; import com.repoachiever.service.command.config.open.OpenConfigCommandService; import com.repoachiever.service.command.swap.open.OpenSwapCommandService; @@ -45,6 +47,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.List; import java.util.Objects; import process.SProcessExecutor; @@ -135,6 +138,24 @@ private void configure() { return; } + VersionInfoResult versionInfoResult; + + try { + versionInfoResult = + versionExternalCommandService.process(configService.getConfig()); + } catch (ApiServerOperationFailureException e) { + ElementHelper.showAlert(errorAlert.getContent(), e.getMessage()); + + return; + } + + if (!versionInfoResult.getExternalApi().getHash().equals(properties.getGitCommitId())) { + ElementHelper.showAlert( + errorAlert.getContent(), properties.getAlertVersionMismatchMessage()); + + return; + } + StateService.setConfigLocation(new File(properties.getConfigDefaultLocation())); ContentRetrievalResult contentRetrievalResult; @@ -573,6 +594,8 @@ private void handleCleanAllEvent(CleanAllEvent event) { if (!versionInfoResult.getExternalApi().getHash().equals(properties.getGitCommitId())) { ElementHelper.showAlert( errorAlert.getContent(), properties.getAlertVersionMismatchMessage()); + + return; } try { @@ -672,6 +695,24 @@ private void handleOpenEvent(OpenEvent event) { return; } + VersionInfoResult versionInfoResult; + + try { + versionInfoResult = + versionExternalCommandService.process(configService.getConfig()); + } catch (ApiServerOperationFailureException e) { + ElementHelper.showAlert(errorAlert.getContent(), e.getMessage()); + + return; + } + + if (!versionInfoResult.getExternalApi().getHash().equals(properties.getGitCommitId())) { + ElementHelper.showAlert( + errorAlert.getContent(), properties.getAlertVersionMismatchMessage()); + + return; + } + StateService.setConfigLocation(event.getConfigLocation()); ContentRetrievalResult contentRetrievalResult; @@ -697,18 +738,107 @@ private void handleOpenEvent(OpenEvent event) { } /** - * Handles incoming swap event. + * Handles incoming topology swap event. * - * @param event given swap event. + * @param event given topology swap event. + */ + @EventListener + private void handleTopologySwapEvent(TopologySwapEvent event) { + SchedulerConfigurationHelper.scheduleOnce( + () -> { + if (Objects.isNull(StateService.getConfigLocation())) { + ElementHelper.showAlert( + errorAlert.getContent(), + properties.getAlertConfigNotOpenedMessage()); + + return; + } + + if (!StateService.getConnectionEstablished()) { + ElementHelper.showAlert( + errorAlert.getContent(), + properties.getAlertApiServerUnavailableMessage()); + + return; + } + + ElementHelper.toggleElementVisibility(mainDeploymentCircleProgressBar.getContent()); + + List topologyInfoUnits; + + try { + topologyInfoUnits = topologyExternalCommandService.process(configService.getConfig()); + } catch (ApiServerOperationFailureException e) { + ElementHelper.showAlert(errorAlert.getContent(), e.getMessage()); + + return; + } + + String swapLocation = eventConfigurationHelper.getSwapLocation(); + + try { + String topologyInfoUnitsRaw; + + try { + topologyInfoUnitsRaw = + TopologyInfoUnitsToJsonConverter.convert(topologyInfoUnits); + } catch (TopologyInfoUnitsToJsonConversionFailureException e) { + ElementHelper.showAlert( + errorAlert.getContent(), + new SwapFileCreationFailureException(e.getMessage()).getMessage()); + + return; + } + + try { + Files.writeString(Path.of(swapLocation), topologyInfoUnitsRaw); + } catch (IOException e) { + ElementHelper.showAlert( + errorAlert.getContent(), + new SwapFileCreationFailureException(e.getMessage()).getMessage()); + + return; + } + + OpenSwapCommandService openSwapCommandService = new OpenSwapCommandService(swapLocation); + + if (commandExecutorService.getOSType() == SProcessExecutor.OS.MAC) { + ElementHelper.showAlert( + informationAlert.getContent(), properties.getAlertEditorCloseReminderMessage()); + } + + try { + commandExecutorService.executeCommand(openSwapCommandService); + } catch (CommandExecutorException e) { + ElementHelper.showAlert(errorAlert.getContent(), e.getMessage()); + } + } finally { + try { + Files.deleteIfExists(Paths.get(swapLocation)); + } catch (IOException e) { + ElementHelper.showAlert( + errorAlert.getContent(), + new SwapFileDeletionFailureException(e.getMessage()).getMessage()); + } finally { + ElementHelper.toggleElementVisibility(mainDeploymentCircleProgressBar.getContent()); + } + } + }); + } + + /** + * Handles incoming details swap event. + * + * @param event given details swap event. */ @EventListener private void handleDetailsSwapEvent(ContentSwapEvent event) { SchedulerConfigurationHelper.scheduleOnce( () -> { ElementHelper.toggleElementVisibility(mainDeploymentCircleProgressBar.getContent()); -// + String swapLocation = eventConfigurationHelper.getSwapLocation(); -// + try { String contentRetrievalUnitRaw; diff --git a/gui/src/main/resources/application.properties b/gui/src/main/resources/application.properties index 6559105..6ace20d 100644 --- a/gui/src/main/resources/application.properties +++ b/gui/src/main/resources/application.properties @@ -145,12 +145,21 @@ image.clean-all.name=image/cleanall.png # Describes image used for download. image.download.name=image/download.png +# Describes image used for topology retrieval. +image.topology.name=image/topology.png + # Describes image used for configuration file edition. image.edit.name=image/edit.png # Describes image used for opening configuration file. image.open.name=image/open.png +# Describes image used for active content state. +image.active.name=image/active.png + +# Describes image used for not active content state. +image.non-active.name=image/nonactive.png + # Describes width of the images used in deployment bar. image.bar.width=20 @@ -175,12 +184,21 @@ button.clean-all.description=Clean all content # Describes download button description. button.download.description=Download content +# Describes topology button description. +button.topology.description=Retrieve topology + # Describes edit button description. button.edit.description=Edit configuration # Describes open button description. button.open.description=Open configuration +# Describes active label description. +label.active.description=Location is active + +# Describes not active label description. +label.non-active.description=Location is not active + # Describes success connection status label description. label.connection-status-success.description=Connection is established @@ -217,12 +235,6 @@ alert.version-mismatch.message=RepoAchiever API Server version is different from # Describes info message related editor close reminder. alert.editor-close-reminder.message=Remember to completely close editor application -# Describe location of graph css file -graph.css.location=smartgraph.css - -# Describe location of graph properties file -graph.properties.location=smartgraph.properties - # Describes location of application configuration file. config.default.location=${user.home}/.repoachiever/config/user.yaml diff --git a/gui/src/main/resources/image/active.png b/gui/src/main/resources/image/active.png new file mode 100644 index 0000000..11047ad Binary files /dev/null and b/gui/src/main/resources/image/active.png differ diff --git a/gui/src/main/resources/image/nonactive.png b/gui/src/main/resources/image/nonactive.png new file mode 100644 index 0000000..2872216 Binary files /dev/null and b/gui/src/main/resources/image/nonactive.png differ diff --git a/gui/src/main/resources/image/topology.png b/gui/src/main/resources/image/topology.png new file mode 100644 index 0000000..7609404 Binary files /dev/null and b/gui/src/main/resources/image/topology.png differ diff --git a/gui/src/main/resources/smartgraph.css b/gui/src/main/resources/smartgraph.css deleted file mode 100644 index 0ad355c..0000000 --- a/gui/src/main/resources/smartgraph.css +++ /dev/null @@ -1,48 +0,0 @@ -.graph { - -fx-background-color: #FFFFFF; - -fx-border-radius: 25; -} - -.vertex { - -fx-stroke-width: 3; - -fx-stroke: #61B5F1; - -fx-stroke-type: inside; /* you should keep this for vertex.radius to hold */ - -fx-fill: #B1DFF7; -} - -.vertex:hover { /* pseudo-classes also work */ - /*-fx-cursor: default; */ /* You can use this style to override the hand/move cursors while hovering. */ - -fx-stroke-width: 4; -} - -.vertex-label { - -fx-font: bold 8pt "sans-serif"; -} - -.edge { - -fx-stroke-width: 2; - -fx-stroke: #FF6D66; - -fx-stroke-dash-array: 2 5 2 5; /* remove for clean edges */ - -fx-fill: transparent; /*important for curved edges. do not remove */ - -fx-stroke-line-cap: round; - -fx-opacity: 0.8; -} - -.edge-label { - -fx-font: normal 5pt "sans-serif"; -} - -.arrow { - -fx-stroke-width: 2; - -fx-stroke: #FF6D66; - -fx-opacity: 0.8; -} - -/* Custom vertex. You should revert any unwanted styling in the default element, - style, since custom styles will be appended to the default style */ -.myVertex { - -fx-stroke-width: 5; - -fx-stroke: green; - -fx-stroke-type: inside; /* you should keep this if using arrows */ - -fx-fill: yellowgreen; -} \ No newline at end of file diff --git a/gui/src/main/resources/smartgraph.properties b/gui/src/main/resources/smartgraph.properties deleted file mode 100644 index 61ebc97..0000000 --- a/gui/src/main/resources/smartgraph.properties +++ /dev/null @@ -1,17 +0,0 @@ -# Vertex related configurations -# -vertex.allow-user-move = true -vertex.radius = 15 -vertex.tooltip = true -vertex.label = true - -# Edge related configurations -# -edge.tooltip = true -edge.label = true -# only makes sense if displaying an oriented graph -edge.arrow = true - -layout.repulsive-force = 25000 -layout.attraction-force = 30 -layout.attraction-scale = 10 \ No newline at end of file