I’ve just checked in the initial bits to use lightweight dialogs in your e4 + JavaFX applications. You can see it in action in the short video from below
Useage is fairly simple. First you need to have dialog implementation like this:
static class OpenProjectDialogImpl extends TitleAreaDialog { private ListView<Project> list; private final CommandService cmdService; @Inject public OpenProjectDialogImpl(Workbench workbench, CommandService cmdService, @Service List<ProjectService> projectServiceList) { super("Open project", "Open project", "Open an existing project"); this.cmdService = cmdService; addDefaultButtons(); setMaxWidth(500); setMaxHeight(500); setId("open-project-dialog"); list = new ListView<>(); list.setMinWidth(600); list.setCellFactory(v -> new SimpleListCell<Project>( p -> labelExtractor(p, projectServiceList), p -> cssProvider(p,projectServiceList))); list.setItems(FXCollections.observableArrayList( workbench.getProjectList())); setClientArea(list); } @Override protected void handleOk() { if( list.getSelectionModel().getSelectedItem() != null ) { cmdService.execute("org.eclipse.fx.code.compensator.app.command.openproject", Collections.singletonMap("projectId", list.getSelectionModel().getSelectedItem().getProjectId())); super.handleOk(); } } }
and displaying it is nothing more than:
public class OpenProjectDialog { @Execute public void open(LightWeightDialogService dialogService) { dialogService.openDialog(OpenProjectDialogImpl.class, ModalityScope.WINDOW); } }
As you can see in the video you can choose how the dialog is opened & closed. This is done through an OSGi-Service of type LightweightDialogTransitionService
:
@Component public class FadeDialogTranstionServiceImpl extends FadeDialogTranstionService implements LightweightDialogTransitionService { @Override protected void configureFadeIn(FadeTransition transition) { super.configureFadeIn(transition); transition.setInterpolator(Interpolator.EASE_OUT); } @Override protected void configureFadeOut(FadeTransition transition) { super.configureFadeOut(transition); transition.setInterpolator(Interpolator.EASE_OUT); } }
Pingback: JavaFX links of the week, April 27 // JavaFX News, Demos and Insight // FX Experience
hi Tom,
Yesterday me and my colleague (Govind) presented a topic JavaFX in Eclipse RCP @ https://wiki.eclipse.org/Eclipse_DemoCamps_Mars_2015/Bangalore and we got very good response from audience. People were excited to see our demos
Great any slides, … available?
“This is done through an OSGi-Service of type LightweightDialogTransitionService”
that means you need to have your own implementation of LightweightDialogTransitionService as an OSGi-Service, where you can also adjust transition (easy out/in, duration, etc)
P.S. It wasn’t clear for me for a while, could be a bit difficult for somebody else.