org.zkoss.zk.ui.Desktop.setAttribute()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(10.7k)|赞(0)|评价(0)|浏览(186)

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

Desktop.setAttribute介绍

[英]Sets the value of the specified custom attribute associated with the desktop.
[中]设置与桌面关联的指定自定义属性的值。

代码示例

代码示例来源:origin: org.zkoss.zk/zk

public String nextComponentUuid(Desktop desktop, Component comp, ComponentInfo compInfo) {
  String number;
  if ((number = (String) desktop.getAttribute(ID_NUM)) == null) {
    number = "0";
    desktop.setAttribute(ID_NUM, number);
  }
  int i = Integer.parseInt(number);
  i++;
  desktop.setAttribute(ID_NUM, String.valueOf(i));
  return ComponentsCtrl.toAutoId(ID_PREFIX, i);
}

代码示例来源:origin: org.zkoss.zk/zk

public String nextPageUuid(Page page) {
  final Desktop desktop = page.getDesktop();
  String number;
  if ((number = (String) desktop.getAttribute(ID_NUM)) == null) {
    number = "0";
    desktop.setAttribute(ID_NUM, number);
  }
  int i = Integer.parseInt(number);
  i++;
  desktop.setAttribute(ID_NUM, String.valueOf(i));
  return ComponentsCtrl.toAutoId(ID_PREFIX, i);
}

代码示例来源:origin: org.zkoss.zk/zk

@SuppressWarnings("unchecked")
/*package*/ ItemFactory(Desktop desktop, HttpServletRequest request, String key, int sizeThreshold,
    File repository, org.zkoss.zk.ui.sys.DiskFileItemFactory factory) {
  super(sizeThreshold, repository);
  _factory = factory;
  _desktop = desktop;
  _key = key;
  long cbtotal = 0;
  String ctlen = request.getHeader("content-length");
  if (ctlen != null)
    try {
      cbtotal = Long.parseLong(ctlen.trim());
      //if (log.isDebugEnabled()) log.debug("content-length="+cbtotal);
    } catch (Throwable ex) {
      log.warn("", ex);
    }
  _cbtotal = cbtotal;
  if (_desktop.getAttribute(Attributes.UPLOAD_PERCENT) == null) {
    _desktop.setAttribute(Attributes.UPLOAD_PERCENT, new HashMap());
    _desktop.setAttribute(Attributes.UPLOAD_SIZE, new HashMap());
  }
  ((Map) _desktop.getAttribute(Attributes.UPLOAD_PERCENT)).put(key, new Integer(0));
  ((Map) _desktop.getAttribute(Attributes.UPLOAD_SIZE)).put(key, new Long(_cbtotal));
}

代码示例来源:origin: org.zkoss.zk/zk

/** Process fileitems named file0, file1 and so on.
 */
private static final void processItems(Desktop desktop, Map<String, Object> params, Map<String, String> attrs)
    throws IOException {
  final List<Media> meds = new LinkedList<Media>();
  final boolean alwaysNative = "true".equals(params.get("native"));
  final Object fis = params.get("file");
  if (fis instanceof FileItem) {
    meds.add(processItem(desktop, (FileItem) fis, alwaysNative,
        (org.zkoss.zk.ui.sys.DiskFileItemFactory) params.get("diskFileItemFactory")));
  } else if (fis != null) {
    for (Iterator it = ((List) fis).iterator(); it.hasNext();) {
      meds.add(processItem(desktop, (FileItem) it.next(), alwaysNative,
          (org.zkoss.zk.ui.sys.DiskFileItemFactory) params.get("diskFileItemFactory")));
    }
  }
  final String contentId = Strings
      .encode(new StringBuffer(12).append("z__ul_"), ((DesktopCtrl) desktop).getNextKey()).toString();
  attrs.put("contentId", contentId);
  desktop.setAttribute(contentId, meds);
}

代码示例来源:origin: org.zkoss.zk/zk

/** Process fileitems named file0, file1 and so on.
 */
@SuppressWarnings("unchecked")
private static final void processItems(Desktop desktop, Map<String, Object> params, Map<String, String> attrs)
    throws IOException {
  String uuid = attrs.get("uuid");
  List<Media> meds = (List<Media>) desktop.getAttribute(uuid);
  if (meds == null) {
    meds = new LinkedList<Media>();
    desktop.setAttribute(uuid, meds);
  }
  final boolean alwaysNative = "true".equals(params.get("native"));
  final Object fis = params.get("file");
  if (fis instanceof FileItem) {
    meds.add(processItem(desktop, (FileItem) fis, alwaysNative,
        (org.zkoss.zk.ui.sys.DiskFileItemFactory) params.get("diskFileItemFactory")));
  } else if (fis != null) {
    for (Iterator it = ((List) fis).iterator(); it.hasNext();) {
      meds.add(processItem(desktop, (FileItem) it.next(), alwaysNative,
          (org.zkoss.zk.ui.sys.DiskFileItemFactory) params.get("diskFileItemFactory")));
    }
  }
}

代码示例来源:origin: org.zkoss.zk/zk

/**
 * Adds a callback method to be executed only once after the execution
 * deactivated.
 * @param callback
 * @since 7.0.5
 */
public void addOnDeactivate(Callback callback) {
  Execution exec = Executions.getCurrent();
  if (exec == null)
    throw new IllegalStateException("Execution cannot be null!");
  Desktop desktop = exec.getDesktop();
  if (desktop != null) {
    List<Callback> callbacks = (List<Callback>) desktop.getAttribute(Add_ON_DEACTIVATE);
    if (callbacks == null) {
      callbacks = new LinkedList<Callback>();
      desktop.setAttribute(Add_ON_DEACTIVATE, callbacks);
    }
    callbacks.add(callback);
  }
}

代码示例来源:origin: org.zkoss.zk/zk

/**
 * Adds a callback method to be executed only once after the execution
 * activated.
 * @param callback
 * @since 7.0.5
 */
public void addOnActivate(Callback callback) {
  Execution exec = Executions.getCurrent();
  if (exec == null)
    throw new IllegalStateException("Execution cannot be null!");
  Desktop desktop = exec.getDesktop();
  if (desktop != null) {
    List<Callback> callbacks = (List<Callback>) desktop.getAttribute(Add_ON_ACTIVATE);
    if (callbacks == null) {
      callbacks = new LinkedList<Callback>();
      desktop.setAttribute(Add_ON_ACTIVATE, callbacks);
    }
    callbacks.add(callback);
  }
}

代码示例来源:origin: stackoverflow.com

desktop.setAttribute(LAST_ID, String.valueOf(counter));

代码示例来源:origin: org.zkoss.zk/zk

public Object setAttribute(String name, Object value, boolean recurse) {
  if (recurse && !hasAttribute(name)) {
    if (_desktop != null) {
      if (_desktop.hasAttribute(name, true))
        return _desktop.setAttribute(name, value, true);
    }
  }
  return setAttribute(name, value);
}

代码示例来源:origin: org.zkoss.zk/zk

public <T extends Event> EventQueue<T> lookup(String name, String scope, boolean autoCreate) {
  final boolean bAppScope = EventQueues.APPLICATION.equals(scope);
  final boolean bSessionScope = EventQueues.SESSION.equals(scope);
  // if the scope is in session or application, it won't need an Execution
  // to work with this event queue for publishing
  if (bSessionScope && Sessions.getCurrent() == null) {
    throw new IllegalStateException("Current session is not available");
  } else if (bAppScope || bSessionScope) {
    return lookup0(name, bAppScope ? (Scope) WebApps.getCurrent() : Sessions.getCurrent(), autoCreate);
  } else if (EventQueues.DESKTOP.equals(scope)) {
    final Execution exec = Executions.getCurrent();
    if (exec == null)
      throw new IllegalStateException("Not in an execution");
    final Desktop desktop = exec.getDesktop();
    Map<String, EventQueue<T>> eqs = cast((Map) desktop.getAttribute(ATTR_EVENT_QUEUES));
    if (eqs == null)
      desktop.setAttribute(ATTR_EVENT_QUEUES, eqs = new HashMap<String, EventQueue<T>>(4));
    EventQueue<T> eq = eqs.get(name);
    if (autoCreate && eq == null)
      eqs.put(name, eq = new DesktopEventQueue<T>());
    if (log.isDebugEnabled()) {
      log.debug("Lookup event queue: name [{}], scope [{}], autoCreate [{}]", name, scope, autoCreate);
    }
    return eq;
  } else
    throw new UnsupportedOperationException("Unknown scope: " + scope);
}

代码示例来源:origin: org.zkoss.zk/zkmax

Map eqs = (Map)desktop.getAttribute(ATTR_EVENT_QUEUES);
if (eqs == null)
  desktop.setAttribute(ATTR_EVENT_QUEUES, eqs = new HashMap(4));

代码示例来源:origin: org.zkoss.zk/zk

if (!found && (desktop = getDesktop()) != null) {
  if (Events.ON_CLIENT_INFO.equals(evtnm)) {
    desktop.setAttribute("org.zkoss.desktop.clientinfo.enabled", true);
    response(new AuClientInfo(desktop));
  } else if (Events.ON_PIGGYBACK.equals(evtnm)) {
    ((DesktopCtrl) desktop).onPiggybackListened(this, true);
  } else if (Events.ON_VISIBILITY_CHANGE.equals(evtnm)) {
    desktop.setAttribute("org.zkoss.desktop.visibilitychange.enabled", true);
  } else if (getClientEvents().containsKey(evtnm)) {
    final boolean asap = Events.isListened(this, evtnm, true);

代码示例来源:origin: org.zkoss.zk/zk

public Object setAttribute(String name, Object value, boolean recurse) {
  if (recurse && !hasAttribute(name)) {
    Desktop desktop = getDesktop();
    if (desktop != null) {
      if (desktop.hasAttribute(name, true))
        return desktop.setAttribute(name, value, true);
    }
  }
  return setAttribute(name, value);
}

代码示例来源:origin: org.zkoss.zk/zk

sb.append("zk.appName='");
  Strings.escape(sb, appnm, Strings.ESCAPE_JAVASCRIPT).append("';");
  desktop.setAttribute(ATTR_APPNM, appnm);
sb.append("zk.themeName='");
Strings.escape(sb, themenm, Strings.ESCAPE_JAVASCRIPT).append("';");
desktop.setAttribute(ATTR_THEMENM, themenm);

代码示例来源:origin: org.carewebframework/org.carewebframework.ext.performance

/**
 * Registers an event sent to the specified target for monitoring.
 * 
 * @param target The component that will be the target of the event.
 * @param eventName The name of the event to be monitored.
 * @param tag The tag to be included in the log entry.
 * @param displayElapsed If true, the performance information will be sent to the display.
 */
public static void monitorEvent(Component target, String eventName, String tag,
                boolean displayElapsed) {
  Desktop dt = target.getDesktop();
  PerformanceData pd = (PerformanceData) dt.getAttribute(PerformanceData.ATTR_PERF_DATA);
  if (pd == null) {
    pd = new PerformanceData(dt);
    dt.setAttribute(PerformanceData.ATTR_PERF_DATA, pd);
  }
  pd.monitorEvent(target, eventName, tag, displayElapsed);
}

代码示例来源:origin: stackoverflow.com

desktop.setAttribute(timerId, timer);
timer.start();

代码示例来源:origin: org.zkoss.zk/zk

private void onListenerChange(Desktop desktop, boolean listen) {
  if (listen) {
    if (Events.isListened(this, Events.ON_CLIENT_INFO, false)) { //asap+deferrable
      response(new AuClientInfo(desktop));
      getDesktop().setAttribute("org.zkoss.desktop.clientinfo.enabled", true);
      //We always fire event not a root, since we don't like to
      //check when setParent or setPage is called
    }
    if (Events.isListened(this, Events.ON_PIGGYBACK, false))
      ((DesktopCtrl) desktop).onPiggybackListened(this, true);
    if (Events.isListened(this, Events.ON_VISIBILITY_CHANGE, false))
      getDesktop().setAttribute("org.zkoss.desktop.visibilitychange.enabled", true);
  } else {
    if (!Events.isListened(this, Events.ON_PIGGYBACK, false))
      ((DesktopCtrl) desktop).onPiggybackListened(this, false);
  }
}

代码示例来源:origin: org.zkoss.zk/zkex

/**
 * Get the {@link OperationQueue} of {@linkplain OperationThread},
 * It is check is there any {@linkplain OperationThread} exist in desktop.
 * If no, create one ,start it and store in desktop, then return thread's operation queue.
 * If yes, return operation queue directly.  
 * 
 * There is only one {@linkplain OperationThread} in each desktop.
 * @param desktop the associated desktop
 * @return a queue which associate to desktop
 */
public static OperationQueue getQueue(Desktop desktop) {
  if (desktop == null)
    throw new NullPointerException("desktop is null");
  synchronized(desktop) {
    if (!desktop.isAlive()) {
      throw new IllegalStateException("desktop not alive:" + desktop);
    }
    OperationThread t = (OperationThread) desktop.getAttribute(DESKTOP_KEY);
    if (t == null) {
      t = new OperationThread(desktop);
      if(D.ON && log.debugable()){
        log.debug("staring a Operation Thread for desktop:"+desktop+",name="+t.getName());
      }
      desktop.setAttribute(DESKTOP_KEY, t);
      t.start();
      
    }
    return t.getQueue();
  }
}

代码示例来源:origin: org.carewebframework/org.carewebframework.ext.performance

pd.setRequestId(requestId);
this.performanceDataMap.put(requestId, pd);
desktop.setAttribute(PerformanceData.ATTR_PERF_DATA, pd);

相关文章