LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 09-08-2010, 05:06 AM   #1
mb12mb
LQ Newbie
 
Registered: Sep 2010
Posts: 1

Rep: Reputation: 0
Helios : Using tab on text field having content proposals, crashes my application


Using content proposal in helios, giving problem if u press tab.
Below is the error.
For recreation snippet is provided(taken from 2 sites) after error log.
Only u need to press tab while proposal pop up is visible & then point mouse at client.
#################################ERROR LOG#############################
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00002aaadc1cafc1, pid=12936, tid=1076615488
#
# JRE version: 6.0_21-b06
# Java VM: Java HotSpot(TM) 64-Bit Server VM (17.0-b16 mixed mode linux-amd64 )
# Problematic frame:
# C [libswt-pi-gtk-3650.so+0x3bfc1] Java_org_eclipse_swt_internal_gtk_OS_GTK_1WIDGET_1WINDOW+0x0
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#



Stack: [0x00000000401bd000,0x00000000402be000], sp=0x00000000402bae08, free space=3f70000000000000018k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C [libswt-pi-gtk-3650.so+0x3bfc1] Java_org_eclipse_swt_internal_gtk_OS_GTK_1WIDGET_1WINDOW+0x0
j org.eclipse.swt.widgets.Shell.filterProc(JJJ)J+297
J org.eclipse.swt.widgets.Display.filterProc(JJJ)J
V [libjvm.so+0x3e756d]
V [libjvm.so+0x5f6f59]
V [libjvm.so+0x3e73a5]
V [libjvm.so+0x420904]
V [libjvm.so+0x3fefe1]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
J org.eclipse.swt.internal.gtk.OS.GTK_WIDGET_WINDOW(J)J
j org.eclipse.swt.widgets.Shell.filterProc(JJJ)J+297
J org.eclipse.swt.widgets.Display.filterProc(JJJ)J
v ~StubRoutines::call_stub
J org.eclipse.swt.internal.gtk.OS._g_main_context_iteration(JZ)Z
J org.eclipse.swt.internal.gtk.OS.g_main_context_iteration(JZ)Z
#####################################################################


####################PROGRAM#######################################

import java.text.ParseException;

import org.eclipse.jface.bindings.keys.IKeyLookup;
import org.eclipse.jface.bindings.keys.KeyLookupFactory;
import org.eclipse.jface.bindings.keys.KeyStroke;
import org.eclipse.jface.fieldassist.ContentProposalAdapter;
import org.eclipse.jface.fieldassist.ControlDecoration;
import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
import org.eclipse.jface.fieldassist.IContentProposalListener2;
import org.eclipse.jface.fieldassist.IContentProposalProvider;
import org.eclipse.jface.fieldassist.SimpleContentProposalProvider;
import org.eclipse.jface.fieldassist.TextContentAdapter;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.ColumnViewerEditor;
import org.eclipse.jface.viewers.ColumnViewerEditorActivationEvent;
import org.eclipse.jface.viewers.ColumnViewerEditorActivationStrategy;
import org.eclipse.jface.viewers.EditingSupport;
import org.eclipse.jface.viewers.FocusCellHighlighter;
import org.eclipse.jface.viewers.FocusCellOwnerDrawHighlighter;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.jface.viewers.TableViewerEditor;
import org.eclipse.jface.viewers.TableViewerFocusCellManager;
import org.eclipse.jface.viewers.TextCellEditor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.Text;

/**
* Shows how to attach content assist to a text cell editor.
*
* @author Mario Winterer
*/
public class TestContentProposal {
private static class Color {
public String name;

public Color(String name) {
this.name = name;
}

public String toString() {
return name;
}
}

public static class TextCellEditorWithContentProposal extends TextCellEditor {

private ContentProposalAdapter contentProposalAdapter;
private boolean popupOpen = false; // true, iff popup is currently open

public TextCellEditorWithContentProposal(Composite parent, IContentProposalProvider contentProposalProvider,
KeyStroke keyStroke, char[] autoActivationCharacters) {
super(parent);

enableContentProposal(contentProposalProvider, keyStroke, autoActivationCharacters);
}

private void enableContentProposal(IContentProposalProvider contentProposalProvider, KeyStroke keyStroke,
char[] autoActivationCharacters) {
contentProposalAdapter = new ContentProposalAdapter(text, new TextContentAdapter(),
contentProposalProvider, keyStroke, autoActivationCharacters);

// Listen for popup open/close events to be able to handle focus events correctly
contentProposalAdapter.addContentProposalListener(new IContentProposalListener2() {

public void proposalPopupClosed(ContentProposalAdapter adapter) {
popupOpen = false;
}

public void proposalPopupOpened(ContentProposalAdapter adapter) {
popupOpen = true;
}
});
}

/**
* Return the {@link ContentProposalAdapter} of this cell editor.
*
* @return the {@link ContentProposalAdapter}
*/
public ContentProposalAdapter getContentProposalAdapter() {
return contentProposalAdapter;
}

protected void focusLost() {
if (!popupOpen) {
// Focus lost deactivates the cell editor.
// This must not happen if focus lost was caused by activating
// the completion proposal popup.
super.focusLost();
}
}

protected boolean dependsOnExternalFocusListener() {
// Always return false;
// Otherwise, the ColumnViewerEditor will install an additional focus listener
// that cancels cell editing on focus lost, even if focus gets lost due to
// activation of the completion proposal popup. See also bug 58777.
return false;
}
}

private static class ColorNameEditingSupport extends EditingSupport {
private TextCellEditorWithContentProposal cellEditor;

public ColorNameEditingSupport(TableViewer viewer) {
super(viewer);

IContentProposalProvider contentProposalProvider = new SimpleContentProposalProvider(new String[] { "red",
"green", "blue" });
cellEditor = new TextCellEditorWithContentProposal(viewer.getTable(), contentProposalProvider, null, null);
}

protected boolean canEdit(Object element) {
return (element instanceof Color);
}

protected CellEditor getCellEditor(Object element) {
return cellEditor;
}

protected Object getValue(Object element) {
return ((Color) element).name;
}

protected void setValue(Object element, Object value) {
((Color) element).name = value.toString();
getViewer().update(element, null);
}

}
public void setFocus() {
}
private void createDeco(Text text, String s){

}

public TestContentProposal(Shell shell) {

/////////////////////////////
GridLayout layout = new GridLayout(2,false);
shell.setLayout(layout);
Label label = new Label(shell, SWT.NONE);
label.setText("Please select a value: ");
Text text = new Text(shell, SWT.BORDER);
createDeco(text, "Use CNTL + SPACE to see possible values");
GridData data = new GridData(GridData.FILL_HORIZONTAL);
text.setLayoutData(data);
ControlDecoration deco = new ControlDecoration(text, SWT.LEFT);
deco.setDescriptionText("Use CNTL + SPACE to see possible values");
deco.setImage(FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_IN FORMATION).getImage());
deco.setShowOnlyOnFocus(false);
// Help the user with the possible inputs
// "." and "#" will also activate the content proposals
char[] autoActivationCharacters = new char[] { '.', '#' };
KeyStroke keyStroke;
try {
//
keyStroke = KeyStroke.getInstance("Ctrl+Space");

// assume that myTextControl has already been created in some way
ContentProposalAdapter adapter = new ContentProposalAdapter(text,
new TextContentAdapter(),
new SimpleContentProposalProvider(new String[] {
"ProposalOne", "ProposalTwo", "ProposalThree" }),
null, null);
adapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
} catch (org.eclipse.jface.bindings.keys.ParseException e) {
e.printStackTrace();
}



///////////////////////////////
final TableViewer viewer = new TableViewer(shell, SWT.BORDER | SWT.FULL_SELECTION);
final Table table = viewer.getTable();
table.setLinesVisible(true);
table.setHeaderVisible(true);

final TableViewerColumn colorColumn = new TableViewerColumn(viewer, SWT.LEFT);
colorColumn.getColumn().setText("Color name");
colorColumn.getColumn().setWidth(200);
colorColumn.setLabelProvider(new ColumnLabelProvider());
colorColumn.setEditingSupport(new ColorNameEditingSupport(viewer));

viewer.setContentProvider(new ArrayContentProvider());

ColumnViewerEditorActivationStrategy activationSupport = new ColumnViewerEditorActivationStrategy(viewer) {
protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) {
return event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL
|| event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION
|| event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC
|| (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED && event.keyCode == KeyLookupFactory
.getDefault().formalKeyLookup(IKeyLookup.ENTER_NAME));
}
};
activationSupport.setEnableEditorActivationWithKeyboard(true);

/*
* Without focus highlighter, keyboard events will not be delivered to
* ColumnViewerEditorActivationStragety#isEditorActivationEvent(...) (see above)
*/
FocusCellHighlighter focusCellHighlighter = new FocusCellOwnerDrawHighlighter(viewer);
TableViewerFocusCellManager focusCellManager = new TableViewerFocusCellManager(viewer, focusCellHighlighter);

TableViewerEditor.create(viewer, focusCellManager, activationSupport, ColumnViewerEditor.TABBING_VERTICAL
| ColumnViewerEditor.KEYBOARD_ACTIVATION);

viewer.setInput(createModel());
}

private Color[] createModel() {
return new Color[] { new Color("red"), new Color("green") };
}

/**
* @param args
*/
public static void main(String[] args) {
Display display = new Display();

Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
new TestContentProposal(shell);
shell.open();

while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}

display.dispose();
}
}
######################################################################
 
Old 09-12-2010, 03:32 AM   #2
14moose
Member
 
Registered: May 2010
Posts: 83

Rep: Reputation: Disabled
Try recoding the GUI in Java Swing instead of Eclipse SWT.

The problem seems to be with SWT, the GUI library Eclipse uses by default. SWT is written in C/C++ (and merely interfaces to Java), so it's inherently less portable than Swing (which s written entirely in Java).

Perhaps there's actually a bug in your code. But, based on the information you provided, I think it's more likely it's either configuration, or a bug in your version of libswt-pi-gtk-3650.so.

Last edited by 14moose; 09-12-2010 at 02:12 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: HeliOS Store Opens to Fund The HeliOS Project LXer Syndicated Linux News 2 09-07-2010 09:41 AM
[SOLVED] looking for text field editor bartonski Linux - Software 4 12-22-2009 01:55 PM
File content by field into variable vijayrc Linux - Newbie 3 06-23-2009 03:10 PM
Replace text of unknown content with other text in file brian0918 Programming 15 07-14-2005 10:22 PM
Replace text of unknown content with other text in file brian0918 Linux - Software 1 07-14-2005 04:22 PM


All times are GMT -5. The time now is 11:45 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration