Пример #1
0
 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();
   }
 }
Пример #2
0
  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());
  }
Пример #3
0
 private void activateSelectedKey() {
   selectedSetData.activateKey(selectedKeyData);
   tableKey.refreshCurrent();
 }
Пример #4
0
 private void refresh() {
   tableSet.reset();
   for (SetData setData : SetData.listAll()) {
     tableSet.setValues(setData);
   }
 }
Пример #5
0
 private void filter() {
   tableSet.reset();
   for (SetData setData : SetData.listFilter(textFilter.getText())) {
     tableSet.setValues(setData);
   }
 }
Пример #6
0
 private void save() {
   setData.save();
   tableSet.setValues(setData);
 }