1
0
mirror of https://github.com/ACINQ/eclair.git synced 2024-11-20 10:39:19 +01:00

Fixed context menu of channel

This commit is contained in:
dpad85 2017-02-09 16:33:28 +01:00
parent 522c7e52f1
commit 105c7950bb
4 changed files with 56 additions and 27 deletions

View File

@ -22,28 +22,37 @@
<RowConstraints minHeight="10.0" vgrow="SOMETIMES"/>
</rowConstraints>
<children>
<Label styleClass="text-muted" text="Node id" GridPane.rowIndex="2"/>
<Label styleClass="text-muted" text="Capacity (milliBTC)" GridPane.rowIndex="4"/>
<Label styleClass="text-muted" text="Funder" GridPane.columnIndex="2" GridPane.rowIndex="3"/>
<Label styleClass="text-muted" text="State" GridPane.columnIndex="2" GridPane.rowIndex="4"/>
<Label styleClass="text-muted" text="Your balance (milliBTC)" GridPane.rowIndex="3"/>
<TextField fx:id="channelId" text="N/A" editable="false" styleClass="noteditable, text-strong"
focusTraversable="false" onContextMenuRequested="#openChannelContext" onMouseClicked="#closeChannelContext"
GridPane.columnSpan="4"/>
<Button fx:id="close" mnemonicParsing="false" styleClass="close-channel" text="Close"
GridPane.columnIndex="4" GridPane.halignment="RIGHT"/>
<TextField fx:id="nodeId" text="N/A" editable="false" styleClass="noteditable"
GridPane.columnIndex="1" GridPane.columnSpan="4" GridPane.rowIndex="2"/>
<TextField fx:id="capacity" text="N/A" editable="false" styleClass="noteditable"
GridPane.columnIndex="1" GridPane.rowIndex="4"/>
<TextField fx:id="funder" text="N/A" editable="false" styleClass="noteditable"
GridPane.columnIndex="3" GridPane.columnSpan="2" GridPane.rowIndex="3"/>
<TextField fx:id="state" text="N/A" editable="false" styleClass="noteditable"
GridPane.columnIndex="3" GridPane.columnSpan="2" GridPane.rowIndex="4"/>
<TextField fx:id="channelId" text="N/A" editable="false" styleClass="noteditable, text-strong"
GridPane.columnSpan="4"/>
<TextField fx:id="amountUs" text="N/A" editable="false" styleClass="noteditable"
GridPane.columnIndex="1" GridPane.rowIndex="3"/>
<ProgressBar fx:id="balanceBar" minHeight="4.0" prefHeight="4.0" maxWidth="1.7976931348623157E308"
progress="0.0" snapToPixel="false" GridPane.columnSpan="5"
GridPane.hgrow="ALWAYS" GridPane.rowIndex="1"/>
progress="0.0" snapToPixel="false" focusTraversable="false"
GridPane.columnSpan="5" GridPane.hgrow="ALWAYS" GridPane.rowIndex="1"/>
<Label styleClass="text-muted" text="Node id" GridPane.rowIndex="2"/>
<TextField fx:id="nodeId" text="N/A" focusTraversable="false" editable="false" styleClass="noteditable"
GridPane.columnIndex="1" GridPane.columnSpan="4" GridPane.rowIndex="2"/>
<Label styleClass="text-muted" text="Your balance (milliBTC)" GridPane.rowIndex="3"/>
<TextField fx:id="amountUs" text="N/A" focusTraversable="false" editable="false" styleClass="noteditable"
GridPane.columnIndex="1" GridPane.rowIndex="3"/>
<Label styleClass="text-muted" text="Capacity (milliBTC)" GridPane.rowIndex="4"/>
<TextField fx:id="capacity" text="N/A" focusTraversable="false" editable="false" styleClass="noteditable"
GridPane.columnIndex="1" GridPane.rowIndex="4"/>
<Label styleClass="text-muted" text="Funder" GridPane.columnIndex="2" GridPane.rowIndex="3"/>
<TextField fx:id="funder" text="N/A" focusTraversable="false" editable="false" styleClass="noteditable"
GridPane.columnIndex="3" GridPane.columnSpan="2" GridPane.rowIndex="3"/>
<Label styleClass="text-muted" text="State" GridPane.columnIndex="2" GridPane.rowIndex="4"/>
<TextField fx:id="state" text="N/A" focusTraversable="false" editable="false" styleClass="noteditable"
GridPane.columnIndex="3" GridPane.columnSpan="2" GridPane.rowIndex="4"/>
</children>
</GridPane>
<HBox styleClass="channel-separator"/>

View File

@ -69,6 +69,10 @@
-fx-padding: 0;
}
.context-menu.context-channel .menu-item .label {
-fx-font-size: 12px;
}
.tab:top:selected {
-fx-focus-color: transparent;
-fx-faint-focus-color: transparent;

View File

@ -57,7 +57,6 @@ class GUIUpdater(primaryStage: Stage, mainController: MainController, setup: Set
val channelPane = m(channel)
Platform.runLater(new Runnable() {
override def run(): Unit = {
channelPane.channelIdValue = s"$channelId"
channelPane.channelId.setText(s"$channelId")
channelPane.capacity.setText(s"${satoshi2millibtc(capacity).amount}")
channelPane.funder.getText match {

View File

@ -1,5 +1,6 @@
package fr.acinq.eclair.gui.controllers
import javafx.beans.value.{ChangeListener, ObservableValue}
import javafx.fxml.FXML
import javafx.scene.control.{Button, ContextMenu, ProgressBar, TextField}
import javafx.scene.input.{ContextMenuEvent, MouseEvent}
@ -13,7 +14,6 @@ import grizzled.slf4j.Logging
*/
class ChannelPaneController(theirNodeIdValue: String, channelParams: LocalParams) extends Logging {
var channelIdValue = ""
@FXML var channelId: TextField = _
@FXML var balanceBar: ProgressBar = _
@FXML var amountUs: TextField = _
@ -25,16 +25,33 @@ class ChannelPaneController(theirNodeIdValue: String, channelParams: LocalParams
var contextMenu: ContextMenu = _
@FXML def openChannelContext(event: ContextMenuEvent): Unit = {
if (contextMenu != null) contextMenu.hide()
private def buildChannelContextMenu = {
contextMenu = ContextMenuUtils.buildCopyContext(List(
new CopyAction("Copy Channel Id", channelIdValue),
new CopyAction("Copy Channel Id", channelId.getText),
new CopyAction("Copy Node Pubkey", theirNodeIdValue)
))
contextMenu.show(channelId, event.getScreenX, event.getScreenY)
contextMenu.getStyleClass.add("context-channel")
channelId.setContextMenu(contextMenu)
amountUs.setContextMenu(contextMenu)
nodeId.setContextMenu(contextMenu)
capacity.setContextMenu(contextMenu)
funder.setContextMenu(contextMenu)
state.setContextMenu(contextMenu)
}
@FXML def closeChannelContext(event: MouseEvent): Unit = {
if (contextMenu != null) contextMenu.hide()
@FXML def initialize = {
channelId.textProperty().addListener(new ChangeListener[String] {
override def changed(observable: ObservableValue[_ <: String], oldValue: String, newValue: String) = buildChannelContextMenu
})
buildChannelContextMenu
}
@FXML def openChannelContext(event: ContextMenuEvent) {
contextMenu.show(channelId, event.getScreenX, event.getScreenY)
event.consume
}
@FXML def closeChannelContext(event: MouseEvent) {
if (contextMenu != null) contextMenu.hide
}
}