Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Nebula » Textfield-GridEditor not usable when heigher than grid
Textfield-GridEditor not usable when heigher than grid [message #599744] Fri, 11 June 2010 13:58
Johannes Michler is currently offline Johannes Michler
Messages: 21
Registered: July 2009
Junior Member
Hi,

I'm trying to build a little application using a nebula grid with setAutoHeigth(true) and a GridEditor. I Registered a MouseAdapter on the Grid and when clicking in a cell of my Grid a new SWT Text widget gets created and filled with the text of my cell. This is fine so far. But when having large amounts of Text in the cell, so that the Entire Cell cannot be shown, I'm getting to problems: When scrolling down in my grid, I can see the next row. But I can not see the remainder text of the previous row. Furthermore, I cannot activate an GridEditor on such cells: I see no cursor of my newly created editor, and I cannot type anything. Visually, everything seems like before clicking the editor.


Have I done something wrong? Or is this a Nebula-Bug?



package edu.karlsruhe.horus.editors.petrinets.properties;

import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.nebula.widgets.grid.Grid;
import org.eclipse.nebula.widgets.grid.GridColumn;
import org.eclipse.nebula.widgets.grid.GridEditor;
import org.eclipse.nebula.widgets.grid.GridItem;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

public class test1 extends TitleAreaDialog {

/**
* Create the dialog.
*
* @param parentShell
*/
public test1( Shell parentShell) {
super( parentShell);
}

/**
* Create contents of the dialog.
*
* @param parent
*/
@Override
protected Control createDialogArea( Composite parent) {
Composite area = ( Composite) super.createDialogArea( parent);
Composite container = new Composite( area, SWT.NONE);
container.setLayout( new GridLayout( 1, false));
container.setLayoutData( new GridData( GridData.FILL_BOTH));

final Grid grid = new Grid( container, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI);
grid.setCellSelectionEnabled( true);
grid.setHeaderVisible( true);
grid.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true, 1, 1));
grid.setAutoHeight( true);

GridColumn gridColumn = new GridColumn( grid, SWT.NONE);
gridColumn.setText( "New Column");
gridColumn.setWidth( 150);
gridColumn.setWordWrap( true);

GridItem gridItem = new GridItem( grid, SWT.NONE);
gridItem
.setText(
0,
"Very long Text! Very long Text! Very long Text! Very long Text! Very long Text!Very long Text!Very long Text!Very long Text!Very long Text!Very long Text! Very long Text! Very long Text!");


final GridEditor editor = new GridEditor( grid);
grid.addMouseListener( new MouseAdapter() {

public void mouseDown( MouseEvent e) {

Control oldEditor = editor.getEditor();
if ( oldEditor != null)
oldEditor.dispose();

Point pt = new Point( e.x, e.y);

final GridItem item = grid.getItem( pt);
final Point cell = grid.getCell( pt);
if ( item == null || cell == null)
return;

// The control that will be the editor must be a child of the Table
Text newEditor = new Text( grid, SWT.MULTI | SWT.BORDER | SWT.WRAP);
newEditor.setText( item.getText( cell.x));
editor.setEditor( newEditor, item, cell.x);
editor.grabHorizontal = true;
editor.grabVertical = true;

}
});
return area;
}

/**
* Create contents of the button bar.
*
* @param parent
*/
@Override
protected void createButtonsForButtonBar( Composite parent) {
createButton( parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
createButton( parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
}

/**
* Return the initial size of the dialog.
*/
@Override
protected Point getInitialSize() {
return new Point( 589, 456);
}

@Override
protected boolean isResizable() {
return true;
}
}
Previous Topic:FormattedText not allowing 0 to be entered
Next Topic:JGoodies Form layout / SWTForms?
Goto Forum:
  


Current Time: Sun Sep 21 12:23:51 GMT 2014

Powered by FUDForum. Page generated in 0.02956 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software