List of usage examples for org.eclipse.jface.viewers LabelProvider LabelProvider
public LabelProvider()
From source file:ch.elexis.core.ui.views.RezepteView.java
License:Open Source License
@Override public void createPartControl(final Composite parent) { setTitleImage(Images.IMG_VIEW_RECIPES.getImage()); parent.setLayout(new GridLayout()); master = tk.createForm(parent);/* ww w. j ava 2 s . c o m*/ master.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); master.getBody().setLayout(new FillLayout()); SashForm sash = new SashForm(master.getBody(), SWT.NONE); tv = new TableViewer(sash, SWT.V_SCROLL | SWT.FULL_SELECTION); tv.setContentProvider(new IStructuredContentProvider() { public Object[] getElements(final Object inputElement) { Query<Rezept> qbe = new Query<Rezept>(Rezept.class); /* * Patient act = (Patient) ElexisEventDispatcher .getSelected(Patient.class); */ if (actPatient != null) { qbe.add(Rezept.PATIENT_ID, Query.EQUALS, actPatient.getId()); qbe.orderBy(true, new String[] { Rezept.DATE, PersistentObject.FLD_LASTUPDATE }); List<Rezept> list = qbe.execute(); return list.toArray(); } else { return new Object[0]; } } public void dispose() { /* leer */ } public void inputChanged(final Viewer viewer, final Object oldInput, final Object newInput) { /* leer */ } }); tv.setLabelProvider(new LabelProvider() { @Override public String getText(final Object element) { if (element instanceof Rezept) { Rezept rp = (Rezept) element; return rp.getLabel(); } return element.toString(); } /* * (non-Javadoc) * * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object ) */ @Override public Image getImage(Object element) { List<OutputLog> outputs = OutputLog.getOutputs((PersistentObject) element); if (outputs != null && outputs.size() > 0) { OutputLog o = outputs.get(0); String outputterID = o.getOutputterID(); IOutputter io = OutputLog.getOutputter(outputterID); if (io != null) { return (Image) io.getSymbol(); } } return null; } }); tv.addSelectionChangedListener(GlobalEventDispatcher.getInstance().getDefaultListener()); lvRpLines = new ListViewer(sash); makeActions(); menus = new ViewMenus(getViewSite()); // menus.createToolbar(newRpAction, addLineAction, printAction ); menus.createMenu(newRpAction, addLineAction, printAction, deleteRpAction); menus.createViewerContextMenu(lvRpLines, removeLineAction, changeMedicationAction); // make selection of prescription viewer available for commands of // context menu getSite().setSelectionProvider(lvRpLines); IToolBarManager tm = getViewSite().getActionBars().getToolBarManager(); List<IAction> importers = Extensions.getClasses( Extensions.getExtensions(ExtensionPointConstantsUi.REZEPT_HOOK), //$NON-NLS-1$ "RpToolbarAction", false); //$NON-NLS-1$ for (IAction ac : importers) { tm.add(ac); } if (importers.size() > 0) { tm.add(new Separator()); } tm.add(newRpAction); tm.add(addLineAction); tm.add(printAction); tv.setInput(getViewSite()); /* Implementation Drag&Drop */ PersistentObjectDropTarget.IReceiver dtr = new PersistentObjectDropTarget.IReceiver() { public boolean accept(PersistentObject o) { // TODO Auto-generated method stub return true; } public void dropped(PersistentObject o, DropTargetEvent ev) { Rezept actR = (Rezept) ElexisEventDispatcher.getSelected(Rezept.class); if (actR == null) { SWTHelper.showError(Messages.RezepteView_NoPrescriptionSelected, //$NON-NLS-1$ Messages.RezepteView_PleaseChoosaAPrescription); //$NON-NLS-1$ return; } if (o instanceof Artikel) { Artikel art = (Artikel) o; Prescription p = new Prescription(art, actR.getPatient(), StringConstants.EMPTY, StringConstants.EMPTY); actR.addPrescription(p); refresh(); } else if (o instanceof Prescription) { Prescription pre = (Prescription) o; Prescription now = new Prescription(pre.getArtikel(), actR.getPatient(), pre.getDosis(), pre.getBemerkung()); actR.addPrescription(now); refresh(); } } }; // final TextTransfer textTransfer = TextTransfer.getInstance(); // Transfer[] types = new Transfer[] {textTransfer}; dropTarget = new PersistentObjectDropTarget("Rezept", lvRpLines.getControl(), dtr); //$NON-NLS-1$ lvRpLines.setContentProvider(new RezeptContentProvider()); lvRpLines.setLabelProvider(new RezeptLabelProvider()); lvRpLines.getControl().setToolTipText(Messages.RezepteView_DragMedicamentsHere); //$NON-NLS-1$ /* lvRpLines.addDragSupport(DND.DROP_COPY,types, */ new PersistentObjectDragSource(lvRpLines); lvRpLines.setInput(getViewSite()); addLineAction.setEnabled(false); printAction.setEnabled(false); GlobalEventDispatcher.addActivationListener(this, this); tv.addDoubleClickListener(new IDoubleClickListener() { @Override public void doubleClick(DoubleClickEvent event) { try { RezeptBlatt rp = (RezeptBlatt) getViewSite().getPage().showView(RezeptBlatt.ID); Rezept actR = (Rezept) ElexisEventDispatcher.getSelected(Rezept.class); Brief rpBrief = actR.getBrief(); if (rpBrief != null) { // existing - just reads prescriptiom and opens // RezeptBlatt rp.loadRezeptFromDatabase(actR, rpBrief); } else { // not existing - create prescription and opens // RezeptBlatt rp.createRezept(actR); } } catch (Throwable ex) { ExHandler.handle(ex); } } }); }
From source file:ch.elexis.core.ui.views.ScriptView.java
License:Open Source License
@Override public void createPartControl(Composite parent) { form = UiDesk.getToolkit().createScrolledForm(parent); form.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); form.getBody().setLayout(new FillLayout()); tv = new TableViewer(form.getBody(), SWT.SINGLE | SWT.FULL_SELECTION); tv.setContentProvider(new IStructuredContentProvider() { public Object[] getElements(Object inputElement) { SortedList<Script> sortedScripts = new SortedList<Script>(new ScriptComparator()); List<Script> scripts = Script.getScripts(); for (int i = 0; i < scripts.size(); i++) { Script script = scripts.get(i); sortedScripts.add(script); }// w ww . j av a 2s .c om return sortedScripts.toArray(); } public void dispose() { } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } }); tv.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { if (element instanceof Script) { return ((Script) element).getLabel(); } else { return element.toString(); } } }); new PersistentObjectDragSource(tv); makeActions(); ViewMenus menu = new ViewMenus(getViewSite()); menu.createToolbar(newScriptAction); menu.createViewerContextMenu(tv, editScriptAction, execScriptAction, null, exportScriptAction, removeScriptAction); menu.createMenu(importScriptAction, newScriptAction); tv.setInput(this); }
From source file:ch.elexis.core.ui.views.SearchView.java
License:Open Source License
@Override public void createPartControl(Composite parent) { parent.setLayout(new FillLayout()); Composite main = new Composite(parent, SWT.NONE); main.setLayout(new GridLayout(1, false)); tabFolder = new TabFolder(main, SWT.NONE); tabFolder.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); mainTabItem = new TabItem(tabFolder, SWT.NONE); mainTabItem.setText(Messages.SearchView_general); //$NON-NLS-1$ Composite mainSearchArea = new Composite(tabFolder, SWT.NONE); mainTabItem.setControl(mainSearchArea); mainSearchArea.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); mainSearchArea.setLayout(new GridLayout(1, false)); // text input box Composite mainInputArea = new Composite(mainSearchArea, SWT.NONE); mainInputArea.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); mainInputArea.setLayout(new GridLayout(2, false)); Label searchTextLabel = new Label(mainInputArea, SWT.NONE); searchTextLabel.setLayoutData(SWTHelper.getFillGridData(2, true, 1, false)); searchTextLabel.setText(Messages.SearchView_textToSearch); //$NON-NLS-1$ mainSearchText = new Text(mainInputArea, SWT.BORDER); mainSearchText.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); mainCaseCheckbox = new Button(mainInputArea, SWT.CHECK); mainCaseCheckbox.setText(Messages.SearchView_honorCase); //$NON-NLS-1$ // search options Composite mainOptionsArea = new Composite(mainSearchArea, SWT.NONE); mainOptionsArea.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); mainOptionsArea.setLayout(new GridLayout(2, true)); Group typeGroup = new Group(mainOptionsArea, SWT.SHADOW_OUT); typeGroup.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); typeGroup.setLayout(new RowLayout()); typeGroup.setText(Messages.SearchView_dosearch); //$NON-NLS-1$ consultationRadio = new Button(typeGroup, SWT.RADIO); consultationRadio.setText(Messages.SearchView_consultations); //$NON-NLS-1$ consultationRadio.setSelection(true); Group optionsGroup = new Group(mainOptionsArea, SWT.SHADOW_OUT); optionsGroup.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); optionsGroup.setLayout(new RowLayout()); optionsGroup.setText(Messages.SearchView_limitTo); //$NON-NLS-1$ consultationTextRadio = new Button(optionsGroup, SWT.RADIO); consultationTextRadio.setText(Messages.SearchView_entry); //$NON-NLS-1$ consultationTextRadio.setSelection(true); searchButton = new Button(mainSearchArea, SWT.PUSH); searchButton.setText(Messages.SearchView_searchButtonCaption); //$NON-NLS-1$ GridData gd = SWTHelper.getFillGridData(1, true, 1, false); gd.horizontalAlignment = GridData.END; searchButton.setLayoutData(gd);//from w ww . j a va 2 s .c o m searchButton.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { viewer.refresh(); } public void widgetDefaultSelected(SelectionEvent e) { widgetSelected(e); } }); viewer = new TableViewer(main); Table table = viewer.getTable(); table.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); viewer.setContentProvider(new IStructuredContentProvider() { public void dispose() { // nothing to do } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { // nothing to do } public Object[] getElements(Object inputElement) { return mainSearch(); } }); // simple default label provider viewer.setLabelProvider(new LabelProvider() { public String getText(Object element) { if (element instanceof PersistentObject) { PersistentObject po = (PersistentObject) element; String type = "?"; //$NON-NLS-1$ String label = ""; //$NON-NLS-1$ if (po instanceof Konsultation) { type = Messages.SearchView_consultation; //$NON-NLS-1$ Konsultation konsultation = (Konsultation) po; Fall fall = konsultation.getFall(); Patient pat = fall.getPatient(); label = pat.getLabel() + " - " + fall.getLabel() + " - " //$NON-NLS-1$ //$NON-NLS-2$ + konsultation.getLabel(); } else { label = po.getLabel(); } return type + " - " + label; //$NON-NLS-1$ } else { return super.getText(element); } } }); viewer.setInput(this.getSite()); }
From source file:ch.elexis.core.ui.wizards.DBConnectSelectionConnectionWizardPage.java
License:Open Source License
@Override public void createControl(Composite parent) { Composite area = new Composite(parent, SWT.NONE); area.setLayout(new GridLayout(1, false)); setControl(area);/* w w w .j ava 2 s . c om*/ Group grpStatCurrentConnection = new Group(area, SWT.NONE); grpStatCurrentConnection.setLayout(new GridLayout(2, true)); grpStatCurrentConnection.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); grpStatCurrentConnection.setText(Messages.DBConnectWizardPage_grpStatCurrentConnection_text); createEntityArea(grpStatCurrentConnection); Composite cmpExistConnSelector = new Composite(area, SWT.BORDER); cmpExistConnSelector.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); cmpExistConnSelector.setLayout(new GridLayout(3, false)); Label lblGespeicherteVerbindungen = new Label(cmpExistConnSelector, SWT.NONE); lblGespeicherteVerbindungen.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1)); lblGespeicherteVerbindungen.setText(Messages.DBConnectWizardPage_lblGespeicherteVerbindungen_text); cViewerConns = new ComboViewer(cmpExistConnSelector, SWT.READ_ONLY); Combo combo = cViewerConns.getCombo(); combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); cViewerConns.setContentProvider(ArrayContentProvider.getInstance()); cViewerConns.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { DBConnection dbc = (DBConnection) element; if (dbc.username != null && dbc.connectionString != null) { return dbc.username + "@" + dbc.connectionString; } else { return "Neue Verbindung erstellen"; } } }); cViewerConns.setInput(getDBConnectWizard().getStoredConnectionList()); btnDelStoredConn = new Button(cmpExistConnSelector, SWT.FLAT); btnDelStoredConn.setImage(Images.IMG_DELETE.getImage()); btnDelStoredConn.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { IStructuredSelection selection = (IStructuredSelection) cViewerConns.getSelection(); if (selection.size() > 0) { Object firstElement = selection.getFirstElement(); if (firstElement != null) { getDBConnectWizard().removeConnection((DBConnection) firstElement); cViewerConns.setInput(getDBConnectWizard().getStoredConnectionList()); setCurrentSelection(); } } } }); btnCopyStoredConn = new Button(cmpExistConnSelector, SWT.FLAT); btnCopyStoredConn.setImage(Images.IMG_COPY.getImage()); btnCopyStoredConn.setToolTipText("Verbindungsdaten in Zwischenablage kopieren"); btnCopyStoredConn.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { IStructuredSelection selection = (IStructuredSelection) cViewerConns.getSelection(); if (selection.size() > 0) { Object firstElement = selection.getFirstElement(); if (firstElement != null) { DBConnection dbc = (DBConnection) firstElement; Clipboard cb = new Clipboard(UiDesk.getDisplay()); TextTransfer textTransfer = TextTransfer.getInstance(); try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) { dbc.marshall(bos); cb.setContents(new Object[] { bos.toString() }, new Transfer[] { textTransfer }); } catch (JAXBException | IOException e1) { MessageDialog.openError(UiDesk.getTopShell(), "Error", e1.getMessage()); } } } } }); cViewerConns.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); if (selection.size() > 0) { Object firstElement = selection.getFirstElement(); if (firstElement != null) { DBConnection targetedConnection = (DBConnection) firstElement; getDBConnectWizard().setTargetedConnection(targetedConnection); btnDelStoredConn.setEnabled( !targetedConnection.equals(getDBConnectWizard().getCurrentConnection())); } } } }); setCurrentSelection(); Label lblOderAufDer = new Label(cmpExistConnSelector, SWT.NONE); lblOderAufDer.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1)); lblOderAufDer.setText(Messages.DBConnectSelectionConnectionWizardPage_lblOderAufDer_text); tdbg = new TestDBConnectionGroup(area, SWT.NONE, getDBConnectWizard()); tdbg.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); }
From source file:ch.elexis.dialogs.DiagnoseSelektor.java
License:Open Source License
public DiagnoseSelektor(Shell shell) { super(shell); setTitle(Messages.getString("DiagnoseSelektorDialog.Title")); // create a list of all diagnoses java.util.List<IConfigurationElement> list = Extensions.getExtensions("ch.elexis.Diagnosecode"); diagnoses.add(new NoDiagnose()); if (list != null) { for (IConfigurationElement ic : list) { try { PersistentObjectFactory po = (PersistentObjectFactory) ic .createExecutableExtension("ElementFactory"); //$NON-NLS-1$ CodeSelectorFactory codeSelectorFactory = (CodeSelectorFactory) ic .createExecutableExtension("CodeSelectorFactory"); //$NON-NLS-1$ // get all available diagnoses available (TI can not be Queried as it is // not in the database) if (!(codeSelectorFactory.getCodeSystemName().equalsIgnoreCase("TI-Code"))) { //$NON-NLS-1$ Query<IDiagnose> qd = new Query<IDiagnose>(codeSelectorFactory.getElementClass()); diagnoses.addAll(qd.execute()); } else { // get TI Code via content provider CommonViewer cv = new CommonViewer(); ViewerConfigurer vc = codeSelectorFactory.createViewerConfigurer(new CommonViewer()); cv.create(vc, shell, SWT.NONE, this); ITreeContentProvider tcp = (ITreeContentProvider) vc.getContentProvider(); Object[] roots = tcp.getElements(null); addDiagnoses(tcp, roots); cv.dispose();//from w w w .ja v a2s . com } } catch (CoreException ex) { ExHandler.handle(ex); } } } setListLabelProvider(new LabelProvider() { @Override public String getText(Object element) { if (element == null) { return ""; } return ((IDiagnose) element).getLabel(); } }); setDetailsLabelProvider(new LabelProvider() { @Override public String getText(Object element) { if (element == null) { return ""; } return ((IDiagnose) element).getCodeSystemName() + " " + ((IDiagnose) element).getLabel(); } }); }
From source file:ch.elexis.dialogs.ImageChooser.java
License:Open Source License
public ImageChooser(Shell shell) { super(shell, new LabelProvider() { @Override/*from www . jav a2 s . co m*/ public Image getImage(Object element) { if (element instanceof DBImage) { return ((DBImage) element).getImage(); } return null; } @Override public String getText(Object element) { if (element instanceof DBImage) { return ((DBImage) element).getName(); } return "?"; //$NON-NLS-1$ } }); }
From source file:ch.elexis.impfplan.view.ImpfplanPreferences.java
License:Open Source License
@Override protected Control createContents(Composite parent) { Composite ret = new Composite(parent, SWT.NONE); ret.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); ret.setLayout(new GridLayout()); tv = new TableViewer(ret); tv.getControl().setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); tv.setContentProvider(new ContentProviderAdapter() { @Override//from w w w . ja v a 2 s.c om public Object[] getElements(Object arg0) { return ImpfplanController.allVaccs().toArray(); } }); tv.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { if (element instanceof VaccinationType) { return ((VaccinationType) element).getLabel(); } return "?"; //$NON-NLS-1$ } }); tv.addDoubleClickListener(new IDoubleClickListener() { @Override public void doubleClick(DoubleClickEvent event) { edit(); } }); Composite cButtons = new Composite(ret, SWT.NONE); cButtons.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); cButtons.setLayout(new RowLayout(SWT.HORIZONTAL)); Button bAdd = new Button(cButtons, SWT.PUSH); bAdd.setText(Messages.ImpfplanPreferences_addCaption); bAdd.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { EditVaccinationDialog dlg = new EditVaccinationDialog(getShell(), new VaccinationType( Messages.ImpfplanPreferences_nameDummy, Messages.ImpfplanPreferences_vaccDummy)); if (dlg.open() == Dialog.OK) { tv.refresh(); } } }); MenuManager menu = new MenuManager(); menu.add(removeAction); tv.getControl().setMenu(menu.createContextMenu(tv.getControl())); tv.setInput(this); return ret; }
From source file:ch.elexis.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 { Hub.log.log("Could not find parent ACE " + s.getName(), Log.ERRORS); }//from ww w . j ava2 s . com } } 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 = Hub.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 = Hub.acl.groupsForGrant(right); List<Anwender> users = Hub.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()) { Hub.acl.revoke(g, right); } for (String g : gsel) { Hub.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) { Hub.acl.revoke(an, right); } for (int i : uSel) { Hub.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.tarmedprefs.RechnungsPrefs.java
License:Open Source License
@Override protected Control createContents(Composite parent) { Color blau = UiDesk.getColor(UiDesk.COL_BLUE); hDetailListener = new DetailListener(); focusListener = new TextListener(); Composite ret = new Composite(parent, SWT.NONE); ret.setLayout(new GridLayout()); hMandanten = new HashMap<String, Mandant>(); cbMands = new Combo(ret, SWT.READ_ONLY); cbMands.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); cbMands.addSelectionListener(new SelectionAdapter() { @Override//from ww w . j av a2s .c o m public void widgetSelected(SelectionEvent e) { int i = cbMands.getSelectionIndex(); if (i == -1) { return; } setMandant((Mandant) hMandanten.get(cbMands.getItem(i))); } }); Query<Mandant> qbe = new Query<Mandant>(Mandant.class); List<Mandant> list = qbe.execute(); for (Mandant m : list) { cbMands.add(m.getLabel()); hMandanten.put(m.getLabel(), m); } Group adrs = new Group(ret, SWT.NONE); adrs.setLayout(new GridLayout(2, false)); adrs.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); adrs.setText(Messages.getString("RechnungsPrefs.BillDetails")); //$NON-NLS-1$ hTreat = new Hyperlink(adrs, SWT.NONE); hTreat.setText(Messages.getString("RechnungsPrefs.Treator")); //$NON-NLS-1$ hTreat.setForeground(blau); hTreat.addHyperlinkListener(hDetailListener); tTreat = new Text(adrs, SWT.BORDER | SWT.READ_ONLY); tTreat.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); Label lMandantType = new Label(adrs, SWT.NONE); lMandantType.setText(Messages.getString("RechnungsPrefs.MandantType")); //$NON-NLS-1$ lMandantType.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); cvMandantType = new ComboViewer(adrs); cvMandantType.setContentProvider(new ArrayContentProvider()); cvMandantType.setLabelProvider(new LabelProvider() { public String getText(Object element) { if (element instanceof MandantType) { return Messages.getString("RechnungsPrefs.MandantType." + ((MandantType) element).name()); } return element.toString(); }; }); cvMandantType.setInput(MandantType.values()); cvMandantType.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { ISelection selection = event.getSelection(); if (selection instanceof StructuredSelection && !selection.isEmpty()) { Object element = ((StructuredSelection) selection).getFirstElement(); if (element instanceof MandantType) { if (actMandant != null) { TarmedLeistung.setMandantType(actMandant, (MandantType) element); } } } } }); cvMandantType.getCombo().setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); // bills electronically bBillsElec = new Button(adrs, SWT.CHECK); bBillsElec.setText("Bills electronically"); if (actMandant != null) { bBillsElec.setSelection( CoreHub.getUserSetting(actMandant).get(PreferenceConstants.BILL_ELECTRONICALLY, false)); } bBillsElec.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Settings settings = CoreHub.getUserSetting(actMandant); settings.set(PreferenceConstants.BILL_ELECTRONICALLY, bBillsElec.getSelection()); settings.flush(); } }); // Finanzinstitut // TODO better layout GridData gd; Composite cFinanzinstitut = new Composite(adrs, SWT.NONE); cFinanzinstitut.setLayoutData(SWTHelper.getFillGridData(2, true, 1, false)); cFinanzinstitut.setLayout(new GridLayout(2, false)); Label lFinanzinstitut = new Label(cFinanzinstitut, SWT.NONE); lFinanzinstitut.setText(Messages.getString("RechnungsPrefs.Financeinst")); //$NON-NLS-1$ lFinanzinstitut.setLayoutData(SWTHelper.getFillGridData(2, true, 1, false)); bPost = new Button(cFinanzinstitut, SWT.RADIO); gd = SWTHelper.getFillGridData(1, false, 1, false); gd.verticalAlignment = SWT.TOP; bPost.setLayoutData(gd); bPost.setText(Messages.getString("RechnungsPrefs.post")); //$NON-NLS-1$ bPost.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { // check if Bank has been chosen if (actBank != null && actBank.isValid()) { // clear all bank data actBank = null; actMandant.setInfoElement(ta.RNBANK, ""); //$NON-NLS-1$ // clear data set with BankLister dialog actMandant.setInfoElement(ta.ESRNUMBER, ""); //$NON-NLS-1$ actMandant.setInfoElement(ta.ESRSUB, Messages.getString("RechnungsPrefs.13")); //$NON-NLS-1$ actMandant.setInfoElement(Messages.getString("RechnungsPrefs.department"), ""); //$NON-NLS-1$ //$NON-NLS-2$ actMandant.setInfoElement(Messages.getString("RechnungsPrefs.POBox"), ""); //$NON-NLS-1$ //$NON-NLS-2$ } // check if Post account is already available if (StringTool.isNothing(actMandant.getInfoElement(ta.ESRNUMBER))) { new PostDialog(getShell()).open(); } // update widgets setMandant(actMandant); } }); Composite cPost = new Composite(cFinanzinstitut, SWT.NONE); gd = SWTHelper.getFillGridData(1, true, 1, false); gd.verticalAlignment = SWT.TOP; cPost.setLayoutData(gd); cPost.setLayout(new GridLayout(1, false)); hPost = new Hyperlink(cPost, SWT.NONE); hPost.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); hPost.setText(Messages.getString("RechnungsPrefs.POAccount")); //$NON-NLS-1$ hPost.setForeground(blau); hPost.addHyperlinkListener(new HyperlinkAdapter() { @Override public void linkActivated(HyperlinkEvent e) { new PostDialog(getShell()).open(); // update widgets setMandant(actMandant); } }); tPost = new Text(cPost, SWT.BORDER | SWT.READ_ONLY); tPost.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); bBank = new Button(cFinanzinstitut, SWT.RADIO); gd = SWTHelper.getFillGridData(1, false, 1, false); gd.verticalAlignment = SWT.TOP; bBank.setLayoutData(gd); bBank.setText(Messages.getString("RechnungsPrefs.bank")); //$NON-NLS-1$ bBank.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (actBank == null) { // invalidate available post data actMandant.setInfoElement(ta.ESRNUMBER, ""); //$NON-NLS-1$ new BankLister(getShell()).open(); } } }); Composite cBank = new Composite(cFinanzinstitut, SWT.NONE); gd = SWTHelper.getFillGridData(1, true, 1, false); gd.verticalAlignment = SWT.TOP; cBank.setLayoutData(gd); cBank.setLayout(new GridLayout(1, false)); hBank = new Hyperlink(cBank, SWT.NONE); hBank.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); hBank.setText(Messages.getString("RechnungsPrefs.bankconnection")); //$NON-NLS-1$ hBank.setForeground(blau); hBank.addHyperlinkListener(new HyperlinkAdapter() { @Override public void linkActivated(HyperlinkEvent e) { // KontaktSelektor dlg=new // KontaktSelektor(getShell(),Organisation.class,"Bankverbindung auswhlen","Bitte geben Sie an, auf welches Finanzinstitut\nIhre Einuahlungsscheine lauten sollen"); BankLister dlg = new BankLister(getShell()); dlg.open(); } }); tBank = new Text(cBank, SWT.BORDER | SWT.READ_ONLY); tBank.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); // Trust Center Group gTC = new Group(ret, SWT.NONE); gTC.setText(Messages.getString("RechnungsPrefs.trustcenter")); //$NON-NLS-1$ gTC.setLayout(new GridLayout()); gTC.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); bUseTC = new Button(gTC, SWT.CHECK); bUseTC.setText(Messages.getString("RechnungsPrefs.TrustCenterUsed")); //$NON-NLS-1$ bUseTC.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { actMandant.setInfoElement(PreferenceConstants.USETC, bUseTC.getSelection() == true ? "1" : "0"); //$NON-NLS-1$ //$NON-NLS-2$ } }); cbTC = new Combo(gTC, SWT.NONE); for (String k : TrustCenters.tc.keySet()) { cbTC.add(k); } cbTC.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { TarmedRequirements.setTC(actMandant, cbTC.getText()); // actMandant.setInfoElement(PreferenceConstants.TARMEDTC, // cbTC.getText()); } }); Group gResponsible = new Group(ret, SWT.NONE); gResponsible.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); gResponsible.setLayout(new FillLayout()); gResponsible.setText("Responsible Doctor"); responsible = new ResponsibleComposite(gResponsible, SWT.NONE); /* * bUseEDA=new Button(gTC,SWT.CHECK); bUseEDA.setText(Messages.getString( * "RechnungsPrefs.TrustCewntereDA")); //$NON-NLS-1$ bUseEDA.addSelectionListener(new * SelectionAdapter(){ * * @Override public void widgetSelected(SelectionEvent e) { * actMandant.setInfoElement(PreferenceConstants.USEEDA, bUseEDA.getSelection()==true ? "1" * : "0"); //$NON-NLS-1$ //$NON-NLS-2$ } * * }); bWithImage=new Button(gTC,SWT.CHECK); bWithImage.setText(Messages. * getString("RechnungsPrefs.ImagesToTrustCenter")); //$NON-NLS-1$ * bWithImage.addSelectionListener(new SelectionAdapter(){ * * @Override public void widgetSelected(SelectionEvent e) { * actMandant.setInfoElement(PreferenceConstants.TCWITHIMAGE, * bWithImage.getSelection()==true ? "1" : "0"); //$NON-NLS-1$ //$NON-NLS-2$ } * * }); */ // OCR font addFontsGroup(ret); Group gAuto = new Group(ret, SWT.NONE); gAuto.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); gAuto.setLayout(new FillLayout()); final Button bAddChildren = new Button(gAuto, SWT.CHECK); bAddChildren.setText("Kinderzuschlge automatisch verrechnen"); bAddChildren.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { CoreHub.mandantCfg.set(PREF_ADDCHILDREN, bAddChildren.getSelection()); } }); bAddChildren.setSelection(CoreHub.mandantCfg.get(PREF_ADDCHILDREN, false)); cbMands.select(0); setMandant((Mandant) hMandanten.get(cbMands.getItem(0))); return ret; }
From source file:ch.elexis.tarmedprefs.ResponsibleComposite.java
License:Open Source License
private void createContent() { setLayout(new GridLayout()); responsibleViewer = new ComboViewer(this); responsibleViewer.setContentProvider(new ArrayContentProvider()); responsibleViewer.getCombo().setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); responsibleViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override/* w w w . java 2s . c o m*/ public void selectionChanged(SelectionChangedEvent event) { StructuredSelection selection = (StructuredSelection) responsibleViewer.getSelection(); if (selection != null && !selection.isEmpty()) { Mandant selected = (Mandant) selection.getFirstElement(); if (selected != noMandant) { mandant.setInfoElement(TarmedRequirements.RESPONSIBLE_INFO_KEY, selected.getId()); } else { mandant.setInfoElement(TarmedRequirements.RESPONSIBLE_INFO_KEY, ""); } } } }); responsibleViewer.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { if (element instanceof Mandant) { return ((Mandant) element).getLabel(); } return super.getText(element); } }); }