예제 #1
0
파일: Window.java 프로젝트: tmillsclare/zk
 /**
  * Processes an AU request.
  *
  * <p>Default: in addition to what are handled by {@link XulElement#service}, it also handles
  * onOpen.
  *
  * @since 5.0.0
  */
 public void service(org.zkoss.zk.au.AuRequest request, boolean everError) {
   final String cmd = request.getCommand();
   if (cmd.equals(Events.ON_OPEN)) {
     OpenEvent evt = OpenEvent.getOpenEvent(request);
     setVisible(evt.isOpen());
     Events.postEvent(evt);
   } else if (cmd.equals(Events.ON_MAXIMIZE)) {
     MaximizeEvent evt = MaximizeEvent.getMaximizeEvent(request);
     setLeftDirectly(evt.getLeft());
     setTopDirectly(evt.getTop());
     setWidthDirectly(evt.getWidth());
     setHeightDirectly(evt.getHeight());
     _maximized = evt.isMaximized();
     if (_maximized) setVisibleDirectly(true);
     Events.postEvent(evt);
   } else if (cmd.equals(Events.ON_MINIMIZE)) {
     MinimizeEvent evt = MinimizeEvent.getMinimizeEvent(request);
     setLeftDirectly(evt.getLeft());
     setTopDirectly(evt.getTop());
     setWidthDirectly(evt.getWidth());
     setHeightDirectly(evt.getHeight());
     _minimized = evt.isMinimized();
     if (_minimized) {
       setVisibleDirectly(false);
       if (_mode == MODAL) leaveModal(OVERLAPPED);
     }
     Events.postEvent(evt);
   } else super.service(request, everError);
 }
예제 #2
0
파일: Window.java 프로젝트: tmillsclare/zk
  /**
   * Makes this window as a modal dialog. It will automatically center the window (ignoring {@link
   * #getLeft} and {@link #getTop}).
   *
   * <p>Notice: though both setMode("modal") and doModal() both causes the window to become modal,
   * they are a bit different. doModal causes the event listener to suspend immediately, while
   * setMode("modal") posts an event ({@link Events#ON_MODAL}). That is, {@link #setMode} won't
   * suspend the execution immediately, but {@link #doModal} will. {@link #doModal} can be called
   * only in an event listener, while {@link #setMode} can be called anytime.
   *
   * @exception SuspendNotAllowedException if 1) not in an event listener;<br>
   *     2) the event thread is disabled.<br>
   *     3) there are too many suspended processing thread than the deployer allows. By default,
   *     there is no limit of # of suspended threads.
   * @exception InterruptedException thrown if the desktop or the Web application is being
   *     destroyed, or {@link org.zkoss.zk.ui.sys.DesktopCtrl#ceaseSuspendedThread}. To tell the
   *     difference, check the getMessage method of InterruptedException.
   * @since 3.0.4
   */
  public void doModal() throws InterruptedException, SuspendNotAllowedException {
    if (!isEventThreadEnabled(true)) {
      checkOverlappable(_MODAL_);
      setNonModalMode(_MODAL_);
      return;
    }

    checkOverlappable(MODAL);

    if (_mode != MODAL) {
      if (!Events.inEventListener())
        throw new SuspendNotAllowedException("doModal must be called in an event listener");

      int oldmode = _mode;
      boolean oldvisi = isVisible();

      setVisible(true); // if MODAL, it must be visible; vice versa

      try {
        enterModal();
      } catch (SuspendNotAllowedException ex) {
        handleFailedModal(oldmode, oldvisi);
        throw ex;
      }
    }
  }
예제 #3
0
파일: Window.java 프로젝트: tmillsclare/zk
 /* Set non-modal mode. */
 private void setNonModalMode(int mode) {
   if (_mode != mode) {
     if (_mode == MODAL) leaveModal(mode);
     else {
       _mode = mode;
       smartUpdate("mode", modeToString(_mode));
     }
   }
   setVisible(true);
 }
예제 #4
0
파일: Window.java 프로젝트: tmillsclare/zk
 private void handleFailedModal(int oldmode, boolean oldvisi) {
   try {
     if (Executions.getCurrent().getAttribute("javax.servlet.error.exception") != null) {
       // handle it specially if it is used for dispalying err
       setMode(HIGHLIGHTED);
     } else {
       setMode(oldmode); // restore
       setVisible(oldvisi);
     }
   } catch (Throwable ex) {
     log.realCauseBriefly("Causing another error", ex);
   }
 }
예제 #5
0
  /** SetVisible for components by checking if there's a right for it. */
  private void doCheckRights() {

    final UserWorkspace workspace = getUserWorkspace();

    orderPositionDialogWindow.setVisible(workspace.isAllowed("orderPositionDialogWindow"));

    btnHelp.setVisible(workspace.isAllowed("button_OrderPositionDialog_btnHelp"));
    btnNew.setVisible(workspace.isAllowed("button_OrderPositionDialog_btnNew"));
    btnEdit.setVisible(workspace.isAllowed("button_OrderPositionDialog_btnEdit"));
    btnDelete.setVisible(workspace.isAllowed("button_OrderPositionDialog_btnDelete"));
    btnSave.setVisible(workspace.isAllowed("button_OrderPositionDialog_btnSave"));
    btnClose.setVisible(workspace.isAllowed("button_OrderPositionDialog_btnClose"));
  }
 public void onEventCreate(CalendarsEvent event) throws InterruptedException, RemoteException {
   StorageComponentProxy proxy = SystemDictionary.getSCProxy();
   bookEventWin = (Window) Executions.createComponents("bookEvent.zul", self.getParent(), null);
   bookEventWin.setAttribute("calendars", cal);
   bookEventWin.setAttribute("calevent", event);
   bookEventWin.getFellow("qsrow").setVisible(true);
   Date setting = event.getBeginDate();
   setting.setTime(setting.getTime() + 43200000);
   ((Datebox) bookEventWin.getFellow("datetask")).setValue(setting);
   ((Timebox) bookEventWin.getFellow("timetask")).setValue(setting);
   ((Button) bookEventWin.getFellow("savebutton")).setVisible(true);
   ((Listbox) bookEventWin.getFellow("tasktypesel")).setSelectedIndex(0);
   String userid = (String) Sessions.getCurrent().getAttribute("userid");
   ((Textbox) bookEventWin.getFellow("userid")).setValue(userid);
   Toolbar toolbar = (Toolbar) self.getFellow("toolbar");
   String currentexecutor = ((Label) toolbar.getFellow("exechelp")).getValue();
   SystemDictionary.webguiLog("DEBUG", "Executor: " + currentexecutor);
   OperationResult opres =
       proxy.getUserIdByPersonId(currentexecutor, SystemDictionary.USERTYPE_PATIENT_INT, userid);
   Patient patient = proxy.getPatient(currentexecutor, userid);
   Carer carer = patient.getPatientCarer();
   OperationResult realexecutor =
       proxy.getUserIdByPersonId(carer.getID(), SystemDictionary.USERTYPE_CARER_INT, userid);
   SystemDictionary.webguiLog(
       "DEBUG", "Executor req: " + realexecutor.getCode() + ":" + opres.getDescription());
   ((Textbox) bookEventWin.getFellow("objid")).setValue(realexecutor.getCode());
   ((Textbox) bookEventWin.getFellow("addressedid")).setValue(opres.getCode());
   ((Textbox) bookEventWin.getFellow("objstr")).setValue(carer.toString());
   ((Textbox) bookEventWin.getFellow("addressedstr")).setValue(patient.toString());
   User assigner = proxy.getUser(userid);
   Clinician assg = proxy.getClinician(assigner.getPersonID(), userid);
   ((Textbox) bookEventWin.getFellow("userstr")).setValue(assg.toString());
   ((Listbox) bookEventWin.getFellow("questnamefield")).setSelectedIndex(0);
   // bookEventWin.getFellow("assignerrow").setVisible(false);
   bookEventWin.getFellow("massivequestionrow").setVisible(true);
   bookEventWin.getFellow("massivecheckrow").setVisible(true);
   bookEventWin.setTitle("New Task");
   bookEventWin.setVisible(true);
   bookEventWin.doModal();
 }
  public void onEventEdit(CalendarsEvent event) throws InterruptedException, RemoteException {
    try {
      StorageComponentProxy proxy = SystemDictionary.getSCProxy();
      Session ses = Sessions.getCurrent();
      String userid = (String) ses.getAttribute("userid");
      bookEventWin = (Window) Executions.createComponents("bookEvent.zul", self.getParent(), null);
      bookEventWin.setAttribute("calendars", cal);
      bookEventWin.setAttribute("calevent", event);
      Date setting = event.getCalendarEvent().getBeginDate();
      SimpleCalendarEvent scevent = (SimpleCalendarEvent) event.getCalendarEvent();
      bookEventWin.getFellow("cancelbutton").setVisible(true);
      ((Datebox) bookEventWin.getFellow("datetask")).setValue(setting);
      ((Datebox) bookEventWin.getFellow("datetask")).setReadonly(true);
      ((Datebox) bookEventWin.getFellow("datetask")).setButtonVisible(false);
      ((Timebox) bookEventWin.getFellow("timetask")).setValue(setting);
      ((Timebox) bookEventWin.getFellow("timetask")).setReadonly(true);
      ((Timebox) bookEventWin.getFellow("timetask")).setButtonVisible(false);
      ((Textbox) bookEventWin.getFellow("taskidfield"))
          .setValue((String) scevent.getParams().get("task"));
      ((Textbox) bookEventWin.getFellow("taskstatusfield"))
          .setValue(
              SystemDictionary.getTaskStatusLabel((String) scevent.getParams().get("status")));
      bookEventWin.getFellow("rowtaskstatus").setVisible(true);
      if (scevent.getParams().get("status").equals(SystemDictionary.TASK_STATUS_COMPLETED)) {
        bookEventWin.getFellow("cancelbutton").setVisible(false);
        String tasktype = (String) scevent.getParams().get("type");
        if (tasktype.equals(SystemDictionary.TASK_TYPE_CARERQS)
            || tasktype.equals(SystemDictionary.TASK_TYPE_PATIENTQS)) {
          // TODO retrieve Questionnaire answers and show in the task window
          Questionnaire q = (Questionnaire) scevent.getParams().get("questionnaire");
          QuestionnaireAnswers qa =
              proxy.getQuestionnaireAnswersByTask((String) scevent.getParams().get("task"), userid);
          SystemDictionary.webguiLog(
              "INFO", "task id: " + (String) scevent.getParams().get("task"));
          // SystemDictionary.webguiLog("INFO", "ANSWERS LENGTH: "+ qa.getAnswer().length);
          // SystemDictionary.webguiLog("INFO", "getQuestion: "+ q.getQuestion().length);
          ArrayList<QuestionnaireAnswer> qalist = new ArrayList<QuestionnaireAnswer>();
          if (qa.getAnswer() != null)
            for (int i = 0; i < qa.getAnswer().length; i++) {
              qalist.add(i, qa.getAnswer(i));
            }

          String responses = provideQuestionnaireResponse(toPlainList(q.getQuestion()), qalist);
          SystemDictionary.webguiLog("DEBUG", "RESPONSES: " + responses);
          bookEventWin.getFellow("qsanswersrow").setVisible(true);
          ((Label) bookEventWin.getFellow("qsanswersfield")).setValue(responses);

        } else if (tasktype.equals(SystemDictionary.TASK_TYPE_BLOODPRESSURE_MEASUREMENT)
            || tasktype.equals(SystemDictionary.TASK_TYPE_WEIGHT_MEASUREMENT)
            || tasktype.equals(SystemDictionary.TASK_TYPE_ACTMONITOR)) {
          String resultfieldvalue = "";
          SearchCriteria searchc =
              new SearchCriteria(
                  "task",
                  new SystemParameter(SystemDictionary.COMPARE_EQ, ""),
                  (String) scevent.getParams().get("task"),
                  "");
          Measurement[] results = proxy.getMeasurement(new SearchCriteria[] {searchc}, userid);
          if (results.length <= 0) {
            resultfieldvalue = "No measurement could be retrieved";
          } else {
            resultfieldvalue = "Use 'Monitor Measurements' button for viewing the measurements";
            /*SystemDictionary.webguiLog("DEBUG", "RESULTS LENGHT: "+results.length);
            for(int ii = 0 ; ii < results.length ; ii++){
            	resultfieldvalue += results[ii].getValue()+""+results[ii].getUnits()+"\n";
            }*/
          }
          bookEventWin.getFellow("mresultrow").setVisible(true);
          ((Label) bookEventWin.getFellow("mresultrowfield")).setValue(resultfieldvalue);
        }
      }
      User addressed = proxy.getUser((String) scevent.getParams().get("objid"));
      Patient patient = proxy.getPatient(addressed.getPersonID(), userid);
      ((Textbox) bookEventWin.getFellow("addressedid"))
          .setValue((String) scevent.getParams().get("objid"));
      ((Textbox) bookEventWin.getFellow("addressedstr")).setValue(patient.toString());
      User object = proxy.getUser((String) scevent.getParams().get("exec"));
      Carer executor = proxy.getCarer(object.getPersonID(), userid);
      ((Textbox) bookEventWin.getFellow("objid"))
          .setValue((String) scevent.getParams().get("exec"));
      ((Textbox) bookEventWin.getFellow("objstr")).setValue(executor.toString());
      User assigner = proxy.getUser((String) scevent.getParams().get("assign"));
      Clinician assg = proxy.getClinician(assigner.getPersonID(), userid);
      ((Textbox) bookEventWin.getFellow("userid"))
          .setValue((String) scevent.getParams().get("assign"));
      ((Textbox) bookEventWin.getFellow("userstr")).setValue(assg.toString());
      ((Textbox) bookEventWin.getFellow("tasktypetext")).setValue(scevent.getContent());
      bookEventWin.getFellow("tasktypetext").setVisible(true);
      // ((Combobox)bookEventWin.getFellow("addressedtext")).setVisible(false);
      int tasktype2 = Integer.parseInt((String) scevent.getParams().get("type"));
      this.showCustomFields(tasktype2);
      bookEventWin.getFellow("tasktypesel").setVisible(false);
      @SuppressWarnings("rawtypes")
      List items = ((Listbox) bookEventWin.getFellow("urlfield")).getItems();
      @SuppressWarnings("rawtypes")
      Iterator it = items.iterator();
      while (it.hasNext()) {
        Listitem currentitem = (Listitem) it.next();
        if (currentitem.getValue().equals((String) scevent.getParams().get("url"))) {
          ((Listbox) bookEventWin.getFellow("urlfield")).setSelectedItem(currentitem);
          break;
        }
      }
      ((Listbox) bookEventWin.getFellow("urlfield")).setDisabled(true);
      if (scevent.getParams().get("questionnaire") != null) {
        items = ((Listbox) bookEventWin.getFellow("questnamefield")).getItems();
        it = items.iterator();
        while (it.hasNext()) {
          Listitem currentitem = (Listitem) it.next();
          if (currentitem
              .getValue()
              .equals(((Questionnaire) scevent.getParams().get("questionnaire")).getID())) {
            ((Listbox) bookEventWin.getFellow("questnamefield")).setSelectedItem(currentitem);
            break;
          }
        }
      }
      ((Listbox) bookEventWin.getFellow("questnamefield")).setDisabled(true);
      // ((Textbox)bookEventWin.getFellow("urlfield")).setValue((String)scevent.getParams().get("url"));
      ((Textbox) bookEventWin.getFellow("textfield"))
          .setValue((String) scevent.getParams().get("text"));

      bookEventWin.setTitle("View Task");
      bookEventWin.setVisible(true);
      bookEventWin.doModal();
    } catch (Exception e) {
      e.printStackTrace();
      Executions.sendRedirect("");
    }
  }