private void doShakeKons(IProgressMonitor monitor, int workUnits) { try { monitor.subTask("Anonymisiere Konsultationen"); Query<Konsultation> qbe = new Query<Konsultation>(Konsultation.class); List<Konsultation> list = qbe.execute(); int workPerKons = (Math.round(workUnits * .8f) / list.size()); Lipsum lipsum = new Lipsum(); monitor.worked(Math.round(workUnits * .2f)); for (Konsultation k : list) { VersionedResource vr = k.getEintrag(); StringBuilder par = new StringBuilder(); int numPars = (int) Math.round(3 * Math.random() + 1); while (numPars-- > 0) { par.append(lipsum.getParagraph()); } vr.update(par.toString(), "random contents"); k.setEintrag(vr, true); k.purgeEintrag(); if (monitor.isCanceled()) { break; } monitor.worked(workPerKons); } } catch (Throwable e) { SWTHelper.showError("Fehler", e.getMessage()); } }
private void createWidgetRows(Composite parent) { if (konsultation != null) { List<ResourceItem> items = new ArrayList<ResourceItem>(); RadioGroupListener radioGroupListener = new RadioGroupListener(); VersionedResource vr = konsultation.getEintrag(); int last = vr.getHeadVersion(); for (int i = last; i >= 0; i--) { ResourceItem ri = vr.getVersion(i); int version = i; String label = ri.getLabel(); String data = ri.data; String labelText = "Rev " + version + ": " + label; Composite rowComposite = new Composite(parent, SWT.NONE); rowComposite.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); GridLayout gridLayout = new GridLayout(1, false); gridLayout.verticalSpacing = 0; rowComposite.setLayout(gridLayout); Button radioButton = new Button(rowComposite, SWT.RADIO); GridData gd = SWTHelper.getFillGridData(1, true, 1, false); gd.verticalAlignment = GridData.BEGINNING; radioButton.setLayoutData(gd); radioButton.setText(labelText); radioGroupListener.addButton(radioButton); /* * Label labelWidget = new Label(rowComposite, SWT.LEFT); * labelWidget.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); * labelWidget.setText(labelText); */ /* * Composite filler = new Composite(rowComposite, SWT.NONE); gd = * SWTHelper.getFillGridData(1, false, 1, false); gd.widthHint = 0; gd.heightHint = * 0; filler.setLayoutData(gd); */ EnhancedTextFieldRO text = new EnhancedTextFieldRO(rowComposite); text.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); text.setText(data); WidgetRow widgetRow = new WidgetRow(radioButton, version); widgetRows.add(widgetRow); } // check the first radio button if (widgetRows.size() > 0) { widgetRows.get(0).radio.setSelection(true); } } }