Browse Source

curr

master
esoe 2 years ago
parent
commit
4cbfec7090
  1. 41
      doc/anyreport.puml
  2. 42
      src/Access.java
  3. 75
      src/AccessPane.java
  4. 11
      src/App.java
  5. 68
      src/Base.java
  6. 18
      src/BaseControls.java
  7. 3
      src/Data.java

41
doc/anyreport.puml

@ -10,6 +10,9 @@ package moodle-anyreport{ @@ -10,6 +10,9 @@ package moodle-anyreport{
'панель подключения к базе данных
class AccessPane{}
AccessPane --> App
'панель просмотра базы данных (аналог phpmyadmin)
class BasePane{}
BasePane --> App
'панель управления тегами для формирования выборки пользователей
class TagPane{}
TagPane --> App
@ -20,7 +23,7 @@ package moodle-anyreport{ @@ -20,7 +23,7 @@ package moodle-anyreport{
/'методы обработки действий пользователя
клики мыши, нажатия клавишь, итд.
'/
class TagControls{
class TagControls <<static>>{
+ enterPressed() : void
+ addTag() : void
+ removeTag() : void
@ -28,14 +31,9 @@ package moodle-anyreport{ @@ -28,14 +31,9 @@ package moodle-anyreport{
}
TagControls --> TagPane
class AccessControls{
+ connect(Base base, JPanel pane) : void
+ disconnect(Base base, JPanel pane) : void
}
AccessControls --> AccessPane
'Пользователь попросил сохранить отчет в файл
'Указывает путь куда сохранить
class ReportControls{
class ReportControls <<static>>{
- path : String
+ getTableReport() : void
+ getXLSXReport() : void
@ -64,15 +62,24 @@ package moodle-anyreport{ @@ -64,15 +62,24 @@ package moodle-anyreport{
class ReportTableModel{}
ReportTableModel --> ReportControls
/'Общий инструментарий работы с базой данных
'/
class BaseControls <<static>>{
+ connectToServer() : void
+ disconnectFromServer() : void
+ showBaseList() : void
+ selectCurrentBase() : void
+ showTables() : void
}
BaseControls --> AccessPane
BaseControls --> BasePane
/'
получение данных из базы данных
доступ к базе данных
'/
class Base{
- access : Access
- connection : Connection
- login : String
- password : String
- link : String
+ setConnection(Connection connaction) : void
+ getConnaction() : Connaction
+ connect(Base b) : void
@ -82,7 +89,13 @@ package moodle-anyreport{ @@ -82,7 +89,13 @@ package moodle-anyreport{
}
Base --> Data
Base --> AccessControls
Base --> BaseControls
enum Access{
- login : String
- password : String
- link : String
}
Access --> Base
' хранение и представление данных
class Data{
@ -106,14 +119,14 @@ package moodle-anyreport{ @@ -106,14 +119,14 @@ package moodle-anyreport{
}
UserListModel --> Data
class User{
enum User{
- id : int
- login : String
- mail : String
}
User --> UserListModel
class Result{
enum Result{
- id : int
- quizid : int
- userid : int
@ -122,7 +135,7 @@ package moodle-anyreport{ @@ -122,7 +135,7 @@ package moodle-anyreport{
}
Result --> Data
class Quiz{
enum Quiz{
- id : int
- name : String
}

42
src/Access.java

@ -0,0 +1,42 @@ @@ -0,0 +1,42 @@
public class Access {
private String link;
private String login;
private String password;
/**
* @param link the link to set
*/
public void setLink(String link) {
this.link = link;
}
/**
* @return the link
*/
public String getLink() {
return link;
}
/**
* @param login the login to set
*/
public void setLogin(String login) {
this.login = login;
}
/**
* @return the login
*/
public String getLogin() {
return login;
}
/**
* @param password the password to set
*/
public void setPassword(String password) {
this.password = password;
}
/**
* @return the password
*/
public String getPassword() {
return password;
}
}

75
src/AccessPane.java

@ -0,0 +1,75 @@ @@ -0,0 +1,75 @@
import javax.swing.JPanel;
import java.awt.Color;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.WindowConstants;
import javax.swing.border.LineBorder;
import javax.swing.border.TitledBorder;
//import ru.egspt.moodle.events.ConnactionListener;
//import ru.egspt.moodle.events.DisconnectionListener;
public class AccessPane extends JPanel {
private JLabel loginLabel = new JLabel("Имя пользователя: ");
private JTextField loginField = new JTextField(25);
private JLabel passLabel = new JLabel("Пароль: ");
private JPasswordField passField = new JPasswordField(25);
private JLabel linkLabel = new JLabel("Адрес сервера: ");
private JTextField linkField = new JTextField(25);
private JButton connButton = new JButton("Подключиться");
private JButton DisconnButton = new JButton("Отключиться");
public AccessPane(Base base){
loginField.setText("esoe");//значения по умолчанию
linkField.setText("www.egspt.ru");//значения по умолчанию
this.add(loginLabel);
this.add(loginField);
this.add(passLabel);
this.add(passField);
this.add(linkLabel);
this.add(linkField);
this.add(connButton);
//настройка кнопки connButton
connButton.addActionListener(e -> BaseControls.ConnectToServer(base, this));
this.add(DisconnButton);
DisconnButton.addActionListener(e -> BaseControls.DisconnectFromServer(base));
TitledBorder border = new TitledBorder(new LineBorder(Color.black), "connection to mysql", TitledBorder.CENTER, TitledBorder.CENTER);
this.setBorder(border);
//this.setBorder(BorderFactory.createTitledBorder("аккаунт сервера базы данных"));
this.setSize(320, 240);
this.setVisible(true);
}
/**
* @return the loginField
*/
public JTextField getLoginField() {
return loginField;
}
/**
* @return the passField
*/
public JPasswordField getPassField() {
return passField;
}
/**
* @return the urlField
*/
public JTextField getLinkField() {
return linkField;
}
public static void main( String[] args ){
Base base = new Base();
//Data data;
System.out.println( "Проверка работоспособности класса Account ..." );
JFrame mainframe = new JFrame("connaction");
AccessPane acc = new AccessPane(base);
mainframe.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
mainframe.add(acc);
mainframe.setSize(320, 240);
mainframe.setVisible(true);
}
}

11
src/App.java

@ -6,19 +6,28 @@ import javax.swing.WindowConstants; @@ -6,19 +6,28 @@ import javax.swing.WindowConstants;
* Основной класс сборки приложения
*/
public class App extends JPanel{
public Base base = new Base();
public Data data;
public void init(){
this.add(new AccessPane(base));
this.setVisible(true);
}
public void initFrame(){
JFrame mainframe = new JFrame("mainframe");
mainframe.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
mainframe.add(this);
mainframe.setSize(640, 480);
mainframe.setVisible(true);
mainframe.setExtendedState(mainframe.MAXIMIZED_BOTH);
//mainframe.setExtendedState(mainframe.MAXIMIZED_BOTH);
}
public static void main( String[] args )
{
System.out.println( "Работает подготовщик отчетов по результатам тестирования пользователей ..." );
App anyreport = new App();
anyreport.initFrame();
anyreport.init();
}
}

68
src/Base.java

@ -2,71 +2,51 @@ import java.sql.Connection; @@ -2,71 +2,51 @@ import java.sql.Connection;
import java.sql.DriverManager;
public class Base {
private Connection connection;
private String link;
private String login;
private String password;
private Connection connection = null;
private Access access = new Access();
//request
//response
Base(String link, String login, String password){
setLink(link);
setLogin(login);
setPassword(password);
}
/**
* @param connection the connection to set
*/
public void setConnection(Connection connection) {
this.connection = connection;
}
/**
* @return the connection
*/
public Connection getConnection() {
return connection;
Base(){
getAccess().setLink("link");
getAccess().setLogin("login");
getAccess().setPassword("password");
}
/**
* @param link the link to set
*/
public void setLink(String link) {
this.link = link;
}
/**
* @return the link
*/
public String getLink() {
return link;
Base(String link, String login, String password){
getAccess().setLink(link);
getAccess().setLogin(login);
getAccess().setPassword(password);
}
/**
* @param login the login to set
* @param access the access to set
*/
public void setLogin(String login) {
this.login = login;
public void setAccess(Access access) {
this.access = access;
}
/**
* @return the login
* @return the access
*/
public String getLogin() {
return login;
public Access getAccess() {
return access;
}
/**
* @param password the password to set
* @param connection the connection to set
*/
public void setPassword(String password) {
this.password = password;
public void setConnection(Connection connection) {
this.connection = connection;
}
/**
* @return the password
* @return the connection
*/
public String getPassword() {
return password;
public Connection getConnection() {
return connection;
}
//подключение к базе
public void connect(){
System.out.println("Подключение к серверу баз данных ...");
Connection conn = null;
try{
conn = DriverManager.getConnection (getLink(), getLogin(), getPassword());
conn = DriverManager.getConnection (getAccess().getLink(), getAccess().getLogin(), getAccess().getPassword());
System.out.println ("Подключение к серверу баз данных установлено ... ");
}
catch (Exception ex){

18
src/BaseControls.java

@ -0,0 +1,18 @@ @@ -0,0 +1,18 @@
public class BaseControls {
//
public static void ConnectToServer(Base base, AccessPane accessPane){
System.out.println("Инициировано событие ConnectToServer ...");
String link = accessPane.getLinkField().getText();
base.getAccess().setLink(link);
String login = accessPane.getLoginField().getText();
base.getAccess().setLogin(login);
String password = String.valueOf(accessPane.getPassField().getPassword());
base.getAccess().setPassword(password);
base.connect();//подключиться к базе
}
public static void DisconnectFromServer(Base base){
System.out.println("Инициировано событие DisconnectFromServer ...");
base.disconnect();
}
}

3
src/Data.java

@ -0,0 +1,3 @@ @@ -0,0 +1,3 @@
public class Data {
}
Loading…
Cancel
Save