Пример #1
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();
   }
 }
Пример #2
0
 public GetExistEnvAction(String envName) {
   this.setName(envName);
   Env env = DesignerEnvManager.getEnvManager().getEnv(envName);
   if (env instanceof LocalEnv) {
     this.setSmallIcon(BaseUtils.readIcon("com/fr/design/images/data/bind/localconnect.png"));
   } else if (env instanceof RemoteEnv) {
     this.setSmallIcon(BaseUtils.readIcon("com/fr/design/images/data/bind/distanceconnect.png"));
   }
 }
Пример #3
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) {
        //
      }
    }
  }
Пример #4
0
 private void initMenuDef() {
   // ButtonGroup group = new ButtonGroup();
   Iterator<String> nameIt = DesignerEnvManager.getEnvManager().getEnvNameIterator();
   while (nameIt.hasNext()) {
     String name = nameIt.next();
     this.setIconPath("com/fr/design/images/m_file/switch.png");
     this.addShortCut(new GetExistEnvAction(name));
   }
   this.addShortCut(SeparatorDef.DEFAULT);
   this.addShortCut(new EditEnvAction());
 }
Пример #5
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();
    }
  }