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
--------------------------------------------------------------------------------