/**
   * When the "update geo data" button is clicked. <br>
   * Updates the login records with geodata for their IP's if found.<br>
   * This is done by a calling a web service from Hostinfo.org.<br>
   *
   * @param event
   * @throws InterruptedException
   */
  public void onClick$button_SecLoginlogList_UpdateGeoData(Event event)
      throws InterruptedException {

    final String str =
        InputConfirmBox.show(
            this.secLoginlogListWindow,
            Labels.getLabel("message.Information.InputSupervisorPassword"));

    if (StringUtils.equalsIgnoreCase(str, "yes we can")) {
      final int recCount = getGuiLoginLoggingService().updateFromHostLookUpMain();

      final String message =
          Labels.getLabel("message.Information.CountRecordsInsertedUpdated") + " " + recCount;
      final String title = Labels.getLabel("message.Information");
      MultiLineMessageBox.doSetTemplate();
      MultiLineMessageBox.show(message, title, MultiLineMessageBox.OK, "INFORMATION", true);

      // ++ create the searchObject and init sorting ++//
      final HibernateSearchObject<SecLoginlog> soSecLoginlog =
          new HibernateSearchObject<SecLoginlog>(SecLoginlog.class, getCountRows());
      // deeper loading of the relations to prevent the lazy
      // loading problem.
      soSecLoginlog.addFetch("ip2Country.countryCode");
      soSecLoginlog.addSort("lglLogtime", true);

      // Set the ListModel
      getPagedListWrapper().init(soSecLoginlog, this.listBoxSecUserlog, this.paging_SecUserLogList);

    } else {
      final String message = Labels.getLabel("message.error.falsePassword");
      final String title = Labels.getLabel("message.Error");
      MultiLineMessageBox.doSetTemplate();
      MultiLineMessageBox.show(message, title, MultiLineMessageBox.OK, "INFORMATION", true);
    }
  }
Esempio n. 2
0
  /**
   * Closes the dialog window. <br>
   * <br>
   * Before closing we check if there are unsaved changes in <br>
   * the components and ask the user if saving the modifications. <br>
   */
  private void doClose() throws Exception {

    if (isDataChanged()) {

      // Show a confirm box
      String msg = Labels.getLabel("message_Data_Modified_Save_Data_YesNo");
      String title = Labels.getLabel("message.Information");

      MultiLineMessageBox.doSetTemplate();
      if (MultiLineMessageBox.show(
              msg,
              title,
              MultiLineMessageBox.YES | MultiLineMessageBox.NO,
              MultiLineMessageBox.QUESTION,
              true,
              new EventListener() {
                @Override
                public void onEvent(Event evt) {
                  switch (((Integer) evt.getData()).intValue()) {
                    case MultiLineMessageBox.YES:
                      try {
                        doSave();
                      } catch (final InterruptedException e) {
                        throw new RuntimeException(e);
                      }
                    case MultiLineMessageBox.NO:
                      break; //
                  }
                }
              })
          == MultiLineMessageBox.YES) {}
    }

    orderPositionDialogWindow.onClose();
  }
  @Listen("onClick=#saveBtn")
  public void addCodeDb() {
    try {
      Map<String, String> map = new HashMap<String, String>();
      map = ZkUtils.getExecutionArgs();
      ErmCodeDb ermCodeDb = new ErmCodeDb();
      List<ErmCodeDb> codeDbList =
          ((ErmCodeDbService) SpringUtil.getBean("ermCodeDbService")).findAllCodeDb(webEmployee);
      String tempId = "OB";
      Long number = (long) codeDbList.size();
      number = number + 1;
      String dbId = tempId + RandomIDGenerator.fmtLong(number, 9);
      ermCodeDb.setDbId(dbId);
      aDbId = dbId;
      dbIdTxt.setValue(dbId);
      if (dbNameTxt.getValue() != null && !"".equals(dbNameTxt.getValue())) {
        ermCodeDb.setName(dbNameTxt.getValue());
      } else {
        ZkUtils.showExclamation(
            Labels.getLabel("webErwSource.nameZhTw") + " " + Labels.getLabel("cannottNull"),
            Labels.getLabel("warn"));
        dbNameTxt.focus();
        return;
      }
      if (resourcesIdTxt.getValue() != null) {
        ermCodeDb.setResourcesId(resourcesIdTxt.getValue());
      }
      ermCodeDb.setHistory("N");
      if (ezproxyRdo.getSelectedItem().getValue() != null) {
        ermCodeDb.setEzproxy(ezproxyRdo.getSelectedItem().getValue().toString());
      }
      if (urlTxt.getValue() != null && !"".equals(urlTxt.getValue())) {
        ermCodeDb.setUrl(urlTxt.getValue());
      }
      if (orderNoIbx.getValue() != null) {
        ermCodeDb.setOrderNo(orderNoIbx.getValue());
      }
      ermCodeDb.setIsDataEffid(1);
      ermCodeDb.setWebEmployee(webEmployee);
      ermCodeDb.setCreateDate(new Date());
      ((ErmCodeDbService) SpringUtil.getBean("ermCodeDbService")).saveCodeDb(ermCodeDb);

      ((WebSysLogService) SpringUtil.getBean("webSysLogService"))
          .insertLog(
              ZkUtils.getRemoteAddr(),
              ermCodeDb.getWebEmployee().getEmployeesn(),
              "codeDb_" + ermCodeDb.getDbId());
      ZkUtils.showInformation(Labels.getLabel("saveOK"), Labels.getLabel("info"));
      dbIdTxt.setValue(ermCodeDb.getDbId());
      addSuunitBtn.setDisabled(false);
      delSuunitBtn.setDisabled(false);
      String url = "ermCodeDb/ermCodeDb.zul";
      ZkUtils.refurbishMethod(url);

    } catch (WrongValueException e) {
      log.error("新增資料庫異常" + e);
    }
  }
Esempio n. 4
0
 public String getOmschrijving() {
   if (omschrijving != null) {
     return Labels.getLabel(omschrijving);
   } else {
     return "Onbekend";
   }
 }
Esempio n. 5
0
  /**
   * When a listItem in the corresponding listbox is selected.<br>
   * Event is forwarded in the corresponding listbox.
   *
   * @param event
   */
  public void onSelect$listBoxBranch(Event event) {
    // logger.debug(event.toString());

    // selectedBranche is filled by annotated databinding mechanism
    final Branche aBranche = getSelectedBranche();

    if (aBranche == null) {
      return;
    }

    // check first, if the tabs are created
    if (getBranchMainCtrl().getBranchDetailCtrl() == null) {
      Events.sendEvent(new Event("onSelect", getBranchMainCtrl().tabBranchDetail, null));
      // if we work with spring beanCreation than we must check a little
      // bit deeper, because the Controller are preCreated ?
    } else if (getBranchMainCtrl().getBranchDetailCtrl().getBinder() == null) {
      Events.sendEvent(new Event("onSelect", getBranchMainCtrl().tabBranchDetail, null));
    }

    // INIT ALL RELATED Queries/OBJECTS/LISTS NEW
    getBranchMainCtrl().getBranchDetailCtrl().setSelectedBranche(aBranche);
    getBranchMainCtrl().getBranchDetailCtrl().setBranche(aBranche);

    // store the selected bean values as current
    getBranchMainCtrl().doStoreInitValues();

    // show the objects data in the statusBar
    final String str = Labels.getLabel("common.Branch") + ": " + aBranche.getBraBezeichnung();
    EventQueues.lookup("selectedObjectEventQueue", EventQueues.DESKTOP, true)
        .publish(new Event("onChangeSelectedObject", null, str));
  }
Esempio n. 6
0
  /**
   * Returns the label or message of the specified key.
   *
   * <ul>
   *   <li>If key is "mesg:class:MMM", Messages.get(class.MMM) is called
   *   <li>Otherwise, {@link Labels#getLabel(String)} is called.
   * </ul>
   *
   * @see #getLabel(String, Object[])
   */
  public static final String getLabel(String key) {
    if (key == null) return "";

    if (key.startsWith("mesg:")) {
      final int j = key.lastIndexOf(':');
      if (j > 5) {
        final String clsnm = key.substring(5, j);
        final String fldnm = key.substring(j + 1);
        try {
          final Class cls = Classes.forNameByThread(clsnm);
          final Field fld = cls.getField(fldnm);
          return Messages.get(((Integer) fld.get(null)).intValue());
        } catch (ClassNotFoundException ex) {
          log.warn("Class not found: " + clsnm, ex);
        } catch (NoSuchFieldException ex) {
          log.warn("Field not found: " + fldnm, ex);
        } catch (IllegalAccessException ex) {
          log.warn("Field not accessible: " + fldnm, ex);
        }
      } else if (log.isDebugEnabled()) {
        log.debug("Not a valid format: " + key);
      }
    }
    return Labels.getLabel(key);
  }
Esempio n. 7
0
  /** @param wapp the Web application (or null if not available yet) */
  private void sessionTimeout(
      HttpServletRequest request, HttpServletResponse response, WebApp wapp, String dtid)
      throws ServletException, IOException {
    final String sid = request.getHeader("ZK-SID");
    if (sid != null) response.setHeader("ZK-SID", sid);

    final AuWriter out = AuWriters.newInstance().open(request, response, 0);

    if (!getAuDecoder(wapp).isIgnorable(request, wapp)) {
      final String deviceType = getDeviceType(request);
      URIInfo ui =
          wapp != null ? (URIInfo) wapp.getConfiguration().getTimeoutURI(deviceType) : null;
      String uri = ui != null ? ui.uri : null;
      out.write(new AuConfirmClose(null)); // Bug: B50-3147382
      final AuResponse resp;
      if (uri != null) {
        if (uri.length() != 0) uri = Encodes.encodeURL(getServletContext(), request, response, uri);
        resp = new AuSendRedirect(uri, null);
      } else {
        String msg = wapp.getConfiguration().getTimeoutMessage(deviceType);
        if (msg != null && msg.startsWith("label:")) {
          final String key;
          msg = Labels.getLabel(key = msg.substring(6), new Object[] {dtid});
          if (msg == null) log.warning("Label not found, " + key);
        }
        if (msg == null) msg = Messages.get(MZk.UPDATE_OBSOLETE_PAGE, dtid);
        resp = new AuObsolete(dtid, msg);
      }
      out.write(resp);
    }

    out.close(request, response);
  }
Esempio n. 8
0
 @Override
 public void init(final ServletConfig config) throws ServletException {
   logger.info("#init: Method has just been started.");
   super.init(config);
   initProperties(config);
   Labels.register(new GeneralLabelLocator());
   trustIxonosTlsCertificates();
 }
 /**
  * Renders a row
  *
  * @param row object where to place information
  * @param object object to be rendered
  * @param i index of the row
  * @throws Exception in case components cannot be added to the row
  */
 @Override
 public void render(Row row, Object object, int i) throws Exception {
   CommandStat stat = (CommandStat) object;
   row.setStyle("padding-top: 0px; padding-bottom: 0px");
   row.setHeight("24px");
   // the data append to each row with simple label
   row.appendChild(new Label(Labels.getLabel(CommonConstants.LABEL_JOB + stat.getCommandName())));
   row.appendChild(new Label(String.valueOf(stat.getCount())));
   row.appendChild(new Label(DateTimeHelper.timeToString(stat.getMeanDuration())));
 }
  private void buildDivFieldsFromEntity(ComposerController<?> composer) {
    //		AnnotateDataBinder binder = new AnnotateDataBinder(crudFormWindow);
    //		binder.bindBean("controller2", composer);

    if (divFields.getChildren().size() == 0) {
      List<Component> list = new ArrayList<Component>(divFields.getChildren());
      for (Component c : list) {
        c.detach();
      }
      d = new Div();
      g = new Grid();
      d.appendChild(g);

      binder = new AnnotateDataBinder(g);
      binder.bindBean("controller2", composer);
      Columns c = new Columns();
      Column col1 = new Column();
      col1.setWidth("120px");
      Column col2 = new Column();
      col2.setAlign("left");
      c.appendChild(col1);
      c.appendChild(col2);
      Rows r = new Rows();
      Textbox t;
      Checkbox checkbox;
      for (ManagedBeanField field : composer.getListColumns()) {
        if (field.isVisible()) {
          Row row = new Row();
          row.appendChild(new Label(Labels.getLabel(field.getFieldCaption())));
          String fieldName = "controller2." + field.getFieldName() + "";

          if (field.getFieldType().equalsIgnoreCase("boolean")) {
            checkbox = new Checkbox();
            binder.addBinding(checkbox, "checked", fieldName);
            row.appendChild(checkbox);

          } else {
            t = new Textbox();

            t.setWidth("98%");

            binder.addBinding(t, "value", fieldName);
            row.appendChild(t);
          }
          r.appendChild(row);
        }
      }
      g.appendChild(r);

      d.setParent(this.divFields);
      // binder.loadAll();
    }
    binder.loadComponent(g);
    // binder.saveAll();
  }
Esempio n. 11
0
  public void onClick$loginBtn() throws InterruptedException {

    validateFields(loginWin);

    user.setIsDisabled(false);
    UsersDAO usersDAO = new UsersDAO();
    List<Users> users = usersDAO.findByExample(user, new String[] {});
    if (users.isEmpty() || users.size() > 1) {
      Messagebox.show(
          Labels.getLabel("loginPage.error"),
          Labels.getLabel("error.title"),
          Messagebox.OK,
          Messagebox.ERROR);
      return;
    }
    user = users.get(0);
    session.setAttribute(IConstants.KEY_USER, user);

    // login to OpenKM and get token
    OkmProtocolDispatcherImpl service = getOkmDispatcher();

    RequestLogin loginReq = new RequestLogin();
    loginReq.setUsername(user.getUsername());
    loginReq.setPassword(user.getPassword());

    ResponseLogin respLogin = service.login(loginReq);
    if (respLogin.isError()) {
      log.error(respLogin.toString());
      Messagebox.show(
          Labels.getLabel("loginPage.error"),
          Labels.getLabel("error.title"),
          Messagebox.OK,
          Messagebox.ERROR);
      return;
    }

    log.info(respLogin.getOkmToken());
    session.setAttribute(IConstants.KEY_OKM_TOKEN, respLogin.getOkmToken());

    Executions.getCurrent().sendRedirect("index.zul");
  }
Esempio n. 12
0
  /**
   * When the "clear local IPs" button is clicked. <br>
   * Deletes local IP's (127.0.0.1) or '0:0:0:0:0:0' <br>
   * from the list from.
   *
   * @param event
   * @throws InterruptedException
   */
  public void onClick$button_SecLoginlogList_DeleteLocalIPs(Event event)
      throws InterruptedException {

    final int recCount = getLoginLoggingService().deleteLocalIPs();

    final String message =
        Labels.getLabel("message.Information.CountRecordsDeleted") + " " + recCount;
    final String title = Labels.getLabel("message.Information");
    MultiLineMessageBox.doSetTemplate();
    MultiLineMessageBox.show(message, title, MultiLineMessageBox.OK, "INFORMATION", true);

    // ++ create the searchObject and init sorting ++//
    final HibernateSearchObject<SecLoginlog> soSecLoginlog =
        new HibernateSearchObject<SecLoginlog>(SecLoginlog.class, getCountRows());
    // deeper loading of the relations to prevent the lazy
    // loading problem.
    soSecLoginlog.addFetch("ip2Country.countryCode");
    soSecLoginlog.addSort("lglLogtime", true);

    // Set the ListModel
    getPagedListWrapper().init(soSecLoginlog, this.listBoxSecUserlog, this.paging_SecUserLogList);
  }
  @Listen("onClick=#delSuunitBtn")
  public void delSunnit() {
    int count = resMainSuunitLix.getSelectedCount();
    if (count > 0) {
      // “你確定要刪除該資料嗎?”
      ZkUtils.showQuestion(
          Labels.getLabel("sureDel"),
          Labels.getLabel("info"),
          new EventListener<Event>() {

            public void onEvent(Event event) throws Exception {
              int ckickButton = (Integer) event.getData();
              if (ckickButton == Messagebox.OK) {
                Set<Listitem> listitems = resMainSuunitLix.getSelectedItems();
                WebEmployee loginwebEmployee =
                    (WebEmployee) ZkUtils.getSessionAttribute("webEmployee");
                for (Listitem listitem : listitems) {
                  ErmResourcesSuunit ermResourcesSuunit = listitem.getValue();
                  ((ErmResourcesSuunitIdService) SpringUtil.getBean("ermResourcesSuunitIdService"))
                      .delSunnit(ermResourcesSuunit);
                  ((WebSysLogService) SpringUtil.getBean("webSysLogService"))
                      .delLog(
                          ZkUtils.getRemoteAddr(),
                          webEmployee.getEmployeesn(),
                          "ermResSuunit_"
                              + ermResourcesSuunit.getDbId()
                              + ermResourcesSuunit.getSuunitId());
                }
                flushList();
              }
            }
          });
    } else {
      // "請先選擇一筆資料"
      ZkUtils.showExclamation(Labels.getLabel("selectMultData"), Labels.getLabel("info"));
      return;
    }
  }
Esempio n. 14
0
  /**
   * When the "import IpToCountry data" button is clicked. <br>
   * Updates the IpToCountry table by importing the newest data <br>
   * from a CSV file from the web server Hostinfo.org.<br>
   *
   * @param event
   * @throws InterruptedException
   */
  public void onClick$button_SecLoginlogList_ImportIPToCountryCSV(Event event)
      throws InterruptedException {

    final String str =
        InputConfirmBox.show(
            this.secLoginlogListWindow,
            Labels.getLabel("message.Information.InputSupervisorPassword"));

    if (StringUtils.equalsIgnoreCase(str, "yes we can")) {
      final int recCount = getGuiLoginLoggingService().importIP2CountryCSV();

      final String message =
          Labels.getLabel("message.Information.CountRecordsInsertedUpdated") + " " + recCount;
      final String title = Labels.getLabel("message.Information");
      MultiLineMessageBox.doSetTemplate();
      MultiLineMessageBox.show(message, title, MultiLineMessageBox.OK, "INFORMATION", true);
    } else {
      final String message = Labels.getLabel("message.error.falsePassword");
      final String title = Labels.getLabel("message.Error");
      MultiLineMessageBox.doSetTemplate();
      MultiLineMessageBox.show(message, title, MultiLineMessageBox.OK, "INFORMATION", true);
    }
  }
Esempio n. 15
0
 /**
  * Metodo que constroi o Listheader baseado nos campos da Entity
  *
  * @param composer composer para construir a lista de campos
  */
 private void builderListHeaderFromEntity(ComposerController<?> composer) {
   if (this.divListhead.getChildren().size() == 1) {
     Listheader oper = (Listheader) this.divListhead.getChildren().get(0);
     this.divListhead.removeChild(oper);
     for (ManagedBeanField field : composer.getListColumns()) {
       if (field.isVisible()) {
         Listheader l = new Listheader(Labels.getLabel(field.getFieldCaption()));
         l.setSort("auto(" + field.getKey() + ")");
         this.divListhead.appendChild(l);
       }
     }
     this.divListhead.appendChild(oper);
   }
 }
    protected Div createWelcomePanel() {
      final Div welcomePanel = new Div();
      welcomePanel.setStyle("text-align: left; padding: 20px 8px 20px 8px;");
      welcomePanel.setSclass("z-groupbox-hm welcome_group");

      final Div labelContainer = new Div();
      final Label label = new Label(Labels.getLabel("liveedit.choose.site"));
      label.setStyle("font-weight: bold");
      label.setParent(labelContainer);
      welcomePanel.appendChild(labelContainer);
      final Div siteContainer = new Div();
      injectSites(siteContainer);
      welcomePanel.appendChild(siteContainer);
      return welcomePanel;
    }
 @Override
 protected Div createMainArea() {
   final Div ret = new Div();
   UITools.maximize(ret);
   final BrowserModel model = getModel();
   if (model instanceof DefaultLiveEditBrowserModel) {
     final DefaultLiveEditBrowserModel liveEditBrowserModel =
         (DefaultLiveEditBrowserModel) model;
     this.liveEditView = newDefaultLiveEditView(liveEditBrowserModel);
     this.liveEditView.getViewComponent().setParent(ret);
   } else {
     ret.appendChild(new Label(Labels.getLabel(EMPTY_MESSAGE)));
   }
   return ret;
 }
Esempio n. 18
0
  /**
   * when the "search/filter" button is clicked. It searches over a period. <br>
   * Checks if EndDate not before StartDate.<br>
   *
   * @param event
   */
  public void onClick$button_SecLoginlogList_bb_SearchDate(Event event) throws Exception {

    if (!(this.dbox_LoginLog_DateFrom.getValue() == null)
        && !(this.dbox_LoginLog_DateTo.getValue() == null)) {

      if (this.dbox_LoginLog_DateFrom.getValue().after(this.dbox_LoginLog_DateTo.getValue())) {
        MultiLineMessageBox.doSetTemplate();
        MultiLineMessageBox.show(Labels.getLabel("message_EndDate_Before_BeginDate"));
      } else {
        Date dateFrom = this.dbox_LoginLog_DateFrom.getValue();
        Date dateTo = this.dbox_LoginLog_DateTo.getValue();

        final Calendar calFrom = Calendar.getInstance();
        calFrom.setTime(dateFrom);
        calFrom.set(Calendar.AM_PM, 0);
        calFrom.set(Calendar.HOUR, 0);
        calFrom.set(Calendar.MINUTE, 0);
        calFrom.set(Calendar.SECOND, 1);
        dateFrom = calFrom.getTime();

        final Calendar calTo = Calendar.getInstance();
        calTo.setTime(dateTo);
        calTo.set(Calendar.AM_PM, 1);
        calTo.set(Calendar.HOUR, 11);
        calTo.set(Calendar.MINUTE, 59);
        calTo.set(Calendar.SECOND, 59);
        dateTo = calTo.getTime();

        // ++ create the searchObject and init sorting ++//
        final HibernateSearchObject<SecLoginlog> soSecLoginlog =
            new HibernateSearchObject<SecLoginlog>(SecLoginlog.class, getCountRows());
        // deeper loading of the relations to prevent the lazy
        // loading problem.
        soSecLoginlog.addFetch("ip2Country.countryCode");
        soSecLoginlog.addSort("lglLogtime", true);

        soSecLoginlog.addFilter(new Filter("lglLogtime", dateFrom, Filter.OP_GREATER_OR_EQUAL));
        soSecLoginlog.addFilter(new Filter("lglLogtime", dateTo, Filter.OP_LESS_OR_EQUAL));

        // Set the ListModel
        getPagedListWrapper()
            .init(soSecLoginlog, this.listBoxSecUserlog, this.paging_SecUserLogList);

        this.checkbox_SecLoginlogList_ShowAll.setChecked(false);
      }
    }
  }
Esempio n. 19
0
  private void doSimpan() throws InterruptedException {

    TPermohonan tPermohonan = gettPermohonan();
    Mttr mttr = new Mttr();
    doWriteComponentsToBean(tPermohonan, mttr);

    try {
      String uploadeFileName = null;
      if (getUploadMedia() != null) {
        uploadeFileName = getUploadMedia().getName();
      }
      getPermohonanService()
          .simpanAllTPermohonan(
              uploadeFileName,
              tPermohonan,
              mttr,
              getUserWorkspace().getUserSession().getEmployeeRole());
      TVerifikasi tVerifikasi =
          getPermohonanService()
              .getTVerifikasiByTIdossVerifikasiId(gettPermohonan().getT_idoss_permohonan_id());
      doWriteComponentsToBeanVer(tVerifikasi);
      getVerifikasiService().saveOrUpdateTVerifikasi(tVerifikasi);

    } catch (DataAccessException e) {
      String message = e.getMessage();
      String title = Labels.getLabel("message_Error");
      MultiLineMessageBox.doSetTemplate();
      MultiLineMessageBox.show(message, title, MultiLineMessageBox.OK, "ERROR", true);
    }

    ListModelList lml = (ListModelList) listbox_DaftarPermohonan.getListModel();

    // Check if the object is new or updated
    // -1 means that the obj is not in the list, so it's new.
    if (lml.indexOf(tPermohonan) == -1) {
      lml.add(tPermohonan);
    } else {
      lml.set(lml.indexOf(tPermohonan), tPermohonan);
    }
    lml.sort(new TPermohonanComparator(), true);
  }
    @Override
    protected HtmlBasedComponent createAdvancedArea() {
      final Div previewDataAreaDiv = new Div();

      previewDataAreaDiv.setStyle(
          "min-height: 40px; width: 100%; background: white; border-bottom: 1px solid #ccc");

      final Div attributesDiv = new Div();
      attributesDiv.setSclass("clearfix");
      attributesDiv.setStyle("text-align: left; width: 100%; ");
      renderEditors(attributesDiv);

      final Div attrContainerDiv = new Div();
      attrContainerDiv.setStyle("max-height: 265px; overflow-y: auto;");
      attrContainerDiv.appendChild(attributesDiv);
      previewDataAreaDiv.appendChild(attrContainerDiv);

      final Div buttonDiv = new Div();
      buttonDiv.setStyle(
          "padding: 3px 20px 3px 24px; text-align:left; height: 26px; position:relative");

      final Button applyButton = new Button(Labels.getLabel("general.apply"));
      applyButton.setStyle("position:absolute; right:20px; top: 4px");
      applyButton.addEventListener(
          Events.ON_CLICK,
          new org.zkoss.zk.ui.event.EventListener() {
            @Override
            public void onEvent(final Event event) throws Exception // NOPMD: ZK Specific
                {

              updatePreviewData();
            }
          });
      buttonDiv.appendChild(applyButton);
      previewDataAreaDiv.appendChild(buttonDiv);

      return previewDataAreaDiv;
    }
 /* (non-Javadoc)
  * @see org.zkoss.zss.ui.sys.ua.impl.AbstractHandler#processAction(org.zkoss.zss.ui.UserActionContext)
  */
 @Override
 protected boolean processAction(UserActionContext ctx) {
   Sheet sheet = ctx.getSheet();
   AreaRef selection = ctx.getSelection();
   CellSelectionType type = ctx.getSelectionType();
   Range range = Ranges.range(sheet, selection);
   if (range.isProtected()) {
     showProtectMessage();
     return true;
   }
   // zss-623, extends to row,column area
   switch (type) {
     case ROW:
       range = range.toRowRange();
       break;
     case COLUMN:
       range = range.toColumnRange();
       break;
     case ALL:
       // we don't allow to set whole sheet style, use column range instead
       range = range.toColumnRange();
   }
   selection =
       new AreaRef(range.getRow(), range.getColumn(), range.getLastRow(), range.getLastColumn());
   UndoableActionManager uam = ctx.getSpreadsheet().getUndoableActionManager();
   uam.doAction(
       new CellStyleAction(
           Labels.getLabel("zss.undo.cellStyle"),
           sheet,
           selection.getRow(),
           selection.getColumn(),
           selection.getLastRow(),
           selection.getLastColumn(),
           CellOperationUtil.getVerticalAligmentApplier(_type)));
   return true;
 }
Esempio n. 22
0
  private void initList() {
    // incList
    List<GenericListHeaderType> header = new LinkedList<GenericListHeaderType>();
    header.add(
        new GenericListHeaderType(
            Labels.getLabel("common.code"), 0, "", true, "String", true, true, false, false));
    header.add(
        new GenericListHeaderType(
            Labels.getLabel("common.relation"), 130, "", true, "String", true, true, false, false));
    header.add(
        new GenericListHeaderType(
            Labels.getLabel("common.code"), 0, "", true, "String", true, true, false, false));

    List<GenericListRowType> dataList = new LinkedList<GenericListRowType>();

    /*for (MetadataParameter meta : valueSet.getMetadataParameters())
    {
    GenericListRowType row = createRowFromMetadataParameter(meta);
    dataList.add(row);
    }*/
    // Liste initialisieren
    Include inc = (Include) getFellow("incList");
    Window winGenericList = (Window) inc.getFellow("winGenericList");
    genericList = (GenericList) winGenericList;

    // genericList.setUserDefinedId("1");
    genericList.setListActions(this);
    genericList.setButton_new(false);
    genericList.setButton_edit(false);
    genericList.setButton_delete(true);
    genericList.setListHeader(header);
    genericList.setDataList(dataList);

    genericList.removeCustomButtons();

    Button buttonAuto =
        new Button(
            Labels.getLabel("common.automatic") + "...", "/rsc/img/design/automatic_16x16.png");
    buttonAuto.addEventListener(
        Events.ON_CLICK,
        new EventListener<Event>() {
          public void onEvent(Event t) throws Exception {
            automaticAssociations();
          }
        });
    buttonAuto.setAttribute("disabled", false);
    buttonAuto.setAttribute("right", true);
    genericList.addCustomButton(buttonAuto);

    Button button = new Button(Labels.getLabel("common.save"), "/rsc/img/design/save_16x16.png");
    button.addEventListener(
        Events.ON_CLICK,
        new EventListener<Event>() {
          public void onEvent(Event t) throws Exception {
            saveAssociations();
          }
        });
    button.setAttribute("disabled", false);
    button.setAttribute("right", true);

    genericList.addCustomButton(button);
  }
Esempio n. 23
0
  public ProfileComponent() {
    super();
    final PlayerProfileData player = getPlayerFacade().getCurrentPlayer();

    final Grid profileGrid = new Grid();
    profileGrid.setSclass("profileGrid");

    final Rows profileRows = new Rows();
    profileGrid.appendChild(profileRows);

    final Row idRow = new Row();
    idRow.setSclass("profileRow");
    idRow.appendChild(new Label(Labels.getLabel("profile.id")));
    idRow.appendChild(new Label(player.getId()));
    profileRows.appendChild(idRow);

    final Row nameRow = new Row();
    nameRow.setSclass("profileRow");
    nameRow.appendChild(new Label(Labels.getLabel("profile.name")));
    final Textbox nameBox = new Textbox(player.getName());
    nameBox.setConstraint(
        new SimpleConstraint(SimpleConstraint.NO_EMPTY, Labels.getLabel("register.error.noname")));
    nameRow.appendChild(nameBox);
    profileRows.appendChild(nameRow);

    final Row mailRow = new Row();
    mailRow.setSclass("profileRow");
    mailRow.appendChild(new Label(Labels.getLabel("profile.email")));
    final Textbox mailBox = new Textbox(player.getEMail());
    mailBox.setConstraint("/.+@.+\\.[a-z]+/: " + Labels.getLabel("register.error.noemail"));
    mailRow.appendChild(mailBox);
    profileRows.appendChild(mailRow);

    final Row pwdRow = new Row();
    pwdRow.setSclass("profileRow");
    pwdRow.appendChild(new Label(Labels.getLabel("profile.password")));
    final Textbox pwdBox = new Textbox(player.getPassword());
    // pwdBox.setConstraint(new SimpleConstraint(SimpleConstraint.NO_EMPTY,
    // Labels.getLabel("register.error.nopassword")));
    pwdBox.setType("password");
    pwdRow.appendChild(pwdBox);
    profileRows.appendChild(pwdRow);

    final Row pwd2Row = new Row();
    pwd2Row.setSclass("profileRow");
    pwd2Row.appendChild(new Label(Labels.getLabel("profile.passwordagain")));
    final Textbox pwd2Box = new Textbox(player.getPassword());
    pwd2Box.setConstraint(
        new Constraint() {
          @Override
          public void validate(final Component comp, final Object value)
              throws WrongValueException {
            if (!(pwdBox.getValue().equals(value))) {
              throw new WrongValueException(
                  comp, Labels.getLabel("register.error.unequalpassword"));
            }
          }
        });
    pwd2Box.setType("password");
    pwd2Row.appendChild(pwd2Box);
    profileRows.appendChild(pwd2Row);

    final Row countryRow = new Row();
    countryRow.setSclass("profileRow");
    countryRow.appendChild(new Label(Labels.getLabel("profile.country")));
    final Combobox countryBox = new Combobox();
    countryBox.setConstraint(
        new SimpleConstraint(
            SimpleConstraint.NO_EMPTY, Labels.getLabel("register.error.nocountry")));
    countryBox.setAutodrop(true);
    countryBox.setReadonly(true);
    fillCombo(countryBox, player.getLocale());
    countryRow.appendChild(countryBox);
    profileRows.appendChild(countryRow);

    final Row avCompetitionsRow = new Row();
    avCompetitionsRow.setSclass("competitionsRow");
    avCompetitionsRow.appendChild(new Label(Labels.getLabel("profile.availableCompetitions")));
    final Listbox listbox = new Listbox();
    listbox.setSclass("competitionsListbox");
    avCompetitionsRow.appendChild(listbox);
    listbox.setCheckmark(true);
    listbox.setMultiple(true);

    final List<CompetitionData> comps = getPlayerFacade().getAllCompetitions();
    for (final CompetitionData cmpData : comps) {
      final Listitem listItem = new Listitem(cmpData.getName());
      listItem.setValue(cmpData);
      listItem.setSelected(cmpData.isActive());
      listItem.setDisabled(
          !cmpData.isDeactivatable() || (cmpData.isCurrentCompetition() && comps.size() != 1));
      listbox.appendChild(listItem);
    }

    profileRows.appendChild(avCompetitionsRow);

    final Row buttonRow = new Row();
    buttonRow.setSclass("profileRow");
    final Button button = new Button(Labels.getLabel("profile.submit"));
    button.addEventListener(
        Events.ON_CLICK,
        new EventListener() {
          @Override
          public void onEvent(final Event event) {
            player.setEMail(mailBox.getValue());
            player.setName(nameBox.getValue());

            if (StringUtils.isNotBlank(pwdBox.getValue())
                && pwdBox.getValue().equals(pwd2Box.getValue())) {
              player.setPassword(pwdBox.getValue());
            }
            player.setLocale((Locale) countryBox.getSelectedItem().getValue());

            final List<CompetitionData> cmps = new ArrayList<CompetitionData>();
            for (final Object listItem : listbox.getSelectedItems()) {
              if (listItem instanceof Listitem) {
                final Object value = ((Listitem) listItem).getValue();
                if (value instanceof CompetitionData) {
                  cmps.add((CompetitionData) value);
                }
              }
            }

            getPlayerFacade().setActiveCompetitions(cmps);

            getPlayerFacade().updatePlayer(player);

            try {
              Messagebox.show(Labels.getLabel("profile.update.success"));
              // TODO proper update mechanism
              Executions.sendRedirect("/");
            } catch (final InterruptedException e) {
              LOG.warn("Error while showing messagebox: ", e);
            }
          }
        });
    buttonRow.appendChild(button);
    profileRows.appendChild(buttonRow);

    this.appendChild(profileGrid);

    final Div detailsDiv = new Div();
    detailsDiv.setSclass("rankingUserDetails");

    final Img img = new Img();
    final Div imgCnt = new Div();
    imgCnt.appendChild(img);
    imgCnt.setSclass("rankingUserDetailsImg");
    img.setDynamicProperty("src", player.getPictureUrl());
    detailsDiv.appendChild(imgCnt);

    final Button uploadButton = new Button(Labels.getLabel("profile.upload"));
    uploadButton.setSclass("btngreen profileUserDetailsUpload");
    detailsDiv.appendChild(uploadButton);

    uploadButton.addEventListener(
        Events.ON_CLICK,
        new EventListener() {

          @Override
          public void onEvent(final Event event) throws InterruptedException {
            final Object media = Fileupload.get();
            if (media instanceof Image) {
              final Image image = (Image) media;
              player.setPictureUrl(
                  getPlayerFacade().uploadProfilePicture(image.getByteData(), image.getName()));
              img.setDynamicProperty("src", player.getPictureUrl());
            } else if (media != null) {
              Messagebox.show("Not an image: " + media, "Error", Messagebox.OK, Messagebox.ERROR);
            }
          }
        });
    this.appendChild(detailsDiv);
  }
Esempio n. 24
0
  private void saveAssociations() {
    logger.debug("saveAssociations()");

    final org.zkoss.zk.ui.Desktop desktop = Executions.getCurrent().getDesktop();
    if (desktop.isServerPushEnabled() == false) desktop.enableServerPush(true);
    final EventListener el = this;

    Clients.showBusy(Labels.getLabel("common.saveChanges") + "...");

    final List<CodeSystemEntityVersionAssociation> failureList =
        new LinkedList<CodeSystemEntityVersionAssociation>();

    // Import durchführen
    Timer timer = new Timer();
    timer.schedule(
        new TimerTask() {
          @Override
          public void run() {
            try {
              String sFailure = "";

              logger.debug(
                  "save associations, count: " + genericList.getListbox().getListModel().getSize());

              // save associations
              // for(Object obj : genericList.getListbox().getListModel())
              for (int i = 0; i < genericList.getListbox().getListModel().getSize(); ++i) {
                GenericListRowType row =
                    (GenericListRowType) genericList.getListbox().getListModel().getElementAt(i);
                logger.debug("row type: " + row.getData().getClass().getCanonicalName());

                if (row.getData() instanceof CodeSystemEntityVersionAssociation) {
                  CodeSystemEntityVersionAssociation cseva =
                      (CodeSystemEntityVersionAssociation) row.getData();
                  // cseva.getCodeSystemEntityVersionByCodeSystemEntityVersionId1()

                  CreateConceptAssociationRequestType request =
                      new CreateConceptAssociationRequestType();
                  request.setLoginToken(SessionHelper.getSessionId());
                  request.setCodeSystemEntityVersionAssociation(cseva);

                  CreateConceptAssociationResponse.Return response =
                      WebServiceHelper.createConceptAssociation(request);

                  logger.debug("result: " + response.getReturnInfos().getMessage());

                  if (response.getReturnInfos().getStatus()
                      == de.fhdo.terminologie.ws.conceptassociation.Status.FAILURE) {
                    failureList.add(cseva);
                    sFailure = response.getReturnInfos().getMessage();
                  }
                }
              }

              // Executions.schedule(desktop, el, new Event("finish", null, ""));
              Executions.activate(desktop);

              Clients.clearBusy();

              List<GenericListRowType> rows = new LinkedList<GenericListRowType>();
              for (CodeSystemEntityVersionAssociation cseva : failureList) {
                rows.add(createRow(cseva));
              }
              genericList.setDataList(rows);

              // reload side lists (change mapping entries)
              reloadLists();

              if (sFailure.length() > 0) throw new Exception(sFailure);
              //  Messagebox.show(sFailure);

              Executions.deactivate(desktop);
              //              Executions.schedule(desktop, el, new Event("updateStatus", null,
              // msg));
            } catch (Exception ex) {
              LoggingOutput.outputException(ex, this);
              try {
                Executions.activate(desktop);

                Clients.clearBusy();
                Messagebox.show(ex.getLocalizedMessage());
                Executions.deactivate(desktop);
              } catch (Exception e) {

              }
            }
          }
        },
        100);
  }
Esempio n. 25
0
  public void automaticAssociations() {
    logger.debug("automaticAssociations()");

    if (Messagebox.show(
            Labels.getLabel("common.automaticMsg"),
            Labels.getLabel("common.automatic"),
            Messagebox.YES | Messagebox.NO,
            Messagebox.QUESTION)
        == Messagebox.YES) {
      final org.zkoss.zk.ui.Desktop desktop = Executions.getCurrent().getDesktop();
      if (desktop.isServerPushEnabled() == false) desktop.enableServerPush(true);

      Clients.showBusy(Labels.getLabel("loginHelper.working"));

      final CodeSystem cs1 = (CodeSystem) SessionHelper.getValue("selectedCS1");
      final CodeSystem cs2 = (CodeSystem) SessionHelper.getValue("selectedCS2");

      // start timer to enable busy message
      Timer timer = new Timer();
      timer.schedule(
          new TimerTask() {
            @Override
            public void run() {
              try {
                // List<CodeSystemEntityVersionAssociation> list = new
                // LinkedList<CodeSystemEntityVersionAssociation>();
                logger.debug("cs1: " + cs1.getName());
                logger.debug("cs2: " + cs2.getName());

                long csvId1 = cs1.getCodeSystemVersions().get(0).getVersionId();
                long csvId2 = cs2.getCodeSystemVersions().get(0).getVersionId();

                logger.debug("csvId1: " + csvId1);
                logger.debug("csvId2: " + csvId2);

                // ListCodeSystemConceptsRequestType
                ListCodeSystemConceptsResponse.Return response1 =
                    WebServiceHelper.listCodeSystemConcepts(csvId1);
                ListCodeSystemConceptsResponse.Return response2 =
                    WebServiceHelper.listCodeSystemConcepts(csvId2);

                logger.debug("result 1: " + response1.getReturnInfos().getMessage());
                logger.debug("result 2: " + response2.getReturnInfos().getMessage());

                Executions.activate(desktop);

                if (response1.getReturnInfos().getStatus() == Status.OK
                    && response2.getReturnInfos().getStatus() == Status.OK) {

                  for (CodeSystemEntity cse1 : response1.getCodeSystemEntity()) {
                    CodeSystemEntityVersion csev1 = cse1.getCodeSystemEntityVersions().get(0);
                    CodeSystemConcept csc1 = csev1.getCodeSystemConcepts().get(0);

                    for (CodeSystemEntity cse2 : response2.getCodeSystemEntity()) {
                      CodeSystemEntityVersion csev2 = cse2.getCodeSystemEntityVersions().get(0);
                      CodeSystemConcept csc2 = csev2.getCodeSystemConcepts().get(0);

                      // check same code
                      if (csc1.getCode().equals(csc2.getCode())) {
                        // match
                        addAutomaticMatch(csev1, csev2);
                      }

                      // check containing text
                      if (csc1.getTerm().toLowerCase().contains(csc2.getTerm().toLowerCase())) {
                        addAutomaticMatch(csev1, csev2);
                      }
                      if (csc2.getTerm().toLowerCase().contains(csc1.getTerm().toLowerCase())) {
                        addAutomaticMatch(csev2, csev1);
                      }
                    }
                  }
                }

                // read data of both codesystems
                /*Include incL = (Include) getFellow("incContentLeft");
                ContentAssociationEditor contentEditor1 = (ContentAssociationEditor)incL.getDynamicProperty("instance");

                Include incR = (Include) getFellow("incContentRight");
                ContentAssociationEditor contentEditor2 = (ContentAssociationEditor)incL.getDynamicProperty("instance");

                ContentConcepts content1 = contentEditor1.getContent();
                ContentConcepts content2 = contentEditor2.getContent();

                TreeModel model1 = content1.getConcepts().getTreeConcepts().getModel();
                logger.debug("root: " + model1.getRoot().getClass().getCanonicalName());*/
                // Executions.schedule(desktop, el, new Event("finish", null, ""));
                Clients.clearBusy();

                Executions.deactivate(desktop);
              } catch (Exception ex) {
                LoggingOutput.outputException(ex, this);
                try {
                  Executions.activate(desktop);

                  Clients.clearBusy();
                  Messagebox.show(ex.getLocalizedMessage());
                  Executions.deactivate(desktop);
                } catch (Exception e) {

                }
              }
            }
          },
          10);
    }
  }
Esempio n. 26
0
  /**
   * Deletes a orderPosition object from database.<br>
   *
   * @throws InterruptedException
   */
  private void doDelete() throws InterruptedException {

    // Show a confirm box
    String msg =
        Labels.getLabel("message.Question.Are_you_sure_to_delete_this_record")
            + "\n\n --> "
            + this.orderposition.getArticle().getArtKurzbezeichnung();
    String title = Labels.getLabel("message.Deleting.Record");

    MultiLineMessageBox.doSetTemplate();
    if (MultiLineMessageBox.show(
            msg,
            title,
            MultiLineMessageBox.YES | MultiLineMessageBox.NO,
            MultiLineMessageBox.QUESTION,
            true,
            new EventListener() {
              @Override
              public void onEvent(Event evt) {
                switch (((Integer) evt.getData()).intValue()) {
                  case MultiLineMessageBox.YES:
                    try {
                      delete();
                    } catch (InterruptedException e) {
                      // TODO Auto-generated catch block
                      e.printStackTrace();
                    }
                  case MultiLineMessageBox.NO:
                    break; //
                }
              }

              // delete from database
              private void delete() throws InterruptedException {

                try {
                  getOrderService().delete(orderposition);
                } catch (DataAccessException e) {
                  ZksampleMessageUtils.showErrorMessage(e.getMostSpecificCause().toString());
                }

                // now synchronize the listBox in the parent zul-file
                final ListModelList lml = (ListModelList) listBoxOrderOrderPositions.getListModel();
                // Check if the orderPosition object is new or updated
                // -1 means that the obj is not in the list, so it's
                // new.
                if (lml.indexOf(orderposition) == -1) {
                } else {
                  lml.remove(lml.indexOf(orderposition));
                }

                // +++++++ now synchronize the listBox in the parent
                // zul-file
                // +++ //
                Listbox listBoxOrderArticle = orderListCtrl.getListBoxOrderArticle();
                // now synchronize the orderposition listBox
                ListModelList lml3 = (ListModelList) listBoxOrderArticle.getListModel();
                // Check if the orderPosition object is new or updated
                // -1 means that the obj is not in the list, so it's
                // new.
                if (lml3.indexOf(orderposition) == -1) {
                } else {
                  lml3.remove(lml3.indexOf(orderposition));
                }

                orderPositionDialogWindow.onClose(); // close
                // the
                // dialog
              }
            })
        == MultiLineMessageBox.YES) {}
  }
Esempio n. 27
0
 public String getSurveyFileTypeLabel(SurveyFile surveyFile) {
   SurveyFileType type = surveyFile.getType();
   return Labels.getLabel("survey.file.type." + type.name().toLowerCase(Locale.ENGLISH));
 }
  /** Creates the components..<br> */
  private void createComponents() {

    /**
     * !! Windows as NameSpaceContainer to prevent not unique id's error from other dashboard module
     * buttons or other used components.
     */
    Window win = new Window();
    win.setBorder("none");
    win.setParent(this);

    Groupbox gb = new Groupbox();
    gb.setMold("3d");
    gb.setClosable(false);
    gb.setParent(win);
    Caption cap = new Caption();
    cap.setImage("/images/icons/new_icons_10.gif");
    cap.setLabel(Labels.getLabel("common.Application.History"));
    cap.setStyle("padding: 0px;");
    cap.setParent(gb);

    // Buttons Toolbar/Timer
    Div div = new Div();
    div.setSclass("z-toolbar");
    div.setStyle("padding: 0px");
    div.setParent(cap);
    Hbox hbox = new Hbox();
    hbox.setPack("stretch");
    hbox.setSclass("hboxRemoveWhiteStrips");
    hbox.setWidth("100%");
    hbox.setParent(div);
    Toolbar toolbarRight = new Toolbar();
    toolbarRight.setAlign("end");
    toolbarRight.setStyle("float:right; border-style: none;");
    toolbarRight.setParent(hbox);

    Hbox hboxBtn = new Hbox();
    hboxBtn.setSclass("hboxRemoveWhiteStrips");
    hboxBtn.setWidth("100%");
    hboxBtn.setParent(toolbarRight);

    //		Paging paging = new Paging();
    //		paging.setParent(hboxBtn);
    //		paging.setDetailed(true);

    if (isTimerControl()) {
      Button btnTimer = new Button();
      btnTimer.setId("btnTimer");
      btnTimer.setHeight("22px");
      btnTimer.setImage("/images/icons/clock1_16x16.gif");

      // convert to seconds
      int seconds = (int) Math.round(getDelay() / 1000);

      if (seconds > 60) {
        // convert to minutes and set localization to minutes
        int minutes = (int) Math.round((getDelay() / 1000) / 60);
        btnTimer.setTooltiptext(
            Labels.getLabel("btnTimer.tooltiptext")
                + " "
                + minutes
                + " "
                + Labels.getLabel("common.Minutes"));
      } else
        // set localization to seconds
        btnTimer.setTooltiptext(
            Labels.getLabel("btnTimer.tooltiptext")
                + " "
                + seconds
                + " "
                + Labels.getLabel("common.Seconds"));

      btnTimer.addEventListener("onClick", new BtnClickListener());
      btnTimer.setParent(hboxBtn);
    }

    Button btnRefresh = new Button();
    btnRefresh.setId("btnRefresh");
    btnRefresh.setHeight("22px");
    btnRefresh.setLabel("!");
    btnRefresh.setTooltiptext(Labels.getLabel("btnRefresh.tooltiptext"));
    btnRefresh.addEventListener("onClick", new BtnClickListener());
    btnRefresh.setParent(hboxBtn);
    // END Buttons Toolbar/Timer

    // body
    Borderlayout bl = new Borderlayout();
    bl.setHeight(getModulHeight() + "px");
    bl.setParent(gb);
    Center ct = new Center();
    ct.setSclass("FDCenterNoBorder");
    ct.setStyle("background-color: white");
    ct.setFlex(true);
    ct.setParent(bl);

    // Listbox
    listbox = new Listbox();
    listbox.setStyle("border: none;");
    listbox.setHeight("100%");
    listbox.setVisible(true);
    listbox.setParent(ct);
    listbox.setItemRenderer(new ItemRenderer());

    Listhead listhead = new Listhead();
    listhead.setParent(listbox);

    Listheader listheader1 = new Listheader();
    listheader1.setWidth("100px");
    listheader1.setHeight("0px");
    listheader1.setParent(listhead);

    Listheader listheader2 = new Listheader();
    listheader2.setWidth("100%");
    listheader1.setHeight("0px");
    listheader2.setParent(listhead);

    doReadData();
  }
    @Override
    protected void createAdditionalRightCaptionComponents(final Hbox hbox) {
      UITools.detachChildren(hbox);
      final BrowserModel browserModel = getModel();
      if (browserModel instanceof DefaultLiveEditBrowserModel) {
        final DefaultLiveEditBrowserModel liveEditBrowserModel =
            (DefaultLiveEditBrowserModel) getModel();
        if (liveEditBrowserModel.getActiaveCatalogVersion() != null) {
          final UIBrowserArea area = getModel().getArea();
          if (area instanceof DefaultLiveEditBrowserArea) {
            final DefaultLiveEditBrowserArea liveEditArea = (DefaultLiveEditBrowserArea) area;
            final boolean liveEditModeEnabled = liveEditArea.isLiveEditModeEnabled();
            // Live edit button
            createRightCaptionButton(
                Labels.getLabel(liveEditModeEnabled ? "browser.liveEditOn" : "browser.liveEditOff"),
                (liveEditModeEnabled
                    ? "btnliveeditcontent_quickedit_active"
                    : "btnliveeditcontent_quickedit"),
                hbox,
                new org.zkoss.zk.ui.event.EventListener() {
                  @Override
                  public void onEvent(final Event event) throws Exception // NOPMD: ZK Specific
                      {
                    liveEditArea.fireModeChange();
                  }
                });

            final boolean isPreviewDataActive = liveEditBrowserModel.isPreviewDataVisible();
            // Preview context button
            createRightCaptionButton(
                Labels.getLabel("browser.previewData"),
                (isPreviewDataActive
                    ? "btnliveeditcontent_previewcontext_active"
                    : "btnliveeditcontent_previewcontext"),
                hbox,
                new org.zkoss.zk.ui.event.EventListener() {
                  @Override
                  public void onEvent(final Event event) throws Exception // NOPMD: ZK Specific
                      {
                    liveEditBrowserModel.fireTogglePreviewDataMode(
                        DefaultLiveEditContentBrowser.this);
                  }
                });

            final String sitePk = getCmsAdminSiteService().getActiveSite().getPk().toString();
            final String catalogPk =
                getCmsAdminSiteService().getActiveCatalogVersion().getPk().toString();

            // Open in page edit button
            if (StringUtils.isNotBlank(liveEditBrowserModel.getRelatedPagePk())) {
              createRightCaptionButton(
                  Labels.getLabel("browser.openInPageEdit"),
                  "btnliveeditcontent_pageedit",
                  hbox,
                  new org.zkoss.zk.ui.event.EventListener() {
                    @Override
                    public void onEvent(final Event event) throws Exception // NOPMD: ZK Specific
                        {
                      final StringBuilder urlBuilder = new StringBuilder();
                      urlBuilder.append("?").append(PERSP_TAG);
                      urlBuilder.append("=").append(PAGE_VIEW_PERSPECTIVE_ID);
                      urlBuilder.append("&").append(EVENTS_TAG);
                      urlBuilder.append("=").append(CMS_NAVIGATION_EVENT);
                      urlBuilder.append("&").append(CMS_PNAV_SITE);
                      urlBuilder.append("=").append(sitePk);
                      urlBuilder.append("&").append(CMS_PNAV_CATALOG);
                      urlBuilder.append("=").append(catalogPk);
                      urlBuilder.append("&").append(CMS_PNAV_PAGE);
                      urlBuilder.append("=").append(liveEditBrowserModel.getRelatedPagePk());

                      if (LOG.isDebugEnabled()) {
                        LOG.debug("URL for Open in Page edit event: " + urlBuilder.toString());
                      }

                      Executions.getCurrent().sendRedirect(urlBuilder.toString());
                    }
                  });
            }
          }
        }
      }
    }
  @Listen("onClick=#editBtn")
  public void editCodeDb() {
    try {
      List<ErmCodeDb> codeDbList =
          ((ErmCodeDbService) SpringUtil.getBean("ermCodeDbService")).findAllCodeDb(webEmployee);
      String tempId = "OB";
      Long number = (long) codeDbList.size();
      number = number + 1;
      String dbId = tempId + RandomIDGenerator.fmtLong(number, 9);
      if (!aDbId.equals("") && aDbId != null) {
        codeDb.setDbId(aDbId);
      } else {
        codeDb.setDbId(dbId);
      }
      aDbId = dbId;
      dbIdTxt.setValue(dbId);
      if (dbNameTxt.getValue() != null && !"".equals(dbNameTxt.getValue())) {
        codeDb.setName(dbNameTxt.getValue());
      } else {
        ZkUtils.showExclamation(
            Labels.getLabel("webErwSource.nameZhTw") + " " + Labels.getLabel("cannottNull"),
            Labels.getLabel("warn"));
        dbNameTxt.focus();
        return;
      }
      if (resourcesIdTxt.getValue() != null) {
        codeDb.setResourcesId(resourcesIdTxt.getValue());
      }
      codeDb.setHistory("N");
      if (ezproxyRdo.getSelectedItem().getValue() != null) {
        codeDb.setEzproxy(ezproxyRdo.getSelectedItem().getValue().toString());
      }
      if (urlTxt.getValue() != null && !"".equals(urlTxt.getValue())) {
        codeDb.setUrl(urlTxt.getValue());
      }
      if (orderNoIbx.getValue() != null) {
        codeDb.setOrderNo(orderNoIbx.getValue());
      }
      codeDb.setIsDataEffid(1);
      codeDb.setLatelyChangedDate(new Date());
      codeDb.setLatelyChangedUser(webEmployee.getEmployeesn());
      ((ErmCodeDbService) SpringUtil.getBean("ermCodeDbService")).saveCodeDb(codeDb);
      ((WebSysLogService) SpringUtil.getBean("webSysLogService"))
          .editLog(
              ZkUtils.getRemoteAddr(),
              codeDb.getWebEmployee().getEmployeesn(),
              "codeDb_" + codeDb.getDbId());

      ZkUtils.showInformation(Labels.getLabel("saveOK"), Labels.getLabel("info"));
      Listbox resCodeDbLix =
          (Listbox) editErmResDataBaseWin.getParent().getFellowIfAny("resCodeDbLix");
      Textbox name = (Textbox) editErmResDataBaseWin.getParent().getFellowIfAny("nameTxt");
      Textbox dbIdParent = (Textbox) editErmResDataBaseWin.getParent().getFellowIfAny("dbIdTxt");
      List<ErmCodeDb> codeDbList1 =
          ((ErmCodeDbService) SpringUtil.getBean("ermCodeDbService"))
              .findPublisherList("", "", name.getValue(), dbIdParent.getValue(), webEmployee);
      ListModelList<ErmCodeDb> model = new ListModelList<ErmCodeDb>(codeDbList1);
      model.setMultiple(true);
      resCodeDbLix.setModel(model);
      resCodeDbLix.setActivePage(Integer.valueOf(currentPage));
      dbIdTxt.setValue(codeDb.getDbId());
      addSuunitBtn.setDisabled(false);
      delSuunitBtn.setDisabled(false);
      /*
       * String url = "ermCodeDb/ermCodeDb.zul";
       * ZkUtils.refurbishMethod(url);
       */

    } catch (WrongValueException e) {
      log.error("新增資料庫異常" + e);
    }
  }