New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open extended visual component in project not working anymore #129

Closed
imartinbe opened this Issue Apr 4, 2014 · 17 comments

Comments

Projects
None yet
2 participants
@imartinbe

imartinbe commented Apr 4, 2014

We just migrated from gradle 1.7/plugin 1.2.6 to gradle 1.11/plugin 1.3.0 and are facing a new issue :
We have a class in the project which extends a JTextField. When opening forms which contain this class, we get the error
"Error in loading component: [JFrame]->jPanel1->CommentBox
Cannot load component class xxxx" where xxxx is the extended JTextField
We have tried to add the component to the palette, but it does not help.
This was working in our previous installations.
Is there a new dependency to add in the gradle script?

@kelemen

This comment has been minimized.

Owner

kelemen commented Apr 4, 2014

The plugin does nothing to explicitly support this. So, I'm not sure if it's the plugin's fault. However, to find what could be the cause, you could try setting "Tools/Options/Miscellaneous/Gradle/Build script evaluation strategy" to "Idea plugin based" (This strategy is used for Gradle 1.7 but a different for 1.11). If adjusting the strategy solves the problem, then the issue is really related to the plugin.

Anyway, I have seen this issue with some components while working perfectly fine with others (so sadly, this is not as simple as this feature is broken in NB).

@imartinbe

This comment has been minimized.

imartinbe commented Apr 4, 2014

We just did some tests :

  • using the plugin 1.2.6 with gradle 1.11 -> OK
  • using the plugin 1.3.0 with gradle 1.7 -> not OK
  • using the plugin 1.3.0 with gradle 1.11 -> not OK, whichever evaluation strategy is choosen.
@kelemen

This comment has been minimized.

Owner

kelemen commented Apr 4, 2014

Can you please check which is the first broken version?

Also, is the custom component in another project or in the same as the project using it?

@imartinbe

This comment has been minimized.

imartinbe commented Apr 4, 2014

It's in the same project. I will test with all versions

@kelemen

This comment has been minimized.

Owner

kelemen commented Apr 4, 2014

I have tried that this issue is printed if the project is not built. Otherwise, this seems to work for me. Given that it works for you in 1.2.6, I would guess, that the plugin does not tell NB the approriate build output directory in your case. Did you cusomize the build output directory? Does the project has its own build.gradle in its project directory?

@kelemen

This comment has been minimized.

Owner

kelemen commented Apr 4, 2014

Also, can you share the relevant parts of ~/NetBeans/X.Y/var/log/messages.log?

@imartinbe

This comment has been minimized.

imartinbe commented Apr 4, 2014

I have done the test with the different versions. It seems only 1.2.6 is working. 1.2.7 is already broken. But clicking on "allow using gradle 1.8 API" does not change the behaviour.
The exact version we were using is the build 1.2.6.2...

Concerning the project, the build output directory is not customized.
The project is a subproject, so the root project has a build.gradle and a common.gradle; the subproject has its build.gradle too.

@kelemen

This comment has been minimized.

Owner

kelemen commented Apr 4, 2014

Disabling 1.8 API needs project reloading (preferably even NB restart). Anyway, this is a strange issue and I cannot reproduce it. So, I'll try to look at NB sources and ask NB developers what information this feature relies on.

@imartinbe

This comment has been minimized.

imartinbe commented Apr 4, 2014

Thanks! I am checking on my side if I find a clue.

@imartinbe

This comment has been minimized.

imartinbe commented Apr 4, 2014

I just created a small single project TestExtension with 3 classes :

  • testMain.main
  • testExtensions.TodayBox
  • testMain.MainJPanel

The TodayBox is simple :

package testExtensions;

import java.util.EventObject;
import javax.swing.JTextField;
import static javax.swing.SwingConstants.CENTER;

public class TodayBox  extends JTextField
{
  public TodayBox()
  {
     super();
     this.setHorizontalAlignment( CENTER );
  }
  public boolean afterValueChanged( EventObject evt )
  {
      boolean changed = false;
      if (! this.getText().equals("Today")){
          this.setText( "Today" );
          changed = true;
      }
      return changed;
  }
}

MainJPanel is a JPanel.
the main class opens the MainJPanel.
I run a Clean & Build which works fine.
When I want to add a TodayBox component onto MainJPanel, I get the error :

Cannot load component class testExtensions.TodayBox from project C:\Users\ima\Documents\NetBeansProjects\TestExtension.
The class could not be found. Note the class must be compiled and must be part of the sources or dependencies of the project where the target GUI form belongs to.

@imartinbe

This comment has been minimized.

imartinbe commented Apr 4, 2014

capture

@kelemen

This comment has been minimized.

Owner

kelemen commented Apr 4, 2014

Thanks, I can reproduce the issue with this.

@kelemen kelemen closed this in 1798ec1 Apr 4, 2014

@kelemen

This comment has been minimized.

Owner

kelemen commented Apr 4, 2014

Should now be fixed in master. I'm not sure when a new version will be released but you may build the plugin from the sources for now. There were some relatively big refactorings related to project properties which I did not throughly test but seems to work fine (so there shouldn't be any blocker). If you choose to use the plugin built from the sources, feel free to report regressions.

@kelemen

This comment has been minimized.

Owner

kelemen commented Apr 4, 2014

Just notices that there are quite a few test failures when building with NB 8.0. I believe this to be an NB bug. Anyway, you should ignore test failures (skip tests) for now as these problems are only there while unit testing. I'll try to find a workaround for these test issues.

@kelemen

This comment has been minimized.

Owner

kelemen commented Apr 5, 2014

As it turned out, the problem is not the version of NB you build with but the JDK. So, tests won't run with JDK 8 for now.

@imartinbe

This comment has been minimized.

imartinbe commented Apr 7, 2014

Thanks a lot! I will compile it directly.

@imartinbe

This comment has been minimized.

imartinbe commented Apr 7, 2014

I have recompiled the plugin at version v1.3.0 with cherry-picking the commit 1798ec1. This works fine (I wanted to keep the most stable version with just the fix, and also with Netbeans running with jdk 1.6). Thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment