Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import ...
- // Контроллер для Главного окна
- public class Controller {
- private CollectionEditable passbookimpl = new CollectionEditable();
- private Stage mainStage;
- @FXML
- private Button addButton;
- @FXML
- private Button changeButton;
- @FXML
- private Button delButton;
- @FXML
- private TableView tablePassBook;
- @FXML
- private TableColumn<Website, String> columnSite;
- @FXML
- private TableColumn<Website, String> columnSiteLogin;
- @FXML
- private TableColumn<Website, String> columnSitePass;
- @FXML
- private TableColumn<Website, String> columnFtp;
- @FXML
- private TableColumn<Website, String> columnFtpLogin;
- @FXML
- private TableColumn<Website, String> columnFtpPass;
- @FXML
- private TableColumn<Website, String> columnPort;
- @FXML
- private TableColumn<Website, String> columnPerson;
- @FXML
- private TableColumn<Website, String> columnPersonEmail;
- @FXML
- private TableColumn<Website, String> columnPersonPass;
- @FXML
- private TableColumn<Website, String> columnPersonPhone;
- @FXML
- private TableColumn<Website, String> columnDbName;
- @FXML
- private TableColumn<Website, String> columnDbUser;
- @FXML
- private TableColumn<Website, String> columnDbPass;
- @FXML
- private TableColumn<Website, String> columnDbHost;
- @FXML
- private TableColumn<Website, String> columnHostingUrl;
- @FXML
- private TableColumn<Website, String> columnHostingLogin;
- @FXML
- private TableColumn<Website, String> columnHostingPass;
- @FXML
- private TableColumn<Website, String> columnProviderUrl;
- @FXML
- private TableColumn<Website, String> columnProviderLogin;
- @FXML
- private TableColumn<Website, String> columnProviderPass;
- @FXML
- private TableColumn<Website, String> columnOtherUrl;
- @FXML
- private TableColumn<Website, String> columnOtherLogin;
- @FXML
- private TableColumn<Website, String> columnOtherPass;
- @FXML
- private TableColumn<Website, String> columnNotes;
- @FXML
- private TextField filterField;
- private static Statement stat;
- private static Connection c;
- @FXML
- private void initialize() {
- columnSite.setCellValueFactory(new PropertyValueFactory<Website, String>("site"));
- columnSiteLogin.setCellValueFactory(new PropertyValueFactory<Website, String>("siteLogin"));
- columnSitePass.setCellValueFactory(new PropertyValueFactory<Website, String>("sitePass"));
- columnFtp.setCellValueFactory(new PropertyValueFactory<Website, String>("ftp"));
- columnFtpLogin.setCellValueFactory(new PropertyValueFactory<Website, String>("ftpLogin"));
- columnFtpPass.setCellValueFactory(new PropertyValueFactory<Website, String>("ftpPass"));
- columnPort.setCellValueFactory(new PropertyValueFactory<Website, String>("port"));
- columnPerson.setCellValueFactory(new PropertyValueFactory<Website, String>("person"));
- columnPersonEmail.setCellValueFactory(new PropertyValueFactory<Website, String>("personEmail"));
- columnPersonPass.setCellValueFactory(new PropertyValueFactory<Website, String>("personPass"));
- columnPersonPhone.setCellValueFactory(new PropertyValueFactory<Website, String>("personPhone"));
- columnDbName.setCellValueFactory(new PropertyValueFactory<Website, String>("dbName"));
- columnDbUser.setCellValueFactory(new PropertyValueFactory<Website, String>("dbUser"));
- columnDbPass.setCellValueFactory(new PropertyValueFactory<Website, String>("dbPass"));
- columnDbHost.setCellValueFactory(new PropertyValueFactory<Website, String>("dbHost"));
- columnHostingUrl.setCellValueFactory(new PropertyValueFactory<Website, String>("hostingUrl"));
- columnHostingLogin.setCellValueFactory(new PropertyValueFactory<Website, String>("hostingLogin"));
- columnHostingPass.setCellValueFactory(new PropertyValueFactory<Website, String>("hostingPass"));
- columnProviderUrl.setCellValueFactory(new PropertyValueFactory<Website, String>("providerUrl"));
- columnProviderLogin.setCellValueFactory(new PropertyValueFactory<Website, String>("providerLogin"));
- columnProviderPass.setCellValueFactory(new PropertyValueFactory<Website, String>("providerPass"));
- columnOtherUrl.setCellValueFactory(new PropertyValueFactory<Website, String>("otherUrl"));
- columnOtherLogin.setCellValueFactory(new PropertyValueFactory<Website, String>("otherLogin"));
- columnOtherPass.setCellValueFactory(new PropertyValueFactory<Website, String>("otherPass"));
- columnNotes.setCellValueFactory(new PropertyValueFactory<Website, String>("notes"));
- .........
- try {
- fxmlLoader.setLocation(getClass().getResource("/addmodal/addpassw.fxml"));
- fxmlEdit = fxmlLoader.load();
- addpassw = fxmlLoader.getController();
- }catch (IOException e){
- e.printStackTrace();
- }
- }
- public void actionButtonPressed(ActionEvent actionEvent) {
- Object source = actionEvent.getSource();
- if (! (source instanceof Button)) {
- return;
- }
- Button clickedButton = (Button) source;
- Website selectedWebsite = (Website)tablePassBook.getSelectionModel().getSelectedItem();
- Window parentWindow = ((Node) actionEvent.getSource()).getScene().getWindow();
- switch (clickedButton.getId()) {
- case "addButton":
- addpassw.setWebsite(new Website());
- showDialog();
- passbookimpl.add(addpassw.getWebsite());
- break;
- case "changeButton":
- addpassw.setWebsite((Website)tablePassBook.getSelectionModel().getSelectedItem());
- showDialog();
- break;
- case "delButton":
- passbookimpl.delete((Website) tablePassBook.getSelectionModel().getSelectedItem());
- try {
- PreparedStatement statement = c.prepareStatement("DELETE FROM data WHERE id = ?");
- statement.setInt(1, selectedWebsite.getId());
- statement.executeUpdate();
- } catch(SQLException ex) {
- //System.out.println("Не удалось удалить запись");
- ex.printStackTrace();
- }
- break;
- }
- }
- public void sqlupdate(int id, String site, String siteLogin, String sitePass, String ftp, String ftpLogin, String ftpPass, String port, String person, String personEmail, String personPass, String personPhone, String dbName, String dbUser, String dbPass, String dbHost, String hostingUrl, String hostingLogin, String hostingPass, String providerUrl, String providerLogin, String providerPass, String otherUrl, String otherLogin, String otherPass, String notes ) {
- String updatesql = "UPDATE data SET site = ? , " + "siteLogin = ? ," + "sitePass = ? ," + "ftp = ?," + "ftpLogin = ?," + "ftpPass = ?," + "port = ?," + "person = ?," + "personEmail = ?," + "personPass = ?," + "personPhone = ?," + "dbName = ?," + "dbUser = ?," + "dbPass = ?," + "dbHost = ?," + "hostingUrl = ?," + "hostingLogin = ?," + "hostingPass = ?," + "providerUrl = ?," + "providerLogin = ?," + "providerPass = ?," + "otherUrl = ?," + "otherLogin = ?," + "otherPass = ?," + "notes = ? "
- + "WHERE id = ?";
- try {
- SQLiteConfig config = new SQLiteConfig();
- c = DriverManager.getConnection("jdbc:sqlite:c:\Users\Phoenix\IdeaProjects\PasswordKeeper\passwkeeper.db");
- //stat = c.createStatement();
- PreparedStatement pstmt = c.prepareStatement(updatesql);
- pstmt.setString(1, site);
- pstmt.setString(2, siteLogin);
- pstmt.setString(3, sitePass);
- pstmt.setString(4, ftp);
- pstmt.setString(5, ftpLogin);
- pstmt.setString(6, ftpPass);
- pstmt.setString(7, port);
- pstmt.setString(8, person);
- pstmt.setString(9, personEmail);
- pstmt.setString(10, personPass);
- pstmt.setString(11, personPhone);
- pstmt.setString(12, dbName);
- pstmt.setString(13, dbUser);
- pstmt.setString(14, dbPass);
- pstmt.setString(15, dbHost);
- pstmt.setString(16, hostingUrl);
- pstmt.setString(17, hostingLogin);
- pstmt.setString(18, hostingPass);
- pstmt.setString(19, providerUrl);
- pstmt.setString(20, providerLogin);
- pstmt.setString(21, providerPass);
- pstmt.setString(22, otherUrl);
- pstmt.setString(23, otherLogin);
- pstmt.setString(24, otherPass);
- pstmt.setString(25, notes);
- // update
- pstmt.executeUpdate();
- } catch (SQLException ex) {
- ex.printStackTrace();
- }
- }
- }
- public class Website {
- //ID
- private SimpleIntegerProperty id = new SimpleIntegerProperty();
- //Website
- private SimpleStringProperty site = new SimpleStringProperty("");
- private SimpleStringProperty siteLogin = new SimpleStringProperty("");
- private SimpleStringProperty sitePass = new SimpleStringProperty("");
- //FTP
- private SimpleStringProperty ftp = new SimpleStringProperty("");
- private SimpleStringProperty ftpLogin = new SimpleStringProperty("");
- private SimpleStringProperty ftpPass = new SimpleStringProperty("");
- private SimpleStringProperty port = new SimpleStringProperty("");
- //Owner
- private SimpleStringProperty person = new SimpleStringProperty("");
- private SimpleStringProperty personEmail = new SimpleStringProperty("");
- private SimpleStringProperty personPass = new SimpleStringProperty("");
- private SimpleStringProperty personPhone = new SimpleStringProperty("");
- //DB
- private SimpleStringProperty dbName = new SimpleStringProperty("");
- private SimpleStringProperty dbUser = new SimpleStringProperty("");
- private SimpleStringProperty dbPass = new SimpleStringProperty("");
- private SimpleStringProperty dbHost = new SimpleStringProperty("");
- // Hosting
- private SimpleStringProperty hostingUrl = new SimpleStringProperty("");
- private SimpleStringProperty hostingLogin = new SimpleStringProperty("");
- private SimpleStringProperty hostingPass = new SimpleStringProperty("");
- // Domain
- private SimpleStringProperty providerUrl = new SimpleStringProperty("");
- private SimpleStringProperty providerLogin = new SimpleStringProperty("");
- private SimpleStringProperty providerPass = new SimpleStringProperty("");
- //Other Accounts
- private SimpleStringProperty otherUrl = new SimpleStringProperty("");
- private SimpleStringProperty otherLogin = new SimpleStringProperty("");
- private SimpleStringProperty otherPass = new SimpleStringProperty("");
- //Notes
- private SimpleStringProperty notes = new SimpleStringProperty("");
Add Comment
Please, Sign In to add comment