mirror of
https://github.com/robertvokac/time-calc.git
synced 2025-03-25 07:27:49 +01:00
Added several improvements
This commit is contained in:
parent
41cfc06b24
commit
cfc945d182
@ -179,6 +179,7 @@ Smileys can be colored or white-black (can be set in configuration)
|
|||||||
* CTRL + P - Decrease pause
|
* CTRL + P - Decrease pause
|
||||||
* SHIFT + C - Increase or decrease of time is change by 1 hour
|
* SHIFT + C - Increase or decrease of time is change by 1 hour
|
||||||
* CTRL + C - Increase or decrease of time is change by 1 minute
|
* CTRL + C - Increase or decrease of time is change by 1 minute
|
||||||
|
* CTRL + E - Save arrival, overtime, working time, pause time and note
|
||||||
|
|
||||||
## Command button
|
## Command button
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import org.nanoboot.utils.timecalc.swing.common.MainWindow;
|
|||||||
import org.nanoboot.utils.timecalc.swing.progress.Time;
|
import org.nanoboot.utils.timecalc.swing.progress.Time;
|
||||||
import org.nanoboot.utils.timecalc.utils.common.FileConstants;
|
import org.nanoboot.utils.timecalc.utils.common.FileConstants;
|
||||||
import org.nanoboot.utils.timecalc.utils.common.Jokes;
|
import org.nanoboot.utils.timecalc.utils.common.Jokes;
|
||||||
|
import org.nanoboot.utils.timecalc.utils.common.TTime;
|
||||||
import org.nanoboot.utils.timecalc.utils.common.Utils;
|
import org.nanoboot.utils.timecalc.utils.common.Utils;
|
||||||
import org.nanoboot.utils.timecalc.utils.property.IntegerProperty;
|
import org.nanoboot.utils.timecalc.utils.property.IntegerProperty;
|
||||||
|
|
||||||
@ -14,7 +15,6 @@ import java.io.FileInputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import org.nanoboot.utils.timecalc.utils.common.TTime;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Robert Vokac
|
* @author Robert Vokac
|
||||||
@ -27,19 +27,19 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
|
|||||||
|
|
||||||
private final TimeCalcConfiguration timeCalcConfiguration;
|
private final TimeCalcConfiguration timeCalcConfiguration;
|
||||||
private final TimeCalcApp timeCalcApp;
|
private final TimeCalcApp timeCalcApp;
|
||||||
private final MainWindow window;
|
private final MainWindow mainWindow;
|
||||||
private final Time time;
|
private final Time time;
|
||||||
private boolean changeByOneHour = false;
|
private boolean changeByOneHour = false;
|
||||||
|
|
||||||
public TimeCalcKeyAdapter(
|
public TimeCalcKeyAdapter(
|
||||||
TimeCalcConfiguration timeCalcConfiguration,
|
TimeCalcConfiguration timeCalcConfiguration,
|
||||||
TimeCalcApp timeCalcApp,
|
TimeCalcApp timeCalcApp,
|
||||||
MainWindow window,
|
MainWindow mainWindow,
|
||||||
Time time
|
Time time
|
||||||
) {
|
) {
|
||||||
this.timeCalcConfiguration = timeCalcConfiguration;
|
this.timeCalcConfiguration = timeCalcConfiguration;
|
||||||
this.timeCalcApp = timeCalcApp;
|
this.timeCalcApp = timeCalcApp;
|
||||||
this.window = window;
|
this.mainWindow = mainWindow;
|
||||||
this.time = time;
|
this.time = time;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,16 +48,22 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
|
|||||||
boolean shiftDown = e.isShiftDown();
|
boolean shiftDown = e.isShiftDown();
|
||||||
boolean ctrlDown = e.isControlDown();
|
boolean ctrlDown = e.isControlDown();
|
||||||
boolean altDown = e.isAltDown();
|
boolean altDown = e.isAltDown();
|
||||||
boolean metaDown = e.isMetaDown();
|
//boolean metaDown = e.isMetaDown();
|
||||||
if (!shiftDown && !ctrlDown && !altDown) {
|
if (!shiftDown && !ctrlDown && !altDown /*&& !metaDown*/) {
|
||||||
processKeyCode(keyCode);
|
processKeyCode(keyCode);
|
||||||
} else {
|
} else
|
||||||
processTestModeKeyCode(keyCode, shiftDown, ctrlDown, altDown);
|
//if (!metaDown)
|
||||||
|
{
|
||||||
|
processShifCtrlAltModeKeyCodes(keyCode, shiftDown, ctrlDown,
|
||||||
|
altDown);
|
||||||
}
|
}
|
||||||
|
// else {
|
||||||
|
// processMetaKeyCodes(keyCode);
|
||||||
|
// }
|
||||||
//meta key ???
|
//meta key ???
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processTestModeKeyCode(int keyCode, boolean shiftDown,
|
private void processShifCtrlAltModeKeyCodes(int keyCode, boolean shiftDown,
|
||||||
boolean ctrlDown, boolean altDown) {
|
boolean ctrlDown, boolean altDown) {
|
||||||
if (shiftDown && ctrlDown) {
|
if (shiftDown && ctrlDown) {
|
||||||
Utils.showNotification("Following key shortcut is not supported: SHIFT + CTRL");
|
Utils.showNotification("Following key shortcut is not supported: SHIFT + CTRL");
|
||||||
@ -119,40 +125,40 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case KeyEvent.VK_A: {
|
case KeyEvent.VK_A: {
|
||||||
//Utils.showNotification((increase ? "Increasing" : (decrease ? "Decreasing" : "Reseting")) + " millisecond.");
|
|
||||||
if (increase) {
|
if (increase) {
|
||||||
window.increaseArrival(changeTTime);
|
mainWindow.increaseArrival(changeTTime);
|
||||||
}
|
}
|
||||||
if (decrease) {
|
if (decrease) {
|
||||||
window.decreaseArrival(changeTTime);
|
mainWindow.decreaseArrival(changeTTime);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case KeyEvent.VK_O: {
|
case KeyEvent.VK_O: {
|
||||||
//Utils.showNotification((increase ? "Increasing" : (decrease ? "Decreasing" : "Reseting")) + " millisecond.");
|
|
||||||
if (increase) {
|
if (increase) {
|
||||||
window.increaseOvertime(changeTTime);
|
mainWindow.increaseOvertime(changeTTime);
|
||||||
}
|
}
|
||||||
if (decrease) {
|
if (decrease) {
|
||||||
window.decreaseOvertime(changeTTime);
|
mainWindow.decreaseOvertime(changeTTime);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case KeyEvent.VK_W: {
|
case KeyEvent.VK_W: {
|
||||||
if (increase) {
|
if (increase) {
|
||||||
window.increaseWork(changeTTime);
|
mainWindow.increaseWork(changeTTime);
|
||||||
}
|
}
|
||||||
if (decrease) {
|
if (decrease) {
|
||||||
window.decreaseWork(changeTTime);
|
mainWindow.decreaseWork(changeTTime);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case KeyEvent.VK_P: {
|
case KeyEvent.VK_P: {
|
||||||
if (increase) {
|
if (increase) {
|
||||||
window.increasePause(changeTTime);
|
mainWindow.increasePause(changeTTime);
|
||||||
}
|
}
|
||||||
if (decrease) {
|
if (decrease) {
|
||||||
window.decreasePause(changeTTime);
|
mainWindow.decreasePause(changeTTime);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -161,6 +167,12 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
|
|||||||
Utils.showNotification("Time will be changed by 1 " + (increase ? "hour" : "minute") + ".");
|
Utils.showNotification("Time will be changed by 1 " + (increase ? "hour" : "minute") + ".");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case KeyEvent.VK_E: {
|
||||||
|
if(ctrlDown) {
|
||||||
|
mainWindow.doSaveButtonClick();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
// Utils.showNotification(
|
// Utils.showNotification(
|
||||||
// "Unsupported key was pressed. There is no key shortcut for this key: "
|
// "Unsupported key was pressed. There is no key shortcut for this key: "
|
||||||
@ -168,6 +180,16 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// private void processMetaKeyCodes(int keyCode) {
|
||||||
|
//
|
||||||
|
// switch (keyCode) {
|
||||||
|
// case KeyEvent.VK_S: {
|
||||||
|
//
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// default:
|
||||||
|
// }
|
||||||
|
// }
|
||||||
private void updateProperty(IntegerProperty integerProperty,
|
private void updateProperty(IntegerProperty integerProperty,
|
||||||
boolean increase, boolean decrease, boolean reset, int timeUnit) {
|
boolean increase, boolean decrease, boolean reset, int timeUnit) {
|
||||||
int currentValue = integerProperty.getValue();
|
int currentValue = integerProperty.getValue();
|
||||||
@ -402,11 +424,11 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case KeyEvent.VK_F2: {
|
case KeyEvent.VK_F2: {
|
||||||
window.doCommand();
|
mainWindow.doCommand();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case KeyEvent.VK_R: {
|
case KeyEvent.VK_R: {
|
||||||
window.doRestart();
|
mainWindow.doRestart();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case KeyEvent.VK_N: {
|
case KeyEvent.VK_N: {
|
||||||
@ -414,20 +436,20 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case KeyEvent.VK_W: {
|
case KeyEvent.VK_W: {
|
||||||
window.openWorkDaysWindow();
|
mainWindow.openWorkDaysWindow();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case KeyEvent.VK_A: {
|
case KeyEvent.VK_A: {
|
||||||
window.openActivitiesWindow();
|
mainWindow.openActivitiesWindow();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case KeyEvent.VK_X: {
|
case KeyEvent.VK_X: {
|
||||||
window.doExit();
|
mainWindow.doExit();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case KeyEvent.VK_S: {
|
case KeyEvent.VK_S: {
|
||||||
window.openConfigWindow();
|
mainWindow.openConfigWindow();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -441,16 +463,16 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
|
|||||||
|
|
||||||
case KeyEvent.VK_P:
|
case KeyEvent.VK_P:
|
||||||
case KeyEvent.VK_F1: {
|
case KeyEvent.VK_F1: {
|
||||||
window.openHelpWindow();
|
mainWindow.openHelpWindow();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case KeyEvent.VK_U: {
|
case KeyEvent.VK_U: {
|
||||||
window.doEnableEverything();
|
mainWindow.doEnableEverything();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
case KeyEvent.VK_I: {
|
case KeyEvent.VK_I: {
|
||||||
window.doDisableAlmostEverything();
|
mainWindow.doDisableAlmostEverything();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case KeyEvent.VK_E: {
|
case KeyEvent.VK_E: {
|
||||||
@ -623,7 +645,7 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window.repaint();
|
mainWindow.repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void switchProfile(boolean previous, boolean next) {
|
private void switchProfile(boolean previous, boolean next) {
|
||||||
|
@ -17,7 +17,7 @@ import lombok.ToString;
|
|||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class WorkingDay {
|
public class WorkingDay {
|
||||||
|
|
||||||
public static final String NODATA = "nodata";
|
private static final String NODATA = "nodata";
|
||||||
|
|
||||||
public static String createId(int year, int month, int day) {
|
public static String createId(int year, int month, int day) {
|
||||||
return (year + "-" + (month < 10 ? "0" : "") + month + "-" + (day < 10 ? "0" : "") + day);
|
return (year + "-" + (month < 10 ? "0" : "") + month + "-" + (day < 10 ? "0" : "") + day);
|
||||||
@ -35,6 +35,10 @@ public class WorkingDay {
|
|||||||
private int workingTimeInMinutes;
|
private int workingTimeInMinutes;
|
||||||
private int pauseTimeInMinutes;
|
private int pauseTimeInMinutes;
|
||||||
private String note;
|
private String note;
|
||||||
|
private boolean timeOff;
|
||||||
|
|
||||||
|
public boolean isThisDayTimeOff() {
|
||||||
|
return timeOff || this.note.equals(NODATA);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,18 @@ public class WorkingDayForStats extends WorkingDay {
|
|||||||
private final TTime pause;
|
private final TTime pause;
|
||||||
private final TTime departure;
|
private final TTime departure;
|
||||||
|
|
||||||
|
public static void fillStatisticsColumns(List<WorkingDayForStats> list) {
|
||||||
|
//todo
|
||||||
|
}
|
||||||
|
public static List<WorkingDayForStats> createList(List<WorkingDay> list) {
|
||||||
|
List<WorkingDayForStats> result = new ArrayList<>();
|
||||||
|
for (WorkingDay wd : list) {
|
||||||
|
WorkingDayForStats wdfs = new WorkingDayForStats(wd);
|
||||||
|
result.add(wdfs);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public WorkingDayForStats(WorkingDay workingDay) {
|
public WorkingDayForStats(WorkingDay workingDay) {
|
||||||
this(workingDay.getId(),
|
this(workingDay.getId(),
|
||||||
workingDay.getYear(),
|
workingDay.getYear(),
|
||||||
@ -39,18 +51,19 @@ public class WorkingDayForStats extends WorkingDay {
|
|||||||
workingDay.getOvertimeMinute(),
|
workingDay.getOvertimeMinute(),
|
||||||
workingDay.getWorkingTimeInMinutes(),
|
workingDay.getWorkingTimeInMinutes(),
|
||||||
workingDay.getPauseTimeInMinutes(),
|
workingDay.getPauseTimeInMinutes(),
|
||||||
workingDay.getNote());
|
workingDay.getNote(),
|
||||||
|
workingDay.isTimeOff());
|
||||||
}
|
}
|
||||||
|
|
||||||
public WorkingDayForStats(String id, int year, int month, int day, int arrivalHour, int arrivalMinute, int overtimeHour, int overtimeMinute, int workingTimeInMinutes, int pauseTimeInMinutes, String note) {
|
public WorkingDayForStats(String id, int year, int month, int day, int arrivalHour, int arrivalMinute, int overtimeHour, int overtimeMinute, int workingTimeInMinutes, int pauseTimeInMinutes, String note, boolean timeOff) {
|
||||||
super(id, year, month, day, arrivalHour, arrivalMinute, overtimeHour, overtimeMinute, workingTimeInMinutes, pauseTimeInMinutes, note);
|
super(id, year, month, day, arrivalHour, arrivalMinute, overtimeHour, overtimeMinute, workingTimeInMinutes, pauseTimeInMinutes, note, timeOff);
|
||||||
this.arrival = this.getNote().equals(WorkingDay.NODATA) ? null : new TTime(arrivalHour, arrivalMinute);
|
this.arrival = this.isThisDayTimeOff() ? null : new TTime(arrivalHour, arrivalMinute);
|
||||||
this.overtime = this.getNote().equals(WorkingDay.NODATA) ? null : new TTime(overtimeHour, overtimeMinute);
|
this.overtime = this.isThisDayTimeOff() ? null : new TTime(overtimeHour, overtimeMinute);
|
||||||
this.work = this.getNote().equals(WorkingDay.NODATA) ? null : TTime.ofMinutes(workingTimeInMinutes);
|
this.work = this.isThisDayTimeOff() ? null : TTime.ofMinutes(workingTimeInMinutes);
|
||||||
this.pause = this.getNote().equals(WorkingDay.NODATA) ? null : TTime.ofMinutes(pauseTimeInMinutes);
|
this.pause = this.isThisDayTimeOff() ? null : TTime.ofMinutes(pauseTimeInMinutes);
|
||||||
this.departure = this.getNote().equals(WorkingDay.NODATA) ? null : this.arrival.add(work).add(pause).add(overtime);
|
this.departure = this.isThisDayTimeOff() ? null : this.arrival.add(work).add(pause).add(overtime);
|
||||||
this.departureHour = this.getNote().equals(WorkingDay.NODATA) ? -1 : departure.getHour();
|
this.departureHour = this.isThisDayTimeOff() ? -1 : departure.getHour();
|
||||||
this.departureMinute = this.getNote().equals(WorkingDay.NODATA) ? -1 : departure.getMinute();
|
this.departureMinute = this.isThisDayTimeOff() ? -1 : departure.getMinute();
|
||||||
Calendar cal = Calendar.getInstance();
|
Calendar cal = Calendar.getInstance();
|
||||||
cal.set(Calendar.YEAR, year);
|
cal.set(Calendar.YEAR, year);
|
||||||
cal.set(Calendar.MONTH, month - 1);
|
cal.set(Calendar.MONTH, month - 1);
|
||||||
@ -59,13 +72,6 @@ public class WorkingDayForStats extends WorkingDay {
|
|||||||
this.dayOfWeek = dayOfWeek == 1 ? 7 : dayOfWeek - 1;
|
this.dayOfWeek = dayOfWeek == 1 ? 7 : dayOfWeek - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<WorkingDayForStats> createList(List<WorkingDay> list) {
|
|
||||||
List<WorkingDayForStats> result = new ArrayList<>();
|
|
||||||
for (WorkingDay wd : list) {
|
|
||||||
WorkingDayForStats wdfs = new WorkingDayForStats(wd);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
public String getDayOfWeekAsString() {
|
public String getDayOfWeekAsString() {
|
||||||
return LocalDate.of(getYear(), getMonth() ,getDay()).getDayOfWeek().toString();
|
return LocalDate.of(getYear(), getMonth() ,getDay()).getDayOfWeek().toString();
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
package org.nanoboot.utils.timecalc.persistence.api;
|
package org.nanoboot.utils.timecalc.persistence.api;
|
||||||
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
|
||||||
|
import org.nanoboot.utils.timecalc.app.TimeCalcException;
|
||||||
import org.nanoboot.utils.timecalc.entity.WorkingDay;
|
import org.nanoboot.utils.timecalc.entity.WorkingDay;
|
||||||
|
import org.nanoboot.utils.timecalc.utils.common.Utils;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -29,5 +32,18 @@ public interface WorkingDayRepositoryApi {
|
|||||||
cal.get(Calendar.DAY_OF_MONTH)
|
cal.get(Calendar.DAY_OF_MONTH)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
public List<String> getYears();
|
List<String> getYears();
|
||||||
|
void delete(int year, int month, int day);
|
||||||
|
default void delete(WorkingDay wd) {
|
||||||
|
delete(wd.getId());
|
||||||
|
}
|
||||||
|
default void delete(String id) {
|
||||||
|
String[] array = id.split("-");
|
||||||
|
if(array.length != 3) {
|
||||||
|
TimeCalcException e = new TimeCalcException("Invalid date: " + id);
|
||||||
|
Utils.showNotification(new TimeCalcException("Invalid date: " + id));
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
delete(Integer.parseInt(array[0]),Integer.parseInt(array[1]),Integer.parseInt(array[2]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ package org.nanoboot.utils.timecalc.persistence.impl.sqlite;
|
|||||||
*
|
*
|
||||||
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
|
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
|
||||||
*/
|
*/
|
||||||
class VersionTable {
|
public class VersionTable {
|
||||||
|
|
||||||
public static final String TABLE_NAME = "VERSION";
|
public static final String TABLE_NAME = "VERSION";
|
||||||
|
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
package org.nanoboot.utils.timecalc.persistence.impl.sqlite;
|
package org.nanoboot.utils.timecalc.persistence.impl.sqlite;
|
||||||
|
|
||||||
|
import org.nanoboot.utils.timecalc.app.TimeCalcException;
|
||||||
|
import org.nanoboot.utils.timecalc.entity.WorkingDay;
|
||||||
|
import org.nanoboot.utils.timecalc.persistence.api.WorkingDayRepositoryApi;
|
||||||
|
import org.nanoboot.utils.timecalc.utils.common.Utils;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import org.nanoboot.utils.timecalc.entity.WorkingDay;
|
|
||||||
import org.nanoboot.utils.timecalc.persistence.api.WorkingDayRepositoryApi;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.nanoboot.utils.timecalc.app.TimeCalcException;
|
|
||||||
import org.nanoboot.utils.timecalc.utils.common.Utils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Robert Vokac
|
* @author Robert Vokac
|
||||||
@ -35,7 +35,7 @@ public class WorkingDayRepositorySQLiteImpl implements WorkingDayRepositoryApi {
|
|||||||
sb
|
sb
|
||||||
.append("INSERT INTO ")
|
.append("INSERT INTO ")
|
||||||
.append(WorkingDayTable.TABLE_NAME)
|
.append(WorkingDayTable.TABLE_NAME)
|
||||||
.append(" VALUES (?,?,?,?, ?,?,?,?, ?,?,?)");
|
.append(" VALUES (?,?,?,?, ?,?,?,?, ?,?,?,?)");
|
||||||
|
|
||||||
String sql = sb.toString();
|
String sql = sb.toString();
|
||||||
|
|
||||||
@ -56,6 +56,7 @@ public class WorkingDayRepositorySQLiteImpl implements WorkingDayRepositoryApi {
|
|||||||
stmt.setInt(++i, workingDay.getWorkingTimeInMinutes());
|
stmt.setInt(++i, workingDay.getWorkingTimeInMinutes());
|
||||||
stmt.setInt(++i, workingDay.getPauseTimeInMinutes());
|
stmt.setInt(++i, workingDay.getPauseTimeInMinutes());
|
||||||
stmt.setString(++i, workingDay.getNote());
|
stmt.setString(++i, workingDay.getNote());
|
||||||
|
stmt.setInt(++i, workingDay.isTimeOff() ? 1 : 0);
|
||||||
|
|
||||||
//
|
//
|
||||||
stmt.execute();
|
stmt.execute();
|
||||||
@ -124,13 +125,20 @@ public class WorkingDayRepositorySQLiteImpl implements WorkingDayRepositoryApi {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(WorkingDay workingDay) {
|
public void update(WorkingDay workingDay) {
|
||||||
if(list(workingDay.getYear(), workingDay.getMonth(),workingDay.getDay()).isEmpty()) {
|
List<WorkingDay> list =
|
||||||
|
list(workingDay.getYear(), workingDay.getMonth(),
|
||||||
|
workingDay.getDay());
|
||||||
|
if(list.isEmpty()) {
|
||||||
create(workingDay);
|
create(workingDay);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("Going to update: " + workingDay.toString());
|
System.out.println("Going to update: " + workingDay.toString());
|
||||||
|
|
||||||
|
if(list.get(0).toString().equals(workingDay.toString())) {
|
||||||
|
System.out.println("Nothing to update.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if(!Utils.askYesNo(null, "Do you want to update this Working Day? " + workingDay, "Update of Working Day")) {
|
if(!Utils.askYesNo(null, "Do you want to update this Working Day? " + workingDay, "Update of Working Day")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -145,7 +153,8 @@ public class WorkingDayRepositorySQLiteImpl implements WorkingDayRepositoryApi {
|
|||||||
.append(WorkingDayTable.OVERTIME_MINUTE).append("=?, ")
|
.append(WorkingDayTable.OVERTIME_MINUTE).append("=?, ")
|
||||||
.append(WorkingDayTable.WORKING_TIME_IN_MINUTES).append("=?, ")
|
.append(WorkingDayTable.WORKING_TIME_IN_MINUTES).append("=?, ")
|
||||||
.append(WorkingDayTable.PAUSE_TIME_IN_MINUTES).append("=?, ")
|
.append(WorkingDayTable.PAUSE_TIME_IN_MINUTES).append("=?, ")
|
||||||
.append(WorkingDayTable.NOTE).append("=? ")
|
.append(WorkingDayTable.NOTE).append("=?, ")
|
||||||
|
.append(WorkingDayTable.TIME_OFF).append("=? ")
|
||||||
.append(" WHERE ").append(
|
.append(" WHERE ").append(
|
||||||
WorkingDayTable.ID).append("=?");
|
WorkingDayTable.ID).append("=?");
|
||||||
|
|
||||||
@ -161,6 +170,7 @@ public class WorkingDayRepositorySQLiteImpl implements WorkingDayRepositoryApi {
|
|||||||
stmt.setInt(++i, workingDay.getWorkingTimeInMinutes());
|
stmt.setInt(++i, workingDay.getWorkingTimeInMinutes());
|
||||||
stmt.setInt(++i, workingDay.getPauseTimeInMinutes());
|
stmt.setInt(++i, workingDay.getPauseTimeInMinutes());
|
||||||
stmt.setString(++i, workingDay.getNote());
|
stmt.setString(++i, workingDay.getNote());
|
||||||
|
stmt.setInt(++i, workingDay.isTimeOff() ? 1 : 0);
|
||||||
|
|
||||||
stmt.setString(++i, workingDay.getId());
|
stmt.setString(++i, workingDay.getId());
|
||||||
|
|
||||||
@ -193,7 +203,8 @@ public class WorkingDayRepositorySQLiteImpl implements WorkingDayRepositoryApi {
|
|||||||
rs.getInt(WorkingDayTable.OVERTIME_MINUTE),
|
rs.getInt(WorkingDayTable.OVERTIME_MINUTE),
|
||||||
rs.getInt(WorkingDayTable.WORKING_TIME_IN_MINUTES),
|
rs.getInt(WorkingDayTable.WORKING_TIME_IN_MINUTES),
|
||||||
rs.getInt(WorkingDayTable.PAUSE_TIME_IN_MINUTES),
|
rs.getInt(WorkingDayTable.PAUSE_TIME_IN_MINUTES),
|
||||||
rs.getString(WorkingDayTable.NOTE)
|
rs.getString(WorkingDayTable.NOTE),
|
||||||
|
rs.getInt(WorkingDayTable.TIME_OFF) != 0
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,4 +247,37 @@ public class WorkingDayRepositorySQLiteImpl implements WorkingDayRepositoryApi {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void delete(int year, int month, int day) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb
|
||||||
|
.append("DELETE ").append(" FROM ")
|
||||||
|
.append(WorkingDayTable.TABLE_NAME);
|
||||||
|
sb.append(" WHERE ");
|
||||||
|
sb.append(WorkingDayTable.YEAR).append("=? AND ");
|
||||||
|
sb.append(WorkingDayTable.MONTH).append("=? AND ");
|
||||||
|
;
|
||||||
|
sb.append(WorkingDayTable.DAY).append("=? ");
|
||||||
|
;
|
||||||
|
|
||||||
|
String sql = sb.toString();
|
||||||
|
int i = 0;
|
||||||
|
try (
|
||||||
|
Connection connection = sqliteConnectionFactory
|
||||||
|
.createConnection();
|
||||||
|
PreparedStatement stmt = connection.prepareStatement(sql);) {
|
||||||
|
stmt.setInt(++i, year);
|
||||||
|
stmt.setInt(++i, month);
|
||||||
|
stmt.setInt(++i, day);
|
||||||
|
stmt.execute();
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
System.out.println(e.getMessage());
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} catch (ClassNotFoundException ex) {
|
||||||
|
System.out.println(ex.getMessage());
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ package org.nanoboot.utils.timecalc.persistence.impl.sqlite;
|
|||||||
*
|
*
|
||||||
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
|
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
|
||||||
*/
|
*/
|
||||||
class WorkingDayTable {
|
public class WorkingDayTable {
|
||||||
|
|
||||||
public static final String TABLE_NAME = "WORKING_DAY";
|
public static final String TABLE_NAME = "WORKING_DAY";
|
||||||
|
|
||||||
@ -38,6 +38,7 @@ class WorkingDayTable {
|
|||||||
public static final String WORKING_TIME_IN_MINUTES = "WORKING_TIME_IN_MINUTES";
|
public static final String WORKING_TIME_IN_MINUTES = "WORKING_TIME_IN_MINUTES";
|
||||||
public static final String PAUSE_TIME_IN_MINUTES = "PAUSE_TIME_IN_MINUTES";
|
public static final String PAUSE_TIME_IN_MINUTES = "PAUSE_TIME_IN_MINUTES";
|
||||||
public static final String NOTE = "NOTE";
|
public static final String NOTE = "NOTE";
|
||||||
|
public static final String TIME_OFF = "TIME_OFF";
|
||||||
|
|
||||||
private WorkingDayTable() {
|
private WorkingDayTable() {
|
||||||
//Not meant to be instantiated.
|
//Not meant to be instantiated.
|
||||||
|
@ -64,9 +64,11 @@ public class MainWindow extends TWindow {
|
|||||||
private final TTextField workingTimeTextField;
|
private final TTextField workingTimeTextField;
|
||||||
private final TTextField pauseTimeTextField;
|
private final TTextField pauseTimeTextField;
|
||||||
private final TTextField noteTextField;
|
private final TTextField noteTextField;
|
||||||
|
private final TCheckBox timeOffCheckBox = new TCheckBox("Time off");
|
||||||
private final TTextField departureTextField;
|
private final TTextField departureTextField;
|
||||||
private final TTextField elapsedTextField;
|
private final TTextField elapsedTextField;
|
||||||
private final TTextField remainingTextField;
|
private final TTextField remainingTextField;
|
||||||
|
private final TButton saveButton;
|
||||||
private HelpWindow helpWindow = null;
|
private HelpWindow helpWindow = null;
|
||||||
private ConfigWindow configWindow = null;
|
private ConfigWindow configWindow = null;
|
||||||
private ActivitiesWindow activitiesWindow = null;
|
private ActivitiesWindow activitiesWindow = null;
|
||||||
@ -79,7 +81,7 @@ public class MainWindow extends TWindow {
|
|||||||
this.overtimeTextField = new TTextField();
|
this.overtimeTextField = new TTextField();
|
||||||
this.workingTimeTextField = new TTextField("8:00");
|
this.workingTimeTextField = new TTextField("8:00");
|
||||||
this.pauseTimeTextField = new TTextField("0:30");
|
this.pauseTimeTextField = new TTextField("0:30");
|
||||||
this.noteTextField = new TTextField("", 160);
|
this.noteTextField = new TTextField("", 120);
|
||||||
this.departureTextField = new TTextField();
|
this.departureTextField = new TTextField();
|
||||||
this.elapsedTextField = new TTextField("", 100);
|
this.elapsedTextField = new TTextField("", 100);
|
||||||
this.remainingTextField = new TTextField("", 100);
|
this.remainingTextField = new TTextField("", 100);
|
||||||
@ -272,11 +274,12 @@ public class MainWindow extends TWindow {
|
|||||||
|
|
||||||
pauseTimeTextField.setBoundsFromLeft(pauseTimeInMinutesFieldLabel);
|
pauseTimeTextField.setBoundsFromLeft(pauseTimeInMinutesFieldLabel);
|
||||||
//
|
//
|
||||||
TLabel noteTextFieldLabel = new TLabel("Note:");
|
TLabel noteTextFieldLabel = new TLabel("Note:", 40);
|
||||||
noteTextFieldLabel.setBoundsFromLeft(pauseTimeTextField);
|
noteTextFieldLabel.setBoundsFromLeft(pauseTimeTextField);
|
||||||
|
|
||||||
noteTextField.setBoundsFromLeft(noteTextFieldLabel);
|
noteTextField.setBoundsFromLeft(noteTextFieldLabel);
|
||||||
//half day, pause time in minutes, note
|
timeOffCheckBox.setBoundsFromLeft(noteTextField);
|
||||||
|
//
|
||||||
arrivalTextField.setEditable(false);
|
arrivalTextField.setEditable(false);
|
||||||
overtimeTextField.setEditable(false);
|
overtimeTextField.setEditable(false);
|
||||||
workingTimeTextField.setEditable(false);
|
workingTimeTextField.setEditable(false);
|
||||||
@ -293,6 +296,7 @@ public class MainWindow extends TWindow {
|
|||||||
add(pauseTimeTextField);
|
add(pauseTimeTextField);
|
||||||
add(noteTextFieldLabel);
|
add(noteTextFieldLabel);
|
||||||
add(noteTextField);
|
add(noteTextField);
|
||||||
|
add(timeOffCheckBox);
|
||||||
//
|
//
|
||||||
TLabel departureTextFieldLabel = new TLabel("Departure:", 70);
|
TLabel departureTextFieldLabel = new TLabel("Departure:", 70);
|
||||||
departureTextFieldLabel.setBoundsFromTop(arrivalTextFieldLabel);
|
departureTextFieldLabel.setBoundsFromTop(arrivalTextFieldLabel);
|
||||||
@ -312,7 +316,7 @@ public class MainWindow extends TWindow {
|
|||||||
|
|
||||||
remainingTextField.setBoundsFromLeft(remainingTextFieldLabel);
|
remainingTextField.setBoundsFromLeft(remainingTextFieldLabel);
|
||||||
remainingTextField.setEditable(false);
|
remainingTextField.setEditable(false);
|
||||||
TButton saveButton = new TButton("Save", 180);
|
this.saveButton = new TButton("Save", 180);
|
||||||
saveButton.setBoundsFromLeft(remainingTextField);
|
saveButton.setBoundsFromLeft(remainingTextField);
|
||||||
//
|
//
|
||||||
|
|
||||||
@ -601,29 +605,35 @@ public class MainWindow extends TWindow {
|
|||||||
workingDay.setWorkingTimeInMinutes(work_.toTotalMilliseconds() / 1000 / 60);
|
workingDay.setWorkingTimeInMinutes(work_.toTotalMilliseconds() / 1000 / 60);
|
||||||
workingDay.setPauseTimeInMinutes(pause_.toTotalMilliseconds() / 1000 / 60);
|
workingDay.setPauseTimeInMinutes(pause_.toTotalMilliseconds() / 1000 / 60);
|
||||||
workingDay.setNote(noteTextField.getText());
|
workingDay.setNote(noteTextField.getText());
|
||||||
|
workingDay.setTimeOff(timeOffCheckBox.isSelected());
|
||||||
workingDayRepository.update(workingDay);
|
workingDayRepository.update(workingDay);
|
||||||
|
|
||||||
|
if(workingDaysWindow != null) {
|
||||||
|
workingDaysWindow.doReloadButtonClick();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
WorkingDay workingDay = workingDayRepository.read(time.asCalendar());
|
WorkingDay wd = workingDayRepository.read(time.asCalendar());
|
||||||
|
|
||||||
if (workingDay != null) {
|
if (wd != null) {
|
||||||
workingTimeTextField.valueProperty.setValue(TTime.ofMilliseconds(workingDay.getWorkingTimeInMinutes() * 60 * 1000).toString().substring(0, 5));
|
workingTimeTextField.valueProperty.setValue(TTime.ofMilliseconds(wd.getWorkingTimeInMinutes() * 60 * 1000).toString().substring(0, 5));
|
||||||
pauseTimeTextField.valueProperty.setValue(TTime.ofMilliseconds(workingDay.getPauseTimeInMinutes() * 60 * 1000).toString().substring(0, 5));
|
pauseTimeTextField.valueProperty.setValue(TTime.ofMilliseconds(wd.getPauseTimeInMinutes() * 60 * 1000).toString().substring(0, 5));
|
||||||
noteTextField.valueProperty.setValue(workingDay.getNote());
|
noteTextField.valueProperty.setValue(wd.getNote());
|
||||||
|
timeOffCheckBox.setSelected(wd.isTimeOff());
|
||||||
} else {
|
} else {
|
||||||
Calendar cal = time.asCalendar();
|
Calendar cal = time.asCalendar();
|
||||||
int year = cal.get(Calendar.YEAR);
|
int year = cal.get(Calendar.YEAR);
|
||||||
int month = cal.get(Calendar.MONTH) + 1;
|
int month = cal.get(Calendar.MONTH) + 1;
|
||||||
int day = cal.get(Calendar.DAY_OF_MONTH);
|
int day = cal.get(Calendar.DAY_OF_MONTH);
|
||||||
workingDay = new WorkingDay();
|
wd = new WorkingDay();
|
||||||
workingDay.setId(WorkingDay.createId(year, month, day));
|
wd.setId(WorkingDay.createId(year, month, day));
|
||||||
workingDay.setYear(year);
|
wd.setYear(year);
|
||||||
workingDay.setMonth(month);
|
wd.setMonth(month);
|
||||||
workingDay.setDay(day);
|
wd.setDay(day);
|
||||||
workingDay.setWorkingTimeInMinutes(480);
|
wd.setWorkingTimeInMinutes(480);
|
||||||
workingDay.setPauseTimeInMinutes(30);
|
wd.setPauseTimeInMinutes(30);
|
||||||
workingDay.setNote("");
|
wd.setNote("");
|
||||||
|
wd.setTimeOff(false);
|
||||||
}
|
}
|
||||||
TTime arrival_ = new TTime(arrivalTextField.getText());
|
TTime arrival_ = new TTime(arrivalTextField.getText());
|
||||||
TTime overtime_ = new TTime(overtimeTextField.getText());
|
TTime overtime_ = new TTime(overtimeTextField.getText());
|
||||||
@ -635,17 +645,15 @@ public class MainWindow extends TWindow {
|
|||||||
// System.out.println("work_=" + work_);
|
// System.out.println("work_=" + work_);
|
||||||
// System.out.println("pause_=" + pause_);
|
// System.out.println("pause_=" + pause_);
|
||||||
|
|
||||||
workingDay.setArrivalHour(arrival_.getHour());
|
wd.setArrivalHour(arrival_.getHour());
|
||||||
workingDay.setArrivalMinute(arrival_.getMinute());
|
wd.setArrivalMinute(arrival_.getMinute());
|
||||||
|
|
||||||
workingDay.setOvertimeHour(overtime_.getHour());
|
wd.setOvertimeHour(overtime_.getHour());
|
||||||
workingDay.setOvertimeMinute(overtime_.getMinute());
|
wd.setOvertimeMinute(overtime_.getMinute());
|
||||||
|
|
||||||
workingDayRepository.update(workingDay);
|
workingDayRepository.update(wd);
|
||||||
|
|
||||||
//saveButton.doClick();
|
|
||||||
|
|
||||||
System.out.println(workingDay);
|
System.out.println(wd);
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if (updateWindow(timeCalcApp, time, clock, minuteBattery, hourBattery,
|
if (updateWindow(timeCalcApp, time, clock, minuteBattery, hourBattery,
|
||||||
@ -967,6 +975,11 @@ public class MainWindow extends TWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void decreasePause(TTime tTime) {
|
public void decreasePause(TTime tTime) {
|
||||||
pauseTimeTextField.valueProperty.setValue(new TTime(this.pauseTimeTextField.valueProperty.getValue()).remove(tTime).toString().substring(0, 5));
|
pauseTimeTextField.valueProperty.setValue(
|
||||||
|
new TTime(this.pauseTimeTextField.valueProperty.getValue())
|
||||||
|
.remove(tTime).toString().substring(0, 5));
|
||||||
|
}
|
||||||
|
public void doSaveButtonClick(){
|
||||||
|
this.saveButton.doClick();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,23 +24,29 @@ import org.nanoboot.utils.timecalc.utils.common.TTime;
|
|||||||
* @since 16.02.2024
|
* @since 16.02.2024
|
||||||
*/
|
*/
|
||||||
public class WorkingDaysWindow extends TWindow {
|
public class WorkingDaysWindow extends TWindow {
|
||||||
|
private static final String NO = "NO";
|
||||||
|
private static final String YES = "YES";
|
||||||
|
private static final String THREE_DASHES = "---";
|
||||||
|
//
|
||||||
|
private static final Color RED = new Color(255,153,153);
|
||||||
|
public static final String E = "?";
|
||||||
|
|
||||||
private final WorkingDayRepositoryApi workingDayRepository;
|
private final WorkingDayRepositoryApi workingDayRepository;
|
||||||
private final Time time;
|
private final Time time;
|
||||||
|
private final JButton reloadButton;
|
||||||
|
|
||||||
private JTable table = null;
|
private JTable table = null;
|
||||||
private final JScrollPane scrollPane;
|
private final JScrollPane scrollPane;
|
||||||
|
|
||||||
public WorkingDaysWindow(WorkingDayRepositoryApi workingDayRepository, Time time) {
|
public WorkingDaysWindow(WorkingDayRepositoryApi workingDayRepository, Time time) {
|
||||||
setSize(800, 700);
|
setSize(1100, 700);
|
||||||
setTitle("Work Days");
|
setTitle("Work Days");
|
||||||
this.workingDayRepository = workingDayRepository;
|
this.workingDayRepository = workingDayRepository;
|
||||||
this.time = time;
|
this.time = time;
|
||||||
|
|
||||||
int year = time.yearProperty.getValue();
|
int year = time.yearProperty.getValue();
|
||||||
this.setLayout(null);
|
this.setLayout(null);
|
||||||
|
|
||||||
|
|
||||||
WorkingDaysWindow workingDaysWindow = this;
|
WorkingDaysWindow workingDaysWindow = this;
|
||||||
|
|
||||||
List<String> yearsList = workingDayRepository.getYears();
|
List<String> yearsList = workingDayRepository.getYears();
|
||||||
@ -51,25 +57,43 @@ public class WorkingDaysWindow extends TWindow {
|
|||||||
JComboBox years = new JComboBox(yearsArray);
|
JComboBox years = new JComboBox(yearsArray);
|
||||||
years.setMaximumSize(new Dimension(150, 25));
|
years.setMaximumSize(new Dimension(150, 25));
|
||||||
|
|
||||||
years.setSelectedItem(time.asCalendar().get(Calendar.YEAR));
|
years.setSelectedItem(String.valueOf(year));
|
||||||
years.addActionListener(e -> {
|
years.addActionListener(e -> {
|
||||||
workingDaysWindow.loadYear(Integer.valueOf((String) years.getSelectedItem()), time);
|
workingDaysWindow.loadYear(Integer.valueOf((String) years.getSelectedItem()), time);
|
||||||
});
|
});
|
||||||
|
|
||||||
add(years);
|
add(years);
|
||||||
years.setBounds(SwingUtils.MARGIN,SwingUtils.MARGIN, 100, 30);
|
years.setBounds(SwingUtils.MARGIN,SwingUtils.MARGIN, 100, 30);
|
||||||
|
|
||||||
|
this.reloadButton = new JButton("Reload");
|
||||||
|
reloadButton.addActionListener(e -> {
|
||||||
|
workingDaysWindow.loadYear(Integer.valueOf((String) years.getSelectedItem()), time);
|
||||||
|
});
|
||||||
|
add(reloadButton);
|
||||||
|
reloadButton.setBounds(years.getX() + years.getWidth() + SwingUtils.MARGIN, years.getY(), 100, 30);
|
||||||
|
|
||||||
|
|
||||||
JButton exitButton = new JButton("Exit");
|
JButton exitButton = new JButton("Exit");
|
||||||
exitButton.addActionListener(e -> {
|
exitButton.addActionListener(e -> {
|
||||||
this.setVisible(false);
|
this.setVisible(false);
|
||||||
});
|
});
|
||||||
add(exitButton);
|
add(exitButton);
|
||||||
exitButton.setBounds(years.getX() + years.getWidth() + SwingUtils.MARGIN, years.getY(), 100, 30);
|
exitButton.setBounds(reloadButton.getX() + reloadButton.getWidth() + SwingUtils.MARGIN, reloadButton.getY(), 100, 30);
|
||||||
|
TLabel deleteLabel = new TLabel("Delete:");
|
||||||
|
add(deleteLabel);
|
||||||
|
deleteLabel.setBounds(exitButton.getX() + exitButton.getWidth() + SwingUtils.MARGIN, exitButton.getY(), 100, 30);
|
||||||
|
TTextField deleteTextField = new TTextField();
|
||||||
|
add(deleteTextField);
|
||||||
|
deleteTextField.setBounds(deleteLabel.getX() + deleteLabel.getWidth() + SwingUtils.MARGIN, deleteLabel.getY(), 100, 30);
|
||||||
|
deleteTextField.addActionListener(e -> {
|
||||||
|
workingDayRepository.delete(deleteTextField.getText());
|
||||||
|
reloadButton.doClick();
|
||||||
|
});
|
||||||
this.scrollPane
|
this.scrollPane
|
||||||
= new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
|
= new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
|
||||||
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
||||||
scrollPane.setBounds(SwingUtils.MARGIN, years.getY() + years.getHeight()+ SwingUtils.MARGIN,
|
scrollPane.setBounds(SwingUtils.MARGIN, years.getY() + years.getHeight()+ SwingUtils.MARGIN,
|
||||||
getWidth() - 2 * SwingUtils.MARGIN,
|
getWidth() - 3 * SwingUtils.MARGIN,
|
||||||
getHeight() - 4 * SwingUtils.MARGIN - 50);
|
getHeight() - 4 * SwingUtils.MARGIN - 50);
|
||||||
add(scrollPane);
|
add(scrollPane);
|
||||||
scrollPane.setViewportView(table);
|
scrollPane.setViewportView(table);
|
||||||
@ -79,9 +103,12 @@ public class WorkingDaysWindow extends TWindow {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void doReloadButtonClick() {
|
||||||
|
this.reloadButton.doClick();
|
||||||
|
}
|
||||||
public void loadYear(int year, Time time) {
|
public void loadYear(int year, Time time) {
|
||||||
|
|
||||||
List<WorkingDay> list = new ArrayList<>();
|
List<WorkingDay> workingDaysList = new ArrayList<>();
|
||||||
Calendar now = time.asCalendar();
|
Calendar now = time.asCalendar();
|
||||||
final int currentYear = now.get(Calendar.YEAR);
|
final int currentYear = now.get(Calendar.YEAR);
|
||||||
final int currentMonth = now.get(Calendar.MONTH) + 1;
|
final int currentMonth = now.get(Calendar.MONTH) + 1;
|
||||||
@ -99,9 +126,9 @@ public class WorkingDaysWindow extends TWindow {
|
|||||||
|
|
||||||
WorkingDay wd = workingDayRepository.read(year, month, day);
|
WorkingDay wd = workingDayRepository.read(year, month, day);
|
||||||
if (wd == null) {
|
if (wd == null) {
|
||||||
wd = new WorkingDay(WorkingDay.createId(year, month,day), year, month, day, -1, -1, -1, -1, -1, -1, WorkingDay.NODATA);
|
wd = new WorkingDay(WorkingDay.createId(year, month,day), year, month, day, -1, -1, -1, -1, -1, -1, "Fictive day", true);
|
||||||
}
|
}
|
||||||
list.add(wd);
|
workingDaysList.add(wd);
|
||||||
|
|
||||||
// System.out.println("year=" + year);
|
// System.out.println("year=" + year);
|
||||||
// System.out.println("month=" + month);
|
// System.out.println("month=" + month);
|
||||||
@ -116,31 +143,46 @@ public class WorkingDaysWindow extends TWindow {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<WorkingDayForStats> wdfsList = WorkingDayForStats.createList(workingDaysList);
|
||||||
|
WorkingDayForStats.fillStatisticsColumns(wdfsList);
|
||||||
|
|
||||||
List<List<String>> listForArray = new ArrayList<>();
|
List<List<String>> listForArray = new ArrayList<>();
|
||||||
for (WorkingDay wd : list) {
|
for (WorkingDayForStats wdfs : wdfsList) {
|
||||||
ArrayList<String> l = new ArrayList<>();
|
ArrayList<String> list2 = new ArrayList<>();
|
||||||
listForArray.add(l);
|
listForArray.add(list2);
|
||||||
WorkingDayForStats wdfs = new WorkingDayForStats(wd);
|
if (wdfs.isThisDayTimeOff()) {
|
||||||
if (wdfs.getNote().equals(WorkingDay.NODATA)) {
|
list2.add(wdfs.getDayOfWeekAsString());
|
||||||
l.add(wdfs.getDayOfWeekAsString());
|
list2.add(wdfs.getDayOfWeek() == 6 || wdfs.getDayOfWeek() == 7 ? YES : NO);
|
||||||
l.add(wdfs.getDayOfWeek() == 6 || wdfs.getDayOfWeek() == 7 ? YES : NO);
|
list2.add(wdfs.getId());
|
||||||
l.add(wdfs.getId());
|
list2.add(THREE_DASHES);
|
||||||
l.add(THREE_DASHES);
|
list2.add(THREE_DASHES);
|
||||||
l.add(THREE_DASHES);
|
list2.add(THREE_DASHES);
|
||||||
l.add(THREE_DASHES);
|
list2.add(THREE_DASHES);
|
||||||
l.add(THREE_DASHES);
|
list2.add(THREE_DASHES);
|
||||||
l.add(THREE_DASHES);
|
list2.add(wdfs.getNote());
|
||||||
l.add(wdfs.getNote());
|
list2.add(wdfs.isTimeOff() ? YES : NO);
|
||||||
|
list2.add(E);
|
||||||
|
list2.add(E);
|
||||||
|
list2.add(E);
|
||||||
|
list2.add(E);
|
||||||
|
list2.add(E);
|
||||||
} else {
|
} else {
|
||||||
l.add(wdfs.getDayOfWeekAsString());
|
list2.add(wdfs.getDayOfWeekAsString());
|
||||||
l.add(wdfs.getDayOfWeek() == 6 || wdfs.getDayOfWeek() == 7 ? YES : NO);
|
list2.add(wdfs.getDayOfWeek() == 6 || wdfs.getDayOfWeek() == 7 ? YES : NO);
|
||||||
l.add(wdfs.getId());
|
list2.add(wdfs.getId());
|
||||||
l.add(new TTime(wdfs.getArrivalHour(), wdfs.getArrivalMinute()).toString().substring(0, 5));
|
list2.add(new TTime(wdfs.getArrivalHour(), wdfs.getArrivalMinute()).toString().substring(0, 5));
|
||||||
l.add(new TTime(wdfs.getDepartureHour(), wdfs.getDepartureMinute()).toString().substring(0, 5));
|
list2.add(new TTime(wdfs.getDepartureHour(), wdfs.getDepartureMinute()).toString().substring(0, 5));
|
||||||
l.add(new TTime(wdfs.getOvertimeHour(), wdfs.getOvertimeMinute()).toString().substring(0, 5));
|
list2.add(new TTime(wdfs.getOvertimeHour(), wdfs.getOvertimeMinute()).toString().substring(0, 5));
|
||||||
l.add(TTime.ofMinutes(wdfs.getWorkingTimeInMinutes()).toString().substring(0, 5));
|
list2.add(TTime.ofMinutes(wdfs.getWorkingTimeInMinutes()).toString().substring(0, 5));
|
||||||
l.add(TTime.ofMinutes(wdfs.getPauseTimeInMinutes()).toString().substring(0, 5));
|
list2.add(TTime.ofMinutes(wdfs.getPauseTimeInMinutes()).toString().substring(0, 5));
|
||||||
l.add(wdfs.getNote());
|
list2.add(wdfs.getNote());
|
||||||
|
list2.add(wdfs.isTimeOff() ? YES : NO);
|
||||||
|
list2.add(E);
|
||||||
|
list2.add(E);
|
||||||
|
list2.add(E);
|
||||||
|
list2.add(E);
|
||||||
|
list2.add(E);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,7 +196,7 @@ public class WorkingDaysWindow extends TWindow {
|
|||||||
data[index] = data2;
|
data[index] = data2;
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
String[] columns = new String[] {"Day of Week", "Weekend", "Date","Arrival","Departure","Overtime","Working time","Pause time","Note"};
|
String[] columns = new String[] {"Day of Week", "Weekend", "Date","Arrival","Departure","Overtime","Working time","Pause time","Note", "Time off", "Total overtime", "Arrival MA7", "Arrival MA14", "Arrival MA28", "Arrival MA56"};
|
||||||
|
|
||||||
if(table != null) {
|
if(table != null) {
|
||||||
scrollPane.remove(table);
|
scrollPane.remove(table);
|
||||||
@ -220,12 +262,5 @@ public class WorkingDaysWindow extends TWindow {
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
private static final String NO = "NO";
|
|
||||||
private static final String YES = "YES";
|
|
||||||
private static final String THREE_DASHES = "---";
|
|
||||||
private static final String TD_END = "</td>";
|
|
||||||
private static final String TD_START = "<td style=\"border: 1px solid black;border-collapse: collapse;\">";
|
|
||||||
private static final String TH_END = "</th>";
|
|
||||||
private static final String TH_START = "<th style=\"border: 1px solid black;background:grey;\">";
|
|
||||||
private Color RED = new Color(255,153,153);
|
|
||||||
}
|
}
|
@ -13,13 +13,13 @@ _Time Calc is written in Java programming language and uses the Swing framework.
|
|||||||
### Start of application
|
### Start of application
|
||||||
|
|
||||||
When "Time Calc" is started", user is asked for:
|
When "Time Calc" is started", user is asked for:
|
||||||
- start time ... like 7:30
|
- start time ... like 7:30
|
||||||
- overtime ... like 0:45 ... overtime is optional and the default value is 0:00
|
- overtime ... like 0:45 ... overtime is optional and the default value is 0:00
|
||||||
|
|
||||||
### Restart of application
|
### Restart of application
|
||||||
|
|
||||||
You can restart the app, if you press the **"Restart"** button.
|
You can restart the app, if you press the **"Restart"** button.
|
||||||
- Then you are asked again for start time and overtime.
|
- Then you are asked again for start time and overtime.
|
||||||
|
|
||||||
### End of application
|
### End of application
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ If these files are present, something special happens.
|
|||||||
|
|
||||||
### .tc/starttime.txt
|
### .tc/starttime.txt
|
||||||
|
|
||||||
This file contains the default start time - used during the previous run of the app.
|
This file contains the default start time - used during the previous run of the app.
|
||||||
If file starttime.txt does not exist, then the default start time is 7:00.
|
If file starttime.txt does not exist, then the default start time is 7:00.
|
||||||
|
|
||||||
### .tc/overtime.txt
|
### .tc/overtime.txt
|
||||||
@ -64,29 +64,29 @@ Optional assignments of profiles to numbers is stored here.
|
|||||||
|
|
||||||
### 3 Visibility modes
|
### 3 Visibility modes
|
||||||
|
|
||||||
* STRONGLY_COLORED - many colors
|
* STRONGLY_COLORED - many colors
|
||||||
* WEAKLY_COLORED - darkened colors
|
* WEAKLY_COLORED - darkened colors
|
||||||
* GRAY - gray colors
|
* GRAY - gray colors
|
||||||
* NONE - widgets are hidden
|
* NONE - widgets are hidden
|
||||||
|
|
||||||
### Widgets
|
### Widgets
|
||||||
|
|
||||||
#### Analog Clock
|
#### Analog Clock
|
||||||
|
|
||||||
* hour hand
|
* hour hand
|
||||||
* minute hand (can be disabled in configuration)
|
* minute hand (can be disabled in configuration)
|
||||||
* second hand (can be disabled in configuration)
|
* second hand (can be disabled in configuration)
|
||||||
* millisecond hand (can be disabled in configuration)
|
* millisecond hand (can be disabled in configuration)
|
||||||
* shows current year, month, day of month and day of week, if analog clock is hovered by mouse cursor and Visibility is STRONGLY_COLORED
|
* shows current year, month, day of month and day of week, if analog clock is hovered by mouse cursor and Visibility is STRONGLY_COLORED
|
||||||
* shows yellow highlighted remaining time until end of today working hours, if analog clock is hovered by mouse cursor and Visibility is STRONGLY_COLORED
|
* shows yellow highlighted remaining time until end of today working hours, if analog clock is hovered by mouse cursor and Visibility is STRONGLY_COLORED
|
||||||
* hands can be long or shorter (can be set in configuration)
|
* hands can be long or shorter (can be set in configuration)
|
||||||
|
|
||||||
#### Progress Square
|
#### Progress Square
|
||||||
* Show graphically day progress
|
* Show graphically day progress
|
||||||
|
|
||||||
#### Progress Circle
|
#### Progress Circle
|
||||||
|
|
||||||
* Show graphically day progress
|
* Show graphically day progress
|
||||||
|
|
||||||
#### Hour Battery
|
#### Hour Battery
|
||||||
|
|
||||||
@ -169,21 +169,28 @@ Smileys can be colored or white-black (can be set in configuration)
|
|||||||
* CTRL + {Y,N,D,H,M,S or I} - Decrease test time value
|
* CTRL + {Y,N,D,H,M,S or I} - Decrease test time value
|
||||||
* ALT + {Y,N,D,H,M,S or I} - Rest test time value
|
* ALT + {Y,N,D,H,M,S or I} - Rest test time value
|
||||||
* D - Reset custom time values to the real time
|
* D - Reset custom time values to the real time
|
||||||
* SHIFT + A - Increase arrival time by 1 minute
|
* SHIFT + A - Increase arrival time
|
||||||
* CTRL + A - Decrease arrival time by 1 minute
|
* CTRL + A - Decrease arrival time
|
||||||
* SHIFT + O - Increase overtime by 1 minute
|
* SHIFT + O - Increase overtime
|
||||||
* CTRL + O - Decrease overtime by 1 minute
|
* CTRL + O - Decrease overtime
|
||||||
|
* SHIFT + W - Increase working time
|
||||||
|
* CTRL + W - Decrease worknig time
|
||||||
|
* SHIFT + P - Increase pause
|
||||||
|
* CTRL + P - Decrease pause
|
||||||
|
* SHIFT + C - Increase or decrease of time is change by 1 hour
|
||||||
|
* CTRL + C - Increase or decrease of time is change by 1 minute
|
||||||
|
* CTRL + E - Save arrival, overtime, working time, pause time and note
|
||||||
|
|
||||||
## Command button
|
## Command button
|
||||||
|
|
||||||
## Todos
|
## Todos
|
||||||
|
|
||||||
* Split to Maven modules
|
* Split to Maven modules
|
||||||
* Junit, Mockito, etc.
|
* Junit, Mockito, etc.
|
||||||
* Checkstyle
|
* Checkstyle
|
||||||
* Sonarlint
|
* Sonarlint
|
||||||
* Sonarqube
|
* Sonarqube
|
||||||
* Add SQLite support and store times of arrivals and departures and time of activities
|
* Add SQLite support and store times of arrivals and departures and time of activities
|
||||||
|
|
||||||
## For Developers
|
## For Developers
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user