Beispiel #1
0
  /**
   * 向服务器发送命令行,给服务器端处理
   *
   * @param lines 命令行
   */
  public static void clientSend(String[] lines) {
    if (lines != null && lines.length <= 0) {
      return;
    }
    Socket socket = null;
    PrintWriter writer = null;
    try {
      socket = new Socket("localhost", port);

      writer =
          new PrintWriter(
              new BufferedWriter(
                  new OutputStreamWriter(
                      socket.getOutputStream(), EncodeConstants.ENCODING_UTF_8)));
      for (int i = 0; i < lines.length; i++) {
        writer.println(lines[i]);
      }

      writer.flush();
    } catch (Exception e) {
      FRContext.getLogger().error(e.getMessage(), e);
    } finally {
      try {
        writer.close();
        socket.close();
      } catch (IOException e) {
        FRContext.getLogger().error(e.getMessage(), e);
      }
    }
  }
Beispiel #2
0
  /**
   * 访问服务器环境
   *
   * @param names 参数名字
   * @param values 参数值
   */
  public static void visitEnvServerByParameters(String[] names, String[] values) {
    int len = Math.min(ArrayUtils.getLength(names), ArrayUtils.getLength(values));
    String[] segs = new String[len];
    for (int i = 0; i < len; i++) {
      try {
        // 设计器里面据说为了改什么界面统一, 把分隔符统一用File.separator, 意味着在windows里面报表路径变成了\
        // 以前的超链, 以及预览url什么的都是/, 产品组的意思就是用到的地方替换下, 真恶心.
        String value = values[i].replaceAll("\\\\", "/");
        segs[i] =
            URLEncoder.encode(CodeUtils.cjkEncode(names[i]), EncodeConstants.ENCODING_UTF_8)
                + "="
                + URLEncoder.encode(CodeUtils.cjkEncode(value), "UTF-8");
      } catch (UnsupportedEncodingException e) {
        FRContext.getLogger().error(e.getMessage(), e);
      }
    }
    String postfixOfUri = (segs.length > 0 ? "?" + StableUtils.join(segs, "&") : StringUtils.EMPTY);

    if (FRContext.getCurrentEnv() instanceof RemoteEnv) {
      try {
        if (Utils.isEmbeddedParameter(postfixOfUri)) {
          String time = Calendar.getInstance().getTime().toString().replaceAll(" ", "");
          boolean isUserPrivilege =
              ((RemoteEnv) FRContext.getCurrentEnv()).writePrivilegeMap(time, postfixOfUri);
          postfixOfUri =
              isUserPrivilege
                  ? postfixOfUri
                      + "&fr_check_url="
                      + time
                      + "&id="
                      + FRContext.getCurrentEnv().getUserID()
                  : postfixOfUri;
        }

        String urlPath = getWebBrowserPath();
        Desktop.getDesktop().browse(new URI(urlPath + postfixOfUri));
      } catch (Exception e) {
        FRContext.getLogger().error("cannot open the url Successful", e);
      }
    } else {
      try {
        String web = GeneralContext.getCurrentAppNameOfEnv();
        String url =
            "http://localhost:"
                + DesignerEnvManager.getEnvManager().getJettyServerPort()
                + "/"
                + web
                + "/"
                + ConfigManager.getProviderInstance().getServletMapping()
                + postfixOfUri;
        StartServer.browerURLWithLocalEnv(url);
      } catch (Throwable e) {
        //
      }
    }
  }
Beispiel #3
0
  private static FRFont getCurrentLocaleFont() {
    FRFont guiFRFont;
    Locale defaultLocale = Locale.getDefault();

    if (isDisplaySimSun(defaultLocale)) {
      guiFRFont = getNamedFont("SimSun");
    } else if (isDisplayDialog(defaultLocale)) {
      guiFRFont = getNamedFont("Dialog");
    } else {
      guiFRFont = getNamedFont("Tahoma");
    }

    // 先初始化的设计器locale, 后初始化lookandfeel.如果顺序改了, 这边也要调整.
    Locale designerLocale = FRContext.getLocale();
    String file = Inter.getLocText("FR-Designer_File");
    char displayChar = file.charAt(0);
    if (!guiFRFont.canDisplay(displayChar)) {
      // 如果不能用默认的语言显示字体, 比如想在英文系统里用中文设计器
      // 默认语言(中文:宋体, 英文:Tahoma, 其他:Dialog)
      guiFRFont = getNamedFont("SimSun");
      if (!guiFRFont.canDisplay(displayChar)) {
        // 比如想在中文或英文系统里用韩文设计器
        guiFRFont = getNamedFont("Dialog");
        if (!guiFRFont.canDisplay(displayChar)) {
          FRContext.getLogger().error(Inter.getLocText("FR-Base_SimSun_Not_Found"));
        }
      }
    }

    return guiFRFont;
  }
Beispiel #4
0
 /**
  * 动作
  *
  * @param e 事件
  */
 public void actionPerformed(ActionEvent e) {
   DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
   Env selectedEnv = envManager.getEnv(this.getName());
   try {
     if (selectedEnv instanceof RemoteEnv && !((RemoteEnv) selectedEnv).testServerConnection()) {
       JOptionPane.showMessageDialog(
           DesignerContext.getDesignerFrame(),
           Inter.getLocText(new String[] {"M-SwitchWorkspace", "Failed"}));
       return;
     }
     String remoteVersion = selectedEnv.getDesignerVersion();
     if (StringUtils.isBlank(remoteVersion)
         || ComparatorUtils.compare(remoteVersion, ProductConstants.DESIGNER_VERSION) < 0) {
       String infor = Inter.getLocText("Server-version-tip");
       String moreInfo = Inter.getLocText("Server-version-tip-moreInfo");
       FRLogger.getLogger().log(Level.WARNING, infor);
       new InformationWarnPane(infor, moreInfo, Inter.getLocText("Tooltips")).show();
       return;
     }
     SignIn.signIn(selectedEnv);
     LicUtils.resetBytes();
     HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().refreshToolArea();
     fireDSChanged();
   } catch (Exception em) {
     FRContext.getLogger().error(em.getMessage(), em);
     JOptionPane.showMessageDialog(
         DesignerContext.getDesignerFrame(),
         Inter.getLocText(new String[] {"M-SwitchWorkspace", "Failed"}));
     TemplatePane.getInstance().editItems();
   }
 }