private void deleteSelectedKey() { MessageBox mb = new MessageBox(getShell(), SWT.YES | SWT.NO); mb.setText("Удаление ключа"); mb.setMessage("Вы уверены?"); if (SWT.YES == mb.open()) { selectedSetData.deleteKey(selectedKeyData); tableKey.deleteCurrent(); } }
private void generate() { Calendar calendar = Calendar.getInstance(); calendar.set(dtFrom.getYear(), dtFrom.getMonth(), dtFrom.getDay()); Date dateFrom = calendar.getTime(); calendar.set(dtTo.getYear(), dtTo.getMonth(), dtTo.getDay()); Date dateTo = calendar.getTime(); setData = new SetData(new Date(), textComment.getText(), dateFrom, dateTo); tableSet.setValues(setData); final int octet = spinnerOctet.getSelection(); final String octetValue = textOctet.getText(); final int keys = spinnerCount.getSelection(); try { new ProgressMonitorDialog(getShell()) .run( true, true, new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask("Генерация ключей…", keys); for (int i = 0; i < keys; ++i) { String key; do { if (monitor.isCanceled()) { throw new InterruptedException(); } key = KeyGenerator.generateKey(octetValue, octet); } while (setData.isKeyExists(key)); setData.addKey(key, true); monitor.worked(1); } } }); } catch (InvocationTargetException e) { throw new KeyException("Ошибка при генерации ключей", e.getCause()); } catch (InterruptedException e) { } tableKey.setValues(setData.getKeys()); }
private void activateSelectedKey() { selectedSetData.activateKey(selectedKeyData); tableKey.refreshCurrent(); }
private void refresh() { tableSet.reset(); for (SetData setData : SetData.listAll()) { tableSet.setValues(setData); } }
private void filter() { tableSet.reset(); for (SetData setData : SetData.listFilter(textFilter.getText())) { tableSet.setValues(setData); } }
private void save() { setData.save(); tableSet.setValues(setData); }