List of usage examples for org.eclipse.jface.viewers IStructuredSelection getFirstElement
public Object getFirstElement();
null
if the selection is empty. From source file:ch.elexis.core.ui.views.codesystems.BlockDetailDisplay.java
License:Open Source License
private void makeActions() { removeLeistung = new Action(Messages.BlockDetailDisplay_remove) { //$NON-NLS-1$ @Override//from w w w.ja v a2 s . co m public void run() { Leistungsblock lb = (Leistungsblock) ElexisEventDispatcher.getSelected(Leistungsblock.class); if (lb != null) { IStructuredSelection sel = (IStructuredSelection) lLst.getSelection(); Object o = sel.getFirstElement(); if (o != null) { lb.removeElement((ICodeElement) o); lLst.refresh(); } } } }; moveUpAction = new Action(Messages.BlockDetailDisplay_moveUp) { //$NON-NLS-1$ @Override public void run() { moveElement(-1); } }; moveDownAction = new Action(Messages.BlockDetailDisplay_moveDown) { //$NON-NLS-1$ @Override public void run() { moveElement(1); } }; editAction = new Action(Messages.BlockDetailDisplay_changeAction) { //$NON-NLS-1$ { setImageDescriptor(Images.IMG_EDIT.getImageDescriptor()); setToolTipText(Messages.BlockDetailDisplay_changeActionTooltip); //$NON-NLS-1$ } @Override public void run() { IStructuredSelection sel = (IStructuredSelection) lLst.getSelection(); PersistentObject parameter = (PersistentObject) sel.getFirstElement(); EditEigenleistungUi.executeWithParams(parameter); } }; }
From source file:ch.elexis.core.ui.views.codesystems.BlockDetailDisplay.java
License:Open Source License
private void moveElement(final int off) { Leistungsblock lb = (Leistungsblock) ElexisEventDispatcher.getSelected(Leistungsblock.class); if (lb != null) { IStructuredSelection sel = (IStructuredSelection) lLst.getSelection(); Object o = sel.getFirstElement(); if (o != null) { lb.moveElement((ICodeElement) o, off); lLst.refresh();/*from w ww.j a v a2 s.c o m*/ } } }
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 w w. ja v a 2s. c om 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.BillingProposalView.java
License:Open Source License
@Override public void createPartControl(Composite parent) { viewer = new TableViewer(parent, SWT.FULL_SELECTION | SWT.BORDER | SWT.MULTI | SWT.VIRTUAL); viewer.getTable().setHeaderVisible(true); viewer.setContentProvider(new BillingInformationContentProvider(viewer)); comparator = new BillingProposalViewerComparator(); viewer.setComparator(comparator);/*from w ww . j a v a 2 s.c o m*/ TableViewerColumn patNameColumn = new TableViewerColumn(viewer, SWT.NONE); patNameColumn.getColumn().setWidth(175); patNameColumn.getColumn().setText("Patient"); patNameColumn.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(Object element) { if (element instanceof BillingInformation) { return ((BillingInformation) element).getPatientName(); } else { return super.getText(element); } } }); patNameColumn.getColumn().addSelectionListener(getSelectionAdapter(0)); TableViewerColumn patNrColumn = new TableViewerColumn(viewer, SWT.NONE); patNrColumn.getColumn().setWidth(50); patNrColumn.getColumn().setText("PatNr"); patNrColumn.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(Object element) { if (element instanceof BillingInformation) { return Integer.toString(((BillingInformation) element).getPatientNr()); } else { return super.getText(element); } } }); patNrColumn.getColumn().addSelectionListener(getSelectionAdapter(1)); TableViewerColumn dateColumn = new TableViewerColumn(viewer, SWT.NONE); dateColumn.getColumn().setWidth(75); dateColumn.getColumn().setText("Datum"); dateColumn.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(Object element) { if (element instanceof BillingInformation) { return ((BillingInformation) element).getDate() .format(DateTimeFormatter.ofPattern("dd.MM.yyyy")); } else { return super.getText(element); } } }); dateColumn.getColumn().addSelectionListener(getSelectionAdapter(2)); TableViewerColumn accountingSystemColumn = new TableViewerColumn(viewer, SWT.NONE); accountingSystemColumn.getColumn().setWidth(75); accountingSystemColumn.getColumn().setText("Fall"); accountingSystemColumn.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(Object element) { if (element instanceof BillingInformation) { return ((BillingInformation) element).getAccountingSystem(); } else { return super.getText(element); } } }); TableViewerColumn insurerColumn = new TableViewerColumn(viewer, SWT.NONE); insurerColumn.getColumn().setWidth(175); insurerColumn.getColumn().setText("Versicherer"); insurerColumn.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(Object element) { if (element instanceof BillingInformation) { return ((BillingInformation) element).getInsurer(); } else { return super.getText(element); } } }); TableViewerColumn totalColumn = new TableViewerColumn(viewer, SWT.NONE); totalColumn.getColumn().setWidth(75); totalColumn.getColumn().setText("Total"); totalColumn.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(Object element) { if (element instanceof BillingInformation) { return ((BillingInformation) element).getTotal(); } else { return super.getText(element); } } }); TableViewerColumn checkResultColumn = new TableViewerColumn(viewer, SWT.NONE); checkResultColumn.getColumn().setWidth(200); checkResultColumn.getColumn().setText("Prfergebnis"); checkResultColumn.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(Object element) { if (element instanceof BillingInformation) { return ((BillingInformation) element).getCheckResultMessage(); } else { return super.getText(element); } } @Override public Color getBackground(Object element) { if (element instanceof BillingInformation) { return ((BillingInformation) element).isOk() ? lightGreen : lightRed; } else { return super.getForeground(element); } } }); viewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); if (selection != null && !selection.isEmpty()) { if (selection.getFirstElement() instanceof BillingInformation) { Konsultation kons = ((BillingInformation) selection.getFirstElement()).getKonsultation(); ElexisEventDispatcher.fireSelectionEvent(kons); } } } }); viewer.getControl().addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { if (e.keyCode == SWT.F5) { refresh(); } } }); MenuManager menuManager = new MenuManager(); Menu menu = menuManager.createContextMenu(viewer.getControl()); viewer.getControl().setMenu(menu); getSite().registerContextMenu(menuManager, viewer); getSite().setSelectionProvider(viewer); }
From source file:ch.elexis.core.ui.views.RezepteView.java
License:Open Source License
private void makeActions() { newRpAction = new Action(Messages.RezepteView_newPrescriptionAction) { //$NON-NLS-1$ {//from ww w . j a v a 2 s . c o m setImageDescriptor(Images.IMG_NEW.getImageDescriptor()); setToolTipText(Messages.RezepteView_newPrescriptonTooltip); //$NON-NLS-1$ } @Override public void run() { Patient act = (Patient) ElexisEventDispatcher.getSelected(Patient.class); if (act == null) { MessageBox mb = new MessageBox(getViewSite().getShell(), SWT.ICON_INFORMATION | SWT.OK); mb.setText(Messages.RezepteView_newPrescriptionError); //$NON-NLS-1$ mb.setMessage(Messages.RezepteView_noPatientSelected); //$NON-NLS-1$ mb.open(); return; } Fall fall = (Fall) ElexisEventDispatcher.getSelected(Fall.class); if (fall == null) { Konsultation k = act.getLetzteKons(false); if (k == null) { SWTHelper.alert(Messages.RezepteView_noCaseSelected, //$NON-NLS-1$ Messages.RezepteView_pleaseCreateOrChooseCase); //$NON-NLS-1$ return; } } Rezept rezept = new Rezept(act); tv.refresh(); doSelectNewRezept(rezept); doAddLine(); } }; deleteRpAction = new Action(Messages.RezepteView_deletePrescriptionActiom) { //$NON-NLS-1$ @Override public void run() { Rezept rp = (Rezept) ElexisEventDispatcher.getSelected(Rezept.class); if (MessageDialog.openConfirm(getViewSite().getShell(), Messages.RezepteView_deletePrescriptionActiom, //$NON-NLS-1$ MessageFormat.format(Messages.RezepteView_deletePrescriptionConfirm, rp //$NON-NLS-1$ .getDate()))) { rp.delete(); tv.refresh(); } } }; removeLineAction = new Action(Messages.RezepteView_deleteLineAction) { //$NON-NLS-1$ @Override public void run() { Rezept rp = (Rezept) ElexisEventDispatcher.getSelected(Rezept.class); IStructuredSelection sel = (IStructuredSelection) lvRpLines.getSelection(); Prescription p = (Prescription) sel.getFirstElement(); if ((rp != null) && (p != null)) { rp.removePrescription(p); lvRpLines.refresh(); } /* * RpZeile z=(RpZeile)sel.getFirstElement(); if((rp!=null) && (z!=null)){ * rp.removeLine(z); lvRpLines.refresh(); } */ } }; addLineAction = new Action(Messages.RezepteView_newLineAction) { //$NON-NLS-1$ @Override public void run() { doAddLine(); } }; printAction = new Action(Messages.RezepteView_printAction) { //$NON-NLS-1$ @Override public void run() { try { RezeptBlatt rp = (RezeptBlatt) getViewSite().getPage().showView(RezeptBlatt.ID); Rezept actR = (Rezept) ElexisEventDispatcher.getSelected(Rezept.class); Brief rpBrief = actR.getBrief(); if (rpBrief == null) // not yet created - just create a new Rezept rp.createRezept(actR); else { // Brief for Rezept already exists: // ask if it should be recreated or just shown String[] dialogButtonLabels = { Messages.RezepteView_RecreatePrescription, Messages.RezepteView_ShowPrescription, Messages.RezepteView_PrescriptionCancel }; MessageDialog msg = new MessageDialog(null, Messages.RezepteView_CreatePrescription, //$NON-NLS-1$ null, Messages.RezepteView_ReallyWantToRecreatePrescription, //$NON-NLS-1$ MessageDialog.WARNING, dialogButtonLabels, 2); int result = msg.open(); switch (result) { case 0: // recreate rezept rp.createRezept(actR); break; case 1: // open rezept rp.loadRezeptFromDatabase(actR, rpBrief); break; case 2: // cancel or closebox - do nothing break; } } } catch (Exception ex) { ExHandler.handle(ex); } } }; changeMedicationAction = new RestrictedAction(AccessControlDefaults.MEDICATION_MODIFY, Messages.RezepteView_ChangeLink) { //$NON-NLS-1$ { setImageDescriptor(Images.IMG_EDIT.getImageDescriptor()); setToolTipText(Messages.RezepteView_ChangeTooltip); //$NON-NLS-1$ } public void doRun() { Rezept rp = (Rezept) ElexisEventDispatcher.getSelected(Rezept.class); IStructuredSelection sel = (IStructuredSelection) lvRpLines.getSelection(); Prescription pr = (Prescription) sel.getFirstElement(); if (pr != null) { new MediDetailDialog(getViewSite().getShell(), pr).open(); lvRpLines.refresh(); } } }; addLineAction.setImageDescriptor(Images.IMG_ADDITEM.getImageDescriptor()); printAction.setImageDescriptor(Images.IMG_PRINTER.getImageDescriptor()); deleteRpAction.setImageDescriptor(Images.IMG_DELETE.getImageDescriptor()); }
From source file:ch.elexis.core.ui.views.ScriptView.java
License:Open Source License
private void makeActions() { exportScriptAction = new Action("export script") { {/*from w w w .j a v a 2s . c o m*/ setImageDescriptor(Images.IMG_EXPORT.getImageDescriptor()); setToolTipText("export script into a text file"); } @Override public void run() { IStructuredSelection sel = (IStructuredSelection) tv.getSelection(); if (sel != null && sel.size() != 0) { FileDialog fd = new FileDialog(getViewSite().getShell(), SWT.SAVE); Script script = (Script) sel.getFirstElement(); fd.setFileName(script.getLabel()); String filename = fd.open(); if (filename != null) { try { File file = new File(filename); FileWriter fw = new FileWriter(file); fw.write(script.getString()); fw.close(); } catch (IOException ex) { SWTHelper.showError("IO Error", "Could not write file " + filename + " : " + ex.getMessage()); } } } } }; importScriptAction = new RestrictedAction(AccessControlDefaults.SCRIPT_EDIT, "Import Script") { { setImageDescriptor(Images.IMG_IMPORT.getImageDescriptor()); setToolTipText("Import script from a text file"); } @Override public void doRun() { FileDialog fd = new FileDialog(getViewSite().getShell(), SWT.OPEN); String filename = fd.open(); if (fd != null) { try { /* Script script= */Script.importFromFile(filename); tv.refresh(); } catch (ElexisException e) { SWTHelper.showError("IO Error", e.getMessage()); } } } }; newScriptAction = new RestrictedAction(AccessControlDefaults.SCRIPT_EDIT, Messages.ScriptView_newScriptAction) { //$NON-NLS-1$ { setImageDescriptor(Images.IMG_NEW.getImageDescriptor()); setToolTipText(Messages.ScriptView_newScriptTooltip); //$NON-NLS-1$ } @Override public void doRun() { InputDialog inp = new InputDialog(getSite().getShell(), Messages.ScriptView_enterNameCaption, //$NON-NLS-1$ Messages.ScriptView_enterNameBody, null, //$NON-NLS-1$ null); if (inp.open() == Dialog.OK) { try { Script.create(inp.getValue(), ""); } catch (ElexisException e) { ExHandler.handle(e); SWTHelper.showError("Fehler bei Scripterstellung", e.getMessage()); } tv.refresh(); } } }; editScriptAction = new RestrictedAction(AccessControlDefaults.SCRIPT_EDIT, Messages.ScriptView_editScriptAction) { //$NON-NLS-1$ { setImageDescriptor(Images.IMG_EDIT.getImageDescriptor()); setToolTipText(Messages.ScriptView_editScriptTooltip); //$NON-NLS-1$ } @Override public void doRun() { IStructuredSelection sel = (IStructuredSelection) tv.getSelection(); if (sel != null && sel.size() != 0) { Script script = (Script) sel.getFirstElement(); ScriptEditor sce = new ScriptEditor(getSite().getShell(), script.getString(), script.getLabel()); if (sce.open() == Dialog.OK) { script.putString(sce.getScript()); } } } }; removeScriptAction = new RestrictedAction(AccessControlDefaults.SCRIPT_EDIT, Messages.ScriptView_deleteScriptAction) { //$NON-NLS-1$ { setImageDescriptor(Images.IMG_DELETE.getImageDescriptor()); setToolTipText(Messages.ScriptView_deleteScriptTooltip); //$NON-NLS-1$ } @Override public void doRun() { IStructuredSelection sel = (IStructuredSelection) tv.getSelection(); if (sel != null && sel.size() != 0) { Script script = (Script) sel.getFirstElement(); script.delete(); tv.refresh(); } } }; execScriptAction = new RestrictedAction(AccessControlDefaults.SCRIPT_EXECUTE, Messages.ScriptView_executeScriptAction) { //$NON-NLS-1$ { setImageDescriptor(Images.IMG_GOFURTHER.getImageDescriptor()); setToolTipText(Messages.ScriptView_executeScriptTooltip); //$NON-NLS-1$ } @Override public void doRun() { IStructuredSelection sel = (IStructuredSelection) tv.getSelection(); if (sel != null && sel.size() != 0) { Script script = (Script) sel.getFirstElement(); try { String contents = script.getString(); ArrayList<String> vars = new ArrayList<String>(); Pattern var = Pattern.compile("\\$[0-9a-z]+", Pattern.CASE_INSENSITIVE); Matcher m = var.matcher(contents); while (m.find()) { String varname = m.group(); if (!vars.contains(varname)) { vars.add(varname); } } String varString = null; if (vars.size() > 0) { SetVarsDlg dlg = new SetVarsDlg(getViewSite().getShell(), vars); if (dlg.open() == Dialog.OK) { varString = dlg.getResult(); } } Object ret = script.execute(varString); SWTHelper.showInfo(Messages.ScriptView_ScriptOutput, ret.toString()); //$NON-NLS-1$ } catch (Exception ex) { ExHandler.handle(ex); SWTHelper.showError("Fehler beim Ausfhren des Scripts", ex.getMessage()); } } } }; }
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 a v a 2s . 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.icpc.views.ChapterDisplay.java
License:Open Source License
public ChapterDisplay(Composite parent, final String chapter) { super(parent, SWT.NONE); this.chapter = chapter; setLayout(new GridLayout(2, false)); fLeft = tk.createScrolledForm(this); fLeft.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); fLeft.setText(chapter);/*from www .j a v a 2 s . c om*/ Composite cLeft = fLeft.getBody(); cLeft.setLayout(new GridLayout()); cLeft.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); final Composite cRight = tk.createComposite(this); cRight.setLayout(new GridLayout()); cRight.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); ec = new ExpandableComposite[IcpcCode.components.length]; for (int i = 0; i < ec.length; i++) { String c = IcpcCode.components[i]; ec[i] = tk.createExpandableComposite(cLeft, ExpandableComposite.TWISTIE); ec[i].setText(c); UserSettings.setExpandedState(ec[i], UC2_HEADING + c.substring(0, 1)); Composite inlay = new Composite(ec[i], SWT.NONE); inlay.setLayout(new FillLayout()); CommonViewer cv = new CommonViewer(); ViewerConfigurer vc = new ViewerConfigurer(new ComponentContentProvider(c), new DefaultLabelProvider(), new SimpleWidgetProvider(SimpleWidgetProvider.TYPE_TABLE, SWT.SINGLE, cv)); ec[i].setData(cv); cv.create(vc, inlay, SWT.NONE, this); cv.addDoubleClickListener(new CommonViewer.DoubleClickListener() { public void doubleClicked(PersistentObject obj, CommonViewer cv) { ICodeSelectorTarget target = CodeSelectorHandler.getInstance().getCodeSelectorTarget(); if (target != null) { target.codeSelected(obj); } } }); cv.getViewerWidget().addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection sel = (IStructuredSelection) event.getSelection(); if (!sel.isEmpty()) { IcpcCode code = (IcpcCode) sel.getFirstElement(); tCrit.setText(code.get("criteria")); tIncl.setText(code.get("inclusion")); tExcl.setText(code.get("exclusion")); tNote.setText(code.get("note")); cRight.layout(); } } }); ec[i].addExpansionListener(new ExpansionAdapter() { @Override public void expansionStateChanging(final ExpansionEvent e) { ExpandableComposite src = (ExpandableComposite) e.getSource(); if (e.getState() == true) { CommonViewer cv = (CommonViewer) src.getData(); cv.notify(CommonViewer.Message.update); } UserSettings.saveExpandedState(UC2_HEADING + src.getText().substring(0, 1), e.getState()); } public void expansionStateChanged(ExpansionEvent e) { fLeft.reflow(true); } }); ec[i].setClient(inlay); } Section sCrit = tk.createSection(cRight, Section.EXPANDED); sCrit.setText("Kriterien"); tCrit = tk.createText(sCrit, "\n", SWT.BORDER | SWT.MULTI); sCrit.setClient(tCrit); Section sIncl = tk.createSection(cRight, Section.EXPANDED); sIncl.setText("Einschliesslich"); tIncl = tk.createText(sIncl, "\n", SWT.BORDER | SWT.MULTI); sIncl.setClient(tIncl); Section sExcl = tk.createSection(cRight, Section.EXPANDED); sExcl.setText("Ausser"); tExcl = tk.createText(sExcl, "", SWT.BORDER | SWT.MULTI); Section sNote = tk.createSection(cRight, Section.EXPANDED); tNote = tk.createText(cRight, "\n", SWT.BORDER | SWT.MULTI); sNote.setText("Anmerkung"); }
From source file:ch.elexis.impfplan.view.AddVaccinationDialog.java
License:Open Source License
@Override protected void okPressed() { IStructuredSelection sel = (IStructuredSelection) tv.getSelection(); if (sel.isEmpty()) { MessageDialog.openError(getShell(), Messages.AddVaccinationDialog_enterVaccinationTitle, Messages.AddVaccinationDialog_enterVaccinationTextError + "."); return;//from w w w. ja v a2 s. c o m } result = (VaccinationType) sel.getFirstElement(); date = new TimeTool(di.getDate()); bUnexact = bCa.getSelection(); super.okPressed(); }
From source file:ch.elexis.impfplan.view.ImpfplanPreferences.java
License:Open Source License
private void edit() { IStructuredSelection sel = (IStructuredSelection) tv.getSelection(); if (!sel.isEmpty()) { VaccinationType t = (VaccinationType) sel.getFirstElement(); if (new EditVaccinationDialog(getShell(), t).open() == Dialog.OK) { tv.refresh(true);// www . j a v a 2 s . c om } } }