浏览代码

Use div instead of notice to avoid UI removing it (#14597)

Change-Id: I70cf7f310ee8238a6846316d8c85b3ae4abfd67d
tags/7.3.1^0
Manolo Carrasco 9 年前
父节点
当前提交
1bd717cf66
共有 1 个文件被更改,包括 63 次插入15 次删除
  1. 63
    15
      client/src/com/vaadin/client/metadata/ConnectorBundleLoader.java

+ 63
- 15
client/src/com/vaadin/client/metadata/ConnectorBundleLoader.java 查看文件

@@ -19,13 +19,21 @@ import java.util.ArrayList;
import java.util.List;

import com.google.gwt.core.shared.GWT;
import com.google.gwt.dom.client.Style;
import com.google.gwt.dom.client.Style.Display;
import com.google.gwt.dom.client.Style.Position;
import com.google.gwt.dom.client.Style.TextAlign;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.dom.client.Style.Visibility;
import com.google.gwt.dom.client.Style.WhiteSpace;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.TouchStartEvent;
import com.google.gwt.event.dom.client.TouchStartHandler;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.client.ApplicationConfiguration;
import com.google.gwt.user.client.ui.RootPanel;
import com.vaadin.client.FastStringMap;
import com.vaadin.client.metadata.AsyncBundleLoader.State;
import com.vaadin.client.ui.VNotification;
import com.vaadin.shared.Position;

public abstract class ConnectorBundleLoader {

@@ -139,23 +147,63 @@ public abstract class ConnectorBundleLoader {

public void cval(String typeName) {
if (!cvals.isEmpty()) {
String msg = "";
for (CValUiInfo c : cvals) {
String ns = c.widgetset.replaceFirst("\\.[^\\.]+$", "");
if (typeName.startsWith(ns)) {
notice(c.product + " " + c.version);
cvals.remove(c);
msg += c.product + " " + c.version + "<br/>";
return;
}
}
if (!msg.isEmpty()) {
// We need a widget for using VNotification, using the
// context-menu parent. Is there an easy way?
Widget w = ApplicationConfiguration.getRunningApplications()
.get(0).getContextMenu().getParent();
VNotification n = VNotification.createNotification(0, w);
n.setWidget(new HTML("Using Evaluation License of:<br/>" + msg));
n.show(Position.BOTTOM_RIGHT);
}
}
}

private HTML notice;

// Not using Vaadin notifications (#14597)
private void notice(String productName) {
if (notice == null) {
notice = new HTML();
notice.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
notice.removeFromParent();
}
});
notice.addTouchStartHandler(new TouchStartHandler() {
public void onTouchStart(TouchStartEvent event) {
notice.removeFromParent();
}
});
}
String msg = notice.getText().trim();
msg += msg.isEmpty() ? "Using Evaluation License of: " : ", ";
notice.setText(msg + productName);
RootPanel.get().add(notice);

notice.getElement().setClassName("");
Style s = notice.getElement().getStyle();

s.setPosition(Position.FIXED);
s.setTextAlign(TextAlign.CENTER);
s.setRight(0, Unit.PX);
s.setLeft(0, Unit.PX);
s.setBottom(0, Unit.PX);
s.setProperty("padding", "0.5em 1em");

s.setProperty("font-family", "sans-serif");
s.setFontSize(12, Unit.PX);
s.setLineHeight(1.1, Unit.EM);

s.setColor("white");
s.setBackgroundColor("black");
s.setOpacity(0.7);

s.setZIndex(2147483646);
s.setProperty("top", "auto");
s.setProperty("width", "auto");
s.setDisplay(Display.BLOCK);
s.setWhiteSpace(WhiteSpace.NORMAL);
s.setVisibility(Visibility.VISIBLE);
s.setMargin(0, Unit.PX);
}
}

正在加载...
取消
保存