Archived
0

add Edit to context menu on PowerPlay screen

This commit is contained in:
iMoHax
2016-12-05 16:58:00 +03:00
parent 9baa38c2b2
commit e557206bce
2 changed files with 33 additions and 36 deletions

View File

@@ -414,25 +414,37 @@ public class PowerPlayController {
historySystems.getItems().clear(); historySystems.getItems().clear();
} }
private SystemModel getFocusedSystem(){
@FXML if (historySystems.isFocused()) return historySystems.getSelectionModel().getSelectedItem();
private void copySystemToClipboard(){ if (controlSystems.isFocused()) return controlSystems.getSelectionModel().getSelectedItem();
SystemModel starSystem = null;
if (historySystems.isFocused()) starSystem = historySystems.getSelectionModel().getSelectedItem();
if (controlSystems.isFocused()) starSystem = controlSystems.getSelectionModel().getSelectedItem();
if (tblResults.isFocused()){ if (tblResults.isFocused()){
ResultEntry entry = tblResults.getSelectionModel().getSelectedItem(); ResultEntry entry = tblResults.getSelectionModel().getSelectedItem();
starSystem = entry != null ? entry.starSystem : null; return entry != null ? entry.starSystem : null;
} }
if (tblDetail.isFocused()){ if (tblDetail.isFocused()){
ResultEntry entry = tblDetail.getSelectionModel().getSelectedItem(); ResultEntry entry = tblDetail.getSelectionModel().getSelectedItem();
starSystem = entry != null ? entry.starSystem : null; return entry != null ? entry.starSystem : null;
} }
return null;
}
@FXML
private void copySystemToClipboard(){
SystemModel starSystem = getFocusedSystem();
if (starSystem != null){ if (starSystem != null){
Main.copyToClipboard(starSystem.getName()); Main.copyToClipboard(starSystem.getName());
} }
} }
@FXML
private void editSystem(){
SystemModel starSystem = getFocusedSystem();
if (starSystem != null){
Screeners.showSystemsEditor(starSystem);
}
}
public class ResultEntry { public class ResultEntry {
private final SystemModel starSystem; private final SystemModel starSystem;
private final ReadOnlyStringProperty nearStations; private final ReadOnlyStringProperty nearStations;

View File

@@ -14,6 +14,15 @@
prefHeight="500" > prefHeight="500" >
<fx:define><Insets fx:id="tablePadding" left="0" right="0" top="0" bottom="0" /></fx:define> <fx:define><Insets fx:id="tablePadding" left="0" right="0" top="0" bottom="0" /></fx:define>
<fx:define><Insets fx:id="summPadding" left="4" right="4" top="4" bottom="4" /></fx:define> <fx:define><Insets fx:id="summPadding" left="4" right="4" top="4" bottom="4" /></fx:define>
<fx:define>
<ContextMenu fx:id="ctxMenu">
<items>
<MenuItem text="%dialog.button.copy" accelerator="Shortcut+C" onAction="#copySystemToClipboard" />
<MenuItem text="%dialog.button.edit" accelerator="Shortcut+E" onAction="#editSystem" />
</items>
</ContextMenu>
</fx:define>
<TitledPane text="%powerplay.analyze.title" collapsible="false"> <TitledPane text="%powerplay.analyze.title" collapsible="false">
<HBox spacing="50" alignment="CENTER" minHeight="230" maxHeight="230"> <HBox spacing="50" alignment="CENTER" minHeight="230" maxHeight="230">
<VBox minWidth="250" maxWidth="250" spacing="4"> <VBox minWidth="250" maxWidth="250" spacing="4">
@@ -24,13 +33,7 @@
</HBox> </HBox>
<HBox spacing="4" alignment="CENTER" VBox.vgrow="ALWAYS" HBox.hgrow="ALWAYS"> <HBox spacing="4" alignment="CENTER" VBox.vgrow="ALWAYS" HBox.hgrow="ALWAYS">
<ListView fx:id="historySystems" HBox.hgrow="ALWAYS"> <ListView fx:id="historySystems" HBox.hgrow="ALWAYS">
<contextMenu> <contextMenu><fx:reference source="ctxMenu"/></contextMenu>
<ContextMenu>
<items>
<MenuItem text="%dialog.button.copy" accelerator="Shortcut+C" onAction="#copySystemToClipboard" />
</items>
</ContextMenu>
</contextMenu>
</ListView> </ListView>
<VBox spacing="4"> <VBox spacing="4">
<Button prefWidth="30" onAction="#addHistorySystem"><graphic><Glyph text="FontAwesome|PLUS"/></graphic></Button> <Button prefWidth="30" onAction="#addHistorySystem"><graphic><Glyph text="FontAwesome|PLUS"/></graphic></Button>
@@ -71,13 +74,7 @@
</HBox> </HBox>
<HBox spacing="4" alignment="CENTER" VBox.vgrow="ALWAYS" HBox.hgrow="ALWAYS"> <HBox spacing="4" alignment="CENTER" VBox.vgrow="ALWAYS" HBox.hgrow="ALWAYS">
<ListView fx:id="controlSystems" HBox.hgrow="ALWAYS"> <ListView fx:id="controlSystems" HBox.hgrow="ALWAYS">
<contextMenu> <contextMenu><fx:reference source="ctxMenu"/></contextMenu>
<ContextMenu>
<items>
<MenuItem text="%dialog.button.copy" accelerator="Shortcut+C" onAction="#copySystemToClipboard" />
</items>
</ContextMenu>
</contextMenu>
</ListView> </ListView>
<VBox spacing="4"> <VBox spacing="4">
<Button prefWidth="30" onAction="#addControlSystem"><graphic><Glyph text="FontAwesome|PLUS"/></graphic></Button> <Button prefWidth="30" onAction="#addControlSystem"><graphic><Glyph text="FontAwesome|PLUS"/></graphic></Button>
@@ -150,13 +147,7 @@
<columnResizePolicy> <columnResizePolicy>
<TableView fx:constant="UNCONSTRAINED_RESIZE_POLICY"/> <TableView fx:constant="UNCONSTRAINED_RESIZE_POLICY"/>
</columnResizePolicy> </columnResizePolicy>
<contextMenu> <contextMenu><fx:reference source="ctxMenu"/></contextMenu>
<ContextMenu>
<items>
<MenuItem text="%dialog.button.copy" accelerator="Shortcut+C" onAction="#copySystemToClipboard" />
</items>
</ContextMenu>
</contextMenu>
</TableView> </TableView>
<ScrollPane minHeight="50"> <ScrollPane minHeight="50">
<VBox spacing="4" padding="$summPadding"> <VBox spacing="4" padding="$summPadding">
@@ -210,13 +201,7 @@
<columnResizePolicy> <columnResizePolicy>
<TableView fx:constant="UNCONSTRAINED_RESIZE_POLICY"/> <TableView fx:constant="UNCONSTRAINED_RESIZE_POLICY"/>
</columnResizePolicy> </columnResizePolicy>
<contextMenu> <contextMenu><fx:reference source="ctxMenu"/></contextMenu>
<ContextMenu>
<items>
<MenuItem text="%dialog.button.copy" accelerator="Shortcut+C" onAction="#copySystemToClipboard" />
</items>
</ContextMenu>
</contextMenu>
</TableView> </TableView>
<ScrollPane minHeight="50"> <ScrollPane minHeight="50">
<VBox spacing="4" padding="$summPadding"> <VBox spacing="4" padding="$summPadding">