List of usage examples for org.eclipse.jface.viewers StructuredSelection StructuredSelection
public StructuredSelection()
From source file:at.rc.tacos.client.view.DialysisView.java
License:Open Source License
/** * Call back method to create the control and initialize them. * //from w w w . ja v a 2 s. c om * @param parent * the parent composite to add */ @Override public void createPartControl(final Composite parent) { // Create the scrolled parent component toolkit = new FormToolkit(CustomColors.FORM_COLOR(parent.getDisplay())); form = toolkit.createScrolledForm(parent); toolkit.decorateFormHeading(form.getForm()); form.getBody().setLayout(new FillLayout()); final Composite composite = form.getBody(); viewer = new TableViewer(composite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION); viewer.setContentProvider(new DialysisTransportContentProvider()); viewer.setLabelProvider(new DialysisTransportLabelProvider()); viewer.setInput(ModelFactory.getInstance().getDialyseManager()); viewer.getTable().setLinesVisible(true); viewer.refresh(); final Table table_2 = viewer.getTable(); table_2.setLinesVisible(true); table_2.setHeaderVisible(true); final TableColumn lockColumn = new TableColumn(table_2, SWT.NONE); lockColumn.setToolTipText("Eintrag wird gerade bearbeitet"); lockColumn.setWidth(24); lockColumn.setText("L"); final TableColumn newColumnTableColumnStationDialyse = new TableColumn(table_2, SWT.NONE); newColumnTableColumnStationDialyse.setToolTipText("Zustndige Ortsstelle"); newColumnTableColumnStationDialyse.setWidth(200); newColumnTableColumnStationDialyse.setText("OS"); final TableColumn newColumnTableColumnAbfDialyse = new TableColumn(table_2, SWT.NONE); newColumnTableColumnAbfDialyse.setToolTipText("Geplante Abfahrt an Ortsstelle"); newColumnTableColumnAbfDialyse.setWidth(68); newColumnTableColumnAbfDialyse.setText("Abf"); final TableColumn newColumnTableColumnAnkDialyse = new TableColumn(table_2, SWT.NONE); newColumnTableColumnAnkDialyse.setToolTipText("Geplante Ankunft beim Patienten"); newColumnTableColumnAnkDialyse.setWidth(68); newColumnTableColumnAnkDialyse.setText("Ank"); final TableColumn newColumnTableColumnTerminDialyse = new TableColumn(table_2, SWT.NONE); newColumnTableColumnTerminDialyse.setToolTipText("Termin auf der Dialyse"); newColumnTableColumnTerminDialyse.setWidth(68); newColumnTableColumnTerminDialyse.setText("Termin"); final TableColumn newColumnTableColumnRTAbfahrtDialyse = new TableColumn(table_2, SWT.NONE); newColumnTableColumnRTAbfahrtDialyse.setToolTipText("Abfahrt an der Ortsstelle"); newColumnTableColumnRTAbfahrtDialyse.setWidth(68); newColumnTableColumnRTAbfahrtDialyse.setText("RT Abfahrt"); final TableColumn newColumnTableColumnAbholbereitDialyse = new TableColumn(table_2, SWT.NONE); newColumnTableColumnAbholbereitDialyse.setToolTipText("Patient ist mit Dialyse fertig, abholbereit im LKH"); newColumnTableColumnAbholbereitDialyse.setWidth(68); newColumnTableColumnAbholbereitDialyse.setText("Abholbereit"); final TableColumn newColumnTableColumnWohnortDialyse = new TableColumn(table_2, SWT.NONE); newColumnTableColumnWohnortDialyse.setWidth(250); newColumnTableColumnWohnortDialyse.setText("Wohnort"); final TableColumn newColumnTableColumnNameDialyse = new TableColumn(table_2, SWT.NONE); newColumnTableColumnNameDialyse.setWidth(250); newColumnTableColumnNameDialyse.setText("Name"); final TableColumn newColumnTableColumnDialyseort = new TableColumn(table_2, SWT.NONE); newColumnTableColumnDialyseort.setWidth(250); newColumnTableColumnDialyseort.setText("Dialyseort"); final TableColumn newColumnTableColumnMontag = new TableColumn(table_2, SWT.NONE); newColumnTableColumnMontag.setData("newKey", null); newColumnTableColumnMontag.setWidth(30); newColumnTableColumnMontag.setText("Mo"); final TableColumn newColumnTableColumnDienstag = new TableColumn(table_2, SWT.NONE); newColumnTableColumnDienstag.setWidth(30); newColumnTableColumnDienstag.setText("Di"); final TableColumn newColumnTableColumnMittwoch = new TableColumn(table_2, SWT.NONE); newColumnTableColumnMittwoch.setWidth(30); newColumnTableColumnMittwoch.setText("Mi"); final TableColumn newColumnTableColumnDonnerstag = new TableColumn(table_2, SWT.NONE); newColumnTableColumnDonnerstag.setWidth(30); newColumnTableColumnDonnerstag.setText("Do"); final TableColumn newColumnTableColumnFreitag = new TableColumn(table_2, SWT.NONE); newColumnTableColumnFreitag.setWidth(30); newColumnTableColumnFreitag.setText("Fr"); final TableColumn newColumnTableColumnSamstag = new TableColumn(table_2, SWT.NONE); newColumnTableColumnSamstag.setWidth(30); newColumnTableColumnSamstag.setText("Sa"); final TableColumn newColumnTableColumnSonntag = new TableColumn(table_2, SWT.NONE); newColumnTableColumnSonntag.setWidth(30); newColumnTableColumnSonntag.setText("So"); final TableColumn newColumnTableColumnTA = new TableColumn(table_2, SWT.NONE); newColumnTableColumnTA.setWidth(90); newColumnTableColumnTA.setText("TA"); final TableColumn newColumnTableColumnStationaer = new TableColumn(table_2, SWT.NONE); newColumnTableColumnStationaer.setToolTipText("Patient wird derzeit nicht transportiert"); newColumnTableColumnStationaer.setWidth(40); newColumnTableColumnStationaer.setText("Stat"); viewer.getTable().addMouseListener(new MouseAdapter() { public void mouseDown(MouseEvent e) { if (viewer.getTable().getItem(new Point(e.x, e.y)) == null) { viewer.setSelection(new StructuredSelection()); } } }); /** make the columns sort able */ Listener sortListener = new Listener() { public void handleEvent(Event e) { // determine new sort column and direction TableColumn sortColumn = viewer.getTable().getSortColumn(); TableColumn currentColumn = (TableColumn) e.widget; int dir = viewer.getTable().getSortDirection(); // revert the sort order if the column is the same if (sortColumn == currentColumn) { if (dir == SWT.UP) dir = SWT.DOWN; else dir = SWT.UP; } else { viewer.getTable().setSortColumn(currentColumn); dir = SWT.UP; } // sort the data based on column and direction String sortIdentifier = null; if (currentColumn == newColumnTableColumnStationDialyse) sortIdentifier = DialysisTransportSorter.RESP_STATION_SORTER; if (currentColumn == newColumnTableColumnAbfDialyse) sortIdentifier = DialysisTransportSorter.ABF_SORTER; if (currentColumn == newColumnTableColumnAnkDialyse) sortIdentifier = DialysisTransportSorter.AT_PATIENT_SORTER; if (currentColumn == newColumnTableColumnTerminDialyse) sortIdentifier = DialysisTransportSorter.TERM_SORTER; if (currentColumn == newColumnTableColumnWohnortDialyse) sortIdentifier = DialysisTransportSorter.TRANSPORT_FROM_SORTER; if (currentColumn == newColumnTableColumnNameDialyse) sortIdentifier = DialysisTransportSorter.PATIENT_SORTER; if (currentColumn == newColumnTableColumnDialyseort) sortIdentifier = DialysisTransportSorter.TRANSPORT_TO_SORTER; if (currentColumn == newColumnTableColumnRTAbfahrtDialyse) sortIdentifier = DialysisTransportSorter.RT_SORTER; if (currentColumn == newColumnTableColumnAbholbereitDialyse) sortIdentifier = DialysisTransportSorter.READY_SORTER; if (currentColumn == newColumnTableColumnTA) sortIdentifier = DialysisTransportSorter.TA_SORTER; // apply the filter viewer.getTable().setSortDirection(dir); viewer.setSorter(new DialysisTransportSorter(sortIdentifier, dir)); } }; // attach the listener newColumnTableColumnStationDialyse.addListener(SWT.Selection, sortListener); newColumnTableColumnAbfDialyse.addListener(SWT.Selection, sortListener); newColumnTableColumnAnkDialyse.addListener(SWT.Selection, sortListener); newColumnTableColumnTerminDialyse.addListener(SWT.Selection, sortListener); newColumnTableColumnWohnortDialyse.addListener(SWT.Selection, sortListener); newColumnTableColumnNameDialyse.addListener(SWT.Selection, sortListener); newColumnTableColumnRTAbfahrtDialyse.addListener(SWT.Selection, sortListener); newColumnTableColumnAbholbereitDialyse.addListener(SWT.Selection, sortListener); newColumnTableColumnTA.addListener(SWT.Selection, sortListener); newColumnTableColumnDialyseort.addListener(SWT.Selection, sortListener); makeActions(); hookContextMenu(); createToolBarActions(); viewer.refresh(); }
From source file:at.rc.tacos.client.view.JournalView.java
License:Open Source License
/** * Callback method to create the control and initialize them. * /*from w w w.ja va 2 s .com*/ * @param parent * the parent composite to add */ @Override public void createPartControl(final Composite parent) { // Create the scrolled parent component toolkit = new FormToolkit(CustomColors.FORM_COLOR(parent.getDisplay())); form = toolkit.createForm(parent); toolkit.decorateFormHeading(form); form.getBody().setLayout(new FillLayout()); final Composite composite = form.getBody(); viewer = new TableViewer(composite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION); viewer.setContentProvider(new JournalViewContentProvider()); viewer.setLabelProvider(new JournalViewLabelProvider()); viewer.setInput(ModelFactory.getInstance().getTransportManager()); viewer.getTable().setLinesVisible(true); // set the tooltip tooltip = new JournalViewTooltip(viewer.getControl()); // show the tooltip when the selection has changed viewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { TableItem[] selection = viewer.getTable().getSelection(); if (selection != null && selection.length > 0) { Rectangle bounds = selection[0].getBounds(); tooltip.show(new Point(bounds.x, bounds.y)); } } }); viewer.getTable().addMouseListener(new MouseAdapter() { public void mouseDown(MouseEvent e) { if (viewer.getTable().getItem(new Point(e.x, e.y)) == null) { viewer.setSelection(new StructuredSelection()); } } }); // sort the table by default viewer.setSorter(new TransportSorter(TransportSorter.TRANSPORT_FROM_SORTER, SWT.DOWN)); // create the table for the transports final Table table = viewer.getTable(); table.setLinesVisible(true); table.setHeaderVisible(true); final TableColumn lockColumn = new TableColumn(table, SWT.NONE); lockColumn.setToolTipText("Eintrag wird gerade bearbeitet"); lockColumn.setWidth(24); lockColumn.setText("L"); final TableColumn realOSJournal = new TableColumn(table, SWT.NONE); realOSJournal.setToolTipText("Ortsstelle, die den Transport durchgefhrt hat"); realOSJournal.setWidth(29); realOSJournal.setText("OS"); final TableColumn columnTNrJournal = new TableColumn(table, SWT.NONE); columnTNrJournal.setMoveable(true); columnTNrJournal.setToolTipText("Transportnummer"); columnTNrJournal.setWidth(70); columnTNrJournal.setText("TNr"); final TableColumn columnPrioritaetJournal = new TableColumn(table, SWT.NONE); columnPrioritaetJournal.setToolTipText( "1 (NEF), 2 (Transport), 3 (Terminfahrt), 4 (Rcktransport), 5 (Heimtransport), 6 (Sonstiges), 7 (NEF extern)"); columnPrioritaetJournal.setWidth(20); columnPrioritaetJournal.setText("Pr"); final TableColumn columnTransportVonJournal = new TableColumn(table, SWT.NONE); columnTransportVonJournal.setMoveable(true); columnTransportVonJournal.setWidth(250); columnTransportVonJournal.setText("Transport von"); final TableColumn columnPatientJournal = new TableColumn(table, SWT.NONE); columnPatientJournal.setMoveable(true); columnPatientJournal.setWidth(195); columnPatientJournal.setText("Patient"); final TableColumn columnTransportNachJournal = new TableColumn(table, SWT.NONE); columnTransportNachJournal.setWidth(250); columnTransportNachJournal.setText("Transport nach"); final TableColumn columnErkrVerlJournal = new TableColumn(table, SWT.NONE); columnErkrVerlJournal.setWidth(120); columnErkrVerlJournal.setText("Erkr/Verl"); final TableColumn columnAEJournal = new TableColumn(table, SWT.NONE); columnAEJournal.setToolTipText("Auftrag erteilt"); columnAEJournal.setWidth(43); columnAEJournal.setText("AE"); final TableColumn columnS1Journal = new TableColumn(table, SWT.NONE); columnS1Journal.setToolTipText("Transportbeginn"); columnS1Journal.setWidth(43); columnS1Journal.setText("S1"); final TableColumn columnS2Journal = new TableColumn(table, SWT.NONE); columnS2Journal.setToolTipText("Bei Patient"); columnS2Journal.setWidth(43); columnS2Journal.setText("S2"); final TableColumn columnS3Journal = new TableColumn(table, SWT.NONE); columnS3Journal.setToolTipText("Abfahrt mit Patient"); columnS3Journal.setWidth(43); columnS3Journal.setText("S3"); final TableColumn columnS4Journal = new TableColumn(table, SWT.NONE); columnS4Journal.setToolTipText("Ankunft Zielort"); columnS4Journal.setWidth(43); columnS4Journal.setText("S4"); final TableColumn columnS5Journal = new TableColumn(table, SWT.NONE); columnS5Journal.setToolTipText("Ziel frei"); columnS5Journal.setWidth(43); columnS5Journal.setText("S5"); final TableColumn columnS6Journal = new TableColumn(table, SWT.NONE); columnS6Journal.setToolTipText("Fahrzeug eingerckt"); columnS6Journal.setWidth(43); columnS6Journal.setText("S6"); final TableColumn columnFzgJournal = new TableColumn(table, SWT.NONE); columnFzgJournal.setWidth(45); columnFzgJournal.setText("Fzg"); final TableColumn columnFahrerJournal = new TableColumn(table, SWT.NONE); columnFahrerJournal.setWidth(120); columnFahrerJournal.setText("Fahrer"); final TableColumn columnSaniIJournal = new TableColumn(table, SWT.NONE); columnSaniIJournal.setWidth(120); columnSaniIJournal.setText("Sanitter I"); final TableColumn columnSaniIIJournal = new TableColumn(table, SWT.NONE); columnSaniIIJournal.setWidth(120); columnSaniIIJournal.setText("Sanitter II"); // make the columns sort able Listener sortListener = new Listener() { public void handleEvent(Event e) { // determine new sort column and direction TableColumn sortColumn = viewer.getTable().getSortColumn(); TableColumn currentColumn = (TableColumn) e.widget; int dir = viewer.getTable().getSortDirection(); // revert the sort order if the column is the same if (sortColumn == currentColumn) { if (dir == SWT.UP) dir = SWT.DOWN; else dir = SWT.UP; } else { viewer.getTable().setSortColumn(currentColumn); dir = SWT.UP; } // sort the data based on column and direction String sortIdentifier = null; if (currentColumn == columnTNrJournal) sortIdentifier = TransportSorter.TNR_SORTER; if (currentColumn == columnPrioritaetJournal) sortIdentifier = TransportSorter.PRIORITY_SORTER; if (currentColumn == columnTransportVonJournal) sortIdentifier = TransportSorter.TRANSPORT_FROM_SORTER; if (currentColumn == columnPatientJournal) sortIdentifier = TransportSorter.PATIENT_SORTER; if (currentColumn == columnTransportNachJournal) sortIdentifier = TransportSorter.TRANSPORT_TO_SORTER; if (currentColumn == columnErkrVerlJournal) sortIdentifier = TransportSorter.KIND_OF_ILLNESS_SORTER; if (currentColumn == columnAEJournal) sortIdentifier = TransportSorter.AE_SORTER; if (currentColumn == columnS1Journal) sortIdentifier = TransportSorter.S1_SORTER; if (currentColumn == columnS2Journal) sortIdentifier = TransportSorter.S2_SORTER; if (currentColumn == columnS3Journal) sortIdentifier = TransportSorter.S3_SORTER; if (currentColumn == columnS4Journal) sortIdentifier = TransportSorter.S4_SORTER; if (currentColumn == columnS5Journal) sortIdentifier = TransportSorter.S5_SORTER; if (currentColumn == columnS6Journal) sortIdentifier = TransportSorter.S6_SORTER; if (currentColumn == columnFzgJournal) sortIdentifier = TransportSorter.VEHICLE_SORTER; if (currentColumn == columnFahrerJournal) sortIdentifier = TransportSorter.DRIVER_SORTER; if (currentColumn == columnSaniIJournal) sortIdentifier = TransportSorter.PARAMEDIC_I_SORTER; if (currentColumn == columnSaniIIJournal) sortIdentifier = TransportSorter.PARAMEDIC_II_SORTER; // apply the filter viewer.getTable().setSortDirection(dir); viewer.setSorter(new TransportSorter(sortIdentifier, dir)); } }; // attach the listener columnTNrJournal.addListener(SWT.Selection, sortListener); columnPrioritaetJournal.addListener(SWT.Selection, sortListener); columnTransportVonJournal.addListener(SWT.Selection, sortListener); columnPatientJournal.addListener(SWT.Selection, sortListener); columnTransportNachJournal.addListener(SWT.Selection, sortListener); columnErkrVerlJournal.addListener(SWT.Selection, sortListener); columnAEJournal.addListener(SWT.Selection, sortListener); columnS1Journal.addListener(SWT.Selection, sortListener); columnS2Journal.addListener(SWT.Selection, sortListener); columnS3Journal.addListener(SWT.Selection, sortListener); columnS4Journal.addListener(SWT.Selection, sortListener); columnS5Journal.addListener(SWT.Selection, sortListener); columnS6Journal.addListener(SWT.Selection, sortListener); columnFzgJournal.addListener(SWT.Selection, sortListener); columnSaniIJournal.addListener(SWT.Selection, sortListener); columnSaniIIJournal.addListener(SWT.Selection, sortListener); // create the actions makeActions(); hookContextMenu(); // show only transport with the status journal viewer.addFilter(new TransportStateViewFilter(PROGRAM_STATUS_JOURNAL)); viewer.addFilter(new TransportDateFilter(Calendar.getInstance())); viewer.refresh(); }
From source file:at.rc.tacos.client.view.OutstandingTransportsView.java
License:Open Source License
/** * Call back method to create the control and initialize them. * //from w w w .ja v a 2 s. co m * @param parent * the parent composite to add */ @Override public void createPartControl(final Composite parent) { // Create the scrolled parent component toolkit = new FormToolkit(CustomColors.FORM_COLOR(parent.getDisplay())); form = toolkit.createForm(parent); form.setText("Offene Transporte"); toolkit.decorateFormHeading(form); form.getBody().setLayout(new FillLayout()); final Composite composite = form.getBody(); viewerOffTrans = new TableViewer(composite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION); viewerOffTrans.setContentProvider(new OutstandingTransportsViewContentProvider()); viewerOffTrans.setLabelProvider(new OutstandingTransportsViewLabelProvider()); viewerOffTrans.setInput(ModelFactory.getInstance().getTransportManager()); viewerOffTrans.getTable().setLinesVisible(true); viewerOffTrans.getTable().addMouseListener(new MouseAdapter() { public void mouseDown(MouseEvent e) { if (viewerOffTrans.getTable().getItem(new Point(e.x, e.y)) == null) { viewerOffTrans.setSelection(new StructuredSelection()); } } }); viewerOffTrans.refresh(); // make the actions for the context menu when selection has changed viewerOffTrans.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { this.makeActions(); this.hookContextMenu(); } /** * Creates the needed actions */ public void makeActions() { forwardTransportAction = new ForwardTransportAction(viewerOffTrans); editTransportAction = new EditTransportAction(viewerOffTrans, "outstanding"); cancelTransportAction = new CancelTransportAction(viewerOffTrans); copyTransportAction = new CopyTransportAction(viewerOffTrans); // get the list of all vehicle with the status ready for action List<VehicleDetail> readyVehicles = ModelFactory.getInstance().getVehicleManager() .getReadyVehicleList(); // loop and create the actions actionList.clear(); for (VehicleDetail veh : readyVehicles) { AssignCarAction action = new AssignCarAction(viewerOffTrans, veh); actionList.add(action); } } /** * Creates the context menu */ private void hookContextMenu() { MenuManager menuManager = new MenuManager("#OutstandingPopupMenu"); menuManager.setRemoveAllWhenShown(true); menuManager.addMenuListener(new IMenuListener() { public void menuAboutToShow(IMenuManager manager) { fillContextMenu(manager); } }); Menu menu = menuManager.createContextMenu(viewerOffTrans.getControl()); viewerOffTrans.getControl().setMenu(menu); // getSite().registerContextMenu(menuManager, viewerOffTrans); } /** * Fills the context menu with the actions */ private void fillContextMenu(IMenuManager manager) { // get the selected object final Object firstSelectedObject = ((IStructuredSelection) viewerOffTrans.getSelection()) .getFirstElement(); // cast to a RosterEntry Transport transport = (Transport) firstSelectedObject; if (transport == null) return; // submenu for the available vehicles MenuManager menuManagerSub = new MenuManager("Fahrzeug zuweisen"); // add the actions manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); manager.add(menuManagerSub); // create a list of ready vehicles and disable the selection if // the transport is locked boolean locked = lockManager.containsLock(Transport.ID, transport.getTransportId()); for (AssignCarAction ac : actionList) { menuManagerSub.add(ac); if (locked) { ac.setEnabled(false); } } manager.add(new Separator()); manager.add(editTransportAction); manager.add(new Separator()); manager.add(cancelTransportAction); manager.add(forwardTransportAction); manager.add(new Separator()); manager.add(copyTransportAction); // if locked if (locked) { copyTransportAction.setEnabled(false); } else copyTransportAction.setEnabled(true); } }); // set the default sorter viewerOffTrans.setSorter(new TransportSorter(TransportSorter.PRIORITY_SORTER, SWT.UP)); final Table tableOff = viewerOffTrans.getTable(); tableOff.setLinesVisible(true); tableOff.setHeaderVisible(true); final TableColumn lockColumn = new TableColumn(tableOff, SWT.NONE); lockColumn.setToolTipText("Eintrag wird gerade bearbeitet"); lockColumn.setWidth(24); lockColumn.setText("L"); final TableColumn prioritaetOffeneTransporte = new TableColumn(tableOff, SWT.NONE); prioritaetOffeneTransporte.setToolTipText( "A (NEF), B (BD1), C (Transport), D (Rcktransport), E (Heimtransport), F (Sonstiges), E (NEF extern)"); prioritaetOffeneTransporte.setWidth(26); prioritaetOffeneTransporte.setText("Pr"); final TableColumn respOSOffeneTransporte = new TableColumn(tableOff, SWT.NONE); respOSOffeneTransporte.setToolTipText("Zustndige Ortsstelle"); respOSOffeneTransporte.setWidth(30); respOSOffeneTransporte.setText("OS"); final TableColumn abfOffeneTransporte = new TableColumn(tableOff, SWT.NONE); abfOffeneTransporte.setToolTipText("Abfahrt auf der Dienststelle"); abfOffeneTransporte.setWidth(43); abfOffeneTransporte.setText("Abf"); final TableColumn ankOffeneTransporte = new TableColumn(tableOff, SWT.NONE); ankOffeneTransporte.setToolTipText("Ankunft beim Patienten"); ankOffeneTransporte.setWidth(43); ankOffeneTransporte.setText("Ank."); final TableColumn terminOffeneTransporte = new TableColumn(tableOff, SWT.NONE); terminOffeneTransporte.setToolTipText("Terminzeit am Zielort"); terminOffeneTransporte.setWidth(43); terminOffeneTransporte.setText("Termin"); final TableColumn transportVonOffeneTransporte = new TableColumn(tableOff, SWT.NONE); transportVonOffeneTransporte.setWidth(250); transportVonOffeneTransporte.setText("Transport von"); final TableColumn patientOffeneTransporte = new TableColumn(tableOff, SWT.NONE); patientOffeneTransporte.setWidth(200); patientOffeneTransporte.setText("Patient"); final TableColumn transportNachOffeneTransporte = new TableColumn(tableOff, SWT.NONE); transportNachOffeneTransporte.setWidth(250); transportNachOffeneTransporte.setText("Transport nach"); final TableColumn aufgOffeneTransporte = new TableColumn(tableOff, SWT.NONE); aufgOffeneTransporte.setToolTipText("Zeit zu der der Transport aufgenommen wurde"); aufgOffeneTransporte.setWidth(43); aufgOffeneTransporte.setText("Aufg"); final TableColumn tOffeneTransporte = new TableColumn(tableOff, SWT.NONE); tOffeneTransporte.setToolTipText("Transportart"); tOffeneTransporte.setWidth(22); tOffeneTransporte.setText("T"); final TableColumn erkrankungVerletzungOffeneTransporte = new TableColumn(tableOff, SWT.NONE); erkrankungVerletzungOffeneTransporte.setWidth(150); erkrankungVerletzungOffeneTransporte.setText("Erkrankung/Verletzung"); final TableColumn anmerkungOffeneTransporte = new TableColumn(tableOff, SWT.NONE); anmerkungOffeneTransporte.setWidth(542); anmerkungOffeneTransporte.setText("Anmerkung"); // make the columns sortable Listener sortListener = new Listener() { public void handleEvent(Event e) { // determine new sort column and direction TableColumn sortColumn = viewerOffTrans.getTable().getSortColumn(); TableColumn currentColumn = (TableColumn) e.widget; int dir = viewerOffTrans.getTable().getSortDirection(); // revert the sort order if the column is the same if (sortColumn == currentColumn) { if (dir == SWT.UP) dir = SWT.DOWN; else dir = SWT.UP; } else { viewerOffTrans.getTable().setSortColumn(currentColumn); dir = SWT.UP; } // sort the data based on column and direction String sortIdentifier = null; if (currentColumn == prioritaetOffeneTransporte) sortIdentifier = TransportSorter.PRIORITY_SORTER; if (currentColumn == respOSOffeneTransporte) sortIdentifier = TransportSorter.RESP_STATION_SORTER; if (currentColumn == abfOffeneTransporte) sortIdentifier = TransportSorter.ABF_SORTER; if (currentColumn == ankOffeneTransporte) sortIdentifier = TransportSorter.AT_PATIENT_SORTER; if (currentColumn == terminOffeneTransporte) sortIdentifier = TransportSorter.TERM_SORTER; if (currentColumn == transportVonOffeneTransporte) sortIdentifier = TransportSorter.TRANSPORT_FROM_SORTER; if (currentColumn == patientOffeneTransporte) sortIdentifier = TransportSorter.PATIENT_SORTER; if (currentColumn == transportNachOffeneTransporte) sortIdentifier = TransportSorter.TRANSPORT_TO_SORTER; if (currentColumn == aufgOffeneTransporte) sortIdentifier = TransportSorter.AUFG_SORTER; if (currentColumn == tOffeneTransporte) sortIdentifier = TransportSorter.TA_SORTER; if (currentColumn == erkrankungVerletzungOffeneTransporte) sortIdentifier = TransportSorter.KIND_OF_ILLNESS_SORTER; if (currentColumn == anmerkungOffeneTransporte) sortIdentifier = TransportSorter.NOTES_SORTER; // apply the filter viewerOffTrans.getTable().setSortDirection(dir); viewerOffTrans.setSorter(new TransportSorter(sortIdentifier, dir)); } }; // attach the listener prioritaetOffeneTransporte.addListener(SWT.Selection, sortListener); respOSOffeneTransporte.addListener(SWT.Selection, sortListener); abfOffeneTransporte.addListener(SWT.Selection, sortListener); ankOffeneTransporte.addListener(SWT.Selection, sortListener); terminOffeneTransporte.addListener(SWT.Selection, sortListener); transportVonOffeneTransporte.addListener(SWT.Selection, sortListener); patientOffeneTransporte.addListener(SWT.Selection, sortListener); transportNachOffeneTransporte.addListener(SWT.Selection, sortListener); aufgOffeneTransporte.addListener(SWT.Selection, sortListener); tOffeneTransporte.addListener(SWT.Selection, sortListener); erkrankungVerletzungOffeneTransporte.addListener(SWT.Selection, sortListener); anmerkungOffeneTransporte.addListener(SWT.Selection, sortListener); viewerOffTrans.resetFilters(); // apply the filter to show only outstanding transports viewerOffTrans.addFilter(new TransportStateViewFilter(PROGRAM_STATUS_OUTSTANDING)); viewerOffTrans.refresh(); }
From source file:at.rc.tacos.client.view.PersonalView.java
License:Open Source License
/** * Callback method to create the control and initalize them. * /*from www . j av a2 s . c o m*/ * @param parent * the parent composite to add */ @Override public void createPartControl(final Composite parent) { // Create the scrolled parent component toolkit = new FormToolkit(CustomColors.FORM_COLOR(parent.getDisplay())); form = toolkit.createForm(parent); toolkit.decorateFormHeading(form); form.getBody().setLayout(new FillLayout()); final Composite composite = form.getBody(); // tab folder tabFolder = new TabFolder(composite, SWT.NONE); tabFolder.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { // assert valid if (e.item.getData() == null) return; if (!(e.item.getData() instanceof Location)) return; // remove all location filter for (ViewerFilter filter : viewer.getFilters()) { if (filter instanceof PersonalViewFilter) viewer.removeFilter(filter); } // cast to a location and apply the new filter Location location = (Location) e.item.getData(); viewer.addFilter(new PersonalViewFilter(location)); } }); viewer = new TableViewer(tabFolder, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION); viewer.setContentProvider(new PersonalViewContentProvider()); viewer.setLabelProvider(new PersonalViewLabelProvider()); viewer.setInput(ModelFactory.getInstance().getRosterEntryManager().toArray()); viewer.getTable().setLinesVisible(true); // set the tooltip tooltip = new PersonalTooltip(viewer.getControl()); // show the tooltip when the selection has changed viewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { TableItem[] selection = viewer.getTable().getSelection(); if (selection != null && selection.length > 0) { Rectangle bounds = selection[0].getBounds(); tooltip.show(new Point(bounds.x, bounds.y)); } } }); viewer.getTable().addMouseListener(new MouseAdapter() { public void mouseDown(MouseEvent e) { if (viewer.getTable().getItem(new Point(e.x, e.y)) == null) { viewer.setSelection(new StructuredSelection()); } } }); // sort the table by default viewer.setSorter(new PersonalViewSorter(PersonalViewSorter.NAME_SORTER, SWT.UP)); viewer.addFilter(new PersonalDateFilter(Calendar.getInstance())); // create the table for the roster entries final Table table = viewer.getTable(); table.setLinesVisible(true); table.setHeaderVisible(true); final TableColumn lockColumn = new TableColumn(table, SWT.NONE); lockColumn.setToolTipText("Eintrag wird gerade bearbeitet"); lockColumn.setWidth(24); lockColumn.setText("L"); final TableColumn columnStandby = new TableColumn(table, SWT.NONE); columnStandby.setToolTipText("Mitarbeiter auf Bereitschaft (Symbol, wenn der Fall)"); columnStandby.setWidth(30); columnStandby.setText("B"); final TableColumn columnNotes = new TableColumn(table, SWT.NONE); columnNotes.setToolTipText("Anmerkung (Symbol, wenn Anmerkung vorhanden)"); columnNotes.setWidth(30); columnNotes.setText("A"); final TableColumn columnStaffName = new TableColumn(table, SWT.NONE); columnStaffName.setWidth(130); columnStaffName.setText("Name"); final TableColumn columnWorkTime = new TableColumn(table, SWT.NONE); columnWorkTime.setToolTipText("Dienst lt. Dienstplan"); columnWorkTime.setWidth(120); columnWorkTime.setText("Dienst"); final TableColumn columnCheckin = new TableColumn(table, SWT.NONE); columnCheckin.setToolTipText("Zeit der tatschlichen Anmeldung"); columnCheckin.setWidth(70); columnCheckin.setText("Anm"); final TableColumn columnCheckout = new TableColumn(table, SWT.NONE); columnCheckout.setToolTipText("Zeit der tatschlichen Abmeldung"); columnCheckout.setWidth(70); columnCheckout.setText("Abm"); final TableColumn columnService = new TableColumn(table, SWT.NONE); columnService.setToolTipText("Dienstverhltnis"); columnService.setWidth(90); columnService.setText("DV"); final TableColumn columnJob = new TableColumn(table, SWT.NONE); columnJob.setToolTipText("Verwendung"); columnJob.setWidth(80); columnJob.setText("V"); final TableColumn columnVehicle = new TableColumn(table, SWT.NONE); columnVehicle.setToolTipText("Fahrzeug, dem der Mitarbeiter zugewiesen ist"); columnVehicle.setWidth(55); columnVehicle.setText("Fzg"); // make the columns sortable Listener sortListener = new Listener() { public void handleEvent(Event e) { // determine new sort column and direction TableColumn sortColumn = viewer.getTable().getSortColumn(); TableColumn currentColumn = (TableColumn) e.widget; int dir = viewer.getTable().getSortDirection(); // revert the sortorder if the column is the same if (sortColumn == currentColumn) { if (dir == SWT.UP) dir = SWT.DOWN; else dir = SWT.UP; } else { viewer.getTable().setSortColumn(currentColumn); dir = SWT.UP; } // sort the data based on column and direction String sortIdentifier = null; if (currentColumn == columnStaffName) sortIdentifier = PersonalViewSorter.NAME_SORTER; if (currentColumn == columnWorkTime) sortIdentifier = PersonalViewSorter.WORKTIME_SORTER; if (currentColumn == columnCheckin) sortIdentifier = PersonalViewSorter.CHECKIN_SORTER; if (currentColumn == columnCheckout) sortIdentifier = PersonalViewSorter.CHECKOUT_SORTER; if (currentColumn == columnService) sortIdentifier = PersonalViewSorter.SERVICE_SORTER; if (currentColumn == columnJob) sortIdentifier = PersonalViewSorter.JOB_SORTER; // apply the filter viewer.getTable().setSortDirection(dir); viewer.setSorter(new PersonalViewSorter(sortIdentifier, dir)); } }; // attach the listener columnStaffName.addListener(SWT.Selection, sortListener); columnWorkTime.addListener(SWT.Selection, sortListener); columnCheckin.addListener(SWT.Selection, sortListener); columnCheckout.addListener(SWT.Selection, sortListener); columnService.addListener(SWT.Selection, sortListener); columnJob.addListener(SWT.Selection, sortListener); // create the actions makeActions(); hookContextMenu(); // load the data loadData(); }
From source file:at.rc.tacos.client.view.PrebookingView.java
License:Open Source License
/** * Creates and returns the table viewer. * /*from ww w . j a v a2s.c om*/ * @param parent * the parent composite to insert * @return the created table */ private TableViewer createTableViewer(Composite parent) { final TableViewer viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION); viewer.setContentProvider(new PrebookingViewContentProvider()); viewer.setLabelProvider(new PrebookingViewLabelProvider()); viewer.setInput(ModelFactory.getInstance().getTransportManager().toArray()); viewer.getTable().setLinesVisible(true); viewer.getTable().addMouseListener(new MouseAdapter() { public void mouseDown(MouseEvent e) { if (viewer.getTable().getItem(new Point(e.x, e.y)) == null) { viewer.setSelection(new StructuredSelection()); } } }); final Table table = viewer.getTable(); table.setLinesVisible(true); table.setHeaderVisible(true); final TableColumn blockColumn = new TableColumn(table, SWT.NONE); blockColumn.setToolTipText("Eintrag wird gerade bearbeitet"); blockColumn.setWidth(24); blockColumn.setText("L"); final TableColumn bTableColumnOrtsstelle = new TableColumn(table, SWT.NONE); bTableColumnOrtsstelle.setWidth(30); bTableColumnOrtsstelle.setText("OS"); final TableColumn bTableColumnAbfahrt = new TableColumn(table, SWT.NONE); bTableColumnAbfahrt.setToolTipText("Geplante Abfahrt an der Ortsstelle"); bTableColumnAbfahrt.setWidth(43); bTableColumnAbfahrt.setText("Abf"); final TableColumn bTableColumnAnkunft = new TableColumn(table, SWT.NONE); bTableColumnAnkunft.setToolTipText("Geplante Ankunft beim Patienten"); bTableColumnAnkunft.setWidth(43); bTableColumnAnkunft.setText("Ank"); final TableColumn bTableColumnTermin = new TableColumn(table, SWT.NONE); bTableColumnTermin.setToolTipText("Termin am Zielort"); bTableColumnTermin.setWidth(43); bTableColumnTermin.setText("Termin"); final TableColumn bTableColumnTransportVon = new TableColumn(table, SWT.NONE); bTableColumnTransportVon.setWidth(188); bTableColumnTransportVon.setText("Transport von"); final TableColumn bTtableColumnPatient = new TableColumn(table, SWT.NONE); bTtableColumnPatient.setWidth(160); bTtableColumnPatient.setText("Patient"); final TableColumn bTableColumnTransportNach = new TableColumn(table, SWT.NONE); bTableColumnTransportNach.setWidth(188); bTableColumnTransportNach.setText("Transport nach"); final TableColumn bTableColumnTA = new TableColumn(table, SWT.NONE); bTableColumnTA.setToolTipText("Transportart"); bTableColumnTA.setWidth(23); bTableColumnTA.setText("T"); final TableColumn anmerkungTransporte = new TableColumn(table, SWT.NONE); anmerkungTransporte.setWidth(66); anmerkungTransporte.setText("Anmerkung"); Listener sortListener = new Listener() { public void handleEvent(Event e) { // determine new sort column and direction TableColumn sortColumn = viewer.getTable().getSortColumn(); TableColumn currentColumn = (TableColumn) e.widget; int dir = viewer.getTable().getSortDirection(); // revert the sort order if the column is the same if (sortColumn == currentColumn) { if (dir == SWT.UP) dir = SWT.DOWN; else dir = SWT.UP; } else { viewer.getTable().setSortColumn(currentColumn); dir = SWT.UP; } // sort the data based on column and direction String sortIdentifier = null; if (currentColumn == bTableColumnOrtsstelle) sortIdentifier = TransportSorter.RESP_STATION_SORTER; if (currentColumn == bTableColumnAbfahrt) sortIdentifier = TransportSorter.ABF_SORTER; if (currentColumn == bTableColumnAnkunft) sortIdentifier = TransportSorter.AT_PATIENT_SORTER; if (currentColumn == bTableColumnTermin) sortIdentifier = TransportSorter.TERM_SORTER; if (currentColumn == bTableColumnTransportVon) sortIdentifier = TransportSorter.TRANSPORT_FROM_SORTER; if (currentColumn == bTtableColumnPatient) sortIdentifier = TransportSorter.PATIENT_SORTER; if (currentColumn == bTableColumnTransportNach) sortIdentifier = TransportSorter.TRANSPORT_TO_SORTER; if (currentColumn == bTableColumnTA) sortIdentifier = TransportSorter.TA_SORTER; if (currentColumn == anmerkungTransporte) sortIdentifier = TransportSorter.NOTES_SORTER; // apply the filter viewer.getTable().setSortDirection(dir); viewer.setSorter(new TransportSorter(sortIdentifier, dir)); } }; // attach the listener bTableColumnOrtsstelle.addListener(SWT.Selection, sortListener); bTableColumnAbfahrt.addListener(SWT.Selection, sortListener); bTableColumnAnkunft.addListener(SWT.Selection, sortListener); bTableColumnTermin.addListener(SWT.Selection, sortListener); bTableColumnTransportVon.addListener(SWT.Selection, sortListener); bTtableColumnPatient.addListener(SWT.Selection, sortListener); bTableColumnTransportNach.addListener(SWT.Selection, sortListener); bTableColumnTA.addListener(SWT.Selection, sortListener); anmerkungTransporte.addListener(SWT.Selection, sortListener); return viewer; }
From source file:at.rc.tacos.client.view.TransportForm.java
License:Open Source License
private void createAssignCarTable() { viewerAssign = new TableViewer(assignCarGroup, SWT.VIRTUAL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION); assignVehicleContentProvider = new AssignVehicleContentProvider(); viewerAssign.setContentProvider(assignVehicleContentProvider); viewerAssign.setLabelProvider(new VehicleAssignLabelProvider()); viewerAssign.setInput(ModelFactory.getInstance().getVehicleManager().getReadyVehicleList()); final Table table_1 = viewerAssign.getTable(); final FormData fd_table_1 = new FormData(); fd_table_1.right = new FormAttachment(0, 824); fd_table_1.left = new FormAttachment(0, 3); fd_table_1.top = new FormAttachment(0, 1); fd_table_1.bottom = new FormAttachment(0, 122); table_1.setLayoutData(fd_table_1);/*from w w w . j a v a2s . c om*/ viewerAssign.getTable().addMouseListener(new MouseAdapter() { public void mouseDown(MouseEvent e) { if (viewerAssign.getTable().getItem(new Point(e.x, e.y)) == null) { viewerAssign.setSelection(new StructuredSelection()); } } }); final Table table = viewerAssign.getTable(); table.setLinesVisible(true); table.setHeaderVisible(true); final TableColumn stationColumn = new TableColumn(table, SWT.NONE); stationColumn.setToolTipText("Aktuelle Dienststelle des Fahrzeuges"); stationColumn.setWidth(30); stationColumn.setText("Dienststelle"); final TableColumn nameColumn = new TableColumn(table, SWT.NONE); nameColumn.setToolTipText("Fahrzeug"); nameColumn.setWidth(60); nameColumn.setText("Fahrzeug"); final TableColumn typeColumn = new TableColumn(table, SWT.NONE); typeColumn.setWidth(60); typeColumn.setText("Fahrzeugtyp"); final TableColumn driverColumn = new TableColumn(table, SWT.NONE); driverColumn.setToolTipText("Fahrer"); driverColumn.setWidth(100); driverColumn.setText("Fahrer"); final TableColumn medicIColumn = new TableColumn(table, SWT.NONE); medicIColumn.setToolTipText("Sanitter I"); medicIColumn.setWidth(100); medicIColumn.setText("Sanitter I"); final TableColumn medicIIColumn = new TableColumn(table, SWT.NONE); medicIIColumn.setToolTipText("Sanitter II"); medicIIColumn.setWidth(100); medicIIColumn.setText("Sanitter II"); Listener sortListener = new Listener() { public void handleEvent(Event e) { // determine new sort column and direction TableColumn sortColumn = viewerAssign.getTable().getSortColumn(); TableColumn currentColumn = (TableColumn) e.widget; int dir = viewerAssign.getTable().getSortDirection(); // revert the sort order if the column is the same if (sortColumn == currentColumn) { if (dir == SWT.UP) dir = SWT.DOWN; else dir = SWT.UP; } else { viewerAssign.getTable().setSortColumn(currentColumn); dir = SWT.UP; } // sort the data based on column and direction String sortIdentifier = null; if (currentColumn == stationColumn) sortIdentifier = VehicleSorter.CURRENT_STATION_SORTER; if (currentColumn == nameColumn) sortIdentifier = VehicleSorter.VEHICLE_SORTER; if (currentColumn == typeColumn) sortIdentifier = VehicleSorter.VEHICLE_TYPE_SORTER; if (currentColumn == driverColumn) sortIdentifier = VehicleSorter.DRIVER_SORTER; if (currentColumn == medicIColumn) sortIdentifier = VehicleSorter.PARAMEDIC_I_SORTER; if (currentColumn == medicIIColumn) sortIdentifier = VehicleSorter.PARAMEDIC_II_SORTER; // apply the filter viewerAssign.getTable().setSortDirection(dir); viewerAssign.setSorter(new VehicleSorter(sortIdentifier, dir)); viewerAssign.refresh(); } }; // attach the listener stationColumn.addListener(SWT.Selection, sortListener); nameColumn.addListener(SWT.Selection, sortListener); typeColumn.addListener(SWT.Selection, sortListener); driverColumn.addListener(SWT.Selection, sortListener); medicIColumn.addListener(SWT.Selection, sortListener); medicIIColumn.addListener(SWT.Selection, sortListener); viewerAssign.refresh(); }
From source file:at.rc.tacos.client.view.TransportForm.java
License:Open Source License
private void createMultiTransportTable() { viewer = new TableViewer(multiTransportGroup, SWT.VIRTUAL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION); final Table table_1 = viewer.getTable(); final FormData fd_table_1 = new FormData(); fd_table_1.right = new FormAttachment(0, 824); fd_table_1.left = new FormAttachment(0, 3); fd_table_1.top = new FormAttachment(0, 1); fd_table_1.bottom = new FormAttachment(0, 122); table_1.setLayoutData(fd_table_1);//from www . j a v a 2 s . c o m viewer.setContentProvider(multiTransportProvider); viewer.setLabelProvider(new MultiTransportLabelProvider()); viewer.setInput(ModelFactory.getInstance().getTransportManager().toArray()); viewer.refresh(); viewer.getTable().addMouseListener(new MouseAdapter() { public void mouseDown(MouseEvent e) { if (viewer.getTable().getItem(new Point(e.x, e.y)) == null) { viewer.setSelection(new StructuredSelection()); } } }); final Table table = viewer.getTable(); table.setLinesVisible(true); table.setHeaderVisible(true); final TableColumn dateColumn = new TableColumn(table, SWT.NONE); dateColumn.setToolTipText("Transportdatum"); dateColumn.setWidth(65); dateColumn.setText("Datum"); final TableColumn bTableColumnOrtsstelle = new TableColumn(table, SWT.NONE); bTableColumnOrtsstelle.setWidth(27); bTableColumnOrtsstelle.setText("OS"); final TableColumn bTableColumnAbfahrt = new TableColumn(table, SWT.NONE); bTableColumnAbfahrt.setToolTipText("Geplante Abfahrt an der Ortsstelle"); bTableColumnAbfahrt.setWidth(40); bTableColumnAbfahrt.setText("Abf"); final TableColumn bTableColumnAnkunft = new TableColumn(table, SWT.NONE); bTableColumnAnkunft.setToolTipText("Geplante Ankunft beim Patienten"); bTableColumnAnkunft.setWidth(40); bTableColumnAnkunft.setText("Ank"); final TableColumn bTableColumnTermin = new TableColumn(table, SWT.NONE); bTableColumnTermin.setToolTipText("Termin am Zielort"); bTableColumnTermin.setWidth(40); bTableColumnTermin.setText("Termin"); final TableColumn bTableColumnTransportVon = new TableColumn(table, SWT.NONE); bTableColumnTransportVon.setWidth(200); bTableColumnTransportVon.setText("Transport von"); final TableColumn bTtableColumnPatient = new TableColumn(table, SWT.NONE); bTtableColumnPatient.setWidth(170); bTtableColumnPatient.setText("Patient"); final TableColumn bTableColumnTransportNach = new TableColumn(table, SWT.NONE); bTableColumnTransportNach.setWidth(200); bTableColumnTransportNach.setText("Transport nach"); final TableColumn bTableColumnTA = new TableColumn(table, SWT.NONE); bTableColumnTA.setToolTipText("Transportart"); bTableColumnTA.setWidth(20); bTableColumnTA.setText("T"); Listener sortListener = new Listener() { public void handleEvent(Event e) { // determine new sort column and direction TableColumn sortColumn = viewer.getTable().getSortColumn(); TableColumn currentColumn = (TableColumn) e.widget; int dir = viewer.getTable().getSortDirection(); // revert the sort order if the column is the same if (sortColumn == currentColumn) { if (dir == SWT.UP) dir = SWT.DOWN; else dir = SWT.UP; } else { viewer.getTable().setSortColumn(currentColumn); dir = SWT.UP; } // sort the data based on column and direction String sortIdentifier = null; if (currentColumn == bTableColumnOrtsstelle) sortIdentifier = TransportSorter.RESP_STATION_SORTER; if (currentColumn == bTableColumnAbfahrt) sortIdentifier = TransportSorter.ABF_SORTER; if (currentColumn == bTableColumnAnkunft) sortIdentifier = TransportSorter.AT_PATIENT_SORTER; if (currentColumn == bTableColumnTermin) sortIdentifier = TransportSorter.TERM_SORTER; if (currentColumn == bTableColumnTransportVon) sortIdentifier = TransportSorter.TRANSPORT_FROM_SORTER; if (currentColumn == bTtableColumnPatient) sortIdentifier = TransportSorter.PATIENT_SORTER; if (currentColumn == bTableColumnTransportNach) sortIdentifier = TransportSorter.TRANSPORT_TO_SORTER; if (currentColumn == bTableColumnTA) sortIdentifier = TransportSorter.TA_SORTER; // apply the filter viewer.getTable().setSortDirection(dir); viewer.setSorter(new TransportSorter(sortIdentifier, dir)); viewer.refresh(); } }; // attach the listener bTableColumnOrtsstelle.addListener(SWT.Selection, sortListener); bTableColumnAbfahrt.addListener(SWT.Selection, sortListener); bTableColumnAnkunft.addListener(SWT.Selection, sortListener); bTableColumnTermin.addListener(SWT.Selection, sortListener); bTableColumnTransportVon.addListener(SWT.Selection, sortListener); bTtableColumnPatient.addListener(SWT.Selection, sortListener); bTableColumnTransportNach.addListener(SWT.Selection, sortListener); bTableColumnTA.addListener(SWT.Selection, sortListener); hookContextMenu(); viewer.refresh(); }
From source file:at.rc.tacos.client.view.UnderwayTransportsView.java
License:Open Source License
/** * Call back method to create the control and initialize them Create * contents of the window//from w ww .jav a 2 s.c o m */ @Override public void createPartControl(final Composite parent) { // Create the scrolled parent component toolkit = new FormToolkit(CustomColors.FORM_COLOR(parent.getDisplay())); formDisp = toolkit.createForm(parent); formDisp.setText("Disponierte Transporte"); toolkit.decorateFormHeading(formDisp); formDisp.getBody().setLayout(new FillLayout()); final Composite composite = formDisp.getBody(); SashForm sashForm = new SashForm(composite, SWT.VERTICAL); viewer = new TableViewer(sashForm, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION); viewer.setContentProvider(new UnderwayTransportsViewContentProvider()); viewer.setLabelProvider(new UnderwayTransportsViewLabelProvider()); viewer.setInput(ModelFactory.getInstance().getTransportManager().toArray()); viewer.getTable().setLinesVisible(true); // integrate the outstandings transports view OutstandingTransportsView outstandingView = new OutstandingTransportsView(); outstandingView.createPartControl(sashForm); viewer.refresh(); viewer.getTable().addMouseListener(new MouseAdapter() { public void mouseDown(MouseEvent e) { if (viewer.getTable().getItem(new Point(e.x, e.y)) == null) { viewer.setSelection(new StructuredSelection()); } } }); // set a default sorter viewer.setSorter(new TransportSorter(TransportSorter.PRIORITY_SORTER, SWT.UP)); final Table tableDisp = viewer.getTable(); tableDisp.setLinesVisible(true); tableDisp.setHeaderVisible(true); final TableColumn lockColumn = new TableColumn(tableDisp, SWT.NONE); lockColumn.setToolTipText("Eintrag wird gerade bearbeitet"); lockColumn.setWidth(24); lockColumn.setText("L"); // create the tab items for the disposition view final TableColumn prioritaetDisponierteTransporte = new TableColumn(tableDisp, SWT.NONE); prioritaetDisponierteTransporte.setToolTipText( "1 (NEF), 2 (BD1), 3 (Transport), 4 (Rcktransport), 5 (Heimtransport), 6 (Sonstiges), 7 (NEF extern)"); prioritaetDisponierteTransporte.setWidth(26); prioritaetDisponierteTransporte.setText("Pr"); final TableColumn transportNummerDisponierteTransporte = new TableColumn(tableDisp, SWT.NONE); transportNummerDisponierteTransporte.setToolTipText("Ortsstellenabhngige Transportnummer"); transportNummerDisponierteTransporte.setMoveable(true); transportNummerDisponierteTransporte.setWidth(70); transportNummerDisponierteTransporte.setText("TNr"); final TableColumn terminDisponierteTransporte = new TableColumn(tableDisp, SWT.NONE); terminDisponierteTransporte.setToolTipText("Termin am Zielort"); terminDisponierteTransporte.setMoveable(true); terminDisponierteTransporte.setWidth(43); terminDisponierteTransporte.setText("Termin"); final TableColumn transportVonDisponierteTransporte = new TableColumn(tableDisp, SWT.NONE); transportVonDisponierteTransporte.setMoveable(true); transportVonDisponierteTransporte.setWidth(250); transportVonDisponierteTransporte.setText("Transport von"); final TableColumn patientDisponierteTransporte = new TableColumn(tableDisp, SWT.NONE); patientDisponierteTransporte.setMoveable(true); patientDisponierteTransporte.setWidth(200); patientDisponierteTransporte.setText("Patient"); final TableColumn transportNachDisponierteTransporte = new TableColumn(tableDisp, SWT.NONE); transportNachDisponierteTransporte.setWidth(250); transportNachDisponierteTransporte.setText("Transport nach"); final TableColumn aeDisponierteTransporte = new TableColumn(tableDisp, SWT.NONE); aeDisponierteTransporte.setToolTipText("Auftrag erteilt"); aeDisponierteTransporte.setWidth(43); aeDisponierteTransporte.setText("AE"); final TableColumn s1DisponierteTransporte = new TableColumn(tableDisp, SWT.NONE); s1DisponierteTransporte.setToolTipText("Transportbeginn"); s1DisponierteTransporte.setWidth(43); s1DisponierteTransporte.setText("S1"); final TableColumn s2DisponierteTransporte = new TableColumn(tableDisp, SWT.NONE); s2DisponierteTransporte.setToolTipText("Ankunft bei Patient"); s2DisponierteTransporte.setWidth(43); s2DisponierteTransporte.setText("S2"); final TableColumn s3DisponierteTransporte = new TableColumn(tableDisp, SWT.NONE); s3DisponierteTransporte.setToolTipText("Abfahrt mit Patient"); s3DisponierteTransporte.setWidth(43); s3DisponierteTransporte.setText("S3"); final TableColumn s4DisponierteTransporte = new TableColumn(tableDisp, SWT.NONE); s4DisponierteTransporte.setToolTipText("Ankunft Ziel"); s4DisponierteTransporte.setWidth(43); s4DisponierteTransporte.setText("S4"); final TableColumn fzgDisponierteTransporte = new TableColumn(tableDisp, SWT.NONE); fzgDisponierteTransporte.setToolTipText("Fahrzeugkennzeichnung"); fzgDisponierteTransporte.setWidth(60); fzgDisponierteTransporte.setText("Fzg"); final TableColumn taDisponierteTransporte = new TableColumn(tableDisp, SWT.NONE); taDisponierteTransporte.setToolTipText("Transportart"); taDisponierteTransporte.setWidth(22); taDisponierteTransporte.setText("T"); final TableColumn erkrankungVerletzungDisponierteTransporte = new TableColumn(tableDisp, SWT.NONE); erkrankungVerletzungDisponierteTransporte.setWidth(200); erkrankungVerletzungDisponierteTransporte.setText("Erkrankung/Verletzung"); final TableColumn anmerkungUnderwayTransporte = new TableColumn(tableDisp, SWT.NONE); anmerkungUnderwayTransporte.setWidth(312); anmerkungUnderwayTransporte.setText("Anmerkung"); /** make columns sort able */ Listener sortListener = new Listener() { public void handleEvent(Event e) { // determine new sort column and direction TableColumn sortColumn = viewer.getTable().getSortColumn(); TableColumn currentColumn = (TableColumn) e.widget; int dir = viewer.getTable().getSortDirection(); // revert the sort order if the column is the same if (sortColumn == currentColumn) { if (dir == SWT.UP) dir = SWT.DOWN; else dir = SWT.UP; } else { viewer.getTable().setSortColumn(currentColumn); dir = SWT.UP; } // sort the data based on column and direction String sortIdentifier = null; if (currentColumn == prioritaetDisponierteTransporte) sortIdentifier = TransportSorter.PRIORITY_SORTER; if (currentColumn == transportNummerDisponierteTransporte) sortIdentifier = TransportSorter.TNR_SORTER; if (currentColumn == fzgDisponierteTransporte) sortIdentifier = TransportSorter.VEHICLE_SORTER; if (currentColumn == terminDisponierteTransporte) sortIdentifier = TransportSorter.TERM_SORTER; if (currentColumn == transportVonDisponierteTransporte) sortIdentifier = TransportSorter.TRANSPORT_FROM_SORTER; if (currentColumn == patientDisponierteTransporte) sortIdentifier = TransportSorter.PATIENT_SORTER; if (currentColumn == transportNachDisponierteTransporte) sortIdentifier = TransportSorter.TRANSPORT_TO_SORTER; if (currentColumn == taDisponierteTransporte) sortIdentifier = TransportSorter.TA_SORTER; if (currentColumn == aeDisponierteTransporte) sortIdentifier = TransportSorter.AE_SORTER; if (currentColumn == s1DisponierteTransporte) sortIdentifier = TransportSorter.S1_SORTER; if (currentColumn == s2DisponierteTransporte) sortIdentifier = TransportSorter.S2_SORTER; if (currentColumn == s3DisponierteTransporte) sortIdentifier = TransportSorter.S3_SORTER; if (currentColumn == s4DisponierteTransporte) sortIdentifier = TransportSorter.S4_SORTER; if (currentColumn == erkrankungVerletzungDisponierteTransporte) sortIdentifier = TransportSorter.KIND_OF_ILLNESS_SORTER; if (currentColumn == anmerkungUnderwayTransporte) sortIdentifier = TransportSorter.NOTES_SORTER; // apply the filter viewer.getTable().setSortDirection(dir); viewer.setSorter(new TransportSorter(sortIdentifier, dir)); } }; // attach the listener prioritaetDisponierteTransporte.addListener(SWT.Selection, sortListener); transportNummerDisponierteTransporte.addListener(SWT.Selection, sortListener); fzgDisponierteTransporte.addListener(SWT.Selection, sortListener); terminDisponierteTransporte.addListener(SWT.Selection, sortListener); transportVonDisponierteTransporte.addListener(SWT.Selection, sortListener); patientDisponierteTransporte.addListener(SWT.Selection, sortListener); transportNachDisponierteTransporte.addListener(SWT.Selection, sortListener); taDisponierteTransporte.addListener(SWT.Selection, sortListener); aeDisponierteTransporte.addListener(SWT.Selection, sortListener); s1DisponierteTransporte.addListener(SWT.Selection, sortListener); s2DisponierteTransporte.addListener(SWT.Selection, sortListener); s3DisponierteTransporte.addListener(SWT.Selection, sortListener); s4DisponierteTransporte.addListener(SWT.Selection, sortListener); erkrankungVerletzungDisponierteTransporte.addListener(SWT.Selection, sortListener); anmerkungUnderwayTransporte.addListener(SWT.Selection, sortListener); // create the actions makeActions(); hookContextMenu(); viewer.addFilter(new TransportStateViewFilter(PROGRAM_STATUS_UNDERWAY)); viewer.refresh(); }
From source file:at.rc.tacos.client.view.VehiclesViewTable.java
License:Open Source License
/** * Callback method to create the control and initalize them. * //from w w w .j ava 2 s. c o m * @param parent * the parent composite to add */ @Override public void createPartControl(final Composite parent) { // Create the scrolled parent component toolkit = new FormToolkit(CustomColors.FORM_COLOR(parent.getDisplay())); form = toolkit.createForm(parent); toolkit.decorateFormHeading(form); form.getBody().setLayout(new FillLayout()); final Composite composite = form.getBody(); viewer = new TableViewer(composite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION); viewer.setContentProvider(new VehicleContentProvider()); viewer.setLabelProvider(new VehicleViewTableLabelProvider()); viewer.setInput(ModelFactory.getInstance().getVehicleManager().toArray()); viewer.getTable().setLinesVisible(true); viewer.refresh(); // set the tooltip tooltip = new VehicleTooltip(viewer.getControl()); // show the tooltip when the selection has changed viewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { TableItem[] selection = viewer.getTable().getSelection(); if (selection != null && selection.length > 0) { Rectangle bounds = selection[0].getBounds(); tooltip.show(new Point(bounds.x, bounds.y)); } } }); viewer.getTable().addMouseListener(new MouseAdapter() { public void mouseDown(MouseEvent e) { if (viewer.getTable().getItem(new Point(e.x, e.y)) == null) { viewer.setSelection(new StructuredSelection()); } } }); // sort the table by default viewer.setSorter(new VehicleViewTableSorter(VehicleViewTableSorter.VEHICLE_SORTER, SWT.UP)); // create the table for the vehicles final Table table = viewer.getTable(); table.setLinesVisible(true); table.setHeaderVisible(true); final TableColumn columnLock = new TableColumn(table, SWT.NONE); columnLock.setToolTipText("Gesperrt"); columnLock.setWidth(24); columnLock.setText("L"); final TableColumn columnVehicleName = new TableColumn(table, SWT.NONE); columnVehicleName.setToolTipText("Fahrzeugname"); columnVehicleName.setWidth(60); final TableColumn columnVehicleStatus = new TableColumn(table, SWT.NONE); columnVehicleStatus.setToolTipText("Verfgbarkeit des Fahrzeuges"); columnVehicleStatus.setWidth(50); // make the columns sortable Listener sortListener = new Listener() { public void handleEvent(Event e) { // determine new sort column and direction TableColumn sortColumn = viewer.getTable().getSortColumn(); TableColumn currentColumn = (TableColumn) e.widget; int dir = viewer.getTable().getSortDirection(); // revert the sortorder if the column is the same if (sortColumn == currentColumn) { if (dir == SWT.UP) dir = SWT.DOWN; else dir = SWT.UP; } else { viewer.getTable().setSortColumn(currentColumn); dir = SWT.UP; } // sort the data based on column and direction String sortIdentifier = null; if (currentColumn == columnVehicleStatus) sortIdentifier = VehicleViewTableSorter.STATUS_SORTER; if (currentColumn == columnVehicleName) sortIdentifier = VehicleViewTableSorter.VEHICLE_SORTER; // apply the filter viewer.getTable().setSortDirection(dir); viewer.setSorter(new VehicleViewTableSorter(sortIdentifier, dir)); } }; // attach the listener columnVehicleName.addListener(SWT.Selection, sortListener); columnVehicleStatus.addListener(SWT.Selection, sortListener); // create the actions makeActions(); hookContextMenu(); viewer.refresh(); }
From source file:at.rc.tacos.client.view.VehiclesViewTableDetailed.java
License:Open Source License
/** * Callback method to create the control and initalize them. * /*from w ww.ja v a 2 s .c om*/ * @param parent * the parent composite to add */ @Override public void createPartControl(final Composite parent) { // Create the scrolled parent component toolkit = new FormToolkit(CustomColors.FORM_COLOR(parent.getDisplay())); form = toolkit.createForm(parent); toolkit.decorateFormHeading(form); form.getBody().setLayout(new FillLayout()); final Composite composite = form.getBody(); viewer = new TableViewer(composite, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION); viewer.setContentProvider(new VehicleContentProvider()); viewer.setLabelProvider(new VehicleViewTableDetailLabelProvider()); viewer.setInput(ModelFactory.getInstance().getVehicleManager().toArray()); viewer.getTable().setLinesVisible(true); viewer.refresh(); viewer.getTable().addMouseListener(new MouseAdapter() { public void mouseDown(MouseEvent e) { if (viewer.getTable().getItem(new Point(e.x, e.y)) == null) { viewer.setSelection(new StructuredSelection()); } } }); // sort the table by default viewer.setSorter(new VehicleViewTableSorter(VehicleViewTableSorter.VEHICLE_SORTER, SWT.UP)); // create the table for the vehicles final Table table = viewer.getTable(); table.setLinesVisible(true); table.setHeaderVisible(true); final TableColumn columnLock = new TableColumn(table, SWT.NONE); columnLock.setToolTipText("Gesperrt"); columnLock.setWidth(24); columnLock.setText("L"); final TableColumn columnReady = new TableColumn(table, SWT.NONE); columnReady.setToolTipText("Einsatzbereit"); columnReady.setWidth(20); columnReady.setText("EB"); final TableColumn columnVehicleName = new TableColumn(table, SWT.NONE); columnVehicleName.setToolTipText("Fahrzeugname"); columnVehicleName.setWidth(45); final TableColumn columnVehicleStatus = new TableColumn(table, SWT.NONE); columnVehicleStatus.setToolTipText("Verfgbarkeit des Fahrzeuges"); columnVehicleStatus.setWidth(20); final TableColumn columnDriver = new TableColumn(table, SWT.NONE); columnDriver.setToolTipText("Fahrer"); columnDriver.setWidth(100); columnDriver.setText("Fahrer"); final TableColumn columnMedicI = new TableColumn(table, SWT.NONE); columnMedicI.setToolTipText("Sanitter I"); columnMedicI.setWidth(100); columnMedicI.setText("Sanitter I"); final TableColumn columnMedicII = new TableColumn(table, SWT.NONE); columnMedicII.setToolTipText("Sanitter"); columnMedicII.setWidth(100); columnMedicII.setText("Sanitter II"); final TableColumn columnPhone = new TableColumn(table, SWT.NONE); columnPhone.setToolTipText("Anderes als primres Handy"); columnPhone.setWidth(18); final TableColumn columnStation = new TableColumn(table, SWT.NONE); columnStation.setToolTipText("Andere als primres Ortsstelle"); columnStation.setWidth(18); final TableColumn columnOutOfOrder = new TableColumn(table, SWT.NONE); columnOutOfOrder.setToolTipText("Fahrzeug ist auer Dienst"); columnOutOfOrder.setWidth(18); final TableColumn columnNotes = new TableColumn(table, SWT.NONE); columnNotes.setToolTipText("Notizen zum Fahrzeug vorhanden"); columnNotes.setWidth(18); final TableColumn columnLastDestinationFree = new TableColumn(table, SWT.NONE); columnLastDestinationFree.setToolTipText("Zeigt den Standort der letzten Meldung \"Ziel frei\" (S6)an"); columnLastDestinationFree.setWidth(226); columnLastDestinationFree.setText("Letzter Status S5"); // make the columns sortable Listener sortListener = new Listener() { public void handleEvent(Event e) { // determine new sort column and direction TableColumn sortColumn = viewer.getTable().getSortColumn(); TableColumn currentColumn = (TableColumn) e.widget; int dir = viewer.getTable().getSortDirection(); // revert the sortorder if the column is the same if (sortColumn == currentColumn) { if (dir == SWT.UP) dir = SWT.DOWN; else dir = SWT.UP; } else { viewer.getTable().setSortColumn(currentColumn); dir = SWT.UP; } // sort the data based on column and direction String sortIdentifier = null; if (currentColumn == columnVehicleStatus) sortIdentifier = VehicleViewTableSorter.STATUS_SORTER; if (currentColumn == columnVehicleName) sortIdentifier = VehicleViewTableSorter.VEHICLE_SORTER; if (currentColumn == columnDriver) sortIdentifier = VehicleViewTableSorter.DRIVER_SORTER; if (currentColumn == columnMedicI) sortIdentifier = VehicleViewTableSorter.PARAMEDIC_I_SORTER; if (currentColumn == columnMedicII) sortIdentifier = VehicleViewTableSorter.PARAMEDIC_II_SORTER; if (currentColumn == columnNotes) sortIdentifier = VehicleViewTableSorter.NOTES_SORTER; if (currentColumn == columnLastDestinationFree) sortIdentifier = VehicleViewTableSorter.LDF_SORTER; // apply the filter viewer.getTable().setSortDirection(dir); viewer.setSorter(new VehicleViewTableSorter(sortIdentifier, dir)); } }; // attach the listener columnVehicleName.addListener(SWT.Selection, sortListener); columnVehicleStatus.addListener(SWT.Selection, sortListener); columnDriver.addListener(SWT.Selection, sortListener); columnMedicI.addListener(SWT.Selection, sortListener); columnMedicII.addListener(SWT.Selection, sortListener); columnNotes.addListener(SWT.Selection, sortListener); columnLastDestinationFree.addListener(SWT.Selection, sortListener); // create the actions makeActions(); hookContextMenu(); viewer.refresh(); }