List of usage examples for org.eclipse.jface.viewers LabelProvider LabelProvider
public LabelProvider()
From source file:ch.elexis.core.ui.dialogs.ZusatzAdresseEingabeDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { Composite com = new Composite(parent, SWT.NONE); com.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); com.setLayout(new GridLayout(2, false)); Composite compAddressType = new Composite(com, SWT.NONE); compAddressType.setLayoutData(SWTHelper.getFillGridData(2, true, 1, true)); compAddressType.setLayout(new GridLayout(2, false)); Label lblAddressType = new Label(compAddressType, SWT.NONE); lblAddressType.setText("Type"); comboAddressType = new ComboViewer(compAddressType, SWT.DROP_DOWN | SWT.BORDER | SWT.READ_ONLY); comboAddressType.setContentProvider(ArrayContentProvider.getInstance()); comboAddressType.setLabelProvider(new LabelProvider() { @Override/* w ww . j av a 2 s. co m*/ public String getText(Object element) { return LocalizeUtil.getLocaleText((AddressType) element); } }); List<AddressType> comboValues = new ArrayList<>(Arrays.asList(AddressType.values())); comboValues.remove(AddressType.PRINCIPAL_RESIDENCE); //principal residence is defined within patient - contact relation comboAddressType.setInput(comboValues); Label l1 = new Label(com, SWT.NONE); l1.setText(Messages.AnschriftEingabeDialog_street + "1"); //$NON-NLS-1$ str1 = new Text(com, SWT.BORDER); str1.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); l1 = new Label(com, SWT.NONE); l1.setText(Messages.AnschriftEingabeDialog_street + "2"); //$NON-NLS-1$ str2 = new Text(com, SWT.BORDER); str2.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); Label l2 = new Label(com, SWT.NONE); l2.setText(Messages.AnschriftEingabeDialog_zip); //$NON-NLS-1$ plz = new Text(com, SWT.BORDER); plz.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); Label l3 = new Label(com, SWT.NONE); l3.setText(Messages.AnschriftEingabeDialog_city); //$NON-NLS-1$ ort = new Text(com, SWT.BORDER); ort.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); Label l4 = new Label(com, SWT.NONE); l4.setText(Messages.AnschriftEingabeDialog_country); //$NON-NLS-1$ land = new Text(com, SWT.BORDER); land.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); Button post = new Button(com, SWT.PUSH); post.setText(Messages.AnschriftEingabeDialog_postalAddress); //$NON-NLS-1$ post.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { setFieldValues(); Kontakt kontakt = Kontakt.load(zusatzAdresseDTO.getKontaktId()); zusatzAdresseDTO.setPostalAddress(kontakt.getSalutation() + zusatzAdresse.getEtikette(false, true, zusatzAdresseDTO.getKontaktId(), zusatzAdresseDTO.getStreet1(), zusatzAdresseDTO.getCountry(), zusatzAdresseDTO.getZip(), zusatzAdresseDTO.getPlace())); loadFieldValues(); } }); postanschrift = new Text(com, SWT.MULTI | SWT.BORDER); GridData gd = SWTHelper.getFillGridData(1, true, 1, true); // at least 3 lines height Point size = postanschrift.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); gd.heightHint = 4 * size.y; postanschrift.setLayoutData(gd); // postanschrift info message new Label(com, SWT.NONE); // filler Label l5 = new Label(com, SWT.NONE); l5.setText(Messages.AnschriftEingabeDialog_postalAddressInfo); //$NON-NLS-1$ l5.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); loadFieldValues(); return com; }
From source file:ch.elexis.core.ui.documents.views.DocumentsMetaDataDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { Composite ret = new Composite(parent, SWT.NONE); ret.setLayout(new GridLayout()); ret.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); new Label(ret, SWT.None).setText(Messages.DocumentView_categoryColumn); Composite cCats = new Composite(ret, SWT.NONE); cCats.setFocus();/*ww w.ja v a 2s . c o m*/ cCats.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); cCats.setLayout(new RowLayout(SWT.HORIZONTAL)); cbCategories = new ComboViewer(cCats, SWT.SINGLE | SWT.READ_ONLY); cbCategories.setContentProvider(ArrayContentProvider.getInstance()); cbCategories.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { if (element instanceof ICategory) { ICategory iCategory = (ICategory) element; return iCategory.getName(); } return super.getText(element); } }); List<ICategory> categories = DocumentStoreServiceHolder.getService().getCategories(document); cbCategories.setInput(categories); Button bNewCat = new Button(cCats, SWT.PUSH); bNewCat.setVisible(categoryCrudAllowed); bNewCat.setImage(Images.IMG_NEW.getImage()); bNewCat.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { InputDialog id = new InputDialog(getShell(), Messages.DocumentMetaDataDialog_newCategory, Messages.DocumentMetaDataDialog_newCategory, null, null); if (id.open() == Dialog.OK) { document.setCategory( DocumentStoreServiceHolder.getService().createCategory(document, id.getValue())); if (!((List<?>) cbCategories.getInput()).contains(document.getCategory())) { cbCategories.add(document.getCategory()); } cbCategories.setSelection(new StructuredSelection(document.getCategory()), true); } } }); Button bEditCat = new Button(cCats, SWT.PUSH); bEditCat.setImage(Images.IMG_EDIT.getImage()); bEditCat.setVisible(categoryCrudAllowed); bEditCat.setToolTipText(Messages.DocumentMetaDataDialog_renameCategory); bEditCat.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { ISelection old = cbCategories.getSelection(); Object selection = ((StructuredSelection) old).getFirstElement(); if (selection instanceof ICategory) { InputDialog id = new InputDialog(getShell(), MessageFormat.format(Messages.DocumentMetaDataDialog_renameCategoryConfirm, ((ICategory) selection).getName()), Messages.DocumentMetaDataDialog_renameCategoryText, ((ICategory) selection).getName(), null); if (id.open() == Dialog.OK) { DocumentStoreServiceHolder.getService().renameCategory(document, id.getValue()); ((ICategory) selection).setName(id.getValue()); cbCategories.refresh(); } } } }); Button bDeleteCat = new Button(cCats, SWT.PUSH); bDeleteCat.setVisible(categoryCrudAllowed); bDeleteCat.setImage(Images.IMG_DELETE.getImage()); bDeleteCat.setToolTipText(Messages.DocumentMetaDataDialog_deleteCategory); bDeleteCat.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent ev) { ISelection old = cbCategories.getSelection(); Object selection = ((StructuredSelection) old).getFirstElement(); InputDialog id = new InputDialog(getShell(), MessageFormat.format(Messages.DocumentMetaDataDialog_deleteCategoryConfirm, ((ICategory) selection).getName()), Messages.DocumentMetaDataDialog_deleteCategoryText, "", null); if (id.open() == Dialog.OK) { try { document.setCategory((ICategory) selection); document.setCategory( DocumentStoreServiceHolder.getService().removeCategory(document, id.getValue())); if (findComboElementByName(document.getCategory().getName()) == null) { cbCategories.add(document.getCategory()); } cbCategories.remove(selection); cbCategories.setSelection(new StructuredSelection(document.getCategory()), true); } catch (ElexisException e) { logger.warn("existing document references", e); SWTHelper.showError(Messages.DocumentMetaDataDialog_deleteCategoryError, Messages.DocumentMetaDataDialog_deleteCategoryErrorText); } } } }); new Label(ret, SWT.NONE).setText(Messages.DocumentsView_Title); tTitle = SWTHelper.createText(ret, 1, SWT.NONE); new Label(ret, SWT.NONE).setText(Messages.DocumentView_keywordsColumn); tKeywords = SWTHelper.createText(ret, 4, SWT.NONE); tKeywords.setEnabled(keywordsCrudAllowed); tTitle.setText(document.getTitle()); tKeywords.setText(document.getKeywords()); Object cbSelection = document.getCategory() != null ? document.getCategory() : cbCategories.getElementAt(0); if (cbSelection != null) { if (!categories.contains(cbSelection)) { cbSelection = DocumentStoreServiceHolder.getService().getDefaultCategory(document); } cbCategories.setSelection(new StructuredSelection(cbSelection), true); } return ret; }
From source file:ch.elexis.core.ui.preferences.inputs.ACLPreferenceTree.java
License:Open Source License
public ACLPreferenceTree(Composite parent, ACE... acl) { super(parent, SWT.NONE); acls = new Tree<ACE>(null, null); for (ACE s : acl) { Tree<ACE> mine = acls.find(s, true); if (mine == null) { Tree<ACE> parentTree = findParent(s); if (parentTree != null) { new Tree<ACE>(parentTree, s); } else { log.error("Could not find parent ACE " + s.getName()); }/*from w w w . j a v a2 s . c o m*/ } } setLayout(new GridLayout()); setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); tv = new TreeViewer(this); tv.setContentProvider(new ITreeContentProvider() { public Object[] getChildren(Object parentElement) { Tree tree = (Tree) parentElement; return tree.getChildren().toArray(); } public Object getParent(Object element) { return ((Tree) element).getParent(); } public boolean hasChildren(Object element) { Tree tree = (Tree) element; return tree.hasChildren(); } public Object[] getElements(Object inputElement) { return acls.getChildren().toArray(); } public void dispose() { // TODO Auto-generated method stub } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { // TODO Auto-generated method stub } }); tv.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { return (String) ((Tree<ACE>) element).contents.getLocalizedName(); } }); tv.getControl().setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); Composite cBottom = new Composite(this, SWT.NONE); cBottom.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); cBottom.setLayout(new GridLayout(2, true)); new Label(cBottom, SWT.NONE).setText(StringConstants.ROLES_DEFAULT); new Label(cBottom, SWT.NONE).setText(StringConstants.ROLE_USERS); lbGroups = new org.eclipse.swt.widgets.List(cBottom, SWT.MULTI | SWT.V_SCROLL); lbUsers = new org.eclipse.swt.widgets.List(cBottom, SWT.MULTI | SWT.V_SCROLL); lbUsers.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); lbGroups.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); lUsers = Hub.getUserList(); for (Anwender an : lUsers) { lbUsers.add(an.getLabel()); } // List<String> lGroups = CoreHub.acl.getGroups(); // for (String s : lGroups) { // lbGroups.add(s); // } tv.addSelectionChangedListener(new ISelectionChangedListener() { /** * if the user selects an ACL from the TreeViewer, we want to select users and groups * that are granted this acl in the lbGroups and lbUsers ListBoxes */ public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection sel = (IStructuredSelection) event.getSelection(); lbGroups.deselectAll(); lbUsers.deselectAll(); // if (!sel.isEmpty()) { // Tree<ACE> acl = (Tree<ACE>) sel.getFirstElement(); // ACE right = acl.contents; // List<String> grps = CoreHub.acl.groupsForGrant(right); // List<Anwender> users = CoreHub.acl.usersForGrant(right); // for (String g : grps) { // int idx = StringTool.getIndex(lbGroups.getItems(), g); // if (idx != -1) { // lbGroups.select(idx); // } // } // for (Anwender an : users) { // int idx = StringTool.getIndex(lbUsers.getItems(), an.getLabel()); // if (idx != -1) { // lbUsers.select(idx); // } // } // } } }); lbGroups.addSelectionListener(new SelectionAdapter() { @SuppressWarnings("unchecked") public void widgetSelected(SelectionEvent arg0) { IStructuredSelection sel = (IStructuredSelection) tv.getSelection(); if (!sel.isEmpty()) { Tree<ACE> acl = (Tree<ACE>) sel.getFirstElement(); ACE right = acl.contents; String[] gsel = lbGroups.getSelection(); for (String g : lbGroups.getItems()) { // CoreHub.acl.revoke(g, right); } for (String g : gsel) { CoreHub.acl.grant(g, right); } } } }); lbUsers.addSelectionListener(new SelectionAdapter() { @SuppressWarnings("unchecked") public void widgetSelected(SelectionEvent arg0) { IStructuredSelection sel = (IStructuredSelection) tv.getSelection(); if (!sel.isEmpty()) { Tree<ACE> acl = (Tree<ACE>) sel.getFirstElement(); ACE right = acl.contents; int[] uSel = lbUsers.getSelectionIndices(); for (Anwender an : lUsers) { // CoreHub.acl.revoke(an, right); } for (int i : uSel) { // CoreHub.acl.grant(lUsers.get(i), right); } } } }); tv.setSorter(new ViewerSorter() { @SuppressWarnings("unchecked") @Override public int compare(Viewer viewer, Object e1, Object e2) { Tree<ACE> t1 = (Tree<ACE>) e1; Tree<ACE> t2 = (Tree<ACE>) e2; return t1.contents.getLocalizedName().compareToIgnoreCase(t2.contents.getLocalizedName()); } }); tv.setInput(this); }
From source file:ch.elexis.core.ui.stock.dialogs.ImportArticleDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { reportBuilder = null;//from w w w .j a v a 2s. c o m Composite ret = new Composite(parent, SWT.NONE); ret.setLayout(new GridLayout(3, false)); ret.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); new Label(ret, SWT.NONE).setText("Import in Lager"); comboStockType = new ComboViewer(ret, SWT.BORDER | SWT.READ_ONLY); comboStockType.setContentProvider(ArrayContentProvider.getInstance()); comboStockType.setInput(new Query<Stock>(Stock.class).execute()); comboStockType.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { ISelection selection = event.getSelection(); if (selection instanceof StructuredSelection) { if (!selection.isEmpty()) { Object o = ((StructuredSelection) selection).getFirstElement(); } } } }); comboStockType.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { if (element instanceof Stock) { Stock stock = (Stock) element; return stock.getLabel(); } return super.getText(element); } }); comboStockType.getCombo().setLayoutData(SWTHelper.getFillGridData(2, false, 1, false)); comboStockType.setSelection(new StructuredSelection(Stock.load(Stock.DEFAULT_STOCK_ID))); new Label(ret, SWT.NONE).setText("Quelldatei auswhlen"); tFilePath = new Text(ret, SWT.BORDER); tFilePath.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); tFilePath.setText(""); Button btnBrowse = new Button(ret, SWT.NONE); btnBrowse.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { FileDialog fd = new FileDialog(getShell(), SWT.OPEN); fd.setFilterExtensions(new String[] { "*.xls" }); String selected = fd.open(); tFilePath.setText(selected); } }); btnBrowse.setText("auswhlen.."); reportLink = new Link(ret, SWT.NONE); reportLink.setText(""); reportLink.setVisible(false); reportLink.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, true, 3, 1)); // Event handling when users click on links. reportLink.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { FileDialog fd = new FileDialog(getShell(), SWT.SAVE); fd.setFilterExtensions(new String[] { "*.csv" }); fd.setFileName("report.csv"); String path = fd.open(); if (path != null) { try { FileUtils.writeStringToFile(new File(path), reportBuilder.toString(), "UTF-8"); } catch (IOException e1) { MessageDialog.openError(getShell(), "Report Error", "Report konnte nicht gespeichert werden.\n\n" + e1.getMessage()); LoggerFactory.getLogger(ImportArticleDialog.class).error("report save error", e1); } } } }); return ret; }
From source file:ch.elexis.core.ui.views.FallListeView.java
License:Open Source License
@Override public void createPartControl(Composite parent) { tk = UiDesk.getToolkit();/*from ww w. j a v a2s. c o m*/ form = tk.createForm(parent); form.getBody().setLayout(new GridLayout()); SashForm sash = new SashForm(form.getBody(), SWT.VERTICAL); form.setText(Messages.FallListeView_NoPatientSelected); //$NON-NLS-1$ sash.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); ButtonProvider fallButton = new ButtonProvider() { public Button createButton(Composite parent1) { Button ret = tk.createButton(parent1, Messages.FallListeView_NewCase, SWT.PUSH); //$NON-NLS-1$ ret.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { String bez = fallCf.getControlFieldProvider().getValues()[0]; Fall fall = actPatient.neuerFall(bez, Messages.FallListeView_Illness, "KVG"); //$NON-NLS-1$ //$NON-NLS-2$ Konsultation b = fall.neueKonsultation(); b.setMandant(CoreHub.actMandant); fallCf.getControlFieldProvider().clearValues(); fallViewer.getViewerWidget().refresh(); fallViewer.setSelection(fall, true); } }); return ret; } public boolean isAlwaysEnabled() { return false; } }; fallViewer = new CommonViewer(); fallCf = new ViewerConfigurer(new DefaultContentProvider(fallViewer, Fall.class) { @Override public Object[] getElements(Object inputElement) { if (actPatient != null) { if (fallCf.getControlFieldProvider().isEmpty()) { return actPatient.getFaelle(); } else { IFilter filter = fallCf.getControlFieldProvider().createFilter(); List<String> list = actPatient.getList(Messages.FallListeView_Cases, true); //$NON-NLS-1$ ArrayList<Fall> arr = new ArrayList<Fall>(); for (String s : list) { Fall f = Fall.load(s); if (filter.select(f)) { arr.add(f); } } return arr.toArray(); } } return new Object[0]; } }, new LabelProvider() { @Override public Image getImage(Object element) { if (element instanceof Fall) { if (((Fall) element).isOpen()) { // show red/green dot is case invalid/valid if (((Fall) element).isValid()) { return Images.IMG_OK.getImage(); } else { return Images.IMG_FEHLER.getImage(); } } else { return Images.IMG_LOCK_CLOSED.getImage(); } } return super.getImage(element); } @Override public String getText(Object element) { return (((Fall) element).getLabel()); } }, new DefaultControlFieldProvider(fallViewer, new String[] { Messages.FallListeView_Label }), fallButton, new SimpleWidgetProvider(SimpleWidgetProvider.TYPE_TABLE, SWT.SINGLE, fallViewer)); fallViewer.create(fallCf, sash, SWT.NONE, getViewSite()); fallViewer.getViewerWidget() .addSelectionChangedListener(GlobalEventDispatcher.getInstance().getDefaultListener()); behandlViewer = new CommonViewer(); ButtonProvider behandlButton = new ButtonProvider() { public Button createButton(Composite parent1) { Button ret = tk.createButton(parent1, Messages.FallListeView_NewKons, SWT.PUSH); //$NON-NLS-1$ ret.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Konsultation b = actFall.neueKonsultation(); if (b != null) { b.setMandant(CoreHub.actMandant); behandlCf.getControlFieldProvider().clearValues(); behandlViewer.getViewerWidget().refresh(); // behandlViewer.setSelection(b); setFall(actFall, b); } } }); return ret; } public boolean isAlwaysEnabled() { return true; } }; behandlCf = new ViewerConfigurer(new CommonContentProviderAdapter() { @Override public Object[] getElements(Object inputElement) { if (actFall != null) { Konsultation[] alle = actFall.getBehandlungen(true); /* * if(behandlungsFilter!=null){ ArrayList<Konsultation> al=new * ArrayList<Konsultation>(alle.length); for(int i=0;i<alle.length;i++){ * if(behandlungsFilter.select(alle[i])==true){ al.add(alle[i]); } } return * al.toArray(); } */ return actFall.getBehandlungen(true); } return new Object[0]; } }, new DefaultLabelProvider(), new DefaultControlFieldProvider(behandlViewer, new String[] { Messages.FallListeView_Date }), behandlButton, new SimpleWidgetProvider(SimpleWidgetProvider.TYPE_LIST, SWT.SINGLE | SWT.V_SCROLL, behandlViewer)); Composite cf = new Composite(sash, SWT.BORDER); cf.setLayout(new GridLayout()); behandlViewer.create(behandlCf, cf, SWT.NONE, getViewSite()); behandlViewer.getViewerWidget() .addSelectionChangedListener(GlobalEventDispatcher.getInstance().getDefaultListener()); tk.adapt(sash, false, false); GlobalEventDispatcher.addActivationListener(this, this); sash.setWeights(new int[] { 50, 50 }); createMenuAndToolbar(); createContextMenu(); ((DefaultContentProvider) fallCf.getContentProvider()).startListening(); fallViewer.addDoubleClickListener(new DoubleClickListener() { @Override public void doubleClicked(PersistentObject obj, CommonViewer cv) { try { FallDetailView pdv = (FallDetailView) getSite().getPage().showView(FallDetailView.ID); } catch (PartInitException e) { ExHandler.handle(e); } } }); behandlViewer.addDoubleClickListener(new DoubleClickListener() { @Override public void doubleClicked(PersistentObject obj, CommonViewer cv) { try { PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .showView(KonsDetailView.ID); } catch (PartInitException e) { ExHandler.handle(e); } } }); }
From source file:ch.elexis.core.ui.views.KonsDetailView.java
License:Open Source License
@Override public void createPartControl(final Composite p) { setTitleImage(Images.IMG_VIEW_CONSULTATION_DETAIL.getImage()); sash = new SashForm(p, SWT.VERTICAL); tk = UiDesk.getToolkit();/* w w w. j av a2s .c o m*/ form = tk.createForm(sash); form.getBody().setLayout(new GridLayout(1, true)); form.setText(NO_CONS_SELECTED); cEtiketten = new Composite(form.getBody(), SWT.NONE); cEtiketten.setLayout(new RowLayout(SWT.HORIZONTAL)); cEtiketten.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); cDesc = new Composite(form.getBody(), SWT.NONE); cDesc.setLayout(new RowLayout(SWT.HORIZONTAL)); cDesc.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); lBeh = tk.createLabel(cDesc, NO_CONS_SELECTED); emFont = UiDesk.getFont("Helvetica", 11, SWT.BOLD); //$NON-NLS-1$ lBeh.setFont(emFont); defaultBackground = p.getBackground(); // lBeh.setBackground(); hlMandant = tk.createHyperlink(cDesc, "--", SWT.NONE); //$NON-NLS-1$ hlMandant.addHyperlinkListener(new HyperlinkAdapter() { @Override public void linkActivated(HyperlinkEvent e) { KontaktSelektor ksl = new KontaktSelektor(getSite().getShell(), Mandant.class, Messages.KonsDetailView_SelectMandatorCaption, // $NON-NLS-1$ Messages.KonsDetailView_SelectMandatorBody, new String[] { Mandant.FLD_SHORT_LABEL, Mandant.FLD_NAME1, Mandant.FLD_NAME2 }); // $NON-NLS-1$ if (ksl.open() == Dialog.OK) { actKons.setMandant((Mandant) ksl.getSelection()); setKons(actKons); } } }); hlMandant.setBackground(p.getBackground()); comboViewerFall = new ComboViewer(form.getBody(), SWT.SINGLE); comboViewerFall.setContentProvider(ArrayContentProvider.getInstance()); comboViewerFall.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { return ((Fall) element).getLabel(); } }); comboFallSelectionListener = new ComboFallSelectionListener(); comboViewerFall.addSelectionChangedListener(comboFallSelectionListener); GridData gdFall = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); comboViewerFall.getCombo().setLayoutData(gdFall); text = new EnhancedTextField(form.getBody()); hXrefs = new Hashtable<String, IKonsExtension>(); @SuppressWarnings("unchecked") List<IKonsExtension> xrefs = Extensions.getClasses( Extensions.getExtensions(ExtensionPointConstantsUi.KONSEXTENSION), "KonsExtension", false); //$NON-NLS-1$ //$NON-NLS-2$ for (IKonsExtension x : xrefs) { String provider = x.connect(text); hXrefs.put(provider, x); } text.setXrefHandlers(hXrefs); @SuppressWarnings("unchecked") List<IKonsMakro> makros = Extensions .getClasses(Extensions.getExtensions(ExtensionPointConstantsUi.KONSEXTENSION), "KonsMakro", false); //$NON-NLS-1$ //$NON-NLS-2$ text.setExternalMakros(makros); GridData gd = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL | GridData.GRAB_VERTICAL | GridData.GRAB_HORIZONTAL); text.setLayoutData(gd); tk.adapt(text); diagAndChargeSash = new SashForm(sash, SWT.HORIZONTAL); Composite botleft = tk.createComposite(diagAndChargeSash); botleft.setLayout(new GridLayout(1, false)); Composite botright = tk.createComposite(diagAndChargeSash); botright.setLayout(new GridLayout(1, false)); dd = new DiagnosenDisplay(getSite().getPage(), botleft, SWT.NONE); dd.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); vd = new VerrechnungsDisplay(getSite().getPage(), botright, SWT.NONE); vd.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); getSite().registerContextMenu(ID + ".VerrechnungsDisplay", vd.contextMenuManager, vd.viewer); getSite().setSelectionProvider(vd.viewer); diagAndChargeSash .setWeights(diagAndChargeSashWeights == null ? new int[] { 40, 60 } : diagAndChargeSashWeights); makeActions(); ViewMenus menu = new ViewMenus(getViewSite()); menu.createMenu(versionDisplayAction, versionFwdAction, versionBackAction, GlobalActions.neueKonsAction, GlobalActions.delKonsAction, GlobalActions.redateAction, assignStickerAction, purgeAction); sash.setWeights(sashWeights == null ? new int[] { 80, 20 } : sashWeights); menu.createToolbar(GlobalActions.neueKonsAction, saveAction); GlobalEventDispatcher.addActivationListener(this, this); ElexisEventDispatcher.getInstance().addListeners(eeli_kons, eeli_kons_sync, eeli_pat, eeli_user, eeli_fall); text.connectGlobalActions(getViewSite()); adaptMenus(); setKons((Konsultation) ElexisEventDispatcher.getSelected(Konsultation.class)); }
From source file:ch.elexis.core.ui.views.PatHeuteView.java
License:Open Source License
@Override public void createPartControl(final Composite parent) { parent.setLayout(new GridLayout()); this.parent = parent; makeActions();/*w ww .j a va2 s. co m*/ ldFilter = new ListDisplay<IVerrechenbar>(parent, SWT.NONE, new ListDisplay.LDListener() { public String getLabel(final Object o) { return ((IVerrechenbar) o).getCode(); } public void hyperlinkActivated(final String l) { if (l.equals(LEISTUNG_HINZU)) { try { if (StringTool.isNothing(LeistungenView.ID)) { SWTHelper.alert(Messages.PatHeuteView_error, //$NON-NLS-1$ "LeistungenView.ID"); //$NON-NLS-1$ } getViewSite().getPage().showView(LeistungenView.ID); CodeSelectorHandler.getInstance().setCodeSelectorTarget(dropTarget); } catch (Exception ex) { ExHandler.handle(ex); } } else if (l.equals(STAT_LEEREN)) { ldFilter.clear(); } } }); ldFilter.addHyperlinks(LEISTUNG_HINZU, STAT_LEEREN); ldFilter.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); ((GridData) ldFilter.getLayoutData()).heightHint = 0; dropTarget = new PersistentObjectDropTarget("Statfilter", ldFilter, //$NON-NLS-1$ new DropReceiver()); Composite top = new Composite(parent, SWT.BORDER); top.setLayout(new RowLayout()); final DatePickerCombo dpc = new DatePickerCombo(top, SWT.BORDER); dpc.setDate(datVon.getTime()); dpc.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { datVon.setTimeInMillis(dpc.getDate().getTime()); } }); final DatePickerCombo dpb = new DatePickerCombo(top, SWT.BORDER); dpb.setDate(datBis.getTime()); dpb.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { datBis.setTimeInMillis(dpb.getDate().getTime()); } }); final Button bOpenKons = new Button(top, SWT.CHECK); bOpenKons.setText(Messages.PatHeuteView_open); //$NON-NLS-1$ bOpenKons.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { bOpen = bOpenKons.getSelection(); } }); final Button bClosedKons = new Button(top, SWT.CHECK); bClosedKons.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { bClosed = bClosedKons.getSelection(); } }); ComboViewer cAccountingSys = new ComboViewer(top, SWT.READ_ONLY); cAccountingSys.setContentProvider(ArrayContentProvider.getInstance()); cAccountingSys.setLabelProvider(new LabelProvider()); String allCases = Messages.PatHeuteView_all; List<String> faelle = Arrays.asList(Fall.getAbrechnungsSysteme()); List<String> accountingSys = new ArrayList<String>(); accountingSys.add(allCases); accountingSys.addAll(faelle); cAccountingSys.setInput(accountingSys); cAccountingSys.setSelection(new StructuredSelection(allCases)); cAccountingSys.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); accountSys = (String) selection.getFirstElement(); // call reload if (kons != null) { kload.schedule(); } } }); bClosedKons.setText(Messages.PatHeuteView_billed); //$NON-NLS-1$ bOpenKons.setSelection(bOpen); bClosedKons.setSelection(bClosed); cv = new CommonViewer(); vc = new ViewerConfigurer(new DefaultContentProvider(cv, Patient.class) { @Override public Object[] getElements(final Object inputElement) { if (!CoreHub.acl.request(AccessControlDefaults.ACCOUNTING_STATS)) { return new Konsultation[0]; } if (kons == null) { kons = new Konsultation[0]; kload.schedule(); } return kons; } }, new DefaultLabelProvider() { @Override public String getText(final Object element) { if (element instanceof Konsultation) { Fall fall = ((Konsultation) element).getFall(); if (fall == null) { return Messages.PatHeuteView_noCase + ((Konsultation) element).getLabel(); //$NON-NLS-1$ } Patient pat = fall.getPatient(); return pat.getLabel(); } return super.getText(element); } }, null, new ViewerConfigurer.DefaultButtonProvider(), new SimpleWidgetProvider(SimpleWidgetProvider.TYPE_LIST, SWT.V_SCROLL, cv)); cv.create(vc, parent, SWT.BORDER, getViewSite()); form = tk.createForm(parent); form.setText(Messages.PatHeuteView_all); //$NON-NLS-1$ form.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); Composite bottom = form.getBody(); bottom.setLayout(new GridLayout(2, false)); tk.createLabel(bottom, Messages.PatHeuteView_consultations); //$NON-NLS-1$ tPat = tk.createText(bottom, "", SWT.BORDER); //$NON-NLS-1$ tPat.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); tPat.setEditable(false); tk.createLabel(bottom, Messages.PatHeuteView_accTime); //$NON-NLS-1$ tTime = tk.createText(bottom, "", SWT.BORDER); //$NON-NLS-1$ tTime.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); tTime.setEditable(false); tk.createLabel(bottom, Messages.PatHeuteView_accAmount); //$NON-NLS-1$ tMoney = tk.createText(bottom, "", SWT.BORDER); //$NON-NLS-1$ tMoney.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); tMoney.setEditable(false); // Group grpSel=new Group(parent,SWT.BORDER); // grpSel.setText("Markierte"); // grpSel.setLayoutData(SWTHelper.getFillGridData(1,true,1,true)); Form fSel = tk.createForm(parent); fSel.setText(Messages.PatHeuteView_marked); //$NON-NLS-1$ fSel.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); Composite cSel = fSel.getBody(); cSel.setLayout(new GridLayout(2, false)); tk.createLabel(cSel, Messages.PatHeuteView_accTime); //$NON-NLS-1$ tTime2 = tk.createText(cSel, "", SWT.BORDER); //$NON-NLS-1$ tTime2.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); tk.createLabel(cSel, Messages.PatHeuteView_accAmount); //$NON-NLS-1$ tMoney2 = tk.createText(cSel, "", SWT.BORDER); //$NON-NLS-1$ tMoney2.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); tTime2.setEditable(false); tMoney2.setEditable(false); ViewMenus menus = new ViewMenus(getViewSite()); menus.createMenu(printAction, reloadAction, statAction); menus.createToolbar(reloadAction, filterAction); // setFocus(); cv.getConfigurer().getContentProvider().startListening(); GlobalEventDispatcher.addActivationListener(this, this); kload.schedule(); cv.addDoubleClickListener(new DoubleClickListener() { @Override public void doubleClicked(PersistentObject obj, CommonViewer cv) { Konsultation k = (Konsultation) obj; ElexisEventDispatcher.fireSelectionEvent(k); ElexisEventDispatcher.fireSelectionEvent(k.getFall()); ElexisEventDispatcher.fireSelectionEvent(k.getFall().getPatient()); try { PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .showView(KonsDetailView.ID); } catch (PartInitException e) { ExHandler.handle(e); } } }); }
From source file:ch.elexis.core.ui.views.rechnung.KonsZumVerrechnenView.java
License:Open Source License
@Override public void createPartControl(final Composite parent) { vc = new ViewerConfigurer(new BasicTreeContentProvider(), new ViewerConfigurer.TreeLabelProvider() { // extend the TreeLabelProvider by getImage() @SuppressWarnings("unchecked") @Override// w w w. j av a2 s. c o m public Image getImage(final Object element) { if (element instanceof Tree) { Tree tree = (Tree) element; PersistentObject po = (PersistentObject) tree.contents; if (po instanceof Fall) { if (po.isValid()) { return Images.IMG_OK.getImage(); } else { return Images.IMG_FEHLER.getImage(); } } } return null; } }, null, // new DefaultControlFieldProvider(cv, new // String[]{"Datum","Name","Vorname","Geb. Dat"}), new ViewerConfigurer.DefaultButtonProvider(), new SimpleWidgetProvider(SimpleWidgetProvider.TYPE_TREE, SWT.MULTI | SWT.V_SCROLL, cv)); SashForm sash = new SashForm(parent, SWT.NULL); left = tk.createForm(sash); Composite cLeft = left.getBody(); left.setText(Messages.KonsZumVerrechnenView_allOpenCons); //$NON-NLS-1$ cLeft.setLayout(new GridLayout()); cv.create(vc, cLeft, SWT.NONE, tAll); cv.getViewerWidget().setComparator(new KonsZumVerrechnenViewViewerComparator()); cv.addDoubleClickListener(new DoubleClickListener() { @Override public void doubleClicked(PersistentObject obj, CommonViewer cv) { if (obj instanceof Patient) { try { ElexisEventDispatcher.fireSelectionEvent((Patient) obj); PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .showView(UiResourceConstants.PatientDetailView2_ID); } catch (PartInitException e) { e.printStackTrace(); } } else if (obj instanceof Fall) { try { ElexisEventDispatcher.fireSelectionEvent((Fall) obj); PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .showView(FallDetailView.ID); } catch (PartInitException e) { e.printStackTrace(); } } else if (obj instanceof Konsultation) { try { ElexisEventDispatcher.fireSelectionEvent((Konsultation) obj); PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .showView(KonsDetailView.ID); } catch (PartInitException e) { e.printStackTrace(); } } } }); right = tk.createForm(sash); Composite cRight = right.getBody(); right.setText(Messages.KonsZumVerrechnenView_selected); //$NON-NLS-1$ cRight.setLayout(new GridLayout()); tvSel = new TreeViewer(cRight, SWT.V_SCROLL | SWT.MULTI); // tvSel.getControl().setLayoutData(SWTHelper.getFillGridData(1,true,t,true)); tvSel.getControl().setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); tvSel.setContentProvider(new BasicTreeContentProvider()); tvSel.setLabelProvider(new LabelProvider() { @SuppressWarnings("unchecked") @Override public String getText(final Object element) { return ((PersistentObject) ((Tree) element).contents).getLabel(); } }); tvSel.setComparator(new KonsZumVerrechnenViewViewerComparator()); tvSel.addDropSupport(DND.DROP_MOVE | DND.DROP_COPY, new Transfer[] { TextTransfer.getInstance() }, new DropTargetAdapter() { @Override public void dragEnter(final DropTargetEvent event) { event.detail = DND.DROP_COPY; } @Override public void drop(final DropTargetEvent event) { String drp = (String) event.data; String[] dl = drp.split(","); //$NON-NLS-1$ for (String obj : dl) { PersistentObject dropped = CoreHub.poFactory.createFromString(obj); if (dropped instanceof Patient) { selectPatient((Patient) dropped, tAll, tSelection); } else if (dropped instanceof Fall) { selectFall((Fall) dropped, tAll, tSelection); } else if (dropped instanceof Konsultation) { selectBehandlung((Konsultation) dropped, tAll, tSelection); } } tvSel.refresh(true); } }); tvSel.addSelectionChangedListener(GlobalEventDispatcher.getInstance().getDefaultListener()); tvSel.setInput(tSelection); // GlobalEvents.getInstance().addActivationListener(this,this); sash.setWeights(new int[] { 60, 40 }); makeActions(); MenuManager selMenu = new MenuManager(); selMenu.setRemoveAllWhenShown(true); selMenu.addMenuListener(new IMenuListener() { public void menuAboutToShow(final IMenuManager manager) { manager.add(removeAction); manager.add(expandSelAction); manager.add(expandSelAllAction); } }); tvSel.getControl().setMenu(selMenu.createContextMenu(tvSel.getControl())); tvSel.getControl().addListener(SWT.MouseDoubleClick, new Listener() { @Override public void handleEvent(Event event) { org.eclipse.swt.widgets.Tree theWidget = (org.eclipse.swt.widgets.Tree) (event.widget); TreeItem obj = theWidget.getSelection()[0]; TreeItem parent = obj.getParentItem(); String viewID = ""; if (parent == null) { // no parent at all -> must be patient viewID = UiResourceConstants.PatientDetailView2_ID; } else { // may be case or cons TreeItem grandpa = parent.getParentItem(); if (grandpa == null) { // must be case viewID = FallDetailView.ID; } else { // must be cons viewID = KonsDetailView.ID; } } try { PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(viewID); } catch (PartInitException e) { e.printStackTrace(); } } }); menu = new ViewMenus(getViewSite()); menu.createToolbar(refreshAction, wizardAction, printAction, clearAction, null, billAction); menu.createMenu(wizardAction, selectByDateAction); menu.createViewerContextMenu(cv.getViewerWidget(), detailAction); addPartActivationListener(); }
From source file:ch.elexis.core.ui.views.rechnung.RechnungsBlatt.java
License:Open Source License
public RechnungsBlatt(Composite parent, IViewSite site) { super(parent, SWT.NONE); this.site = site; setLayout(new GridLayout()); form = tk.createScrolledForm(this); form.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); // TableWrapLayout twl=new TableWrapLayout(); Composite body = form.getBody(); body.setLayout(new GridLayout()); // body.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); rnform = new LabeledInputField.AutoForm(body, rndata, 2, 3); // rnform.setEnabled(false); for (InputData li : rndata) { li.setEditable(false);//from w w w. j a v a 2 s. com } rnform.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); rnAdressat = new Label(body, SWT.NONE); rnAdressat.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); IExpansionListener ecExpansionListener = new ExpansionAdapter() { @Override public void expansionStateChanging(final ExpansionEvent e) { ExpandableComposite src = (ExpandableComposite) e.getSource(); saveExpandedState(KEY_RECHNUNGSBLATT + src.getText(), e.getState()); } }; ecBuchungen = WidgetFactory.createExpandableComposite(tk, form, Messages.RechnungsBlatt_bookings); //$NON-NLS-1$ ecBuchungen.addExpansionListener(ecExpansionListener); // tk.createLabel(body, "Buchungen"); buchungen = new ListViewer(ecBuchungen, SWT.V_SCROLL | SWT.BORDER); // TableWrapData twd=new TableWrapData(TableWrapData.FILL_GRAB); SWTHelper.setGridDataHeight(buchungen.getControl(), 4, true); buchungen.setContentProvider(new IStructuredContentProvider() { public void dispose() { } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } public Object[] getElements(Object inputElement) { Rechnung actRn = (Rechnung) inputElement; if (actRn == null) { return new String[] { Messages.RechnungsBlatt_noBillSelected }; } List<Zahlung> lz = actRn.getZahlungen(); return lz.toArray(); } }); tk.adapt(buchungen.getControl(), true, true); ecBuchungen.setClient(buchungen.getControl()); buchungen.setLabelProvider(new DefaultLabelProvider() { public String getColumnText(Object element, int columnIndex) { return getText(element); } @Override public String getText(Object element) { if (element instanceof Zahlung) { Zahlung zahlung = (Zahlung) element; StringBuilder sb = new StringBuilder(); sb.append(zahlung.getLabel()); String bemerkung = zahlung.getBemerkung(); if (!StringTool.isNothing(bemerkung)) { sb.append(" ("); //$NON-NLS-1$ sb.append(bemerkung); sb.append(")"); //$NON-NLS-1$ } return sb.toString(); } else { return element.toString(); } } }); buchungen.setInput(null); // new Label(body,SWT.SEPARATOR|SWT.HORIZONTAL); ecBemerkungen = WidgetFactory.createExpandableComposite(tk, form, Messages.RechnungsBlatt_remarks); //$NON-NLS-1$ ecBemerkungen.addExpansionListener(ecExpansionListener); tBemerkungen = SWTHelper.createText(tk, ecBemerkungen, 5, SWT.BORDER); tBemerkungen.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { if (actRn != null) { actRn.setBemerkung(tBemerkungen.getText()); } } }); ecBemerkungen.setClient(tBemerkungen); // tk.createLabel(body, "Statusnderungen"); ecStatus = WidgetFactory.createExpandableComposite(tk, form, Messages.RechnungsBlatt_sateChangements); //$NON-NLS-1$ ecStatus.addExpansionListener(ecExpansionListener); lbJournal = new org.eclipse.swt.widgets.List(ecStatus, SWT.V_SCROLL | SWT.BORDER); SWTHelper.setGridDataHeight(lbJournal, 4, true); tk.adapt(lbJournal, true, true); ecStatus.setClient(lbJournal); ecFehler = WidgetFactory.createExpandableComposite(tk, form, Messages.RechnungsBlatt_errorMessages); //$NON-NLS-1$ ecFehler.addExpansionListener(ecExpansionListener); tRejects = SWTHelper.createText(tk, ecFehler, 4, SWT.READ_ONLY | SWT.V_SCROLL); ecFehler.setClient(tRejects); ecAusgaben = WidgetFactory.createExpandableComposite(tk, form, Messages.RechnungsBlatt_outputs); //$NON-NLS-1$ ecAusgaben.addExpansionListener(ecExpansionListener); lbOutputs = new org.eclipse.swt.widgets.List(ecAusgaben, SWT.V_SCROLL | SWT.BORDER); ecAusgaben.setClient(lbOutputs); SWTHelper.setGridDataHeight(lbOutputs, 4, true); tk.adapt(lbOutputs, true, true); ecKons = WidgetFactory.createExpandableComposite(tk, form, Messages.RechnungsBlatt_consultations); //$NON-NLS-1$ ecKons.addExpansionListener(ecExpansionListener); konsultationenViewer = new ListViewer(ecKons, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); ecKons.setClient(konsultationenViewer.getList()); konsultationenViewer.setContentProvider(new IStructuredContentProvider() { public Object[] getElements(Object inputElement) { List<Object> elements = new ArrayList<Object>(); if (actRn != null) { List<Konsultation> konsultationen = actRn.getKonsultationen(); if (konsultationen != null) { for (Konsultation konsultation : konsultationen) { elements.add(konsultation); List<IDiagnose> diagnosen = konsultation.getDiagnosen(); if (diagnosen != null) { for (IDiagnose diagnose : diagnosen) { elements.add(diagnose); } } List<Verrechnet> leistungen = konsultation.getLeistungen(); if (leistungen != null) { for (Verrechnet verrechnet : leistungen) { elements.add(verrechnet); } } } } } return elements.toArray(); } public void dispose() { // nothing to do } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { // nothing to do } }); konsultationenViewer.setLabelProvider(new LabelProvider() { public String getText(Object element) { if (element instanceof Konsultation) { Konsultation konsultation = (Konsultation) element; Money sum = new Money(0); List<Verrechnet> leistungen = konsultation.getLeistungen(); if (leistungen != null) { for (Verrechnet verrechnet : leistungen) { int zahl = verrechnet.getZahl(); Money preis = verrechnet.getNettoPreis(); preis.multiply(zahl); sum.addMoney(preis); } } return konsultation.getLabel() + " (" + sum.toString() + ")"; //$NON-NLS-1$ //$NON-NLS-2$ } else if (element instanceof IDiagnose) { IDiagnose diagnose = (IDiagnose) element; return " - " + diagnose.getLabel(); //$NON-NLS-1$ } else if (element instanceof Verrechnet) { Verrechnet verrechnet = (Verrechnet) element; int zahl = verrechnet.getZahl(); Money preis = verrechnet.getNettoPreis(); preis.multiply(zahl); return " - " + zahl + " " + verrechnet.getLabel() + " (" + preis.toString() //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + ")"; //$NON-NLS-1$ } else { return element.toString(); } } }); konsultationenViewer.setInput(this); // form.getToolBarManager().add() ecStorno = WidgetFactory.createExpandableComposite(tk, form, Messages.RechnungsBlatt_storno); ecStorno.addExpansionListener(ecExpansionListener); stornoViewer = new ListViewer(ecStorno, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); ecStorno.setClient(stornoViewer.getList()); stornoViewer.setContentProvider(new IStructuredContentProvider() { @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { //nothing to do } @Override public void dispose() { //nothing to do } @Override public Object[] getElements(Object inputElement) { List<Object> elements = new ArrayList<Object>(); if (actRn != null) { List<Konsultation> konsultationen = actRn.getKonsultationen(); if (konsultationen == null || konsultationen.isEmpty()) { HashMap<Konsultation, List<VerrechnetCopy>> elementsMap = new HashMap<Konsultation, List<VerrechnetCopy>>(); // prepare heading label that will look like this dd.MM.yyyy (cancelled) - amountOfMoney StringBuilder sbHeadingLabel = new StringBuilder(); sbHeadingLabel.append(Messages.AccountView_bill + " " + actRn.getDatumRn()); //$NON-NLS-1$ sbHeadingLabel.append(Messages.RechnungsBlatt_stornoLabel); // store all verrechnetCopies and add label with sum of all cancelled items Query<VerrechnetCopy> vcQuery = new Query<VerrechnetCopy>(VerrechnetCopy.class); vcQuery.add(VerrechnetCopy.RECHNUNGID, Query.EQUALS, actRn.getId()); List<VerrechnetCopy> vcList = vcQuery.execute(); Money sum = new Money(0); for (VerrechnetCopy vc : vcList) { // add amount of money this item/s cost Money price = vc.getNettoPreis(); price.multiply(vc.getZahl()); sum.addMoney(price); // add verrechnet to map addToMap(vc, elementsMap); } // add the map to the elements Set<Konsultation> keys = elementsMap.keySet(); for (Konsultation konsultation : keys) { if (konsultation != null) { elements.add(konsultation); } else { elements.add("?"); //$NON-NLS-1$ } elements.addAll(elementsMap.get(konsultation)); } // finalize heading label by adding sum of money of all cancellations sbHeadingLabel.append(sum.toString()); elements.add(0, sbHeadingLabel.toString()); } } return elements.toArray(); } private void addToMap(VerrechnetCopy copy, HashMap<Konsultation, List<VerrechnetCopy>> elementsMap) { String konsId = copy.get(VerrechnetCopy.BEHANDLUNGID); if (konsId != null && !konsId.isEmpty()) { Konsultation kons = Konsultation.load(konsId); if (kons != null && kons.exists()) { List<VerrechnetCopy> list = elementsMap.get(kons); if (list == null) { list = new ArrayList<VerrechnetCopy>(); } list.add(copy); elementsMap.put(kons, list); } else { List<VerrechnetCopy> list = elementsMap.get(null); if (list == null) { list = new ArrayList<VerrechnetCopy>(); } list.add(copy); elementsMap.put(null, list); } } } }); stornoViewer.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { if (element instanceof VerrechnetCopy) { VerrechnetCopy vc = (VerrechnetCopy) element; int amount = vc.getZahl(); Money price = vc.getNettoPreis(); price.multiply(amount); return " - " + amount + " " + vc.getLabel() + " (" + price.toString() //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + ")"; //$NON-NLS-1$ } else if (element instanceof Konsultation) { return "Konsultation " + ((Konsultation) element).getDatum(); } else { return element.toString(); } } }); stornoViewer.setInput(this); List<IViewContribution> filtered = ViewContributionHelper .getFilteredAndPositionSortedContributions(detailComposites, 0); for (IViewContribution ivc : filtered) { ExpandableComposite ec = WidgetFactory.createExpandableComposite(tk, form, ivc.getLocalizedTitle()); ec.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); ec.addExpansionListener(ecExpansionListener); Composite mainComposite = new Composite(ec, SWT.None); mainComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); mainComposite.setLayout(new GridLayout(1, false)); Composite ret = ivc.initComposite(mainComposite); tk.adapt(ret); ec.setClient(ret); } GlobalEventDispatcher.addActivationListener(this, site.getPart()); }
From source file:ch.elexis.core.ui.views.rechnung.VerrDetailDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { Composite ret = new Composite(parent, SWT.NONE); ret.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); ret.setLayout(new FillLayout()); TreeViewer tv = new TreeViewer(ret, SWT.V_SCROLL); tv.setContentProvider(new ITreeContentProvider() { public Object[] getChildren(Object parentElement) { Tree[] ret = (Tree[]) ((Tree) parentElement).getChildren().toArray(new Tree[0]); Arrays.sort(ret, new Comparator<Tree>() { public int compare(Tree t1, Tree t2) { if (t1.contents instanceof Konsultation) { Konsultation k1 = (Konsultation) t1.contents; return k1.compareTo((Konsultation) t2.contents); }/* w ww . ja v a2 s . com*/ return 0; } }); return ret; } public Object getParent(Object element) { return ((Tree) element).getParent(); } public boolean hasChildren(Object element) { return ((Tree) element).hasChildren(); } public Object[] getElements(Object inputElement) { Tree[] ret = (Tree[]) tree.getChildren().toArray(new Tree[0]); return ret; } public void dispose() { } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } }); tv.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { Object o = ((Tree) element).contents; if (o instanceof Fall) { Fall f = (Fall) o; Money sum = new Money(); List<Konsultation> list = faelle.get(f); if (list != null) { for (Konsultation k : list) { sum.addMoney(calcKons(k)); } } return f.getLabel() + " - " + sum.getAmountAsString(); //$NON-NLS-1$ } else if (o instanceof Konsultation) { Konsultation k = (Konsultation) o; return k.getLabel() + " - " + calcKons(k).getAmountAsString(); //$NON-NLS-1$ } return super.getText(element); } }); tv.setInput(this); return ret; }