List of usage examples for org.eclipse.jface.viewers SelectionChangedEvent SelectionChangedEvent
public SelectionChangedEvent(ISelectionProvider source, ISelection selection)
From source file:ac.soton.fmusim.components.presentation.ComponentsActionBarContributor.java
License:Open Source License
/** * When the active editor changes, this remembers the change and registers with it as a selection provider. * <!-- begin-user-doc -->/* www. ja v a 2s . co m*/ * <!-- end-user-doc --> * @generated */ @Override public void setActiveEditor(IEditorPart part) { super.setActiveEditor(part); activeEditorPart = part; // Switch to the new selection provider. // if (selectionProvider != null) { selectionProvider.removeSelectionChangedListener(this); } if (part == null) { selectionProvider = null; } else { selectionProvider = part.getSite().getSelectionProvider(); selectionProvider.addSelectionChangedListener(this); // Fake a selection changed event to update the menus. // if (selectionProvider.getSelection() != null) { selectionChanged(new SelectionChangedEvent(selectionProvider, selectionProvider.getSelection())); } } }
From source file:ac.soton.fmusim.components.presentation.ComponentsEditor.java
License:Open Source License
/** * This implements {@link org.eclipse.jface.viewers.ISelectionProvider} to set this editor's overall selection. * Calling this result will notify the listeners. * <!-- begin-user-doc -->//from w w w . j ava 2 s.c o m * <!-- end-user-doc --> * @generated */ public void setSelection(ISelection selection) { editorSelection = selection; for (ISelectionChangedListener listener : selectionChangedListeners) { listener.selectionChanged(new SelectionChangedEvent(this, selection)); } setStatusLineManager(selection); }
From source file:at.rc.tacos.client.ui.custom.DatePickerPanel.java
License:Open Source License
private void initialize() { if (date == null) { date = Calendar.getInstance(); date.set(Calendar.HOUR_OF_DAY, 0); date.set(Calendar.MINUTE, 0); date.set(Calendar.SECOND, 0); date.set(Calendar.MILLISECOND, 0); }//from w w w. j a v a2 s . c o m GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 2; this.setLayout(gridLayout); calendar = new DateTime(this, SWT.CALENDAR); calendar.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { date.set(Calendar.YEAR, calendar.getYear()); date.set(Calendar.MONTH, calendar.getMonth()); date.set(Calendar.DAY_OF_MONTH, calendar.getDay()); setSelection(new DateSelection(date)); notifyListeners(new SelectionChangedEvent(DatePickerPanel.this, getSelection())); } }); createTimeList(this); }
From source file:at.rc.tacos.client.ui.custom.DatePickerPanel.java
License:Open Source License
/** * This method initializes the month combo *//*w ww.jav a2 s . c o m*/ private void createTimeList(Composite composite) { DateFormat dateFormat = DateFormat.getTimeInstance(DateFormat.SHORT); Calendar tempCalendar = Calendar.getInstance(); tempCalendar.set(Calendar.MINUTE, 0); tempCalendar.set(Calendar.SECOND, 0); String[] times = new String[48]; int pos = 0; for (int x = 0; x < 24; x++) { // hour tempCalendar.set(Calendar.MINUTE, 0); tempCalendar.set(Calendar.HOUR_OF_DAY, x); times[pos] = dateFormat.format(tempCalendar.getTime()); // count up the position for the minute pos++; // minute tempCalendar.set(Calendar.MINUTE, 30); times[pos] = dateFormat.format(tempCalendar.getTime()); // count up the position for the hour pos++; } ListViewer listViewer = new ListViewer(composite); listViewer.setContentProvider(new ArrayContentProvider()); listViewer.setInput(times); timeList = listViewer.getList(); listViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { // even index -> just hour if (timeList.getSelectionIndex() % 2 == 0) { date.set(Calendar.HOUR_OF_DAY, timeList.getSelectionIndex() / 2); date.set(Calendar.MINUTE, 0); } else { date.set(Calendar.HOUR_OF_DAY, timeList.getSelectionIndex() / 2); date.set(Calendar.MINUTE, 30); } setSelection(new DateSelection(date)); notifyListeners(new SelectionChangedEvent(DatePickerPanel.this, getSelection())); } }); GridDataFactory.fillDefaults().hint(SWT.DEFAULT, 150).grab(false, true).applyTo(timeList); if (date != null) { // if we have a minute -> select it if (date.get(Calendar.MINUTE) > 0) listViewer.setSelection(new StructuredSelection(times[date.get(Calendar.HOUR_OF_DAY) + 1]), true); else listViewer.setSelection(new StructuredSelection(times[date.get(Calendar.HOUR_OF_DAY)]), true); } else { listViewer.setSelection(new StructuredSelection(times[8]), true); } timeList.addKeyListener(this); }
From source file:at.rc.tacos.client.ui.custom.DatePickerPanel.java
License:Open Source License
public void keyPressed(KeyEvent e) { if (e.keyCode == SWT.ESC) { SelectionChangedEvent changeEvent = new SelectionChangedEvent(this, new ISelection() { public boolean isEmpty() { return true; }//from w w w .j ava 2 s . c om }); notifyListeners(changeEvent); } }
From source file:at.spardat.xma.guidesign.presentation.action.GuidesignActionBarContributor.java
License:Open Source License
/** * When the active editor changes,//from ww w . j ava 2 s. c o m * this remembers the change, * and registers with it as a selection provider. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setActiveEditor(IEditorPart part) { super.setActiveEditor(part); activeEditorPart = part; // Switch to the new selection provider. // if (selectionProvider != null) { selectionProvider.removeSelectionChangedListener(this); } if (part == null) { selectionProvider = null; } else { selectionProvider = part.getSite().getSelectionProvider(); selectionProvider.addSelectionChangedListener(this); // Fake a selection changed event to update the menus. // if (selectionProvider.getSelection() != null) { selectionChanged(new SelectionChangedEvent(selectionProvider, selectionProvider.getSelection())); } } }
From source file:at.spardat.xma.guidesign.presentation.GuidesignEditor.java
License:Open Source License
/** * This implements {@link org.eclipse.jface.viewers.ISelectionProvider} to set this editor's overall selection. * Calling this result will notify the listeners. * @param selection current selection in the editor * maybe null in case of creating a new component by the wizzard * @modified/*from w w w .jav a2s .com*/ */ public void setSelection(ISelection selection) { if (selection != null) { editorSelection = selection; List list = Collections.synchronizedList((List) selectionChangedListeners); //synchronize the notification because some property changes may alter the list synchronized (list) { for (Iterator listeners = list.iterator(); listeners.hasNext();) { ISelectionChangedListener listener = (ISelectionChangedListener) listeners.next(); listener.selectionChanged(new SelectionChangedEvent(this, selection)); } } setStatusLineManager(selection); } }
From source file:at.spardat.xma.guidesign.presentation.UIPreviewer.java
License:Open Source License
/** * * @param widget/* w ww. ja va 2s. co m*/ * @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:au.com.langdale.ui.util.SelectionProvider.java
License:Open Source License
public void setSelection(ISelection selection) { theSelection = selection;//w ww.j a v a 2s .co m final SelectionChangedEvent e = new SelectionChangedEvent(this, selection); Object[] listenersArray = listeners.toArray(); for (int i = 0; i < listenersArray.length; i++) { final ISelectionChangedListener l = (ISelectionChangedListener) listenersArray[i]; SafeRunner.run(new SafeRunnable() { public void run() { l.selectionChanged(e); } }); } }
From source file:bilab.ConsoleView.java
License:Open Source License
protected void fireSelectionChangedListeners() { final ValueSelection s = new ValueSelection(selectedValue); for (final ISelectionChangedListener l : selectionChangedListeners) { l.selectionChanged(new SelectionChangedEvent(this, s)); }//from ww w . j a v a 2s .c o m }