org.uberfire.client.workbench.Workbench类的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(9.9k)|赞(0)|评价(0)|浏览(150)

本文整理了Java中org.uberfire.client.workbench.Workbench类的一些代码示例,展示了Workbench类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Workbench类的具体详情如下:
包路径:org.uberfire.client.workbench.Workbench
类名称:Workbench

Workbench介绍

[英]Responsible for bootstrapping the client-side Workbench user interface by coordinating calls to the PanelManager and PlaceManager. Normally this happens automatically with no need for assistance or interference from the application. Thus, applications don't usually need to do anything with the Workbench class directly.

Delaying Workbench Startup

In special cases, applications may wish to delay the startup of the workbench. For example, an application that relies on global variables (also known as singletons or Application Scoped beans) that are initialized based on response data from the server doesn't want UberFire to start initializing its widgets until that server response has come in.

To delay startup, add a Startup Blocker before Errai starts calling AfterInitialization methods. The best place to do this is in the PostConstruct method of an EntryPoint bean. You would then remove the startup blocker from within the callback from the server:

@EntryPointpublic class MyMutableGlobal() { 
 @Inject private Workbench workbench; @Inject private Caller remoteService;// set up by a server call. don't start the app until it's populated! 
 private MyParams params; @PostConstructprivate void earlyInit() { 
workbench.addStartupBlocker(MyMutableGlobal.class); 
} 
 @AfterInitializationprivate void lateInit() { 
remoteService.call(new  
 RemoteCallback{ 
public void callback(MyParams params) { 
MyMutableGlobal.this.params = params; 
workbench.removeStartupBlocker(MyMutableGlobal.class); 
} 
}).fetchParameters(); 
} 
}

[中]通过协调对PanelManager和PlaceManager的调用,负责引导客户端工作台用户界面。通常情况下,这会自动发生,不需要应用程序的帮助或干扰。因此,应用程序通常不需要直接对Workbench类执行任何操作。
延迟工作台启动
在特殊情况下,应用程序可能希望延迟工作台的启动。例如,依赖基于服务器响应数据初始化的全局变量(也称为单例或应用程序范围的bean)的应用程序不希望UberFire在收到服务器响应之前开始初始化其小部件。
要延迟启动,请在Errai开始调用AfterInitialization方法之前添加启动阻止程序。最好的方法是在入口点bean的PostConstruct方法中。然后从服务器的回调中删除启动阻止程序:

@EntryPointpublic class MyMutableGlobal() { 
 @Inject private Workbench workbench; @Inject private Caller remoteService;// set up by a server call. don't start the app until it's populated! 
 private MyParams params; @PostConstructprivate void earlyInit() { 
workbench.addStartupBlocker(MyMutableGlobal.class); 
} 
 @AfterInitializationprivate void lateInit() { 
remoteService.call(new  
 RemoteCallback{ 
public void callback(MyParams params) { 
MyMutableGlobal.this.params = params; 
workbench.removeStartupBlocker(MyMutableGlobal.class); 
} 
}).fetchParameters(); 
} 
}

代码示例

代码示例来源:origin: org.uberfire/uberfire-runtime-plugins-client

@PostConstruct
public void init() {
  workbench.addStartupBlocker(RuntimePluginStartup.class);
}

代码示例来源:origin: org.uberfire/uberfire-workbench-client

@Test
public void shouldStartWhenUnblocked() throws Exception {
  workbench.addStartupBlocker(WorkbenchStartupTest.class);
  workbench.removeStartupBlocker(WorkbenchStartupTest.class);
  verify(appReadyEvent,
      times(1)).fire(any(ApplicationReadyEvent.class));
}

代码示例来源:origin: kiegroup/appformer

/**
 * Causes the given responsible party to no longer block workbench initialization.
 * If the given responsible party was not already in the blocking set (either because
 * it was never added, or it has already been removed) then the method call has no effect.
 * <p>
 * After removing the blocker, if there are no more blockers left in the blocking set, the workbench UI is
 * bootstrapped immediately. If there are still one or more blockers left in the blocking set, the workbench UI
 * remains uninitialized.
 * @param responsibleParty any Class object that was previously passed to {@link #addStartupBlocker(Class)}.
 * Must not be null.
 */
public void removeStartupBlocker(Class<?> responsibleParty) {
  if (startupBlockers.remove(responsibleParty)) {
    logger.info(responsibleParty.getName() + " is no longer blocking startup.");
  } else {
    logger.info(responsibleParty.getName() + " tried to unblock startup, but it wasn't blocking to begin with!");
  }
  startIfNotBlocked();
}

代码示例来源:origin: org.kie.uberfire/kie-uberfire-perspective-editor-client

@Override
  public boolean error( Object o,
             Throwable throwable ) {
    workbench.removeStartupBlocker( PerspectiveEntryPoint.this.getClass() );
    return false;
  }
} ).loadAll();

代码示例来源:origin: org.uberfire/uberfire-workbench-client

@Test
public void shouldNotStartWhenBlocked() throws Exception {
  verify(appReadyEvent,
      never()).fire(any(ApplicationReadyEvent.class));
  workbench.addStartupBlocker(WorkbenchStartupTest.class);
  workbench.startIfNotBlocked();
  verify(appReadyEvent,
      never()).fire(any(ApplicationReadyEvent.class));
}

代码示例来源:origin: kiegroup/appformer

private void bootstrap() {
  logger.info("Starting workbench...");
  ((SessionInfoImpl) currentSession()).setId(((ClientMessageBusImpl) bus).getSessionId());
  layout.onBootstrap();
  addLayoutToRootPanel(layout);
    final PerspectiveActivity homePerspective = getHomePerspectiveActivity();
    if (homePerspective != null) {
      appReady.fire(new ApplicationReadyEvent());
    handleStandaloneMode(Window.Location.getParameterMap());

代码示例来源:origin: kiegroup/appformer

private void goToHomePerspective() {
  final PerspectiveActivity homePerspectiveActivity = workbench.getHomePerspectiveActivity();
  if (homePerspectiveActivity != null) {
    final String homePerspectiveIdentifier = homePerspectiveActivity.getIdentifier();
    if (hasAccessToPerspective(homePerspectiveIdentifier)) {
      placeManager.goTo(homePerspectiveIdentifier);
    }
  }
}

代码示例来源:origin: org.uberfire/uberfire-workbench-client

@Before
public void setup() {
  when(bm.lookupBeans(any(Class.class))).thenReturn(Collections.emptyList());
  when(dragController.getBoundaryPanel()).thenReturn(new AbsolutePanel());
  doNothing().when(workbench).addLayoutToRootPanel(any(WorkbenchLayout.class));
  when(permissionManager.getAuthorizationPolicy()).thenReturn(authorizationPolicy);
  when(authorizationManager.authorize(any(Resource.class),
                    any(User.class))).thenReturn(true);
  when(bm.lookupBeans(PerspectiveActivity.class)).thenReturn(Arrays.asList(perspectiveBean1,
                                       perspectiveBean2));
  when(perspectiveBean1.getInstance()).thenReturn(perspectiveActivity1);
  when(perspectiveBean2.getInstance()).thenReturn(perspectiveActivity2);
  when(perspectiveActivity1.getIdentifier()).thenReturn("perspective1");
  when(perspectiveActivity2.getIdentifier()).thenReturn("perspective2");
  when(perspectiveActivity2.isDefault()).thenReturn(true);
}

代码示例来源:origin: org.kie.uberfire/kie-uberfire-perspective-editor-client

public void callback( List<PerspectiveEditor> editors ) {
    for ( PerspectiveEditor editor : editors ) {
      perspectiveEditorGenerator.generate( editor );
    }
    workbench.removeStartupBlocker( PerspectiveEntryPoint.this.getClass() );
  }
}, new ErrorCallback<Object>() {

代码示例来源:origin: kiegroup/appformer

@Test
public void shouldNotStartWhenBlocked() throws Exception {
  verify(appReadyEvent,
      never()).fire(any(ApplicationReadyEvent.class));
  workbench.addStartupBlocker(WorkbenchStartupTest.class);
  workbench.startIfNotBlocked();
  verify(appReadyEvent,
      never()).fire(any(ApplicationReadyEvent.class));
}

代码示例来源:origin: org.uberfire/uberfire-workbench-client

@Test
public void setupHomeLinkWithNoDefaultPerspective() {
  doReturn(null).when(workbench).getHomePerspectiveActivity();
  doReturn(true).when(presenter).hasAccessToPerspective(any());
  presenter.setupHomeLink();
  ArgumentCaptor<Command> commandCaptor = ArgumentCaptor.forClass(Command.class);
  verify(view).setHomeLinkAction(commandCaptor.capture());
  verify(view).setBrandImageAction(commandCaptor.capture());
  commandCaptor.getValue().execute();
  verify(placeManager,
      never()).goTo(anyString());
}

代码示例来源:origin: kiegroup/appformer

@Before
public void setup() {
  when(bm.lookupBeans(any(Class.class))).thenReturn(Collections.emptyList());
  when(dragController.getBoundaryPanel()).thenReturn(new AbsolutePanel());
  doNothing().when(workbench).addLayoutToRootPanel(any(WorkbenchLayout.class));
  when(permissionManager.getAuthorizationPolicy()).thenReturn(authorizationPolicy);
  when(authorizationManager.authorize(any(Resource.class),
                    any(User.class))).thenReturn(true);
  when(bm.lookupBeans(PerspectiveActivity.class)).thenReturn(Arrays.asList(perspectiveBean1,
                                       perspectiveBean2));
  when(perspectiveBean1.getInstance()).thenReturn(perspectiveActivity1);
  when(perspectiveBean2.getInstance()).thenReturn(perspectiveActivity2);
  when(perspectiveActivity1.getIdentifier()).thenReturn("perspective1");
  when(perspectiveActivity2.getIdentifier()).thenReturn("perspective2");
  when(perspectiveActivity2.isDefault()).thenReturn(true);
}

代码示例来源:origin: kiegroup/appformer

@PostConstruct
public void init() {
  workbench.addStartupBlocker(RuntimePluginStartup.class);
}

代码示例来源:origin: kiegroup/appformer

@Test
public void shouldStartWhenUnblocked() throws Exception {
  workbench.addStartupBlocker(WorkbenchStartupTest.class);
  workbench.removeStartupBlocker(WorkbenchStartupTest.class);
  verify(appReadyEvent,
      times(1)).fire(any(ApplicationReadyEvent.class));
}

代码示例来源:origin: kiegroup/appformer

@AfterInitialization
private void afterInit() {
  removeStartupBlocker(Workbench.class);
}

代码示例来源:origin: org.uberfire/uberfire-workbench-client

@Test
public void shouldStartOnAfterInitIfNeverBlocked() throws Exception {
  workbench.startIfNotBlocked();
  verify(appReadyEvent,
      times(1)).fire(any(ApplicationReadyEvent.class));
}

代码示例来源:origin: kiegroup/appformer

@Test
public void setupHomeLinkWithNoDefaultPerspective() {
  doReturn(null).when(workbench).getHomePerspectiveActivity();
  doReturn(true).when(presenter).hasAccessToPerspective(any());
  presenter.setupHomeLink();
  ArgumentCaptor<Command> commandCaptor = ArgumentCaptor.forClass(Command.class);
  verify(view).setHomeLinkAction(commandCaptor.capture());
  verify(view).setBrandImageAction(commandCaptor.capture());
  commandCaptor.getValue().execute();
  verify(placeManager,
      never()).goTo(anyString());
}

代码示例来源:origin: org.kie.uberfire/kie-uberfire-perspective-editor-client

@PostConstruct
public void init() {
  workbench.addStartupBlocker( this.getClass() );
}

代码示例来源:origin: org.kie/kie-drools-wb-webapp

@Test
public void setupMenuTest() {
  kieWorkbenchEntryPoint.setupMenu();
  verify(menuBar).addMenus(any());
  verify(menusHelper).addUtilitiesMenuItems();
  verify(workbench).removeStartupBlocker(KieDroolsWorkbenchEntryPoint.class);
}

代码示例来源:origin: kiegroup/appformer

@Test
public void shouldStartOnAfterInitIfNeverBlocked() throws Exception {
  workbench.startIfNotBlocked();
  verify(appReadyEvent,
      times(1)).fire(any(ApplicationReadyEvent.class));
}

相关文章