Line 142... |
Line 142... |
142 |
|
142 |
|
143 |
/**
|
143 |
/**
|
144 |
* Check if the register installation has moved and ask the user about it if it did. This can be
|
144 |
* Check if the register installation has moved and ask the user about it if it did. This can be
|
145 |
* called from outside the EDT.
|
145 |
* called from outside the EDT.
|
146 |
*
|
146 |
*
|
- |
|
147 |
* @param erpTM UI locale
|
147 |
* @return <code>true</code> if the user wants to quit.
|
148 |
* @return <code>true</code> if the user wants to quit.
|
148 |
* @throws InterruptedException if this thread was interrupted while waiting on the EDT.
|
149 |
* @throws InterruptedException if this thread was interrupted while waiting on the EDT.
|
149 |
* @throws ExecutionException if there was an error while asking the user.
|
150 |
* @throws ExecutionException if there was an error while asking the user.
|
150 |
*/
|
151 |
*/
|
151 |
public final boolean checkIfMoved() throws InterruptedException, ExecutionException {
|
152 |
public final boolean checkIfMoved(final TM erpTM) throws InterruptedException, ExecutionException {
|
152 |
final SQLRowValues lastEntry = this.getLastEntry();
|
153 |
final SQLRowValues lastEntry = this.getLastEntry();
|
153 |
if (lastEntry == null) {
|
154 |
if (lastEntry == null) {
|
154 |
return false;
|
155 |
return false;
|
155 |
}
|
156 |
}
|
156 |
|
157 |
|
157 |
final Map<String, Object> currentValues = fillHostValues(new SQLRowValues(lastEntry.getTable())).getAbsolutelyAll();
|
158 |
final Map<String, Object> currentValues = fillHostValues(new SQLRowValues(lastEntry.getTable())).getAbsolutelyAll();
|
158 |
final Map<String, Object> dbValues = lastEntry.getValues(currentValues.keySet());
|
159 |
final Map<String, Object> dbValues = lastEntry.getValues(currentValues.keySet());
|
159 |
if (dbValues.equals(currentValues) || NULL_VALUES.equals(dbValues)) {
|
160 |
if (dbValues.equals(currentValues) || NULL_VALUES.equals(dbValues)) {
|
160 |
return false;
|
161 |
return false;
|
161 |
} else {
|
162 |
} else {
|
162 |
final String message = TM.tr("register.moved", getPosID());
|
163 |
final String message = erpTM.translate("register.moved", getPosID());
|
163 |
final String[] options = new String[] { TM.tr("register.moved.ignore"), TM.tr("register.moved.quit") };
|
164 |
final String[] options = new String[] { erpTM.translate("register.moved.ignore"), erpTM.translate("register.moved.quit") };
|
164 |
final FutureTask<Boolean> askUserCallable = new FutureTask<>(new Callable<Boolean>() {
|
165 |
final FutureTask<Boolean> askUserCallable = new FutureTask<>(new Callable<Boolean>() {
|
165 |
@Override
|
166 |
@Override
|
166 |
public Boolean call() throws Exception {
|
167 |
public Boolean call() throws Exception {
|
167 |
// quit by default
|
168 |
// quit by default
|
168 |
final int ans = JOptionPane.showOptionDialog(null, message, TM.tr("register.moved.title"), JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[1]);
|
169 |
final int ans = JOptionPane.showOptionDialog(null, message, erpTM.translate("register.moved.title"), JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, options,
|
- |
|
170 |
options[1]);
|
169 |
// CLOSED_OPTION also means quit, only clicking "ignore" means don't quit
|
171 |
// CLOSED_OPTION also means quit, only clicking "ignore" means don't quit
|
170 |
return ans != 0;
|
172 |
return ans != 0;
|
171 |
}
|
173 |
}
|
172 |
});
|
174 |
});
|
173 |
SwingThreadUtils.invoke(askUserCallable);
|
175 |
SwingThreadUtils.invoke(askUserCallable);
|