Home » Archived » Visual Editor (VE) » VE error when I use a FormAttachment
VE error when I use a FormAttachment [message #84755] |
Fri, 25 March 2005 13:19  |
Eclipse User |
|
|
|
Originally posted by: chris.chrisbenson.com
I get the following error message when I try to use a FormAttachment in
the Visual Editor:
Error trying to set new file into editor.
Reason: java.lang.NullPointerException
This is my code. If I comment out the lines like "data.top = new
FormAttachment(0, 5);" then it renders in the visual editor part. If I
uncomment the lines the error returns. Can anyone help me with this?
Thanks.
/*
* Created on Mar 16, 2005
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package com.chrisbenson.data.developer;
import org.eclipse.jface.window.ApplicationWindow;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Text;
//import org.eclipse.swt.widgets.*;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.widgets.Composite;
/**
* @author Chris
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class GuiMain
{
private org.eclipse.swt.widgets.Shell shell = null; //
@jve:decl-index=0:visual-constraint="40,54"
private Button newButton = null;
private Text newDatasourceText = null;
public static void main(String[] args)
{
/* Before this is run, be sure to set up the following in the launch
configuration
* (Arguments->VM Arguments) for the correct SWT library path.
* The following is a windows example:
*
-Djava.library.path=" installation_directory\plugins\org.eclipse.swt.win32_3.0.0\o s\win32\x86 "
*/
org.eclipse.swt.widgets.Display display =
org.eclipse.swt.widgets.Display.getDefault();
GuiMain thisClass = new GuiMain();
thisClass.createShell();
thisClass.shell.pack();
thisClass.shell.open();
while (!thisClass.shell.isDisposed())
{
if (!display.readAndDispatch()) display.sleep ();
}
display.dispose();
}
/**
* This method initializes shell
*/
private void createShell()
{
shell = new org.eclipse.swt.widgets.Shell();
shell.setSize(new org.eclipse.swt.graphics.Point(800,600));
shell.setText("Data Developer");
FormLayout layout = new FormLayout();
layout.marginHeight = 5;
layout.marginWidth = 5;
layout.spacing = 5;
shell.setLayout(layout);
newButton = new Button(shell, SWT.PUSH);
newButton.setText("New");
newDatasourceText = new Text(shell, SWT.NONE);
newDatasourceText.setBounds(new
org.eclipse.swt.graphics.Rectangle(50,50,150,25));
FormData data = new FormData();
data.height = 50;
data.width = 50;
data.top = new FormAttachment(0, 5);
data.left = new FormAttachment(0, 5);
data.bottom = new FormAttachment(50, -5);
data.right = new FormAttachment(50, -5);
newButton.setLayoutData(data);
data = new FormData();
data.top = new FormAttachment(0, 5);
data.left = new FormAttachment(newButton);
data.bottom = new FormAttachment(50, -5);
data.right = new FormAttachment(50, -5);
newDatasourceText.setLayoutData(data);
newButton.addSelectionListener(new
org.eclipse.swt.events.SelectionAdapter()
{
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e)
{
org.eclipse.swt.widgets.DirectoryDialog dirdlg = new
org.eclipse.swt.widgets.DirectoryDialog(shell);
String selectedDirectory = dirdlg.open();
//String newDatasourceText = "";
}
}
);
}
}
|
|
|
Re: VE error when I use a FormAttachment [message #84787 is a reply to message #84755] |
Fri, 25 March 2005 15:34  |
Eclipse User |
|
|
|
Hello,
There are some problems because of which the below source cannot be
correctly understood by VE.
(*) Missing codegen annotations
VE models in the graphical side common types which it knows are visual -
like Shell, Button etc. It doesnt care about other Types - like
FormData. To make VE pay attention to such types, there should be a
codegen annotation ( // @jve:decl-index=0: ) in the source where the
bean is instantiated. Ex:
FormData data = new FormData();// @jve:decl-index=0:
This will make VE pay attention to the 'data' variable. The codegen
annotations are added by VE automatically when the instances are created
by it. Manually coded non-modelled beans should have this annotation added.
(*) Resuse of variables
Currently in the source variables are being reused. Ex:
FormData data = new FormData();
..
data = new FormData();
..
This pattern is currently not supported and the defect
https://bugs.eclipse.org/bugs/show_bug.cgi?id=88763 exists to fix this
problem. Please add yourself on CC to track its progress.
To workaround this problem please rename the second usage of the
variable to be something different so that VE can distinguish clearly
which instance is used where:
FormData data = new FormData();
..
FormData data1 = new FormData();
..
(*) VE not processing field settings correctly.
For some reason VE is not decoding all the expressions where fields of a
bean are being set. In :
1 data.top = new FormAttachment(0, 5);
2 data.left = new FormAttachment(0, 5);
3 data.bottom = new FormAttachment(50, -5);
4 data.right = new FormAttachment(50, 5);
VE is not processing the last three statements because it thinks they
are duplicates of the first statement. I have opened a defect for this (
https://bugs.eclipse.org/bugs/show_bug.cgi?id=89129 ), please add
yourself on CC to track its progress.
Regards,
Sri.
Christopher Benson wrote:
> I get the following error message when I try to use a FormAttachment in
> the Visual Editor:
>
> Error trying to set new file into editor.
>
> Reason: java.lang.NullPointerException
>
> This is my code. If I comment out the lines like "data.top = new
> FormAttachment(0, 5);" then it renders in the visual editor part. If I
> uncomment the lines the error returns. Can anyone help me with this?
> Thanks.
>
> /*
> * Created on Mar 16, 2005
> *
> * TODO To change the template for this generated file go to
> * Window - Preferences - Java - Code Style - Code Templates
> */
> package com.chrisbenson.data.developer;
>
> import org.eclipse.jface.window.ApplicationWindow;
>
> import org.eclipse.swt.widgets.Button;
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.widgets.Text;
> //import org.eclipse.swt.widgets.*;
>
>
> import org.eclipse.swt.layout.FormLayout;
> import org.eclipse.swt.layout.FormData;
> import org.eclipse.swt.layout.FormAttachment;
> import org.eclipse.swt.widgets.Composite;
> /**
> * @author Chris
> *
> * TODO To change the template for this generated type comment go to
> * Window - Preferences - Java - Code Style - Code Templates
> */
> public class GuiMain
> {
>
> private org.eclipse.swt.widgets.Shell shell = null; //
> @jve:decl-index=0:visual-constraint="40,54"
>
> private Button newButton = null;
>
> private Text newDatasourceText = null;
>
> public static void main(String[] args) {
> /* Before this is run, be sure to set up the following in the
> launch configuration * (Arguments->VM Arguments) for the
> correct SWT library path. * The following is a windows example:
> *
> -Djava.library.path=" installation_directory\plugins\org.eclipse.swt.win32_3.0.0\o s\win32\x86 "
>
> */
> org.eclipse.swt.widgets.Display display =
> org.eclipse.swt.widgets.Display.getDefault();
> GuiMain thisClass = new GuiMain();
> thisClass.createShell();
> thisClass.shell.pack();
> thisClass.shell.open();
>
> while (!thisClass.shell.isDisposed()) {
> if (!display.readAndDispatch()) display.sleep ();
> }
> display.dispose();
> }
>
> /**
> * This method initializes shell
> */
> private void createShell() {
> shell = new org.eclipse.swt.widgets.Shell();
> shell.setSize(new org.eclipse.swt.graphics.Point(800,600));
> shell.setText("Data Developer");
>
> FormLayout layout = new FormLayout();
> layout.marginHeight = 5;
> layout.marginWidth = 5;
> layout.spacing = 5;
> shell.setLayout(layout);
>
> newButton = new Button(shell, SWT.PUSH);
> newButton.setText("New");
>
> newDatasourceText = new Text(shell, SWT.NONE);
> newDatasourceText.setBounds(new
> org.eclipse.swt.graphics.Rectangle(50,50,150,25));
>
> FormData data = new FormData();
> data.height = 50;
> data.width = 50;
>
> data.top = new FormAttachment(0, 5);
> data.left = new FormAttachment(0, 5);
> data.bottom = new FormAttachment(50, -5);
> data.right = new FormAttachment(50, -5);
> newButton.setLayoutData(data);
> data = new FormData();
>
> data.top = new FormAttachment(0, 5);
> data.left = new FormAttachment(newButton);
> data.bottom = new FormAttachment(50, -5);
> data.right = new FormAttachment(50, -5);
> newDatasourceText.setLayoutData(data);
>
> newButton.addSelectionListener(new
> org.eclipse.swt.events.SelectionAdapter()
> { public void
> widgetSelected(org.eclipse.swt.events.SelectionEvent e)
> {
> org.eclipse.swt.widgets.DirectoryDialog dirdlg = new
> org.eclipse.swt.widgets.DirectoryDialog(shell);
> String selectedDirectory = dirdlg.open();
> //String newDatasourceText = "";
> }
> }
> );
> }
> }
>
>
>
>
>
>
>
>
|
|
|
Re: VE error when I use a FormAttachment [message #606091 is a reply to message #84755] |
Fri, 25 March 2005 15:34  |
Eclipse User |
|
|
|
Hello,
There are some problems because of which the below source cannot be
correctly understood by VE.
(*) Missing codegen annotations
VE models in the graphical side common types which it knows are visual -
like Shell, Button etc. It doesnt care about other Types - like
FormData. To make VE pay attention to such types, there should be a
codegen annotation ( // @jve:decl-index=0: ) in the source where the
bean is instantiated. Ex:
FormData data = new FormData();// @jve:decl-index=0:
This will make VE pay attention to the 'data' variable. The codegen
annotations are added by VE automatically when the instances are created
by it. Manually coded non-modelled beans should have this annotation added.
(*) Resuse of variables
Currently in the source variables are being reused. Ex:
FormData data = new FormData();
..
data = new FormData();
..
This pattern is currently not supported and the defect
https://bugs.eclipse.org/bugs/show_bug.cgi?id=88763 exists to fix this
problem. Please add yourself on CC to track its progress.
To workaround this problem please rename the second usage of the
variable to be something different so that VE can distinguish clearly
which instance is used where:
FormData data = new FormData();
..
FormData data1 = new FormData();
..
(*) VE not processing field settings correctly.
For some reason VE is not decoding all the expressions where fields of a
bean are being set. In :
1 data.top = new FormAttachment(0, 5);
2 data.left = new FormAttachment(0, 5);
3 data.bottom = new FormAttachment(50, -5);
4 data.right = new FormAttachment(50, 5);
VE is not processing the last three statements because it thinks they
are duplicates of the first statement. I have opened a defect for this (
https://bugs.eclipse.org/bugs/show_bug.cgi?id=89129 ), please add
yourself on CC to track its progress.
Regards,
Sri.
Christopher Benson wrote:
> I get the following error message when I try to use a FormAttachment in
> the Visual Editor:
>
> Error trying to set new file into editor.
>
> Reason: java.lang.NullPointerException
>
> This is my code. If I comment out the lines like "data.top = new
> FormAttachment(0, 5);" then it renders in the visual editor part. If I
> uncomment the lines the error returns. Can anyone help me with this?
> Thanks.
>
> /*
> * Created on Mar 16, 2005
> *
> * TODO To change the template for this generated file go to
> * Window - Preferences - Java - Code Style - Code Templates
> */
> package com.chrisbenson.data.developer;
>
> import org.eclipse.jface.window.ApplicationWindow;
>
> import org.eclipse.swt.widgets.Button;
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.widgets.Text;
> //import org.eclipse.swt.widgets.*;
>
>
> import org.eclipse.swt.layout.FormLayout;
> import org.eclipse.swt.layout.FormData;
> import org.eclipse.swt.layout.FormAttachment;
> import org.eclipse.swt.widgets.Composite;
> /**
> * @author Chris
> *
> * TODO To change the template for this generated type comment go to
> * Window - Preferences - Java - Code Style - Code Templates
> */
> public class GuiMain
> {
>
> private org.eclipse.swt.widgets.Shell shell = null; //
> @jve:decl-index=0:visual-constraint="40,54"
>
> private Button newButton = null;
>
> private Text newDatasourceText = null;
>
> public static void main(String[] args) {
> /* Before this is run, be sure to set up the following in the
> launch configuration * (Arguments->VM Arguments) for the
> correct SWT library path. * The following is a windows example:
> *
> -Djava.library.path=" installation_directory\plugins\org.eclipse.swt.win32_3.0.0\o s\win32\x86 "
>
> */
> org.eclipse.swt.widgets.Display display =
> org.eclipse.swt.widgets.Display.getDefault();
> GuiMain thisClass = new GuiMain();
> thisClass.createShell();
> thisClass.shell.pack();
> thisClass.shell.open();
>
> while (!thisClass.shell.isDisposed()) {
> if (!display.readAndDispatch()) display.sleep ();
> }
> display.dispose();
> }
>
> /**
> * This method initializes shell
> */
> private void createShell() {
> shell = new org.eclipse.swt.widgets.Shell();
> shell.setSize(new org.eclipse.swt.graphics.Point(800,600));
> shell.setText("Data Developer");
>
> FormLayout layout = new FormLayout();
> layout.marginHeight = 5;
> layout.marginWidth = 5;
> layout.spacing = 5;
> shell.setLayout(layout);
>
> newButton = new Button(shell, SWT.PUSH);
> newButton.setText("New");
>
> newDatasourceText = new Text(shell, SWT.NONE);
> newDatasourceText.setBounds(new
> org.eclipse.swt.graphics.Rectangle(50,50,150,25));
>
> FormData data = new FormData();
> data.height = 50;
> data.width = 50;
>
> data.top = new FormAttachment(0, 5);
> data.left = new FormAttachment(0, 5);
> data.bottom = new FormAttachment(50, -5);
> data.right = new FormAttachment(50, -5);
> newButton.setLayoutData(data);
> data = new FormData();
>
> data.top = new FormAttachment(0, 5);
> data.left = new FormAttachment(newButton);
> data.bottom = new FormAttachment(50, -5);
> data.right = new FormAttachment(50, -5);
> newDatasourceText.setLayoutData(data);
>
> newButton.addSelectionListener(new
> org.eclipse.swt.events.SelectionAdapter()
> { public void
> widgetSelected(org.eclipse.swt.events.SelectionEvent e)
> {
> org.eclipse.swt.widgets.DirectoryDialog dirdlg = new
> org.eclipse.swt.widgets.DirectoryDialog(shell);
> String selectedDirectory = dirdlg.open();
> //String newDatasourceText = "";
> }
> }
> );
> }
> }
>
>
>
>
>
>
>
>
|
|
|
Goto Forum:
Current Time: Fri May 02 04:54:37 EDT 2025
Powered by FUDForum. Page generated in 0.04480 seconds
|