Esempio n. 1
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;
  }
Esempio n. 2
0
  /** execute method之后,取返回的inputstream */
  private static ByteArrayInputStream execute4InputStream(HttpClient client) throws Exception {
    int statusCode = client.getResponseCode();
    if (statusCode != HttpURLConnection.HTTP_OK) {
      throw new EnvException("Method failed: " + statusCode);
    }
    InputStream in = client.getResponseStream();
    if (in == null) {
      return null;
    }
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    try {
      Utils.copyBinaryTo(in, out);

      // 看一下传过来的byte[]是不是DesignProcessor.INVALID,如果是的话,就抛Exception
      byte[] bytes = out.toByteArray();
      // carl:格式一致传中文
      String message = new String(bytes, EncodeConstants.ENCODING_UTF_8);
      if (ComparatorUtils.equals(message, RemoteDeziConstants.NO_SUCH_RESOURCE)) {
        return null;
      } else if (ComparatorUtils.equals(message, RemoteDeziConstants.INVALID_USER)) {
        throw new EnvException(RemoteDeziConstants.INVALID_USER);
      } else if (ComparatorUtils.equals(message, RemoteDeziConstants.FILE_LOCKED)) {
        JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer_file-is-locked"));
        return null;
      } else if (message.startsWith(RemoteDeziConstants.RUNTIME_ERROR_PREFIX)) {
      }
      return new ByteArrayInputStream(bytes);
    } finally {
      in.close();
      out.close();
      client.release();
    }
  }