List of usage examples for org.eclipse.jface.viewers IStructuredSelection isEmpty
public boolean isEmpty();
From source file:ca.uvic.cs.tagsea.ui.views.WaypointsComposite.java
License:Open Source License
/** * Gets the selected waypoints or returns empty array. * @return Waypoint[] the selected waypoints or an empty array */// www .j a v a 2s . c om public Waypoint[] getSelectedWaypoints() { Waypoint[] wps = new Waypoint[0]; IStructuredSelection sel = (IStructuredSelection) waypointsTableViewer.getSelection(); if (!sel.isEmpty()) { Object[] array = sel.toArray(); ArrayList<Waypoint> wpList = new ArrayList<Waypoint>(array.length); for (Object obj : array) { if (obj instanceof Waypoint) { wpList.add((Waypoint) obj); } } wps = new Waypoint[wpList.size()]; wps = (Waypoint[]) wpList.toArray(wps); } return wps; }
From source file:cane.brothers.e4.commander.part.DynamicTab.java
License:Open Source License
@Override public void selectionChanged(SelectionChangedEvent event) { Object prevSelection = selectionService.getSelection(); if (log.isDebugEnabled()) { log.debug("Prev selection is {}", prevSelection); //$NON-NLS-1$ }/* w ww . ja va 2 s . co m*/ IStructuredSelection selection = (IStructuredSelection) event.getSelection(); boolean hasSelection = selection != null && selection.isEmpty() == false; if (hasSelection) { Object firstElement = selection.getFirstElement(); if (log.isDebugEnabled()) { log.debug("Current selection is {}", firstElement); //$NON-NLS-1$ } // set the selection to the service selectionService.setSelection(firstElement); if (log.isDebugEnabled()) { log.debug("Selection changed:"); //$NON-NLS-1$ } // trace selected objects for (Object sel : selection.toArray()) { if (sel instanceof PathFixture) { PathFixture fixture = (PathFixture) sel; if (log.isDebugEnabled()) { log.debug(" " + fixture); //$NON-NLS-1$ } } } } }
From source file:ch.docbox.elexis.DocboxDocumentsView.java
License:Open Source License
@Override public void createPartControl(Composite parent) { table = new Table(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION); String[] colLabels = getColumnLabels(); int columnWidth[] = getColumnWidth(); SortListener sortListener = new SortListener(); TableColumn[] cols = new TableColumn[colLabels.length]; for (int i = 0; i < colLabels.length; i++) { cols[i] = new TableColumn(table, SWT.NONE); cols[i].setWidth(columnWidth[i]); cols[i].setText(colLabels[i]);// w w w .j a va 2 s . c o m cols[i].setData(new Integer(i)); cols[i].addSelectionListener(sortListener); } table.setHeaderVisible(true); table.setLinesVisible(true); boldFont = createBoldFont(table.getFont()); tableViewer = new TableViewer(table); tableViewer.setContentProvider(new ViewContentProvider()); tableViewer.setLabelProvider(new ViewLabelProvider()); tableViewer.setSorter(new Sorter()); tableViewer.setUseHashlookup(true); Transfer[] transferTypes = new Transfer[] { FileTransfer.getInstance() }; tableViewer.addDragSupport(DND.DROP_COPY, transferTypes, new DragSourceListener() { private CdaMessage cdaMessage; @Override public void dragStart(DragSourceEvent event) { event.doit = true; event.detail = DND.DROP_MOVE; log.log("dragStart", Log.DEBUGMSG); } @Override public void dragSetData(DragSourceEvent event) { ISelection selection = tableViewer.getSelection(); Object obj = ((IStructuredSelection) selection).getFirstElement(); if (obj != null) { cdaMessage = (CdaMessage) obj; String files[] = cdaMessage.getFiles(); for (int i = 0; i < files.length; ++i) { files[i] = cdaMessage.getPath(files[i]); log.log("dragSetData " + files[i], Log.DEBUGMSG); } event.data = files; } } @Override public void dragFinished(DragSourceEvent event) { log.log("dragFinished", Log.DEBUGMSG); if (event.detail == 1) { cdaMessage.setAssignedToOmnivore(); } } }); selectionEvent(CoreHub.actUser); tableViewer.setInput(getViewSite()); actionOpenAttachments = new Action(Messages.DocboxDocumentsView_Action_AttachmentsOpen) { public void run() { ISelection selection = tableViewer.getSelection(); Object obj = ((IStructuredSelection) selection).getFirstElement(); CdaMessage cdaMessage = (CdaMessage) obj; cdaMessage.execute(); } }; actionShowCdaDocument = new Action(Messages.DocboxDocumentsView_Action_ShowCdaDocument) { public void run() { ISelection selection = tableViewer.getSelection(); Object obj = ((IStructuredSelection) selection).getFirstElement(); CdaMessage cdaMessage = (CdaMessage) obj; TextTransfer textTransfer = TextTransfer.getInstance(); final Clipboard cb = new Clipboard(UiDesk.getDisplay()); cb.setContents(new Object[] { cdaMessage.getCda() }, new Transfer[] { textTransfer }); } }; actionDeleteDocument = new Action(Messages.DocboxDocumentsView_Action_Delete) { public void run() { ISelection selection = tableViewer.getSelection(); Object obj = ((IStructuredSelection) selection).getFirstElement(); if (obj != null) { CdaMessage cdaMessage = (CdaMessage) obj; MessageBox messageBox = new MessageBox(UiDesk.getDisplay().getActiveShell(), SWT.ICON_WARNING | SWT.OK | SWT.CANCEL); messageBox.setText(Messages.DocboxDocumentsView_Action_Delete); messageBox.setMessage(String.format(Messages.DocboxDocumentsView_Action_DeleteConfirmMsg, cdaMessage.getTitle())); if (messageBox.open() == SWT.OK) { cdaMessage.deleteDocs(); tableViewer.refresh(); } } } }; actionCreatePatient = new Action(Messages.DocboxDocumentsView_Action_CreatePatient) { public void run() { ISelection selection = tableViewer.getSelection(); Object obj = ((IStructuredSelection) selection).getFirstElement(); if (obj != null) { CdaMessage cdaMessage = (CdaMessage) obj; CdaChXPath xpath = new CdaChXPath(); String name = cdaMessage.getCda(); if (name != null) { xpath.setPatientDocument(cdaMessage.getCda()); String family = xpath.getPatientLastName(); String given = xpath.getPatientFirstName(); String streetAdressLine = xpath.getPatientStreet(); String plz = xpath.getPatientPlz(); String city = xpath.getPatientCity(); Patient p = new Patient(family, given, "", ""); p.set(Person.NAME, family); p.set(Person.FIRSTNAME, given); p.set(Kontakt.FLD_STREET, streetAdressLine); p.set(Kontakt.FLD_ZIP, plz); p.set(Kontakt.FLD_PLACE, city); p.set(Patient.FLD_E_MAIL, xpath.getPatientEmail()); if ("M".equals(xpath.getPatientGender())) { p.set(Patient.FLD_SEX, "m"); } if ("F".equals(xpath.getPatientGender())) { p.set(Patient.FLD_SEX, "w"); } p.set(Patient.FLD_PHONE1, xpath.getPatientHomePhone()); p.set(Patient.FLD_MOBILEPHONE, xpath.getPatientMobile()); p.set(Patient.FLD_PHONE2, xpath.getPatientOfficePhone()); p.set(Patient.BIRTHDATE, xpath.getPatientDateOfBirth()); String ahv = xpath.getPatientAhv13(); if (ahv != null && !"".equals(ahv)) { p.addXid(DOMAIN_AHV, xpath.getPatientAhv13(), true); } ElexisEventDispatcher.fireSelectionEvent((PersistentObject) p); ElexisEventDispatcher.reload(Patient.class); } } } }; MenuManager mgr = new MenuManager(); mgr.setRemoveAllWhenShown(true); mgr.addMenuListener(new IMenuListener() { public void menuAboutToShow(IMenuManager manager) { manager.add(actionOpenAttachments); manager.add(actionDeleteDocument); manager.add(actionShowCdaDocument); manager.add(actionCreatePatient); } }); tableViewer.getControl().setMenu(mgr.createContextMenu(tableViewer.getControl())); tableViewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { actionOpenAttachments.run(); } }); tableViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection sel = (IStructuredSelection) event.getSelection(); if ((sel != null) && !sel.isEmpty()) { Object object = sel.getFirstElement(); if (object instanceof CdaMessage) { CdaMessage cdaMessage = (CdaMessage) object; cdaMessage.setRead(); // try to find the matchting person CdaChXPath cdaChXPath = new CdaChXPath(); String cda = cdaMessage.getCda(); if (cda != null) { cdaChXPath.setPatientDocument(cda); String lastName = cdaChXPath.getPatientLastName(); String firstName = cdaChXPath.getPatientFirstName(); String geburtsdatum = cdaChXPath.getPatientDateOfBirth(); if (cdaChXPath.getPatientNumber() != null) { String patId = new Query<Patient>(Patient.class).findSingle("PatientNr", "=", //$NON-NLS-1$//$NON-NLS-2$ cdaChXPath.getPatientNumber()); if (patId != null) { Patient elexisPatient = Patient.load(patId); if (elexisPatient != null && elexisPatient.getName().equals(lastName) && elexisPatient.getVorname().equals(firstName)) { log.log("selecting patient by id with " + lastName + ", " + firstName, Log.DEBUGMSG); ElexisEventDispatcher.fireSelectionEvent(elexisPatient); return; } } } if (KontaktMatcher.findPerson(lastName, firstName, geburtsdatum, null, null, null, null, null, CreateMode.FAIL) != null) { log.log("selecting patient by demographics " + lastName + ", " + firstName, Log.DEBUGMSG); Patient elexisPatient = KontaktMatcher.findPatient(lastName, firstName, geburtsdatum, null, null, null, null, null, CreateMode.FAIL); if (elexisPatient != null) { ElexisEventDispatcher.fireSelectionEvent(elexisPatient); } } } tableViewer.refresh(); } } } }); GlobalEventDispatcher.addActivationListener(this, getViewSite().getPart()); }
From source file:ch.elexis.agenda.views.BaseAgendaView.java
License:Open Source License
public IPlannable getSelection() { IStructuredSelection sel = (IStructuredSelection) tv.getSelection(); if ((sel == null || (sel.isEmpty()))) { return null; } else {/*from w w w . ja va2 s . c om*/ IPlannable pl = (IPlannable) sel.getFirstElement(); return pl; } }
From source file:ch.elexis.agenda.views.BaseAgendaView.java
License:Open Source License
protected void makeActions() { dayLimitsAction = new Action(Messages.BaseAgendaView_dayLimits) { @Override/*from w w w .j av a2s . c o m*/ public void run() { new TagesgrenzenDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), agenda.getActDate().toString(TimeTool.DATE_COMPACT), agenda.getActResource()).open(); tv.refresh(true); } }; dayLimitsAction.setId("ch.elexis.agenda.actions.dayLimitsAction"); blockAction = new Action(Messages.TagesView_lockPeriod) { @Override public void run() { IStructuredSelection sel = (IStructuredSelection) tv.getSelection(); if (sel != null && !sel.isEmpty()) { IPlannable p = (IPlannable) sel.getFirstElement(); if (p instanceof Termin.Free) { new Termin(agenda.getActResource(), agenda.getActDate().toString(TimeTool.DATE_COMPACT), p.getStartMinute(), p.getDurationInMinutes() + p.getStartMinute(), Termin.typReserviert(), Termin.statusLeer()); ElexisEventDispatcher.reload(Termin.class); } } } }; terminAendernAction = new LockRequestingRestrictedAction<Termin>(ACLContributor.CHANGE_APPOINTMENTS, Messages.TagesView_changeTermin) { { setImageDescriptor(Images.IMG_EDIT.getImageDescriptor()); setToolTipText(Messages.TagesView_changeThisTermin); } @Override public Termin getTargetedObject() { return (Termin) ElexisEventDispatcher.getSelected(Termin.class); } @Override public void doRun(Termin element) { AcquireLockBlockingUi.aquireAndRun(element, new ILockHandler() { @Override public void lockFailed() { // do nothing } @Override public void lockAcquired() { TerminDialog dlg = new TerminDialog(element); dlg.open(); } }); if (tv != null) { tv.refresh(true); } } }; terminKuerzenAction = new LockRequestingRestrictedAction<Termin>(ACLContributor.CHANGE_APPOINTMENTS, Messages.TagesView_shortenTermin) { @Override public Termin getTargetedObject() { return (Termin) ElexisEventDispatcher.getSelected(Termin.class); } @Override public void doRun(Termin element) { element.setDurationInMinutes(element.getDurationInMinutes() >> 1); ElexisEventDispatcher.reload(Termin.class); } }; terminVerlaengernAction = new LockRequestingRestrictedAction<Termin>(ACLContributor.CHANGE_APPOINTMENTS, Messages.TagesView_enlargeTermin) { @Override public Termin getTargetedObject() { return (Termin) ElexisEventDispatcher.getSelected(Termin.class); } @Override public void doRun(Termin t) { agenda.setActDate(t.getDay()); Termin n = Plannables.getFollowingTermin(agenda.getActResource(), agenda.getActDate(), t); if (n != null) { t.setEndTime(n.getStartTime()); // t.setDurationInMinutes(t.getDurationInMinutes()+15); ElexisEventDispatcher.reload(Termin.class); } } }; newTerminAction = new RestrictedAction(ACLContributor.CHANGE_DAYSETTINGS, Messages.TagesView_newTermin) { { setImageDescriptor(Images.IMG_NEW.getImageDescriptor()); setToolTipText(Messages.TagesView_createNewTermin); } @Override public void doRun() { TerminDialog dlg = new TerminDialog(null); dlg.open(); if (tv != null) { tv.refresh(true); } } }; newTerminForAction = new Action("Neuer Termin fr...") { { setImageDescriptor(Images.IMG_NEW.getImageDescriptor()); setToolTipText("Dialog zum Auswhlen eines Kontakts fr den Termin ffnen"); } @Override public void run() { KontaktSelektor ksl = new KontaktSelektor(getSite().getShell(), Kontakt.class, "Terminvergabe", "Bitte whlen Sie aus, wer einen Termin braucht", Kontakt.DEFAULT_SORT); IPlannable sel = getSelection(); TerminDialog dlg = new TerminDialog(null); dlg.open(); if (tv != null) { tv.refresh(true); } } }; printAction = new Action(Messages.BaseAgendaView_printDayList) { { setImageDescriptor(Images.IMG_PRINTER.getImageDescriptor()); setToolTipText(Messages.BaseAgendaView_printListOfDay); } @Override public void run() { IPlannable[] liste = Plannables.loadDay(agenda.getActResource(), agenda.getActDate()); TerminListeDruckenDialog dlg = new TerminListeDruckenDialog(getViewSite().getShell(), liste); dlg.open(); if (tv != null) { tv.refresh(true); } } }; printPatientAction = new Action(Messages.BaseAgendaView_printPatAppointments) { { setImageDescriptor(Images.IMG_PRINTER.getImageDescriptor()); setToolTipText(Messages.BaseAgendaView_printFutureAppsOfSelectedPatient); } @Override public void run() { Patient patient = ElexisEventDispatcher.getSelectedPatient(); if (patient != null) { Query<Termin> qbe = new Query<Termin>(Termin.class); qbe.add(Termin.FLD_PATIENT, Query.EQUALS, patient.getId()); qbe.add(PersistentObject.FLD_DELETED, Query.NOT_EQUAL, StringConstants.ONE); qbe.add(Termin.FLD_TAG, Query.GREATER_OR_EQUAL, new TimeTool().toString(TimeTool.DATE_COMPACT)); qbe.orderBy(false, Termin.FLD_TAG, Termin.FLD_BEGINN); java.util.List<Termin> list = qbe.execute(); if (list != null) { boolean directPrint = CoreHub.localCfg.get( PreferenceConstants.AG_PRINT_APPOINTMENTCARD_DIRECTPRINT, PreferenceConstants.AG_PRINT_APPOINTMENTCARD_DIRECTPRINT_DEFAULT); TermineDruckenDialog dlg = new TermineDruckenDialog(getViewSite().getShell(), list.toArray(new Termin[0])); if (directPrint) { dlg.setBlockOnOpen(false); dlg.open(); if (dlg.doPrint()) { dlg.close(); } else { SWTHelper.alert(Messages.BaseAgendaView_errorWhileprinting, Messages.BaseAgendaView_errorHappendPrinting); } } else { dlg.setBlockOnOpen(true); dlg.open(); } } } } }; exportAction = new Action(Messages.BaseAgendaView_exportAgenda) { { setToolTipText(Messages.BaseAgendaView_exportAppointsments); setImageDescriptor(Images.IMG_GOFURTHER.getImageDescriptor()); } @Override public void run() { ICalTransfer ict = new ICalTransfer(); ict.doExport(agenda.getActDate(), agenda.getActDate(), agenda.getActResource()); } }; importAction = new Action(Messages.BaseAgendaView_importAgenda) { { setToolTipText(Messages.BaseAgendaView_importFromIcal); setImageDescriptor(Images.IMG_IMPORT.getImageDescriptor()); } @Override public void run() { ICalTransfer ict = new ICalTransfer(); ict.doImport(agenda.getActResource()); } }; bereichMenu = new Action(Messages.TagesView_bereich, Action.AS_DROP_DOWN_MENU) { Menu mine; { setToolTipText(Messages.TagesView_selectBereich); setMenuCreator(bmc); } }; mgr = getViewSite().getActionBars().getMenuManager(); mgr.add(bereichMenu); mgr.add(dayLimitsAction); mgr.add(newViewAction); mgr.add(exportAction); mgr.add(importAction); mgr.add(printAction); mgr.add(printPatientAction); }
From source file:ch.elexis.core.ui.dialogs.DocumentSelectDialog.java
License:Open Source License
@Override protected void okPressed() { IStructuredSelection sel = (IStructuredSelection) tv.getSelection(); if ((sel != null) && (!sel.isEmpty())) { result = (Brief) sel.getFirstElement(); if ((type & TEMPLATE) != 0) { betreff = tBetreff.getText(); }//from w w w.j a va2 s . c o m if (StringTool.isNothing(betreff)) { betreff = result.getBetreff(); } } super.okPressed(); }
From source file:ch.elexis.core.ui.laboratory.views.LabNotSeenView.java
License:Open Source License
@Override public void createPartControl(final Composite parent) { parent.setLayout(new FillLayout()); Table table = new Table(parent, SWT.CHECK | SWT.V_SCROLL); for (int i = 0; i < columnHeaders.length; i++) { TableColumn tc = new TableColumn(table, SWT.NONE); tc.setText(columnHeaders[i]);// ww w .j av a2s. c om tc.setWidth(colWidths[i]); } table.setHeaderVisible(true); table.setLinesVisible(true); tv = new CheckboxTableViewer(table); tv.setContentProvider(new LabNotSeenContentProvider()); tv.setLabelProvider(new LabNotSeenLabelProvider()); tv.setUseHashlookup(true); tv.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(final SelectionChangedEvent event) { IStructuredSelection sel = (IStructuredSelection) event.getSelection(); if (!sel.isEmpty()) { if (sel.getFirstElement() instanceof LabResult) { LabResult lr = (LabResult) sel.getFirstElement(); ElexisEventDispatcher.fireSelectionEvent(lr.getPatient()); } } } }); tv.addCheckStateListener(new ICheckStateListener() { boolean bDaempfung; public void checkStateChanged(final CheckStateChangedEvent event) { if (bDaempfung == false) { bDaempfung = true; LabResult lr = (LabResult) event.getElement(); boolean state = event.getChecked(); if (state) { if (CoreHub.acl.request(AccessControlDefaults.LAB_SEEN)) { lr.removeFromUnseen(); } else { tv.setChecked(lr, false); } } else { lr.addToUnseen(); } bDaempfung = false; } } }); makeActions(); ViewMenus menu = new ViewMenus(getViewSite()); menu.createToolbar(markPersonAction, markAllAction); heartbeat(); CoreHub.heart.addListener(this, CoreHub.userCfg.get(Preferences.LABSETTINGS_CFG_LABNEW_HEARTRATE, Heartbeat.FREQUENCY_HIGH)); tv.setInput(this); }
From source file:ch.elexis.core.ui.preferences.inputs.ACLPreferenceTree.java
License:Open Source License
public ACLPreferenceTree(Composite parent, ACE... acl) { super(parent, SWT.NONE); acls = new Tree<ACE>(null, null); for (ACE s : acl) { Tree<ACE> mine = acls.find(s, true); if (mine == null) { Tree<ACE> parentTree = findParent(s); if (parentTree != null) { new Tree<ACE>(parentTree, s); } else { log.error("Could not find parent ACE " + s.getName()); }//from w w w .jav a2s .co m } } setLayout(new GridLayout()); setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); tv = new TreeViewer(this); tv.setContentProvider(new ITreeContentProvider() { public Object[] getChildren(Object parentElement) { Tree tree = (Tree) parentElement; return tree.getChildren().toArray(); } public Object getParent(Object element) { return ((Tree) element).getParent(); } public boolean hasChildren(Object element) { Tree tree = (Tree) element; return tree.hasChildren(); } public Object[] getElements(Object inputElement) { return acls.getChildren().toArray(); } public void dispose() { // TODO Auto-generated method stub } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { // TODO Auto-generated method stub } }); tv.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { return (String) ((Tree<ACE>) element).contents.getLocalizedName(); } }); tv.getControl().setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); Composite cBottom = new Composite(this, SWT.NONE); cBottom.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); cBottom.setLayout(new GridLayout(2, true)); new Label(cBottom, SWT.NONE).setText(StringConstants.ROLES_DEFAULT); new Label(cBottom, SWT.NONE).setText(StringConstants.ROLE_USERS); lbGroups = new org.eclipse.swt.widgets.List(cBottom, SWT.MULTI | SWT.V_SCROLL); lbUsers = new org.eclipse.swt.widgets.List(cBottom, SWT.MULTI | SWT.V_SCROLL); lbUsers.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); lbGroups.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); lUsers = Hub.getUserList(); for (Anwender an : lUsers) { lbUsers.add(an.getLabel()); } // List<String> lGroups = CoreHub.acl.getGroups(); // for (String s : lGroups) { // lbGroups.add(s); // } tv.addSelectionChangedListener(new ISelectionChangedListener() { /** * if the user selects an ACL from the TreeViewer, we want to select users and groups * that are granted this acl in the lbGroups and lbUsers ListBoxes */ public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection sel = (IStructuredSelection) event.getSelection(); lbGroups.deselectAll(); lbUsers.deselectAll(); // if (!sel.isEmpty()) { // Tree<ACE> acl = (Tree<ACE>) sel.getFirstElement(); // ACE right = acl.contents; // List<String> grps = CoreHub.acl.groupsForGrant(right); // List<Anwender> users = CoreHub.acl.usersForGrant(right); // for (String g : grps) { // int idx = StringTool.getIndex(lbGroups.getItems(), g); // if (idx != -1) { // lbGroups.select(idx); // } // } // for (Anwender an : users) { // int idx = StringTool.getIndex(lbUsers.getItems(), an.getLabel()); // if (idx != -1) { // lbUsers.select(idx); // } // } // } } }); lbGroups.addSelectionListener(new SelectionAdapter() { @SuppressWarnings("unchecked") public void widgetSelected(SelectionEvent arg0) { IStructuredSelection sel = (IStructuredSelection) tv.getSelection(); if (!sel.isEmpty()) { Tree<ACE> acl = (Tree<ACE>) sel.getFirstElement(); ACE right = acl.contents; String[] gsel = lbGroups.getSelection(); for (String g : lbGroups.getItems()) { // CoreHub.acl.revoke(g, right); } for (String g : gsel) { CoreHub.acl.grant(g, right); } } } }); lbUsers.addSelectionListener(new SelectionAdapter() { @SuppressWarnings("unchecked") public void widgetSelected(SelectionEvent arg0) { IStructuredSelection sel = (IStructuredSelection) tv.getSelection(); if (!sel.isEmpty()) { Tree<ACE> acl = (Tree<ACE>) sel.getFirstElement(); ACE right = acl.contents; int[] uSel = lbUsers.getSelectionIndices(); for (Anwender an : lUsers) { // CoreHub.acl.revoke(an, right); } for (int i : uSel) { // CoreHub.acl.grant(lUsers.get(i), right); } } } }); tv.setSorter(new ViewerSorter() { @SuppressWarnings("unchecked") @Override public int compare(Viewer viewer, Object e1, Object e2) { Tree<ACE> t1 = (Tree<ACE>) e1; Tree<ACE> t2 = (Tree<ACE>) e2; return t1.contents.getLocalizedName().compareToIgnoreCase(t2.contents.getLocalizedName()); } }); tv.setInput(this); }
From source file:ch.elexis.core.ui.util.viewers.CommonViewer.java
License:Open Source License
public void doubleClick(DoubleClickEvent event) { if (dlListeners != null) { Iterator<DoubleClickListener> it = dlListeners.iterator(); while (it.hasNext()) { DoubleClickListener dl = it.next(); IStructuredSelection sel = (IStructuredSelection) event.getSelection(); if ((sel != null) && (!sel.isEmpty())) { Object element = sel.getFirstElement(); if (element instanceof Tree<?>) { element = ((Tree<?>) element).contents; }//w w w . j av a 2 s.c o m if (element instanceof PersistentObject) { dl.doubleClicked((PersistentObject) element, this); } } } } }
From source file:ch.elexis.core.ui.views.AUF2.java
License:Open Source License
@Override public void createPartControl(Composite parent) { // setTitleImage(Desk.getImage(ICON)); setPartName(Messages.AUF2_certificate); //$NON-NLS-1$ tv = new TableViewer(parent); tv.setLabelProvider(new DefaultLabelProvider()); tv.setContentProvider(new AUFContentProvider()); makeActions();/*from w w w. jav a2s. c o m*/ ViewMenus menus = new ViewMenus(getViewSite()); menus.createMenu(newAUF, delAUF, modAUF, printAUF); menus.createToolbar(newAUF, delAUF, printAUF); tv.setUseHashlookup(true); GlobalEventDispatcher.addActivationListener(this, this); tv.addSelectionChangedListener(GlobalEventDispatcher.getInstance().getDefaultListener()); tv.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { modAUF.run(); } }); tv.setInput(getViewSite()); final Transfer[] dragTransferTypes = new Transfer[] { TextTransfer.getInstance() }; tv.addDragSupport(DND.DROP_COPY, dragTransferTypes, new DragSourceAdapter() { @Override public void dragSetData(DragSourceEvent event) { IStructuredSelection selection = (IStructuredSelection) tv.getSelection(); StringBuilder sb = new StringBuilder(); if (selection != null && !selection.isEmpty()) { AUF auf = (AUF) selection.getFirstElement(); sb.append(auf.storeToString()).append(","); //$NON-NLS-1$ } event.data = sb.toString().replace(",$", ""); //$NON-NLS-1$ //$NON-NLS-2$ } }); }