List of usage examples for org.eclipse.jface.viewers StructuredSelection StructuredSelection
public StructuredSelection(List elements)
List
. From source file:ch.elexis.core.ui.contacts.preferences.BezugsKontaktSettings.java
License:Open Source License
@Override protected Control createContents(Composite parent) { updateExistingEntriesIds.clear();//from ww w . j a v a2 s . c om Composite container = new Composite(parent, SWT.NULL); container.setLayout(new GridLayout(1, false)); Group group = new Group(container, SWT.NONE); group.setLayout(new GridLayout(1, false)); group.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); group.setText(Messages.Bezugskontakt_Definition); Composite composite = new Composite(group, SWT.NONE); GridData gd_composite = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1); gd_composite.heightHint = 300; composite.setLayoutData(gd_composite); TableColumnLayout tcl_composite = new TableColumnLayout(); composite.setLayout(tcl_composite); tableViewer = new TableViewer(composite, SWT.BORDER | SWT.FULL_SELECTION); tableViewer.setContentProvider(ArrayContentProvider.getInstance()); tableBezugsKontaktRelations = tableViewer.getTable(); tableBezugsKontaktRelations.setHeaderVisible(true); tableBezugsKontaktRelations.setLinesVisible(true); if (allowEditing) { Menu menu = new Menu(tableBezugsKontaktRelations); tableBezugsKontaktRelations.setMenu(menu); MenuItem mntmAddBezugsKontaktRelation = new MenuItem(menu, SWT.NONE); mntmAddBezugsKontaktRelation.setText(Messages.Bezugskontakt_Add); mntmAddBezugsKontaktRelation.setImage(Images.IMG_NEW.getImage()); mntmAddBezugsKontaktRelation.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { BezugsKontaktRelation bezugsKontaktRelation = new BezugsKontaktRelation("", RelationshipType.AGENERIC, RelationshipType.AGENERIC); tableViewer.add(bezugsKontaktRelation); tableViewer.setSelection(new StructuredSelection(bezugsKontaktRelation)); } }); MenuItem mntmRemoveBezugsKontaktRelation = new MenuItem(menu, SWT.NONE); mntmRemoveBezugsKontaktRelation.setText(Messages.Bezugskontakt_Delete); mntmRemoveBezugsKontaktRelation.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { int selectionsIdx = tableViewer.getTable().getSelectionIndex(); if (selectionsIdx != -1) { boolean ret = MessageDialog.openQuestion(UiDesk.getTopShell(), Messages.Bezugskontakt_ConfirmDelete, Messages.Bezugskontakt_ConfirmDeleteText); if (ret) { tableViewer.getTable().remove(selectionsIdx); } } } }); } TableViewerColumn viewCol = new TableViewerColumn(tableViewer, SWT.NONE); TableColumn col = viewCol.getColumn(); tcl_composite.setColumnData(col, new ColumnWeightData(1, 140)); col.setText(Messages.BezugsKonktat_Reference); col.setToolTipText(Messages.Bezugskontakt_ReferenceTooltip); viewCol.setLabelProvider(new CellLabelProvider() { @Override public void update(ViewerCell cell) { BezugsKontaktRelation s = (BezugsKontaktRelation) cell.getElement(); if (s == null) return; cell.setText(s.getName()); } }); viewCol.setEditingSupport(new EditingSupport(tableViewer) { @Override protected void setValue(Object element, Object value) { if (element instanceof BezugsKontaktRelation) { String newName = String.valueOf(value); BezugsKontaktRelation tableData = null; for (TableItem tableItem : tableViewer.getTable().getItems()) { tableData = (BezugsKontaktRelation) tableItem.getData(); if (tableData != null && !tableData.equals(element) && !tableData.getName().isEmpty() && newName.equalsIgnoreCase(tableData.getName())) { MessageDialog.openError(UiDesk.getTopShell(), "", Messages.Bezugskontakt_NameMustBeUnique); return; } } BezugsKontaktRelation bezugsKontaktRelation = (BezugsKontaktRelation) element; if (!bezugsKontaktRelation.getName().equals(newName)) { bezugsKontaktRelation.setName(newName); getViewer().update(bezugsKontaktRelation, null); openConfirmUpdateExistingData(bezugsKontaktRelation); } } } @Override protected Object getValue(Object element) { if (element instanceof BezugsKontaktRelation) { return ((BezugsKontaktRelation) element).getName(); } return null; } @Override protected CellEditor getCellEditor(Object element) { return new TextCellEditor(tableViewer.getTable()); } @Override protected boolean canEdit(Object element) { return allowEditing; } }); viewCol = new TableViewerColumn(tableViewer, SWT.NONE); col = viewCol.getColumn(); tcl_composite.setColumnData(col, new ColumnWeightData(0, 140)); col.setText(Messages.Bezugskontakt_RelationFrom); viewCol.setLabelProvider(new CellLabelProvider() { @Override public void update(ViewerCell cell) { BezugsKontaktRelation s = (BezugsKontaktRelation) cell.getElement(); if (s == null) return; cell.setText(LocalizeUtil.getLocaleText(s.getDestRelationType())); } }); viewCol.setEditingSupport(new EditingSupport(tableViewer) { @Override protected void setValue(Object element, Object value) { if (element instanceof BezugsKontaktRelation && value instanceof Integer) { BezugsKontaktRelation bezugsKontaktRelation = (BezugsKontaktRelation) element; RelationshipType[] allRelationshipTypes = RelationshipType.values(); if ((int) value != -1 && !bezugsKontaktRelation.getDestRelationType() .equals(allRelationshipTypes[(int) value])) { bezugsKontaktRelation.setDestRelationType(allRelationshipTypes[(int) value]); getViewer().update(bezugsKontaktRelation, null); openConfirmUpdateExistingData(bezugsKontaktRelation); } } } @Override protected Object getValue(Object element) { if (element instanceof BezugsKontaktRelation) { BezugsKontaktRelation bezugsKontaktRelation = (BezugsKontaktRelation) element; RelationshipType relationshipType = bezugsKontaktRelation.getDestRelationType(); if (relationshipType != null) { return relationshipType.getValue(); } } return 0; } @Override protected CellEditor getCellEditor(Object element) { return new ComboBoxCellEditor(tableViewer.getTable(), BezugsKontaktAuswahl.getBezugKontaktTypes(), SWT.NONE); } @Override protected boolean canEdit(Object element) { return allowEditing; } }); viewCol = new TableViewerColumn(tableViewer, SWT.NONE); col = viewCol.getColumn(); tcl_composite.setColumnData(col, new ColumnWeightData(0, 140)); col.setText(Messages.Bezugskontakt_RelationTo); viewCol.setLabelProvider(new CellLabelProvider() { @Override public void update(ViewerCell cell) { BezugsKontaktRelation s = (BezugsKontaktRelation) cell.getElement(); if (s == null) return; cell.setText(LocalizeUtil.getLocaleText(s.getSrcRelationType())); } }); viewCol.setEditingSupport(new EditingSupport(tableViewer) { @Override protected void setValue(Object element, Object value) { if (element instanceof BezugsKontaktRelation && value instanceof Integer) { BezugsKontaktRelation bezugsKontaktRelation = (BezugsKontaktRelation) element; RelationshipType[] allRelationshipTypes = RelationshipType.values(); if ((int) value != -1 && !bezugsKontaktRelation.getSrcRelationType() .equals(allRelationshipTypes[(int) value])) { bezugsKontaktRelation.setSrcRelationType(allRelationshipTypes[(int) value]); getViewer().update(bezugsKontaktRelation, null); openConfirmUpdateExistingData(bezugsKontaktRelation); } } } @Override protected Object getValue(Object element) { if (element instanceof BezugsKontaktRelation) { BezugsKontaktRelation bezugsKontaktRelation = (BezugsKontaktRelation) element; RelationshipType relationshipType = bezugsKontaktRelation.getSrcRelationType(); if (relationshipType != null) { return relationshipType.getValue(); } } return 0; } @Override protected CellEditor getCellEditor(Object element) { return new ComboBoxCellEditor(tableViewer.getTable(), BezugsKontaktAuswahl.getBezugKontaktTypes(), SWT.NONE); } @Override protected boolean canEdit(Object element) { return allowEditing; } }); ; tableViewer .setInput(loadBezugKonkaktTypes(CoreHub.globalCfg.get(Patientenblatt2.CFG_BEZUGSKONTAKTTYPEN, ""))); return container; }
From source file:ch.elexis.core.ui.contacts.views.Patientenblatt2.java
License:Open Source License
void recreateUserpanel() { // cUserfields.setRedraw(false); if (ipp != null) { ipp.dispose();//from w ww .j av a2 s .c om ipp = null; } ArrayList<InputData> fields = new ArrayList<InputData>(20); fields.add(new InputData(Messages.Patientenblatt2_name, Patient.FLD_NAME, InputData.Typ.STRING, null)); // $NON-NLS-1$ fields.add(new InputData(Messages.Patientenblatt2_firstname, Patient.FLD_FIRSTNAME, InputData.Typ.STRING, null)); // $NON-NLS-1$ fields.add(new InputData(Messages.Patientenblatt2_birthdate, Patient.BIRTHDATE, InputData.Typ.DATE, null)); // $NON-NLS-1$ fields.add(new InputData(Messages.Patientenblatt2_sex, Patient.FLD_SEX, null, new String[] { Person.FEMALE, Person.MALE }, false)); IStructuredSelectionResolver isr = new IStructuredSelectionResolver() { @Override public StructuredSelection resolveStructuredSelection(String value) { MaritalStatus selection = MaritalStatus.byNumericSafe(value); return new StructuredSelection(selection); } }; fields.add(new InputData(Messages.Patientenblatt2_civilState, Patient.FLD_EXTINFO, PatientConstants.FLD_EXTINFO_MARITAL_STATUS, Typ.COMBO_VIEWER, ArrayContentProvider.getInstance(), new LabelProvider() { @Override public String getText(Object element) { MaritalStatus ms = (MaritalStatus) element; if (ms != null) { return ms.getLocaleText(); } return super.getText(element); } }, isr, MaritalStatus.values())); fields.add( new InputData(Messages.Patientenblatt2_phone1, Patient.FLD_PHONE1, InputData.Typ.STRING, null, 30)); // $NON-NLS-1$ fields.add( new InputData(Messages.Patientenblatt2_phone2, Patient.FLD_PHONE2, InputData.Typ.STRING, null, 30)); // $NON-NLS-1$ fields.add(new InputData(Messages.Patientenblatt2_mobile, Patient.MOBILE, InputData.Typ.STRING, null, 30)); // $NON-NLS-1$ fields.add(new InputData(Messages.Patientenblatt2_fax, Patient.FLD_FAX, InputData.Typ.STRING, null, 30)); // $NON-NLS-1$ fields.add(new InputData(Messages.Patientenblatt2_email, Patient.FLD_E_MAIL, // $NON-NLS-1$ new LabeledInputField.IExecLinkProvider() { @Override public void executeString(InputData ltf) { if (ltf.getText().length() == 0) return; try { URI uriMailTo = new URI("mailto", ltf.getText(), null); Desktop.getDesktop().mail(uriMailTo); } catch (URISyntaxException e1) { Status status = new Status(IStatus.WARNING, Hub.PLUGIN_ID, "Error in using mail address " + ltf); StatusManager.getManager().handle(status, StatusManager.SHOW); } catch (IOException e2) { Status status = new Status(IStatus.WARNING, Hub.PLUGIN_ID, "Error in using mail address " + ltf); StatusManager.getManager().handle(status, StatusManager.SHOW); } } })); fields.add(new InputData(Messages.Patientenblatt2_group, Patient.FLD_GROUP, InputData.Typ.STRING, null)); // $NON-NLS-1$ fields.add(new InputData(Messages.Patientenblatt2_balance, Patient.FLD_BALANCE, new LabeledInputField.IContentProvider() { // $NON-NLS-1$ public void displayContent(PersistentObject po, InputData ltf) { ltf.setText(actPatient.getKontostand().getAmountAsString()); } public void reloadContent(PersistentObject po, InputData ltf) { if (new AddBuchungDialog(getShell(), actPatient).open() == Dialog.OK) { ltf.setText(actPatient.getKontostand().getAmountAsString()); } } })); fields.add(new InputData(Messages.Patientenblatt2_regularPhysician, PatientConstants.FLD_EXTINFO_STAMMARZT, new LabeledInputField.IContentProvider() { // $NON-NLS-1$ public void displayContent(PersistentObject po, InputData ltf) { Patient p = (Patient) po; String result = ""; if (p.getStammarzt() != null && p.getStammarzt().exists()) { result = p.getStammarzt().getLabel(true); } ltf.setText(result); } public void reloadContent(PersistentObject po, InputData ltf) { if (bLocked) { return; } KontaktSelektor ks = new KontaktSelektor(getShell(), Kontakt.class, Messages.Patientenblatt2_selectRegularPhysicianTitle, Messages.Patientenblatt2_selectRegularPhysicianMessage, null); ks.enableEmptyFieldButton(); if (ks.open() == Dialog.OK) { Object contactSel = ks.getSelection(); if (contactSel == null) { ((Patient) po).removeStammarzt(); ltf.setText(""); } else { Kontakt k = (Kontakt) contactSel; ((Patient) po).setStammarzt(k); ltf.setText(k.getLabel(true)); } } } })); fields.add(new InputData(Messages.Patientenblatt2_ahvNumber, XidConstants.DOMAIN_AHV, new LabeledInputField.IContentProvider() { public void displayContent(PersistentObject po, InputData ltf) { Patient p = (Patient) po; ltf.setText(p.getXid(XidConstants.DOMAIN_AHV)); } public void reloadContent(final PersistentObject po, final InputData ltf) { if (bLocked) { return; } ArrayList<String> extFlds = new ArrayList<String>(); Kontakt k = (Kontakt) po; for (String dom : Xid.getXIDDomains()) { XIDDomain xd = Xid.getDomain(dom); if ((k.istPerson() && xd.isDisplayedFor(Person.class)) || (k.istOrganisation() && xd.isDisplayedFor(Organisation.class))) { extFlds.add(Xid.getSimpleNameForXIDDomain(dom) + "=" + dom); //$NON-NLS-1$ } else if (k.istOrganisation() && xd.isDisplayedFor(Labor.class)) { extFlds.add(Xid.getSimpleNameForXIDDomain(dom) + "=" + dom); } } KontaktExtDialog dlg = new KontaktExtDialog(UiDesk.getTopShell(), (Kontakt) po, extFlds.toArray(new String[0])); dlg.open(); Patient p = (Patient) po; ltf.setText(p.getXid(XidConstants.DOMAIN_AHV)); } })); fields.add(new InputData(Messages.Patientenblatt2_legalGuardian, PatientConstants.FLD_EXTINFO_LEGAL_GUARDIAN, new LabeledInputField.IContentProvider() { @Override public void displayContent(PersistentObject po, InputData ltf) { Patient p = (Patient) po; String guardianLabel = ""; Kontakt legalGuardian = p.getLegalGuardian(); if (legalGuardian != null && legalGuardian.exists()) { guardianLabel = legalGuardian.get(Kontakt.FLD_NAME1) + " " + legalGuardian.get(Kontakt.FLD_NAME2); } ltf.setText(guardianLabel); } @Override public void reloadContent(PersistentObject po, InputData ltf) { if (bLocked) { return; } KontaktSelektor ks = new KontaktSelektor(getShell(), Kontakt.class, Messages.Patientenblatt2_selectLegalGuardianTitle, Messages.Patientenblatt2_selectLegalGuardianMessage, null); ks.enableEmptyFieldButton(); if (ks.open() == Dialog.OK) { String guardianLabel = ""; Object contactSel = ks.getSelection(); Kontakt legalGuardian = null; // get legal guardian if one is defined if (contactSel != null) { legalGuardian = (Kontakt) contactSel; guardianLabel = legalGuardian.get(Kontakt.FLD_NAME1) + " " + legalGuardian.get(Kontakt.FLD_NAME2); } ((Patient) po).setLegalGuardian(legalGuardian); ltf.setText(guardianLabel); } } })); String[] userfields = CoreHub.userCfg.get(CFG_EXTRAFIELDS, StringConstants.EMPTY) .split(StringConstants.COMMA); for (String extfield : userfields) { if (!StringTool.isNothing(extfield)) { fields.add(new InputData(extfield, Patient.FLD_EXTINFO, InputData.Typ.STRING, extfield)); } } ipp = new InputPanel(cUserfields, 3, 3, fields.toArray(new InputData[0])); ipp.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); ipp.changed(ipp.getChildren()); // cUserfields.setRedraw(true); cUserfields.setBounds(ipp.getBounds()); refresh(); if (actPatient != null) { setPatient(actPatient); } layout(true); }
From source file:ch.elexis.core.ui.contacts.views.PatientenListeView.java
License:Open Source License
private void makeActions() { filterAction = new Action(Messages.PatientenListeView_FilteList, Action.AS_CHECK_BOX) { // $NON-NLS-1$ {// w ww . j av a 2s .c o m setImageDescriptor(Images.IMG_FILTER.getImageDescriptor()); setToolTipText(Messages.PatientenListeView_FilterList); // $NON-NLS-1$ } @Override public void run() { GridData gd = (GridData) plfb.getLayoutData(); if (filterAction.isChecked()) { gd.heightHint = 80; plfb.reset(); plcp.setFilter(plfb); } else { gd.heightHint = 0; plcp.removeFilter(plfb); } parent.layout(true); } }; newPatAction = new RestrictedAction(AccessControlDefaults.PATIENT_INSERT, Messages.PatientenListeView_NewPatientAction) { { setImageDescriptor(Images.IMG_NEW.getImageDescriptor()); setToolTipText(Messages.PatientenListeView_NewPationtToolTip); } @Override public void doRun() { HashMap<String, String> ctlFields = new HashMap<String, String>(); String[] fx = vc.getControlFieldProvider().getValues(); int i = 0; if (CoreHub.userCfg.get(Preferences.USR_PATLIST_SHOWPATNR, false)) { if (i < fx.length) { ctlFields.put(Patient.FLD_PATID, fx[i++]); } } if (CoreHub.userCfg.get(Preferences.USR_PATLIST_SHOWNAME, true)) { if (i < fx.length) { ctlFields.put(Patient.FLD_NAME, fx[i++]); } } if (CoreHub.userCfg.get(Preferences.USR_PATLIST_SHOWFIRSTNAME, true)) { if (i < fx.length) { ctlFields.put(Patient.FLD_FIRSTNAME, fx[i++]); } } if (CoreHub.userCfg.get(Preferences.USR_PATLIST_SHOWDOB, true)) { if (i < fx.length) { ctlFields.put(Patient.FLD_DOB, fx[i++]); } } PatientErfassenDialog ped = new PatientErfassenDialog(getViewSite().getShell(), ctlFields); if (ped.open() == Dialog.OK) { plcp.temporaryAddObject(ped.getResult()); Patient pat = ped.getResult(); for (int j = 0; j < currentUserFields.length; j++) { String current = currentUserFields[j]; if (current.startsWith(Patient.FLD_PATID)) { dcfp.setValue(j, pat.getPatCode()); } else if (current.startsWith(Patient.FLD_NAME) && pat.getName() != null) { dcfp.setValue(j, pat.getName()); } else if (current.startsWith(Patient.FLD_FIRSTNAME) && pat.getVorname() != null) { dcfp.setValue(j, pat.getVorname()); } } plcp.syncRefresh(); TableViewer tv = (TableViewer) cv.getViewerWidget(); tv.setSelection(new StructuredSelection(pat), true); } } }; /* * Copy selected PatientInfos to the clipboard, so it/they can be easily * pasted into a letter for printing. An action with identical / similar * code has also been added above, and to KontakteView.java. Detailed * comments regarding field access, and output including used newline/cr * characters are maintained only there. */ copySelectedPatInfosToClipboardAction = new Action( Messages.PatientenListeView_copySelectedPatInfosToClipboard) { // $NON-NLS-1$ { setImageDescriptor(Images.IMG_CLIPBOARD.getImageDescriptor()); setToolTipText(Messages.PatientenListeView_copySelectedPatInfosToClipboard); // $NON-NLS-1$ } @Override public void run() { // Adopted from KontakteView.printList: // Convert the selected addresses into a list /* * ToDo: OK, vielleicht wre es schner, in Person.java * (+-Patient.java?) eine Funktion getPostAnschriftFaxEmail() zu * ergnzen... */ // TODO: PatientenListeView.java, Bitte in Person.java // getPersonalia() durch // abgewandelte Fassung komplementieren und den entsprechenden // Code dorthin verlagern. // TODO: Bitte Fehlermeldung Elexis-Konform gestalten, ggf. // Automatik / // assistierte Fehlerbehebung hinzufgen. StringBuffer selectedPatInfosText = new StringBuffer(); Object[] sel = cv.getSelection(); // If you enable the following line for debug output, // you should also enable the selectedPatInfosText.setLength(0) // line below, // and enable output of selectedPatInfosText even for the case // of an empty // selection further below. // selectedPatInfosText.append("jsdebug: Sorry, your selection // is empty."); if (sel != null && sel.length > 0) { // selectedPatInfosText.setLength(0); // selectedPatInfosText.append("jsdebug: Your selection // includes "+sel.length+" // element(s):"+System.getProperty("line.separator")); // In PateintenListeView.java, only zero or one patients can // be selected at // a time. // Consequently, the for-loop inherited from // KontakteView.java is a bit of // an overkill right here. for (int i = 0; i < sel.length; i++) { /* * Patient ist eine Person, das ist Kontakt mit * zustzlichen Feldern (Kontakt.java, Person.java) In * KontakteView.java stand hier: Kontakt k = (Kontakt) * sel[i] In PatientenListeView.java verwende ich * dieselbe Variablenbezeichnung k, damit ich unten * nicht alle Feldeinbindungen aktualisieren muss - und * damit spter nderungen in KontakteView.java schnell * hierher bernommen werden knnen. */ Patient k = (Patient) sel[i]; /* * Synthesize the lines to output from the entries in * Patient (=includes fields from Kontakt) k. This time, * we build a completely self-made block of text, * instead of using getPostAnschrift() as above. */ // The following code is adopted from // Kontakt.createStdAnschrift for a // different purpose/layout: // ggf. hier zu Person.getPersonalia() eine abgewandelte // Fassung // hinzufgen und von hier aus aufrufen. // Highly similar (but still different) code is now // added // to KontakteView.java // CopySelectedContactInfoToClipboard... // 201202161313js if (k.istPerson()) { // TODO default salutation might be configurable (or // a // "Sex missing!" Info might appear) js String salutation; if (k.getGeschlecht().equals(Person.MALE)) { salutation = Messages.KontakteView_SalutationM; // $NON-NLS-1$ } else // We do not use any default salutation for // unknown sex to // avoid errors! if (k.getGeschlecht().equals(Person.FEMALE)) { salutation = Messages.KontakteView_SalutationF; // $NON-NLS-1$ } else { salutation = ""; //$NON-NLS-1$ } selectedPatInfosText.append(salutation); selectedPatInfosText.append(StringTool.space); String titel = k.get(Person.TITLE); // $NON-NLS-1$ if (!StringTool.isNothing(titel)) { selectedPatInfosText.append(titel).append(StringTool.space); } // A comma between Family Name and Given Name would // be generally // helpful to reliably tell them apart: // selectedPatInfosText.append(k.getName()+","+StringTool.space+k.getVorname()); // But Jrg Hamacher prefers this in his letters // without a comma in // between: // selectedPatInfosText.append(k.getName()+StringTool.space+k.getVorname()); // Now, I only use a spacer, if the first field is // not empty! // SelectedContactInfosText.append(p.getVorname()+StringTool.space+p.getName()); if (!StringTool.isNothing(k.getName())) { selectedPatInfosText.append(k.getName() + StringTool.space); } if (!StringTool.isNothing(k.getVorname())) { selectedPatInfosText.append(k.getVorname()); } String thisPatientBIRTHDATE = k.get(Person.BIRTHDATE); if (!StringTool.isNothing(thisPatientBIRTHDATE)) { // This would add the term "geb." (born on the) // before the date // of birth: // selectedPatInfosText.append(","+StringTool.space+"geb."+StringTool.space+new // TimeTool(thisPatientBIRTHDATE).toString(TimeTool.DATE_GER)); // But Jrg Hamacher prefers the patient // information in his // letters without that term: selectedPatInfosText.append("," + StringTool.space + new TimeTool(thisPatientBIRTHDATE).toString(TimeTool.DATE_GER)); } String thisAddressFLD_STREET = k.get(Kontakt.FLD_STREET); if (!StringTool.isNothing(thisAddressFLD_STREET)) { selectedPatInfosText.append("," + StringTool.space + thisAddressFLD_STREET); } String thisAddressFLD_COUNTRY = k.get(Kontakt.FLD_COUNTRY); if (!StringTool.isNothing(thisAddressFLD_COUNTRY)) { selectedPatInfosText.append("," + StringTool.space + thisAddressFLD_COUNTRY + "-"); } String thisAddressFLD_ZIP = k.get(Kontakt.FLD_ZIP); if (!StringTool.isNothing(thisAddressFLD_ZIP)) { if (StringTool.isNothing(thisAddressFLD_COUNTRY)) { selectedPatInfosText.append("," + StringTool.space); } ; selectedPatInfosText.append(thisAddressFLD_ZIP); } ; String thisAddressFLD_PLACE = k.get(Kontakt.FLD_PLACE); if (!StringTool.isNothing(thisAddressFLD_PLACE)) { if (StringTool.isNothing(thisAddressFLD_COUNTRY) && StringTool.isNothing(thisAddressFLD_ZIP)) { selectedPatInfosText.append(","); } ; selectedPatInfosText.append(StringTool.space + thisAddressFLD_PLACE); } String thisAddressFLD_PHONE1 = k.get(Kontakt.FLD_PHONE1); if (!StringTool.isNothing(thisAddressFLD_PHONE1)) { selectedPatInfosText .append("," + StringTool.space + StringTool.space + thisAddressFLD_PHONE1); } String thisAddressFLD_PHONE2 = k.get(Kontakt.FLD_PHONE2); if (!StringTool.isNothing(thisAddressFLD_PHONE2)) { selectedPatInfosText .append("," + StringTool.space + StringTool.space + thisAddressFLD_PHONE2); } String thisAddressFLD_MOBILEPHONE = k.get(Kontakt.FLD_MOBILEPHONE); if (!StringTool.isNothing(thisAddressFLD_MOBILEPHONE)) { // With a colon after the label: // selectedPatInfosText.append(","+StringTool.space+k.FLD_MOBILEPHONE+":"+StringTool.space+thisAddressFLD_MOBILEPHONE); // Without a colon after the label: selectedPatInfosText.append("," + StringTool.space + Kontakt.FLD_MOBILEPHONE + StringTool.space + thisAddressFLD_MOBILEPHONE); } String thisAddressFLD_FAX = k.get(Kontakt.FLD_FAX); if (!StringTool.isNothing(thisAddressFLD_FAX)) { // With a colon after the label: // selectedPatInfosText.append(","+StringTool.space+k.FLD_FAX+":"+StringTool.space+thisAddressFLD_FAX); // Without a colon after the label: selectedPatInfosText.append("," + StringTool.space + Kontakt.FLD_FAX + StringTool.space + thisAddressFLD_FAX); } String thisAddressFLD_E_MAIL = k.get(Kontakt.FLD_E_MAIL); if (!StringTool.isNothing(thisAddressFLD_E_MAIL)) { selectedPatInfosText.append("," + StringTool.space + thisAddressFLD_E_MAIL); } } else { selectedPatInfosText.append( "Fehler: Bei diesem Patienten ist das Flag \"Person\" nicht gesetzt! Bitte korrigieren!\n"); // TODO: Fehler: Bei diesem Patienten ist das Flag // \"Person\" nicht gesetzt!\n"); // TODO: Bitte Fehlermeldung Elexis-Konform // gestalten, ggf. // Automatik / assistierte Fehlerbehebung // hinzufgen.\n"); } // Add another empty line (or rather: paragraph), if at // least one more // address will follow. if (i < sel.length - 1) { selectedPatInfosText.append(System.getProperty("line.separator")); } } // for each element in sel do /* * The following code portions can be moved down behind the * next } if you want to produce debugging output or empty * the clipboard even when NO addresses have been selected. * (However, I may disable the toolbar icon / menu entry for * this action in that case later on.) */ // Adopted from BestellView.exportClipboardAction: // Copy some generated object.toString() to the clipoard Clipboard clipboard = new Clipboard(UiDesk.getDisplay()); TextTransfer textTransfer = TextTransfer.getInstance(); Transfer[] transfers = new Transfer[] { textTransfer }; Object[] data = new Object[] { selectedPatInfosText.toString() }; clipboard.setContents(data, transfers); clipboard.dispose(); } // if sel not empty }; // copyselectedPatInfosToClipboardAction.run() }; /* * Copy selected address(es) to the clipboard, so it/they can be easily * pasted into a letter for printing. An actions with identical / * similar code has also been added below, and to KontakteView.java. * Detailed comments regarding field access, and output including used * newline/cr characters are maintained only there. */ copySelectedAddressesToClipboardAction = new Action( Messages.PatientenListeView_copySelectedAddressesToClipboard) { // $NON-NLS-1$ { setImageDescriptor(Images.IMG_CLIPBOARD.getImageDescriptor()); setToolTipText(Messages.PatientenListeView_copySelectedAddressesToClipboard); // $NON-NLS-1$ } @Override public void run() { // Adopted from KontakteView.printList: // Convert the selected addresses into a list StringBuffer selectedAddressesText = new StringBuffer(); Object[] sel = cv.getSelection(); // If you enable the following line for debug output, // you should also enable the selectedAddressesText.setLength(0) // line below, // and enable output of selectedAddressesText even for the case // of an empty // selection further below. // selectedAddressesText.append("jsdebug: Sorry, your selection // is empty."); if (sel != null && sel.length > 0) { // selectedAddressesText.setLength(0); // selectedAddressesText.append("jsdebug: Your selection // includes "+sel.length+" // element(s):"+System.getProperty("line.separator")); // In PateintenListeView.java, only zero or one patients can // be selected at // a time. // Consequently, the for-loop inherited from // KontakteView.java is a bit of // an overkill right here. for (int i = 0; i < sel.length; i++) { /* * Patient ist eine Person, das ist Kontakt mit * zustzlichen Feldern (Kontakt.java, Person.java) In * KontakteView.java stand hier: Kontakt k = (Kontakt) * sel[i] In PatientenListeView.java verwende ich * dieselbe Variablenbezeichnung k, damit ich unten * nicht alle Feldeinbindungen aktualisieren muss - und * damit spter nderungen in KontakteView.java schnell * hierher bernommen werden knnen. */ Patient k = (Patient) sel[i]; /* * Synthesize the address lines to output from the * entries in Patient (=includes fields from Kontakt) k. * A different, completely self-made block of text, is * provided by a similar action defined further below. */ // selectedAddressesText.append("jsdebug: Item // "+Integer.toString(i)+" // "+k.toString()+System.getProperty("line.separator")); // getPostAnschriftPhoneFaxEmail() already returns a // line separator // after the address // The first parameter controls multiline or single line // output // The second parameter controls whether the phone // numbers shall be // included selectedAddressesText.append(k.getPostAnschriftPhoneFaxEmail(true, true)); // Add another empty line (or rather: paragraph), if at // least one more // address will follow. if (i < sel.length - 1) { selectedAddressesText.append(System.getProperty("line.separator")); } } // for each element in sel do /* * I would prefer to move the following code portions down * behind the "if sel not empty" block, so that (a) * debugging output can be produced and (b) the clipboard * will be emptied when NO addresses have been selected. I * did this to avoid the case where a user would assume they * had selected some address, copied data to the clipboard, * and pasted them - and, even when they erred about their * selection, which was indeed empty, they would not * immediately notice that because some (old, unchanged) * content would still come out of the clipboard. * * But if I do so, and there actually is no address * selected, I get an error window: Unhandled Exception ... * not valid. So to avoid that message without any further * research (I need to get this work fast now), I move the * code back up and leave the clipboard unchanged for now, * if no addresses had been selected to process. * * (However, I may disable the toolbar icon / menu entry for * this action in that case later on.) */ // System.out.print("jsdebug: selectedAddressesText: // \n"+selectedAddressesText+"\n"); // Adopted from BestellView.exportClipboardAction: // Copy some generated object.toString() to the clipoard Clipboard clipboard = new Clipboard(UiDesk.getDisplay()); TextTransfer textTransfer = TextTransfer.getInstance(); Transfer[] transfers = new Transfer[] { textTransfer }; Object[] data = new Object[] { selectedAddressesText.toString() }; clipboard.setContents(data, transfers); clipboard.dispose(); } // if sel not empty }; // copySelectedAddressesToClipboardAction.run() }; }
From source file:ch.elexis.core.ui.dialogs.KonsZumVerrechnenWizardDialog.java
License:Open Source License
@Override protected Control createDialogArea(final Composite parent) { Composite ret = new Composite(parent, SWT.NONE); ret.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); ret.setLayout(new GridLayout(4, false)); cbMarked = new Button(ret, SWT.CHECK); cbMarked.setText(ALLMARKED);/* ww w . j ava2 s .c o m*/ cbMarked.setLayoutData(SWTHelper.getFillGridData(4, true, 1, false)); cbBefore = new Button(ret, SWT.CHECK); cbBefore.setText(TREATMENTBEGINBEFORE); ddc1 = new DayDateCombo(ret, "", TAGEN_BZW_DEM); //$NON-NLS-1$ ddc1.spinDaysBack(); cbTime = new Button(ret, SWT.CHECK); cbTime.setText(TREATMENTENDBEFORE); ddc2 = new DayDateCombo(ret, "", TAGEN_BZW_DEM); //$NON-NLS-1$ ddc2.spinDaysBack(); int prev = CoreHub.localCfg.get(CONFIG + "beginBefore", 30) * -1; //$NON-NLS-1$ TimeTool ttNow = new TimeTool(); ttNow.addDays(prev); ddc1.setDays(prev); prev = CoreHub.localCfg.get(CONFIG + "endBefore", 20) * -1; //$NON-NLS-1$ ddc2.setDays(prev); ddc1.setLayoutData(SWTHelper.getFillGridData(3, true, 1, false)); ddc2.setLayoutData(SWTHelper.getFillGridData(3, true, 1, false)); cbAmount = new Button(ret, SWT.CHECK); cbAmount.setText(TREATMENT_AMOUNTHIGHER); mi1 = new MoneyInput(ret); mi1.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1)); mi1.setLayoutData(SWTHelper.getFillGridData(3, true, 1, false)); cbQuartal = new Button(ret, SWT.CHECK); cbQuartal.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 4, 1)); cbQuartal.setText(TREATMENT_TRIMESTER); cbTimespan = new Button(ret, SWT.CHECK); cbTimespan.setText(TREATMENT_TIMESPAN); timespanFrom = new DateTime(ret, SWT.NONE); Label lblTill = new Label(ret, SWT.NONE); lblTill.setText(TREATMENT_TIMESPAN_TILL); timespanTo = new DateTime(ret, SWT.NONE); cbTimespan.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { timespanFrom.setEnabled(cbTimespan.getSelection()); timespanTo.setEnabled(cbTimespan.getSelection()); } }); cbAccountingSys = new Button(ret, SWT.CHECK); cbAccountingSys.setText(TREATMENT_ACCOUNTING_SYS); cbAccountingSys.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { cAccountingSys.getCombo().setEnabled(cbAccountingSys.getSelection()); } }); cAccountingSys = new ComboViewer(ret, SWT.NONE); Combo combo = cAccountingSys.getCombo(); combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 3, 1)); cAccountingSys.setContentProvider(ArrayContentProvider.getInstance()); cAccountingSys.setLabelProvider(new LabelProvider()); String[] accSystems = Fall.getAbrechnungsSysteme(); cAccountingSys.setInput(accSystems); cAccountingSys.setSelection(new StructuredSelection(accSystems[0])); new Label(ret, SWT.NONE); new Label(ret, SWT.NONE); new Label(ret, SWT.NONE); new Label(ret, SWT.NONE); new Label(ret, SWT.NONE); new Label(ret, SWT.NONE); new Label(ret, SWT.NONE); new Label(ret, SWT.NONE); new Label(ret, SWT.SEPARATOR | SWT.HORIZONTAL).setLayoutData(SWTHelper.getFillGridData(4, true, 1, false)); cbSkip = new Button(ret, SWT.CHECK); cbSkip.setText(SKIPSELECTION); cbSkip.setSelection(CoreHub.globalCfg.get(CFG_SKIP, false)); cbBefore.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { ddc1.setEnabled(cbBefore.getSelection()); } }); cbTime.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { ddc2.setEnabled(cbTime.getSelection()); } }); cAccountingSys.getCombo().setEnabled(false); timespanFrom.setEnabled(false); timespanTo.setEnabled(false); ddc1.setEnabled(false); ddc2.setEnabled(false); new Label(ret, SWT.NONE); new Label(ret, SWT.NONE); new Label(ret, SWT.NONE); return ret; }
From source file:ch.elexis.core.ui.dialogs.SelectBestellungDialog.java
License:Open Source License
protected Control createDialogArea(Composite container) { Composite parent = (Composite) super.createDialogArea(container); createMessageArea(parent);//from w ww. ja v a 2 s .c o m fTableViewer = new TableViewer(parent, getTableStyle()); fTableViewer.setContentProvider(new BestellContentProvider()); addColumns(); setComparator(); fTableViewer.setInput(this); fTableViewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { if (fAddCancelButton) { okPressed(); } } }); List initialSelection = getInitialElementSelections(); if (initialSelection != null) { fTableViewer.setSelection(new StructuredSelection(initialSelection)); } GridData gd = new GridData(GridData.FILL_BOTH); gd.heightHint = convertHeightInCharsToPixels(heightInChars); gd.widthHint = convertWidthInCharsToPixels(widthInChars); Table table = fTableViewer.getTable(); table.setLayoutData(gd); table.setFont(container.getFont()); table.setHeaderVisible(true); return parent; }
From source file:ch.elexis.core.ui.dialogs.SelectFallNoObligationDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); Composite areaComposite = new Composite(composite, SWT.NONE); areaComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL)); areaComposite.setLayout(new FormLayout()); Label lbl = new Label(areaComposite, SWT.NONE); lbl.setText("Fall erstellen"); ToolBarManager tbManager = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL | SWT.WRAP); tbManager.add(GlobalActions.neuerFallAction); ToolBar toolbar = tbManager.createControl(areaComposite); FormData fd = new FormData(); fd.top = new FormAttachment(0, 5); fd.left = new FormAttachment(0, 5); lbl.setLayoutData(fd);/*from w w w .java 2s . co m*/ fd = new FormData(); fd.top = new FormAttachment(0, 5); fd.left = new FormAttachment(30, 5); toolbar.setLayoutData(fd); lbl = new Label(areaComposite, SWT.NONE); lbl.setText("Fall auswhlen"); noOblFallCombo = new ComboViewer(areaComposite); noOblFallCombo.setContentProvider(new ArrayContentProvider()); noOblFallCombo.setInput(getNoObligationFaelle()); noOblFallCombo.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { return ((Fall) element).getLabel(); } }); if (lastSelectedFall != null) noOblFallCombo.setSelection(new StructuredSelection(lastSelectedFall)); ElexisEventDispatcher.getInstance() .addListeners(new UpdateFallComboListener(noOblFallCombo, Fall.class, 0xff)); fd = new FormData(); fd.top = new FormAttachment(toolbar, 5); fd.left = new FormAttachment(0, 5); lbl.setLayoutData(fd); fd = new FormData(); fd.top = new FormAttachment(toolbar, 5); fd.left = new FormAttachment(30, 5); fd.right = new FormAttachment(100, -5); noOblFallCombo.getControl().setLayoutData(fd); return areaComposite; }
From source file:ch.elexis.core.ui.dialogs.ZusatzAdresseEingabeDialog.java
License:Open Source License
private void loadFieldValues() { str1.setText(zusatzAdresseDTO.getStreet1()); str2.setText(zusatzAdresseDTO.getStreet2()); plz.setText(zusatzAdresseDTO.getZip()); ort.setText(zusatzAdresseDTO.getPlace()); land.setText(zusatzAdresseDTO.getCountry()); comboAddressType.setSelection(new StructuredSelection(zusatzAdresseDTO.getAddressType())); postanschrift.setText(zusatzAdresseDTO.getPostalAddress().replaceAll("[\\r\\n]\\n", StringTool.lf)); }
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();//w w w . j a v a 2 s . 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.documents.views.DocumentsView.java
License:Open Source License
private void makeActions() { doubleClickAction = new Action() { public void run() { ISelection selection = viewer.getSelection(); Object obj = ((IStructuredSelection) selection).getFirstElement(); if (obj instanceof IDocument) { IDocument dh = (IDocument) obj; DocumentStoreServiceHolder.getService().getPersistenceObject(dh).ifPresent(po -> { ICommandService commandService = (ICommandService) PlatformUI.getWorkbench() .getService(ICommandService.class); Command command = commandService .getCommand("ch.elexis.core.ui.command.startEditLocalDocument"); PlatformUI.getWorkbench().getService(IEclipseContext.class) .set(command.getId().concat(".selection"), new StructuredSelection(po)); try { command.executeWithChecks( new ExecutionEvent(command, Collections.EMPTY_MAP, null, null)); } catch (ExecutionException | NotDefinedException | NotEnabledException | NotHandledException e) { e.printStackTrace(); }/*from w w w.jav a 2s.c o m*/ }); viewer.refresh(); } } }; }
From source file:ch.elexis.core.ui.laboratory.preferences.LabGroupPrefs.java
License:Open Source License
@Override protected Control createContents(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); composite.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); composite.setLayout(new GridLayout(1, false)); Label label;/*from w ww . ja v a 2 s . c o m*/ GridLayout layout; Composite topArea = new Composite(composite, SWT.NONE); topArea.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); layout = new GridLayout(3, false); layout.verticalSpacing = 20; topArea.setLayout(layout); label = new Label(topArea, SWT.NONE); label.setText(Messages.LabGroupPrefs_ExplanationsLine1 + Messages.LabGroupPrefs_ExplanationsLine2 + Messages.LabGroupPrefs_ExplanationsLine3); label.setLayoutData(SWTHelper.getFillGridData(3, true, 1, false)); GridData gd; label = new Label(topArea, SWT.NONE); label.setText(Messages.LabGroupPrefs_group); gd = SWTHelper.getFillGridData(1, false, 1, false); gd.verticalAlignment = GridData.BEGINNING; label.setLayoutData(gd); groupsViewer = new ComboViewer(topArea, SWT.READ_ONLY); gd = SWTHelper.getFillGridData(1, true, 1, false); gd.verticalAlignment = GridData.BEGINNING; groupsViewer.getControl().setLayoutData(gd); groupsViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection sel = (IStructuredSelection) groupsViewer.getSelection(); Object element = sel.getFirstElement(); if (element instanceof LabGroup) { actGroup = (LabGroup) element; itemsViewer.refresh(); } updateButtonsState(); } }); groupsViewer.setContentProvider(new GroupsContentProvider()); groupsViewer.setLabelProvider(new DefaultLabelProvider()); groupsViewer.setInput(this); Composite groupButtonArea = new Composite(topArea, SWT.PUSH); layout = new GridLayout(1, false); layout.marginHeight = 0; groupButtonArea.setLayout(layout); newButton = new Button(groupButtonArea, SWT.PUSH); newButton.setText(Messages.LabGroupPrefs_new); newButton.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { InputDialog dialog = new InputDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.LabGroupPrefs_newLabGroup, Messages.LabGroupPrefs_selectNameForLabGroup, "", null); //$NON-NLS-1$ int rc = dialog.open(); if (rc == Window.OK) { String name = dialog.getValue(); LabGroup group = new LabGroup(name, null); groupsViewer.refresh(); groupsViewer.setSelection(new StructuredSelection(group)); } } @Override public void widgetDefaultSelected(SelectionEvent e) { widgetSelected(e); } }); removeButton = new Button(groupButtonArea, SWT.PUSH); removeButton.setText(Messages.LabGroupPrefs_delete); removeButton.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { if (actGroup != null) { if (SWTHelper.askYesNo(Messages.LabGroupPrefs_deleteGroup, MessageFormat.format(Messages.LabGroupPrefs_reallyDeleteGroup, actGroup.getLabel()))) ; { actGroup.delete(); actGroup = null; groupsViewer.refresh(); itemsViewer.refresh(); selectFirstGroup(); } } } @Override public void widgetDefaultSelected(SelectionEvent e) { widgetSelected(e); } }); final Button showGroups = new Button(topArea, SWT.NONE | SWT.CHECK); showGroups.setText(Messages.LabGroupPrefs_showLabGroupsOnly); showGroups.setSelection(CoreHub.userCfg.get(SHOW_GROUPS_ONLY, false)); showGroups.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { CoreHub.userCfg.set(SHOW_GROUPS_ONLY, showGroups.getSelection()); } }); Composite bottomArea = new Composite(composite, SWT.NONE); bottomArea.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); bottomArea.setLayout(new GridLayout(1, false)); label = new Label(bottomArea, SWT.NONE); label.setText(Messages.LabGroupPrefs_containingLabItems); itemsViewer = new ListViewer(bottomArea, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); itemsViewer.getControl().setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); itemsViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { updateItemButtonsState(); } }); itemsViewer.setContentProvider(new GroupItemsContentProvider()); itemsViewer.setLabelProvider(new ItemsLabelProvider()); itemsViewer.setInput(this); Composite buttonArea = new Composite(bottomArea, SWT.NONE); buttonArea.setLayoutData(SWTHelper.getFillGridData(1, false, 1, false)); buttonArea.setLayout(new GridLayout(2, true)); addItemButton = new Button(buttonArea, SWT.PUSH); addItemButton.setText(Messages.LabGroupPrefs_add); addItemButton.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); removeItemButton = new Button(buttonArea, SWT.PUSH); removeItemButton.setText(Messages.LabGroupPrefs_remove); removeItemButton.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); addItemButton.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { if (actGroup != null) { LabItemSelektor selektor = new LabItemSelektor( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); if (selektor.open() == Dialog.OK) { List<LabItem> items = selektor.getSelection(); // list of existing items List<LabItem> existingItems = actGroup.getItems(); for (Object obj : items) { if (obj instanceof LabItem) { LabItem item = (LabItem) obj; if (!existingItems.contains(item)) { actGroup.addItem(item); } } } itemsViewer.refresh(); } } } @Override public void widgetDefaultSelected(SelectionEvent e) { widgetSelected(e); } }); removeItemButton.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { if (actGroup != null) { IStructuredSelection sel = (IStructuredSelection) itemsViewer.getSelection(); for (Object obj : sel.toList()) { if (obj instanceof LabItem) { LabItem item = (LabItem) obj; actGroup.removeItem(item); } } itemsViewer.refresh(); } } @Override public void widgetDefaultSelected(SelectionEvent e) { widgetSelected(e); } }); selectFirstGroup(); return composite; }