/** Load list of scopes for user selection of top level element for report. */ private void setupComboScopes() { // check if audit was selected by context menu: if (this.auditId != null && isContextMenuCall()) { scopeCombo.removeAll(); scopeCombo.add(this.auditName); rootElement = auditId; scopeCombo.setEnabled(true); scopeCombo.select(0); scopeCombo.redraw(); return; } else if (this.preSelectedElments != null && this.preSelectedElments.size() > 0 && isContextMenuCall()) { scopeCombo.removeAll(); ArrayList<Integer> auditIDList = new ArrayList<Integer>(); StringBuilder sb = new StringBuilder(); for (CnATreeElement elmt : preSelectedElments) { sb.append(elmt.getTitle()); if (preSelectedElments.indexOf(elmt) != preSelectedElments.size() - 1) sb.append(" & "); auditIDList.add(elmt.getDbId()); } scopeCombo.add(sb.toString()); rootElements = auditIDList.toArray(new Integer[auditIDList.size()]); scopeCombo.setEnabled(false); scopeCombo.select(0); scopeCombo.redraw(); return; } scopes = new ArrayList<CnATreeElement>(); scopeTitles = new ArrayList<String>(); scopes.addAll(loadScopes()); scopes.addAll(loadITVerbuende()); Collections.sort( scopes, new Comparator<CnATreeElement>() { @Override public int compare(CnATreeElement o1, CnATreeElement o2) { return o1.getTitle().compareToIgnoreCase(o2.getTitle()); } }); for (CnATreeElement elmt : scopes) { scopeTitles.add(elmt.getTitle()); if (LOG.isDebugEnabled()) { LOG.debug( Messages.GenerateReportDialog_16 + elmt.getDbId() + ": " + elmt .getTitle()); //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-1$ //$NON-NLS-1$ // //$NON-NLS-1$ } } String[] titles = scopeTitles.toArray(new String[scopeTitles.size()]); scopeCombo.setItems(titles); }
private void updateForm() { try { if (loggedIn) { if (templateStore == null) { templateStore = new TemplateStore(); } setEnable(true); // remove and reload template combo templateCombo.removeAll(); for (String templateName : templateStore.getTemplateNames()) { templateCombo.add(templateName); } if (templateCombo.getItemCount() > 0) templateCombo.select(0); for (int i = 0; i < templateCombo.getItemCount(); i++) { if (templateCombo .getItem(i) .equals(perferenceStore.getString(PreferenceConstants.TEMPLATE_NAME))) { templateCombo.select(i); break; } } templateCombo.redraw(); loadSelectedTemplate(); } else { setEnable(false); templateCombo.removeAll(); templateCombo.redraw(); } } catch (ApplicationException e) { BgcPlugin.openAsyncError( "Database Error", //$NON-NLS-1$ "Error while updating form", e); //$NON-NLS-1$ } }