List of usage examples for org.eclipse.jface.viewers StructuredSelection StructuredSelection
public StructuredSelection(List elements)
List
. From source file:at.rc.tacos.client.view.RosterEntryForm.java
License:Open Source License
/** * Create contents of the window/*from www.ja v a 2 s .co m*/ */ @Override protected Control createDialogArea(Composite parent) { // setup the composite Composite composite = (Composite) super.createDialogArea(parent); GridLayout layout = new GridLayout(); layout.horizontalSpacing = 30; layout.verticalSpacing = 10; composite.setLayout(layout); composite.setBackground(CustomColors.SECTION_BACKGROUND); toolkit = new FormToolkit(CustomColors.FORM_COLOR(parent.getDisplay())); // create the content of the dialog createGeneralSection(composite); createPlaningSection(composite); createSignSection(composite); // init data if (rosterEntry != null) { Calendar cal = Calendar.getInstance(); // check in if (rosterEntry.getRealStartOfWork() != 0) { cal.setTimeInMillis(rosterEntry.getRealStartOfWork()); anmeldung.setDate(cal); } // check out if (rosterEntry.getRealEndOfWork() != 0) { cal = Calendar.getInstance(); cal.setTimeInMillis(rosterEntry.getRealEndOfWork()); abmeldung.setDate(cal); } // planned start of work cal = Calendar.getInstance(); cal.setTimeInMillis(rosterEntry.getPlannedStartOfWork()); dienstVon.setDate(cal); // planned end of work cal = Calendar.getInstance(); cal.setTimeInMillis(rosterEntry.getPlannedEndOfWork()); dienstBis.setDate(cal); // other fields if (rosterEntry.getRosterNotes() != null) noteEditor.getDocument().set(rosterEntry.getRosterNotes()); this.comboDienstverhaeltnis.setSelection(new StructuredSelection(rosterEntry.getServicetype())); this.comboVerwendung.setSelection(new StructuredSelection(rosterEntry.getJob())); this.comboOrtsstelle.setSelection(new StructuredSelection(rosterEntry.getStation())); this.bereitschaftButton.setSelection(rosterEntry.getStandby()); this.employeenameCombo.setSelection(new StructuredSelection(rosterEntry.getStaffMember())); } return composite; }
From source file:at.rc.tacos.client.view.TransportForm.java
License:Open Source License
/** * Create contents of the window//from www .ja va 2s . com */ @Override protected Control createDialogArea(Composite parent) { // setup the composite Composite composite = (Composite) super.createDialogArea(parent); setShellStyle(SWT.SYSTEM_MODAL); // Create the content of the dialog createTransportSection(composite); // disable some buttons if (transportType.equalsIgnoreCase("emergencyTransport")) { buttonMehrfachtransport.setEnabled(false); buttonAssignCar.setEnabled(true); } if (transportType.equalsIgnoreCase("prebooking")) buttonAssignCar.setEnabled(false); // do not allow editing longer than 4 days after the transport if (transportType.equalsIgnoreCase("both")) { Calendar fourDaysAgo = Calendar.getInstance(); fourDaysAgo.set(Calendar.DAY_OF_YEAR, fourDaysAgo.get(Calendar.DAY_OF_YEAR) - 4); Calendar transportDate = Calendar.getInstance(); transportDate.setTimeInMillis(transport.getDateOfTransport()); if (transportDate.getTimeInMillis() < fourDaysAgo.getTimeInMillis()) { composite.setEnabled(false); } } // Simple date format for the alarming timestamps SimpleDateFormat sdf_dateTime = new SimpleDateFormat("dd.MM.yy HH:mm"); // init data if (!createNew) { // changing transport type only possible for a new transport buttonVormerkung.setEnabled(false); buttonNotfall.setEnabled(false); buttonDialyse.setEnabled(false); buttonMehrfachtransport.setVisible(false); buttonADDMehrfachtransport.setVisible(false); buttonAssignCar.setVisible(false); // set field contents GregorianCalendar gcal = new GregorianCalendar(); gcal.setTimeZone(TimeZone.getDefault()); // formatter for the date and time SimpleDateFormat sdf = new SimpleDateFormat("HH:mm"); Calendar cal = Calendar.getInstance(); // date of transport gcal.setTimeInMillis(transport.getDateOfTransport()); this.dateTime.setDay(gcal.get(GregorianCalendar.DATE)); this.dateTime.setMonth(gcal.get(GregorianCalendar.MONTH)); this.dateTime.setYear(gcal.get(GregorianCalendar.YEAR)); // planned start of transport if (transport.getPlannedStartOfTransport() != 0) { gcal.setTimeInMillis(transport.getPlannedStartOfTransport()); String abfahrtTime = (gcal.get(GregorianCalendar.HOUR_OF_DAY) <= 9 ? "0" : "") + gcal.get(GregorianCalendar.HOUR_OF_DAY) + ":" + ((gcal.get(GregorianCalendar.MINUTE) <= 9 ? "0" : "") + gcal.get(GregorianCalendar.MINUTE)); this.textAbf.setText(abfahrtTime); } // time at patient if (transport.getPlannedTimeAtPatient() != 0) { gcal.setTimeInMillis(transport.getPlannedTimeAtPatient()); String beiPatientTime = (gcal.get(GregorianCalendar.HOUR_OF_DAY) <= 9 ? "0" : "") + gcal.get(GregorianCalendar.HOUR_OF_DAY) + ":" + ((gcal.get(GregorianCalendar.MINUTE) <= 9 ? "0" : "") + gcal.get(GregorianCalendar.MINUTE)); this.textBeiPat.setText(beiPatientTime); } // time at destination if (transport.getAppointmentTimeAtDestination() != 0) { gcal.setTimeInMillis(transport.getAppointmentTimeAtDestination()); String terminTime = (gcal.get(GregorianCalendar.HOUR_OF_DAY) <= 9 ? "0" : "") + gcal.get(GregorianCalendar.HOUR_OF_DAY) + ":" + ((gcal.get(GregorianCalendar.MINUTE) <= 9 ? "0" : "") + gcal.get(GregorianCalendar.MINUTE)); this.textTermin.setText(terminTime); } // transport stati if (transport.getStatusMessages() != null) { if (transport.getStatusMessages().containsKey(ITransportStatus.TRANSPORT_STATUS_ORDER_PLACED)) { cal.setTimeInMillis( transport.getStatusMessages().get(ITransportStatus.TRANSPORT_STATUS_ORDER_PLACED)); this.textAE.setText(sdf.format(cal.getTime())); } // Status 0 if (transport.getStatusMessages().containsKey(ITransportStatus.TRANSPORT_STATUS_ON_THE_WAY)) { cal.setTimeInMillis( transport.getStatusMessages().get(ITransportStatus.TRANSPORT_STATUS_ON_THE_WAY)); textS1.setText(sdf.format(cal.getTime())); } // Status 2 if (transport.getStatusMessages().containsKey(ITransportStatus.TRANSPORT_STATUS_AT_PATIENT)) { cal.setTimeInMillis( transport.getStatusMessages().get(ITransportStatus.TRANSPORT_STATUS_AT_PATIENT)); textS2.setText(sdf.format(cal.getTime())); } // Status 3 if (transport.getStatusMessages() .containsKey(ITransportStatus.TRANSPORT_STATUS_START_WITH_PATIENT)) { cal.setTimeInMillis(transport.getStatusMessages() .get(ITransportStatus.TRANSPORT_STATUS_START_WITH_PATIENT)); textS3.setText(sdf.format(cal.getTime())); } // Status 4 if (transport.getStatusMessages().containsKey(ITransportStatus.TRANSPORT_STATUS_AT_DESTINATION)) { cal.setTimeInMillis( transport.getStatusMessages().get(ITransportStatus.TRANSPORT_STATUS_AT_DESTINATION)); textS4.setText(sdf.format(cal.getTime())); } // Status 5 if (transport.getStatusMessages().containsKey(ITransportStatus.TRANSPORT_STATUS_DESTINATION_FREE)) { cal.setTimeInMillis( transport.getStatusMessages().get(ITransportStatus.TRANSPORT_STATUS_DESTINATION_FREE)); textS5.setText(sdf.format(cal.getTime())); } // Status 6 if (transport.getStatusMessages().containsKey(ITransportStatus.TRANSPORT_STATUS_CAR_IN_STATION)) { cal.setTimeInMillis( transport.getStatusMessages().get(ITransportStatus.TRANSPORT_STATUS_CAR_IN_STATION)); textS6.setText(sdf.format(cal.getTime())); } } if (transport.getCreationTime() != 0) { cal.setTimeInMillis(transport.getCreationTime()); textAufgen.setText(sdf.format(cal.getTime())); } // alarming timestamps if (transport.getTimestampNA() != 0) { cal.setTimeInMillis(transport.getTimestampNA()); timestampNA.setText(sdf_dateTime.format(cal.getTime())); } if (transport.getTimestampRTH() != 0) { cal.setTimeInMillis(transport.getTimestampRTH()); timestampRTH.setText(sdf_dateTime.format(cal.getTime())); } if (transport.getTimestampDF() != 0) { cal.setTimeInMillis(transport.getTimestampDF()); timestampDF.setText(sdf_dateTime.format(cal.getTime())); } if (transport.getTimestampBRKDT() != 0) { cal.setTimeInMillis(transport.getTimestampBRKDT()); timestampBRKDT.setText(sdf_dateTime.format(cal.getTime())); } if (transport.getTimestampFW() != 0) { cal.setTimeInMillis(transport.getTimestampFW()); timestampFW.setText(sdf_dateTime.format(cal.getTime())); } if (transport.getTimestampPolizei() != 0) { cal.setTimeInMillis(transport.getTimestampPolizei()); timestampPolizei.setText(sdf_dateTime.format(cal.getTime())); } if (transport.getTimestampBergrettung() != 0) { cal.setTimeInMillis(transport.getTimestampBergrettung()); timestampBergrettung.setText(sdf_dateTime.format(cal.getTime())); } if (transport.getTimestampKIT() != 0) { cal.setTimeInMillis(transport.getTimestampKIT()); timestampKIT.setText(sdf_dateTime.format(cal.getTime())); } // other fields this.begleitpersonButton.setSelection(transport.isAssistantPerson()); this.bergrettungButton.setSelection(transport.isMountainRescueServiceAlarming()); this.brkdtButton.setSelection(transport.isBrkdtAlarming()); // the disease if (transport.getKindOfIllness() != null) { // the returned disease has no id so we query the managed // diseases and try to get the complete object :) String name = transport.getKindOfIllness().getDiseaseName(); Disease disease = diseaseManager.getDiseaseByName(name); if (disease != null) { transport.setKindOfIllness(disease); setErkrVerl.setSelection(new StructuredSelection(disease)); } } if (transport.getPatient() != null) { this.patientLastName.setText(transport.getPatient().getLastname()); this.patientFirstName.setText(transport.getPatient().getFirstname()); } if (transport.getToCity() != null) textToCity.setText(transport.getToCity()); if (transport.getToStreet() != null) textToStreet.setText(transport.getToStreet()); // mandatory fields if (transport.getTransportPriority() != null) { oldPriority = transport.getTransportPriority(); comboPrioritaet.setText(this.priorityToString(transport.getTransportPriority())); } textFromStreet.setText(transport.getFromStreet()); if (transport.getPlanedLocation() != null) this.zustaendigeOrtsstelle.setSelection(new StructuredSelection(transport.getPlanedLocation()));// mandatory!! // default: // Bezirk if (transport.getFromCity() != null) textFromCity.setText(transport.getFromCity()); this.dfButton.setSelection(transport.isDfAlarming()); this.fernfahrtButton.setSelection(transport.isLongDistanceTrip()); this.feuerwehrButton.setSelection(transport.isFirebrigadeAlarming()); this.notarztButton.setSelection(transport.isEmergencyDoctorAlarming()); this.polizeiButton.setSelection(transport.isPoliceAlarming()); this.KITButton.setSelection(transport.isKITAlarming()); this.rthButton.setSelection(transport.isHelicopterAlarming()); this.ruecktransportMoeglichButton.setSelection(transport.isBackTransport()); this.rufhilfepatientButton.setSelection(transport.isEmergencyPhone()); this.bd2Button.setSelection(transport.isBlueLightToGoal()); this.bd1Button.setSelection(transport.isBlueLight1()); this.createdBy.setText(transport.getCreatedByUsername()); if (transport.getDisposedByUsername() != null) disposedBy.setText(transport.getDisposedByUsername()); if (transport.getNotes() != null) { this.textAnmerkungen.setText(transport.getNotes()); } if (transport.getCallerDetail() != null) { if (transport.getCallerDetail().getCallerName() != null) this.textAnrufer.setText(transport.getCallerDetail().getCallerName()); if (transport.getCallerDetail().getCallerTelephoneNumber() != null) this.textTelefonAnrufer.setText(transport.getCallerDetail().getCallerTelephoneNumber()); } // the real station which did the transport if (transport.getVehicleDetail() != null) { this.textOrtsstelle.setText(transport.getVehicleDetail().getCurrentStation().getLocationName()); } if (transport.getFeedback() != null) this.textRueckmeldung.setText(transport.getFeedback()); if (transport.getTransportNumber() != 0) if (transport.getTransportNumber() == -1) this.textTransportNummer.setText("STORNO"); else if (transport.getTransportNumber() == -2) this.textTransportNummer.setText("WTGL"); else if (transport.getTransportNumber() == -4) this.textTransportNummer.setText("NEF"); else if (transport.getTransportNumber() != 0) this.textTransportNummer.setText(String.valueOf(transport.getTransportNumber())); // kind of transport if (transport.getKindOfTransport() != null) combokindOfTransport.setText(transport.getKindOfTransport()); // directness int direction = transport.getDirection(); if (TOWARDS_BRUCK == direction) { this.bruckButton.setSelection(true); } if (TOWARDS_GRAZ == direction) { this.grazButton.setSelection(true); } if (TOWARDS_LEOBEN == direction) { this.leobenButton.setSelection(true); } if (TOWARDS_MARIAZELL == direction) { this.mariazellButton.setSelection(true); } if (TOWARDS_VIENNA == direction) { this.wienButton.setSelection(true); } if (TOWARDS_KAPFENBERG == direction) { this.kapfenbergButton.setSelection(true); } if (transport.getVehicleDetail() != null) { if (transport.getVehicleDetail().getDriver() != null) { this.setTextFahrer .setSelection(new StructuredSelection(transport.getVehicleDetail().getDriver())); } if (transport.getVehicleDetail().getFirstParamedic() != null) { this.setTextSaniI.setSelection( new StructuredSelection(transport.getVehicleDetail().getFirstParamedic())); } if (transport.getVehicleDetail().getSecondParamedic() != null) { this.setTextSaniII.setSelection( new StructuredSelection(transport.getVehicleDetail().getSecondParamedic())); } textFahrzeug.setText(transport.getVehicleDetail().getVehicleName()); } } return composite; }
From source file:at.rc.tacos.client.view.VehicleForm.java
License:Open Source License
/** * Create contents of the window/* w ww . j a v a 2 s . c o m*/ */ @Override protected Control createDialogArea(Composite parent) { // setup the composite Composite composite = (Composite) super.createDialogArea(parent); GridLayout layout = new GridLayout(); layout.horizontalSpacing = 30; layout.verticalSpacing = 10; composite.setLayout(layout); composite.setBackground(CustomColors.SECTION_BACKGROUND); toolkit = new FormToolkit(CustomColors.FORM_COLOR(parent.getDisplay())); // create the sections createDetailSection(composite); createStatusSection(composite); createCrewSection(composite); createNotesSection(composite); // init if we have a vehicle if (vehicleDetail != null) { vehicleComboViewer.setSelection(new StructuredSelection(vehicleDetail)); mobilePhoneComboViewer.setSelection(new StructuredSelection(vehicleDetail.getMobilePhone())); stationComboViewer.setSelection(new StructuredSelection(vehicleDetail.getCurrentStation())); if (vehicleDetail.getDriver() != null) driverComboViewer.setSelection(new StructuredSelection(vehicleDetail.getDriver())); if (vehicleDetail.getFirstParamedic() != null) medic1ComboViewer.setSelection(new StructuredSelection(vehicleDetail.getFirstParamedic())); if (vehicleDetail.getSecondParamedic() != null) medic2ComboViewer.setSelection(new StructuredSelection(vehicleDetail.getSecondParamedic())); readyButton.setSelection(vehicleDetail.isReadyForAction()); outOfOrder.setSelection(vehicleDetail.isOutOfOrder()); noteEditor.getDocument().set(vehicleDetail.getVehicleNotes()); // check if this vehicle has a assigned transport List<Transport> transports = transportManager .getUnderwayTransportsByVehicle(vehicleDetail.getVehicleName()); if (!transports.isEmpty()) { stationComboViewer.getCombo().setEnabled(false); stationLabel.setImage(ImageFactory.getInstance().getRegisteredImage("admin.info")); stationLabel.setToolTipText("Dieses Fahrzeug fhrt gerade einen oder mehrere Transporte durch, " + "die Ortsstelle kann nicht gendert werden"); } } checkRequiredFields(); return composite; }
From source file:at.spardat.xma.gui.mapper.MapperDialog.java
License:Open Source License
/** * The selection changed in the widget-tree. The reaction is, that an associated * relationship and the attribute is highlithed. *///from ww w.j av a 2 s . co m private void widgetTreeSelectionChanged(SelectionChangedEvent event) { Iterator iter = ((StructuredSelection) event.getSelection()).iterator(); if (iter.hasNext()) { Object widget = iter.next(); if (widget instanceof IBDAttachable) { //for debugging debug("--> widget selected: " + ((IBDAttachable) widget).getNamInstance()); // is there a relationship attached? Relationship rel = mdlRels_.find((IBDAttachable) widget); if (rel == null) { // no attachment; deselect all bdTreeViewer.setSelection(StructuredSelection.EMPTY); mapGraphics_.setFocusedRelationship(null); } else { MdlAttribute attr = rel.attribute_; if (attr != null) { if (mapGraphics_.getFocusedRelationship() != rel) { mapGraphics_.setFocusedRelationship(rel); StructuredSelection sel = new StructuredSelection(attr); bdTreeViewer.setSelection(sel, true); } } } relArea.redraw(); stateChanged(); } } }
From source file:at.spardat.xma.gui.mapper.MapperDialog.java
License:Open Source License
/** * The selection changed in the businessData-tree. The reaction is, that an associated * relationshiop and the widget is highlighted. *//*from w w w .j ava 2 s. c o m*/ private void bdTreeSelectionChanged(SelectionChangedEvent event) { int numSelected = 0; Iterator iter = ((StructuredSelection) event.getSelection()).iterator(); while (iter.hasNext()) { iter.next(); numSelected++; } if (numSelected == 1) { iter = ((StructuredSelection) event.getSelection()).iterator(); if (iter.hasNext()) { Object attribute = iter.next(); if (attribute instanceof MdlAttribute) { // for debugging debug("---> attribute selected: " + ((MdlAttribute) attribute).getNamInstance()); // is there a relationship attached? Relationship rel = null; // fixe for mantis bug 18593 rel = getInvolvedRS((MdlAttribute) attribute); if (rel != null) { if (mapGraphics_.getFocusedRelationship() != rel) { mapGraphics_.setFocusedRelationship(rel); StructuredSelection sel = new StructuredSelection(rel.bdAttachable_); widgetTreeViewer.setSelection(sel, true); } } else { // no attachment; deselect all widgetTreeViewer.setSelection(StructuredSelection.EMPTY); mapGraphics_.setFocusedRelationship(null); } relArea.redraw(); stateChanged(); } } } }
From source file:at.spardat.xma.guidesign.presentation.GuidesignEditor.java
License:Open Source License
/** * This creates a model editor.// w ww . j ava 2s . c om * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public GuidesignEditor() { super(); // Create an adapter factory that yields item providers. // List factories = new ArrayList(); factories.add(new ResourceItemProviderAdapterFactory()); factories.add(new GuidesignItemProviderAdapterFactory()); factories.add(new TypesItemProviderAdapterFactory()); adapterFactory = new ComposedAdapterFactory(factories); // Create the command stack that will notify this editor as commands are executed. // BasicCommandStack commandStack = new BasicCommandStack(); // Add a listener to set the most recent command's affected objects to be the selection of the viewer with focus. // commandStack.addCommandStackListener(new CommandStackListener() { public void commandStackChanged(final EventObject event) { getContainer().getDisplay().asyncExec(new Runnable() { public void run() { //for debugging debug("asyncExec in commandStackChanged: command stack changed"); firePropertyChange(IEditorPart.PROP_DIRTY); // Try to select the affected objects. // Command mostRecentCommand = ((CommandStack) event.getSource()).getMostRecentCommand(); if (mostRecentCommand != null) { //setSelectionToViewer(mostRecentCommand.getAffectedObjects()); final Collection theSelection = mostRecentCommand.getAffectedObjects(); // Try to select the items in the current content viewer of the editor. //for debugging debug("asyncExec in commandStackChanged: selection changed"); if (currentViewer != null) { currentViewer.setSelection(new StructuredSelection(theSelection.toArray()), true); } } } }); } }); // Create the editing domain with a special command stack. // //TODO Prio 3: global Clipboard: override the setClipboard/getClipboard methods of AdapterFactoryEditingDomain editingDomain = new AdapterFactoryEditingDomain(adapterFactory, commandStack); }
From source file:at.spardat.xma.guidesign.presentation.GuidesignEditor.java
License:Open Source License
/** * <!-- begin-user-doc -->/*from ww w. j a v a 2 s . c o m*/ * <!-- end-user-doc --> * @modified */ public void gotoMarker(IMarker marker) { Object obj = null; try { obj = getComponent().findObjectOfMarker(new Long(marker.getId())); } catch (Exception e) { GUIDesignerPlugin.INSTANCE.log(e); } if (obj != null) { ISelection selection = new StructuredSelection(obj); setSelection(selection); setContentOutlineSelection(selection); } }
From source file:at.spardat.xma.guidesign.presentation.NewComponentWizard.java
License:Open Source License
/** * Do the work after everything is specified. * <!-- begin-user-doc -->/*from www . j ava 2 s. c o m*/ * <!-- end-user-doc --> * @generated */ public boolean performFinish() { try { // Remember the file. // final IFile modelFile = getModelFile(); // Do the work within an operation. // WorkspaceModifyOperation operation = new WorkspaceModifyOperation() { protected void execute(IProgressMonitor progressMonitor) { try { // Create a resource set // ResourceSet resourceSet = new ResourceSetImpl(); // Get the URI of the model file. // URI fileURI = URI.createPlatformResourceURI(modelFile.getFullPath().toString()); // Create a resource for this file. // Resource resource = resourceSet.createResource(fileURI); // Add the initial model object to the contents. // EObject rootObject = createInitialModel(); if (rootObject != null) { resource.getContents().add(rootObject); } // Save the contents of the resource to the file system. // resource.save(Collections.EMPTY_MAP); } catch (Exception exception) { GUIDesignerPlugin.INSTANCE.log(exception); } finally { progressMonitor.done(); } } }; getContainer().run(false, false, operation); //augment the application descriptor and the build file with the new component info try { createApplicationDescriptor(selectedResource.getProject(), componentCreationPage.getNamPackage(), componentCreationPage.getNamClass(), selectedResource.getName()); } catch (Throwable ex) { String message = ex.getMessage() + "\n" + GUIDesignerPlugin.INSTANCE.getString("_UI_WARN_AppDescrCreation_Failed_label"); MessageDialog.openError(workbench.getActiveWorkbenchWindow().getShell(), GUIDesignerPlugin.INSTANCE.getString("_UI_WARN_AppDescrCreation_Failed_text"), message); GUIDesignerPlugin.INSTANCE.log(ex); } // Select the new file resource in the current view. // IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow(); IWorkbenchPage page = workbenchWindow.getActivePage(); final IWorkbenchPart activePart = page.getActivePart(); if (activePart instanceof ISetSelectionTarget) { final ISelection targetSelection = new StructuredSelection(modelFile); getShell().getDisplay().asyncExec(new Runnable() { public void run() { ((ISetSelectionTarget) activePart).selectReveal(targetSelection); } }); } // Open an editor on the new file. // try { // TODO Prio 1: an 3.0 API anpassen IDE.openEditor(page, modelFile); } catch (PartInitException exception) { MessageDialog.openError(workbenchWindow.getShell(), GUIDesignerPlugin.INSTANCE.getString("_UI_OpenEditorError_label"), exception.getMessage()); return false; } return true; } catch (Exception exception) { GUIDesignerPlugin.INSTANCE.log(exception); return false; } }
From source file:at.spardat.xma.guidesign.presentation.UIPreviewer.java
License:Open Source License
/** * * @param widget/*w w w . j a va2 s . c om*/ * @param parent * @return * @modified */ private Control createControl(XMAWidget widget, Composite parent) { // Control control = null; //this code could be replaced with a switch if (widget instanceof XMAText) { control = widgetFactory.createText(parent, widget); } if (widget instanceof XMALabel) { control = widgetFactory.createLabel(parent, widget); } if (widget instanceof DataLabel) { control = widgetFactory.createLabel(parent, widget); } if (widget instanceof XMAButton) { control = widgetFactory.createButton(parent, widget); } if (widget instanceof XMACombo) { control = widgetFactory.createCombo(parent, widget); } if (widget instanceof SimpleCombo) { control = widgetFactory.createCombo(parent, widget); } if (widget instanceof XMAList) { control = widgetFactory.createList(parent, widget); } if (widget instanceof XMATree) { control = widgetFactory.createTree(parent, widget); } if (widget instanceof XMASeperator) { control = widgetFactory.createLabel(parent, widget); } if (widget instanceof XMATable) { if (((XMATable) widget).isYnCombo()) control = buildTableCombo((XMATable) widget, parent); else control = buildTable((XMATable) widget, parent); } if (widget instanceof XMAGroup) { // if (((XMAGroup)widget).isYnSimpleLayout()) { // control = buildGeneratedGroup((XMAGroup) widget ,parent); // } else { control = buildWidgetTree((XMAGroup) widget, parent); // } } else if (widget instanceof XMAComposite) { // if (((XMAComposite)widget).isYnSimpleLayout()) { // control = buildGeneratedComposite((XMAComposite) widget ,parent); // } else { control = buildWidgetTree((XMAComposite) widget, parent); } // } if (widget instanceof XMASashForm) { control = buildSashForm((XMASashForm) widget, parent); } if (widget instanceof XMATabFolder) { control = buildTabFolder((XMATabFolder) widget, parent); } if (widget instanceof XMAContainer) { control = buildContainer((XMAContainer) widget, parent); } if (widget instanceof XMAScrolledComposite) { control = buildScrolledComposite((XMAScrolledComposite) widget, parent); } if (widget instanceof DatePicker) { control = new at.spardat.xma.guidesign.presentation.DatePicker(parent, widget.getStyle()); } if (widget instanceof XMAGrid) { control = new at.spardat.xma.guidesign.presentation.XMAGrid(parent, widget.getStyle()); } if (widget instanceof XMAPagingControl) { XMAPagingControl ctrl = ((XMAPagingControl) widget); int style = ctrl.getPagingControlStyle().getValue(); if (style == PagingControlStyle.CUSTOM.getValue()) { style = 0; for (PagingControlCustomStyle customStyle : (java.util.List<PagingControlCustomStyle>) PagingControlCustomStyle.VALUES) { if (ctrl.getCustomStyles().isStyleSet(customStyle)) { style |= customStyle.getValue(); } } } control = new PagingControlClient(parent, Locale.getDefault(), style, widget.getStyle()); } if (control != null) { //workaround to ensure that every widget has his item provider associated AdapterFactoryLabelProvider provider = (AdapterFactoryLabelProvider) getLabelProvider(); provider.getText(widget); //set properties to ensure the right appearance widget.setProps(control); if (parent != scrollComp) { //we don't need the outer scrolled component in the adj list adjControls.put(widget, control); } control.addMouseListener(new MouseAdapter() { public void mouseDown(MouseEvent e) { debug("Mouse down on: " + e.widget.getData().toString()); ISelection selection = new StructuredSelection(e.widget.getData()); UIPreviewer.this.fireSelectionChanged(new SelectionChangedEvent(UIPreviewer.this, selection)); editor.setContentOutlineSelection(selection); } }); if (widget instanceof IImageUrl) { //dispose image resources control.addDisposeListener(ImageDisposer.getInstance()); } setContextMenuFor(control); /* Colors and fonts*/ colorsAndFont.setColorsAndFont(control, widget); return control; } else { //there is an unsopported widget //throw new IllegalArgumentException(widget.getClass() + "not supported!"); return null; } }
From source file:at.spardat.xma.guidesign.presentation.UIPreviewer.java
License:Open Source License
/** * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection() *///from ww w . j av a2 s . c o m public ISelection getSelection() { if (actWidget != null) return new StructuredSelection(actWidget); else return null; }