CodenameOne:是否可以为应用程序的不同用户组定义'Views'?
CodenameOne: Is it possible to define 'Views' for different usergroups of the app?
我目前正计划使用 CodenameOne 开发一个应用程序,我想知道是否可以定义一些 数据库,如视图 一个应用程序,以便不同的用户看到应用程序的不同部分?
我说的是一个应用程序,它是项目结构的一部分,它由不同的模块组成,需要单独购买,但都应该集成到同一个应用程序中。作为某种广告策略,未购买的部分应该显示,但没有任何功能。
另一个与此密切相关的问题是如何让不同的人使用同一个应用程序的不同 GUIS?
例子:有一个master和一个worker。
大师有这些菜单:
- show all machines
- show available teams
- send message to team x
工作人员有这些菜单:
- show my machine
- show my team
- send message to master
如果主人重新分配一个团队,团队成员菜单的内容只会相应地改变,而应用程序本身不会改变。
如果一个工人被指定为主人,服务器会发送类似 you are now the master
的内容,并且视图将更改为主人视图(仍在同一个应用程序中)
这可能吗?
如果我没有理解错的话,没有内置支持类似的东西。您可能会使用一组权限系统和 if 语句来实现这一点,但是没有系统可以让您明确地说 "this module is only visible to that user"。
我相信您可能需要的只是动态构建这些视图。如果应用程序逻辑表明某个用户是主人 - 那么您将为该用户构建一个 master-like 视图,否则您将创建简单的工作者视图。关于assignment(哪个master统治一个worker),只是基本的one-to-many关系范式。
使用 GUI + 代码动态构建视图的技巧:
public UserViewBuilder extends UIBuilder {
private Resource res;
private Container view;
//User is the parent class of both Worker and Master
private User user;
...
public UserView(Resource res){
this.res = res;
}
private void init(boolean isMasterView){
//where you initialize all the component of your view
}
...
public Container viewSelector(boolean isUserMaster){
if(isUserMaster){
//getting data for a master-user, just throwing ideas
this.user = Data.fetchYourMasterData();
//getting the design from GUI
this.view =this.createContainer(res,"ContainerDesignForMaster");
//putting the necessary data into the design
this.init(isUserMaster);
}
else {
//getting data for a worker-user, just throwing ideas
this.user = Data.fetchYourWorkerData();
//getting the design from GUI
this.view =this.createContainer(res,"ContainerDesignForWorker");
//putting the necessary data into the design
this.init(isUserMaster);
}
}
...
}
使用该体系结构方法,您将使用 GUI 构建器创建主节点和辅助节点的设计 - 然后您将编写视图选择逻辑代码。
(如果您需要一个工作示例 netbeans 项目以便更好地理解,请告诉我)
我目前正计划使用 CodenameOne 开发一个应用程序,我想知道是否可以定义一些 数据库,如视图 一个应用程序,以便不同的用户看到应用程序的不同部分?
我说的是一个应用程序,它是项目结构的一部分,它由不同的模块组成,需要单独购买,但都应该集成到同一个应用程序中。作为某种广告策略,未购买的部分应该显示,但没有任何功能。
另一个与此密切相关的问题是如何让不同的人使用同一个应用程序的不同 GUIS?
例子:有一个master和一个worker。
大师有这些菜单:
- show all machines
- show available teams
- send message to team x
工作人员有这些菜单:
- show my machine
- show my team
- send message to master
如果主人重新分配一个团队,团队成员菜单的内容只会相应地改变,而应用程序本身不会改变。
如果一个工人被指定为主人,服务器会发送类似 you are now the master
的内容,并且视图将更改为主人视图(仍在同一个应用程序中)
这可能吗?
如果我没有理解错的话,没有内置支持类似的东西。您可能会使用一组权限系统和 if 语句来实现这一点,但是没有系统可以让您明确地说 "this module is only visible to that user"。
我相信您可能需要的只是动态构建这些视图。如果应用程序逻辑表明某个用户是主人 - 那么您将为该用户构建一个 master-like 视图,否则您将创建简单的工作者视图。关于assignment(哪个master统治一个worker),只是基本的one-to-many关系范式。
使用 GUI + 代码动态构建视图的技巧:
public UserViewBuilder extends UIBuilder {
private Resource res;
private Container view;
//User is the parent class of both Worker and Master
private User user;
...
public UserView(Resource res){
this.res = res;
}
private void init(boolean isMasterView){
//where you initialize all the component of your view
}
...
public Container viewSelector(boolean isUserMaster){
if(isUserMaster){
//getting data for a master-user, just throwing ideas
this.user = Data.fetchYourMasterData();
//getting the design from GUI
this.view =this.createContainer(res,"ContainerDesignForMaster");
//putting the necessary data into the design
this.init(isUserMaster);
}
else {
//getting data for a worker-user, just throwing ideas
this.user = Data.fetchYourWorkerData();
//getting the design from GUI
this.view =this.createContainer(res,"ContainerDesignForWorker");
//putting the necessary data into the design
this.init(isUserMaster);
}
}
...
}
使用该体系结构方法,您将使用 GUI 构建器创建主节点和辅助节点的设计 - 然后您将编写视图选择逻辑代码。
(如果您需要一个工作示例 netbeans 项目以便更好地理解,请告诉我)