/** Initializes the controller class. */ @Override public void initialize(URL url, ResourceBundle rb) { logger.entry(); OkButton.disableProperty() .bind( Bindings.isEmpty(FederationExecutionName.textProperty()) .or(Bindings.isEmpty(FederateType.textProperty()))); logger.exit(); }
@FXML public void registrarArticulo(ActionEvent e) { Articulo art = new Articulo(); cruds = new CRUDArticulos(); boolean registrado; int indiceCategoria = cmbCategorias.getSelectionModel().getSelectedIndex() + 1; art.setNombre(tfNombreArticulo.getText()); art.setMarca(tfMarca.getText()); art.setDescripcion_estado(txaDescripcion.getText()); art.setEstado(true); RadioButton chk = (RadioButton) acceso.getSelectedToggle(); if (chk.getText().equals("Prestable")) art.setAcceso(true); else art.setAcceso(false); art.setIdcategoria(indiceCategoria); registrado = cruds.registrarArticulo(art); System.out.println(art.getIdcategoria() + "" + art.isAcceso()); if (registrado) JOptionPane.showMessageDialog(null, "algo salio mal menor"); else JOptionPane.showMessageDialog(null, "se ha registrado con exito menor"); }
@FXML private void Ok_click(ActionEvent event) { logger.entry(); LogEntry log = new LogEntry("6.16", "Local Delete Object Instance service"); try { ObjectInstanceHandle instanceHandle = rtiAmb .getObjectInstanceHandleFactory() .decode( ByteBuffer.allocate(4) .putInt(Integer.parseInt(ObjectInstanceDesignator.getText())) .array(), 0); log.getSuppliedArguments() .add( new ClassValuePair( "Object instance designator", ObjectInstanceHandle.class, instanceHandle.toString())); rtiAmb.localDeleteObjectInstance(instanceHandle); log.setDescription("Local Object instance deleted successfully"); log.setLogType(LogEntryType.REQUEST); } catch (FederateNotExecutionMember | NotConnected | NumberFormatException | CouldNotDecode | RTIinternalError | OwnershipAcquisitionPending | FederateOwnsAttributes | ObjectInstanceNotKnown | SaveInProgress | RestoreInProgress ex) { log.setException(ex); log.setLogType(LogEntryType.ERROR); logger.log(Level.ERROR, ex.getMessage(), ex); } catch (Exception ex) { log.setException(ex); log.setLogType(LogEntryType.FATAL); logger.log(Level.FATAL, ex.getMessage(), ex); } logEntries.add(log); ((Stage) OkButton.getScene().getWindow()).close(); logger.exit(); }
@FXML public void consultarArticulos(ActionEvent e) { cruds = new CRUDArticulos(); Articulo a; ArrayList<Articulo> articulos = new ArrayList<Articulo>(); try { articulos = cruds.consultar(tfArtBuscar.getText()); for (int i = 0; i < articulos.size(); i++) { System.out.println(articulos.get(i).getNombre()); System.out.println(articulos.get(i).getNombre()); } // tfNombreArticulo.setText(a.getNombre()); } catch (Exception ex) { JOptionPane.showMessageDialog(null, "Error"); } }
/** Initializes the controller class. */ @Override public void initialize(URL url, ResourceBundle rb) { logger.entry(); OkButton.disableProperty().bind(ObjectInstanceDesignator.textProperty().isEmpty()); logger.exit(); }
public static void setJar(final Tile node) { node.data.put("type", "Jar"); List<Node> toRemove = new ArrayList<>(); for (Node n : node.node.getChildren()) { if (!n.getId().equals("delete")) { if (n.getId().equals("typeLabel")) { Label l = (Label) n; l.setText("jar"); l.setTranslateY(l.getTranslateY() - 1); } else { toRemove.add(n); } } } VBox leftPadding = new VBox(); leftPadding.setPrefWidth(14); VBox buttons = new VBox(); VBox textBoxes = new VBox(); VBox extra = new VBox(); buttons.setSpacing(5); textBoxes.setSpacing(5); extra.setSpacing(5); buttons.setPadding(new Insets(7, 0, 0, 0)); textBoxes.setPadding(new Insets(7, 0, 0, 0)); extra.setPadding(new Insets(7, 0, 0, 0)); textBoxes.setTranslateX(17); extra.setTranslateX(32); node.node.getChildren().removeAll(toRemove); final String name = "Package Name"; final String name2 = "Jar Name"; Button findPkg = new Button(); final TextField pkgText = new TextField(); final TextField jarName = new TextField(); findPkg.getStyleClass().add("defaultButton"); findPkg.setText("Find Package Name"); findPkg.setPrefHeight(25); findPkg.setTranslateX(12); findPkg.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { String mainClassName = Util.packageNameFromTile(); if (mainClassName != null) { pkgText.setText(mainClassName); } } }); pkgText.setText(name); pkgText.setPrefSize(150, 27); pkgText.setFont(Font.font("Segoe UI")); pkgText.setId("textBox"); pkgText .textProperty() .addListener( new ChangeListener<String>() { @Override public void changed( ObservableValue<? extends String> observable, String oldValue, String newValue) { node.data.put("package", pkgText.getText().trim()); } }); pkgText .focusedProperty() .addListener( new ChangeListener<Boolean>() { @Override public void changed( ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { if (newValue == true && pkgText.getText().equals(name)) { pkgText.setText(""); } else if (newValue == false && pkgText.getText().trim().equals("")) { pkgText.setText(name); } } }); jarName.setText(name2); jarName.setPrefSize(150, 27); jarName.setFont(Font.font("Segoe UI")); jarName.setId("textBox"); jarName .textProperty() .addListener( new ChangeListener<String>() { @Override public void changed( ObservableValue<? extends String> observable, String oldValue, String newValue) { node.data.put("jarname", jarName.getText().trim()); } }); jarName .focusedProperty() .addListener( new ChangeListener<Boolean>() { @Override public void changed( ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { if (newValue == true && jarName.getText().equals(name2)) { jarName.setText(""); } else if (newValue == false && jarName.getText().trim().equals("")) { jarName.setText(name2); } } }); final String defTxt = "Additional Flags"; final TextField flags = new TextField(); flags.setText(defTxt); flags.setPrefSize(150, 27); flags.setFont(Font.font("Segoe UI")); flags.setId("textBox"); flags .focusedProperty() .addListener( new ChangeListener<Boolean>() { @Override public void changed( ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { if (newValue == true && flags.getText().equals(defTxt)) { flags.setText(""); } else if (newValue == false && flags.getText().trim().equals("")) { flags.setText(defTxt); } } }); flags .textProperty() .addListener( new ChangeListener<String>() { @Override public void changed( ObservableValue<? extends String> observable, String oldValue, String newValue) { node.data.put("flags", flags.getText().trim()); } }); final String defTxt2 = "Output Directory"; final TextField outputDir = new TextField(); outputDir.setText(defTxt2); outputDir.setPrefSize(150, 27); outputDir.setFont(Font.font("Segoe UI")); outputDir.setId("textBox"); outputDir .focusedProperty() .addListener( new ChangeListener<Boolean>() { @Override public void changed( ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { if (newValue == true && outputDir.getText().equals(defTxt2)) { outputDir.setText(""); } else if (newValue == false && outputDir.getText().trim().equals("")) { outputDir.setText(defTxt2); } } }); outputDir .textProperty() .addListener( new ChangeListener<String>() { @Override public void changed( ObservableValue<? extends String> observable, String oldValue, String newValue) { node.data.put("output", outputDir.getText().trim()); } }); buttons.getChildren().addAll(findPkg); textBoxes.getChildren().addAll(pkgText, jarName); extra.getChildren().addAll(flags, outputDir); node.node.getChildren().addAll(leftPadding, buttons, textBoxes, extra); }
public void nuevo(ActionEvent e) { tfMarca.setText(""); tfNombreArticulo.setText(""); txaDescripcion.setText(""); }
@Override public void start(Stage primaryStage) throws Exception { /* create the menu (for the top of the user interface) */ Menu fileMenu = new Menu("File"); MenuItem newMenuItem = new MenuItem("New", imageFile("images/new.png")); newMenuItem.setAccelerator(KeyCombination.keyCombination("Ctrl+N")); fileMenu.getItems().add(newMenuItem); fileMenu.getItems().add(new SeparatorMenuItem()); fileMenu.getItems().add(new MenuItem("Open...", imageFile("images/open.png"))); fileMenu.getItems().add(new SeparatorMenuItem()); MenuItem saveMenuItem = new MenuItem("Save", imageFile("images/save.png")); fileMenu.getItems().add(saveMenuItem); MenuItem saveAsMenuItem = new MenuItem("Save As...", imageFile("images/save_as.png")); fileMenu.getItems().add(saveAsMenuItem); fileMenu.getItems().add(new SeparatorMenuItem()); MenuItem exitMenuItem = new MenuItem("Exit", imageFile("images/exit.png")); fileMenu.getItems().add(exitMenuItem); exitMenuItem.setAccelerator(KeyCombination.keyCombination("Ctrl+Q")); exitMenuItem.setOnAction(e -> System.exit(0)); Menu editMenu = new Menu("Edit"); editMenu.getItems().add(new MenuItem("Cut", imageFile("images/cut.png"))); editMenu.getItems().add(new MenuItem("Copy", imageFile("images/copy.png"))); editMenu.getItems().add(new MenuItem("Paste", imageFile("images/paste.png"))); Menu helpMenu = new Menu("Help"); helpMenu.getItems().add(new MenuItem("About...", imageFile("images/about.png"))); helpMenu.getItems().add(new SeparatorMenuItem()); helpMenu.getItems().add(new MenuItem("Help...", imageFile("images/help.png"))); MenuBar menuBar = new MenuBar(); menuBar.getMenus().add(fileMenu); menuBar.getMenus().add(editMenu); menuBar.getMenus().add(helpMenu); primaryStage.setTitle("Lab08"); // grid contains all of the textfeilds, labels , buttons, ect.. GridPane grid = new GridPane(); // the tableview puts all of our data into a exel like format TableView<StudentRecord> table = new TableView<>(); table.setItems(DataSource.getAllMarks()); table.setEditable(true); TableColumn<StudentRecord, String> IDColumn = null; IDColumn = new TableColumn<>("SID"); IDColumn.setMinWidth(100); // the thing in quotes is what it will search for in the StudentRecords.java (MAKE SURE THERE IS // A GET FUNCTION FOR THAT VARIBALE) IDColumn.setCellValueFactory(new PropertyValueFactory<>("ID")); TableColumn<StudentRecord, Double> AssignmentColumn = null; AssignmentColumn = new TableColumn<>("Assignment"); AssignmentColumn.setMinWidth(100); AssignmentColumn.setCellValueFactory(new PropertyValueFactory<>("Assign")); TableColumn<StudentRecord, Float> MidtermColumn = null; MidtermColumn = new TableColumn<>("Midterm"); MidtermColumn.setMinWidth(100); MidtermColumn.setCellValueFactory(new PropertyValueFactory<>("Midterm")); TableColumn<StudentRecord, Float> FinalColumn = null; FinalColumn = new TableColumn<>("Final Exam"); FinalColumn.setMinWidth(100); FinalColumn.setCellValueFactory(new PropertyValueFactory<>("Final")); TableColumn<StudentRecord, String> GradeColumn = null; GradeColumn = new TableColumn<>("Letter Grade"); GradeColumn.setMinWidth(100); GradeColumn.setCellValueFactory(new PropertyValueFactory<>("Grade")); table.getColumns().add(IDColumn); table.getColumns().add(AssignmentColumn); table.getColumns().add(MidtermColumn); table.getColumns().add(FinalColumn); table.getColumns().add(GradeColumn); Label IDLabel = new Label("SID:"); grid.add(IDLabel, 0, 0); TextField IDField = new TextField(); IDField.setPromptText("SID"); grid.add(IDField, 1, 0); Label AssignLabel = new Label("Assignments:"); grid.add(AssignLabel, 2, 0); TextField AssignField = new TextField(); AssignField.setPromptText("Assignment"); grid.add(AssignField, 3, 0); Label MidLabel = new Label("Midterm:"); grid.add(MidLabel, 0, 1); TextField midField = new TextField(); midField.setPromptText("Midterm"); grid.add(midField, 1, 1); Label FinalLabel = new Label("Final:"); grid.add(FinalLabel, 2, 1); TextField FinalField = new TextField(); FinalField.setPromptText("Final"); grid.add(FinalField, 3, 1); Button AddButton = new Button("Add"); AddButton.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { char Grade; String SID = IDField.getText(); Float Assignment = Float.parseFloat(AssignField.getText()); Float Midterm = Float.parseFloat(midField.getText()); Float Final = Float.parseFloat(FinalField.getText()); table.getItems().add(new StudentRecord(SID, Assignment, Midterm, Final)); IDField.setText(""); AssignField.setText(""); midField.setText(""); FinalField.setText(""); } }); grid.add(AddButton, 0, 2); layout = new BorderPane(); layout.setTop(menuBar); layout.setCenter(table); layout.setBottom(grid); Scene scene = new Scene(layout); grid.setPadding(new Insets(10, 10, 10, 10)); grid.setVgap(10); grid.setHgap(10); primaryStage.setScene(scene); primaryStage.show(); }
@Override public void start(Stage primaryStage) throws Exception { primaryStage.setTitle("JavaFX Demo"); /* create the menu (for the top of the user interface) */ Menu fileMenu = new Menu("File"); MenuItem newMenuItem = new MenuItem("New", imageFile("images/new.png")); newMenuItem.setAccelerator(KeyCombination.keyCombination("Ctrl+N")); fileMenu.getItems().add(newMenuItem); fileMenu.getItems().add(new SeparatorMenuItem()); fileMenu.getItems().add(new MenuItem("Open...", imageFile("images/open.png"))); fileMenu.getItems().add(new SeparatorMenuItem()); fileMenu.getItems().add(new MenuItem("Save", imageFile("images/save.png"))); fileMenu.getItems().add(new MenuItem("Save As...", imageFile("images/save_as.png"))); fileMenu.getItems().add(new SeparatorMenuItem()); MenuItem exitMenuItem = new MenuItem("Exit", imageFile("images/exit.png")); fileMenu.getItems().add(exitMenuItem); exitMenuItem.setAccelerator(KeyCombination.keyCombination("Ctrl+Q")); exitMenuItem.setOnAction(e -> System.exit(0)); Menu editMenu = new Menu("Edit"); editMenu.getItems().add(new MenuItem("Cut", imageFile("images/cut.png"))); editMenu.getItems().add(new MenuItem("Copy", imageFile("images/copy.png"))); editMenu.getItems().add(new MenuItem("Paste", imageFile("images/paste.png"))); Menu helpMenu = new Menu("Help"); helpMenu.getItems().add(new MenuItem("About...", imageFile("images/about.png"))); helpMenu.getItems().add(new SeparatorMenuItem()); helpMenu.getItems().add(new MenuItem("Help...", imageFile("images/help.png"))); MenuBar menuBar = new MenuBar(); menuBar.getMenus().add(fileMenu); menuBar.getMenus().add(editMenu); menuBar.getMenus().add(helpMenu); /* create the table (for the center of the user interface) */ table = new TableView<>(); table.setItems(DataSource.getAllStudents()); table.setEditable(true); /* create the table's columns */ TableColumn<Student, Integer> sidColumn = null; sidColumn = new TableColumn<>("SID"); sidColumn.setMinWidth(100); sidColumn.setCellValueFactory(new PropertyValueFactory<>("sid")); TableColumn<Student, String> firstNameColumn = null; firstNameColumn = new TableColumn<>("First Name"); firstNameColumn.setMinWidth(200); firstNameColumn.setCellValueFactory(new PropertyValueFactory<>("firstName")); firstNameColumn.setCellFactory(TextFieldTableCell.<Student>forTableColumn()); firstNameColumn.setOnEditCommit( (CellEditEvent<Student, String> event) -> { ((Student) event.getTableView().getItems().get(event.getTablePosition().getRow())) .setFirstName(event.getNewValue()); }); TableColumn<Student, String> lastNameColumn = null; lastNameColumn = new TableColumn<>("Last Name"); lastNameColumn.setMinWidth(200); lastNameColumn.setCellValueFactory(new PropertyValueFactory<>("lastName")); lastNameColumn.setCellFactory(TextFieldTableCell.<Student>forTableColumn()); lastNameColumn.setOnEditCommit( (CellEditEvent<Student, String> event) -> { ((Student) event.getTableView().getItems().get(event.getTablePosition().getRow())) .setLastName(event.getNewValue()); }); TableColumn<Student, Double> gpaColumn = null; gpaColumn = new TableColumn<>("GPA"); gpaColumn.setMinWidth(100); gpaColumn.setCellValueFactory(new PropertyValueFactory<>("gpa")); table.getColumns().add(sidColumn); table.getColumns().add(lastNameColumn); table.getColumns().add(firstNameColumn); table.getColumns().add(gpaColumn); /* create an edit form (for the bottom of the user interface) */ GridPane editArea = new GridPane(); editArea.setPadding(new Insets(10, 10, 10, 10)); editArea.setVgap(10); editArea.setHgap(10); Label sidLabel = new Label("SID:"); editArea.add(sidLabel, 0, 0); TextField sidField = new TextField(); sidField.setPromptText("SID"); editArea.add(sidField, 1, 0); Label fnameLabel = new Label("First name:"); editArea.add(fnameLabel, 0, 1); TextField fnameField = new TextField(); fnameField.setPromptText("First Name"); editArea.add(fnameField, 1, 1); Label lnameLabel = new Label("Last name:"); editArea.add(lnameLabel, 0, 2); TextField lnameField = new TextField(); lnameField.setPromptText("Last Name"); editArea.add(lnameField, 1, 2); Label gpaLabel = new Label("GPA:"); editArea.add(gpaLabel, 0, 3); TextField gpaField = new TextField(); gpaField.setPromptText("GPA"); editArea.add(gpaField, 1, 3); Button addButton = new Button("Add"); addButton.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { int sid = Integer.parseInt(sidField.getText()); String firstName = fnameField.getText(); String lastName = lnameField.getText(); double gpa = Double.parseDouble(gpaField.getText()); table.getItems().add(new Student(sid, firstName, lastName, gpa)); sidField.setText(""); fnameField.setText(""); lnameField.setText(""); gpaField.setText(""); } }); editArea.add(addButton, 1, 4); /* arrange all components in the main user interface */ layout = new BorderPane(); layout.setTop(menuBar); layout.setCenter(table); layout.setBottom(editArea); Scene scene = new Scene(layout, 600, 600); primaryStage.setScene(scene); primaryStage.show(); }
@FXML private void OK_click(ActionEvent event) { logger.entry(); FederateHandle federateHandle; LogEntry log = new LogEntry("4.9", "Join Federation Execution service"); try { if (!FederateName.getText().isEmpty()) { log.getSuppliedArguments() .add(new ClassValuePair("Federate Name", String.class, FederateName.getText())); } log.getSuppliedArguments() .add(new ClassValuePair("Federate Type", String.class, FederateType.getText())); log.getSuppliedArguments() .add( new ClassValuePair( "Federation Execution Name", String.class, FederationExecutionName.getText())); List<URL> foms = new ArrayList<>(); int i = 1; for (File file : FomModuleDesignators.getFiles()) { foms.add(file.toURI().toURL()); log.getSuppliedArguments() .add( new ClassValuePair( "FOM Module Deisgnator " + i++, URL.class, file.toURI().toURL().toString())); } if (FederateName.getText().isEmpty() && FomModuleDesignators.getFileNames().isEmpty()) { federateHandle = rtiAmb.joinFederationExecution( FederateType.getText(), FederationExecutionName.getText()); } else if (FomModuleDesignators.getFileNames().isEmpty()) { federateHandle = rtiAmb.joinFederationExecution( FederateName.getText(), FederateType.getText(), FederationExecutionName.getText()); } else if (FederateName.getText().isEmpty()) { federateHandle = rtiAmb.joinFederationExecution( FederateType.getText(), FederationExecutionName.getText(), foms.toArray(new URL[foms.size()])); } else { federateHandle = rtiAmb.joinFederationExecution( FederateName.getText(), FederateType.getText(), FederationExecutionName.getText(), foms.toArray(new URL[foms.size()])); } log.getReturnedArguments() .add( new ClassValuePair( "Federate Handle", FederateHandle.class, federateHandle.toString())); log.setDescription("Federate joined federation execution successfully"); log.setLogType(LogEntryType.REQUEST); logicalTimeFactory = rtiAmb.getTimeFactory(); currentLogicalTime = logicalTimeFactory.makeInitial(); // subscribe to HLAcurrentFDD to retrieve FDD ObjectClassHandle FederationHandle = rtiAmb.getObjectClassHandle("HLAobjectRoot.HLAmanager.HLAfederation"); currentFDDHandle = rtiAmb.getAttributeHandle(FederationHandle, "HLAcurrentFDD"); AttributeHandleSet set = rtiAmb.getAttributeHandleSetFactory().create(); set.add(currentFDDHandle); rtiAmb.subscribeObjectClassAttributes(FederationHandle, set); rtiAmb.requestAttributeValueUpdate(FederationHandle, set, null); // In case of HLA_EVOKED we require this line to receive the FDD rtiAmb.evokeMultipleCallbacks( .05, 1); // evoke one callback will not be enough because the reflect attribute is the second // one } catch (CouldNotCreateLogicalTimeFactory | CallNotAllowedFromWithinCallback | CouldNotOpenFDD | ErrorReadingFDD | InconsistentFDD | FederateNameAlreadyInUse | FederateAlreadyExecutionMember | FederationExecutionDoesNotExist | SaveInProgress | RestoreInProgress | NotConnected | RTIinternalError ex) { log.setException(ex); log.setLogType(LogEntryType.ERROR); logger.log(Level.ERROR, ex.getMessage(), ex); } catch (Exception ex) { log.setException(ex); log.setLogType(LogEntryType.FATAL); logger.log(Level.FATAL, ex.getMessage(), ex); } logEntries.add(log); ((Stage) FederationExecutionName.getScene().getWindow()).close(); logger.exit(); }
@FXML private void Cancel_click(ActionEvent event) { logger.entry(); ((Stage) FederationExecutionName.getScene().getWindow()).close(); logger.exit(); }
private void handleButtonAction(ActionEvent event) { textf.appendText("Tjena"); }