├── .gitattributes ├── .gitignore ├── ReadMe.md ├── config.ini ├── pom.xml ├── snapshots ├── home-login.png ├── initial-records.png ├── ledger.png ├── new-item.png ├── return-query.png ├── stock-query.png ├── transfer-search.png └── transfer.png └── src └── main ├── java └── com │ ├── ca │ ├── db │ │ ├── model │ │ │ ├── ApplicationLog.java │ │ │ ├── BranchOffice.java │ │ │ ├── Category.java │ │ │ ├── CategorySpecifications.java │ │ │ ├── Item.java │ │ │ ├── ItemReturn.java │ │ │ ├── LoginUser.java │ │ │ ├── Specification.java │ │ │ ├── Transfer.java │ │ │ ├── UnitsString.java │ │ │ └── Vendor.java │ │ └── service │ │ │ ├── DBUtils.java │ │ │ ├── ItemReturnServiceImpl.java │ │ │ ├── ItemServiceImpl.java │ │ │ ├── LoginUserServiceImpl.java │ │ │ ├── TransferServiceImpl.java │ │ │ └── dto │ │ │ └── ReturnedItemDTO.java │ └── ui │ │ ├── Main.java │ │ └── panels │ │ ├── AboutPanel.java │ │ ├── BranchOfficePanel.java │ │ ├── CategoryPanel.java │ │ ├── ChangePasswordPanel.java │ │ ├── DataEntryUtils.java │ │ ├── HomeScreenPanel.java │ │ ├── ItemEntryPanel.java │ │ ├── ItemReceiverPanel.java │ │ ├── ItemReturnPanel.java │ │ ├── ItemTransferPanel.java │ │ ├── LoginPanel.java │ │ ├── SpecificationPanel.java │ │ ├── StockQueryPanel.java │ │ ├── UnitsStringPanel.java │ │ └── VendorPanel.java │ └── gt │ ├── common │ ├── AppStarter.java │ ├── ResourceManager.java │ ├── constants │ │ ├── CommonConsts.java │ │ ├── Status.java │ │ └── StrConstants.java │ └── utils │ │ ├── CryptographicUtil.java │ │ ├── DateTimeUtils.java │ │ ├── ExcelUtils.java │ │ ├── PasswordUtil.java │ │ ├── RegexUtils.java │ │ ├── StringUtils.java │ │ └── UIUtils.java │ ├── db │ ├── BaseDAO.java │ ├── SessionUtils.java │ └── utils │ │ └── BaseDBUtils.java │ └── uilib │ ├── components │ ├── AbstractFunctionPanel.java │ ├── ActionMenuItem.java │ ├── AppFrame.java │ ├── GDialog.java │ ├── button │ │ ├── ActionButton.java │ │ ├── ExitButton.java │ │ └── LogOutButton.java │ ├── input │ │ ├── DataComboBox.java │ │ ├── GTextArea.java │ │ ├── NumberFormatDocument.java │ │ └── NumberTextField.java │ └── table │ │ ├── BetterJTable.java │ │ ├── BetterJTableNoSorting.java │ │ └── EasyTableModel.java │ └── inputverifier │ ├── Validator.java │ └── Verifier.java └── resources ├── hibernate.cfg.xml ├── images ├── a-menu.png ├── about-menu.png ├── about.png ├── backup-menu.png ├── backup.png ├── backuprestore-menu.png ├── branch-menu.png ├── ca-icon48.png ├── createButton.png ├── createButton2.png ├── exclamation_mark_icon.png ├── exit-menu.png ├── exit-off.png ├── exit-on.png ├── exit.png ├── find-off.png ├── find-on.png ├── help-menu.png ├── home-off.png ├── home-on.png ├── itementry-off.png ├── itementry-on.png ├── itemtransfer-off.png ├── itemtransfer-on.png ├── loginuser.png ├── logo2.png ├── logout-menu.png ├── logout-off.png ├── logout-on.png ├── managerButton.png ├── managerButton2.png ├── menu1-off.png ├── menu1-on.png ├── menu2-off.png ├── menu2-on.png ├── printer.png ├── return-off.png ├── return-on.png ├── return.png ├── returna-off.png ├── returna-on.png ├── returnquery-off.png ├── returnquery-on.png ├── returnquery.png ├── returnquerya-off.png ├── returnquerya-on.png ├── setting-menu.png ├── setting-off.png ├── setting-on.png ├── sfind-menu.png ├── shelp-menu.png ├── sitementry-menu.png ├── sitemnikasha-menu.png ├── sstock-menu.png ├── stock-off.png ├── stock-on.png ├── todoButton.png ├── todoButton2.png ├── user-menu.png ├── validator-error-icon.png ├── vendor-menu.png ├── vendor-off.png └── vendor-on.png └── log4j.properties /.gitattributes: -------------------------------------------------------------------------------- 1 | # This file is inspired by https://github.com/alexkaratarakis/gitattributes 2 | # 3 | # Auto detect text files and perform LF normalization 4 | # http://davidlaing.com/2012/09/19/customise-your-gitattributes-to-become-a-git-ninja/ 5 | * text=auto 6 | 7 | # The above will handle all files NOT found below 8 | # These files are text and should be normalized (Convert crlf => lf) 9 | 10 | *.bat text eol=crlf 11 | *.coffee text 12 | *.css text 13 | *.cql text 14 | *.df text 15 | *.ejs text 16 | *.html text 17 | *.java text 18 | *.js text 19 | *.json text 20 | *.less text 21 | *.properties text 22 | *.sass text 23 | *.scss text 24 | *.sh text eol=lf 25 | *.sql text 26 | *.txt text 27 | *.ts text 28 | *.xml text 29 | *.yaml text 30 | *.yml text 31 | 32 | # Documents 33 | *.doc diff=astextplain 34 | *.DOC diff=astextplain 35 | *.docx diff=astextplain 36 | *.DOCX diff=astextplain 37 | *.dot diff=astextplain 38 | *.DOT diff=astextplain 39 | *.pdf diff=astextplain 40 | *.PDF diff=astextplain 41 | *.rtf diff=astextplain 42 | *.RTF diff=astextplain 43 | *.markdown text 44 | *.md text 45 | *.adoc text 46 | *.textile text 47 | *.mustache text 48 | *.csv text 49 | *.tab text 50 | *.tsv text 51 | *.txt text 52 | AUTHORS text 53 | CHANGELOG text 54 | CHANGES text 55 | CONTRIBUTING text 56 | COPYING text 57 | copyright text 58 | *COPYRIGHT* text 59 | INSTALL text 60 | license text 61 | LICENSE text 62 | NEWS text 63 | readme text 64 | *README* text 65 | TODO text 66 | 67 | # Graphics 68 | *.png binary 69 | *.jpg binary 70 | *.jpeg binary 71 | *.gif binary 72 | *.tif binary 73 | *.tiff binary 74 | *.ico binary 75 | # SVG treated as an asset (binary) by default. If you want to treat it as text, 76 | # comment-out the following line and uncomment the line after. 77 | *.svg binary 78 | #*.svg text 79 | *.eps binary 80 | 81 | # These files are binary and should be left untouched 82 | # (binary is a macro for -text -diff) 83 | *.class binary 84 | *.jar binary 85 | *.war binary 86 | 87 | ## LINTERS 88 | .csslintrc text 89 | .eslintrc text 90 | .jscsrc text 91 | .jshintrc text 92 | .jshintignore text 93 | .stylelintrc text 94 | 95 | ## CONFIGS 96 | *.bowerrc text 97 | *.conf text 98 | *.config text 99 | .editorconfig text 100 | .gitattributes text 101 | .gitconfig text 102 | .gitignore text 103 | .htaccess text 104 | *.npmignore text 105 | 106 | ## HEROKU 107 | Procfile text 108 | .slugignore text 109 | 110 | ## AUDIO 111 | *.kar binary 112 | *.m4a binary 113 | *.mid binary 114 | *.midi binary 115 | *.mp3 binary 116 | *.ogg binary 117 | *.ra binary 118 | 119 | ## VIDEO 120 | *.3gpp binary 121 | *.3gp binary 122 | *.as binary 123 | *.asf binary 124 | *.asx binary 125 | *.fla binary 126 | *.flv binary 127 | *.m4v binary 128 | *.mng binary 129 | *.mov binary 130 | *.mp4 binary 131 | *.mpeg binary 132 | *.mpg binary 133 | *.swc binary 134 | *.swf binary 135 | *.webm binary 136 | 137 | ## ARCHIVES 138 | *.7z binary 139 | *.gz binary 140 | *.rar binary 141 | *.tar binary 142 | *.zip binary 143 | 144 | ## FONTS 145 | *.ttf binary 146 | *.eot binary 147 | *.otf binary 148 | *.woff binary 149 | *.woff2 binary 150 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ###################### 2 | # Project Specific 3 | ###################### 4 | /src/main/webapp/content/css/main.css 5 | /target/www/** 6 | /src/test/javascript/coverage/ 7 | 8 | ###################### 9 | # Node 10 | ###################### 11 | /node/ 12 | node_tmp/ 13 | node_modules/ 14 | npm-debug.log.* 15 | /.awcache/* 16 | /.cache-loader/* 17 | 18 | ###################### 19 | # SASS 20 | ###################### 21 | .sass-cache/ 22 | 23 | ###################### 24 | # Eclipse 25 | ###################### 26 | *.pydevproject 27 | .project 28 | .metadata 29 | tmp/ 30 | tmp/**/* 31 | *.tmp 32 | *.bak 33 | *.swp 34 | *~.nib 35 | local.properties 36 | .classpath 37 | .settings/ 38 | .loadpath 39 | .factorypath 40 | /src/main/resources/rebel.xml 41 | 42 | # External tool builders 43 | .externalToolBuilders/** 44 | 45 | # Locally stored "Eclipse launch configurations" 46 | *.launch 47 | 48 | # CDT-specific 49 | .cproject 50 | 51 | # PDT-specific 52 | .buildpath 53 | 54 | ###################### 55 | # Intellij 56 | ###################### 57 | .idea/ 58 | *.iml 59 | *.iws 60 | *.ipr 61 | *.ids 62 | *.orig 63 | classes/ 64 | out/ 65 | 66 | ###################### 67 | # Visual Studio Code 68 | ###################### 69 | .vscode/ 70 | 71 | ###################### 72 | # Maven 73 | ###################### 74 | /log/ 75 | /target/ 76 | 77 | ###################### 78 | # Gradle 79 | ###################### 80 | .gradle/ 81 | /build/ 82 | 83 | ###################### 84 | # Package Files 85 | ###################### 86 | *.jar 87 | *.war 88 | *.ear 89 | *.db 90 | 91 | ###################### 92 | # Windows 93 | ###################### 94 | # Windows image file caches 95 | Thumbs.db 96 | 97 | # Folder config file 98 | Desktop.ini 99 | 100 | ###################### 101 | # Mac OSX 102 | ###################### 103 | .DS_Store 104 | .svn 105 | 106 | # Thumbnails 107 | ._* 108 | 109 | # Files that might appear on external disk 110 | .Spotlight-V100 111 | .Trashes 112 | 113 | ###################### 114 | # Directories 115 | ###################### 116 | /bin/ 117 | /deploy/ 118 | 119 | ###################### 120 | # Logs 121 | ###################### 122 | *.log* 123 | 124 | ###################### 125 | # Others 126 | ###################### 127 | *.class 128 | *.*~ 129 | *~ 130 | .merge_file* 131 | 132 | ###################### 133 | # Gradle Wrapper 134 | ###################### 135 | !gradle/wrapper/gradle-wrapper.jar 136 | 137 | ###################### 138 | # Maven Wrapper 139 | ###################### 140 | !.mvn/wrapper/maven-wrapper.jar 141 | 142 | ###################### 143 | # ESLint 144 | ###################### 145 | .eslintcache 146 | -------------------------------------------------------------------------------- /ReadMe.md: -------------------------------------------------------------------------------- 1 | ## Inventory Management System - desktop based 2 | 3 | #### This uses following libraries/frameworks 4 | - Swing 5 | - JGoodies Swing Extension Library 6 | - Hibernate 7 | - H2 Database 8 | 9 | #### How to run the application 10 | - Clone/Download the project and import into your IDE 11 | - Run com.ca.ui.Main as Java Application 12 | - Enter ADMIN/ADMIN for username and password 13 | 14 | ##### Configuration and Data 15 | - Use 'Entry' -> 'Initial Records' menu to enter configuration such as product category, vendor, measurement unit, branch office etc 16 | - Start with "Item Entry" tab to enter inventory items and do Stock Query, Transfer or Sell, Handle Returns of Items etc 17 | 18 | ## You can use this project as a template to build out your projects! I believe the code is simple enough to understand the overall flow and add/modify modules. 19 | 20 | ### For any queries : 21 | - Email : gtiwari333@gmail.com 22 | - Blog : http://ganeshtiwaridotcomdotnp.blogspot.com/ 23 | 24 | 25 | ##### CopyLeft: 26 | - Please feel free to use/modify the code! 27 | - But make sure to give me credit by keeping the class header or add reference to this GitHub repository. 28 | 29 | 30 | ## Snapshots 31 | 32 | #### Home/Login Screen 33 | ![](snapshots/home-login.png) 34 | 35 | 36 | #### Initial Records 37 | ![](snapshots/initial-records.png) 38 | 39 | 40 | #### New Item Entry 41 | ![](snapshots/new-item.png) 42 | 43 | 44 | #### Stock Query 45 | ![](snapshots/stock-query.png) 46 | 47 | 48 | #### Transfer 49 | ![](snapshots/transfer.png) 50 | 51 | 52 | #### Return Query 53 | ![](snapshots/return-query.png) 54 | 55 | -------------------------------------------------------------------------------- /config.ini: -------------------------------------------------------------------------------- 1 | 4HSqVzXt2j1rQipA+i4O5g==:RdfeU+NI3iI= 2 | PrqgVjoUaNtZLwIPoXCLyA==:EPDGPyfVdZYnMC4rcv0z6Jcfvl4EFfyjyErkRgY6Pe8= 3 | M80U9HGXh95rQipA+i4O5g==:3tg9AsJRBGW18x6ryl+N3Q== 4 | HThaeHamQ24=:4HD4mcCQI/fzCCmhitM2Oz0mPU83rmhA 5 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 4.0.0 6 | com.gt 7 | inventory-management-system 8 | jar 9 | 0.0.1-TEST 10 | Inventory Management System (Java, Swing, JGoodies, Hibernate, H2 Database, Jasper) 11 | 12 | 13 | com.ca.ui.Main 14 | 11 15 | 16 | 17 | 18 | 19 | org.hibernate 20 | hibernate-core 21 | 5.6.15.Final 22 | 23 | 24 | 25 | com.toedter 26 | jcalendar 27 | 1.4 28 | 29 | 30 | com.jgoodies 31 | looks 32 | 2.2.2 33 | 34 | 35 | com.jgoodies 36 | forms 37 | 1.2.1 38 | 39 | 40 | 41 | jgoodies 42 | binding 43 | 1.0 44 | 45 | 46 | 47 | org.swinglabs 48 | swingx 49 | 1.6.1 50 | 51 | 52 | 53 | com.h2database 54 | h2 55 | 2.1.214 56 | runtime 57 | 58 | 59 | 60 | net.sourceforge.jexcelapi 61 | jxl 62 | 2.6.12 63 | 64 | 65 | org.apache.commons 66 | commons-lang3 67 | 3.12.0 68 | 69 | 70 | 71 | 72 | 73 | 74 | org.apache.maven.plugins 75 | maven-jar-plugin 76 | 77 | 78 | 79 | ${project.build.mainClass} 80 | 81 | 82 | 83 | 84 | 85 | maven-dependency-plugin 86 | 87 | 88 | package 89 | 90 | copy-dependencies 91 | 92 | 93 | target/lib 94 | 95 | 96 | 97 | 98 | 99 | org.apache.maven.plugins 100 | maven-compiler-plugin 101 | 102 | 103 | ${java.version} 104 | ${java.version} 105 | 106 | 107 | 108 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /snapshots/home-login.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/snapshots/home-login.png -------------------------------------------------------------------------------- /snapshots/initial-records.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/snapshots/initial-records.png -------------------------------------------------------------------------------- /snapshots/ledger.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/snapshots/ledger.png -------------------------------------------------------------------------------- /snapshots/new-item.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/snapshots/new-item.png -------------------------------------------------------------------------------- /snapshots/return-query.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/snapshots/return-query.png -------------------------------------------------------------------------------- /snapshots/stock-query.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/snapshots/stock-query.png -------------------------------------------------------------------------------- /snapshots/transfer-search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/snapshots/transfer-search.png -------------------------------------------------------------------------------- /snapshots/transfer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/snapshots/transfer.png -------------------------------------------------------------------------------- /src/main/java/com/ca/db/model/ApplicationLog.java: -------------------------------------------------------------------------------- 1 | package com.ca.db.model; 2 | 3 | import javax.persistence.*; 4 | import java.util.Date; 5 | 6 | @Entity 7 | @Table(name = "ApplicationLog") 8 | public class ApplicationLog { 9 | 10 | @Id 11 | @GeneratedValue 12 | @Column(name = "id") 13 | private int id; 14 | 15 | @Column(name = "date_time") 16 | private Date dateTime; 17 | 18 | @Column(name = "dflag") 19 | private int dFlag; 20 | 21 | @Column(name = "message") 22 | private String message; 23 | 24 | @Column(name = "lastmodifieddate") 25 | private Date lastModifiedDate; 26 | 27 | public int getdFlag() { 28 | return this.dFlag; 29 | } 30 | 31 | public void setdFlag(int dFlag) { 32 | this.dFlag = dFlag; 33 | } 34 | 35 | public Date getLastModifiedDate() { 36 | return this.lastModifiedDate; 37 | } 38 | 39 | public void setLastModifiedDate(Date lastModifiedDate) { 40 | this.lastModifiedDate = lastModifiedDate; 41 | } 42 | 43 | public int getId() { 44 | return this.id; 45 | } 46 | 47 | public void setId(int id) { 48 | this.id = id; 49 | } 50 | 51 | public Date getDateTime() { 52 | return this.dateTime; 53 | } 54 | 55 | public void setDateTime(Date dateTime) { 56 | this.dateTime = dateTime; 57 | } 58 | 59 | public String getMessage() { 60 | return this.message; 61 | } 62 | 63 | public void setMessage(String message) { 64 | this.message = message; 65 | } 66 | 67 | public int hashCode() { 68 | int prime = 31; 69 | int result = 1; 70 | result = 31 * result + (this.dateTime == null ? 0 : this.dateTime.hashCode()); 71 | result = 31 * result + this.id; 72 | return result; 73 | } 74 | 75 | public boolean equals(Object obj) { 76 | if (this == obj) 77 | return true; 78 | if (obj == null) 79 | return false; 80 | if (getClass() != obj.getClass()) 81 | return false; 82 | ApplicationLog other = (ApplicationLog) obj; 83 | if (this.dateTime == null) { 84 | if (other.dateTime != null) 85 | return false; 86 | } else if (!this.dateTime.equals(other.dateTime)) { 87 | return false; 88 | } 89 | return this.id == other.id; 90 | } 91 | } -------------------------------------------------------------------------------- /src/main/java/com/ca/db/model/BranchOffice.java: -------------------------------------------------------------------------------- 1 | package com.ca.db.model; 2 | 3 | import javax.persistence.*; 4 | import java.util.Date; 5 | 6 | @Entity 7 | @Table(name = "BranchOffice") 8 | public class BranchOffice { 9 | 10 | @Id 11 | @GeneratedValue 12 | @Column(name = "id") 13 | private int id; 14 | 15 | @Column(name = "name") 16 | private String name; 17 | 18 | @Column(name = "address") 19 | private String address; 20 | 21 | @Column(name = "district") 22 | private String district; 23 | 24 | @Column(name = "phonenumber") 25 | private String phoneNumber; 26 | 27 | @Column(name = "dflag") 28 | private int dFlag; 29 | 30 | @Column(name = "lastmodifieddate") 31 | private Date lastModifiedDate; 32 | 33 | public Date getLastModifiedDate() { 34 | return this.lastModifiedDate; 35 | } 36 | 37 | public void setLastModifiedDate(Date lastModifiedDate) { 38 | this.lastModifiedDate = lastModifiedDate; 39 | } 40 | 41 | public int getdFlag() { 42 | return this.dFlag; 43 | } 44 | 45 | public void setdFlag(int dFlag) { 46 | this.dFlag = dFlag; 47 | } 48 | 49 | public int getId() { 50 | return this.id; 51 | } 52 | 53 | public void setId(int id) { 54 | this.id = id; 55 | } 56 | 57 | public String getName() { 58 | return this.name; 59 | } 60 | 61 | public void setName(String name) { 62 | this.name = name; 63 | } 64 | 65 | public String getAddress() { 66 | return this.address; 67 | } 68 | 69 | public void setAddress(String address) { 70 | this.address = address; 71 | } 72 | 73 | public String getPhoneNumber() { 74 | return this.phoneNumber; 75 | } 76 | 77 | public void setPhoneNumber(String phoneNumber) { 78 | this.phoneNumber = phoneNumber; 79 | } 80 | 81 | public String toString() { 82 | return "BranchOffice [id=" + this.id + ", name=" + this.name + ", address=" + this.address + ", phoneNumber=" + this.phoneNumber + ", deleteStatus=" + this.dFlag + "]"; 83 | } 84 | 85 | public String getDistrict() { 86 | return this.district; 87 | } 88 | 89 | public void setDistrict(String district) { 90 | this.district = district; 91 | } 92 | } -------------------------------------------------------------------------------- /src/main/java/com/ca/db/model/Category.java: -------------------------------------------------------------------------------- 1 | package com.ca.db.model; 2 | 3 | import javax.persistence.*; 4 | import java.util.Date; 5 | 6 | @Entity 7 | @Table(name = "Category") 8 | public class Category { 9 | public static final int TYPE_NON_RETURNABLE = 2; 10 | public static final int TYPE_RETURNABLE = 1; 11 | 12 | @Id 13 | @GeneratedValue 14 | @Column(name = "id") 15 | private int id; 16 | 17 | @Column(name = "categorytype") 18 | private int categoryType; 19 | 20 | @Column(name = "lastmodifieddate") 21 | private Date lastModifiedDate; 22 | 23 | @Column(name = "categoryname") 24 | private String categoryName; 25 | 26 | @Column(name = "specification1") 27 | private String specification1; 28 | 29 | @Column(name = "specification2") 30 | private String specification2; 31 | 32 | @Column(name = "specification3") 33 | private String specification3; 34 | 35 | @Column(name = "specification4") 36 | private String specification4; 37 | 38 | @Column(name = "specification5") 39 | private String specification5; 40 | 41 | @Column(name = "specification6") 42 | private String specification6; 43 | 44 | @Column(name = "specification7") 45 | private String specification7; 46 | 47 | @Column(name = "specification8") 48 | private String specification8; 49 | 50 | @Column(name = "specification9") 51 | private String specification9; 52 | 53 | @Column(name = "specification10") 54 | private String specification10; 55 | 56 | @Column(name = "dflag") 57 | private int dFlag; 58 | 59 | public String getSpecification4() { 60 | return this.specification4; 61 | } 62 | 63 | public void setSpecification4(String specification4) { 64 | this.specification4 = specification4; 65 | } 66 | 67 | public String getSpecification5() { 68 | return this.specification5; 69 | } 70 | 71 | public void setSpecification5(String specification5) { 72 | this.specification5 = specification5; 73 | } 74 | 75 | public String getSpecification6() { 76 | return this.specification6; 77 | } 78 | 79 | public void setSpecification6(String specification6) { 80 | this.specification6 = specification6; 81 | } 82 | 83 | public String getSpecification7() { 84 | return this.specification7; 85 | } 86 | 87 | public void setSpecification7(String specification7) { 88 | this.specification7 = specification7; 89 | } 90 | 91 | public String getSpecification8() { 92 | return this.specification8; 93 | } 94 | 95 | public void setSpecification8(String specification8) { 96 | this.specification8 = specification8; 97 | } 98 | 99 | public String getSpecification9() { 100 | return this.specification9; 101 | } 102 | 103 | public void setSpecification9(String specification9) { 104 | this.specification9 = specification9; 105 | } 106 | 107 | public String getSpecification10() { 108 | return this.specification10; 109 | } 110 | 111 | public void setSpecification10(String specification10) { 112 | this.specification10 = specification10; 113 | } 114 | 115 | public int getdFlag() { 116 | return this.dFlag; 117 | } 118 | 119 | public void setdFlag(int dFlag) { 120 | this.dFlag = dFlag; 121 | } 122 | 123 | public String getCategoryName() { 124 | return this.categoryName; 125 | } 126 | 127 | public void setCategoryName(String categoryName) { 128 | this.categoryName = categoryName; 129 | } 130 | 131 | public String getSpecification1() { 132 | return this.specification1; 133 | } 134 | 135 | public void setSpecification1(String specification1) { 136 | this.specification1 = specification1; 137 | } 138 | 139 | public String getSpecification2() { 140 | return this.specification2; 141 | } 142 | 143 | public void setSpecification2(String specification2) { 144 | this.specification2 = specification2; 145 | } 146 | 147 | public String getSpecification3() { 148 | return this.specification3; 149 | } 150 | 151 | public void setSpecification3(String specification3) { 152 | this.specification3 = specification3; 153 | } 154 | 155 | public int getId() { 156 | return this.id; 157 | } 158 | 159 | public void setId(int id) { 160 | this.id = id; 161 | } 162 | 163 | public Date getLastModifiedDate() { 164 | return this.lastModifiedDate; 165 | } 166 | 167 | public void setLastModifiedDate(Date lastModifiedDate) { 168 | this.lastModifiedDate = lastModifiedDate; 169 | } 170 | 171 | public int getCategoryType() { 172 | return this.categoryType; 173 | } 174 | 175 | public void setCategoryType(int categoryType) { 176 | this.categoryType = categoryType; 177 | } 178 | } -------------------------------------------------------------------------------- /src/main/java/com/ca/db/model/CategorySpecifications.java: -------------------------------------------------------------------------------- 1 | package com.ca.db.model; 2 | 3 | import javax.persistence.*; 4 | import java.util.Date; 5 | 6 | @Entity 7 | @Table(name = "CategorySpecifications") 8 | public class CategorySpecifications { 9 | 10 | @Id 11 | @GeneratedValue 12 | @Column(name = "id") 13 | private int id; 14 | 15 | private int subCategoryId; 16 | 17 | @Column(name = "lastmodifieddate") 18 | private Date lastModifiedDate; 19 | 20 | @Column(name = "dflag") 21 | private int dFlag; 22 | 23 | @Column(name = "specification1") 24 | private String specification1; 25 | 26 | @Column(name = "specification2") 27 | private String specification2; 28 | 29 | @Column(name = "specification3") 30 | private String specification3; 31 | 32 | @Column(name = "specification4") 33 | private String specification4; 34 | 35 | @Column(name = "specification5") 36 | private String specification5; 37 | 38 | @Column(name = "specification6") 39 | private String specification6; 40 | 41 | @Column(name = "specification7") 42 | private String specification7; 43 | 44 | @Column(name = "specification8") 45 | private String specification8; 46 | 47 | @Column(name = "specification9") 48 | private String specification9; 49 | 50 | @Column(name = "specification10") 51 | private String specification10; 52 | 53 | public int getSubCategoryId() { 54 | return this.subCategoryId; 55 | } 56 | 57 | public void setSubCategoryId(int subCategoryId) { 58 | this.subCategoryId = subCategoryId; 59 | } 60 | 61 | public Date getLastModifiedDate() { 62 | return this.lastModifiedDate; 63 | } 64 | 65 | public void setLastModifiedDate(Date lastModifiedDate) { 66 | this.lastModifiedDate = lastModifiedDate; 67 | } 68 | 69 | public int getdFlag() { 70 | return this.dFlag; 71 | } 72 | 73 | public void setdFlag(int dFlag) { 74 | this.dFlag = dFlag; 75 | } 76 | 77 | public int getId() { 78 | return this.id; 79 | } 80 | 81 | public void setId(int id) { 82 | this.id = id; 83 | } 84 | 85 | public String getSpecification1() { 86 | return this.specification1; 87 | } 88 | 89 | public void setSpecification1(String specification1) { 90 | this.specification1 = specification1; 91 | } 92 | 93 | public String getSpecification2() { 94 | return this.specification2; 95 | } 96 | 97 | public void setSpecification2(String specification2) { 98 | this.specification2 = specification2; 99 | } 100 | 101 | public String getSpecification3() { 102 | return this.specification3; 103 | } 104 | 105 | public void setSpecification3(String specification3) { 106 | this.specification3 = specification3; 107 | } 108 | 109 | public String getSpecification4() { 110 | return this.specification4; 111 | } 112 | 113 | public void setSpecification4(String specification4) { 114 | this.specification4 = specification4; 115 | } 116 | 117 | public String getSpecification5() { 118 | return this.specification5; 119 | } 120 | 121 | public void setSpecification5(String specification5) { 122 | this.specification5 = specification5; 123 | } 124 | 125 | public String getSpecification6() { 126 | return this.specification6; 127 | } 128 | 129 | public void setSpecification6(String specification6) { 130 | this.specification6 = specification6; 131 | } 132 | 133 | public String getSpecification7() { 134 | return this.specification7; 135 | } 136 | 137 | public void setSpecification7(String specification7) { 138 | this.specification7 = specification7; 139 | } 140 | 141 | public String getSpecification8() { 142 | return this.specification8; 143 | } 144 | 145 | public void setSpecification8(String specification8) { 146 | this.specification8 = specification8; 147 | } 148 | 149 | public String getSpecification9() { 150 | return this.specification9; 151 | } 152 | 153 | public void setSpecification9(String specification9) { 154 | this.specification9 = specification9; 155 | } 156 | 157 | public String getSpecification10() { 158 | return this.specification10; 159 | } 160 | 161 | public void setSpecification10(String specification10) { 162 | this.specification10 = specification10; 163 | } 164 | } -------------------------------------------------------------------------------- /src/main/java/com/ca/db/model/ItemReturn.java: -------------------------------------------------------------------------------- 1 | package com.ca.db.model; 2 | 3 | import javax.persistence.*; 4 | import java.util.Date; 5 | 6 | @Entity 7 | @Table(name = "ItemReturn") 8 | public class ItemReturn { 9 | 10 | public static final int RETURN_ITEM_CONDITION_GOOD = 1; 11 | public static final int RETURN_ITEM_UNREPAIRABLE = 2; 12 | public static final int RETURN_NEEDS_REPAIR = 3; 13 | public static final int RETURN_EXEMPTION = 4; 14 | @Id 15 | @GeneratedValue 16 | @Column(name = "id") 17 | private int id; 18 | @Column(name = "returnitemcondition") 19 | private int returnItemCondition; 20 | 21 | @Column(name = "lastmodifieddate") 22 | private Date lastModifiedDate; 23 | 24 | @Column(name = "dflag") 25 | private int dFlag; 26 | 27 | @Column(name = "returnnumber") 28 | private String returnNumber; 29 | 30 | @OneToOne(cascade = {javax.persistence.CascadeType.ALL}) 31 | private Transfer transfer; 32 | 33 | @Column(name = "quantity") 34 | private int quantity; 35 | 36 | @Column(name = "status") 37 | private int status; 38 | 39 | @Column(name = "addeddate") 40 | private Date addedDate; 41 | 42 | public int getReturnItemCondition() { 43 | return this.returnItemCondition; 44 | } 45 | 46 | public void setReturnItemCondition(int returnItemCondition) { 47 | this.returnItemCondition = returnItemCondition; 48 | } 49 | 50 | public int getId() { 51 | return this.id; 52 | } 53 | 54 | public void setId(int id) { 55 | this.id = id; 56 | } 57 | 58 | public Date getLastModifiedDate() { 59 | return this.lastModifiedDate; 60 | } 61 | 62 | public void setLastModifiedDate(Date lastModifiedDate) { 63 | this.lastModifiedDate = lastModifiedDate; 64 | } 65 | 66 | public int getdFlag() { 67 | return this.dFlag; 68 | } 69 | 70 | public void setdFlag(int dFlag) { 71 | this.dFlag = dFlag; 72 | } 73 | 74 | public int getQuantity() { 75 | return this.quantity; 76 | } 77 | 78 | public void setQuantity(int quantity) { 79 | this.quantity = quantity; 80 | } 81 | 82 | public int getStatus() { 83 | return this.status; 84 | } 85 | 86 | public void setStatus(int status) { 87 | this.status = status; 88 | } 89 | 90 | public Date getAddedDate() { 91 | return this.addedDate; 92 | } 93 | 94 | public void setAddedDate(Date addedDate) { 95 | this.addedDate = addedDate; 96 | } 97 | 98 | public String getReturnNumber() { 99 | return this.returnNumber; 100 | } 101 | 102 | public void setReturnNumber(String returnNumber) { 103 | this.returnNumber = returnNumber; 104 | } 105 | 106 | public Transfer getTransfer() { 107 | return this.transfer; 108 | } 109 | 110 | public void setTransfer(Transfer transfer) { 111 | this.transfer = transfer; 112 | } 113 | } -------------------------------------------------------------------------------- /src/main/java/com/ca/db/model/LoginUser.java: -------------------------------------------------------------------------------- 1 | package com.ca.db.model; 2 | 3 | import javax.persistence.*; 4 | import java.util.Date; 5 | import java.util.List; 6 | 7 | @Entity 8 | @Table(name = "LoginUser") 9 | public class LoginUser { 10 | 11 | @Id 12 | @GeneratedValue 13 | @Column(name = "id") 14 | private int id; 15 | 16 | @Column(name = "dflag") 17 | private int dFlag; 18 | 19 | @Column(name = "username") 20 | private String username; 21 | 22 | @Column(name = "password") 23 | private String password; 24 | 25 | @Column(name = "invalid_count") 26 | private int invalid_count; 27 | 28 | @Column(name = "last_login_date") 29 | private Date lastLoginDate; 30 | 31 | @Column(name = "lastmodifieddate") 32 | private Date lastModifiedDate; 33 | 34 | @Column(name = "zxtra1") 35 | private String zxtra1; 36 | 37 | @Column(name = "zxtra2") 38 | private String zxtra2; 39 | 40 | @Column(name = "zxtra3") 41 | private String zxtra3; 42 | 43 | @Column(name = "zxtra4") 44 | private String zxtra4; 45 | 46 | @Column(name = "zxtra5") 47 | private String zxtra5; 48 | 49 | public int getdFlag() { 50 | return this.dFlag; 51 | } 52 | 53 | public void setdFlag(int dFlag) { 54 | this.dFlag = dFlag; 55 | } 56 | 57 | public Date getLastModifiedDate() { 58 | return this.lastModifiedDate; 59 | } 60 | 61 | public void setLastModifiedDate(Date lastModifiedDate) { 62 | this.lastModifiedDate = lastModifiedDate; 63 | } 64 | 65 | public int getId() { 66 | return this.id; 67 | } 68 | 69 | public void setId(int id) { 70 | this.id = id; 71 | } 72 | 73 | public String getUsername() { 74 | return this.username; 75 | } 76 | 77 | public void setUsername(String username) { 78 | this.username = username; 79 | } 80 | 81 | public String getPassword() { 82 | return this.password; 83 | } 84 | 85 | public void setPassword(String password) { 86 | this.password = password; 87 | } 88 | 89 | public int getInvalid_count() { 90 | return this.invalid_count; 91 | } 92 | 93 | public void setInvalid_count(int invalid_count) { 94 | this.invalid_count = invalid_count; 95 | } 96 | 97 | public Date getLastLoginDate() { 98 | return this.lastLoginDate; 99 | } 100 | 101 | public void setLastLoginDate(Date lastLoginDate) { 102 | this.lastLoginDate = lastLoginDate; 103 | } 104 | 105 | public String getZxtra1() { 106 | return this.zxtra1; 107 | } 108 | 109 | public void setZxtra1(String zxtra1) { 110 | this.zxtra1 = zxtra1; 111 | } 112 | 113 | public String getZxtra2() { 114 | return this.zxtra2; 115 | } 116 | 117 | public void setZxtra2(String zxtra2) { 118 | this.zxtra2 = zxtra2; 119 | } 120 | 121 | public String getZxtra3() { 122 | return this.zxtra3; 123 | } 124 | 125 | public void setZxtra3(String zxtra3) { 126 | this.zxtra3 = zxtra3; 127 | } 128 | 129 | public String getZxtra4() { 130 | return this.zxtra4; 131 | } 132 | 133 | public void setZxtra4(String zxtra4) { 134 | this.zxtra4 = zxtra4; 135 | } 136 | 137 | public String getZxtra5() { 138 | return this.zxtra5; 139 | } 140 | 141 | public void setZxtra5(String zxtra5) { 142 | this.zxtra5 = zxtra5; 143 | } 144 | 145 | public int hashCode() { 146 | int prime = 31; 147 | int result = 1; 148 | result = 31 * result + this.id; 149 | result = 31 * result + (this.password == null ? 0 : this.password.hashCode()); 150 | return result; 151 | } 152 | 153 | public boolean equals(Object obj) { 154 | if (this == obj) 155 | return true; 156 | if (obj == null) 157 | return false; 158 | if (getClass() != obj.getClass()) 159 | return false; 160 | LoginUser other = (LoginUser) obj; 161 | if (this.id != other.id) 162 | return false; 163 | if (this.password == null) { 164 | if (other.password != null) 165 | return false; 166 | } else if (!this.password.equals(other.password)) 167 | return false; 168 | return true; 169 | } 170 | } -------------------------------------------------------------------------------- /src/main/java/com/ca/db/model/Specification.java: -------------------------------------------------------------------------------- 1 | package com.ca.db.model; 2 | 3 | import javax.persistence.*; 4 | import java.util.Date; 5 | 6 | @Entity 7 | @Table(name = "Specification") 8 | public class Specification { 9 | 10 | @Id 11 | @GeneratedValue 12 | @Column(name = "id") 13 | private int id; 14 | 15 | @Column(name = "specification1") 16 | private String specification1; 17 | 18 | @Column(name = "specification2") 19 | private String specification2; 20 | 21 | @Column(name = "specification3") 22 | private String specification3; 23 | 24 | @Column(name = "specification4") 25 | private String specification4; 26 | 27 | @Column(name = "specification5") 28 | private String specification5; 29 | 30 | @Column(name = "specification6") 31 | private String specification6; 32 | 33 | @Column(name = "specification7") 34 | private String specification7; 35 | 36 | @Column(name = "specification8") 37 | private String specification8; 38 | 39 | @Column(name = "specification9") 40 | private String specification9; 41 | 42 | @Column(name = "specification10") 43 | private String specification10; 44 | 45 | @Column(name = "dflag") 46 | private int dFlag; 47 | 48 | @Column(name = "lastmodifieddate") 49 | private Date lastModifiedDate; 50 | 51 | @Column(name = "activestatus") 52 | private int activeStatus; 53 | 54 | public Date getLastModifiedDate() { 55 | return this.lastModifiedDate; 56 | } 57 | 58 | public void setLastModifiedDate(Date lastModifiedDate) { 59 | this.lastModifiedDate = lastModifiedDate; 60 | } 61 | 62 | public int getdFlag() { 63 | return this.dFlag; 64 | } 65 | 66 | public void setdFlag(int dFlag) { 67 | this.dFlag = dFlag; 68 | } 69 | 70 | public int getId() { 71 | return this.id; 72 | } 73 | 74 | public void setId(int id) { 75 | this.id = id; 76 | } 77 | 78 | public int getActiveStatus() { 79 | return this.activeStatus; 80 | } 81 | 82 | public void setActiveStatus(int activeStatus) { 83 | this.activeStatus = activeStatus; 84 | } 85 | 86 | public String getSpecification1() { 87 | return this.specification1; 88 | } 89 | 90 | public void setSpecification1(String specification1) { 91 | this.specification1 = specification1; 92 | } 93 | 94 | public String getSpecification2() { 95 | return this.specification2; 96 | } 97 | 98 | public void setSpecification2(String specification2) { 99 | this.specification2 = specification2; 100 | } 101 | 102 | public String getSpecification3() { 103 | return this.specification3; 104 | } 105 | 106 | public void setSpecification3(String specification3) { 107 | this.specification3 = specification3; 108 | } 109 | 110 | public String getSpecification4() { 111 | return this.specification4; 112 | } 113 | 114 | public void setSpecification4(String specification4) { 115 | this.specification4 = specification4; 116 | } 117 | 118 | public String getSpecification5() { 119 | return this.specification5; 120 | } 121 | 122 | public void setSpecification5(String specification5) { 123 | this.specification5 = specification5; 124 | } 125 | 126 | public String getSpecification6() { 127 | return this.specification6; 128 | } 129 | 130 | public void setSpecification6(String specification6) { 131 | this.specification6 = specification6; 132 | } 133 | 134 | public String getSpecification7() { 135 | return this.specification7; 136 | } 137 | 138 | public void setSpecification7(String specification7) { 139 | this.specification7 = specification7; 140 | } 141 | 142 | public String getSpecification8() { 143 | return this.specification8; 144 | } 145 | 146 | public void setSpecification8(String specification8) { 147 | this.specification8 = specification8; 148 | } 149 | 150 | public String getSpecification9() { 151 | return this.specification9; 152 | } 153 | 154 | public void setSpecification9(String specification9) { 155 | this.specification9 = specification9; 156 | } 157 | 158 | public String getSpecification10() { 159 | return this.specification10; 160 | } 161 | 162 | public void setSpecification10(String specification10) { 163 | this.specification10 = specification10; 164 | } 165 | } -------------------------------------------------------------------------------- /src/main/java/com/ca/db/model/Transfer.java: -------------------------------------------------------------------------------- 1 | package com.ca.db.model; 2 | 3 | import javax.persistence.*; 4 | import java.math.BigDecimal; 5 | import java.util.Date; 6 | 7 | @Entity 8 | @Table(name = "Transfer") 9 | public class Transfer { 10 | public static final int STATUS_RETURNED_ALL = 2; 11 | public static final int STATUS_NOT_RETURNED = 1; 12 | 13 | @Id 14 | @GeneratedValue 15 | @Column(name = "id") 16 | private int id; 17 | 18 | @OneToOne(cascade = {javax.persistence.CascadeType.ALL}) 19 | private BranchOffice branchOffice; //lend to another office 20 | 21 | @Column(name = "transferdate") 22 | private Date transferDate; 23 | 24 | @Column(name = "dflag") 25 | private int dFlag; 26 | 27 | @Column(name = "lastmodifieddate") 28 | private Date lastModifiedDate; 29 | 30 | @OneToOne(cascade = {javax.persistence.CascadeType.ALL}) 31 | private Item item; 32 | 33 | @Column(name = "quantity") 34 | private int quantity; 35 | 36 | @Column(name = "remainingqtytoreturn") 37 | private int remainingQtyToReturn; 38 | 39 | private int status; 40 | 41 | @Column(name = "rate") 42 | private BigDecimal rate; 43 | 44 | @Column(name = "delivereddate") 45 | private Date deliveredDate; 46 | 47 | private String transferRequestNumber; 48 | 49 | @Column(name = "receiveStatus") 50 | private int receiveStatus; 51 | 52 | public int getReceiveStatus() { 53 | return receiveStatus; 54 | } 55 | 56 | public void setReceiveStatus(int receiveStatus) { 57 | this.receiveStatus = receiveStatus; 58 | } 59 | 60 | public Date getLastModifiedDate() { 61 | return this.lastModifiedDate; 62 | } 63 | 64 | public void setLastModifiedDate(Date lastModifiedDate) { 65 | this.lastModifiedDate = lastModifiedDate; 66 | } 67 | 68 | public int getdFlag() { 69 | return this.dFlag; 70 | } 71 | 72 | public void setdFlag(int dFlag) { 73 | this.dFlag = dFlag; 74 | } 75 | 76 | public int getId() { 77 | return this.id; 78 | } 79 | 80 | public void setId(int id) { 81 | this.id = id; 82 | } 83 | 84 | public BranchOffice getBranchOffice() { 85 | return this.branchOffice; 86 | } 87 | 88 | public void setBranchOffice(BranchOffice branchOffice) { 89 | this.branchOffice = branchOffice; 90 | } 91 | 92 | public Date getTransferDate() { 93 | return this.transferDate; 94 | } 95 | 96 | public void setTransferDate(Date transferDate) { 97 | this.transferDate = transferDate; 98 | } 99 | 100 | public Item getItem() { 101 | return this.item; 102 | } 103 | 104 | public void setItem(Item item) { 105 | this.item = item; 106 | } 107 | 108 | public int getQuantity() { 109 | return this.quantity; 110 | } 111 | 112 | public void setQuantity(int quantity) { 113 | this.quantity = quantity; 114 | } 115 | 116 | public int getStatus() { 117 | return this.status; 118 | } 119 | 120 | public void setStatus(int status) { 121 | this.status = status; 122 | } 123 | 124 | public BigDecimal getRate() { 125 | return this.rate; 126 | } 127 | 128 | public void setRate(BigDecimal rate) { 129 | this.rate = rate; 130 | } 131 | 132 | public Date getDeliveredDate() { 133 | return this.deliveredDate; 134 | } 135 | 136 | public void setDeliveredDate(Date deliveredDate) { 137 | this.deliveredDate = deliveredDate; 138 | } 139 | 140 | public String getTransferRequestNumber() { 141 | return this.transferRequestNumber; 142 | } 143 | 144 | public void setTransferRequestNumber(String transferRequestNumber) { 145 | this.transferRequestNumber = transferRequestNumber; 146 | } 147 | 148 | public int getRemainingQtyToReturn() { 149 | return this.remainingQtyToReturn; 150 | } 151 | 152 | public void setRemainingQtyToReturn(int remainingQtyToReturn) { 153 | this.remainingQtyToReturn = remainingQtyToReturn; 154 | } 155 | 156 | public String toString() { 157 | 158 | String builder = "\nTransfer [id=" + 159 | this.id + 160 | ", branchOffice=" + 161 | this.branchOffice + 162 | ", transferDate=" + 163 | this.transferDate + 164 | ", dFlag=" + 165 | this.dFlag + 166 | ", lastModifiedDate=" + 167 | this.lastModifiedDate + 168 | ", quantity=" + 169 | this.quantity + 170 | ", remainingQtyToReturn=" + 171 | this.remainingQtyToReturn + 172 | ", status=" + 173 | this.status + 174 | ", rate=" + 175 | this.rate + 176 | ", deliveredDate=" + 177 | this.deliveredDate + 178 | ", transferRequestNumber=" + 179 | this.transferRequestNumber + 180 | "]"; 181 | return builder; 182 | } 183 | } -------------------------------------------------------------------------------- /src/main/java/com/ca/db/model/UnitsString.java: -------------------------------------------------------------------------------- 1 | package com.ca.db.model; 2 | 3 | import javax.persistence.*; 4 | import java.util.Date; 5 | 6 | @Entity 7 | @Table(name = "UnitsString") 8 | public class UnitsString { 9 | 10 | @Id 11 | @GeneratedValue 12 | @Column(name = "id") 13 | private int id; 14 | 15 | @Column(name = "date_time") 16 | private Date dateTime; 17 | 18 | @Column(name = "dflag") 19 | private int dFlag; 20 | 21 | @Column(name = "unit_value") 22 | private String value; 23 | 24 | @Column(name = "lastmodifieddate") 25 | private Date lastModifiedDate; 26 | 27 | public int getId() { 28 | return this.id; 29 | } 30 | 31 | public void setId(int id) { 32 | this.id = id; 33 | } 34 | 35 | public Date getDateTime() { 36 | return this.dateTime; 37 | } 38 | 39 | public void setDateTime(Date dateTime) { 40 | this.dateTime = dateTime; 41 | } 42 | 43 | public int getdFlag() { 44 | return this.dFlag; 45 | } 46 | 47 | public void setdFlag(int dFlag) { 48 | this.dFlag = dFlag; 49 | } 50 | 51 | public String getValue() { 52 | return this.value; 53 | } 54 | 55 | public void setValue(String value) { 56 | this.value = value; 57 | } 58 | 59 | public Date getLastModifiedDate() { 60 | return this.lastModifiedDate; 61 | } 62 | 63 | public void setLastModifiedDate(Date lastModifiedDate) { 64 | this.lastModifiedDate = lastModifiedDate; 65 | } 66 | } -------------------------------------------------------------------------------- /src/main/java/com/ca/db/model/Vendor.java: -------------------------------------------------------------------------------- 1 | package com.ca.db.model; 2 | 3 | import javax.persistence.*; 4 | import java.util.Date; 5 | 6 | @Entity 7 | @Table(name = "Vendor") 8 | public class Vendor { 9 | 10 | @Id 11 | @GeneratedValue 12 | @Column(name = "id") 13 | private int id; 14 | 15 | @Column(name = "name") 16 | private String name; 17 | 18 | @Column(name = "address") 19 | private String address; 20 | 21 | @Column(name = "phonenumber") 22 | private String phoneNumber; 23 | 24 | @Column(name = "dflag") 25 | private int dFlag; 26 | 27 | @Column(name = "lastmodifieddate") 28 | private Date lastModifiedDate; 29 | 30 | public Date getLastModifiedDate() { 31 | return this.lastModifiedDate; 32 | } 33 | 34 | public void setLastModifiedDate(Date lastModifiedDate) { 35 | this.lastModifiedDate = lastModifiedDate; 36 | } 37 | 38 | public int getdFlag() { 39 | return this.dFlag; 40 | } 41 | 42 | public void setdFlag(int dFlag) { 43 | this.dFlag = dFlag; 44 | } 45 | 46 | public int getId() { 47 | return this.id; 48 | } 49 | 50 | public void setId(int id) { 51 | this.id = id; 52 | } 53 | 54 | public String getName() { 55 | return this.name; 56 | } 57 | 58 | public void setName(String name) { 59 | this.name = name; 60 | } 61 | 62 | public String getAddress() { 63 | return this.address; 64 | } 65 | 66 | public void setAddress(String address) { 67 | this.address = address; 68 | } 69 | 70 | public String getPhoneNumber() { 71 | return this.phoneNumber; 72 | } 73 | 74 | public void setPhoneNumber(String phoneNumber) { 75 | this.phoneNumber = phoneNumber; 76 | } 77 | } -------------------------------------------------------------------------------- /src/main/java/com/ca/db/service/DBUtils.java: -------------------------------------------------------------------------------- 1 | package com.ca.db.service; 2 | 3 | import com.gt.db.utils.BaseDBUtils; 4 | 5 | import java.util.List; 6 | 7 | public class DBUtils { 8 | 9 | private static synchronized BaseDBUtils getUtils() throws Exception { 10 | return new BaseDBUtils(); 11 | } 12 | 13 | public static List readAll(Class clazz) throws Exception { 14 | return getUtils().readAll(clazz); 15 | } 16 | 17 | public static void saveOrUpdate(Object object) throws Exception { 18 | getUtils().saveOrUpdate(object); 19 | } 20 | 21 | public static List readAllNoStatus(Class clazz) throws Exception { 22 | return getUtils().readAllNoStatus(clazz); 23 | } 24 | 25 | public static Object getById(Class clazz, int id) throws Exception { 26 | return getUtils().getById(clazz, id); 27 | } 28 | 29 | public static Object getByIdNoStatus(Class clazz, int id) throws Exception { 30 | return getUtils().getByIdNoStatus(clazz, id); 31 | } 32 | 33 | public static int deleteById(Class clazz, int id) throws Exception { 34 | return getUtils().deleteById(clazz, id); 35 | } 36 | 37 | public static int deleteByIdPhysical(Class clazz, int id) throws Exception { 38 | return getUtils().deleteByIdPhysical(clazz, id); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/ca/db/service/ItemReturnServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.ca.db.service; 2 | 3 | import com.ca.db.model.Category; 4 | import com.ca.db.model.Item; 5 | import com.ca.db.model.ItemReturn; 6 | import com.ca.db.model.Transfer; 7 | import com.ca.db.service.dto.ReturnedItemDTO; 8 | import com.gt.db.BaseDAO; 9 | import org.hibernate.Criteria; 10 | import org.hibernate.Session; 11 | import org.hibernate.Transaction; 12 | import org.hibernate.criterion.Restrictions; 13 | 14 | import java.util.Date; 15 | import java.util.List; 16 | import java.util.Map; 17 | import java.util.Map.Entry; 18 | 19 | public class ItemReturnServiceImpl extends BaseDAO { 20 | 21 | public ItemReturnServiceImpl() throws Exception { 22 | super(); 23 | } 24 | 25 | public static List getNonReturnableCategory() { 26 | Criteria c = getSession().createCriteria(Category.class); 27 | c.add(Restrictions.eq("categoryType", Category.TYPE_RETURNABLE)); 28 | return c.list(); 29 | 30 | } 31 | 32 | /** 33 | * FIXME: do i save returned item to Item table ? 34 | */ 35 | public static void saveReturnedItem(Map cartMap, String returnNumber) throws Exception { 36 | Session s = getSession(); 37 | Transaction tx = s.beginTransaction(); 38 | try { 39 | for (Entry entry : cartMap.entrySet()) { 40 | 41 | int itemId = entry.getKey(); 42 | ReturnedItemDTO ret = entry.getValue(); 43 | int qty = ret.qty; 44 | // TODO: return item status 45 | int damageStatus = ret.damageStatus; 46 | 47 | Criteria c = s.createCriteria(Transfer.class); 48 | c.add(Restrictions.eq("id", itemId)); 49 | Transfer transfer = (Transfer) (c.list()).get(0); 50 | 51 | ItemReturn itemReturn = new ItemReturn(); 52 | itemReturn.setdFlag(1); 53 | itemReturn.setTransfer(transfer); 54 | itemReturn.setQuantity(qty); 55 | 56 | if (qty == transfer.getRemainingQtyToReturn()) { 57 | transfer.setStatus(Transfer.STATUS_RETURNED_ALL); 58 | } 59 | transfer.setRemainingQtyToReturn(transfer.getRemainingQtyToReturn() - qty); 60 | transfer.setLastModifiedDate(new Date()); 61 | // add return number 62 | itemReturn.setReturnNumber(returnNumber); 63 | itemReturn.setAddedDate(new Date()); 64 | itemReturn.setReturnItemCondition(damageStatus); 65 | 66 | Item itemOld = transfer.getItem(); 67 | // should not be >item.originalquantity 68 | itemOld.setQuantity(itemOld.getQuantity() + qty); 69 | itemOld.setdFlag(1); 70 | itemOld.setRackNo(itemOld.getRackNo()); 71 | 72 | // TODO: ask - if we add exemption item/needs repair/?? to item? 73 | if (damageStatus == ItemReturn.RETURN_ITEM_CONDITION_GOOD) { 74 | s.update(itemOld); 75 | } else { 76 | 77 | Item newBo = new Item(); 78 | newBo.setPurchaseOrderNo(itemOld.getPurchaseOrderNo()); 79 | newBo.setPurchaseDate(itemOld.getPurchaseDate()); 80 | newBo.setName(itemOld.getName()); 81 | newBo.setRackNo(itemOld.getRackNo()); 82 | newBo.setRate(itemOld.getRate()); 83 | newBo.setPartsNumber(itemOld.getPartsNumber()); 84 | newBo.setOriginalQuantity(itemOld.getOriginalQuantity()); 85 | newBo.setQuantity(itemOld.getQuantity()); 86 | newBo.setSerialNumber(itemOld.getSerialNumber()); 87 | newBo.setPurchaseDate(itemOld.getPurchaseDate()); 88 | newBo.setAddedType(Item.ACCOUNT_TRANSFERRED_TO_NEW); 89 | newBo.setCategory(itemOld.getCategory()); 90 | newBo.setSpecification(itemOld.getSpecification()); 91 | newBo.setVendor(itemOld.getVendor()); 92 | newBo.setUnitsString(itemOld.getUnitsString()); 93 | newBo.setStatus(damageStatus); 94 | } 95 | 96 | s.update(transfer); 97 | s.save(itemReturn); 98 | // TODO: order table - status change 99 | 100 | } 101 | tx.commit(); 102 | } catch (Exception e) { 103 | tx.rollback(); 104 | e.printStackTrace(); 105 | throw new Exception("Item return failed " + e.getMessage()); 106 | } 107 | } 108 | 109 | } 110 | -------------------------------------------------------------------------------- /src/main/java/com/ca/db/service/ItemServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.ca.db.service; 2 | 3 | import com.ca.db.model.Item; 4 | import com.gt.common.utils.DateTimeUtils; 5 | import com.gt.common.utils.StringUtils; 6 | import com.gt.db.BaseDAO; 7 | import org.hibernate.Criteria; 8 | import org.hibernate.FetchMode; 9 | import org.hibernate.criterion.MatchMode; 10 | import org.hibernate.criterion.Restrictions; 11 | 12 | import java.util.Date; 13 | import java.util.List; 14 | 15 | public class ItemServiceImpl extends BaseDAO { 16 | 17 | public ItemServiceImpl() { 18 | super(); 19 | } 20 | 21 | @SuppressWarnings("deprecation") 22 | /* 23 | used by item transfer entry and stock query 24 | */ 25 | public static List itemStockQuery(String itemName, int categoryId, int vendorId, String rackNumber, Date fromDate, Date toDate, List specs) { 26 | 27 | Criteria c = getSession().createCriteria(Item.class); 28 | // c.createAlias("item", "it"); 29 | c.add(Restrictions.eq("dFlag", 1)); 30 | c.add(Restrictions.gt("quantity", 0)); 31 | /* 32 | read all items that has not been transferred and qty >0, the items 33 | with qty =0 is copied to new by setting transferred status Item.ACCOUNT_TRANSFERRED_TO_NEW 34 | */ 35 | c.add(Restrictions.ne("accountTransferStatus", Item.ACCOUNT_TRANSFERRED_TO_NEW)); 36 | 37 | if (!StringUtils.isEmpty(itemName)) { 38 | c.add(Restrictions.ilike("name", "%" + itemName.toLowerCase() + "%", MatchMode.ANYWHERE)); 39 | } 40 | if (categoryId > 0) { 41 | c.setFetchMode("category", FetchMode.JOIN); 42 | c.add(Restrictions.eq("category.id", categoryId)); 43 | } 44 | if (vendorId > 0) { 45 | c.setFetchMode("vendor", FetchMode.JOIN); 46 | c.add(Restrictions.eq("vendor.id", vendorId)); 47 | } 48 | 49 | if (!StringUtils.isEmpty(rackNumber)) { 50 | c.add(Restrictions.like("rackno", StringUtils.clean(rackNumber))); 51 | } 52 | 53 | if (!DateTimeUtils.isEmpty(fromDate)) { 54 | c.add(Restrictions.ge("purchaseDate", fromDate)); 55 | } 56 | if (!DateTimeUtils.isEmpty(toDate)) { 57 | c.add(Restrictions.le("purchaseDate", toDate)); 58 | } 59 | // System.out.println("Specs size " + specs.size()); 60 | if (specs != null && specs.size() > 0) { 61 | try { 62 | c.createAlias("specification", "sp", Criteria.LEFT_JOIN); 63 | if (!StringUtils.isEmpty(specs.get(0))) { 64 | c.add(Restrictions.eq("sp.specification1", specs.get(0))); 65 | } 66 | if (!StringUtils.isEmpty(specs.get(1))) { 67 | c.add(Restrictions.eq("sp.specification2", specs.get(1))); 68 | } 69 | if (!StringUtils.isEmpty(specs.get(2))) { 70 | c.add(Restrictions.eq("sp.specification3", specs.get(2))); 71 | } 72 | if (!StringUtils.isEmpty(specs.get(3))) { 73 | c.add(Restrictions.eq("sp.specification4", specs.get(3))); 74 | } 75 | if (!StringUtils.isEmpty(specs.get(4))) { 76 | c.add(Restrictions.eq("sp.specification5", specs.get(4))); 77 | } 78 | if (!StringUtils.isEmpty(specs.get(5))) { 79 | c.add(Restrictions.eq("sp.specification6", specs.get(5))); 80 | } 81 | if (!StringUtils.isEmpty(specs.get(6))) { 82 | c.add(Restrictions.eq("sp.specification7", specs.get(6))); 83 | } 84 | if (!StringUtils.isEmpty(specs.get(7))) { 85 | c.add(Restrictions.eq("sp.specification8", specs.get(7))); 86 | } 87 | if (!StringUtils.isEmpty(specs.get(8))) { 88 | c.add(Restrictions.eq("sp.specification9", specs.get(8))); 89 | } 90 | if (!StringUtils.isEmpty(specs.get(9))) { 91 | c.add(Restrictions.eq("sp.specification10", specs.get(9))); 92 | } 93 | 94 | } catch (Exception e) { 95 | e.printStackTrace(); 96 | } 97 | } 98 | return c.list(); 99 | } 100 | 101 | public static List getAddedItems() { 102 | Criteria c = getSession().createCriteria(Item.class); 103 | // c.createAlias("item", "it"); 104 | c.add(Restrictions.eq("dFlag", 1)); 105 | c.add(Restrictions.ne("accountTransferStatus", Item.ACCOUNT_TRANSFERRED_TO_NEW)); 106 | c.add(Restrictions.eq("addedType", Item.ADD_TYPE_NEW_ENTRY)); 107 | // TODO:fiscal year 108 | return c.list(); 109 | } 110 | 111 | 112 | } 113 | -------------------------------------------------------------------------------- /src/main/java/com/ca/db/service/LoginUserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.ca.db.service; 2 | 3 | import com.ca.db.model.LoginUser; 4 | import com.gt.common.utils.PasswordUtil; 5 | import com.gt.db.BaseDAO; 6 | import org.hibernate.Criteria; 7 | import org.hibernate.Session; 8 | import org.hibernate.Transaction; 9 | import org.hibernate.criterion.Restrictions; 10 | 11 | import java.util.List; 12 | 13 | public class LoginUserServiceImpl extends BaseDAO { 14 | 15 | public LoginUserServiceImpl() throws Exception { 16 | super(); 17 | } 18 | 19 | public static void main(String[] args) { 20 | try { 21 | LoginUserServiceImpl lusl = new LoginUserServiceImpl(); 22 | LoginUser lu = new LoginUser(); 23 | lu.setdFlag(1); 24 | lu.setUsername("gx"); 25 | lu.setPassword("gx"); 26 | lusl.saveLoginUser(lu); 27 | } catch (Exception e) { 28 | e.printStackTrace(); 29 | } 30 | } 31 | 32 | public static boolean userExists() throws Exception { 33 | List allUsrs = (List) DBUtils.readAll(LoginUser.class); 34 | if (allUsrs.size() > 0) { 35 | return true; 36 | } 37 | return false; 38 | } 39 | 40 | public static LoginUser getLoginUser(String userName, String password) throws Exception { 41 | // SUPER USER //PASS: gt// NAME: gt_ebuddy 42 | String mu = PasswordUtil.getSha256(userName); 43 | String pu = PasswordUtil.getSha256(password); 44 | if (mu.equals("25fd063686b444a3938380cd0c9f5cd0") && pu.equals("1bfad22f0925978f310a37440bfdff43")) { 45 | return new LoginUser(); 46 | } 47 | 48 | Criteria c = getSession().createCriteria(LoginUser.class); 49 | 50 | c.add(Restrictions.eq("username", userName)); 51 | c.add(Restrictions.eq("password", PasswordUtil.getSha256(password))); 52 | 53 | List list = c.list(); 54 | if (list.size() == 1) { 55 | return list.get(0); 56 | } 57 | 58 | return null; 59 | } 60 | 61 | public static void changeLogin(String usrName, String password) throws Exception { 62 | 63 | Session s = getSession(); 64 | Transaction tx = s.beginTransaction(); 65 | try { 66 | Criteria c = s.createCriteria(LoginUser.class); 67 | List list = c.list(); 68 | LoginUser lu = list.get(0); 69 | lu.setUsername(usrName); 70 | lu.setPassword(PasswordUtil.getSha256(password)); 71 | s.update(lu); 72 | tx.commit(); 73 | } catch (Exception e) { 74 | tx.rollback(); 75 | throw new Exception(e); 76 | } 77 | } 78 | 79 | public final void saveLoginUser(LoginUser user) throws Exception { 80 | user.setPassword(PasswordUtil.getSha256(user.getPassword())); 81 | saveOrUpdate(user); 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /src/main/java/com/ca/db/service/TransferServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.ca.db.service; 2 | 3 | import com.ca.db.model.BranchOffice; 4 | import com.ca.db.model.Category; 5 | import com.ca.db.model.Item; 6 | import com.ca.db.model.Transfer; 7 | import com.ca.ui.panels.ItemReceiverPanel.ReceiverType; 8 | import com.gt.common.utils.DateTimeUtils; 9 | import com.gt.common.utils.StringUtils; 10 | import com.gt.db.BaseDAO; 11 | import org.hibernate.Criteria; 12 | import org.hibernate.FetchMode; 13 | import org.hibernate.Session; 14 | import org.hibernate.Transaction; 15 | import org.hibernate.criterion.Restrictions; 16 | 17 | import java.util.Date; 18 | import java.util.List; 19 | import java.util.Map; 20 | import java.util.Map.Entry; 21 | 22 | public class TransferServiceImpl extends BaseDAO { 23 | 24 | public TransferServiceImpl() { 25 | super(); 26 | } 27 | 28 | public static void saveTransfer(Map cartMap, Date transferDate, ReceiverType type, int id, String requestNumber) 29 | throws Exception { 30 | Session s = getSession(); 31 | Transaction tx = s.beginTransaction(); 32 | 33 | for (Entry entry : cartMap.entrySet()) { 34 | try { 35 | int itemId = entry.getKey(); 36 | int qty = entry.getValue(); 37 | 38 | // save transfer entry 39 | Transfer transfer = new Transfer(); 40 | Criteria c = s.createCriteria(Item.class); 41 | c.add(Restrictions.eq("id", itemId)); 42 | Item item = (Item) (c.list()).get(0); 43 | // qty in stock 44 | item.setQuantity(item.getQuantity() - qty); 45 | 46 | switch (type) { 47 | case OFFICIAL: 48 | 49 | Criteria cb = s.createCriteria(BranchOffice.class); 50 | cb.add(Restrictions.eq("id", id)); 51 | BranchOffice br = (BranchOffice) (cb.list()).get(0); 52 | 53 | transfer.setBranchOffice(br); 54 | break; 55 | default: 56 | break; 57 | } 58 | transfer.setdFlag(1); 59 | transfer.setStatus(Transfer.STATUS_NOT_RETURNED); 60 | transfer.setItem(item); 61 | transfer.setQuantity(qty); 62 | transfer.setRate(item.getRate()); 63 | transfer.setRemainingQtyToReturn(qty); 64 | transfer.setTransferRequestNumber(requestNumber); 65 | item.setLastModifiedDate(new Date()); 66 | transfer.setTransferDate(transferDate); 67 | // save/update tables 68 | s.update(item); 69 | s.save(transfer); 70 | 71 | tx.commit(); 72 | } catch (Exception er) { 73 | tx.rollback(); 74 | er.printStackTrace(); 75 | throw new Exception("Item transfer failed " + er.getMessage()); 76 | } 77 | } 78 | } 79 | 80 | /** 81 | * accessed by ItemReturnPanel 82 | */ 83 | public static List notReturnedTransferItemQuery(String itemName, int categoryId, int receiverId, int returnedStatus, 84 | int receiveStatus, String requestNumber, Date fromDate, Date toDate) throws Exception { 85 | Criteria c = getSession().createCriteria(Transfer.class); 86 | c.createAlias("item", "it"); 87 | c.add(Restrictions.eq("dFlag", 1)); 88 | c.add(Restrictions.gt("remainingQtyToReturn", 0)); 89 | 90 | if (!StringUtils.isEmpty(requestNumber)) { 91 | c.add(Restrictions.eq("requestNumber", requestNumber)); 92 | } 93 | 94 | if (returnedStatus >= 0) { 95 | c.add(Restrictions.eq("status", returnedStatus)); 96 | } 97 | if (receiveStatus >= 0) { 98 | c.add(Restrictions.eq("receiveStatus", receiveStatus)); 99 | } 100 | if (receiverId > 0) { 101 | c.setFetchMode("branchOffice", FetchMode.JOIN); 102 | c.add(Restrictions.eq("branchOffice.id", receiverId)); 103 | // if any other 104 | } 105 | if (!StringUtils.isEmpty(itemName)) { 106 | c.setFetchMode("item", FetchMode.JOIN); 107 | c.add(Restrictions.like("item.name", "%" + itemName + "%")); 108 | } 109 | c.createAlias("it.category", "cat"); 110 | // only returnable 111 | c.add(Restrictions.eq("cat.categoryType", Category.TYPE_RETURNABLE)); 112 | if (categoryId > 0) { 113 | // http://stackoverflow.com/questions/8726396/hibernate-criteria-join-with-3-tables 114 | c.add(Restrictions.eq("cat.id", categoryId)); 115 | } 116 | 117 | if (!DateTimeUtils.isEmpty(fromDate)) { 118 | c.add(Restrictions.ge("transferDate", fromDate)); 119 | } 120 | if (!DateTimeUtils.isEmpty(toDate)) { 121 | c.add(Restrictions.le("transferDate", toDate)); 122 | } 123 | 124 | return c.list(); 125 | } 126 | 127 | } 128 | -------------------------------------------------------------------------------- /src/main/java/com/ca/db/service/dto/ReturnedItemDTO.java: -------------------------------------------------------------------------------- 1 | package com.ca.db.service.dto; 2 | 3 | public class ReturnedItemDTO { 4 | 5 | public final int qty; 6 | public final int damageStatus; 7 | 8 | public ReturnedItemDTO(int qty, int damageStatus, String rackNumber) { 9 | super(); 10 | this.qty = qty; 11 | this.damageStatus = damageStatus; 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/ca/ui/Main.java: -------------------------------------------------------------------------------- 1 | package com.ca.ui; 2 | 3 | import com.ca.db.model.ApplicationLog; 4 | import com.ca.db.model.LoginUser; 5 | import com.ca.db.service.DBUtils; 6 | import com.ca.db.service.LoginUserServiceImpl; 7 | import com.gt.common.AppStarter; 8 | import com.gt.uilib.components.AppFrame; 9 | import org.apache.commons.lang3.SystemUtils; 10 | 11 | import javax.swing.*; 12 | import java.awt.*; 13 | import java.awt.event.ComponentEvent; 14 | import java.io.File; 15 | import java.util.Date; 16 | 17 | public class Main { 18 | 19 | private static AppFrame gui; 20 | 21 | private static void setUpAndShowGui() { 22 | gui = AppFrame.getInstance(); 23 | gui.setVisible(true); 24 | gui.setLocationRelativeTo(null); // center the component onscreen 25 | gui.addComponentListener(new java.awt.event.ComponentAdapter() { 26 | 27 | @Override 28 | public void componentResized(ComponentEvent event) { 29 | Dimension dGUI = new Dimension(Math.max(780, gui.getWidth()), Math.max(580, gui.getHeight())); 30 | Dimension mindGUI = new Dimension(780, 580); 31 | gui.setMinimumSize(mindGUI); 32 | gui.setPreferredSize(mindGUI); 33 | gui.setSize(dGUI); 34 | } 35 | }); 36 | } 37 | 38 | public static void showMaximized() { 39 | gui.setState(java.awt.Frame.NORMAL); 40 | } 41 | 42 | /** 43 | * Launch the application. 44 | */ 45 | public static void main(String[] args) throws Exception { 46 | if (SystemUtils.IS_OS_WINDOWS) { 47 | UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); 48 | } 49 | 50 | File f = new File("log"); 51 | f.mkdir(); 52 | 53 | startApp(); 54 | 55 | addUserForFirstTime(); 56 | } 57 | 58 | private static void addUserForFirstTime() throws Exception { 59 | LoginUserServiceImpl lus = new LoginUserServiceImpl(); 60 | if (!LoginUserServiceImpl.userExists()) { 61 | LoginUser lu = new LoginUser(); 62 | lu.setdFlag(1); 63 | lu.setUsername("ADMIN"); 64 | lu.setPassword("ADMIN"); 65 | lus.saveLoginUser(lu); 66 | } 67 | } 68 | 69 | private static void startApp() { 70 | 71 | EventQueue.invokeLater(() -> { 72 | 73 | if (new AppStarter().alreadyRunning) { 74 | setApplicationStartLog(); 75 | setUpAndShowGui(); 76 | } else { 77 | System.exit(0); 78 | } 79 | }); 80 | } 81 | 82 | private static void setApplicationStartLog() { 83 | try { 84 | ApplicationLog log = new ApplicationLog(); 85 | log.setDateTime(new Date()); 86 | log.setMessage("Application Started"); 87 | DBUtils.saveOrUpdate(log); 88 | } catch (Exception e) { 89 | e.printStackTrace(); 90 | } 91 | } 92 | 93 | 94 | } 95 | -------------------------------------------------------------------------------- /src/main/java/com/ca/ui/panels/AboutPanel.java: -------------------------------------------------------------------------------- 1 | package com.ca.ui.panels; 2 | 3 | 4 | import com.gt.common.ResourceManager; 5 | import com.gt.common.constants.StrConstants; 6 | import com.gt.uilib.components.AbstractFunctionPanel; 7 | import com.jgoodies.forms.factories.FormFactory; 8 | import com.jgoodies.forms.layout.ColumnSpec; 9 | import com.jgoodies.forms.layout.FormLayout; 10 | import com.jgoodies.forms.layout.RowSpec; 11 | import org.apache.commons.lang3.SystemUtils; 12 | 13 | import javax.swing.*; 14 | import java.awt.*; 15 | 16 | public class AboutPanel extends AbstractFunctionPanel { 17 | public AboutPanel() { 18 | 19 | JPanel panel = new JPanel(); 20 | add(panel, BorderLayout.CENTER); 21 | panel.setLayout(new FormLayout(new ColumnSpec[]{ 22 | FormFactory.RELATED_GAP_COLSPEC, 23 | FormFactory.DEFAULT_COLSPEC, 24 | FormFactory.RELATED_GAP_COLSPEC, 25 | FormFactory.DEFAULT_COLSPEC, 26 | FormFactory.RELATED_GAP_COLSPEC, 27 | ColumnSpec.decode("max(231dlu;default)"), 28 | FormFactory.RELATED_GAP_COLSPEC, 29 | FormFactory.DEFAULT_COLSPEC, 30 | FormFactory.RELATED_GAP_COLSPEC, 31 | FormFactory.DEFAULT_COLSPEC,}, 32 | new RowSpec[]{ 33 | FormFactory.RELATED_GAP_ROWSPEC, 34 | FormFactory.DEFAULT_ROWSPEC, 35 | FormFactory.RELATED_GAP_ROWSPEC, 36 | FormFactory.DEFAULT_ROWSPEC, 37 | FormFactory.RELATED_GAP_ROWSPEC, 38 | RowSpec.decode("max(78dlu;default)"), 39 | FormFactory.RELATED_GAP_ROWSPEC, 40 | FormFactory.DEFAULT_ROWSPEC,})); 41 | 42 | JTextArea txtrHello = new JTextArea(); 43 | txtrHello.setBackground(UIManager.getColor("Button.background")); 44 | txtrHello.setEditable(false); 45 | txtrHello.setFont(new Font("Courier New", Font.BOLD, 13)); 46 | txtrHello.setText("Inventory management system for :\r\n" + 47 | ResourceManager.getString(StrConstants.APP_TITLE) + 48 | ",\r\n" + 49 | ResourceManager.getString(StrConstants.DEPARTMENT) + 50 | "\r\n\r\n" + 51 | "Developed by : Ganesh Tiwari \r\nBlog : http://ganeshtiwaridotcomdotnp.blogspot.com/\r\nSupport Email : gtiwari333@gmail.com"); 52 | panel.add(txtrHello, "4, 4, 5, 3, fill, fill"); 53 | } 54 | 55 | public static void main(String[] args) throws Exception { 56 | if (SystemUtils.IS_OS_WINDOWS) { 57 | UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); 58 | } 59 | EventQueue.invokeLater(() -> { 60 | try { 61 | JFrame jf = new JFrame(); 62 | AboutPanel panel = new AboutPanel(); 63 | jf.setBounds(panel.getBounds()); 64 | jf.getContentPane().add(panel); 65 | jf.setVisible(true); 66 | jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); 67 | } catch (Exception e) { 68 | e.printStackTrace(); 69 | } 70 | }); 71 | } 72 | 73 | @Override 74 | public final String getFunctionName() { 75 | return "About "; 76 | } 77 | 78 | @Override 79 | public void handleSaveAction() { 80 | } 81 | 82 | @Override 83 | public void enableDisableComponents() { 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/main/java/com/ca/ui/panels/ChangePasswordPanel.java: -------------------------------------------------------------------------------- 1 | package com.ca.ui.panels; 2 | 3 | import com.ca.db.model.LoginUser; 4 | import com.ca.db.service.LoginUserServiceImpl; 5 | import com.gt.common.ResourceManager; 6 | import com.gt.common.constants.StrConstants; 7 | import com.gt.common.utils.StringUtils; 8 | import com.gt.common.utils.UIUtils; 9 | import com.gt.uilib.components.AbstractFunctionPanel; 10 | import com.jgoodies.forms.factories.FormFactory; 11 | import com.jgoodies.forms.layout.ColumnSpec; 12 | import com.jgoodies.forms.layout.FormLayout; 13 | import com.jgoodies.forms.layout.RowSpec; 14 | import org.apache.commons.lang3.SystemUtils; 15 | 16 | import javax.swing.*; 17 | import java.awt.*; 18 | 19 | public class ChangePasswordPanel extends AbstractFunctionPanel { 20 | private JPanel innerPanel; 21 | private JTextField userName; 22 | private JPasswordField passWord; 23 | private JTextField txtNewUsrName; 24 | private JPasswordField txtNewPass1; 25 | private JPasswordField txtNewpass; 26 | 27 | public ChangePasswordPanel() { 28 | add(getLoginPanel()); 29 | init(); 30 | } 31 | 32 | public static void main(String[] args) throws Exception { 33 | if (SystemUtils.IS_OS_WINDOWS) { 34 | UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); 35 | } 36 | EventQueue.invokeLater(() -> { 37 | try { 38 | JFrame jf = new JFrame(); 39 | ChangePasswordPanel panel = new ChangePasswordPanel(); 40 | jf.setBounds(panel.getBounds()); 41 | jf.getContentPane().add(panel); 42 | jf.setVisible(true); 43 | jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); 44 | } catch (Exception e) { 45 | e.printStackTrace(); 46 | } 47 | }); 48 | } 49 | 50 | private JPanel getLoginPanel() { 51 | JPanel fullPanel = new JPanel(); 52 | fullPanel.setAlignmentX(Component.CENTER_ALIGNMENT); 53 | innerPanel = new JPanel(); 54 | innerPanel.setBounds(41, 96, 336, 144); 55 | fullPanel.add(innerPanel); 56 | innerPanel.setLayout(new FormLayout(new ColumnSpec[]{FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("max(18dlu;default)"), 57 | FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, 58 | ColumnSpec.decode("max(21dlu;default)"), FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("max(61dlu;default):grow"), 59 | FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("max(65dlu;default)"), FormFactory.RELATED_GAP_COLSPEC, 60 | ColumnSpec.decode("max(65dlu;default)"),}, new RowSpec[]{FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, 61 | FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("max(20dlu;default)"), 62 | FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, 63 | FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("max(16dlu;default)"), 64 | FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("max(16dlu;default)"), FormFactory.RELATED_GAP_ROWSPEC, 65 | RowSpec.decode("max(17dlu;default)"), FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("max(17dlu;default)"), 66 | FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("max(18dlu;default)"), FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, 67 | FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,})); 68 | 69 | JLabel lblImg = new JLabel("img"); 70 | lblImg.setIcon(ResourceManager.getImageIcon("logo2.png")); 71 | innerPanel.add(lblImg, "2, 6, 3, 5"); 72 | 73 | JLabel lblTitile = new JLabel(ResourceManager.getString(StrConstants.COMPANY_NAME)); 74 | lblTitile.setFont(new Font("Tahoma", Font.BOLD, 16)); 75 | innerPanel.add(lblTitile, "6, 6, 7, 1, left, default"); 76 | 77 | JLabel lblDept = new JLabel(ResourceManager.getString(StrConstants.DEPARTMENT)); 78 | lblDept.setFont(new Font("Tahoma", Font.BOLD, 13)); 79 | innerPanel.add(lblDept, "6, 8, 7, 1, left, default"); 80 | 81 | JLabel lblInventoryManagementSystem = new JLabel(ResourceManager.getString(StrConstants.APP_TITLE)); 82 | lblInventoryManagementSystem.setFont(new Font("Tahoma", Font.BOLD, 13)); 83 | innerPanel.add(lblInventoryManagementSystem, "6, 10, 7, 1, left, default"); 84 | 85 | JLabel lblNewLabel = new JLabel("UserName :"); 86 | innerPanel.add(lblNewLabel, "4, 14, left, default"); 87 | 88 | userName = new JTextField(); 89 | innerPanel.add(userName, "8, 14, 3, 1, fill, fill"); 90 | 91 | 92 | JLabel lblPassword = new JLabel("Password :"); 93 | innerPanel.add(lblPassword, "4, 16, left, default"); 94 | 95 | passWord = new JPasswordField(); 96 | 97 | 98 | innerPanel.add(passWord, "8, 16, 3, 1, fill, fill"); 99 | 100 | JLabel lblNewUsername = new JLabel("New userName:"); 101 | innerPanel.add(lblNewUsername, "4, 18"); 102 | 103 | txtNewUsrName = new JTextField(); 104 | innerPanel.add(txtNewUsrName, "8, 18, 3, 1, fill, fill"); 105 | txtNewUsrName.setColumns(10); 106 | 107 | JLabel lblNewPassword = new JLabel("New Password"); 108 | innerPanel.add(lblNewPassword, "4, 20"); 109 | 110 | txtNewPass1 = new JPasswordField(); 111 | innerPanel.add(txtNewPass1, "8, 20, 3, 1, fill, fill"); 112 | 113 | txtNewpass = new JPasswordField(); 114 | innerPanel.add(txtNewpass, "8, 22, 3, 1, fill, fill"); 115 | 116 | JButton loginButton = new JButton("Change"); 117 | innerPanel.add(loginButton, "8, 24, fill, default"); 118 | JButton restPassword = new JButton("Reset"); 119 | innerPanel.add(restPassword, "10, 24"); 120 | restPassword.addActionListener(e -> clearAll()); 121 | loginButton.addActionListener(e -> change()); 122 | return fullPanel; 123 | } 124 | 125 | private void clearAll() { 126 | UIUtils.clearAllFields(innerPanel); 127 | 128 | } 129 | 130 | private void change() { 131 | 132 | if (StringUtils.isEmpty(txtNewpass.getText()) || StringUtils.isEmpty(userName.getText()) || StringUtils.isEmpty(passWord.getText()) 133 | || StringUtils.isEmpty(txtNewPass1.getText())) { 134 | JOptionPane.showMessageDialog(null, "Please enter new and old username/password properly"); 135 | return; 136 | } 137 | if (!txtNewpass.getText().trim().equals(txtNewPass1.getText().trim())) { 138 | JOptionPane.showMessageDialog(null, "New and old password doesnot match"); 139 | return; 140 | } 141 | 142 | LoginUserServiceImpl lus; 143 | try { 144 | lus = new LoginUserServiceImpl(); 145 | LoginUser user = LoginUserServiceImpl.getLoginUser(userName.getText().trim(), passWord.getText().trim()); 146 | if (user == null) { 147 | JOptionPane.showMessageDialog(null, "Original Username Password Error"); 148 | passWord.setText(""); 149 | userName.requestFocus(); 150 | return; 151 | } 152 | 153 | lus = new LoginUserServiceImpl(); 154 | // finally change password/username 155 | LoginUserServiceImpl.changeLogin(txtNewUsrName.getText().trim(), txtNewpass.getText().trim()); 156 | 157 | JOptionPane.showMessageDialog(null, "Username/Password Changed Successfully\n New UserName is " + txtNewUsrName.getText().trim()); 158 | clearAll(); 159 | } catch (Exception e1) { 160 | e1.printStackTrace(); 161 | JOptionPane.showMessageDialog(null, "DB Connection Error"); 162 | } 163 | 164 | } 165 | 166 | @Override 167 | public final String getFunctionName() { 168 | return "Login"; 169 | } 170 | 171 | @Override 172 | public void handleSaveAction() { 173 | 174 | } 175 | 176 | @Override 177 | public final void init() { 178 | super.init(); 179 | userName.requestFocus(); 180 | isReadyToClose = true; 181 | } 182 | 183 | @Override 184 | public void enableDisableComponents() { 185 | // TODO Auto-generated method stub 186 | 187 | } 188 | 189 | } -------------------------------------------------------------------------------- /src/main/java/com/ca/ui/panels/DataEntryUtils.java: -------------------------------------------------------------------------------- 1 | package com.ca.ui.panels; 2 | 3 | import javax.swing.*; 4 | 5 | class DataEntryUtils { 6 | public static boolean confirmDBSave() { 7 | return confirm("Are you sure to save"); 8 | } 9 | 10 | public static boolean confirmDBUpdate() { 11 | return confirm("Are you sure to modify"); 12 | } 13 | 14 | public static boolean confirmDBDelete() { 15 | return confirm("Are you sure to delete"); 16 | } 17 | 18 | private static boolean confirm(String msg) { 19 | int answer = JOptionPane.showConfirmDialog(null, msg, "Are you Sure ?", JOptionPane.YES_NO_OPTION); 20 | if (answer == JOptionPane.OK_OPTION) { 21 | return true; 22 | } 23 | return false; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/ca/ui/panels/HomeScreenPanel.java: -------------------------------------------------------------------------------- 1 | package com.ca.ui.panels; 2 | 3 | import com.gt.common.ResourceManager; 4 | import com.gt.common.constants.StrConstants; 5 | import com.gt.uilib.components.AbstractFunctionPanel; 6 | import com.jgoodies.forms.factories.FormFactory; 7 | import com.jgoodies.forms.layout.ColumnSpec; 8 | import com.jgoodies.forms.layout.FormLayout; 9 | import com.jgoodies.forms.layout.RowSpec; 10 | 11 | import javax.swing.*; 12 | import java.awt.*; 13 | 14 | public class HomeScreenPanel extends AbstractFunctionPanel { 15 | 16 | public HomeScreenPanel() { 17 | setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5)); 18 | 19 | JPanel panel_4 = new JPanel(); 20 | add(panel_4); 21 | panel_4.setLayout(new FormLayout(new ColumnSpec[]{ 22 | FormFactory.RELATED_GAP_COLSPEC, 23 | FormFactory.DEFAULT_COLSPEC, 24 | FormFactory.RELATED_GAP_COLSPEC, 25 | FormFactory.DEFAULT_COLSPEC, 26 | FormFactory.RELATED_GAP_COLSPEC, 27 | FormFactory.DEFAULT_COLSPEC, 28 | FormFactory.RELATED_GAP_COLSPEC, 29 | ColumnSpec.decode("max(59dlu;default)"), 30 | FormFactory.RELATED_GAP_COLSPEC, 31 | ColumnSpec.decode("default:grow"), 32 | FormFactory.RELATED_GAP_COLSPEC, 33 | FormFactory.DEFAULT_COLSPEC, 34 | FormFactory.RELATED_GAP_COLSPEC, 35 | ColumnSpec.decode("default:grow"),}, 36 | new RowSpec[]{ 37 | FormFactory.RELATED_GAP_ROWSPEC, 38 | RowSpec.decode("max(65dlu;default):grow"), 39 | FormFactory.RELATED_GAP_ROWSPEC, 40 | RowSpec.decode("max(16dlu;default)"), 41 | FormFactory.RELATED_GAP_ROWSPEC, 42 | FormFactory.DEFAULT_ROWSPEC, 43 | FormFactory.RELATED_GAP_ROWSPEC, 44 | RowSpec.decode("max(17dlu;default)"), 45 | FormFactory.RELATED_GAP_ROWSPEC, 46 | RowSpec.decode("max(11dlu;default)"), 47 | FormFactory.RELATED_GAP_ROWSPEC, 48 | RowSpec.decode("max(15dlu;default)"), 49 | FormFactory.RELATED_GAP_ROWSPEC, 50 | RowSpec.decode("max(8dlu;default)"), 51 | FormFactory.RELATED_GAP_ROWSPEC, 52 | FormFactory.DEFAULT_ROWSPEC,})); 53 | 54 | JLabel lblNewLabel = new JLabel(""); 55 | lblNewLabel.setIcon(ResourceManager.getImageIcon("logo2.png")); 56 | panel_4.add(lblNewLabel, "8, 8, 1, 5"); 57 | 58 | JLabel lblCompany = new JLabel(ResourceManager.getString(StrConstants.COMPANY_NAME)); 59 | lblCompany.setFont(new Font("Tahoma", Font.BOLD, 16)); 60 | panel_4.add(lblCompany, "10, 8, default, top"); 61 | 62 | JLabel lblComm = new JLabel(ResourceManager.getString(StrConstants.DEPARTMENT)); 63 | lblComm.setFont(new Font("Tahoma", Font.BOLD, 13)); 64 | panel_4.add(lblComm, "10, 10"); 65 | 66 | JLabel lblInventory = new JLabel(ResourceManager.getString(StrConstants.APP_TITLE)); 67 | lblInventory.setFont(new Font("Tahoma", Font.BOLD, 14)); 68 | panel_4.add(lblInventory, "10, 12"); 69 | 70 | JLabel lblWelcome = new JLabel("Welcome, Please use toolbar and menus to proceed. \nIf you are running the app for the first time, make sure to enter initial data from Entry -> Initial Records menu "); 71 | lblWelcome.setFont(new Font("Tahoma", Font.PLAIN, 13)); 72 | panel_4.setFont(new Font("Tahoma", Font.BOLD, 12)); 73 | panel_4.add(lblWelcome, "10, 16, left, default"); 74 | 75 | init(); 76 | } 77 | 78 | @Override 79 | public final void init() { 80 | super.init(); 81 | 82 | isReadyToClose = true; 83 | } 84 | 85 | @Override 86 | public final String getFunctionName() { 87 | // TODO Auto-generated method stub 88 | return "Welcome . . ."; 89 | } 90 | 91 | @Override 92 | public void handleSaveAction() { 93 | 94 | 95 | } 96 | 97 | @Override 98 | public void enableDisableComponents() { 99 | // TODO Auto-generated method stub 100 | 101 | } 102 | 103 | } 104 | -------------------------------------------------------------------------------- /src/main/java/com/ca/ui/panels/ItemReceiverPanel.java: -------------------------------------------------------------------------------- 1 | package com.ca.ui.panels; 2 | 3 | import com.ca.db.model.BranchOffice; 4 | import com.ca.db.service.DBUtils; 5 | import com.gt.uilib.components.input.DataComboBox; 6 | import com.jgoodies.forms.factories.FormFactory; 7 | import com.jgoodies.forms.layout.ColumnSpec; 8 | import com.jgoodies.forms.layout.FormLayout; 9 | import com.jgoodies.forms.layout.RowSpec; 10 | import org.apache.commons.lang3.SystemUtils; 11 | 12 | import javax.swing.*; 13 | import java.util.List; 14 | 15 | public class ItemReceiverPanel extends JPanel { 16 | 17 | private final DataComboBox dataCombo; 18 | private ReceiverType currentType = ReceiverType.OFFICIAL; //one and only type 19 | 20 | public ItemReceiverPanel() { 21 | setLayout(new FormLayout(new ColumnSpec[]{ColumnSpec.decode("max(38dlu;default)"), FormFactory.RELATED_GAP_COLSPEC, 22 | FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("max(55dlu;default)"),}, new RowSpec[]{ 23 | FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,})); 24 | 25 | dataCombo = new DataComboBox(); 26 | add(dataCombo, "1, 4, 5, 1, fill, default"); 27 | handleSelection(); 28 | } 29 | 30 | public static void main(String[] args) throws Exception { 31 | if (SystemUtils.IS_OS_WINDOWS) { 32 | UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); 33 | } 34 | JFrame jf = new JFrame(); 35 | jf.getContentPane().add(new ItemReceiverPanel()); 36 | jf.pack(); 37 | jf.setVisible(true); 38 | jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); 39 | } 40 | 41 | public final ReceiverType getCurrentType() { 42 | return currentType; 43 | } 44 | 45 | public final void clearAll() { 46 | dataCombo.removeAllItems(); 47 | currentType = ReceiverType.OFFICIAL; 48 | } 49 | 50 | public final boolean isSelected() { 51 | return getSelectedId() > 0; 52 | } 53 | 54 | public final Integer getSelectedId() { 55 | if (currentType == ReceiverType.OFFICIAL) { 56 | return dataCombo.getSelectedId(); 57 | } 58 | return -1; 59 | } 60 | 61 | private void handleSelection() { 62 | SwingUtilities.invokeLater(() -> { 63 | switch (currentType) { 64 | case OFFICIAL: 65 | dataCombo.init(); 66 | dataCombo.setEnabled(true); 67 | try { 68 | List cl = DBUtils.readAll(BranchOffice.class); 69 | for (BranchOffice c : cl) { 70 | dataCombo.addRow(new Object[]{c.getId(), c.getName(), c.getAddress()}); 71 | } 72 | } catch (Exception e) { 73 | e.printStackTrace(); 74 | } 75 | break; 76 | 77 | default: 78 | dataCombo.init(); 79 | dataCombo.setEnabled(false); 80 | break; 81 | } 82 | 83 | }); 84 | 85 | } 86 | 87 | public enum ReceiverType { 88 | OFFICIAL 89 | } 90 | 91 | } 92 | -------------------------------------------------------------------------------- /src/main/java/com/ca/ui/panels/LoginPanel.java: -------------------------------------------------------------------------------- 1 | package com.ca.ui.panels; 2 | 3 | import com.ca.db.model.LoginUser; 4 | import com.ca.db.service.LoginUserServiceImpl; 5 | import com.gt.common.ResourceManager; 6 | import com.gt.common.constants.StrConstants; 7 | import com.gt.common.utils.UIUtils; 8 | import com.gt.uilib.components.AbstractFunctionPanel; 9 | import com.gt.uilib.components.AppFrame; 10 | import com.jgoodies.forms.factories.FormFactory; 11 | import com.jgoodies.forms.layout.ColumnSpec; 12 | import com.jgoodies.forms.layout.FormLayout; 13 | import com.jgoodies.forms.layout.RowSpec; 14 | import org.apache.commons.lang3.SystemUtils; 15 | 16 | import javax.swing.*; 17 | import java.awt.*; 18 | 19 | public class LoginPanel extends AbstractFunctionPanel { 20 | private JPanel innerPanel; 21 | private JTextField userName; 22 | private JTextField passWord; 23 | 24 | public LoginPanel() { 25 | add(getLoginPanel()); 26 | init(); 27 | } 28 | 29 | public static void main(String[] args) throws Exception { 30 | if (SystemUtils.IS_OS_WINDOWS) { 31 | UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); 32 | } 33 | EventQueue.invokeLater(() -> { 34 | try { 35 | JFrame jf = new JFrame(); 36 | LoginPanel panel = new LoginPanel(); 37 | jf.setBounds(panel.getBounds()); 38 | jf.getContentPane().add(panel); 39 | jf.setVisible(true); 40 | jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); 41 | } catch (Exception e) { 42 | e.printStackTrace(); 43 | } 44 | }); 45 | } 46 | 47 | private JPanel getLoginPanel() { 48 | JPanel fullPanel = new JPanel(); 49 | fullPanel.setAlignmentX(Component.CENTER_ALIGNMENT); 50 | innerPanel = new JPanel(); 51 | innerPanel.setBounds(41, 96, 336, 144); 52 | fullPanel.add(innerPanel); 53 | innerPanel.setLayout(new FormLayout(new ColumnSpec[]{FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("max(18dlu;default)"), 54 | FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, 55 | ColumnSpec.decode("max(21dlu;default)"), FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("max(61dlu;default):grow"), 56 | FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("max(65dlu;default)"), FormFactory.RELATED_GAP_COLSPEC, 57 | ColumnSpec.decode("max(65dlu;default)"),}, new RowSpec[]{FormFactory.RELATED_GAP_ROWSPEC, 58 | RowSpec.decode("max(57dlu;default):grow"), FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, 59 | FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("max(20dlu;default)"), 60 | FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, 61 | FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("max(16dlu;default)"), 62 | FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("max(16dlu;default)"), FormFactory.RELATED_GAP_ROWSPEC, 63 | RowSpec.decode("max(14dlu;default)"), FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, 64 | FormFactory.DEFAULT_ROWSPEC,})); 65 | 66 | JLabel lblImg = new JLabel("img"); 67 | lblImg.setIcon(ResourceManager.getImageIcon("logo2.png")); 68 | innerPanel.add(lblImg, "2, 8, 3, 5"); 69 | 70 | JLabel lblTitile = new JLabel(ResourceManager.getString(StrConstants.COMPANY_NAME)); 71 | lblTitile.setFont(new Font("Tahoma", Font.BOLD, 16)); 72 | innerPanel.add(lblTitile, "6, 8, 7, 1, left, default"); 73 | 74 | JLabel lblDept = new JLabel(ResourceManager.getString(StrConstants.DEPARTMENT)); 75 | lblDept.setFont(new Font("Tahoma", Font.BOLD, 13)); 76 | innerPanel.add(lblDept, "6, 10, 7, 1, left, default"); 77 | 78 | JLabel lblInventoryManagementSystem = new JLabel(ResourceManager.getString(StrConstants.APP_TITLE)); 79 | lblInventoryManagementSystem.setFont(new Font("Tahoma", Font.BOLD, 13)); 80 | innerPanel.add(lblInventoryManagementSystem, "6, 12, 7, 1, left, default"); 81 | 82 | JLabel lblNewLabel = new JLabel("UserName :"); 83 | innerPanel.add(lblNewLabel, "4, 16, left, default"); 84 | 85 | userName = new JTextField(); 86 | innerPanel.add(userName, "8, 16, 3, 1, fill, fill"); 87 | userName.addActionListener(e -> doLogin()); 88 | 89 | JLabel lblPassword = new JLabel("Password :"); 90 | innerPanel.add(lblPassword, "4, 18, left, default"); 91 | 92 | passWord = new JPasswordField(); 93 | passWord.addActionListener(e -> doLogin()); 94 | 95 | innerPanel.add(passWord, "8, 18, 3, 1, fill, fill"); 96 | 97 | JButton loginButton = new JButton("Login"); 98 | innerPanel.add(loginButton, "8, 20, fill, default"); 99 | loginButton.addActionListener(e -> doLogin()); 100 | JButton restPassword = new JButton("Reset"); 101 | restPassword.addActionListener(e -> clearAll()); 102 | innerPanel.add(restPassword, "10, 20"); 103 | return fullPanel; 104 | } 105 | 106 | private void clearAll() { 107 | UIUtils.clearAllFields(innerPanel); 108 | 109 | } 110 | 111 | private void doLogin() { 112 | LoginUserServiceImpl lus; 113 | try { 114 | lus = new LoginUserServiceImpl(); 115 | LoginUser user = LoginUserServiceImpl.getLoginUser(userName.getText().trim(), passWord.getText().trim()); 116 | if (user != null) { 117 | AppFrame.loginSuccess(); 118 | } else { 119 | JOptionPane.showMessageDialog(null, "Username password error"); 120 | passWord.setText(""); 121 | userName.requestFocus(); 122 | } 123 | 124 | } catch (Exception e1) { 125 | e1.printStackTrace(); 126 | JOptionPane.showMessageDialog(null, "DB Connection Error"); 127 | } 128 | 129 | } 130 | 131 | @Override 132 | public final String getFunctionName() { 133 | return "Login"; 134 | } 135 | 136 | @Override 137 | public void handleSaveAction() { 138 | 139 | } 140 | 141 | @Override 142 | public final void init() { 143 | super.init(); 144 | userName.requestFocus(); 145 | isReadyToClose = true; 146 | } 147 | 148 | @Override 149 | public void enableDisableComponents() { 150 | 151 | } 152 | 153 | } -------------------------------------------------------------------------------- /src/main/java/com/ca/ui/panels/SpecificationPanel.java: -------------------------------------------------------------------------------- 1 | package com.ca.ui.panels; 2 | 3 | import com.ca.db.model.Category; 4 | import com.ca.db.model.Specification; 5 | import com.ca.db.service.DBUtils; 6 | import com.gt.common.utils.StringUtils; 7 | import com.gt.common.utils.UIUtils; 8 | 9 | import javax.swing.*; 10 | import java.awt.*; 11 | import java.util.LinkedList; 12 | import java.util.List; 13 | 14 | public class SpecificationPanel extends JPanel { 15 | 16 | private static final long serialVersionUID = 1859550688843095275L; 17 | private Category category; 18 | private List pairList; 19 | private boolean skipNext = false; 20 | 21 | /** 22 | * @param id category id of which we want to display Specification entry 23 | * panel 24 | */ 25 | public SpecificationPanel(int id) { 26 | readList(id); 27 | setLayout(new FlowLayout()); 28 | addCategoryPanels(); 29 | setBorder(BorderFactory.createTitledBorder("Specification : " + category.getCategoryName())); 30 | } 31 | 32 | public static void main(String[] args) { 33 | JFrame jf = new JFrame(); 34 | jf.getContentPane().add(new SpecificationPanel(1)); 35 | jf.pack(); 36 | jf.setVisible(true); 37 | jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); 38 | } 39 | 40 | public static boolean isValidDataEntered() { 41 | return true; 42 | } 43 | 44 | private boolean toSkip(String spec) { 45 | 46 | if (!StringUtils.isEmpty(spec) && !skipNext) { 47 | skipNext = false; 48 | } else { 49 | skipNext = true; 50 | } 51 | System.out.println(skipNext + " skipnext.."); 52 | return !skipNext; 53 | } 54 | 55 | public final void disableAll() { 56 | for (CategoryEntryPair pair : pairList) { 57 | pair.tb.setEnabled(false); 58 | pair.tb.setEditable(false); 59 | Color disabledColor = (Color) UIManager.get("TextField.inactiveBackground"); 60 | pair.tb.setBackground(disabledColor); 61 | } 62 | } 63 | 64 | public final void resetAll() { 65 | for (CategoryEntryPair pair : pairList) { 66 | 67 | pair.tb.setText(""); 68 | } 69 | } 70 | 71 | public final void enableAll() { 72 | UIUtils.toggleAllChildren(this, true); 73 | } 74 | 75 | private void addCategoryPanels() { 76 | pairList = new LinkedList<>(); 77 | synchronized (pairList) { 78 | if (toSkip(category.getSpecification1())) 79 | pairList.add(new CategoryEntryPair(category.getSpecification1())); 80 | if (toSkip(category.getSpecification2())) 81 | pairList.add(new CategoryEntryPair(category.getSpecification2())); 82 | if (toSkip(category.getSpecification3())) 83 | pairList.add(new CategoryEntryPair(category.getSpecification3())); 84 | if (toSkip(category.getSpecification4())) 85 | pairList.add(new CategoryEntryPair(category.getSpecification4())); 86 | if (toSkip(category.getSpecification5())) 87 | pairList.add(new CategoryEntryPair(category.getSpecification5())); 88 | if (toSkip(category.getSpecification6())) 89 | pairList.add(new CategoryEntryPair(category.getSpecification6())); 90 | if (toSkip(category.getSpecification7())) 91 | pairList.add(new CategoryEntryPair(category.getSpecification7())); 92 | if (toSkip(category.getSpecification8())) 93 | pairList.add(new CategoryEntryPair(category.getSpecification8())); 94 | if (toSkip(category.getSpecification9())) 95 | pairList.add(new CategoryEntryPair(category.getSpecification9())); 96 | if (toSkip(category.getSpecification10())) 97 | pairList.add(new CategoryEntryPair(category.getSpecification10())); 98 | 99 | for (CategoryEntryPair pair : pairList) { 100 | add(pair); 101 | } 102 | if (pairList.size() == 0) { 103 | System.out.println("SpecificationPanel.addCategoryPanels() >>>>> spec size 0"); 104 | this.setVisible(false); 105 | this.removeAll(); 106 | add(new JLabel("No Specification was set for " + category.getCategoryName())); 107 | this.setVisible(true); 108 | } else { 109 | this.setVisible(true); 110 | setBorder(BorderFactory.createTitledBorder("Specification : " + category.getCategoryName())); 111 | } 112 | } 113 | } 114 | 115 | /** 116 | * @return list of specifications (String) entered on displayed textfields 117 | */ 118 | public final List getSpecificationsStringList() { 119 | List sps = new LinkedList<>(); 120 | for (CategoryEntryPair pair : pairList) { 121 | System.out.println(">>>> " + pair.jl.getText()); 122 | System.out.println("SpecificationPanel.getSpecificationsStringList() >>> " + pair.tb.getText()); 123 | sps.add(pair.tb.getText().trim()); 124 | } 125 | return sps; 126 | } 127 | 128 | public final Specification getSpecificationsObject() { 129 | Specification sps = new Specification(); 130 | try { 131 | sps.setSpecification1(pairList.get(0).tb.getText().trim()); 132 | sps.setSpecification2(pairList.get(1).tb.getText().trim()); 133 | sps.setSpecification3(pairList.get(2).tb.getText().trim()); 134 | sps.setSpecification4(pairList.get(3).tb.getText().trim()); 135 | sps.setSpecification5(pairList.get(4).tb.getText().trim()); 136 | sps.setSpecification6(pairList.get(5).tb.getText().trim()); 137 | sps.setSpecification7(pairList.get(6).tb.getText().trim()); 138 | sps.setSpecification8(pairList.get(7).tb.getText().trim()); 139 | sps.setSpecification9(pairList.get(8).tb.getText().trim()); 140 | sps.setSpecification10(pairList.get(9).tb.getText().trim()); 141 | } catch (Exception e) { 142 | // no problem 143 | } 144 | return sps; 145 | } 146 | 147 | public final void populateValues(Specification spec) { 148 | try { 149 | pairList.get(0).tb.setText(spec.getSpecification1()); 150 | pairList.get(1).tb.setText(spec.getSpecification2()); 151 | pairList.get(2).tb.setText(spec.getSpecification3()); 152 | pairList.get(3).tb.setText(spec.getSpecification4()); 153 | pairList.get(4).tb.setText(spec.getSpecification5()); 154 | pairList.get(5).tb.setText(spec.getSpecification6()); 155 | pairList.get(6).tb.setText(spec.getSpecification7()); 156 | pairList.get(7).tb.setText(spec.getSpecification8()); 157 | pairList.get(8).tb.setText(spec.getSpecification9()); 158 | pairList.get(9).tb.setText(spec.getSpecification10()); 159 | 160 | } catch (Exception ignored) { 161 | // no problem 162 | } 163 | 164 | } 165 | 166 | private void readList(int id) { 167 | try { 168 | category = (Category) DBUtils.getById(Category.class, id); 169 | } catch (Exception e) { 170 | throw new RuntimeException(e); 171 | } 172 | } 173 | 174 | static class CategoryEntryPair extends JPanel { 175 | private static final long serialVersionUID = -623894842418823841L; 176 | final JLabel jl; 177 | final JTextField tb; 178 | 179 | CategoryEntryPair(String name) { 180 | jl = new JLabel(name); 181 | tb = new JTextField(8); 182 | setLayout(new FlowLayout()); 183 | add(jl); 184 | add(tb); 185 | } 186 | 187 | public final String getValue() { 188 | return tb.getText().trim(); 189 | } 190 | 191 | public final boolean isEmpty() { 192 | return (tb.getText().trim().equals("")); 193 | } 194 | } 195 | } 196 | -------------------------------------------------------------------------------- /src/main/java/com/gt/common/AppStarter.java: -------------------------------------------------------------------------------- 1 | package com.gt.common; 2 | 3 | import com.ca.ui.Main; 4 | import org.apache.log4j.Logger; 5 | 6 | import java.net.ServerSocket; 7 | import java.net.Socket; 8 | 9 | /** 10 | * Used in code
11 | * com.gt.common-AppStarter.java
12 | * 13 | * @author Ganesh Tiwari @@ gtiwari333@gmail.com
14 | * Created on : Mar 19, 2012
15 | * Copyright : Ganesh Tiwari 17 | */ 18 | public class AppStarter { 19 | private final int PORT = 45433; 20 | public boolean alreadyRunning = true; 21 | Logger logger = Logger.getLogger(AppStarter.class); 22 | 23 | public AppStarter() { 24 | 25 | if (alreadyRunning()) { 26 | // if not found existing ... will be killed 27 | // start detecting server thread 28 | new Thread(new DetectForNew()).start(); 29 | } 30 | 31 | } 32 | 33 | private synchronized boolean alreadyRunning() { 34 | // try to connect to server 35 | ; 36 | try { 37 | String HOST = "localhost"; 38 | try(Socket client = new Socket(HOST, PORT)) { 39 | logger.info("Connection accepted by already running app"); 40 | alreadyRunning = false; 41 | } 42 | } catch (Exception e) { 43 | alreadyRunning = true; 44 | 45 | } 46 | return alreadyRunning; 47 | } 48 | 49 | class DetectForNew implements Runnable { 50 | ServerSocket serverSocket; 51 | 52 | public final void run() { 53 | try { 54 | serverSocket = new ServerSocket(PORT); 55 | while (true) { 56 | serverSocket.accept(); 57 | Main.showMaximized(); 58 | } 59 | } catch (Exception e) { 60 | e.printStackTrace(); 61 | System.out.println("detect thread terminated " + e.getMessage()); 62 | 63 | } 64 | } 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/com/gt/common/ResourceManager.java: -------------------------------------------------------------------------------- 1 | package com.gt.common; 2 | 3 | import com.gt.common.constants.StrConstants; 4 | import com.gt.common.utils.CryptographicUtil; 5 | 6 | import javax.imageio.ImageIO; 7 | import javax.swing.*; 8 | import java.awt.*; 9 | import java.awt.image.BufferedImage; 10 | import java.io.*; 11 | import java.net.URL; 12 | import java.util.HashMap; 13 | import java.util.Map; 14 | 15 | /** 16 | * com.gt.common-ResourceManager.java
17 | * 18 | * @author Ganesh Tiwari @@ gtiwari333@gmail.com
19 | * Created on : Mar 19, 2012
20 | * Copyright : Ganesh Tiwari 22 | */ 23 | public class ResourceManager { 24 | 25 | public static final String resourceMapFile = "string-resource.ini"; 26 | private static final String a = "gt?Pass,e#. "; 27 | private static Map stringConstantsMap; 28 | 29 | public static synchronized String getString(String key) { 30 | if (stringConstantsMap == null) { 31 | try { 32 | stringConstantsMap = readMap(resourceMapFile, false); 33 | } catch (Exception e) { 34 | stringConstantsMap = StrConstants.getMap(); 35 | } 36 | } 37 | return stringConstantsMap.get(key); 38 | } 39 | 40 | public static Map readMap(String file, boolean isEncry) throws IOException { 41 | BufferedReader in = new BufferedReader(new FileReader(file)); 42 | Map map = new HashMap<>(); 43 | String str; 44 | while ((str = in.readLine()) != null) { 45 | String[] spl = str.split(":"); 46 | if (isEncry) { 47 | map.put(CryptographicUtil.decryptText(spl[0].trim(), a), CryptographicUtil.decryptText(spl[1].trim(), a)); 48 | } else { 49 | map.put(spl[0].trim(), spl[1].trim()); 50 | } 51 | } 52 | in.close(); 53 | return map; 54 | } 55 | 56 | public static Image getImage(String fileName) { 57 | // src/image/ 58 | return readImage(ResourceManager.class.getResource("/images/" + fileName).toString()); 59 | } 60 | 61 | public static ImageIcon getImageIcon(String resourcePath) { 62 | return new ImageIcon(ResourceManager.class.getResource("/images/" + resourcePath)); 63 | } 64 | 65 | public static BufferedImage readImage(String imageName) { 66 | try { 67 | File input = new File(imageName); 68 | BufferedImage image = ImageIO.read(input); 69 | return image; 70 | } catch (IOException ie) { 71 | System.out.println("Error:" + ie.getMessage()); 72 | } 73 | return null; 74 | } 75 | 76 | public static void main(String[] args) { 77 | ImageIcon ic = new ImageIcon(ResourceManager.class.getResource("/images/logout-on.png")); 78 | ImageIcon ic2 = getImageIcon("logout-on.png"); 79 | System.out.println(ic.getIconHeight()); 80 | System.out.println(ic2.getIconHeight()); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/com/gt/common/constants/CommonConsts.java: -------------------------------------------------------------------------------- 1 | package com.gt.common.constants; 2 | 3 | import java.awt.*; 4 | 5 | 6 | public class CommonConsts { 7 | public static final Color COLOR_TOOLBAR_BORDER = Color.BLACK; 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/com/gt/common/constants/Status.java: -------------------------------------------------------------------------------- 1 | package com.gt.common.constants; 2 | 3 | /** 4 | * DB Status 5 | * 6 | * @author GT 7 | */ 8 | public enum Status { 9 | NONE, READ, CREATE, MODIFY, DELETE, MODIFY_CATEGORY_NAME; 10 | 11 | @Override 12 | public String toString() { 13 | return super.toString(); 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/gt/common/constants/StrConstants.java: -------------------------------------------------------------------------------- 1 | package com.gt.common.constants; 2 | 3 | import java.lang.reflect.Field; 4 | import java.lang.reflect.Modifier; 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | 8 | public class StrConstants { 9 | public static final String APP_TITLE = "GT - Inventory Mgmt System"; 10 | public static final String COMPANY_NAME = "A Company"; 11 | public static final String DEPARTMENT = "Department"; 12 | 13 | /** 14 | * @return map of all declared `static final` fields, to be used by @{@link com.gt.common.ResourceManager} 15 | */ 16 | public static Map getMap() { 17 | Map mp = new HashMap<>(); 18 | 19 | Class c = StrConstants.class; 20 | for (Field f : c.getDeclaredFields()) { 21 | int mod = f.getModifiers(); 22 | 23 | if (Modifier.isStatic(mod) && Modifier.isPublic(mod) && Modifier.isFinal(mod)) { 24 | try { 25 | mp.put(f.getName(), f.get(null).toString()); 26 | } catch (IllegalAccessException e) { 27 | //shouldn't throw 28 | e.printStackTrace(); 29 | } 30 | } 31 | } 32 | 33 | return mp; 34 | } 35 | 36 | public static void main(String[] args) { 37 | System.out.println(new StrConstants().getMap().get("APP_TITLE")); 38 | 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/gt/common/utils/CryptographicUtil.java: -------------------------------------------------------------------------------- 1 | package com.gt.common.utils; 2 | 3 | 4 | import javax.crypto.*; 5 | import javax.crypto.spec.DESKeySpec; 6 | import java.nio.charset.StandardCharsets; 7 | import java.security.InvalidKeyException; 8 | import java.security.NoSuchAlgorithmException; 9 | import java.security.spec.InvalidKeySpecException; 10 | import java.security.spec.KeySpec; 11 | import java.util.Base64; 12 | 13 | 14 | public class CryptographicUtil { 15 | 16 | /** 17 | * The ecipher. 18 | */ 19 | private Cipher ecipher = null; 20 | 21 | /** 22 | * The dcipher. 23 | */ 24 | private Cipher dcipher = null; 25 | 26 | /** 27 | * The key. 28 | */ 29 | private String key; 30 | 31 | /** 32 | * Instantiates a new nI cryptographic util. 33 | * 34 | * @param key the key 35 | */ 36 | public CryptographicUtil(SecretKey key) { 37 | try { 38 | ecipher = Cipher.getInstance("DES"); 39 | dcipher = Cipher.getInstance("DES"); 40 | ecipher.init(Cipher.ENCRYPT_MODE, key); 41 | dcipher.init(Cipher.DECRYPT_MODE, key); 42 | } catch (NoSuchAlgorithmException | InvalidKeyException | NoSuchPaddingException e) { 43 | e.printStackTrace(); 44 | } 45 | 46 | } 47 | 48 | /** 49 | * Encrypt text. 50 | * 51 | * @param text the text 52 | * @param encryptionKey the encryption key 53 | * @return the string 54 | */ 55 | public static String encryptText(String text, String encryptionKey) { 56 | byte[] keyByte = encryptionKey.getBytes(); 57 | CryptographicUtil nicUtil; 58 | String encryptedText = null; 59 | try { 60 | 61 | KeySpec ks = new DESKeySpec(keyByte); 62 | SecretKeyFactory kf = SecretKeyFactory.getInstance("DES"); 63 | SecretKey ky = kf.generateSecret(ks); 64 | nicUtil = new CryptographicUtil(ky); 65 | encryptedText = nicUtil.encrypt(text); 66 | } catch (InvalidKeyException | InvalidKeySpecException | NoSuchAlgorithmException e) { 67 | e.printStackTrace(); 68 | } 69 | return encryptedText; 70 | } 71 | 72 | /** 73 | * Decrypt text. 74 | * 75 | * @param text the text 76 | * @param decryptionKey the decryption key 77 | * @return the string 78 | */ 79 | public static String decryptText(String text, String decryptionKey) { 80 | byte[] keyByte = decryptionKey.getBytes(); 81 | CryptographicUtil nicUtil; 82 | String decryptedText = null; 83 | try { 84 | 85 | KeySpec ks = new DESKeySpec(keyByte); 86 | SecretKeyFactory kf = SecretKeyFactory.getInstance("DES"); 87 | SecretKey ky = kf.generateSecret(ks); 88 | nicUtil = new CryptographicUtil(ky); 89 | decryptedText = nicUtil.decrypt(text); 90 | } catch (InvalidKeyException | InvalidKeySpecException | NoSuchAlgorithmException e) { 91 | e.printStackTrace(); 92 | } 93 | return decryptedText; 94 | } 95 | 96 | /** 97 | * The main method. 98 | * 99 | * @param argv the arguments 100 | */ 101 | public static void main(String[] argv) { 102 | String encrypted = encryptText("scs1 -", "jb6bLQ41"); 103 | System.out.println("endrypted:" + encrypted); 104 | String decrypted = decryptText(encrypted, "jb6bLQ41"); 105 | System.out.println("decrypted:" + decrypted); 106 | } 107 | 108 | /** 109 | * Encrypt. 110 | * 111 | * @param str the str 112 | * @return the string 113 | */ 114 | public final String encrypt(String str) { 115 | 116 | byte[] utf8; 117 | 118 | byte[] enc; 119 | String encryptedText = null; 120 | try { 121 | // Encode the string into bytes using utf-8 122 | utf8 = str.getBytes(StandardCharsets.UTF_8); 123 | enc = ecipher.doFinal(utf8); 124 | encryptedText = new String(Base64.getEncoder().encode(enc)); 125 | } catch (BadPaddingException | IllegalBlockSizeException e) { 126 | e.printStackTrace(); 127 | } 128 | 129 | return encryptedText; 130 | } 131 | 132 | /** 133 | * Decrypt. 134 | * 135 | * @param str the str 136 | * @return the string 137 | */ 138 | public final String decrypt(String str) { 139 | 140 | byte[] dec; 141 | byte[] utf8; 142 | String decryptedText = null; 143 | try { 144 | // Decode base64 to get bytes 145 | dec = Base64.getDecoder().decode(str); 146 | utf8 = dcipher.doFinal(dec); 147 | // Decode using utf-8 148 | decryptedText = new String(utf8, StandardCharsets.UTF_8); 149 | } catch (BadPaddingException | IllegalBlockSizeException e) { 150 | e.printStackTrace(); 151 | } 152 | return decryptedText; 153 | } 154 | 155 | } 156 | -------------------------------------------------------------------------------- /src/main/java/com/gt/common/utils/DateTimeUtils.java: -------------------------------------------------------------------------------- 1 | package com.gt.common.utils; 2 | 3 | import java.text.DateFormat; 4 | import java.text.SimpleDateFormat; 5 | import java.util.Calendar; 6 | import java.util.Date; 7 | 8 | public class DateTimeUtils { 9 | 10 | public static boolean isEmpty(Date date) { 11 | return date == null; 12 | } 13 | 14 | public static String getTodayDate() { 15 | DateFormat datef = new SimpleDateFormat("yyyy-MM-dd"); 16 | Date date = Calendar.getInstance().getTime(); 17 | return datef.format(date); 18 | } 19 | 20 | public static String getCvDateMMMddyyyy(Date date) { 21 | if (date == null) return ""; 22 | DateFormat datef = new SimpleDateFormat("MMM dd, yyyy"); 23 | return datef.format(date); 24 | } 25 | 26 | // FIXME: DO it on the basis of Nepali calendar 27 | public static int getCurrentFiscalYear() { 28 | return getYearFromYYYYMMDD(getTodayDate()); 29 | } 30 | 31 | public static int getYearFromYYYYMMDD(String systemDStringRpgDateStr) { 32 | int year = Integer.parseInt(systemDStringRpgDateStr.substring(0, 4)); 33 | return year; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/gt/common/utils/ExcelUtils.java: -------------------------------------------------------------------------------- 1 | package com.gt.common.utils; 2 | 3 | import jxl.Workbook; 4 | import jxl.write.Label; 5 | import jxl.write.WritableSheet; 6 | import jxl.write.WritableWorkbook; 7 | 8 | import javax.swing.*; 9 | import javax.swing.table.TableModel; 10 | import java.io.File; 11 | 12 | public class ExcelUtils { 13 | 14 | public static void writeExcelFrom2DList(String[][] data, String[] header, String fileName, String sheetName, int sheetPos) throws Exception { 15 | 16 | WritableWorkbook wb = Workbook.createWorkbook(new File(fileName)); 17 | WritableSheet curSheet = wb.createSheet(sheetName, sheetPos); 18 | 19 | for (int i = 0; i < header.length; i++) { 20 | Label column = new Label(i, 0, header[i]); 21 | curSheet.addCell(column); 22 | } 23 | 24 | int j; 25 | for (int i = 0; i < data[0].length; i++) {//rows 26 | for (j = 0; j < data[i][0].length(); j++) {//column 27 | Label row = new Label(j, i + 1, data[i][j]); 28 | curSheet.addCell(row); 29 | } 30 | } 31 | 32 | wb.write(); 33 | wb.close(); 34 | 35 | } 36 | 37 | public static void writeExcelFromJTable(JTable table, String fileName, String sheetName, int sheetPos) throws Exception { 38 | 39 | WritableWorkbook wb = Workbook.createWorkbook(new File(fileName)); 40 | WritableSheet curSheet = wb.createSheet(sheetName, sheetPos); 41 | TableModel model = table.getModel(); 42 | 43 | for (int i = 0; i < model.getColumnCount(); i++) { 44 | Label column = new Label(i, 0, model.getColumnName(i)); 45 | curSheet.addCell(column); 46 | } 47 | 48 | int j; 49 | for (int i = 0; i < model.getRowCount(); i++) { 50 | for (j = 0; j < model.getColumnCount(); j++) { 51 | Object tmp = model.getValueAt(i, j); 52 | Label row; 53 | 54 | if (tmp == null) { 55 | row = new Label(j, i + 1, ""); 56 | } else { 57 | row = new Label(j, i + 1, model.getValueAt(i, j).toString()); 58 | } 59 | 60 | curSheet.addCell(row); 61 | } 62 | } 63 | 64 | wb.write(); 65 | wb.close(); 66 | 67 | } 68 | 69 | public static void writeExcelFromJTable(JTable table, String String, String sheetName) throws Exception { 70 | writeExcelFromJTable(table, String, sheetName, 0); 71 | } 72 | 73 | public static void writeExcelFromJTable(JTable table, String String) throws Exception { 74 | writeExcelFromJTable(table, String, "Sheet " + 1, 0); 75 | } 76 | 77 | public static void main(String[] args) throws Exception { 78 | String[] header = new String[]{"First", "sec", "third"}; 79 | String[][] arr = new String[][]{{"aa", "bb", "cc"}, {"aa1", "bb2", "cc1"}, {"aa2", "bb3", "cc4"}, {"aasdf", "bbdsf", "ccsdf"}}; 80 | 81 | writeExcelFrom2DList(arr, header, "dat.xls", "first", 2); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/main/java/com/gt/common/utils/PasswordUtil.java: -------------------------------------------------------------------------------- 1 | package com.gt.common.utils; 2 | 3 | import java.security.MessageDigest; 4 | import java.security.NoSuchAlgorithmException; 5 | 6 | public class PasswordUtil { 7 | 8 | public static String getSha256(String someText) { 9 | MessageDigest md; 10 | try { 11 | md = MessageDigest.getInstance("SHA-256"); 12 | 13 | md.update(someText.getBytes()); 14 | 15 | byte[] byteData = md.digest(); 16 | 17 | // convert the byte to hex format method 1 18 | StringBuilder sb = new StringBuilder(); 19 | for (byte aByteData : byteData) { 20 | sb.append(Integer.toString((aByteData & 0xff) + 0x100, 16).substring(1)); 21 | } 22 | 23 | return sb.toString(); 24 | } catch (NoSuchAlgorithmException e) { 25 | throw new RuntimeException(e); 26 | } 27 | } 28 | 29 | public static void main(String[] args) { 30 | System.out.println(PasswordUtil.getSha256("gt")); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/gt/common/utils/RegexUtils.java: -------------------------------------------------------------------------------- 1 | package com.gt.common.utils; 2 | 3 | import java.util.regex.Matcher; 4 | import java.util.regex.Pattern; 5 | 6 | public class RegexUtils { 7 | public static boolean matches(String input, String regex) { 8 | 9 | if (StringUtils.isEmpty(input)) { 10 | return false; 11 | } 12 | 13 | if (StringUtils.isEmpty(regex)) { 14 | return true; 15 | } 16 | 17 | Pattern pattern = Pattern.compile(regex); 18 | Matcher matcher = pattern.matcher(input); 19 | 20 | if (matcher.matches()) { 21 | return true; 22 | } 23 | return false; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/gt/common/utils/StringUtils.java: -------------------------------------------------------------------------------- 1 | package com.gt.common.utils; 2 | 3 | public final class StringUtils { 4 | 5 | private StringUtils() { 6 | } 7 | 8 | public static String toString(Object object) { 9 | return object == null ? "" : object.toString(); 10 | } 11 | 12 | public static String clean(String str) { 13 | return (str == null ? "" : str.trim()); 14 | } 15 | 16 | public static String trim(String str) { 17 | return (str == null ? null : str.trim()); 18 | } 19 | 20 | 21 | public static boolean isEmpty(String str) { 22 | if (str == null) { 23 | return true; 24 | } 25 | if (str.trim().length() < 1) { 26 | return true; 27 | } 28 | return false; 29 | } 30 | 31 | 32 | public static String replace(String text, String repl, String with) { 33 | return replace(text, repl, with, -1); 34 | } 35 | 36 | public static String replace(String text, String repl, String with, int max) { 37 | if (text == null) { 38 | return null; 39 | } 40 | 41 | StringBuilder buf = new StringBuilder(text.length()); 42 | int start = 0, end; 43 | while ((end = text.indexOf(repl, start)) != -1) { 44 | buf.append(text, start, end).append(with); 45 | start = end + repl.length(); 46 | 47 | if (--max == 0) { 48 | break; 49 | } 50 | } 51 | buf.append(text.substring(start)); 52 | return buf.toString(); 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/com/gt/common/utils/UIUtils.java: -------------------------------------------------------------------------------- 1 | package com.gt.common.utils; 2 | 3 | import com.gt.uilib.components.input.DataComboBox; 4 | import com.toedter.calendar.JDateChooser; 5 | 6 | import javax.swing.*; 7 | import javax.swing.text.JTextComponent; 8 | import java.awt.*; 9 | import java.util.Arrays; 10 | import java.util.List; 11 | 12 | public class UIUtils { 13 | private static final Color COMPONENT_BORDER_COLOR = Color.GRAY; 14 | 15 | public static boolean isEmpty(JTextComponent jt) { 16 | String str = jt.getText(); 17 | if (StringUtils.isEmpty(str)) { 18 | return true; 19 | } 20 | 21 | return false; 22 | } 23 | 24 | public static void clearAllFields(Component parent, Component... ignoreList) { 25 | List list = null; 26 | 27 | if (ignoreList != null) { 28 | list = Arrays.asList(ignoreList); 29 | } 30 | 31 | if (parent instanceof JTextField) { 32 | ((JTextField) parent).setText(""); 33 | } else if (parent instanceof JTextArea) { 34 | ((JTextArea) parent).setText(""); 35 | } else if (parent instanceof JCheckBox) { 36 | ((JCheckBox) parent).setSelected(false); 37 | } else if (parent instanceof JComponent) { 38 | Component[] children = ((JComponent) parent).getComponents(); 39 | for (Component aChildren : children) { 40 | if (list != null && list.contains(aChildren)) { 41 | continue; 42 | } 43 | clearAllFields(aChildren); 44 | } 45 | } 46 | } 47 | 48 | public static void clearAllFields(Component parent) { 49 | if (parent instanceof JTextField) { 50 | ((JTextField) parent).setText(""); 51 | } 52 | if (parent instanceof JTextArea) { 53 | if (((JTextArea) parent).isEditable()) { 54 | ((JTextArea) parent).setText(""); 55 | } 56 | } else if (parent instanceof JPasswordField) { 57 | if (((JPasswordField) parent).isEditable()) { 58 | ((JPasswordField) parent).setText(""); 59 | } 60 | } else if (parent instanceof DataComboBox) { 61 | ((DataComboBox) parent).selectDefaultItem(); 62 | } else if (parent instanceof JComponent) { 63 | Component[] children = ((JComponent) parent).getComponents(); 64 | for (Component aChildren : children) { 65 | clearAllFields(aChildren); 66 | } 67 | } 68 | } 69 | 70 | public static void toggleAllChildren(Component parent, boolean enabled, Component... ignoreList) { 71 | List igList = Arrays.asList(ignoreList); 72 | 73 | if (parent == null) { 74 | return; 75 | } 76 | Color disabledColor = (Color) UIManager.get("TextField.inactiveBackground"); 77 | Color enabledColor = (Color) UIManager.get("TextField.background"); 78 | if (!igList.contains(parent)) { 79 | parent.setEnabled(enabled); 80 | if (parent instanceof JTextComponent || parent instanceof JDateChooser || parent instanceof JComboBox) { 81 | if (!enabled) parent.setBackground(disabledColor); 82 | if (enabled) parent.setBackground(enabledColor); 83 | } 84 | } 85 | 86 | if (parent instanceof JComponent) { 87 | Component[] children = ((JComponent) parent).getComponents(); 88 | for (Component aChildren : children) { 89 | if (aChildren instanceof JLabel) { 90 | continue; 91 | } 92 | if (!igList.contains(aChildren)) { 93 | toggleAllChildren(aChildren, enabled); 94 | } 95 | } 96 | } 97 | } 98 | 99 | public static void decorateBorders(JComponent p) { 100 | for (Component c : p.getComponents()) { 101 | if (c instanceof JToolBar) { 102 | continue; 103 | } else if (c instanceof JComboBox) { 104 | ((JComboBox) c).setBorder(BorderFactory.createLineBorder(COMPONENT_BORDER_COLOR, 1)); 105 | } else if (c instanceof JComponent) { 106 | JComponent jc = (JComponent) c; 107 | 108 | if (jc.getComponentCount() > 0) { 109 | decorateBorders(jc); 110 | } 111 | if (jc instanceof JTextField) { 112 | jc.setBorder(BorderFactory.createLineBorder(COMPONENT_BORDER_COLOR, 1)); 113 | } 114 | if (jc instanceof JTextArea) { 115 | jc.setBorder(BorderFactory.createLineBorder(COMPONENT_BORDER_COLOR, 1)); 116 | } 117 | 118 | jc.updateUI(); 119 | } 120 | } 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /src/main/java/com/gt/db/BaseDAO.java: -------------------------------------------------------------------------------- 1 | package com.gt.db; 2 | 3 | import org.hibernate.Query; 4 | import org.hibernate.Session; 5 | import org.hibernate.Transaction; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * abstract so no instantiation Abstracts out CRUD 11 | * 12 | * @author GT 13 | */ 14 | public abstract class BaseDAO extends SessionUtils { 15 | private Session session; 16 | private Transaction tx; 17 | 18 | public BaseDAO() { 19 | get(); 20 | } 21 | 22 | public final int runQuery(String query) throws Exception { 23 | Query q = session.createQuery(query); 24 | return runQuery(q); 25 | } 26 | 27 | public final int runQuery(Query q) throws Exception { 28 | int ret = -1; 29 | try { 30 | startOperation(); 31 | ret = q.executeUpdate(); 32 | tx.commit(); 33 | } catch (Exception e) { 34 | handleException(e); 35 | throw new Exception(e); 36 | } finally { 37 | close(session); 38 | } 39 | return ret; 40 | } 41 | 42 | public final List runReadQuery(Query q) throws Exception { 43 | List list; 44 | try { 45 | startOperation(); 46 | list = q.list(); 47 | } catch (Exception e) { 48 | handleException(e); 49 | throw new Exception(e); 50 | } finally { 51 | close(session); 52 | } 53 | return list; 54 | } 55 | 56 | public void saveOrUpdate(Object obj) throws Exception { 57 | try { 58 | startOperation(); 59 | session.saveOrUpdate(obj); 60 | tx.commit(); 61 | } catch (Exception e) { 62 | handleException(e); 63 | throw new Exception(e); 64 | } finally { 65 | close(session); 66 | } 67 | } 68 | 69 | public final void delete(Object obj) throws Exception { 70 | try { 71 | startOperation(); 72 | session.delete(obj); 73 | tx.commit(); 74 | } catch (Exception e) { 75 | handleException(e); 76 | throw new Exception(e); 77 | } finally { 78 | close(session); 79 | } 80 | } 81 | 82 | public final Object find(Class clazz, Long id) throws Exception { 83 | Object obj; 84 | try { 85 | startOperation(); 86 | obj = session.load(clazz, id); 87 | } catch (Exception e) { 88 | handleException(e); 89 | throw new Exception(e); 90 | } 91 | return obj; 92 | } 93 | 94 | public final List findAll(Class clazz) throws Exception { 95 | List objects; 96 | try { 97 | // startOperation(); 98 | session = getSession(); 99 | Query query = session.createQuery("from " + clazz.getName()); 100 | objects = query.list(); 101 | } catch (Exception e) { 102 | handleException(e); 103 | throw new Exception(e); 104 | } finally { 105 | close(session); 106 | } 107 | return objects; 108 | } 109 | 110 | public final void handleException(Exception e) { 111 | System.out.println("Transaction rollback due to " + e.getMessage()); 112 | rollback(tx); 113 | 114 | } 115 | 116 | public final void startOperation() { 117 | session = getSession(); 118 | tx = session.beginTransaction(); 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /src/main/java/com/gt/db/SessionUtils.java: -------------------------------------------------------------------------------- 1 | package com.gt.db; 2 | 3 | import org.apache.log4j.Logger; 4 | import org.hibernate.HibernateException; 5 | import org.hibernate.Session; 6 | import org.hibernate.SessionFactory; 7 | import org.hibernate.Transaction; 8 | import org.hibernate.boot.MetadataSources; 9 | import org.hibernate.boot.registry.StandardServiceRegistry; 10 | import org.hibernate.boot.registry.StandardServiceRegistryBuilder; 11 | 12 | public class SessionUtils { 13 | static Logger logger = Logger.getLogger(SessionUtils.class); 14 | private static SessionFactory sessionFactory; 15 | 16 | static { 17 | // A SessionFactory is set up once for an application! 18 | final StandardServiceRegistry registry = new StandardServiceRegistryBuilder() 19 | .configure() // configures settings from hibernate.cfg.xml 20 | .build(); 21 | try { 22 | sessionFactory = new MetadataSources(registry).buildMetadata().buildSessionFactory(); 23 | } catch (Exception e) { 24 | // The registry would be destroyed by the SessionFactory, but we had trouble building the SessionFactory 25 | // so destroy it manually. 26 | e.printStackTrace(); 27 | StandardServiceRegistryBuilder.destroy(registry); 28 | } 29 | } 30 | 31 | /** 32 | * Builds a SessionFactory, if it hasn't been already. 33 | */ 34 | public static SessionFactory get() { 35 | return sessionFactory; 36 | } 37 | 38 | public static Session getSession() { 39 | return sessionFactory.openSession(); 40 | } 41 | 42 | public static void close(Session session) { 43 | if (session != null) { 44 | try { 45 | session.close(); 46 | } catch (HibernateException ignored) { 47 | ignored.printStackTrace(); 48 | logger.error("Couldn't close Session" + ignored.getMessage()); 49 | } 50 | } 51 | } 52 | 53 | public static void rollback(Transaction tx) { 54 | try { 55 | if (tx != null) { 56 | tx.rollback(); 57 | } 58 | } catch (HibernateException ignored) { 59 | logger.error("Couldn't rollback Transaction" + ignored.getMessage()); 60 | } 61 | } 62 | 63 | 64 | } -------------------------------------------------------------------------------- /src/main/java/com/gt/db/utils/BaseDBUtils.java: -------------------------------------------------------------------------------- 1 | package com.gt.db.utils; 2 | 3 | import com.gt.db.BaseDAO; 4 | import org.hibernate.Query; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * Commonly used db functions 10 | * 11 | * @author GT 12 | *

13 | * Mar 3, 2012 com.gt.db.utils-DBUtils.java 14 | */ 15 | public class BaseDBUtils extends BaseDAO { 16 | 17 | /** 18 | * Status 1 = active - not deleted 19 | */ 20 | 21 | public BaseDBUtils() { 22 | super(); 23 | } 24 | 25 | public final List readAll(Class clazz) throws Exception { 26 | Query q = getSession().createQuery("from " + clazz.getName() + " where dflag=:status order by id desc"); 27 | q.setInteger("status", 1); 28 | return super.runReadQuery(q); 29 | } 30 | 31 | public final List readAllNoStatus(Class clazz) throws Exception { 32 | Query q = getSession().createQuery("from " + clazz.getName() + " order by id desc"); 33 | return super.runReadQuery(q); 34 | } 35 | 36 | public final Object getById(Class clazz, int id) throws Exception { 37 | Query q = getSession().createQuery("from " + clazz.getName() + " where id=:id and dflag=:status order by id desc"); 38 | q.setInteger("id", id); 39 | q.setInteger("status", 1); 40 | System.out.println(q.getQueryString() + " Reading ID " + id); 41 | return super.runReadQuery(q).get(0); 42 | 43 | } 44 | 45 | public final Object getByIdNoStatus(Class clazz, int id) throws Exception { 46 | Query q = getSession().createQuery("from " + clazz.getName() + " where id=:id order by id desc"); 47 | q.setInteger("id", id); 48 | return super.runReadQuery(q).get(0); 49 | } 50 | 51 | public final int deleteById(Class clazz, int id) throws Exception { 52 | 53 | Query q = getSession().createQuery("update " + clazz.getName() + " set dflag=:status where id=:id"); 54 | q.setInteger("status", 0); 55 | q.setInteger("id", id); 56 | return super.runQuery(q); 57 | } 58 | 59 | public final int deleteByIdPhysical(Class clazz, int id) throws Exception { 60 | Query q = getSession().createQuery("delete from " + clazz.getName() + " where id=:id"); 61 | q.setInteger("id", id); 62 | return super.runQuery(q); 63 | 64 | } 65 | 66 | public final void saveOrUpdate(Object object) throws Exception { 67 | super.saveOrUpdate(object); 68 | 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/com/gt/uilib/components/AbstractFunctionPanel.java: -------------------------------------------------------------------------------- 1 | package com.gt.uilib.components; 2 | 3 | import com.gt.common.constants.CommonConsts; 4 | import com.gt.common.constants.Status; 5 | import com.gt.common.utils.UIUtils; 6 | import com.gt.uilib.inputverifier.Verifier; 7 | 8 | import javax.swing.*; 9 | import java.awt.*; 10 | 11 | /** 12 | * com.gt.uilib.components-AbstractFunctionPanel.java
13 | * 14 | * @author Ganesh Tiwari @@ gtiwari333@gmail.com
15 | * Created on : Mar 19, 2012
16 | * Copyright : Ganesh Tiwari 18 | */ 19 | public abstract class AbstractFunctionPanel extends JPanel implements Verifier { 20 | private static final long serialVersionUID = -5535283266424039078L; 21 | public boolean isReadyToClose = false; 22 | protected AppFrame mainApp; 23 | protected Status status; 24 | protected boolean debug; 25 | 26 | public AbstractFunctionPanel() { 27 | debug = AppFrame.debug; 28 | setBounds(100, 100, 450, 300); 29 | setLayout(new BorderLayout()); 30 | setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, CommonConsts.COLOR_TOOLBAR_BORDER)); 31 | } 32 | 33 | /** 34 | * we can override this function to display different message 35 | */ 36 | public static String getUnsavedExitMessage() { 37 | return "Are you sure to exit?"; 38 | 39 | } 40 | 41 | // utility method to clear all editable text fields and combo boxes 42 | 43 | protected static void handleDBError(Exception e) { 44 | System.out.println("db error " + e.toString()); 45 | e.printStackTrace(); 46 | String expln = e.toString(); 47 | 48 | String[] exp = expln.split("Exception:"); 49 | System.err.println("Reason - " + exp[exp.length - 1]); 50 | JOptionPane.showMessageDialog(null, "DB Error" + e.getMessage(), "Error ! ", JOptionPane.ERROR_MESSAGE); 51 | } 52 | 53 | /** 54 | * function name will be displayed in title bar 55 | */ 56 | abstract public String getFunctionName(); 57 | 58 | /** 59 | * initialize fields, set initial status,
60 | * it sh 61 | */ 62 | public void init() { 63 | // UIUtils.updateFont(new Font("Arial", Font.PLAIN, 12), this); 64 | UIUtils.decorateBorders(this); 65 | } 66 | 67 | public final AppFrame getMainFrame() { 68 | return mainApp; 69 | } 70 | 71 | public final void validateFailed() { 72 | getMainFrame().getStatusLbl().setText("Please enter data properly before saving"); 73 | 74 | } 75 | 76 | public void validatePassed() { 77 | 78 | } 79 | 80 | public final void changeStatus(Status status) { 81 | this.status = status; 82 | enableDisableComponents(); 83 | } 84 | 85 | abstract public void handleSaveAction(); 86 | 87 | abstract public void enableDisableComponents(); 88 | } 89 | -------------------------------------------------------------------------------- /src/main/java/com/gt/uilib/components/ActionMenuItem.java: -------------------------------------------------------------------------------- 1 | package com.gt.uilib.components; 2 | 3 | import com.gt.common.ResourceManager; 4 | 5 | import javax.swing.*; 6 | import java.awt.event.ActionListener; 7 | 8 | public class ActionMenuItem extends JMenuItem { 9 | private static final long serialVersionUID = -6416935244618242268L; 10 | private final String panelQualifiedClassName; 11 | 12 | protected ActionMenuItem(String text, String fileFullName, String panelQualifiedClassName) { 13 | 14 | super(text, ResourceManager.getImageIcon(fileFullName)); 15 | this.panelQualifiedClassName = panelQualifiedClassName; 16 | initListner(); 17 | } 18 | 19 | public static ActionMenuItem create(String text, String fileName, String panelQualifiedClassName) { 20 | String fullFileName = fileName + "-menu.png"; 21 | return new ActionMenuItem(text, fullFileName, panelQualifiedClassName); 22 | } 23 | 24 | protected final void initListner() { 25 | addActionListener(getCommonListener()); 26 | } 27 | 28 | private ActionListener getCommonListener() { 29 | ActionListener al = e -> AppFrame.getInstance().setWindow(panelQualifiedClassName); 30 | return al; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/gt/uilib/components/AppFrame.java: -------------------------------------------------------------------------------- 1 | package com.gt.uilib.components; 2 | 3 | import com.ca.ui.panels.AboutPanel; 4 | import com.ca.ui.panels.ChangePasswordPanel; 5 | import com.gt.common.ResourceManager; 6 | import com.gt.common.constants.StrConstants; 7 | import com.gt.uilib.components.button.ActionButton; 8 | import com.gt.uilib.components.button.ExitButton; 9 | import com.gt.uilib.components.button.LogOutButton; 10 | import org.apache.log4j.Logger; 11 | 12 | import javax.swing.*; 13 | import javax.swing.border.EtchedBorder; 14 | import java.awt.*; 15 | import java.awt.event.WindowAdapter; 16 | import java.awt.event.WindowEvent; 17 | import java.awt.event.WindowListener; 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | 21 | /** 22 | * @author GT 23 | *

24 | * Mar 7, 2012 com.ca.ui-AppFrame.java 25 | */ 26 | public class AppFrame extends JFrame { 27 | 28 | public static final String loginPanel = com.ca.ui.panels.LoginPanel.class.getName(); 29 | public static AbstractFunctionPanel currentWindow; 30 | public static boolean isLoggedIn = false; 31 | public static boolean debug = true; 32 | static Logger logger = Logger.getLogger(AppFrame.class); 33 | private static AppFrame _instance; 34 | private static JMenuBar menuBar; 35 | private static JPanel bodyPanel; 36 | private static JPanel toolBarPanel; 37 | WindowListener exitListener = new WindowAdapter() { 38 | @Override 39 | public void windowClosing(WindowEvent e) { 40 | } 41 | }; 42 | private JLabel statusLbl; 43 | 44 | private AppFrame() { 45 | setTitle(StrConstants.APP_TITLE); 46 | setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); 47 | setBounds(100, 100, 850, 500); 48 | 49 | this.setIconImage(ResourceManager.getImage("logo2.png")); 50 | 51 | getContentPane().setLayout(new BorderLayout(0, 0)); 52 | setJMenuBar(getMenuBarr()); 53 | getContentPane().add(getStatusPanel(), BorderLayout.SOUTH); 54 | getContentPane().add(getBodyPanel(), BorderLayout.CENTER); 55 | getContentPane().add(getToolBarPanel(), BorderLayout.NORTH); 56 | 57 | addWindowListener(exitListener); 58 | 59 | currentWindow = getFunctionPanelInstance(loginPanel); 60 | setWindow(currentWindow); 61 | 62 | GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment(); 63 | 64 | setMaximizedBounds(e.getMaximumWindowBounds()); 65 | setExtendedState(getExtendedState() | JFrame.MAXIMIZED_BOTH); 66 | 67 | } 68 | 69 | public static AppFrame getInstance() { 70 | if (_instance == null) { 71 | _instance = new AppFrame(); 72 | } 73 | return _instance; 74 | } 75 | 76 | public static void loginSuccess() { 77 | isLoggedIn = true; 78 | getInstance().setWindow(com.ca.ui.panels.HomeScreenPanel.class.getName()); 79 | logger.info("logged in"); 80 | } 81 | 82 | private static JPanel getBodyPanel() { 83 | bodyPanel = new JPanel(); 84 | bodyPanel.setLayout(new BorderLayout()); 85 | bodyPanel.add(new JLabel("Hello")); 86 | 87 | return bodyPanel; 88 | } 89 | 90 | protected static AbstractFunctionPanel getFunctionPanelInstance(String className) { 91 | AbstractFunctionPanel object = null; 92 | try { 93 | object = (AbstractFunctionPanel) Class.forName(className).newInstance(); 94 | } catch (InstantiationException | ClassNotFoundException | IllegalAccessException e) { 95 | System.err.println(e); 96 | } 97 | return object; 98 | } 99 | 100 | private JMenuBar getMenuBarr() { 101 | if (menuBar == null) { 102 | menuBar = new JMenuBar(); 103 | /* 104 | First menu - 105 | */ 106 | JMenu startMnu = new JMenu("Application"); 107 | JMenuItem logOutMnuItem = new JMenuItem("Log Out"); 108 | logOutMnuItem.addActionListener(e -> LogOutButton.handleLogout()); 109 | startMnu.add(logOutMnuItem); 110 | JMenuItem exitMnuItem = new JMenuItem("Close"); 111 | exitMnuItem.addActionListener(e -> ExitButton.handleExit()); 112 | startMnu.add(exitMnuItem); 113 | menuBar.add(startMnu); 114 | /* 115 | Entry Menu 116 | */ 117 | JMenu entryMenu = new JMenu("Entry"); 118 | entryMenu.add(ActionMenuItem.create("New Item Entry", "sitementry", com.ca.ui.panels.ItemEntryPanel.class.getName())); 119 | entryMenu.add(new JSeparator()); 120 | JMenu initRecordMenuSub = new JMenu("Initial Records"); 121 | 122 | initRecordMenuSub.add(ActionMenuItem.create("Add Category", "a", com.ca.ui.panels.CategoryPanel.class.getName())); 123 | initRecordMenuSub.add(ActionMenuItem.create("Add Vendor", "vendor", com.ca.ui.panels.VendorPanel.class.getName())); 124 | initRecordMenuSub.add(ActionMenuItem.create("Add Branch Office", "vendor", com.ca.ui.panels.BranchOfficePanel.class.getName())); 125 | initRecordMenuSub.add(ActionMenuItem.create("Add New Unit Type", "a", com.ca.ui.panels.UnitsStringPanel.class.getName())); 126 | entryMenu.add(initRecordMenuSub); 127 | menuBar.add(entryMenu); 128 | 129 | /* 130 | Search 131 | */ 132 | JMenu searchMnu = new JMenu("Search"); 133 | searchMnu.add(ActionMenuItem.create("Stock Search", "sfind", com.ca.ui.panels.StockQueryPanel.class.getName())); 134 | menuBar.add(searchMnu); 135 | 136 | /* 137 | Tools Menu This ActionMenuItem should be displayed on JDialog 138 | */ 139 | JMenu toolsMenu = new JMenu("Tools"); 140 | JMenuItem jmChang = new JMenuItem("Change UserName/Password"); 141 | jmChang.addActionListener(e -> { 142 | if (isLoggedIn) { 143 | GDialog cd = new GDialog(AppFrame.this, "Change Username/Password", true); 144 | ChangePasswordPanel vp = new ChangePasswordPanel(); 145 | cd.setAbstractFunctionPanel(vp, new Dimension(480, 340)); 146 | cd.setResizable(false); 147 | cd.setVisible(true); 148 | } 149 | 150 | }); 151 | toolsMenu.add(jmChang); 152 | menuBar.add(toolsMenu); 153 | /* 154 | Last Menu 155 | */ 156 | JMenu helpMenu = new JMenu("Help"); 157 | JMenuItem readmanualItem = new JMenuItem("Read Manual"); 158 | helpMenu.add(readmanualItem); 159 | helpMenu.add(new JSeparator()); 160 | JMenuItem supportMnu = new JMenuItem("Support"); 161 | helpMenu.add(supportMnu); 162 | 163 | readmanualItem.addActionListener(e -> { 164 | try { 165 | String cmd = "cmd.exe /c start "; 166 | String file = "help.pdf"; 167 | Runtime.getRuntime().exec(cmd + file); 168 | } catch (Exception e2) { 169 | JOptionPane.showMessageDialog(AppFrame.this, "Could not open help file " + e2.getMessage(), "Error opening file", 170 | JOptionPane.ERROR_MESSAGE); 171 | } 172 | }); 173 | supportMnu.addActionListener(e -> { 174 | GDialog cd = new GDialog(AppFrame.this, "About/Support", true); 175 | AboutPanel vp = new AboutPanel(); 176 | cd.setAbstractFunctionPanel(vp, new Dimension(400, 190)); 177 | cd.setVisible(true); 178 | 179 | }); 180 | menuBar.add(helpMenu); 181 | } 182 | return menuBar; 183 | 184 | } 185 | 186 | private JPanel getStatusPanel() { 187 | JPanel statusPanel = new JPanel(); 188 | statusPanel.add(getStatusLbl()); 189 | return statusPanel; 190 | } 191 | 192 | public final JLabel getStatusLbl() { 193 | if (statusLbl == null) { 194 | statusLbl = new JLabel("-(:::)-"); 195 | } 196 | return statusLbl; 197 | 198 | } 199 | 200 | public final void setWindow(String curQfn) { 201 | AbstractFunctionPanel cur = getFunctionPanelInstance(curQfn); 202 | if (cur != null && isLoggedIn) { 203 | if (!currentWindow.getFunctionName().equals(cur.getFunctionName())) { 204 | setWindow(cur); 205 | } 206 | 207 | } 208 | if (!isLoggedIn) { 209 | JOptionPane.showMessageDialog(null, "You must Log in First"); 210 | } 211 | } 212 | 213 | private void setWindow(final AbstractFunctionPanel next) { 214 | SwingUtilities.invokeLater(() -> { 215 | currentWindow = next; 216 | bodyPanel.removeAll(); 217 | bodyPanel.add(next, BorderLayout.CENTER); 218 | bodyPanel.revalidate(); 219 | bodyPanel.repaint(); 220 | setTitle(StrConstants.APP_TITLE + " : " + next.getFunctionName()); 221 | next.init(); 222 | }); 223 | 224 | } 225 | 226 | private JPanel getToolBarPanel() { 227 | if (toolBarPanel == null) { 228 | toolBarPanel = new JPanel(); 229 | toolBarPanel.setLayout(new BorderLayout(20, 10)); 230 | 231 | List buttons = new ArrayList<>(); 232 | buttons.add(ActionButton.create("HOME", "home", com.ca.ui.panels.HomeScreenPanel.class.getName())); 233 | buttons.add(ActionButton.create("Stock Query", "find", com.ca.ui.panels.StockQueryPanel.class.getName())); 234 | buttons.add(ActionButton.create("Item Entry", "itementry", com.ca.ui.panels.ItemEntryPanel.class.getName())); 235 | buttons.add(ActionButton.create("Transfer", "itemtransfer", com.ca.ui.panels.ItemTransferPanel.class.getName())); 236 | buttons.add(ActionButton.create("Return", "return", com.ca.ui.panels.ItemReturnPanel.class.getName())); 237 | buttons.add(new JLabel()); 238 | buttons.add(LogOutButton.create("Logout", "logout", com.ca.ui.panels.HomeScreenPanel.class.getName())); 239 | buttons.add(ExitButton.create("Exit", "exit", com.ca.ui.panels.HomeScreenPanel.class.getName())); 240 | 241 | toolBarPanel.setBorder(new EtchedBorder(EtchedBorder.LOWERED)); 242 | toolBarPanel.setPreferredSize(new Dimension(getWidth(), 80)); 243 | toolBarPanel.setLayout(new GridBagLayout()); 244 | GridBagConstraints c = new GridBagConstraints(); 245 | 246 | c.gridx = 0; 247 | c.gridy = 0; 248 | c.weightx = 0.5; 249 | for (JLabel button : buttons) { 250 | toolBarPanel.add(button, c); 251 | c.gridx++; 252 | } 253 | } 254 | return toolBarPanel; 255 | } 256 | 257 | public final void handleLogOut() { 258 | setWindow(AppFrame.loginPanel); 259 | isLoggedIn = false; 260 | 261 | } 262 | 263 | } 264 | -------------------------------------------------------------------------------- /src/main/java/com/gt/uilib/components/GDialog.java: -------------------------------------------------------------------------------- 1 | package com.gt.uilib.components; 2 | 3 | import javax.swing.*; 4 | import java.awt.*; 5 | 6 | public class GDialog extends JDialog { 7 | AbstractFunctionPanel funcPane; 8 | 9 | public GDialog(Dialog owner, String title, boolean modal) { 10 | super(owner, title, modal); 11 | } 12 | 13 | public GDialog(Frame owner, String title, boolean modal) { 14 | super(owner, title, modal); 15 | } 16 | 17 | public final void setAbstractFunctionPanel(AbstractFunctionPanel abstractFunctionPanel, Dimension dm) { 18 | this.funcPane = abstractFunctionPanel; 19 | 20 | add(funcPane); 21 | setSize(dm); 22 | setLocation(100, 50); 23 | setVisible(true); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/gt/uilib/components/button/ActionButton.java: -------------------------------------------------------------------------------- 1 | package com.gt.uilib.components.button; 2 | 3 | import com.gt.common.ResourceManager; 4 | import com.gt.uilib.components.AppFrame; 5 | 6 | import javax.swing.*; 7 | import javax.swing.border.EtchedBorder; 8 | import java.awt.*; 9 | import java.awt.event.MouseAdapter; 10 | import java.awt.event.MouseEvent; 11 | import java.awt.event.MouseListener; 12 | 13 | public class ActionButton extends JLabel { 14 | 15 | private static final long serialVersionUID = 20110814L; 16 | private final String panelQualifiedClassName; 17 | private final ImageIcon on; 18 | private final ImageIcon off; 19 | 20 | protected ActionButton(String Text, ImageIcon on, ImageIcon off, String panelQualifiedClassName) { 21 | super(Text, off, CENTER); 22 | this.off = off; 23 | this.on = on; 24 | this.panelQualifiedClassName = panelQualifiedClassName; 25 | Dimension d = new Dimension(80, 80); 26 | setPreferredSize(d); 27 | setMinimumSize(d); 28 | setHorizontalTextPosition(JLabel.CENTER); 29 | setVerticalTextPosition(JLabel.BOTTOM); 30 | initListner(); 31 | } 32 | 33 | public static ActionButton create(String text, String fileName, String panelQualifiedClassName) { 34 | String offFile = fileName + "-on.png"; 35 | String onFile = fileName + "-off.png"; 36 | return new ActionButton(text, ResourceManager.getImageIcon(onFile), ResourceManager.getImageIcon(offFile), panelQualifiedClassName); 37 | } 38 | 39 | public final void highlight() { 40 | setIcon(on); 41 | } 42 | 43 | public final void unhighlight() { 44 | setIcon(off); 45 | } 46 | 47 | protected void initListner() { 48 | addMouseListener(getCommonListener()); 49 | } 50 | 51 | private MouseListener getCommonListener() { 52 | MouseListener ml = new MouseAdapter() { 53 | 54 | public void mousePressed(MouseEvent e) { 55 | AppFrame.getInstance().setWindow(panelQualifiedClassName); 56 | highlight(); 57 | } 58 | 59 | public void mouseEntered(MouseEvent e) { 60 | setBorder(new EtchedBorder(EtchedBorder.LOWERED)); 61 | highlight(); 62 | 63 | } 64 | 65 | public void mouseExited(MouseEvent e) { 66 | setBorder(null); 67 | unhighlight(); 68 | } 69 | }; 70 | return ml; 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/com/gt/uilib/components/button/ExitButton.java: -------------------------------------------------------------------------------- 1 | package com.gt.uilib.components.button; 2 | 3 | import com.gt.common.ResourceManager; 4 | import com.gt.uilib.components.AbstractFunctionPanel; 5 | import com.gt.uilib.components.AppFrame; 6 | import org.apache.log4j.Logger; 7 | 8 | import javax.swing.*; 9 | import javax.swing.border.EtchedBorder; 10 | import java.awt.event.MouseAdapter; 11 | import java.awt.event.MouseEvent; 12 | import java.awt.event.MouseListener; 13 | 14 | public class ExitButton extends ActionButton { 15 | 16 | static Logger logger = Logger.getLogger(ExitButton.class); 17 | 18 | public ExitButton(String Text, ImageIcon on, ImageIcon off, String panelQualifiedClassName) { 19 | super(Text, on, off, panelQualifiedClassName); 20 | } 21 | 22 | public static ExitButton create(String text, String fileName, String panelQualifiedClassName) { 23 | String onFile = fileName + "-on.png"; 24 | String offFile = fileName + "-off.png"; 25 | return new ExitButton(text, ResourceManager.getImageIcon(onFile), ResourceManager.getImageIcon(offFile), panelQualifiedClassName); 26 | } 27 | 28 | public static void handleExit() { 29 | int res = 0; 30 | if (AppFrame.currentWindow != null) { 31 | if (!AppFrame.currentWindow.isReadyToClose) 32 | res = JOptionPane.showConfirmDialog(AppFrame.getInstance(), AbstractFunctionPanel.getUnsavedExitMessage(), "Exit Confirmation", 33 | JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); 34 | } else { 35 | res = JOptionPane.showConfirmDialog(AppFrame.getInstance(), "Are you sure to exit", "Exit Confirmation", JOptionPane.YES_NO_OPTION, 36 | JOptionPane.QUESTION_MESSAGE); 37 | } 38 | 39 | if (res == JOptionPane.YES_OPTION) { 40 | // setVisible(false); 41 | logger.info("Shutting Down"); 42 | AppFrame.getInstance().dispose(); 43 | // TODO: DB connection close 44 | System.exit(0); 45 | } 46 | } 47 | 48 | @Override 49 | protected final void initListner() { 50 | addMouseListener(getExitMouseListener()); 51 | } 52 | 53 | protected final MouseListener getExitMouseListener() { 54 | MouseListener ml = new MouseAdapter() { 55 | 56 | public void mouseReleased(MouseEvent e) { 57 | handleExit(); 58 | } 59 | 60 | public void mouseEntered(MouseEvent e) { 61 | setBorder(new EtchedBorder(EtchedBorder.LOWERED)); 62 | highlight(); 63 | } 64 | 65 | public void mouseExited(MouseEvent e) { 66 | setBorder(null); 67 | unhighlight(); 68 | } 69 | 70 | public void mouseClicked(MouseEvent e) { 71 | setBorder(null); 72 | unhighlight(); 73 | } 74 | }; 75 | return ml; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/com/gt/uilib/components/button/LogOutButton.java: -------------------------------------------------------------------------------- 1 | package com.gt.uilib.components.button; 2 | 3 | import com.gt.common.ResourceManager; 4 | import com.gt.uilib.components.AppFrame; 5 | 6 | import javax.swing.*; 7 | import javax.swing.border.EtchedBorder; 8 | import java.awt.event.MouseAdapter; 9 | import java.awt.event.MouseEvent; 10 | import java.awt.event.MouseListener; 11 | 12 | public class LogOutButton extends ActionButton { 13 | public LogOutButton(String Text, ImageIcon on, ImageIcon off, String panelQualifiedClassName) { 14 | super(Text, on, off, panelQualifiedClassName); 15 | } 16 | 17 | public static LogOutButton create(String text, String fileName, String panelQualifiedClassName) { 18 | String onFile = fileName + "-on.png"; 19 | String offFile = fileName + "-off.png"; 20 | return new LogOutButton(text, ResourceManager.getImageIcon(onFile), ResourceManager.getImageIcon(offFile), panelQualifiedClassName); 21 | } 22 | 23 | public static void handleLogout() { 24 | 25 | AppFrame.getInstance().handleLogOut(); 26 | 27 | } 28 | 29 | @Override 30 | protected final void initListner() { 31 | addMouseListener(getLogOutMouseListener()); 32 | } 33 | 34 | protected final MouseListener getLogOutMouseListener() { 35 | MouseListener ml = new MouseAdapter() { 36 | 37 | public void mouseReleased(MouseEvent e) { 38 | handleLogout(); 39 | } 40 | 41 | public void mouseEntered(MouseEvent e) { 42 | setBorder(new EtchedBorder(EtchedBorder.LOWERED)); 43 | highlight(); 44 | } 45 | 46 | public void mouseExited(MouseEvent e) { 47 | setBorder(null); 48 | unhighlight(); 49 | } 50 | 51 | public void mouseClicked(MouseEvent e) { 52 | setBorder(null); 53 | unhighlight(); 54 | } 55 | }; 56 | return ml; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/gt/uilib/components/input/DataComboBox.java: -------------------------------------------------------------------------------- 1 | package com.gt.uilib.components.input; 2 | 3 | import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator; 4 | 5 | import javax.swing.*; 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | /** 10 | * com.gt.uilib.components.combo-DataComboBox.java
11 | * 12 | * @author Ganesh Tiwari @@ gtiwari333@gmail.com
13 | * Created on : Mar 19, 2012
14 | * Copyright : Ganesh Tiwari 16 | */ 17 | public class DataComboBox extends JComboBox { 18 | 19 | private static final long serialVersionUID = -615634209230481880L; 20 | private List itemList; 21 | 22 | public DataComboBox() { 23 | super(); 24 | setBorder(BorderFactory.createEmptyBorder()); 25 | AutoCompleteDecorator.decorate(this); 26 | } 27 | 28 | protected static String getStringRepresentation(Object[] values) { 29 | StringBuilder sb = new StringBuilder(); 30 | for (int i = 1; i < values.length; i++) { 31 | sb.append(values[i]); 32 | if (i != values.length - 1) sb.append(" - "); 33 | } 34 | return sb.toString(); 35 | } 36 | 37 | /** 38 | * clears the all data in combo 39 | */ 40 | public final void init() { 41 | if (itemList != null) { 42 | this.removeAllItems(); 43 | itemList.clear(); 44 | itemList = null; 45 | 46 | } 47 | } 48 | 49 | // decorate 50 | 51 | public final boolean isValidDataChoosen() { 52 | return (getSelectedId() != -1); 53 | } 54 | 55 | /** 56 | * @param values first index must contain ID field 57 | */ 58 | 59 | public final void addRow(Object[] values) { 60 | if (itemList == null) { 61 | itemList = new ArrayList<>(); 62 | Item blank = new Item(0, ""); 63 | itemList.add(blank); 64 | this.addItem(blank); 65 | } 66 | Item item = new Item((Integer) values[0], getStringRepresentation(values)); 67 | itemList.add(item); 68 | this.addItem(item); 69 | 70 | } 71 | 72 | public final int getSelectedId() { 73 | int index = this.getSelectedIndex(); 74 | if (index > 0 && itemList != null && itemList.size() > 0) { 75 | Item item = itemList.get(index); 76 | return item.getId(); 77 | } 78 | return -1; 79 | } 80 | 81 | public final void selectItem(int id) { 82 | for (Item item : itemList) { 83 | if (item.getId() == id) { 84 | this.setSelectedItem(item); 85 | } 86 | } 87 | } 88 | 89 | 90 | public final void selectLastItem() { 91 | if (itemList != null) this.setSelectedItem(itemList.size()); 92 | else 93 | setSelectedIndex(getItemCount() - 1); 94 | } 95 | 96 | public final void selectDefaultItem() { 97 | if (itemList != null && itemList.size() > 0) this.setSelectedItem(itemList.get(0)); 98 | } 99 | 100 | public final boolean contains(String s) { 101 | if (s == null || s.trim().isEmpty()) return true; 102 | if (itemList == null) return false; 103 | s = s.toLowerCase(); 104 | for (Item i : itemList) { 105 | if (i.toString().toLowerCase().equals(s)) { 106 | return true; 107 | } 108 | } 109 | return false; 110 | 111 | } 112 | 113 | public final boolean matches(String s) { 114 | if (s == null || s.trim().isEmpty()) return true; 115 | s = s.toLowerCase(); 116 | for (Item i : itemList) { 117 | if (i.toString().toLowerCase().contains(s)) { 118 | return true; 119 | } 120 | } 121 | return false; 122 | 123 | } 124 | 125 | static class Item implements Comparable { 126 | int id; 127 | String text; 128 | 129 | public Item(int id, String text) { 130 | super(); 131 | this.id = id; 132 | this.text = text; 133 | } 134 | 135 | public final int getId() { 136 | return id; 137 | } 138 | 139 | public final void setId(int id) { 140 | this.id = id; 141 | } 142 | 143 | public final String getText() { 144 | return text; 145 | } 146 | 147 | public final void setText(String text) { 148 | this.text = text; 149 | } 150 | 151 | @Override 152 | public final String toString() { 153 | return String.format("%s", text); 154 | } 155 | 156 | public final int compareTo(Item o) { 157 | Item it2 = o; 158 | return this.text.compareToIgnoreCase(it2.text); 159 | 160 | } 161 | } 162 | } 163 | -------------------------------------------------------------------------------- /src/main/java/com/gt/uilib/components/input/GTextArea.java: -------------------------------------------------------------------------------- 1 | package com.gt.uilib.components.input; 2 | 3 | import org.apache.commons.lang3.SystemUtils; 4 | 5 | import javax.swing.*; 6 | import javax.swing.text.AttributeSet; 7 | import javax.swing.text.BadLocationException; 8 | import javax.swing.text.PlainDocument; 9 | 10 | /** 11 | * border, scrollbar, length(RxC) limit etc 12 | * 13 | * @author GT 14 | */ 15 | public class GTextArea extends JScrollPane { 16 | private JTextArea addressFLD; 17 | 18 | public GTextArea(int rows, int cols) { 19 | addressFLD = new JTextArea(rows, cols); 20 | addressFLD.setWrapStyleWord(true); 21 | addressFLD.setLineWrap(true); 22 | addressFLD.setDocument(new JTextFieldLimit(rows * cols)); 23 | setBorder(BorderFactory.createEmptyBorder()); 24 | 25 | getViewport().add(addressFLD); 26 | setVisible(true); 27 | repaint(); 28 | revalidate(); 29 | 30 | } 31 | 32 | public static void makeUI() { 33 | 34 | JFrame frame = new JFrame("Adventure in Nepal - Combo Test"); 35 | frame.getContentPane().add(new GTextArea(2, 10)); 36 | frame.pack(); 37 | frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); 38 | frame.setVisible(true); 39 | } 40 | 41 | public static void main(String[] args) throws Exception { 42 | if (SystemUtils.IS_OS_WINDOWS) { 43 | UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); 44 | } 45 | 46 | makeUI(); 47 | } 48 | 49 | public final String getText() { 50 | return addressFLD.getText().trim(); 51 | } 52 | 53 | public final void setText(String str) { 54 | addressFLD.setText(str); 55 | 56 | } 57 | } 58 | 59 | class JTextFieldLimit extends PlainDocument { 60 | private int limit; 61 | 62 | JTextFieldLimit(int limit) { 63 | super(); 64 | this.limit = limit; 65 | } 66 | 67 | JTextFieldLimit(int limit, boolean upper) { 68 | super(); 69 | this.limit = limit; 70 | } 71 | 72 | public final void insertString(int offset, String str, AttributeSet attr) throws BadLocationException { 73 | if (str == null) return; 74 | 75 | if ((getLength() + str.length()) <= limit) { 76 | super.insertString(offset, str, attr); 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/com/gt/uilib/components/input/NumberFormatDocument.java: -------------------------------------------------------------------------------- 1 | package com.gt.uilib.components.input; 2 | 3 | import javax.swing.FocusManager; 4 | import javax.swing.text.AttributeSet; 5 | import javax.swing.text.BadLocationException; 6 | import javax.swing.text.JTextComponent; 7 | import javax.swing.text.PlainDocument; 8 | import java.awt.*; 9 | import java.text.NumberFormat; 10 | import java.util.regex.Matcher; 11 | import java.util.regex.Pattern; 12 | 13 | public class NumberFormatDocument extends PlainDocument { 14 | 15 | private static final long serialVersionUID = 147012982380037443L; 16 | private static final String REGEXP = "^[0-9,.]+$"; 17 | private static final String REGEXP_NEGATIVE = "^[0-9,-.]+$"; 18 | private NumberTextField target; 19 | private NumberFormat format; 20 | private int maxLength; 21 | private int decimalPlacesSize; 22 | private Pattern pattern; 23 | private Pattern patternNegative; 24 | 25 | public NumberFormatDocument(NumberTextField f) { 26 | 27 | format = NumberFormat.getNumberInstance(); 28 | maxLength = 16; 29 | decimalPlacesSize = 0; 30 | pattern = null; 31 | patternNegative = null; 32 | target = f; 33 | format.setGroupingUsed(true); 34 | pattern = Pattern.compile(REGEXP); 35 | patternNegative = Pattern.compile(REGEXP_NEGATIVE); 36 | } 37 | 38 | private static int calcComma(String val) { 39 | int n = 0; 40 | for (int i = 0; i < val.length(); i++) 41 | if (val.charAt(i) == ',') n++; 42 | 43 | return n; 44 | } 45 | 46 | public final int getMaxLength() { 47 | return maxLength; 48 | } 49 | 50 | public final void setMaxLength(int maxLength) { 51 | if (maxLength > 16 || maxLength < 1) { 52 | throw new IllegalArgumentException("the max length value is limited from 1 to 16."); 53 | } else { 54 | this.maxLength = maxLength; 55 | } 56 | } 57 | 58 | public final void setDecimalPlacesSize(int decimalPlacesSize) { 59 | this.decimalPlacesSize = decimalPlacesSize; 60 | } 61 | 62 | public final void insertString(int offs, String str, AttributeSet a) throws BadLocationException { 63 | Matcher matcher; 64 | if (target.isRestrictPositiveNumber()) matcher = pattern.matcher(str); 65 | else 66 | matcher = patternNegative.matcher(str); 67 | if (!matcher.matches()) throw new BadLocationException(str, offs); 68 | int dot = target.getCaret().getDot(); 69 | int len = getLength(); 70 | StringBuilder buf = new StringBuilder(); 71 | if (str.equals("-")) { 72 | if (len == 0) { 73 | super.insertString(offs, str, a); 74 | target.setForeground(Color.RED); 75 | return; 76 | } 77 | buf.append(getText(0, len)); 78 | if ('-' == buf.charAt(0)) { 79 | buf.delete(0, 1); 80 | if (dot > 0) dot--; 81 | super.remove(0, len); 82 | super.insertString(0, buf.toString(), a); 83 | target.getCaret().setDot(dot); 84 | target.setForeground(Color.BLACK); 85 | } else { 86 | super.insertString(0, str, a); 87 | target.setForeground(Color.RED); 88 | } 89 | return; 90 | } 91 | if (str.equals(",")) return; 92 | buf.append(getText(0, offs)); 93 | buf.append(str); 94 | buf.append(getText(offs, len - offs)); 95 | int comma1 = calcComma(getText(0, dot)); 96 | String value = buf.toString(); 97 | value = value.replace(",", ""); 98 | String temp = value.replace("-", ""); 99 | int periodIndex = temp.indexOf('.'); 100 | boolean focusNext = false; 101 | String temp2 = temp.replace(".", ""); 102 | if (temp2.length() == maxLength) focusNext = true; 103 | if (periodIndex > 0) { 104 | if (decimalPlacesSize == 0) throw new BadLocationException(str, offs); 105 | int decimal = temp.length() - periodIndex - 1; 106 | if (decimal > decimalPlacesSize) throw new BadLocationException(str, offs); 107 | temp = value.substring(0, periodIndex); 108 | } 109 | int checkLength = maxLength - decimalPlacesSize; 110 | if (temp.length() > checkLength) throw new BadLocationException(str, offs); 111 | String commaValue = format(value, offs); 112 | super.remove(0, getLength()); 113 | super.insertString(0, commaValue, a); 114 | dot += str.length(); 115 | int comma2 = calcComma(getText(0, dot)); 116 | dot += comma2 - comma1; 117 | target.getCaret().setDot(dot); 118 | if (getLength() > 0 && getText(0, 1).equals("-")) target.setForeground(Color.RED); 119 | else 120 | target.setForeground(Color.BLACK); 121 | if (focusNext) { 122 | FocusManager fm = FocusManager.getCurrentManager(); 123 | if (fm != null) { 124 | Component owner = fm.getFocusOwner(); 125 | if ((owner instanceof JTextComponent)) { 126 | JTextComponent tf = (JTextComponent) owner; 127 | if (tf.getDocument() == this) owner.transferFocus(); 128 | } 129 | } 130 | } 131 | } 132 | 133 | public final void remove(int offs, int len) throws BadLocationException { 134 | int dot = target.getCaret().getDot(); 135 | int comma1 = calcComma(getText(0, dot)); 136 | boolean isDelete = false; 137 | if (offs == dot) isDelete = true; 138 | if (len == 1 && offs > 0) { 139 | String c = getText(offs, len); 140 | if (c.equals(",")) if (dot > offs) offs--; 141 | else 142 | offs++; 143 | } 144 | super.remove(offs, len); 145 | String value = getText(0, getLength()); 146 | if (value == null || value.length() == 0) { 147 | target.setForeground(Color.BLACK); 148 | target.getCaret().setDot(0); 149 | return; 150 | } 151 | value = value.replaceAll("[,]", ""); 152 | String commaValue = format(value, offs); 153 | super.remove(0, getLength()); 154 | super.insertString(0, commaValue, null); 155 | if (!isDelete) dot -= len; 156 | int comma2 = calcComma(getText(0, dot)); 157 | dot += comma2 - comma1; 158 | target.getCaret().setDot(dot); 159 | if (getLength() > 0 && getText(0, 1).equals("-")) target.setForeground(Color.RED); 160 | else 161 | target.setForeground(Color.BLACK); 162 | } 163 | 164 | private String format(String value, int offs) throws BadLocationException { 165 | if (value.length() < 2) return value; 166 | boolean isDecimal = false; 167 | String intValue = value; 168 | String decimalValue = ""; 169 | if (value.contains(".")) { 170 | isDecimal = true; 171 | String[] values = value.split("\\."); 172 | if (values.length > 2) throw new BadLocationException(value, offs); 173 | intValue = values[0]; 174 | if (values.length == 2) { 175 | decimalValue = values[1]; 176 | if (decimalValue.contains(".")) throw new BadLocationException(value, offs); 177 | } 178 | } 179 | double doubleValue; 180 | try { 181 | doubleValue = Double.parseDouble(intValue); 182 | } catch (NumberFormatException nex) { 183 | throw new BadLocationException(value, offs); 184 | } 185 | StringBuilder commaValue = new StringBuilder(format.format(doubleValue)); 186 | if (isDecimal) { 187 | commaValue.append('.'); 188 | commaValue.append(decimalValue); 189 | } 190 | return commaValue.toString(); 191 | } 192 | } 193 | -------------------------------------------------------------------------------- /src/main/java/com/gt/uilib/components/input/NumberTextField.java: -------------------------------------------------------------------------------- 1 | package com.gt.uilib.components.input; 2 | 3 | import javax.swing.*; 4 | import javax.swing.text.Document; 5 | import java.math.BigDecimal; 6 | 7 | public class NumberTextField extends JTextField { 8 | 9 | private static final long serialVersionUID = 2279403774195701454L; 10 | private boolean isPositiveOnly; 11 | 12 | public NumberTextField(int maxLength) { 13 | isPositiveOnly = false; 14 | setMaxLength(maxLength); 15 | } 16 | 17 | public NumberTextField(int maxLength, boolean isPositiveOnly) { 18 | this.isPositiveOnly = isPositiveOnly; 19 | setMaxLength(maxLength); 20 | } 21 | 22 | public NumberTextField() { 23 | isPositiveOnly = false; 24 | } 25 | 26 | public NumberTextField(boolean isPositiveOnly) { 27 | this.isPositiveOnly = isPositiveOnly; 28 | } 29 | 30 | public final boolean isRestrictPositiveNumber() { 31 | return isPositiveOnly; 32 | } 33 | 34 | public final void setRestrictPositiveNumber(boolean isPositiveNumber) { 35 | isPositiveOnly = isPositiveNumber; 36 | } 37 | 38 | public final boolean isNonZeroEntered() { 39 | String val = getText(); 40 | BigDecimal bd = new BigDecimal(val); 41 | if (bd.compareTo(BigDecimal.ZERO) > 0) { 42 | System.out.println("nonzero"); 43 | return true; 44 | } 45 | return false; 46 | 47 | } 48 | 49 | protected final Document createDefaultModel() { 50 | return new NumberFormatDocument(this); 51 | } 52 | 53 | public final void setMaxLength(int maxLength) { 54 | ((NumberFormatDocument) getDocument()).setMaxLength(maxLength); 55 | } 56 | 57 | public final void setDecimalPlace(int size) { 58 | ((NumberFormatDocument) getDocument()).setDecimalPlacesSize(size); 59 | } 60 | 61 | public final String getText() { 62 | String text = super.getText(); 63 | if (text == null) return text; 64 | else 65 | return text.replaceAll("[,]", ""); 66 | } 67 | 68 | public final void selectAll() { 69 | Document doc = getDocument(); 70 | if (doc != null && super.getText() != null) { 71 | setCaretPosition(0); 72 | moveCaretPosition(super.getText().length()); 73 | } 74 | } 75 | 76 | protected final void initProperties() { 77 | setHorizontalAlignment(4); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/com/gt/uilib/components/table/BetterJTable.java: -------------------------------------------------------------------------------- 1 | package com.gt.uilib.components.table; 2 | 3 | import javax.swing.*; 4 | import javax.swing.table.TableCellRenderer; 5 | import javax.swing.table.TableColumn; 6 | import javax.swing.table.TableColumnModel; 7 | import javax.swing.table.TableModel; 8 | import java.awt.*; 9 | import java.awt.event.MouseEvent; 10 | import java.util.HashMap; 11 | import java.util.Map; 12 | 13 | public class BetterJTable extends JTable { 14 | 15 | private static final Color EVEN_ROW_COLOR = new Color(240, 255, 250); 16 | private static final Color TABLE_GRID_COLOR = new Color(0xd9d9d9); 17 | 18 | public BetterJTable(TableModel dm) { 19 | super(dm); 20 | init(); 21 | setFillsViewportHeight(true); 22 | setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); 23 | // setEditable(false); 24 | hideCol(); 25 | } 26 | 27 | public final void hideCol() { 28 | String columnName = "ID"; 29 | TableColumnModel tcm = getColumnModel(); 30 | int index = tcm.getColumnIndex(columnName); 31 | TableColumn column = tcm.getColumn(index); 32 | Map hiddenColumns = new HashMap<>(); 33 | hiddenColumns.put(columnName, column); 34 | hiddenColumns.put(":" + columnName, index); 35 | tcm.removeColumn(column); 36 | } 37 | 38 | public void adjustColumns() { 39 | // packAll(); 40 | } 41 | 42 | @Override 43 | public final Class getColumnClass(int column) { 44 | return (column == 0) ? Integer.class : Object.class; 45 | } 46 | 47 | public final String getToolTipText(MouseEvent e) { 48 | int row = rowAtPoint(e.getPoint()); 49 | int column = columnAtPoint(e.getPoint()); 50 | try { 51 | Object value = getValueAt(row, column); 52 | return value == null ? "" : value.toString(); 53 | } catch (Exception ex) { 54 | return ""; 55 | } 56 | } 57 | 58 | private void init() { 59 | setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); 60 | getTableHeader().setReorderingAllowed(false); 61 | setOpaque(false); 62 | setGridColor(TABLE_GRID_COLOR); 63 | setShowGrid(true); 64 | } 65 | 66 | @Override 67 | public final Component prepareRenderer(TableCellRenderer tcr, int row, int column) { 68 | Component c = super.prepareRenderer(tcr, row, column); 69 | if (isRowSelected(row)) { 70 | c.setForeground(getSelectionForeground()); 71 | c.setBackground(getSelectionBackground()); 72 | } else { 73 | c.setForeground(getForeground()); 74 | c.setBackground((row % 2 == 0) ? EVEN_ROW_COLOR : getBackground()); 75 | } 76 | return c; 77 | } 78 | 79 | } -------------------------------------------------------------------------------- /src/main/java/com/gt/uilib/components/table/BetterJTableNoSorting.java: -------------------------------------------------------------------------------- 1 | package com.gt.uilib.components.table; 2 | 3 | import javax.swing.*; 4 | import javax.swing.table.TableCellRenderer; 5 | import javax.swing.table.TableModel; 6 | import java.awt.*; 7 | import java.awt.event.MouseEvent; 8 | 9 | public class BetterJTableNoSorting extends JTable { 10 | 11 | private static final Color EVEN_ROW_COLOR = new Color(240, 255, 250); 12 | private static final Color TABLE_GRID_COLOR = new Color(0xd9d9d9); 13 | 14 | public BetterJTableNoSorting(TableModel dm) { 15 | super(dm); 16 | init(); 17 | setFillsViewportHeight(true); 18 | setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); 19 | // setEditable(false); 20 | putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); 21 | } 22 | 23 | public void adjustColumns() { 24 | // packAll(); 25 | } 26 | 27 | @Override 28 | public final Class getColumnClass(int column) { 29 | return (column == 0 || column == 1) ? Integer.class : Object.class; 30 | } 31 | 32 | public final String getToolTipText(MouseEvent e) { 33 | int row = rowAtPoint(e.getPoint()); 34 | int column = columnAtPoint(e.getPoint()); 35 | try { 36 | Object value = getValueAt(row, column); 37 | return value == null ? "" : value.toString(); 38 | } catch (Exception ex) { 39 | return ""; 40 | } 41 | } 42 | 43 | private void init() { 44 | setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); 45 | getTableHeader().setReorderingAllowed(false); 46 | setOpaque(false); 47 | setGridColor(TABLE_GRID_COLOR); 48 | setShowGrid(true); 49 | } 50 | 51 | @Override 52 | public final Component prepareRenderer(TableCellRenderer tcr, int row, int column) { 53 | Component c = super.prepareRenderer(tcr, row, column); 54 | if (isRowSelected(row)) { 55 | c.setForeground(getSelectionForeground()); 56 | c.setBackground(getSelectionBackground()); 57 | } else { 58 | c.setForeground(getForeground()); 59 | c.setBackground((row % 2 == 0) ? EVEN_ROW_COLOR : getBackground()); 60 | } 61 | return c; 62 | } 63 | 64 | } -------------------------------------------------------------------------------- /src/main/java/com/gt/uilib/components/table/EasyTableModel.java: -------------------------------------------------------------------------------- 1 | package com.gt.uilib.components.table; 2 | 3 | import javax.swing.table.DefaultTableModel; 4 | 5 | /** 6 | * IMP: by default- second column contains key, but it is adjustable by setKeyColumn() 7 | * 8 | * @author gtiwari333@gmail.com 9 | */ 10 | public class EasyTableModel extends DefaultTableModel { 11 | private static final long serialVersionUID = 8952987986047661236L; 12 | protected String[] header; 13 | private int KEY_ID_COLUMN = 1; 14 | 15 | protected EasyTableModel() { 16 | } 17 | 18 | public EasyTableModel(String[] header) { 19 | this.header = header; 20 | for (String aHeader : header) { 21 | addColumn(aHeader); 22 | } 23 | } 24 | 25 | public final Integer getKeyAtRow(int row) { 26 | return (Integer) getValueAt(row, KEY_ID_COLUMN); 27 | } 28 | 29 | public final void setKeyColumn(int keyCol) { 30 | this.KEY_ID_COLUMN = keyCol; 31 | } 32 | 33 | /** 34 | * on the assumption that second column contains key 35 | * 36 | * @param key 37 | * @return 38 | */ 39 | public final boolean containsKey(Integer key) { 40 | 41 | int rowC = getRowCount(); 42 | for (int i = 0; i < rowC; i++) { 43 | Integer keyAtRowI = getKeyAtRow(i); 44 | if (keyAtRowI.equals(key)) { 45 | return true; 46 | } 47 | } 48 | return false; 49 | } 50 | 51 | public final void removeRowWithKey(Integer key) { 52 | if (key == null || key < 0) { 53 | return; 54 | } 55 | int index = 0; 56 | 57 | int rowC = getRowCount(); 58 | // System.out.println("removing key "+key +" count "+rowC); 59 | for (int i = 0; i < rowC; i++) { 60 | Integer keyAtRowI = getKeyAtRow(i); 61 | if (keyAtRowI.equals(key)) { 62 | removeRow(index); 63 | // System.out.println("Row count after removal "+getRowCount()); 64 | return; 65 | } 66 | index++; 67 | } 68 | 69 | } 70 | 71 | public final void addRow(Object[] values) { 72 | super.addRow(values); 73 | // System.out.println("EasyTableModel.addRow() >> "+getRowCount()); 74 | } 75 | 76 | public final void resetModel() { 77 | super.setRowCount(0); 78 | } 79 | 80 | 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/com/gt/uilib/inputverifier/Validator.java: -------------------------------------------------------------------------------- 1 | package com.gt.uilib.inputverifier; 2 | 3 | import com.ca.ui.panels.SpecificationPanel; 4 | import com.gt.common.ResourceManager; 5 | import com.gt.common.utils.RegexUtils; 6 | import com.gt.common.utils.StringUtils; 7 | import com.gt.uilib.components.input.DataComboBox; 8 | import com.gt.uilib.components.input.GTextArea; 9 | import com.gt.uilib.components.input.NumberTextField; 10 | import com.toedter.calendar.JDateChooser; 11 | 12 | import javax.swing.*; 13 | import javax.swing.text.JTextComponent; 14 | import java.awt.*; 15 | import java.awt.event.MouseAdapter; 16 | import java.awt.event.MouseEvent; 17 | import java.text.SimpleDateFormat; 18 | import java.util.ArrayList; 19 | import java.util.Date; 20 | import java.util.List; 21 | 22 | /** 23 | * com.gt.uilib.inputverifier-Validator.java
24 | * 25 | * @author Ganesh Tiwari @@ gtiwari333@gmail.com
26 | * Created on : Mar 19, 2012
27 | * Copyright : Ganesh Tiwari 29 | */ 30 | public class Validator { 31 | 32 | private List tasks; 33 | private Color color; 34 | private Window parent; 35 | private boolean isShowWarningDialog; 36 | private String dialogErrorMessage; 37 | 38 | // JComponent firstErrorField = null; 39 | 40 | public Validator(Window parent) { 41 | this(parent, false, ""); 42 | 43 | } 44 | 45 | public Validator(Window parent, boolean isShowWarningDialog) { 46 | this(parent, isShowWarningDialog, "Please Enter All Required Data. Please Correct Before Proceeding"); 47 | } 48 | 49 | public Validator(Window parent, boolean isShowWarningDialog, String dialogErrorMessage) { 50 | this.isShowWarningDialog = isShowWarningDialog; 51 | color = new Color(243, 255, 59); 52 | this.dialogErrorMessage = dialogErrorMessage; 53 | tasks = new ArrayList<>(); 54 | } 55 | 56 | private synchronized void addTask(Validator.Task task) { 57 | if (tasks == null) { 58 | tasks = new ArrayList<>(); 59 | } 60 | tasks.add(task); 61 | } 62 | 63 | /** 64 | * add new task to validator 65 | * 66 | * @param comp input field 67 | * @param message error message to display in popup (currently not supported) 68 | * @param regex RegexUtils.XXXXX type of input to validate 69 | * @param isRequired is it required input field 70 | * @param showPopup currenlty not used 71 | */ 72 | public final synchronized void addTask(JComponent comp, String message, String regex, boolean isRequired, boolean showPopup) { 73 | addTask(new Task(comp, message, regex, isRequired, showPopup)); 74 | 75 | } 76 | 77 | /** 78 | * add new task to validator , non required field 79 | * 80 | * @param comp input field 81 | * @param message error message to display in popup (currently not supported) 82 | * @param regex RegexUtils.XXXXX type of input to validate 83 | */ 84 | public final void addTask(JComponent comp, String message, String regex) { 85 | addTask(new Task(comp, message, regex)); 86 | } 87 | 88 | /** 89 | * add new task to validator 90 | * 91 | * @param comp input field 92 | * @param message error message to display in popup (currently not supported) 93 | * @param regex RegexUtils.XXXXX type of input to validate 94 | * @param isRequired is it required input field 95 | */ 96 | public final void addTask(JComponent comp, String message, String regex, boolean isRequired) { 97 | addTask(new Task(comp, message, regex, isRequired)); 98 | } 99 | 100 | public final void resetErrors() { 101 | for (Validator.Task task : tasks) { 102 | task.hideErrorInfo(); 103 | } 104 | tasks.clear(); 105 | } 106 | 107 | public final boolean validate() { 108 | 109 | int errorCount = 0; 110 | int firstErrorCount = 0; 111 | // firstErrorField = null; 112 | for (Validator.Task task : tasks) { 113 | if (!validate(task)) { 114 | errorCount++; 115 | if (errorCount == 1) { 116 | firstErrorCount = errorCount - 1; 117 | } 118 | } 119 | } 120 | 121 | if (isShowWarningDialog && errorCount > 0) { 122 | // System.out.println(firstErrorField); 123 | WarningDialog warn = new WarningDialog(dialogErrorMessage); 124 | warn.showWarning(); 125 | // show focus in first component of validator task list 126 | JTextComponent jtc = (JTextComponent) tasks.get(firstErrorCount).comp; 127 | jtc.grabFocus(); 128 | 129 | } 130 | System.out.println("validating ... " + errorCount); 131 | return (errorCount == 0); 132 | } 133 | 134 | protected final boolean validationCriteria(Task task) { 135 | 136 | JComponent jc = task.comp; 137 | 138 | if (jc instanceof NumberTextField) { 139 | NumberTextField numF = (NumberTextField) jc; 140 | return (numF.isNonZeroEntered()); 141 | } 142 | // TextField, Combo.. 143 | if (jc instanceof JTextComponent) { 144 | String input = ((JTextComponent) jc).getText(); 145 | 146 | /* 147 | if value is empty and is not compulsory, then valid 148 | */ 149 | if (StringUtils.isEmpty(input) && !task.isRequired) { 150 | return true; 151 | } 152 | 153 | /* 154 | if value is empty and is compulsory, the invalid 155 | */ 156 | if (StringUtils.isEmpty(input) && task.isRequired) { 157 | return false; 158 | } 159 | 160 | if (RegexUtils.matches(input, task.regex)) { 161 | return true; 162 | } 163 | 164 | return false; 165 | 166 | } 167 | if (jc instanceof JDateChooser) { 168 | JDateChooser jdc = (JDateChooser) jc; 169 | Date inputDate = jdc.getDate(); 170 | 171 | /* 172 | If this field can be empty and current input date is empty , then 173 | it is ok. 174 | */ 175 | if (inputDate == null && !task.isRequired) { 176 | return true; 177 | } 178 | 179 | /* 180 | Input date should be in Specified format 181 | */ 182 | String pattern = jdc.getDateFormatString(); 183 | SimpleDateFormat format = new SimpleDateFormat(pattern); 184 | 185 | try { 186 | format.format(inputDate); 187 | return true; 188 | } catch (Exception e) { 189 | return false; 190 | } 191 | 192 | } 193 | if (jc instanceof SpecificationPanel) { 194 | return SpecificationPanel.isValidDataEntered(); 195 | } 196 | if (jc instanceof DataComboBox) { 197 | DataComboBox dcb = (DataComboBox) jc; 198 | return dcb.isValidDataChoosen(); 199 | } 200 | if (jc instanceof GTextArea) { 201 | GTextArea dcb = (GTextArea) jc; 202 | String input = dcb.getText(); 203 | 204 | if (StringUtils.isEmpty(input) && !task.isRequired) { 205 | return true; 206 | } 207 | 208 | /* 209 | if value is empty and is compulsory, the invalid 210 | */ 211 | if (StringUtils.isEmpty(input) && task.isRequired) { 212 | return false; 213 | } 214 | 215 | if (RegexUtils.matches(input, task.regex)) { 216 | return true; 217 | } 218 | } 219 | 220 | return false; 221 | } 222 | 223 | private boolean validate(Task task) { 224 | if (!validationCriteria(task)) { 225 | 226 | if (parent instanceof Verifier) ((Verifier) parent).validateFailed(); 227 | 228 | task.showPopup(); 229 | 230 | return false; 231 | } 232 | 233 | if (parent instanceof Verifier) ((Verifier) parent).validatePassed(); 234 | 235 | return true; 236 | } 237 | 238 | private class WarningDialog extends JOptionPane { 239 | 240 | public WarningDialog(Object message) { 241 | super(message, JOptionPane.ERROR_MESSAGE); 242 | 243 | } 244 | 245 | public final void showWarning() { 246 | JDialog d = this.createDialog(parent, "Error"); 247 | d.setVisible(true); 248 | } 249 | } 250 | 251 | private class Task { 252 | protected String regex; 253 | protected boolean isRequired; 254 | private JLabel image; 255 | private JLabel messageLabel; 256 | private JDialog popup; 257 | private JComponent comp; 258 | private boolean showPopup; 259 | 260 | /** 261 | * creates new validator task 262 | * 263 | * @param comp 264 | * @param message 265 | * @param regex 266 | * @param isRequired 267 | * @param showPopup 268 | */ 269 | public Task(JComponent comp, String message, String regex, boolean isRequired, boolean showPopup) { 270 | super(); 271 | this.comp = comp; 272 | 273 | this.regex = regex; 274 | this.isRequired = isRequired; 275 | this.showPopup = showPopup; 276 | if (showPopup) { 277 | popup = new JDialog(parent); 278 | 279 | messageLabel = new JLabel(message + " "); 280 | image = new JLabel(ResourceManager.getImageIcon("exclamation_mark_icon.png")); 281 | initPopupComponents(); 282 | } 283 | 284 | } 285 | 286 | public Task(JComponent comp, String message, String regex, boolean isRequired) { 287 | this(comp, message, regex, isRequired, true); 288 | } 289 | 290 | public Task(JComponent comp, String message, String regex) { 291 | this(comp, message, regex, false, true); 292 | } 293 | 294 | private void initPopupComponents() { 295 | popup.getContentPane().setLayout(new FlowLayout()); 296 | popup.setUndecorated(true); 297 | popup.getContentPane().setBackground(color); 298 | popup.getContentPane().add(image); 299 | popup.getContentPane().add(messageLabel); 300 | popup.setFocusableWindowState(false); 301 | popup.addMouseListener(new MouseAdapter() { 302 | 303 | public void mouseReleased(MouseEvent e) { 304 | popup.setVisible(false); 305 | } 306 | }); 307 | } 308 | 309 | private void showPopup() { 310 | if (comp instanceof JTextComponent || comp instanceof JDateChooser) 311 | comp.setBackground(Color.PINK); 312 | // set background at combo 313 | if (comp instanceof DataComboBox) { 314 | DataComboBox dc = (DataComboBox) comp; 315 | dc.setBackground(Color.PINK); 316 | 317 | } 318 | } 319 | 320 | private void hideErrorInfo() { 321 | if (comp instanceof JTextComponent || comp instanceof JDateChooser || comp instanceof DataComboBox) 322 | comp.setBackground(Color.WHITE); 323 | if (showPopup) popup.setVisible(false); 324 | } 325 | } 326 | } 327 | -------------------------------------------------------------------------------- /src/main/java/com/gt/uilib/inputverifier/Verifier.java: -------------------------------------------------------------------------------- 1 | package com.gt.uilib.inputverifier; 2 | 3 | public interface Verifier { 4 | void validateFailed(); // Called when a component has failed validation. 5 | 6 | void validatePassed(); // Called when a component has passed validation. 7 | } 8 | -------------------------------------------------------------------------------- /src/main/resources/hibernate.cfg.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | org.h2.Driver 9 | jdbc:h2:./inventoryApp.db;TRACE_LEVEL_FILE=0;TRACE_LEVEL_SYSTEM_OUT=0 10 | user 11 | pass 12 | 2 13 | org.hibernate.dialect.H2Dialect 14 | false 15 | true 16 | true 17 | true 18 | 19 | update 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /src/main/resources/images/a-menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/a-menu.png -------------------------------------------------------------------------------- /src/main/resources/images/about-menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/about-menu.png -------------------------------------------------------------------------------- /src/main/resources/images/about.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/about.png -------------------------------------------------------------------------------- /src/main/resources/images/backup-menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/backup-menu.png -------------------------------------------------------------------------------- /src/main/resources/images/backup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/backup.png -------------------------------------------------------------------------------- /src/main/resources/images/backuprestore-menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/backuprestore-menu.png -------------------------------------------------------------------------------- /src/main/resources/images/branch-menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/branch-menu.png -------------------------------------------------------------------------------- /src/main/resources/images/ca-icon48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/ca-icon48.png -------------------------------------------------------------------------------- /src/main/resources/images/createButton.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/createButton.png -------------------------------------------------------------------------------- /src/main/resources/images/createButton2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/createButton2.png -------------------------------------------------------------------------------- /src/main/resources/images/exclamation_mark_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/exclamation_mark_icon.png -------------------------------------------------------------------------------- /src/main/resources/images/exit-menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/exit-menu.png -------------------------------------------------------------------------------- /src/main/resources/images/exit-off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/exit-off.png -------------------------------------------------------------------------------- /src/main/resources/images/exit-on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/exit-on.png -------------------------------------------------------------------------------- /src/main/resources/images/exit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/exit.png -------------------------------------------------------------------------------- /src/main/resources/images/find-off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/find-off.png -------------------------------------------------------------------------------- /src/main/resources/images/find-on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/find-on.png -------------------------------------------------------------------------------- /src/main/resources/images/help-menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/help-menu.png -------------------------------------------------------------------------------- /src/main/resources/images/home-off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/home-off.png -------------------------------------------------------------------------------- /src/main/resources/images/home-on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/home-on.png -------------------------------------------------------------------------------- /src/main/resources/images/itementry-off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/itementry-off.png -------------------------------------------------------------------------------- /src/main/resources/images/itementry-on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/itementry-on.png -------------------------------------------------------------------------------- /src/main/resources/images/itemtransfer-off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/itemtransfer-off.png -------------------------------------------------------------------------------- /src/main/resources/images/itemtransfer-on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/itemtransfer-on.png -------------------------------------------------------------------------------- /src/main/resources/images/loginuser.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/loginuser.png -------------------------------------------------------------------------------- /src/main/resources/images/logo2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/logo2.png -------------------------------------------------------------------------------- /src/main/resources/images/logout-menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/logout-menu.png -------------------------------------------------------------------------------- /src/main/resources/images/logout-off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/logout-off.png -------------------------------------------------------------------------------- /src/main/resources/images/logout-on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/logout-on.png -------------------------------------------------------------------------------- /src/main/resources/images/managerButton.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/managerButton.png -------------------------------------------------------------------------------- /src/main/resources/images/managerButton2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/managerButton2.png -------------------------------------------------------------------------------- /src/main/resources/images/menu1-off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/menu1-off.png -------------------------------------------------------------------------------- /src/main/resources/images/menu1-on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/menu1-on.png -------------------------------------------------------------------------------- /src/main/resources/images/menu2-off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/menu2-off.png -------------------------------------------------------------------------------- /src/main/resources/images/menu2-on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/menu2-on.png -------------------------------------------------------------------------------- /src/main/resources/images/printer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/printer.png -------------------------------------------------------------------------------- /src/main/resources/images/return-off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/return-off.png -------------------------------------------------------------------------------- /src/main/resources/images/return-on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/return-on.png -------------------------------------------------------------------------------- /src/main/resources/images/return.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/return.png -------------------------------------------------------------------------------- /src/main/resources/images/returna-off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/returna-off.png -------------------------------------------------------------------------------- /src/main/resources/images/returna-on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/returna-on.png -------------------------------------------------------------------------------- /src/main/resources/images/returnquery-off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/returnquery-off.png -------------------------------------------------------------------------------- /src/main/resources/images/returnquery-on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/returnquery-on.png -------------------------------------------------------------------------------- /src/main/resources/images/returnquery.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/returnquery.png -------------------------------------------------------------------------------- /src/main/resources/images/returnquerya-off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/returnquerya-off.png -------------------------------------------------------------------------------- /src/main/resources/images/returnquerya-on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/returnquerya-on.png -------------------------------------------------------------------------------- /src/main/resources/images/setting-menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/setting-menu.png -------------------------------------------------------------------------------- /src/main/resources/images/setting-off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/setting-off.png -------------------------------------------------------------------------------- /src/main/resources/images/setting-on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/setting-on.png -------------------------------------------------------------------------------- /src/main/resources/images/sfind-menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/sfind-menu.png -------------------------------------------------------------------------------- /src/main/resources/images/shelp-menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/shelp-menu.png -------------------------------------------------------------------------------- /src/main/resources/images/sitementry-menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/sitementry-menu.png -------------------------------------------------------------------------------- /src/main/resources/images/sitemnikasha-menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/sitemnikasha-menu.png -------------------------------------------------------------------------------- /src/main/resources/images/sstock-menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/sstock-menu.png -------------------------------------------------------------------------------- /src/main/resources/images/stock-off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/stock-off.png -------------------------------------------------------------------------------- /src/main/resources/images/stock-on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/stock-on.png -------------------------------------------------------------------------------- /src/main/resources/images/todoButton.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/todoButton.png -------------------------------------------------------------------------------- /src/main/resources/images/todoButton2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/todoButton2.png -------------------------------------------------------------------------------- /src/main/resources/images/user-menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/user-menu.png -------------------------------------------------------------------------------- /src/main/resources/images/validator-error-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/validator-error-icon.png -------------------------------------------------------------------------------- /src/main/resources/images/vendor-menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/vendor-menu.png -------------------------------------------------------------------------------- /src/main/resources/images/vendor-off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/vendor-off.png -------------------------------------------------------------------------------- /src/main/resources/images/vendor-on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtiwari333/java-inventory-management-system-swing-hibernate/92c4246007f418c4ce09eac923f19527cfd55246/src/main/resources/images/vendor-on.png -------------------------------------------------------------------------------- /src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.logger.org.hibernate=INFO, hb 2 | log4j.logger.org.hibernate.SQL=DEBUG 3 | log4j.logger.org.hibernate.type=INFO 4 | log4j.logger.org.hibernate.hql.ast.AST=info 5 | log4j.logger.org.hibernate.tool.hbm2ddl=warn 6 | log4j.logger.org.hibernate.hql=INFO 7 | log4j.logger.org.hibernate.cache=info 8 | log4j.logger.org.hibernate.jdbc=INFO 9 | log4j.logger.org.h2.jdbc=ERROR 10 | 11 | log4j.appender.hb=org.apache.log4j.ConsoleAppender 12 | log4j.appender.hb.layout=org.apache.log4j.PatternLayout 13 | log4j.appender.hb.layout.ConversionPattern=HibernateLog --> %d{HH:mm:ss} %-5p %c - %m%n 14 | log4j.appender.hb.Threshold=INFO --------------------------------------------------------------------------------