package ch.elexis.core.ui.dialogs;

import java.util.List;

import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.swt.graphics.Point;
import org.eclipse.ui.dialogs.ListSelectionDialog;

import ch.elexis.core.l10n.Messages;
import ch.elexis.core.model.issue.ProcessStatus;
import ch.elexis.core.ui.UiDesk;
import ch.elexis.core.ui.util.viewers.PersistentObjectLabelProvider;
import ch.elexis.data.Reminder;

/**
 * Show a list of reminders, and set them as closed on selection and ok
 * 
 * @since 3.7
 */
public class ReminderListSelectionDialog extends ListSelectionDialog {
	
	public ReminderListSelectionDialog(List<Reminder> input, String message){
		super(UiDesk.getTopShell(), input, ArrayContentProvider.getInstance(),
			PersistentObjectLabelProvider.getInstance(),
			Messages.ReminderListSelectionDialog_SelectToClose);
		setTitle(message);
	}
	
	@Override
	protected void okPressed(){
		super.okPressed();
		
		Object[] result = getResult();
		for (Object object : result) {
			Reminder reminder = (Reminder) object;
			reminder.setProcessStatus(ProcessStatus.CLOSED);
		}
	}
	
	@Override
	protected Point getInitialSize(){
		return new Point(600, 250);
	}
	
}

@@ -131,26 +131,441 @@
 pse.
-swt.graphics.Point
+jface.viewers.ISelectionChangedListener;%0Aimport org.eclipse.jface.viewers.IStructuredSelection;%0Aimport org.eclipse.jface.viewers.SelectionChangedEvent;%0Aimport org.eclipse.jface.viewers.StructuredSelection;%0Aimport org.eclipse.swt.SWT;%0Aimport org.eclipse.swt.graphics.Point;%0Aimport org.eclipse.swt.layout.FillLayout;%0Aimport org.eclipse.swt.widgets.Composite;%0Aimport org.eclipse.swt.widgets.Control;%0Aimport org.eclipse.swt.widgets.Label
 ;%0Aim
@@ -1006,16 +1006,73 @@
 log %7B%0A%09%0A
+%09private Label detailLabel;%0A%09private Composite detail;%0A%09%0A
 %09public 
@@ -1344,32 +1344,1081 @@
 %09%7D%0A%09%0A%09@Override%0A
+%09protected Control createDialogArea(Composite parent)%7B%0A%09%09Control control = super.createDialogArea(parent);%0A%09%09detail = new Composite(parent, SWT.None);%0A%09%09detail.setLayout(new FillLayout(SWT.HORIZONTAL));%0A%09%09%0A%09%09detailLabel = new Label(detail, SWT.None);%0A%09%09%0A%09%09getViewer().addSelectionChangedListener(new ISelectionChangedListener() %7B%0A%09%09%09%0A%09%09%09@Override%0A%09%09%09public void selectionChanged(SelectionChangedEvent arg0)%7B%0A%09%09%09%09final StringBuilder sb = new StringBuilder();%0A%09%09%09%09%0A%09%09%09%09if (!arg0.getSelection().isEmpty()) %7B%0A%09%09%09%09%09Reminder reminder =%0A%09%09%09%09%09%09(Reminder) ((IStructuredSelection) arg0.getSelection()).getFirstElement();%0A%09%09%09%09%09sb.append(%22    %22+reminder.getSubject() + %22%5Cn%22);%0A%09%09%09%09%09sb.append(%22    %22+reminder.getMessage());%0A%09%09%09%09%7D%0A%09%09%09%09detailLabel.setText(sb.toString());%0A%09%09%09%09detail.getParent().layout();%0A%09%09%09%7D%0A%09%09%7D);%0A%09%09%0A%09%09@SuppressWarnings(%22unchecked%22)%0A%09%09List%3CReminder%3E reminders = (List%3CReminder%3E) getViewer().getInput();%0A%09%09if (reminders.size() %3E 0) %7B%0A%09%09%09getViewer().setSelection(new StructuredSelection(reminders.get(0)));%0A%09%09%7D%0A%09%09%0A%09%09return control;%0A%09%7D%0A%09%0A%09@Override%0A
 %09protected void 
@@ -2697,17 +2697,15 @@
 00, 
-25
+30
 0);%0A%09%7D%0A
-%09%0A
 %7D%0A

Allow closing reminders on login, show reminder detail