I am trying to create a custom Emitter for BIRT. I created a Plugin, here works everything fine the problem is that I need it as a Java class.
The problem is when I try to Render in my own Emitter it says that the custom RenderOption is not supported.
Here is some of my Code:
IJsonRenderOption:
package org.eclipse.birt.report.engine.emitter.json;
import org.eclipse.birt.report.engine.api.IRenderOption;
public interface IJsonRenderOption extends IRenderOption {
public static final String OUTPUT_FORMAT_JSON = "json";
public static final String OUTPUT_EMITTERID_JSON = "org.eclipse.birt.report.engine.emitter.json";
}
JsonRenderOption:
package org.eclipse.birt.report.engine.emitter.json;
import org.eclipse.birt.report.engine.api.IRenderOption;
import org.eclipse.birt.report.engine.api.RenderOption;
public class JsonRenderOption extends RenderOption implements IJsonRenderOption {
public JsonRenderOption() {
super();
}
public JsonRenderOption(IRenderOption options) {
super(options);
}
}
I hope somebody can help me
Greetz
Try importing the following packages
importPackage(org.eclipse.birt.report.engine.emitter.json);
importPackage(org.eclipse.birt.report.engine.api.IRenderOption);
importPackage(org.eclipse.birt.report.engine.api.RenderOption);
Related
I would like to use Koin library from Java. According to this tutorial, Koin modules can be written in Kotlin even using Java in the rest of a project.
https://insert-koin.io/docs/quickstart/android-java/
I use also #JvmField annotation for the module field because in the source code of this tutorial it is used
https://github.com/InsertKoinIO/koin/blob/master/quickstart/getting-started-koin-android/app/src/main/kotlin/org/koin/sample/AppModule.kt
In my project I use koinInjector which is a list of modules
import org.koin.android.java.KoinAndroidApplication;
import org.koin.core.KoinApplication;
import static org.koin.core.context.DefaultContextExtKt.startKoin;
import static com.x.y.KoinInjectorKt.koinInjector;
public class App extends Singleton {
#Override
public void onCreate() {
super.onCreate();
KoinApplication koin = KoinAndroidApplication
.create(this)
.modules(koinInjector);
startKoin(koin);
}
}
KoinInjector.kt:
#JvmField
val koinInjector: List<Module> = listOf(
localDbModule,
)
But during build I get the error:
error: cannot find symbol
import static com.x.y.KoinInjectorKt.koinInjector;
^
symbol: class KoinInjectorKt
location: package com.x.y
I had to add
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10"
to build.gradle and
apply plugin: 'kotlin-android' to build.gradle (app)`
Now it works.
Thanks #Jeroen Steenbeeke for your comment
Try to replace the code with -
import org.koin.android.java.KoinAndroidApplication;
import org.koin.core.KoinApplication;
import static org.koin.core.context.DefaultContextExtKt.startKoin;
import static com.x.y.KoinInjectorKt.koinInjector;
public class App extends Singleton {
#Override
public void onCreate() {
super.onCreate();
KoinApplication koin = KoinAndroidApplication
.create(this)
.modules(listOf(localDbModule));
startKoin(koin);
}
}
remove this import
'import static com.x.y.KoinInjectorKt.koinInjector;'
and write your code like this
public class App extends Singleton {
#Override
public void onCreate() {
super.onCreate();
List<Module> list = new ArrayList<Module>();
list.add(localDbModule);
KoinApplication koin = KoinAndroidApplication
.create(this)
.modules(list);
startKoin(koin);
}
}
I want to open pdf files using the code below, but method getHostServices(); is not found even though i have the right imports.
import javafx.application.HostServices;
ClinicFiles clinicFiles = (ClinicFiles) listViewClinic.getSelectionModel().getSelectedItem();
HostServices hostServices = getHostServices();
hostServices.showDocument(clinicFiles.getAbsolutePath());
Probably, your class is not extending from javafx.application.Application:
For example:
import javafx.application.Application;
import javafx.application.HostServices;
public class App extends Application {
public void method(String[] args) {
ClinicFiles clinicFiles = (ClinicFiles) listViewClinic.getSelectionModel().getSelectedItem();
HostServices hostServices = getHostServices();
hostServices.showDocument(clinicFiles.getAbsolutePath());
}
}
I'm sure, this question can be answered very quickly by a experienced Java-developer. But as I am not that familiar with Java I don't get how to source out the #Config part of Selenium in Java. It would be optimal, if I could have a config-file or -class where I can put the data (browser, website etc.) on the one hand and on the other hand the test-files.
Here is an example of a test file:
package com.example_test.selenium;
import io.ddavison.conductor.Browser;
import io.ddavison.conductor.Config;
import io.ddavison.conductor.Locomotive;
import org.junit.Test;
#Config(
browser = Browser.CHROME,
url = "http://example.com"
)
public class test_a_Home extends Locomotive {
#Test
public void testifExists() {
validatePresent(site_a_Home.EL_NEWCUSTOMERBANNER);
}
}
Now I would like to have a seperate file called tests.java where I can call the "test_a_Home"-function. If I try it just with
package com.example_test.selenium;
public class tests {
test_a_Home test = new test_a_Home();
test.testifExists();
}
I am receiving the error, that "testifExists()" cannot be resolved.
I tried changing the public void testifExists() to public int testifExists() and tried to call it with int res = test.testifExists(); in the class tests but this does not work either, as I receive the error java.lang.Exception: Method testNewCustomersBannerExists() should be void.
I would be very happy, if anyone could help me. If you need more information please feel free to mention it. Thank you.
If you want your design to be like this, then you need to organize your tests as such:
public class BasePage {
public Locomotive test;
public BasePage(Locomotive baseTest) {
test = baseTest;
}
}
public class test_a_Home extends BasePage {
public test_a_Home(Locomotive baseTest) {
super(baseTest);
}
public void testifExists() {
test.validatePresent(site_a_Home.EL_NEWCUSTOMERBANNER);
}
}
Then your test class, i'd recommend creating a base class as well:
#Config(
browser = Browser.CHROME,
url = "http://example.com"
)
public class BaseTest extends Locomotive {}
And then your test class:
public class tests extends BaseTest {
test_a_Home test = new test_a_Home(this);
#Test
public void testHomePage() {
test.testIfExists();
}
}
Also you state state:
I don't get how to source out the #Config part of Selenium in Java.
Please make sure you know, that using Conductor abstracts you from the Selenium API.. It just wraps it. #Config does not belong to Selenium, it belongs to Conductor.
I just downloaded the play framework from their site and am working through this tutorial.
I've noticed the framework creates the folders app/controllers and app/views, but not a models folder. I created it manually and added Task.java to it. When I get to the section entitled "Rendering the first page" and open localhost:9000/tasks I get a compilation error that says package play.models does not exist. Here is what my Task.java looks like:
package models;
import java.util.*;
public class Task {
public Long id;
#Required
public String label;
public static List<Task> all() {
return new ArrayList<Task>();
}
public static void create(Task task) {
}
public static void delete(Long id) {
}
}
Here is application.java, the file generating the compilation error:
package controllers;
import play.*;
import play.mvc.*;
import views.html.*;
import play.data.*;
import play.models.*; // COMPILATION ERROR: "package play.models does not exist"!
public class Application extends Controller {
static Form<Task> taskForm = Form.form(Task.class);
public static Result index() {
//return ok(index.render("Your new application is ready."));
return redirect(routes.Application.tasks());
}
public static Result tasks() {
return ok(views.html.index.render(Task.all(), taskForm));
}
public static Result newTask() {
return TODO;
}
public static Result deleteTask(Long id) {
return TODO;
}
}
I believe it's supposed to be import models.Task; as opposed to import play.models.*;
That's quite confusing (IMHO) step in this tutorial, instead scroll down to Persist the tasks in a database section which describes preparing a model to cooperate with DB :) (it extends Model class, uses proper annotations, etc)
As you recognized it yet, you need to create a models package yourself.
Also as cYn wrote: you should import models like models.SomeModel into your controller
You are correct HukeLau_DABA , the Play will not create the models package for you. you have to create it.
I got these imports in my Application controller class. I got this sample play application running.
import play.api._
import play.api.mvc._
import play.api.data.Form
import play.api.data.Forms._
import models.Task
and another thing in Eclipse is it will not import the necessary imports automatically.
it is bit pain now, once the IDE support get better I hope this will change.
To familirise myself with the Play 2.0 Framework, I've been following the Play 2.0 introduction tutorial. Unforunatly, I can't get the Ebean persistence to work. My Task.java looks like this:
package models;
import java.util.*;
import play.db.*;
import play.data.validation.Constraints.*;
import javax.persistence.*;
#Entity
public class Task {
#Id
public Long id;
#Required
public String label;
public static List<Task> all() {
return find.all();
}
public static void create(Task task) {
task.save();
}
public static void delete(Long id) {
find.ref(id).delete();
}
}
But on running the applicaton, find and save can't be resolved. I guess I forgot to import a module, but I can't figure out which on it is ...
I believe you need to extend Model class.
#Entity
public class Task extends Model {
....
}
Hope this helps.
As Dan W. already said, you need to extend the Model class:
#Entity
public class Task extends Model {
....
}
You also have to add the following static methode:
public static Finder<Long,Task> find = new Finder(
Long.class, Task.class
);
Also make sure you added following lines to your application.conf file to enable the database:
db.default.driver=org.h2.Driver
db.default.url="jdbc:h2:mem:play"
ebean.default="models.*"