Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 90165 Details for
Bug 197953
[Viewers] Using FocusCellOwnerDrawHighlighter with OwnerDrawLabelProvider
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Proposal of modified FocusCellOwnerDrawHighlighter
FocusCellMyOwnerDrawHighlighter.java (text/plain), 5.25 KB, created by
Pavel Sklenak
on 2008-02-20 06:13:57 EST
(
hide
)
Description:
Proposal of modified FocusCellOwnerDrawHighlighter
Filename:
MIME Type:
Creator:
Pavel Sklenak
Created:
2008-02-20 06:13:57 EST
Size:
5.25 KB
patch
obsolete
>/******************************************************************************* > * Copyright (c) 2007 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at > * http://www.eclipse.org/legal/epl-v10.html > * > * Contributors: > * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation > * - fix for bug 183850, 182652 > * IBM Corporation - initial API and implementation > ******************************************************************************/ > >package org.eclipse.jface.viewers; > >import org.eclipse.core.runtime.Assert; >import org.eclipse.swt.SWT; >import org.eclipse.swt.graphics.Color; >import org.eclipse.swt.graphics.GC; >import org.eclipse.swt.graphics.Rectangle; >import org.eclipse.swt.widgets.Event; >import org.eclipse.swt.widgets.Listener; > >/** > * @since 3.3 > * > */ >public class FocusCellMyOwnerDrawHighlighter extends FocusCellHighlighter { > > private ViewerCell oldCell; > > // Needed to work-around problem in bug 183850 > private static final boolean WIN_32 = "win32".equals(SWT.getPlatform()); //$NON-NLS-1$ > private ColumnViewer viewer; > private int index; > private Object item; > > /** > * @param viewer > * the viewer > */ > public FocusCellMyOwnerDrawHighlighter(ColumnViewer viewer) { > super(viewer); > this.viewer = viewer; > hookListener(); > } > > private void markFocusedCell(Event event, ViewerCell cell) { > Color background = null; > Color foreground = null; > > if ( WIN_32 || foreground != null || background != null) { > GC gc = event.gc; > > if (background == null) { > background = cell.getItem().getDisplay().getSystemColor( > SWT.COLOR_LIST_SELECTION); > } > > if (foreground == null) { > foreground = cell.getItem().getDisplay().getSystemColor( > SWT.COLOR_LIST_SELECTION_TEXT); > } > > gc.setBackground(background); > gc.setForeground(foreground); > gc.fillRectangle(event.getBounds()); > > // This is a workaround for an SWT-Bug on WinXP bug 169517 > gc.drawText(" ", cell.getBounds().x, cell.getBounds().y, false); //$NON-NLS-1$ > event.detail &= ~SWT.SELECTED; > } > } > > private void removeSelectionInformation(Event event, ViewerCell cell) { > Color background = getSelectedCellBackgroundColor(cell); > Color foreground = getSelectedCellForegroundColor(cell); > > GC gc = event.gc; > > if(background == null) { > background = cell.getViewerRow().getBackground( > cell.getColumnIndex()); > } > > if(foreground == null) { > foreground = cell.getViewerRow().getForeground( > cell.getColumnIndex()); > } > > gc.setBackground(background); > gc.setForeground(foreground); > gc.fillRectangle(cell.getBounds()); > // This is a workaround for an SWT-Bug on WinXP bug 169517 > gc.drawText(" ", cell.getBounds().x, cell.getBounds().y, false); //$NON-NLS-1$ > event.detail &= ~SWT.SELECTED; > } > > private void hookListener() { > > Listener listener = new Listener() { > > public void handleEvent(Event event) { > if ((event.detail & SWT.SELECTED) > 0) { > ViewerCell focusCell = getFocusCell(); > ViewerRow row = viewer.getViewerRowFromItem(event.item); > > Assert > .isNotNull(row, > "Internal structure invalid. Item without associated row is not possible."); //$NON-NLS-1$ > > ViewerCell cell = row.getCell(event.index); > >// if (focusCell == null || !cell.equals(focusCell)) { >// removeSelectionInformation(event, cell); >// } else { >// markFocusedCell(event, cell); >// } >// > if (cell.equals(focusCell)) { > removeSelectionInformation(event, cell); > notifyTraverse(event); > } else { > markFocusedCell(event, cell); > } > } > } > > }; > viewer.getControl().addListener(SWT.EraseItem, listener); > } > > /** > * Send event to viewer's control (SWT.Traverse) > * @param event > */ > protected void notifyTraverse(Event event){ > if(event.index != index || event.item != item){ > index = event.index; > item = event.item; > viewer.getControl().notifyListeners(SWT.Traverse, event); > } > } > > /** > * @param cell > * the cell which is colored > * @return the color > */ > protected Color getSelectedCellBackgroundColor(ViewerCell cell) { > return null; > } > > /** > * @param cell > * the cell which is colored > * @return the color > */ > protected Color getSelectedCellForegroundColor(ViewerCell cell) { > return null; > } > > /* > * (non-Javadoc) > * > * @see org.eclipse.jface.viewers.FocusCellHighlighter#focusCellChanged(org.eclipse.jface.viewers.ViewerCell) > */ > protected void focusCellChanged(ViewerCell cell) { > super.focusCellChanged(cell); > > // Redraw new area > if (cell != null) { > redrawArea(cell); > } > > if (oldCell != null) { > redrawArea(oldCell); > } > > this.oldCell = cell; > } > > private void redrawArea(ViewerCell cell){ > Rectangle rect = cell.getBounds(); > int x = cell.getColumnIndex() == 0 ? 0 : rect.x; > int width = cell.getColumnIndex() == 0 ? rect.x + rect.width > : rect.width; > // 1 is a fix for Linux-GTK > cell.getControl().redraw(x, rect.y-1, width, rect.height+1, true); > } >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 197953
:
74677
|
90165
|
90189
|
100632
|
100633