Skip to content

Commit

Permalink
fixed table resizing
Browse files Browse the repository at this point in the history
  • Loading branch information
Ljaysoft committed Aug 26, 2016
1 parent b964cb6 commit 1ce67ee
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 48 deletions.
76 changes: 35 additions & 41 deletions src/main/resources/layout/MainWindow.fxml
Expand Up @@ -46,51 +46,45 @@
<Label fx:id="nbItemsBagsLbl" text="###/### Items" />
</children>
</HBox>
<AnchorPane layoutY="57.0" AnchorPane.bottomAnchor="32.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="57.0">
<children>
<TabPane tabClosingPolicy="UNAVAILABLE" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<tabs>
<Tab text="Pokémon">
<content>
<AnchorPane>
<TabPane tabClosingPolicy="UNAVAILABLE" AnchorPane.bottomAnchor="25.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="57">
<tabs>
<Tab text="Pokémon" >
<content>
<AnchorPane>
<children>
<HBox AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<TextField fx:id="searchField" promptText="Search..." />
<Button fx:id="selectBtn" text="Select" />
</children>
</HBox>
<AnchorPane AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="32.0">
<children>
<HBox AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<TextField fx:id="searchField" promptText="Search..." />
<Button fx:id="selectBtn" text="Select" />
</children>
</HBox>
<VBox AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="25.0">
<children>
<Accordion>
<panes>
<TitledPane maxHeight="-Infinity" prefHeight="136.0" prefWidth="576.0" text="Filters" />
</panes>
</Accordion>
<ScrollPane>
<AnchorPane fx:id="pokemontable" />
</ScrollPane>
</children>
</VBox>
<Accordion AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<panes>
<TitledPane maxHeight="-Infinity" prefHeight="136.0" prefWidth="576.0" text="Filters" />
</panes>
</Accordion>
<GridPane fx:id="pokemontable" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"/>
</children>
</AnchorPane>
</content>
</Tab>
<Tab text="Items">
<content>
</children>
</AnchorPane>
</content>
</Tab>
<Tab text="Items">
<content>

</content>
</Tab>
<Tab text="LuckyEggGrinder">
<content>
<fx:include fx:id="luckyEggGrinderPane" source="LuckyEggGrinder.fxml" />
</content>
</Tab>
</tabs>
</TabPane>
</children>
</AnchorPane>
<ToolBar fx:id="statusBar" maxHeight="-Infinity" prefHeight="27.0" prefWidth="576.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">
</content>
</Tab>
<Tab text="LuckyEggGrinder">
<content>
<fx:include fx:id="luckyEggGrinderPane" source="LuckyEggGrinder.fxml" />
</content>
</Tab>
</tabs>
</TabPane>
<ToolBar fx:id="statusBar" prefHeight="27.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">
<Label fx:id="statusBarLeftText" text="Status" />
</ToolBar>
</children>
Expand Down
15 changes: 12 additions & 3 deletions src/main/resources/layout/PokemonTable.fxml
@@ -1,9 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.TableView?>
<?import javafx.scene.layout.*?>
<fx:root fx:id="pokemonTableViewRoot" type="javafx.scene.layout.AnchorPane" xmlns="http://javafx.com/javafx/8.0.60" xmlns:fx="http://javafx.com/fxml/1">
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.RowConstraints?>

<fx:root fx:id="pokemonTableViewRoot" maxHeight="1.7976931348623157E308" type="javafx.scene.layout.GridPane" xmlns="http://javafx.com/javafx/8.0.60" xmlns:fx="http://javafx.com/fxml/1">
<children>
<TableView fx:id="pokemonTableView" tableMenuButtonVisible="true" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"/>
<TableView fx:id="pokemonTableView" fixedCellSize="25.0" maxHeight="Infinity" tableMenuButtonVisible="true" GridPane.columnIndex="0" GridPane.fillHeight="TRUE" GridPane.hgrow="ALWAYS" GridPane.rowIndex="0" GridPane.vgrow="ALWAYS" />
</children>
<columnConstraints>
<ColumnConstraints />
</columnConstraints>
<rowConstraints>
<RowConstraints />
</rowConstraints>
</fx:root>
Expand Up @@ -15,8 +15,8 @@
import javafx.scene.image.ImageView;
import javafx.scene.image.PixelWriter;
import javafx.scene.image.WritableImage;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
Expand Down Expand Up @@ -74,7 +74,7 @@ public class MainWindowController extends BorderPane {
private Label nbItemsBagsLbl;

@FXML
private AnchorPane pokemontable;
private GridPane pokemontable;

@FXML
private PokemonTableController pokemontableController;
Expand Down
@@ -1,5 +1,6 @@
package me.corriekay.pokegoutil.GUI.controller;

import javafx.beans.binding.Bindings;
import javafx.beans.property.Property;
import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;
Expand All @@ -12,6 +13,7 @@
import javafx.scene.input.MouseButton;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.GridPane;
import me.corriekay.pokegoutil.DATA.managers.PokemonBagManager;
import me.corriekay.pokegoutil.DATA.models.PokemonModel;
import me.corriekay.pokegoutil.GUI.enums.ColumnID;
Expand All @@ -23,7 +25,7 @@
import java.util.List;


public class PokemonTableController extends AnchorPane {
public class PokemonTableController extends GridPane {
private final String fxmlLayout = "layout/PokemonTable.fxml";
private ClassLoader classLoader = getClass().getClassLoader();

Expand All @@ -35,7 +37,7 @@ public class PokemonTableController extends AnchorPane {

private List<TableColumn<PokemonModel, ?>> columns = new ArrayList<>();

public PokemonTableController(AnchorPane pane) {
public PokemonTableController(GridPane pane) {
FXMLLoader loader = new FXMLLoader();
loader.setLocation(classLoader.getResource(fxmlLayout));
loader.setRoot(this);
Expand All @@ -57,6 +59,7 @@ private void initialize() {
pokemonTableView.getColumns().addAll(columns);
pokemonTableView.setItems(PokemonBagManager.getAllPokemon());
pokemonTableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
pokemonTableView.prefHeightProperty().bind(Bindings.size(pokemonTableView.getItems()).multiply(pokemonTableView.getFixedCellSize()).add(30));
pokemonTableView.getColumns().addListener((ListChangeListener) c -> {
saveOrderToConfig();
});
Expand Down

0 comments on commit 1ce67ee

Please sign in to comment.