2

I started using the CN1 new Guibuilder for the first time today and can't fathom out how to add components. I have watched and read the tutorials but my system isn't behaving the same.

I create a new CN1 project and the 'Form' guibuilder class, right mouse click > Guibuilder > the builder IDE opens fine and looks visually correct. On the right hand side panel i select any component, eg. Label, and as i am dragging onto the canvas it looks as per the tutorial - the handles and height/widths properties visible - see enter image description here. I release the mouse button and it leave a grey box enter image description here

If i click on the grey box (or try to add any component) it disappears enter image description here

Wierdly if i click and drag and at the same time click the PrintScreen button, the label sometime stays on the canvas with the handles and i can see its properties panel, but when i try and change a property, the Label vanishes.

Basically if i try and change anything in the builder, including clicking one the Layouts (bottom left panel) for the GuiForm then the builder seemingly rebuilds itself and collapses and hides anything i have open - resetting itself back to when it was first opened. It's like its in a read-only mode.

Is there a log i can look at? I am not getting any error in my console. Eclipse is running normally in all other areas. I'm on the latest JRE and Eclipse Neon.3 and latest CN1 updates.

EDIT 12/11/17 The name value in the guibuilder.input is empty:

`<?xml version="1.0" encoding="UTF-8"?>
<con name="" formName="GuiForm"  file="file:/C:/VersionControl/sandpit/GuiBuilderTest1/res/guibuilder/com/thinksmart/guibuilder2/GuiForm.gui" javaFile="file:/C:/WINDOWS/system32/GuiBuilderTest1/src/com/thinksmart/guibuilder2/GuiForm.java" resFile="file:/C:/VersionControl/sandpit/GuiBuilderTest1/src/theme.res" outputFile="file:/C:/Users/William/CN1_Home/.guiBuilder/3979cc5c-798a-41b4-9bda-d7824141986a.ouput" running="file:/C:/Users/William/CN1_Home/.guiBuilder/3979cc5c-798a-41b4-9bda-d7824141986a" />`

The GuiBuilderTest1/codenameone_settings.properties file for this brand new project is:

`codename1.vendor=CodenameOne
codename1.displayName=GuiBuilderTest1
codename1.icon=icon.png
codename1.arg.java.version=8
codename1.languageLevel=5
codename1.secondaryTitle=GuiBuilderTest1
codename1.version=1.0
codename1.mainName=MyApplication
codename1.ios.certificatePassword=
codename1.arg.ios.newStorageLocation=true
codename1.rim.signtoolDb=
codename1.ios.certificate=
codename1.j2me.nativeTheme=nativej2me.res
codename1.android.keystorePassword=
codename1.rim.signtoolCsk=
codename1.android.keystore=
codename1.android.keystoreAlias=
codename1.rim.certificatePassword=
codename1.ios.provision=
codename1.packageName=com.thinksmart.guibuilder2`

The CN1Log file also has the name attribute as ''.

Think.Smart
  • 523
  • 1
  • 5
  • 13
  • I've moved forward a bit by finding this article: https://stackoverflow.com/questions/47061947/codename-one-gui-builder-does-not-work?rq=1 The guilbuilder.input showed a wrong directory - it used the one where eclipse is launched from (where the shortcut is). So after moving the shortcut to the root of the projects i now get the error in the CN1.log_$ file: [EDT] 0:0:31,380 - Exception: java.io.FileNotFoundException - C:\Users\William\.guiBuilder (Access is denied). Changing permissions aren't retained, so how do i tell eclipse to create the .guilbuilder folder in another part of my c: ? – Think.Smart Nov 05 '17 at 01:16
  • BTW, i am running as administrator. I have given my user full control over that folder. But it still error from this CN1 class "at com.codename1.impl.javase.JavaSEPort.createStorageOutputStream(JavaSEPort.java:7376)". The outputFile (from .input file) does not exist so perhaps this is what the error refers to - i cant seem to manually create the file, as every time i do it removed from the folder straight away. The 'running' file is there. – Think.Smart Nov 05 '17 at 01:46
  • The GUI builder and JavaSE port use the home directory from Java SE to determine where they should create the `.codenameone`, `.guiBuilder` and `.cn1` folders. I'm guessing you are seeing similar permission errors for the other two directories required by Codename One, once you have those and have the proper permissions this should work. Ideally we should have better error messages for this situation. – Shai Almog Nov 05 '17 at 04:41
  • My windows PATH variable, hence the one for Java SE, is set to a c:\Program Data... folder. The CN1 source code is getting the path from new File(System.getProperty("user.home"), hence why it is where it is. The guibuilder is creating the 'running' file in that folder fine, so it can create and remove files. I just notice that the 'output' file is never created and i get the [EDT] 0:0:41,528 - Exception: java.io.FileNotFoundException - C:\Users\William\.guiBuilder (Access is denied), everytime. I have treble checked windows folder permissions and i have full access. Run out of ideas. Cheers – Think.Smart Nov 05 '17 at 10:08
  • Used another laptop (windows 10 and latest CN1 plugin) and exactly the same permissions error happened there. – Think.Smart Nov 05 '17 at 11:53
  • I just tried this on my Windows 10 machine and the folders are there. Do you have an anti-virus or corporate software that imposes restrictions? Did you create the folder manually? What's in the properties menu for that .guiBuilder folder? When you created it did you use the case sensitive naming? – Shai Almog Nov 06 '17 at 05:10
  • Have continued to get this working but haven't cracked it. I have changed the JVM's user home, by setting the environment variable "_JAVA_OPTIONS" to "c:/eclipse" (forward slash). When using Eclipse this does successfully create a new .guibuilder folder in c:\eclipse with the preferences and input files. I have made sure i have Full Control privs on that folder.I drag a label component directly onto the empty canvas and it disappears straight away and the log file has the same error as i reported FileNotFoundException. If i try and trick it by creating a .ouput file, it is immediately deleted. – Think.Smart Nov 11 '17 at 14:12
  • The only thing i can do now is read through the CN1 source, starting at 'UndoableEditQueue', because my error is: at java.io.FileOutputStream.open0(Native Method) at java.io.FileOutputStream.open(Unknown Source) at java.io.FileOutputStream.(Unknown Source) at java.io.FileOutputStream.(Unknown Source) at com.codename1.impl.javase.JavaSEPort.createStorageOutputStream(JavaSEPort.java:7376) at com.codename1.io.Storage.createOutputStream(Storage.java:161) at com.codename1.apps.guibuilder.UndoableEditQueue.pushStateToStack(UndoableEditQueue.java:72) – Think.Smart Nov 11 '17 at 14:13
  • Having said that, I cannot locate those CN1 source code classes on github or through general google search. – Think.Smart Nov 11 '17 at 14:31
  • I have seen on various forums that the parameter for FileOutputStream is either the filename or the path and file name. The error specifies a folder name, which other said would be the cause.Could the issue be that the filename isn't being passed as a parameter? – Think.Smart Nov 11 '17 at 17:45
  • I don't understand the problem on your machine. Assuming your user name is `William` then the correct home directory should be `c:\Users\William`. I don't understand why that path isn't writable. I'm not sure `c:/Eclipse` will work properly as access to the home related directories is all over the code as a hard assumption. Am I missing something? BTW we released an update to the plugin over the weekend can you try updating and see if this makes a difference? – Shai Almog Nov 12 '17 at 05:32

1 Answers1

1

I think I've been looking at this in the wrong direction. I think the problem isn't a permission problem but a naming problem. It seems that the project name is blank for some reason which I didn't think would be an option but I guess it is.

The project name should come from codename1.displayName in codenameone_settings.properties. I'll add a fix for this to work with "UnnamedProject" for version 3.81.

Shai Almog
  • 51,749
  • 5
  • 35
  • 65
  • Am willing to given that a test when available. Thanks. FYI, i do have the property value set codename1.displayName=GuiBuilderTest in my properties file of the project. I used a 3rd new home PC today to retry this (windows 10, running Eclipse latest Oxygen as Admin, latest JDK and latest CN1 plugin), by creating a basic CN1 project and adding to it the CN guibuilder (Form) class and still got the same error in the log. Thanks for taking the time to look into this. – Think.Smart Nov 12 '17 at 15:26
  • That is odd! When you look in the XML file `.guiBuilder/guibuilder.input` does it have a name attribute? E.g. i mine I have something like this: ` – Shai Almog Nov 12 '17 at 16:23
  • Can you also post the content of your `codenameone_settings.properties`? – Shai Almog Nov 12 '17 at 16:30
  • Have added info the original question. – Think.Smart Nov 12 '17 at 18:05
  • Maybe the properties file isn't found because of a bug that we used to have and should have been fixed. Try opening the command line, navigate to the eclipse workspace directory and run eclipse from there. See if the name is set correctly then when you launch the GUI builder. I'm thinking it might be related to this: https://github.com/codenameone/CodenameOne/issues/2082 but I'm not sure how yet. I'll try to dig through the code that finds the properties file – Shai Almog Nov 12 '17 at 19:29
  • Yes, it's that bug!!! Looking at your XML it seems to think your GUI builder java file is in "C:/WINDOWS/system32/". – Shai Almog Nov 12 '17 at 19:31
  • Looking deeper into this there are two ways to open the GUI builder and unfortunately they lead to two very different code paths. Which did you use: Right Click file -> "Gui Builder" or "Open With -> GuiBuilder"? – Shai Almog Nov 12 '17 at 19:44
  • Right click file > GuiBuilder. – Think.Smart Nov 12 '17 at 20:01
  • BTW, I ran Eclipse from the command line with the -data switch to set a new workspace. Once in, i created a new project, but the same error and symptoms were there. – Think.Smart Nov 12 '17 at 20:02
  • That did it - Its finally working, by using the Open With option on the file. I will use that as my approach. Thanks so much for your help. – Think.Smart Nov 12 '17 at 20:04
  • Final thing to add is that the new Builder is very impressive from what i've just seen and used. – Think.Smart Nov 12 '17 at 20:25
  • Thanks! OK, I'll fix the code from the GUI Builder command to match the open with logic... I guess the engineer who did this didn't notice it is called in two places. – Shai Almog Nov 13 '17 at 05:03