/** * Called on the viewer disposal. Unregisters from the compare configuration. Clients may extend * if they have to do additional cleanup. * * @see org.eclipse.jface.viewers.ContentViewer#handleDispose(org.eclipse.swt.events.DisposeEvent) */ protected void handleDispose(DisposeEvent event) { if (fHandlerService != null) fHandlerService.dispose(); Object input = getInput(); if (input instanceof ICompareInput) { ICompareContainer container = getCompareConfiguration().getContainer(); container.removeCompareInputChangeListener( (ICompareInput) input, fCompareInputChangeListener); } if (input != null) { ICompareInputLabelProvider lp = getCompareConfiguration().getLabelProvider(); if (lp != null) lp.removeListener(labelChangeListener); } if (fPropertyChangeListener != null) { fCompareConfiguration.removePropertyChangeListener(fPropertyChangeListener); fPropertyChangeListener = null; } fAncestorLabel = null; fLeftLabel = null; fDirectionLabel = null; fRightLabel = null; fCenter = null; if (fRightArrow != null) { fRightArrow.dispose(); fRightArrow = null; } if (fLeftArrow != null) { fLeftArrow.dispose(); fLeftArrow = null; } if (fBothArrow != null) { fBothArrow.dispose(); fBothArrow = null; } if (fNormalCursor != null) { fNormalCursor.dispose(); fNormalCursor = null; } if (fHSashCursor != null) { fHSashCursor.dispose(); fHSashCursor = null; } if (fVSashCursor != null) { fVSashCursor.dispose(); fVSashCursor = null; } if (fHVSashCursor != null) { fHVSashCursor.dispose(); fHVSashCursor = null; } super.handleDispose(event); }
private void updateItem(Item item) { if (!item.isDisposed()) { // defensive code ILabelProvider lprovider = (ILabelProvider) fContentViewer.getLabelProvider(); Object data = item.getData(); String oldText = item.getText(); String text = lprovider.getText(data); if (text != null && !text.equals(oldText)) { item.setText(text); } Image oldImage = item.getImage(); Image image = lprovider.getImage(data); if (image != null && !image.equals(oldImage)) { item.setImage(image); } } }
/** * The <code>ContentMergeViewer</code> implementation of this <code>ContentViewer</code> method * checks to ensure that the content provider is an <code>IMergeViewerContentProvider</code>. * * @param contentProvider the content provider to set. Must implement IMergeViewerContentProvider. */ public void setContentProvider(IContentProvider contentProvider) { Assert.isTrue(contentProvider instanceof IMergeViewerContentProvider); super.setContentProvider(contentProvider); }
protected void hookControl(final Control control) { super.hookControl(control); if (control instanceof Scale) { Listener listener = new Listener() { private boolean mouseDown = false; private boolean mouseDrag = false; private boolean selectionChangedDuringDragging = false; public void handleEvent(Event event) { switch (event.type) { case SWT.Selection: boolean selectionChanged = handleScaleSelection((Scale) event.widget); if (selectionChanged && !selectionChangedDuringDragging && (mouseDrag || mouseDown)) { selectionChangedDuringDragging = true; } if (!selectionChangedDuringDragging) { firePostSelectionChanged(); } break; case SWT.MouseDoubleClick: mouseDown = false; mouseDrag = false; selectionChangedDuringDragging = false; fireOpen(new OpenEvent(SliderViewer.this, getSelection())); break; case SWT.MouseDown: mouseDown = true; mouseDrag = false; selectionChangedDuringDragging = false; break; case SWT.MouseMove: if (!mouseDrag && mouseDown) { mouseDrag = true; } break; case SWT.MouseUp: boolean postSelected = selectionChangedDuringDragging; mouseDown = false; mouseDrag = false; selectionChangedDuringDragging = false; if (postSelected) { firePostSelectionChanged(); } } } }; control.addListener(SWT.Selection, listener); control.addListener(SWT.MouseDoubleClick, listener); control.addListener(SWT.MouseDown, listener); control.addListener(SWT.MouseMove, listener); control.addListener(SWT.MouseUp, listener); return; } else if (control instanceof FigureCanvas) { Listener listener = new Listener() { private boolean mouseDown = false; private boolean mouseDrag = false; private boolean selectionChangedDuringDragging = false; public void handleEvent(Event event) { switch (event.type) { case SWT.Resize: handleResize(); break; case SWT.MouseMove: if (!mouseDrag && mouseDown) { mouseDrag = true; } if (mouseDrag && (event.stateMask & SWT.BUTTON1) != 0) { if (handleCanvasSelection(event.x, event.y)) { selectionChangedDuringDragging = true; } } break; case SWT.MouseDown: if (receives(event.x, event.y)) { mouseDown = true; mouseDrag = false; if (event.button == 1) { if (handleCanvasSelection(event.x, event.y)) { selectionChangedDuringDragging = true; } } } break; case SWT.MouseUp: boolean postSelected = selectionChangedDuringDragging; mouseDown = false; mouseDrag = false; selectionChangedDuringDragging = false; if (postSelected) { firePostSelectionChanged(); } break; case SWT.MouseDoubleClick: mouseDown = false; mouseDrag = false; fireOpen(new OpenEvent(SliderViewer.this, getSelection())); break; } } }; control.addListener(SWT.MouseMove, listener); control.addListener(SWT.MouseDown, listener); control.addListener(SWT.MouseUp, listener); control.addListener(SWT.Resize, listener); control.addListener(SWT.MouseDoubleClick, listener); } }
/** 刷新数据列表。 */ public void refresh() { for (ContentViewer viewer : dataTreeViewers) { viewer.refresh(); } }