CustomWindowDemo.java 9.05 KB
package cn.csbr.app.gui.page;

import cn.csbr.app.gui.component.useAndBackTab.UseConSumeTabTable;
import cn.csbr.app.gui.page.useAndBackTab.*;
import cn.csbr.app.gui.util.CsButtonGroup;
import com.sun.javafx.geom.BaseBounds;
import com.sun.javafx.geom.transform.BaseTransform;
import com.sun.javafx.jmx.MXNodeAlgorithm;
import com.sun.javafx.jmx.MXNodeAlgorithmContext;
import com.sun.javafx.sg.prism.NGNode;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.scene.image.ImageView;
import javafx.scene.layout.*;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import javafx.stage.WindowEvent;
import org.controlsfx.control.PropertySheet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.awt.*;

import static cn.csbr.app.gui.util.SystemUtils.getDataTableMinHeight;
import static cn.csbr.app.gui.util.SystemUtils.getScreenWidth;


@Component
public class CustomWindowDemo extends AbstractPage  {
    private PropertySheet propertySheet = new PropertySheet();
    @Autowired
    private UseTabPage useTabPage;
    @Autowired
    private BackTabPage backTabPage;
    @Autowired
    private InboundTabPage inboundTabPage;

    @Autowired
    private UseConSumeTabPage useConSumeTabPage;
    @Autowired
    private ErorrTabPage erorrTabPage;
    Stage primaryStage;
    @Autowired
    private MainPage mainPage;
    Tab errorTab = null;
    int isshow = 0;
    public void start(Stage stage)  {
        if(isshow == 1) {
            isshow = 0;
            primaryStage.close();
        }

        primaryStage = new Stage();
        primaryStage.initOwner(stage);
        primaryStage.initModality(Modality.APPLICATION_MODAL);
        primaryStage.initStyle(StageStyle.TRANSPARENT);
        StackPane bp = new StackPane();

        BorderPane root = new BorderPane();
        GridPane gpTitle = new GridPane();
        GridPane gpButton = new GridPane();
        gpTitle.setAlignment(Pos.CENTER_LEFT);
        gpTitle.setPadding(new Insets(10));
        gpTitle.setStyle("-fx-background-color: whitesmoke");
        gpButton.setAlignment(Pos.CENTER_LEFT);
        gpButton.setPadding(new Insets(10));
        Label lbTitle = new Label("取还货");
        lbTitle.setGraphic(new ImageView());
        lbTitle.setStyle("-fx-background-color: whitesmoke");
        Button btnMin = new Button("最小化");
        Button btnMax = new Button("最大化");
        Button btnClose = new Button("关闭");
        Button btnConfirm =  CsButtonGroup.createSingleButton("确定", "icon/icon_ok.png");
        btnConfirm.setStyle("-fx-min-width: 150px;-fx-min-height: 60px;-fx-font-size: 1.4em");
        gpButton.setStyle("-fx-text-alignment:left;-fx-alignment: baseline-center;");
        btnClose.setOnAction(e -> {
            isshow = 0;
            primaryStage.close();
        });
        btnConfirm.setOnAction(e -> {
            isshow = 0;
            Thread thread= new Thread(() -> {
                updateIsSure();
            });
            thread.setDaemon(true);
            thread.start();

            primaryStage.close();
        });
        gpTitle.add(lbTitle, 0 , 0);
        gpTitle.add(btnClose, 3, 0);
        gpButton.add(btnConfirm, 1, 0);
        GridPane.setHgrow(lbTitle, Priority.ALWAYS);

        TabPane tabPane = new TabPane();
        tabPane.getStylesheets().add("styles/tab.css");
        tabPane.setTabClosingPolicy(TabPane.TabClosingPolicy.UNAVAILABLE);

        Tab inboundTab = new Tab("业务类型  [入库]"+"        数量  ["+inboundTabPage.getInbonudItemLength()+"]");

        Tab useTab = new Tab("业务类型  [取货]"+"        数量  ["+useTabPage.getInbonudItemLength()+"]");

        Tab backTab = new Tab("业务类型  [还货]"+"        数量  ["+backTabPage.getInbonudItemLength()+"]");
        errorTab = new Tab("异常标签"+"  数量  ["+erorrTabPage.getInbonudItemLength()+"]");
        useTab.setStyle("-fx-font-size: 1.7em;");
        //useTab.setStyle("-");
        //useTab.
        backTab.setStyle("-fx-font-size: 1.7em;");
        inboundTab.setStyle("-fx-font-size: 1.7em;");

        int count=inboundTabPage.getInbonudItemLength()+useTabPage.getInbonudItemLength()
                +backTabPage.getInbonudItemLength()
                +erorrTabPage.getInbonudItemLength();
        if(count==0) {
            return;
        }
        if(inboundTabPage.getInbonudItemLength()>0){
            tabPane.getTabs().addAll(inboundTab);
        }
        if(useTabPage.getInbonudItemLength()>0){
            tabPane.getTabs().addAll(useTab);
        }
        if(backTabPage.getInbonudItemLength()>0){
            tabPane.getTabs().addAll(backTab);
        }
        if(erorrTabPage.getInbonudItemLength()>0){
            tabPane.getTabs().addAll(errorTab);
        }
        errorTab.setStyle("-fx-font-size: 1.7em;-fx-background-color: red ;");
//        tabPane.getTabs().setAll(inboundTab,useTab,backTab);
        tabPane.setStyle("-fx-font-size: 1em;");
        tabPane.setTabMinWidth(350);
        tabPane.setTabMinHeight(150);
        useTab.setContent(useTabPage.tabUseContent());
        backTab.setContent(backTabPage.tabBackContent());
        inboundTab.setContent(inboundTabPage.tabInboundContent());
        errorTab.setContent(erorrTabPage.tabInboundContent());
        //tabPane.setStyle("-fx-background-color: red");
        //inboundTab.setStyle("-fx-background-color: red");
        root.setStyle("-fx-background-color: white ;" +
                "-fx-border-color: rgb(128,128,64);" +
                " -fx-border-width: 1;");
//        tabPane.setMinHeight(800);
        root.setCenter(tabPane);
        root.setBottom(gpButton);
        Scene scene = new Scene(root, 1000, 1000);
        primaryStage.setScene(scene);
        primaryStage.setX(140);
        primaryStage.setY(10);
       if(isshow == 0) {
            primaryStage.show();
            isshow = 1;
        }
        primaryStage.setOnCloseRequest((WindowEvent event)->{
            //mainPage.refreturn();
        });
    }
    public void start2(Stage stage,String num)  {
        if(isshow == 1) {
            isshow = 0;
            primaryStage.close();
        }
        primaryStage = new Stage();
        primaryStage.initOwner(stage);
        primaryStage.initModality(Modality.APPLICATION_MODAL);
        primaryStage.initStyle(StageStyle.TRANSPARENT);
        StackPane bp = new StackPane();

        BorderPane root = new BorderPane();
        GridPane gpTitle = new GridPane();
        GridPane gpButton = new GridPane();
        gpTitle.setAlignment(Pos.CENTER_LEFT);
        gpTitle.setPadding(new Insets(10));
        gpTitle.setStyle("-fx-background-color: whitesmoke");
        gpButton.setAlignment(Pos.CENTER_LEFT);
        gpButton.setPadding(new Insets(10));
        Label lbTitle = new Label("未归还操作");
        lbTitle.setGraphic(new ImageView());
        lbTitle.setStyle("-fx-background-color: whitesmoke");
        Button btnMin = new Button("最小化");
        Button btnMax = new Button("最大化");
        Button btnClose = new Button("关闭");
        Button btnConfirm =  CsButtonGroup.createSingleButton("确定", "icon/icon_ok.png");
        btnConfirm.setStyle("-fx-min-width: 150px;-fx-min-height: 60px;-fx-font-size: 1.4em");
        gpButton.setStyle("-fx-text-alignment:left;-fx-alignment: baseline-center;");
        btnClose.setOnAction(e -> {
            isshow = 0;
            primaryStage.close();
        });
        btnConfirm.setOnAction(e -> {
            isshow = 0;
            primaryStage.close();
        });
        gpTitle.add(lbTitle, 0 , 0);
        gpTitle.add(btnClose, 3, 0);
        gpButton.add(btnConfirm, 1, 0);
        GridPane.setHgrow(lbTitle, Priority.ALWAYS);

        TabPane tabPane = new TabPane();
        tabPane.getStylesheets().add("styles/tab.css");
        tabPane.setTabClosingPolicy(TabPane.TabClosingPolicy.UNAVAILABLE);

        Tab inboundTab = new Tab("[未归还操作]"+"        数量  ["+num+"]");

        tabPane.getTabs().setAll(inboundTab);
        inboundTab.setStyle("-fx-font-size: 1.7em;");
        tabPane.setStyle("-fx-font-size: 1em;");
        tabPane.setTabMinWidth(350);
        tabPane.setTabMinHeight(50);

        inboundTab.setContent(useConSumeTabPage.tabUseContent());

        root.setStyle("-fx-background-color: white ;" +
                "-fx-border-color: rgb(128,128,64);" +
                " -fx-border-width: 1;");
//        tabPane.setMinHeight(800);
        root.setCenter(tabPane);
        root.setBottom(gpButton);
        Scene scene = new Scene(root, 1150, 1000);
        primaryStage.setScene(scene);
        primaryStage.setX(40);
        primaryStage.setY(10);
        if(isshow == 0) {
            primaryStage.show();
            isshow = 1;
        }
    }
    @Override
    protected Node constructNode() {
        return null;
    }

    @Override
    public void refresh() {

    }
}