I am developing 'Pure' Eclipse 4 RCP application. I want to open a 'part' using method like page.openEditor(IEditorInput input, String editorId, boolean activate); in e3.x
How can i do this?
You use EPartService to manage parts:
#Inject
private EPartService partService;
MPart mpart = partService.showPart("part id", PartState.ACTIVATE);
if necessary you can then access your part class:
MyPart myPart = (MyPart)mpart.getObject();
Related
I am developing an Eclipse application, using the latest version of Eclipse RCP and RAP 2022-12.
I have a target platform, a product file, a complete Maven/Tycho build system working with unit and integration test.
My need now is to persist to a DB (my preference here is MongoDB) a simple POJO class, for example:
/**
* The logged user.
*/
public class User implements IMASUser {
/**
* Developer user name
*/
public static final String DEVELOPER_USER_NAME = "developer"; //$NON-NLS-1$
private static final SimpleDateFormat DB_DATE_FORMAT = new SimpleDateFormat(CommonConstants.DB_DATE_FORMAT_PATTERN);
private int m_id;
private String m_username;
private String m_password;
private String m_name;
private String m_surname;
private String m_domainID;
private String m_office;
private String m_blockCode;
private String m_eMail;
private AccessLevel m_accessLevel;
private boolean m_isBeta; // Access to beta program
private boolean m_isActive; // Currently working (hired and actively developing)
private Date m_loginDate;
private Date m_lastLoginDate;
......
What is the most "common" and easy way to integrate a persistence framework into an Eclipse RCP application?
In a standard Java app I would try Hibernate or Spring Boot but here the integration in the OSGi environment is somehow problematic.
I tried to integrate:
Spring Boot JPA
Hibernate
Eclipselink
adding the dependencies to the target platform.
All of those have problems runtime discovering the needed service and classes.
For sure I'm missing some experience in Eclipse/RCP/OSGi.
Can you share some of your experience (if any), I can't find any up to date documentation.
Thank you!
I have to implement a custom action to search the windows registry for the installed version of the dotnet framework. Therefore I thought to extend the ReadRegistryValueAction to integrate my individual search algorithm. But the custom action will not be found at the IDE. So I extends the action from the AbstractInstallAction and included the RegistryRoot class to configure the action inside the IDE the same way as with provided registry actions of install4j framework.
public class CheckDotNetInstallationAction extends AbstractInstallAction {
private RegistryRoot registryRoot;
public RegistryRoot getRegistryRoot() {
return registryRoot;
}
public void setRegistryRoot(RegistryRoot registryRoot) {
this.registryRoot = registryRoot;
}
#Override
public boolean install(InstallerContext paramInstallerContext)
throws UserCanceledException {
// do custom search
return false;
}
}
But instead to get a dropdown list, there is only a blank field. I expected also a dropdown list the same way as in the present registry action. Now there are two questions:
Is it possible to extends existing actions/screens/forms and to use and configure it in the IDE or is it necessary to extends from the AbstractInstallAction?
How can I use classes like RegistryRoot for my custom components the same way as they are used in the actions provided by the install4j framework? Specifically the way to configure these components inside the IDE.
You have to add add a BeanInfo class and set an enumeration mapper. See the source file
samples/customCode/SampleActionBeanInfo.java
in your install4j install4j Installation and and look for the the call to setEnumerationMappers.
I'm using gwtupload lib for uploading file(s) in my GWT project. https://code.google.com/p/gwtupload/wiki/GwtUpload_GettingStarted
Case: I've 3 - 4 MultiUploader on same page. Its uploading fine. But when I try to upload same file in other component its not allowing. I figured out that if we click on remove button maintained by gwtupload. Its allow to upload same file on other component. So how to fire remove button click. Check image attached below.
This behavior is in this way by design, gwtupload prevents uploading the same file-name if it was successful previously in any instance of uploaders.
You can disable the default feature just calling the avoidRepeatFiles method though.
MultiUploader uploader1 = new MultiUploader();
uploader1.avoidRepeatFiles(false);
After digging down source code of gwtupload. I found the solution. If you want to have multiple SingleUploader or MultiUploader on same page. You need to change below lines and need to create .jar file of gwtupload.
private static HashSet<String> fileDone = new HashSet<String>();
private static HashSet<String> fileUploading = new HashSet<String>();
private static List<String> fileQueue = new ArrayList<String>();
to (Remove static)
private HashSet<String> fileDone = new HashSet<String>();
private HashSet<String> fileUploading = new HashSet<String>();
private List<String> fileQueue = new ArrayList<String>();
in File Uploader.java located in package gwtupload.client
I've installed WindowBuilder in Eclipse Juno and am able to create Details Page. The generated source code:
/**
* Initialize the details page.
* #param form
*/
public void initialize(IManagedForm form) {
managedForm = form;
}
/**
* Create contents of the details page.
* #param parent
*/
public void createContents(Composite parent) {
FormToolkit toolkit = managedForm.getToolkit();
parent.setLayout(new FillLayout());
//
requires a ManagedForm to be initialised. A a very Java newbie I've been completely stuck as to where to get this object. I've probably missed the obvious but help would be very much appreciated.
Check out the ManagedForm class. Create a new class that inherits from ManagedForm and you got yourself an IManagedForm implementation:
public class MyManagedForm extends ManagedForm {
public MyManagedForm(Composite parent) {
super(parent);
}
}
I'd recommend using an Editor like Eclipse and getting the source code into it so that you can easily browse the documentation and the API's classes in general. Lars Vogel's introduction to Eclipse APIs is a good read, too.
I'm trying to extract parts of a GWT application into many separate dialogs that can be invoked from php.
Existing state:
We have a GWT appplication that is deployed to JBoss as a WAR.
The app has a single module with a signle entry point.
The main JSP sets up the environment and then has some JS that loads the .nocache.js using document.write();
The entry point's onModuleLoad() creates a panel to fill the browser and adds it to the root using RootPanel.get("root").add();
When some event happens (e.g., user presses button) we pop up a DialogBox by instatiating a subclass and calling center() or setVisible()
Desired state:
We want a php app with multiple pages, to be able to invoke various DialogBox subclasses.
I think that the php side should use JS function calls that use document.write();
As for the GWT side, the options I see are:
One module with multiple entry points.
Multiple modules.
Does anyone have any experience or understanding of what would be the best practice here?
If I've understood right, you need to call GWT methods from Javascript.
You can use JSNI.
But I think you should try gwt-exporter on the GWT side. Overview. Tutorial.
It's simple GWT module to create JS_API for your GWT modules.
Not pretending to be the best practices, just quick example.
On the server-side you include an existing GWT module with DialogBoxes on every page.
You need to modify this GWT module or create new like this.
public class GwtModule implements EntryPoint {
#Override
public void onModuleLoad() {
// exportable class
DialogBoxManager dbm = new DialogBoxManager();
// export all Exportable classes of module
ExporterUtil.exportAll();
// needed cause JS_API will be available only after the GWT is loaded
onLoad();
}
// call when GWT module loaded
private native void onLoad() /*-{
$wnd.loaded();
}-*/;
DialogBoxManager looks like this
#Export
#ExportPackage("pkg")
public class DialogBoxManager implements ClickHandler, Exportable {
private DialogBox db;
public DialogBoxManager() {
this.db = new DialogBox();
}
#Export("showDB")
public void showDialog() {
db.setVisible(true);
db.center();
db.show();
}
#Override
public void onClick(ClickEvent event) {
showDialog();
}
}
String values in #Export("show"), #ExportPackage("pkg"), etc. annotations will be used in our JS_API calls for annotated GWT methods (you can export also fields).
You can use just #Export (as I did for DialogBoxManager).
When GWT module is loaded in your JS library you can realize initialization of JS_API member or what you need
var dbManager = null;
...
function loaded() {
dbManager = new pkg.DialogBoxManager();
}
and then just call JS_API like this
function showDB() {
if (dbManager != null) {
dbManager.showDB();
}
}