Skip to content

Commit

Permalink
added
Browse files Browse the repository at this point in the history
  • Loading branch information
adityasonittyl committed May 10, 2020
1 parent 21ac089 commit 6ae7056
Show file tree
Hide file tree
Showing 1,593 changed files with 465,454 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Diff_java_projects/simple-java-crud-app-master/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="D:/JavaProjects/mysql-connector-java-3.1.14-bin.jar"/>
<classpathentry kind="lib" path="D:/JavaProjects/weblaf-1.27.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
17 changes: 17 additions & 0 deletions Diff_java_projects/simple-java-crud-app-master/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Swing26 - Tables</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
14 changes: 14 additions & 0 deletions Diff_java_projects/simple-java-crud-app-master/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Java CRUD App
Simple java business application with CRUD functional made for university course.

## `Note!`As it project became much visible somehow I strongly encourage to use provided code on your own risk. It is very dirty and hacky!

To run it you need to have
- Eclipse IDE (J2EE) **preferred**

*or you need to install `JDK` on your own.*
- MySQL pre-installed
- some MySQL UI ( I used MySql Workbench )
- mysql-connector

also i used `weblaf` swing look and feel.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import java.sql.SQLException;

import model.AgeCategory;
import model.Database;
import model.EmploymentCategory;
import model.Gender;
import model.Person;


public class TestDatabase {

public static void main(String[] args)
{


System.out.println("Running database test");

Database db = new Database();
try {
db.connect();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

db.addPerson(new Person("Joe222","sdsdsdsd",AgeCategory.Nissan,EmploymentCategory.sklad,"2323",false,Gender.no));
db.addPerson(new Person("Joe222","sdsdsdsd",AgeCategory.Nissan,EmploymentCategory.sklad,"2323",false,Gender.no));
db.addPerson(new Person("Suzana","sdssdsdsdd",AgeCategory.Nissan,EmploymentCategory.sklad,"43",true,Gender.no));
db.addPerson(new Person("qwqw","sd12dd",AgeCategory.Mazda,EmploymentCategory.no,"43",true,Gender.yes));
db.addPerson(new Person("qwqw","sd12dd",AgeCategory.Mazda,EmploymentCategory.no,"43",true,Gender.yes));
db.addPerson(new Person("qwasasqw","sd12dd",AgeCategory.Mazda,EmploymentCategory.no,"43",true,Gender.yes));

try {
db.save();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

try {
db.load();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
db.disconnect();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
package controller;

import gui.FormEvent;

import java.io.File;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

import model.AgeCategory;
import model.Database;
import model.EmploymentCategory;
import model.Gender;
import model.Person;

public class Controller {
Database db = new Database();

public List<Person> getPeople() {
return db.getPeople();
}

public void save() throws SQLException
{
db.save();
}

public void load() throws SQLException
{
db.load();
}
public void connect() throws Exception
{
db.connect();
}

public void disconnect()
{
db.disconnect();
}



public void addPerson(FormEvent ev) {
String name = ev.getName();
String occupation = ev.getOccupation();
int ageCatId = ev.getAgeCategory();
String empCat = ev.getEmploymentCategory();
boolean isUs = ev.isUsCitizen();
String taxId = ev.getTaxId();
String gender = ev.getGender();

AgeCategory ageCategory = null;

switch(ageCatId) {
case 0:
ageCategory = AgeCategory.Nissan;
break;
case 1:
ageCategory = AgeCategory.Mazda;
break;
case 2:
ageCategory = AgeCategory.Land_Rover;
break;
case 3:
ageCategory = AgeCategory.Lada;
break;
case 4:
ageCategory = AgeCategory.Honda;
break;

}


EmploymentCategory empCategory;

if(empCat.equals("åñòü")) {
empCategory = EmploymentCategory.yes;
}
else if(empCat.equals("íåò")) {
empCategory = EmploymentCategory.no;
}
else if(empCat.equals("ñêëàä")) {
empCategory = EmploymentCategory.sklad;
}
else {
empCategory = EmploymentCategory.other;
System.err.println(empCat);
}

Gender genderCat;

if(gender.equals("yes")) {
genderCat = Gender.yes;
}
else {
genderCat = Gender.no;
}

Person person = new Person(name, occupation, ageCategory, empCategory,
taxId, isUs, genderCat);

db.addPerson(person);
}
public void removePerson(int index)
{
db.removePerson(index);
}

public void saveToFile(File file) throws IOException
{
db.saveToFile(file);
}
public void loadFromFile(File file) throws IOException
{
db.loadFromFile(file);
}

}
15 changes: 15 additions & 0 deletions Diff_java_projects/simple-java-crud-app-master/src/gui/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package gui;
import javax.swing.SwingUtilities;

public class App {

public static void main(String[] args) {

SwingUtilities.invokeLater(new Runnable() {
public void run() {
new MainFrame();
}
});
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package gui;

import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.EventObject;

import javax.swing.AbstractCellEditor;
import javax.swing.JComboBox;
import javax.swing.JTable;
import javax.swing.table.TableCellEditor;

import model.EmploymentCategory;

public class EmploymentCategoryEditor extends AbstractCellEditor implements TableCellEditor {

private JComboBox combo;

public EmploymentCategoryEditor()
{
combo = new JComboBox(EmploymentCategory.values());
}
@Override
public boolean isCellEditable(EventObject e) {

return true;
}

@Override
public Object getCellEditorValue() {
// TODO Auto-generated method stub
return combo.getSelectedItem();
}

@Override
public Component getTableCellEditorComponent(JTable table, Object value,
boolean isSelected, int row, int column) {


combo.setSelectedItem(value);

combo.addActionListener(new ActionListener()
{

@Override
public void actionPerformed(ActionEvent arg0) {
fireEditingStopped();

}

});


return combo;
}



}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package gui;

import java.awt.Component;

import javax.swing.JComboBox;
import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;

import model.EmploymentCategory;

public class EmploymentCategoryRenderer implements TableCellRenderer {

private JComboBox combo;

public EmploymentCategoryRenderer() {
combo = new JComboBox(EmploymentCategory.values());
}

@Override
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {

combo.setSelectedItem(value);
return combo;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package gui;
import java.awt.event.KeyEvent;
import java.util.EventObject;

public class FormEvent extends EventObject {

private String name;
private String occupation;
private int ageCategory;
private String empCat;
private String taxId;
private boolean usCitizen;
private String gender;

public FormEvent(Object source) {
super(source);
}

public FormEvent(Object source, String name, String occupation, int ageCat,
String empCat, String taxId, boolean usCitizen, String gender) {
super(source);

this.name = name;
this.occupation = occupation;
this.ageCategory = ageCat;
this.empCat = empCat;
this.taxId = taxId;
this.usCitizen = usCitizen;
this.gender = gender;
}

public String getGender() {
return gender;
}

public String getTaxId() {
return taxId;
}

public boolean isUsCitizen() {
return usCitizen;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getOccupation() {
return occupation;
}

public void setOccupation(String occupation) {
this.occupation = occupation;
}

public int getAgeCategory() {
return ageCategory;
}

public String getEmploymentCategory() {
return empCat;
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package gui;
import java.util.EventListener;

public interface FormListener extends EventListener {
public void formEventOccurred(FormEvent e);
}
Loading

0 comments on commit 6ae7056

Please sign in to comment.