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 154574 Details for
Bug 297969
[Shell] JavaScript error when creating a dialog in certain constellations
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
DemoTableViewPart.java to reproduct the problem
DemoTableViewPart.java (text/x-java), 7.13 KB, created by
Markus Krüger
on 2009-12-16 12:01:58 EST
(
hide
)
Description:
DemoTableViewPart.java to reproduct the problem
Filename:
MIME Type:
Creator:
Markus Krüger
Created:
2009-12-16 12:01:58 EST
Size:
7.13 KB
patch
obsolete
>/******************************************************************************* > * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH. > * 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: > * Innoopract Informationssysteme GmbH - initial API and implementation > ******************************************************************************/ >package org.eclipse.rap.demo; > >import java.util.ArrayList; >import java.util.List; > >import org.eclipse.core.runtime.*; >import org.eclipse.core.runtime.jobs.Job; >import org.eclipse.jface.viewers.*; >import org.eclipse.rwt.lifecycle.UICallBack; >import org.eclipse.swt.SWT; >import org.eclipse.swt.events.SelectionEvent; >import org.eclipse.swt.events.SelectionListener; >import org.eclipse.swt.layout.GridData; >import org.eclipse.swt.layout.GridLayout; >import org.eclipse.swt.widgets.*; >import org.eclipse.ui.part.ViewPart; > >public class DemoTableViewPart extends ViewPart { > > private static final int ROWS = 100; > private static final int COLUMNS = 3; > private TableViewer viewer; > private class ViewContentProvider implements IStructuredContentProvider { > > public Object[] getElements( Object inputElement ) { > List rows = new ArrayList(); > for( int i = 0; i < ROWS; i++ ) { > List row = new ArrayList(); > for( int j = 0; j < COLUMNS; j++ ) { > row.add( "Item" + i + "-" + j ); > } > rows.add( row ); > } > return rows.toArray( new List[ rows.size() ] ); > } > > public void dispose() { > } > > public void inputChanged( Viewer viewer, Object oldInput, Object newInput ) > { > } > } > private class ViewerLabelProvider extends ColumnLabelProvider { > > private int index = -1; > > public ViewerLabelProvider( int index ) { > this.index = index; > } > > public int getIndex() { > return index; > } > > public String getText( Object element ) { > List row = ( List )element; > return row.get( index ).toString(); > } > > public String getToolTipText( Object element ) { > return getText( element ); > } > } > private class ViewLabelProvider extends LabelProvider { > > public String getText( Object element ) { > return new ViewerLabelProvider( 0 ).getText( element ); > } > } > > public void createPartControl( final Composite parent ) { > parent.setLayout( new GridLayout( 1, false ) ); > parent.setBackground( parent.getDisplay().getSystemColor( SWT.COLOR_BLUE ) ); > Composite c = new Composite( parent, SWT.NONE ); > c.setLayout( new GridLayout( 1, false ) ); > c.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) ); > c.setBackground( parent.getDisplay().getSystemColor( SWT.COLOR_RED ) ); > Button b = new Button( c, SWT.PUSH ); > b.setText( "TEST" ); > b.addSelectionListener( new SelectionListener() { > > public void widgetSelected( SelectionEvent e ) { > final Display display = viewer.getTable().getDisplay(); > Job j = new Job( "ddd" ) { > > protected IStatus run( IProgressMonitor monitor ) { > monitor.beginTask( getName(), IProgressMonitor.UNKNOWN ); > try { > UICallBack.runNonUIThreadWithFakeContext( display, new Runnable() > { > > public void run() { > try { > Thread.sleep( 2000 ); > } catch( InterruptedException exception1 ) { > exception1.printStackTrace(); > } > Runnable runnable = new Runnable() { > > public void run() { > try { > viewer.setInput( viewer.getInput() ); > viewer.refresh(); > } catch( Exception exception ) { > // > } > } > }; > if( Display.getCurrent() != null ) { > runnable.run(); > } else { > Display.getDefault().syncExec( runnable ); > } > } > } ); > } catch( Exception exception ) { > exception.printStackTrace(); > } > monitor.done(); > return Status.OK_STATUS; > } > }; > j.setUser( true ); > j.schedule(); > } > > public void widgetDefaultSelected( SelectionEvent e ) { > } > } ); > viewer = new TableViewer( c, SWT.H_SCROLL | SWT.V_SCROLL ); > viewer.setContentProvider( new ViewContentProvider() ); > viewer.setLabelProvider( new ViewLabelProvider() ); > final Table table = viewer.getTable(); > table.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) ); > viewer.setColumnProperties( initColumnProperties( viewer ) ); > table.setLinesVisible( true ); > table.setHeaderVisible( true ); > viewer.setInput( this ); > ColumnViewerToolTipSupport.enableFor( viewer ); > getSite().setSelectionProvider( viewer ); > } > > public void setFocus() { > viewer.getTable().setFocus(); > } > > private String[] initColumnProperties( final TableViewer tableViewer ) { > String[] result = new String[ COLUMNS ]; > for( int i = 0; i < COLUMNS; i++ ) { > final int currentIndex = i; > TableViewerColumn tblvCol = new TableViewerColumn( tableViewer, SWT.NONE ); > if( i == 2 ) { > tblvCol.getColumn().setWidth( 190 ); > } else { > tblvCol.getColumn().setWidth( 70 ); > } > tblvCol.getColumn().setResizable( true ); > tblvCol.getColumn().setAlignment( SWT.LEFT ); > tblvCol.setLabelProvider( new ViewerLabelProvider( i ) ); > tblvCol.setEditingSupport( new EditingSupport( tableViewer ) { > > private TextCellEditor textEditor = null; > > protected boolean canEdit( Object element ) { > return true; > } > > protected CellEditor getCellEditor( Object element ) { > if( textEditor == null ) { > textEditor = new TextCellEditor( tableViewer.getTable() ); > ( ( Text )textEditor.getControl() ).setTextLimit( 15 ); > textEditor.setValidator( new ICellEditorValidator() { > > public String isValid( Object value ) { > // no validation for demo > return null; > } > } ); > } > return textEditor; > } > > protected Object getValue( Object element ) { > List row = ( List )element; > return row.get( currentIndex ); > } > > protected void setValue( Object element, Object value ) { > if( value != null ) { > String str = value.toString(); > List row = ( List )element; > row.set( currentIndex, str ); > getViewer().update( element, null ); > } > } > } ); > result[ i ] = "Column" + i; > tblvCol.getColumn().setText( result[ i ] ); > } > return result; > } >}
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 297969
:
154570
| 154574 |
154575