Application Development in WebOS
Recognize the abstract class Application
The operating system accepts classes that implement Application,
Install the application by calling the install() method
Call the uninstall() method to uninstall the application
package com.single.os.core.client;
public abstract class Application {
protected boolean installed=false;
protected String prefix;
public String getPrefix() {
return prefix;
}
public Application(String prefix){
this.prefix=prefix;
}
public boolean isInstalled() {
return installed;
}
/**
*
* @return
*/
abstract boolean install();
/**
*
* @return
*/
abstract boolean uninstall();
}
For simple applications we provide the SimpleApplication classIt includes several main properties,
Includes controller, program menu items, command set
You just need to create a class extending SimpleApplication
Override the initial() method, assign controller, appMenuItem and add commands using the addCommand method.
The controller is the controller. To use this object, you need to understand the MVC architecture of GXT first.
appMenuItem is your program menu, which will be added to: Start -> Programs.
The addCommand method is to register your command in the system. For details, please refer to the related articles introduced by Command.
package com.single.os.core.client;
import java.util.HashMap;
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.mvc.Controller;
import com.extjs.gxt.ui.client.mvc.Dispatcher;
import com.extjs.gxt.ui.client.widget.menu.MenuItem;
import com.single.os.core.client.ui.desktop.Desktop;
public class SimpleApplication extends Application{
public SimpleApplication(String prefix) {
super(prefix);
}
private static int increase=1;
protected String baseStyle="module"+increase++;
/**
*
*/
protected Controller controller;
/**
* -> ->
*/
protected MenuItem appMenuItem;
/**
*
*/
private HashMap<String, CommandExecute> commands=new HashMap<String, CommandExecute>();
public void addCommand(String command,CommandExecute execute){
commands.put(command, execute);
}
// ,
protected void initial(){
}
@Override
boolean install() {
if(installed){
return false;
}
initial();
//
if(controller!=null){
Dispatcher.get().addController(controller);
}
//
if(appMenuItem!=null){
Desktop desktop=Registry.get(OS.DESKTOP);
desktop.getStartMenu().addApplicationMenuItem(appMenuItem);
}
//
if(commands.size()>0){
for(String command:commands.keySet()){
CommandCollection.add(command, commands.get(command));
}
}
installed=true;
return true;
}
@Override
boolean uninstall() {
if(!installed){
return false;
}
//
if(controller!=null){
Dispatcher.get().removeController(controller);
}
//
if(commands.size()>0){
for(String command:commands.keySet()){
CommandCollection.remove(command);
}
}
installed=false;
return true;
}
}
You can build a class YourApplication that extends SimpleApplication
Then after setting the relevant content in the initial() method,
Add the application to the OS system
OS.addApplication(new YourApplication());
How to create a well-formed application
A well-formed application means that the program is independent, has a good degree of modularity, and has simple and clear dependencies.
That is, as long as someone inherits your module in gwt.xml, your system can automatically install and take effect.
Generally, one application corresponds to one module.
Create a new module, and then create an entry EntryPoint for the module
The method onMouldeLoad is the method that will be called when the program enters your module.
You can initialize your module or application here.
For example, create your own Application,
Then call OS.addApplication(new YourApplication());
Add your application to the system.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Application Development in WebOSDevelop applications in WebOS Recognize the abstract class Application The operating system accepts classes that impleme...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.