public EditComposite(Composite parent, int style) { super(parent, style); setLayout(new GridLayout(2, false)); Group groupFilter = new Group(this, SWT.NONE); groupFilter.setText("Поиск ключей"); groupFilter.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false)); groupFilter.setLayout(new GridLayout(2, false)); textFilter = new Text(groupFilter, SWT.BORDER); textFilter.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); Button button = new Button(groupFilter, SWT.PUSH); button.setImage( new Image(getShell().getDisplay(), getClass().getResourceAsStream("/search.gif"))); button.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { filter(); } }); button = new Button(this, SWT.PUSH); button.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); button.setText("Показать все"); button.setImage( new Image(getShell().getDisplay(), getClass().getResourceAsStream("/refresh.gif"))); button.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { refresh(); } }); SashForm sash = new SashForm(this, SWT.VERTICAL); sash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); tableSet = new SetTable(sash, true); tableSet.addSelectionListener( new SetTable.SetSelectionListener() { @Override public void selected(SetData setData) { selectedSetData = setData; List<KeyData> keys = null; if (null != setData) { keys = setData.getKeys(); } tableKey.setValues(keys); buttonExport.setEnabled((keys != null) && !keys.isEmpty()); buttonDeleteSet.setEnabled(keys != null); } }); Composite keyComposite = new Composite(sash, SWT.NONE); GridLayout gl = new GridLayout(2, false); gl.marginWidth = 0; keyComposite.setLayout(gl); tableKey = new KeyTable(keyComposite); tableKey.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 4)); tableKey.addSelectionListener( new KeyTable.KeySelectionListener() { @Override public void selected(KeyData keyData) { selectedKeyData = keyData; boolean isKeySelected = (keyData != null); buttonDeleteKey.setEnabled(isKeySelected); buttonActivateKey.setEnabled(isKeySelected); } }); buttonDeleteSet = new Button(keyComposite, SWT.PUSH); buttonDeleteSet.setLayoutData(new GridData(SWT.FILL, SWT.NONE, false, false)); buttonDeleteSet.setText("Удаление пачки"); buttonDeleteSet.setImage( new Image(getShell().getDisplay(), getClass().getResourceAsStream("/delete.gif"))); buttonDeleteSet.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { deleteSelectedSet(); } }); buttonDeleteSet.setEnabled(false); buttonActivateKey = new Button(keyComposite, SWT.PUSH); buttonActivateKey.setText("Блокировать/активировать ключ"); buttonActivateKey.setLayoutData(new GridData(SWT.FILL, SWT.NONE, false, false)); // buttonActivateKey.setImage(new Image(getShell().getDisplay(), // getClass().getResourceAsStream("/delete.gif"))); buttonActivateKey.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { activateSelectedKey(); } }); buttonActivateKey.setEnabled(false); buttonDeleteKey = new Button(keyComposite, SWT.PUSH); buttonDeleteKey.setText("Удаление ключа"); buttonDeleteKey.setLayoutData(new GridData(SWT.FILL, SWT.NONE, false, false)); buttonDeleteKey.setImage( new Image(getShell().getDisplay(), getClass().getResourceAsStream("/delete.gif"))); buttonDeleteKey.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { deleteSelectedKey(); } }); buttonDeleteKey.setEnabled(false); buttonExport = new Button(keyComposite, SWT.PUSH); buttonExport.setLayoutData(new GridData(SWT.FILL, SWT.NONE, false, false)); buttonExport.setText("Экспорт пачки…"); buttonExport.setImage( new Image(getShell().getDisplay(), getClass().getResourceAsStream("/saveas.gif"))); buttonExport.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { export(); } }); buttonExport.setEnabled(false); }
public NewComposite(Composite parent, int style) { super(parent, style); setLayout(new GridLayout(2, false)); GridData gd = new GridData(SWT.NONE, SWT.NONE, false, false); new Label(this, SWT.NONE).setText("Количество октетов:"); spinnerOctet = new Spinner(this, SWT.BORDER); spinnerOctet.setLayoutData(gd); spinnerOctet.setMinimum(2); spinnerOctet.setMaximum(8); new Label(this, SWT.NONE).setText("Количество ключей:"); spinnerCount = new Spinner(this, SWT.BORDER); spinnerCount.setLayoutData(gd); spinnerCount.setMinimum(1); spinnerCount.setMaximum(20000); new Label(this, SWT.NONE).setText("Настраиваемый октет:"); textOctet = new Text(this, SWT.BORDER); textOctet.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false)); textOctet.addVerifyListener( new VerifyListener() { @Override public void verifyText(VerifyEvent event) { int len = event.text.length(); if (len > 0) { int allowed = CUSTOM_OCTET_LENGTH - ((Text) event.widget).getText().length(); if (len > allowed) { event.text = event.text.substring(0, allowed); } if (!PATTERN_ALPHANUM.matcher(event.text).matches()) { event.doit = false; } else { event.text = event.text.toUpperCase(); } } } }); new Label(this, SWT.NONE).setText("Комментарий:"); textComment = new Text(this, SWT.BORDER); textComment.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false)); new Label(this, SWT.NONE).setText("Начало действия ключа:"); dtFrom = new DateTime(this, SWT.BORDER | SWT.DATE); Calendar calendar = Calendar.getInstance(); dtFrom.setDate( calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH)); new Label(this, SWT.NONE).setText("Окончание действия ключа:"); dtTo = new DateTime(this, SWT.BORDER | SWT.DATE); calendar.add(Calendar.YEAR, 1); dtTo.setDate( calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH)); Button button = new Button(this, SWT.PUSH); button.setImage(new Image(getShell().getDisplay(), getClass().getResourceAsStream("/new.gif"))); GridData buttonGridData = new GridData(SWT.NONE, SWT.NONE, false, false, 2, 1); button.setLayoutData(buttonGridData); button.setText("Создать"); button.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { generate(); buttonSave.setEnabled(true); } }); tableSet = new SetTable(this, false); tableSet.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false, 2, 1)); tableKey = new KeyTable(this); GridData gdKeyTable = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1); gdKeyTable.heightHint = 50; tableKey.setLayoutData(gdKeyTable); buttonSave = new Button(this, SWT.PUSH); buttonSave.setLayoutData(buttonGridData); buttonSave.setText("Сохранить"); buttonSave.setImage( new Image(getShell().getDisplay(), getClass().getResourceAsStream("/export.gif"))); buttonSave.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { save(); buttonSave.setEnabled(false); } }); buttonSave.setEnabled(false); }