本文整理匯總了Java中com.vaadin.server.ClientConnector.DetachEvent類的典型用法代碼示例。如果您正苦於以下問題:Java DetachEvent類的具體用法?Java DetachEvent怎麽用?Java DetachEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
DetachEvent類屬於com.vaadin.server.ClientConnector包,在下文中一共展示了DetachEvent類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: init
import com.vaadin.server.ClientConnector.DetachEvent; //導入依賴的package包/類
@Override
protected void init(VaadinRequest request) {
setPollInterval(1000);
hl = new HorizontalSplitPanel();
hl.setSizeFull();
setContent(hl);
buttonsOnTheLeft = new VerticalLayout();
buttonsOnTheLeft.setSizeUndefined();
hl.setFirstComponent(buttonsOnTheLeft);
hl.setSplitPosition(25, Unit.PERCENTAGE);
ServiceTracker<FragmentFactory, FragmentFactory> tracker = new ServiceTracker<FragmentFactory, FragmentFactory>(
VaadinActivator.context, FragmentFactory.class, this);
tracker.open();
addDetachListener(new DetachListener() {
@Override
public void detach(DetachEvent event) {
tracker.close();
}
});
}
示例2: detach
import com.vaadin.server.ClientConnector.DetachEvent; //導入依賴的package包/類
public synchronized void detach(DetachEvent event) {
UI ui = (UI) event.getConnector();
if (log.isDebugEnabled())
log.debug("UI [" + ui.getUIId() + "] detached, destroying scoped beans");
removeBeans(ui);
sessions.remove(ui);
}
示例3: CollabSketch
import com.vaadin.server.ClientConnector.DetachEvent; //導入依賴的package包/類
public CollabSketch(CollabSketchLineContainer lineContainer, int width, int height) {
this.lineContainer = lineContainer;
setImmediate(true);
getState().canvasWidth = width;
getState().canvasHeight = height;
String color;
ui = UI.getCurrent();
sessionID = ui.getSession().getSession().getId();
if (lineContainer.getSessionColors().containsKey(sessionID)) {
color = lineContainer.getSessionColors().get(sessionID);
} else {
int user = this.lineContainer.getListeners().size();
if (user >= colors.length) {
color = colors[user % colors.length];
} else {
color = colors[user];
}
lineContainer.getSessionColors().put(sessionID, color.toString());
}
getState().color = color;
listener = new CollabSketchUpdateListener(ui) {
@Override
public void lineAdded(final DrawLine line) {
listener.getUi().runSafely(new Runnable() {
@Override
public void run() {
getRpcProxy(CollabSketchClientRpc.class).drawLine(line);
}
});
}
@Override
public void canvasCleared() {
listener.getUi().runSafely(new Runnable() {
@Override
public void run() {
getRpcProxy(CollabSketchClientRpc.class).clearCanvas();
}
});
}
};
// To receive events from the client, we register ServerRpc
registerRpc(rpc);
if (!lineContainer.getLines().isEmpty()) {
getState().lines = (ArrayList<DrawLine>) lineContainer.getLines();
}
lineContainer.getListeners().put(sessionID, listener);
ui.addDetachListener(new DetachListener() {
@Override
public void detach(DetachEvent event) {
CollabSketch.this.lineContainer.getListeners().remove(listener);
CollabSketch.this.lineContainer.getSessionColors().remove(sessionID);
}
});
}