@Override public Node showView() { Tab tab = new Tab("View Heat CHart : Search"); try { VBox main = ViewLayout.getMainVBox("View Heat Chart", "Details"); final ObservableList<HeatChartMaster> mailboxData = FXCollections.observableArrayList(); main.getChildren() .addAll(SearchBoxUtil.getHeatChartSearchBox("Heat Chart Number", mailboxData)); final TableView<HeatChartMaster> tableMailbox = TableUtil.createSearchHeatChartTable(); main.getChildren().add(ControlsUtil.makeScrollable(tableMailbox)); tableMailbox.setItems(mailboxData); tableMailbox.setOnMouseClicked( new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent mouseEvent) { if (mouseEvent.getClickCount() == 2) { HeatChartMaster selHeatChart = tableMailbox.getSelectionModel().getSelectedItem(); if (selHeatChart != null) { createViewTab(selHeatChart); } } } }); EventHandler<ActionEvent> viewHeatChartEventHandler = new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { HeatChartMaster heatChart = tableMailbox.getSelectionModel().getSelectedItem(); if (heatChart != null) { createViewTab(heatChart); } } }; tableMailbox.setContextMenu( TableContextMenu.getViewHeatChartContextMenu(viewHeatChartEventHandler)); tab.setContent(ControlsUtil.makeScrollable(main)); tab.setClosable(false); pane.getTabs().add(tab); pane.setSide(Side.TOP); return pane; } catch (HibernateException e) { LoggerUtil.getLogger().debug(e); Alert.showAlert( Context.getWindowStage(), "Error", "Error", "Some error occured. Details...\n" + e.getMessage()); return new ErrorView().showView(); } catch (MalformedURLException ex) { LoggerUtil.getLogger().debug(ex); Alert.showAlert( Context.getWindowStage(), "Error", "Error", "Some error occured. Details...\n" + ex.getMessage()); return new ErrorView().showView(); } }
private void createViewTab(final HeatChartMaster heatChart) { for (Tab selTab : pane.getTabs()) { if (selTab.getId() != null && selTab.getId().equalsIgnoreCase(heatChart.getChartNumber())) { pane.getSelectionModel().select(selTab); return; } } Tab tab = new Tab("View Heat Chart : " + heatChart.getChartNumber()); tab.setId(heatChart.getChartNumber()); VBox main = ViewLayout.getMainVBox("Heat Chart", "Details"); GridPane form = new GridPane(); form.setHgap(ViewLayout.H_SPACE); form.setVgap(ViewLayout.V_SPACE); Label equipmentLabel = new Label("Equipment"); equipmentLabel.setPrefWidth(ViewLayout.LABEL_WIDTH); final ViewBox equipmentTextField = new ViewBox("Equipment", heatChart.equipmentProperty()); Label customerLabel = new Label("Customer"); customerLabel.setPrefWidth(ViewLayout.LABEL_WIDTH); final ViewBox customerTextField = new ViewBox("Customer", heatChart.customerProperty()); Label poDetailsLabel = new Label("PO Details"); poDetailsLabel.setPrefWidth(ViewLayout.LABEL_WIDTH); final ViewBox poDetailsTextField = new ViewBox("PO Details", heatChart.poDetailsProperty()); Label drawingLabel = new Label("Drawing No."); drawingLabel.setPrefWidth(ViewLayout.LABEL_WIDTH); final ViewBox drawingTextField = new ViewBox("Drawing No.", heatChart.drawingNumberProperty()); Label suryeyorLabel = new Label("Surveyor"); suryeyorLabel.setPrefWidth(ViewLayout.LABEL_WIDTH); final ViewBox suryeyorTextField = new ViewBox("Suryeyor", heatChart.surveyorProperty()); Label tagNumberLabel = new Label("Tag Number"); suryeyorLabel.setPrefWidth(ViewLayout.LABEL_WIDTH); final ViewBox tagNumberTextField = new ViewBox("Tag Number", heatChart.tagNumberProperty()); form.add(equipmentLabel, 0, 0); form.add(equipmentTextField, 1, 0); form.add(customerLabel, 2, 0); form.add(customerTextField, 3, 0); form.add(poDetailsLabel, 4, 0); form.add(poDetailsTextField, 5, 0); form.add(drawingLabel, 0, 1); form.add(drawingTextField, 1, 1); form.add(suryeyorLabel, 2, 1); form.add(suryeyorTextField, 3, 1); form.add(tagNumberLabel, 4, 1); form.add(tagNumberTextField, 5, 1); main.getChildren().addAll(form); final ObservableList<HeatChartSheets> data = FXCollections.observableArrayList(); TableView<HeatChartSheets> table = TableUtil.createViewHeatChartSheetTable(); data.setAll(heatChart.getHeatChartSheets()); table.setItems(data); main.getChildren().addAll(ControlsUtil.makeScrollable(table)); final HBox buttons = new HBox(ViewLayout.H_SPACE); buttons.setTranslateY(32); final Button printButton = new Button("Print"); printButton.getStyleClass().add("submit-button"); buttons.getChildren().addAll(printButton); main.getChildren().addAll(buttons); printButton.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { printHeatChart.setHeatChart(heatChart); printHeatChart.restart(); } }); Context.getWindowBottomText() .textProperty() .bind(Bindings.format("%s", printHeatChart.stateProperty())); printHeatChart .stateProperty() .addListener( new ChangeListener<Worker.State>() { @Override public void changed( ObservableValue<? extends Worker.State> observable, Worker.State oldValue, Worker.State newState) { if (newState == Worker.State.SUCCEEDED) { Alert.showAlert( Context.getWindowStage(), "Alert", "Alert", "The report has been saved as " + printHeatChart.getValue()); Context.getHostServices().showDocument(printHeatChart.getValue()); } else if (newState == Worker.State.FAILED) { Alert.showAlert( Context.getWindowStage(), "Error", "Error", "Some error cooured. Details : " + printHeatChart.getException().getCause()); } } }); tab.setContent(ControlsUtil.makeScrollable(main)); pane.getTabs().add(tab); }
private void createEditTab(final UserMaster user) { for (Tab selTab : getTabs()) { if (selTab.getId() != null && selTab.getId().equalsIgnoreCase(user.getUserName())) { getSelectionModel().select(selTab); return; } } Tab tab = new Tab("Edit User : "******"User", "Details"); GridPane form = new GridPane(); form.setHgap(ViewLayout.H_SPACE); form.setVgap(ViewLayout.V_SPACE); Label userNameLabel = new Label("User Name"); userNameLabel.setPrefWidth(ViewLayout.LABEL_WIDTH); ViewBox userNameTextBox = new ViewBox(user.userNameProperty()); Label passwordLabel = new Label("Password"); passwordLabel.setPrefWidth(ViewLayout.LABEL_WIDTH); final PasswordBox passwordBox = new PasswordBox("Password", user.passwordProperty()); Label confirmPasswordLabel = new Label("Confirm Password"); confirmPasswordLabel.setPrefWidth(ViewLayout.LABEL_WIDTH); final PasswordBox confirmPasswordBox = new PasswordBox("Confirm Password", user.confirmPasswordProperty()); Label roleLabel = new Label("Role"); roleLabel.setPrefWidth(ViewLayout.LABEL_WIDTH); final RoleEditableComboBox roleChoiceBox = new RoleEditableComboBox("Role", user.roleProperty()); form.add(userNameLabel, 0, 0); form.add(userNameTextBox, 1, 0); form.add(passwordLabel, 0, 1); form.add(passwordBox, 1, 1); form.add(confirmPasswordLabel, 0, 2); form.add(confirmPasswordBox, 1, 2); form.add(roleLabel, 0, 3); form.add(roleChoiceBox, 1, 3); main.getChildren().addAll(form); final HBox buttons = new HBox(ViewLayout.H_SPACE); buttons.setTranslateY(32); final Button updateButton = new Button("Update"); updateButton.getStyleClass().add("submit-button"); main.getChildren().addAll(buttons); updateButton.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { if (Validator.validateUserData(user)) { ServiceManager.getUserDetailsService(user, PersistType.UPDATE).restart(); } } }); buttons.getChildren().addAll(updateButton); tab.setContent(ControlsUtil.makeScrollable(main)); getTabs().add(tab); }
public EditUser() { Tab tab = new Tab("Edit User : Details"); try { VBox main = ViewLayout.getMainVBox("Edit User", "Details"); final TableView<UserMaster> table = TableUtil.createEditUserTable(); main.getChildren().add(table); final ObservableList<UserMaster> mailboxData = FXCollections.observableArrayList(UserData.getUserList()); table.setItems(mailboxData); EventHandler<ActionEvent> editUserEventHandler = new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { UserMaster user = table.getSelectionModel().getSelectedItem(); if (user != null) { createEditTab(user); } } }; EventHandler<ActionEvent> deleteUserEventHandler = new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { final UserMaster user = table.getSelectionModel().getSelectedItem(); EventHandler<ActionEvent> delUserEvent = new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent arg0) { PersistUserDetails pud = ServiceManager.getUserDetailsService(user, PersistType.DELETE); pud.restart(); pud.setOnSucceeded( new EventHandler<WorkerStateEvent>() { @Override public void handle(WorkerStateEvent e) { mailboxData.remove(user); } }); } }; Confirm.showConfirm( Context.getWindowStage(), "Confirm", "Confirm", "Delete User : "******". Are you sure?", delUserEvent); } }; table.setContextMenu( TableContextMenu.getEditUserContextMenu(editUserEventHandler, deleteUserEventHandler)); table.setOnMouseClicked( new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent mouseEvent) { if (mouseEvent.getClickCount() == 2) { UserMaster user = table.getSelectionModel().getSelectedItem(); if (user != null) { createEditTab(user); } } } }); tab.setContent(ControlsUtil.makeScrollable(main)); tab.setClosable(false); getTabs().add(tab); setSide(Side.TOP); } catch (Exception e) { LoggerUtil.getLogger().debug(e); Alert.showAlert( Context.getWindowStage(), "Error", "Error", "Some error occured. Details...\n" + e.getMessage()); } }
public void createAgencyTab() { Tab agencyTab = new Tab("Agency"); final AgencyProperty agency = new AgencyProperty(); VBox main = ViewLayout.getMainVBox("Add Agency", "Details"); GridPane agencyForm = new GridPane(); agencyForm.setHgap(ViewLayout.H_SPACE); agencyForm.setVgap(ViewLayout.V_SPACE); Label agencyCodeLabel = new Label("Agency Code"); agencyCodeLabel.setPrefWidth(ViewLayout.LABEL_WIDTH); final ViewIntegerBox agencyCodeBox = new ViewIntegerBox(agency.get().getAgencyCode(), agency.get().agencyCodeProperty()); Label agencyNameLabel = new Label("Agency Name"); agencyNameLabel.setPrefWidth(ViewLayout.LABEL_WIDTH); final AgencyComboBox agencyNameBox = new AgencyComboBox("Agency Name", agency); Label agencyRemarksLabel = new Label("Remarks"); agencyRemarksLabel.setPrefWidth(ViewLayout.LABEL_WIDTH); final TextBox agencyRemarksTextBox = new TextBox("Remarks", agency.get().remarksProperty()); Button agencyButton = new Button("Submit"); agencyButton.getStyleClass().add("submit-button"); agencyButton.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { if (agencyNameBox.getText().trim().length() > 0) { if (agencyRemarksTextBox.getText().trim().length() == 0) { agency.get().setRemarks(agency.get().getAgencyName()); } PersistValidationDetails pvd = ServiceManager.getValidationDetailsService( "Agency", agency.get(), PersistType.UPDATE); pvd.restart(); pvd.setOnSucceeded( new EventHandler<WorkerStateEvent>() { @Override public void handle(WorkerStateEvent e) { agency.get().clean(); } }); } else { Alert.showAlert( Context.getWindowStage(), "Error", "Error", "Please enter agency name."); } } }); agencyForm.add(agencyCodeLabel, 0, 0); agencyForm.add(agencyCodeBox, 1, 0); agencyForm.add(agencyNameLabel, 0, 1); agencyForm.add(agencyNameBox, 1, 1); agencyForm.add(agencyRemarksLabel, 0, 2); agencyForm.add(agencyRemarksTextBox, 1, 2); agencyForm.add(agencyButton, 1, 3); main.getChildren().add(agencyForm); agencyTab.setContent(ControlsUtil.makeScrollable(main)); agencyTab.setClosable(false); getTabs().add(agencyTab); }