Beispiel #1
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();
    }
  }
Beispiel #2
0
 private static boolean isDisplayDialog(Locale defaultLocale) {
   return ComparatorUtils.equals(defaultLocale, Locale.TRADITIONAL_CHINESE)
       || ComparatorUtils.equals(defaultLocale, Locale.JAPANESE)
       || ComparatorUtils.equals(defaultLocale, Locale.JAPAN)
       || ComparatorUtils.equals(defaultLocale, Locale.KOREAN)
       || ComparatorUtils.equals(defaultLocale, Locale.KOREA);
 }
Beispiel #3
0
  /**
   * 当前的报表运行环境切换到env
   *
   * @param env 需要切换去的环境
   */
  public static void switchToEnv(Env env) {
    if (env == null) {
      return;
    }

    Env oldEnv = FRContext.getCurrentEnv();
    String oldEnvPath = oldEnv == null ? null : oldEnv.getPath();

    // 看一下这个env在DesignerEnvManager里面有没有对应的,有的话就setCurrentEnvName
    DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
    java.util.Iterator<String> nameIt = envManager.getEnvNameIterator();
    while (nameIt.hasNext()) {
      String name = nameIt.next();
      if (ComparatorUtils.equals(envManager.getEnv(name), env)) {
        envManager.setCurEnvName(name);
        break;
      }
    }

    // 更新CurrentEnv于FRContext & DesignerEnvManager
    FRContext.setCurrentEnv(env);

    final Env run_env = env;

    // 刷新DesignerFrame里面的面板
    SwingUtilities.invokeLater(
        new Runnable() {

          public void run() {
            if (DesignerContext.getDesignerFrame() == null) {
              return;
            }
            DesignerContext.getDesignerFrame().refreshEnv(run_env);
            DesignerContext.getDesignerFrame().repaint(); // kunsnat: 切换环境后 刷新下 报表. 比如图表某些风格改变.
          }
        });
    // 当换了运行环境,重置服务器,让它下次预览时重启
    if (env instanceof LocalEnv && !ComparatorUtils.equals(env.getPath(), oldEnvPath)) {
      StartServer.currentEnvChanged();
    }
  }
Beispiel #4
0
 private static boolean isDisplaySimSun(Locale defaultLocale) {
   return ComparatorUtils.equals(defaultLocale, Locale.SIMPLIFIED_CHINESE);
 }