<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.Insets?>
<?import javafx.scene.control.*?>
<?import javafx.scene.control.cell.*?>
<?import javafx.scene.layout.*?>
<?import org.controlsfx.control.SegmentedButton?>
<?import ru.trader.view.support.cells.*?>
<GridPane xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"
          fx:controller="ru.trader.controllers.OffersController">

    <fx:define><Insets fx:id="stationsMargin" left="5" right="5" /></fx:define>
    <fx:define><Insets fx:id="stationsPadding" left="12" right="10" /></fx:define>

    <columnConstraints>
        <ColumnConstraints minWidth="270" maxWidth="270"/>
        <ColumnConstraints fillWidth="true"/>
    </columnConstraints>

    <TitledPane GridPane.rowSpan="3" text="%market.systems" minWidth="270" prefHeight="590" collapsible="false">
        <TextField fx:id="systemText" />
    </TitledPane>

    <TitledPane GridPane.columnIndex="1" text="%market.stations" maxHeight="60" collapsible="false">
        <SegmentedButton fx:id="stationsBar" />
    </TitledPane>
    <TitledPane GridPane.rowIndex="1" GridPane.columnIndex="1" text="" maxHeight="60" collapsible="false">
        <VBox>
            <HBox spacing="4">
                <Label text="%offers.text.distance"/>
                <Label fx:id="distance" minWidth="60"/>
                <Label text="%market.allegiance"/>
                <Label fx:id="faction" minWidth="60"/>
                <Label text="%market.government"/>
                <Label fx:id="government" minWidth="60"/>
            </HBox>
            <HBox spacing="4">
            <Label text="%offers.text.services"/>
            <HBox spacing="15">
                <CheckBox fx:id="cbMarket" text="%services.MARKET"/>
                <CheckBox fx:id="cbBlackMarket" text="%services.BLACK_MARKET"/>
                <CheckBox fx:id="cbRepair" text="%services.REPAIR"/>
                <CheckBox fx:id="cbMunition" text="%services.MUNITION"/>
                <CheckBox fx:id="cbOutfit" text="%services.OUTFIT"/>
                <CheckBox fx:id="cbShipyard" text="%services.SHIPYARD"/>
                <CheckBox fx:id="cbMediumLandpad" text="%services.MEDIUM_LANDPAD"/>
                <CheckBox fx:id="cbLargeLandpad" text="%services.LARGE_LANDPAD"/>
            </HBox>
        </HBox>
        </VBox>

    </TitledPane>
    <Accordion GridPane.rowIndex="2" GridPane.columnIndex="1" GridPane.hgrow="ALWAYS" GridPane.vgrow="ALWAYS">
        <panes>
            <TitledPane fx:id="paneSells" animated="false" text="%offers.pane.sell">
              <TableView fx:id="tblSell" editable="true">
                  <columns>
                      <TableColumn minWidth="230.0" text="%market.item.name">
                          <cellValueFactory><PropertyValueFactory property="name"/></cellValueFactory>
                      </TableColumn>
                      <TableColumn minWidth="110.0" text="%market.offer.price" onEditCommit="#editPrice">
                          <cellFactory><PriceCellImpl/></cellFactory>
                          <cellValueFactory><PropertyValueFactory property="price"/></cellValueFactory>
                      </TableColumn>
                      <TableColumn minWidth="80.0" text="%market.offer.supply">
                          <cellValueFactory><PropertyValueFactory property="count"/></cellValueFactory>
                      </TableColumn>
                      <TableColumn fx:id="sortSell" minWidth="90.0" text="%market.order.profit" sortType="DESCENDING">
                          <cellFactory><DoubleCell/></cellFactory>
                          <cellValueFactory><PropertyValueFactory property="profit"/></cellValueFactory>
                      </TableColumn>
                      <TableColumn text="%market.offer.avg">
                        <columns>
                            <TableColumn minWidth="80.0" text="%market.offer.sell">
                                <cellFactory><DoubleCell/></cellFactory>
                                <cellValueFactory><PropertyValueFactory property="avgSell"/></cellValueFactory>
                            </TableColumn>
                            <TableColumn minWidth="80.0" text="%market.offer.buy">
                                <cellFactory><DoubleCell/></cellFactory>
                                <cellValueFactory><PropertyValueFactory property="avgBuy"/></cellValueFactory>
                            </TableColumn>
                        </columns>
                      </TableColumn>
                      <TableColumn text="%market.offer.best">
                        <columns>
                            <TableColumn minWidth="120.0" text="%market.offer.sell">
                                <cellValueFactory><OfferCellValueImpl property="bestSell"/></cellValueFactory>
                            </TableColumn>
                            <TableColumn minWidth="120.0" text="%market.offer.buy">
                                <cellValueFactory><OfferCellValueImpl property="bestBuy"/></cellValueFactory>
                            </TableColumn>
                        </columns>
                      </TableColumn>
                  </columns>
                  <columnResizePolicy>
                      <TableView fx:constant="UNCONSTRAINED_RESIZE_POLICY"/>
                  </columnResizePolicy>
                  <sortOrder>
                      <fx:reference source="sortSell"/>
                  </sortOrder>
              </TableView>
            </TitledPane>
            <TitledPane animated="false" text="%offers.pane.buy">
              <TableView fx:id="tblBuy" editable="true">
                  <columns>
                      <TableColumn minWidth="230.0" text="%market.item.name">
                          <cellValueFactory><PropertyValueFactory property="name"/></cellValueFactory>
                      </TableColumn>
                      <TableColumn minWidth="110.0" text="%market.offer.price" editable="true" onEditCommit="#editPrice">
                          <cellFactory><PriceCellImpl/></cellFactory>
                          <cellValueFactory><PropertyValueFactory property="price"/></cellValueFactory>
                      </TableColumn>
                      <TableColumn minWidth="80.0" text="%market.offer.demand">
                          <cellValueFactory><PropertyValueFactory property="count"/></cellValueFactory>
                      </TableColumn>
                      <TableColumn fx:id="sortBuy" minWidth="90.0" text="%market.order.profit" sortType="DESCENDING">
                          <cellFactory><DoubleCell/></cellFactory>
                          <cellValueFactory><PropertyValueFactory property="profit"/></cellValueFactory>
                      </TableColumn>
                      <TableColumn text="%market.offer.avg">
                          <columns>
                              <TableColumn minWidth="80.0" text="%market.offer.sell">
                                  <cellFactory><DoubleCell/></cellFactory>
                                  <cellValueFactory><PropertyValueFactory property="avgSell"/></cellValueFactory>
                              </TableColumn>
                              <TableColumn minWidth="80.0" text="%market.offer.buy">
                                  <cellFactory><DoubleCell/></cellFactory>
                                  <cellValueFactory><PropertyValueFactory property="avgBuy"/></cellValueFactory>
                              </TableColumn>
                          </columns>
                      </TableColumn>
                      <TableColumn text="%market.offer.best">
                          <columns>
                              <TableColumn minWidth="120.0" text="%market.offer.sell">
                                  <cellValueFactory><OfferCellValueImpl property="bestSell"/></cellValueFactory>
                              </TableColumn>
                              <TableColumn minWidth="120.0" text="%market.offer.buy">
                                  <cellValueFactory><OfferCellValueImpl property="bestBuy"/></cellValueFactory>
                              </TableColumn>
                          </columns>
                      </TableColumn>
                  </columns>
                  <columnResizePolicy>
                      <TableView fx:constant="UNCONSTRAINED_RESIZE_POLICY"/>
                  </columnResizePolicy>
                  <sortOrder>
                      <fx:reference source="sortBuy"/>
                  </sortOrder>
              </TableView>
            </TitledPane>
        </panes>
        <expandedPane>
            <fx:reference source="paneSells"/>
        </expandedPane>
    </Accordion>
</GridPane>
