Editing JComponents on Standard screens - install4j

Is it possible to customize the JComponents on a built-in Standard Screen? Specifically, I've been asked to add a Required Disk Space label on the Installation Components screen that updates as different components are selected. I can get this label to appear by enabling the "Show installation directory chooser" property in the configuration of that screen, but can't figure out a way to prevent the display of the Destination Directory label/text field/button. com.install4j.runtime.beans.screens.ComponentsScreen is not an instance of com.install4j.api.screens.FormPanelContainer so I'm unable to interact with the FormEnvironment as I might on a custom screen.
Is there a way to either add my own dynamic label to this screen or edit/hide unwanted JComponents that are already there?

As of install4j 6.x, there is no was to do that without custom code. I think that the standard screens should just be templates composed of form components, so you can customize them. It's possible that we will do this install4j 7, but right now you would have to derive from
com.install4j.runtime.beans.screens.ComponentsScreen
and override addScreenContent like this:
#Override
protected void addScreenContent(JPanel panel, GridBagConstraints gc) {
super.addScreenContent(panel, gc);
gc.gridy++;
panel.add(new JLabel("your label"));
}

Related

How to create a custom Pane for use in SceneBuilder where controls layout correctly

I am trying to provide some default behavior to a standard Pane in Java FX. I would like to use this Pane in SceneBuilder. For some reason the layout isn't working as I would expect.
I created the following component:
public class GroupBox extends Pane {
public void configureGroupBox(String title) {
//Perform needed set up here.....
}
}
I have exported this control into a JAR file and imported that control into SceneBuilder. I am able to select this control in SceneBuilder and add it to my FXML.
However, the problem starts when I attempt to add controls within it. Even though this extends a javafx.scene.layout.Pane the layout engine of SceneBuilder is pushing all controls to the top left and overlapping them, rather than having no layout instructions.
Is what I am trying to do possible? If so, is there something else I need to do? At this point, my control is just an empty extension of the Pane class.
Thanks.
That is a Scene Builder limitation.
SB provides full operation for builtin containers only (i.e. the ones that are part of JavaFX). For custom containers, it provides limited operations: typically SB allows to drop a component inside but not to move it (because it considers that extending Pane does not imply free positioning of children).

Eclipse rcp view remove icon

My requirement is to remove the title icons for all views but it seems impossible.
First i removed the references to the icons from extension point="org.eclipse.ui.views" in my plugin.xml file.
There is a similar question to this one where it is suggested to override getTitleImage() in the view that extends ViewPart so i did just that and i tryed 2 versions.
#Override
public Image getTitleImage() {
return null;
}
#Override
public Image getTitleImage() {
return new Image(getSite().getShell().getDisplay(), new Rectangle(0, 0, 1, 1));
}
The result no matter which method i used is that some views don't display the icon and some do. For example the first view is always opened without the icon but the following views get the default icon. Also if i have save and restore enabled and restart the application while leaving some views open, the one that is selected doesn't have the icon while the rest do.
This is so frustrating, i just don't get why something so simple has to be so complicated to implement.
I think the problem is views that have not yet been created (so getTitleImage has not been called). In that case the workbench part reference code uses the default image if there is nothing defined in the view definition.
If the above is correct creating an empty image icon file and defining that as the icon in the org.eclipse.ui.views extension in your plugin.xml should work.

ImgButton : How to tell SmartGWT to not concatene state on the name of file source?

private ImgButton button = new ImgButton();
...
button.setSrc("iconName.jpg");
GWT or SmartGWT, I cannot tell exactly, generate state word to concatene it on the name of file.
Example to clarify :
On focus, iconName.jpg become iconName_Focus.jpg
On mouse down click, iconName.jpg become iconName_Down.jpg
On over, iconName.jpg become iconName_Over.jpg
Because these images are custom images, I want to tell GWT to take a default image when I didn't provide the corresponding image.
For example, when over event is fire and iconName_Over.jpg does not exist then use iconName.jpg.
Use the setShow{State} or setShow{State}Icon methods accordingly. For example for disabling the mouse down state, use setShowDown(Boolean.FALSE). For not showing a different icon when the mouse goes down on the button, use the setShowDownIcon(Boolean.FALSE). The rest of the actions have accordingly named methods you can look up at the ImgButton's javadoc page.

GWT Editors for readonly and edit mode

GWT's Editor framework is really handy and it can not only be used for editing POJOs but also for read-only display.
However I am not entirely sure what the best practice is for doing inline edits.
Let's assume I have a PersonProxy and I have one Presenter-View pair for displaying and editing the PersonProxy. This Presenter-View should by default display the PersonProxy in read-only mode and if the user presses on a edit button it should allow the user to edit the PersonProxy object.
The solution I came up with was to create two Editors (PersonEditEditor and PersonDisplayEditor) that both added via UiBinder to the View. The PersonEditEditor contains
ValueBoxEditorDecorators and the PersonDisplayEditor contains normal Labels.
Initially I display the PersonDisplayEditor and hide PersonEditEditor.
In the View I create two RequestFactoryEditorDriver for each Editor and make it accessable from the Presenter via the View interface. I also define a setState() method in the View interface.
When the Presenter is displayed for the first time I call PersonDisplayDriver.display() and setState(DISPLAYING).
When the user clicks on the Edit button I call PersonEditDriver.edit() and setState(EDITING) from my Presenter.
setState(EDITING) will hide the PersonDisplayEditor and make the PersonEditEditor visible.
I am not sure if this is the best approach. If not what's the recommended approach for doing inline edits? What's the best way to do unit-testing on the Editors?
If you can afford developing 2 distinct views, then go with it, it gives you the most flexibility.
What we did in our app, where we couldn't afford the cost of developing and maintaining two views, was to bake the two states down into our editors, e.g. a custom component that can be either a label or a text box (in most cases, we simply set the text box to read-only and applied some styling to hide the box borders).
To detect which mode we're in, because we use RequestFactoryEditorDriver (like you do), we have our editors implement HasRequestContext: receiving a null value here means the driver's display() method was used, so we're in read-only mode. An alternative would be to use an EditorVisitor along with some HasReadOnly interface (which BTW is exactly what RequestFactoryEditorDriver does to pass the RequestContext down to HasRequestContext editors).
Yes,Presenter-View pair should be. But Here two ways to achieve this feature if you like to go with:
1) Integrate Edit/View code design in one ui.xml i.e.Edit code in EDitHorizonatlPanel and View code in ViewHorizontalPanel.The panel has different id. By using id, show/hide panel with display method. if getView().setState() ==Displaying then show ViewHorizontalPanel and if getView().setState()==Editing then show EditHorizontalPanel.
2) Instead of using labels, Use textboxes only. set Enable property is false when you need it in view mode otherwise true
You have created two Presenter/view but I think if Edit/View function has similar code so no need to rewrite similar code again and again for view purpose.
If a big project has so many Edit/View function and you will create such type of multiple View/Presenter than your project size become so huge unnecessary.
I think that whatever I have suggest that might be not good approach but a way should be find out which help to avoid code replication.

SWT Controls with predefined styles

I want to have in my SWT project controls (Button-s, Text-s, etc) with predefined styles. My first idea was to extend for example org.eclipse.swt.widgets.Text class, set some settings and use that new classes instead of original, but get org.eclipse.swt.SWTException: Subclassing not allowed exception. How to do that right ?
You have to override checkSubclass method to do nothing, otherwise it will complain that subclassing not allowed - because usually you shouldn't really override standard components.
#Override
protected void checkSubclass() {
// Disable the check that prevents subclassing of SWT components
}
You also should consider building custom widgets containing primitive controls using delegation. For example you can build MyText which will contain Text widget inside with custom setup.
Thing to remember is SWT provides standard controls which looks natively on each on platform. Anyway polishing standard components is still allowed and even a must in production software.
See the SWT Faq for this concern. There you'll find also a link howto write custom widgets