Esempio n. 1
0
  /**
   * Gets the scripts that is need for this element to work
   *
   * @return script files uris
   */
  public static List<String> getNeededScripts(IWContext iwc) {

    List<String> scripts = new ArrayList<String>();

    scripts.add(CoreConstants.DWR_ENGINE_SCRIPT);
    scripts.add(CoreConstants.DWR_UTIL_SCRIPT);

    Web2Business web2 = WFUtil.getBeanInstance(iwc, Web2Business.SPRING_BEAN_IDENTIFIER);
    if (web2 != null) {
      JQuery jQuery = web2.getJQuery();
      scripts.add(jQuery.getBundleURIToJQueryLib());

      scripts.add(web2.getBundleUriToHumanizedMessagesScript());

    } else {
      Logger.getLogger("ContentShareComponent")
          .log(
              Level.WARNING,
              "Failed getting Web2Business no jQuery and it's plugins files were added");
    }

    IWMainApplication iwma = iwc.getApplicationContext().getIWMainApplication();
    IWBundle iwb = iwma.getBundle(UserConstants.IW_BUNDLE_IDENTIFIER);
    scripts.add(iwb.getVirtualPathWithFileNameString("javascript/GroupJoinerHelper.js"));
    scripts.add("/dwr/interface/GroupService.js");

    return scripts;
  }
  public void main(IWContext iwc) throws Exception {
    _editPermission = (iwc.hasEditPermission(this) || this.isOwnerOfProject(iwc));
    Text tBreak = (Text) Text.getBreak().clone();
    tBreak.setFontSize(Text.FONT_SIZE_7_HTML_1);
    this.addAtBeginning(tBreak);

    IWBundle iwb = this.getBundle(iwc);
    IWResourceBundle iwrb = iwb.getResourceBundle(iwc);

    // this.addAtBeginning(new Text(this.getGroupName(),true,false,true));
    super.main(iwc);
    if (_editPermission) {
      Table table = new Table(8, 1);
      table.setHorizontalAlignment("left");
      table.setCellpadding(0);
      table.setCellpadding(0);

      table.setWidth(1, "6");
      table.setWidth(3, "6");
      table.setWidth(5, "12");
      table.setWidth(7, "6");

      //      table.add(getAddAndRemoveGroupLinkIcon(iwc, iwb),2,1);
      //      table.add(getAddAndRemoveGroupLink(iwc, iwrb),4,1);
      //
      //      table.add(getAddAndRemoveUserLinkIcon(iwc, iwb),6,1);
      //      table.add(getAddAndRemoveUserLink(iwc, iwrb),8,1);

      table.add(getAddAndRemoveUserLinkIcon(iwc, iwb), 2, 1);
      table.add(getAddAndRemoveUserLink(iwc, iwrb), 4, 1);

      this.add(table);
    }
  }
Esempio n. 3
0
 @Override
 public void main(IWContext iwc) {
   empty();
   if (this.chooserButtonImage == null) {
     IWBundle iwb = iwc.getIWMainApplication().getBundle(CoreConstants.IW_USER_BUNDLE_IDENTIFIER);
     setChooseButtonImage(iwb.getImage("magnifyingglass.gif", "Choose"));
   }
 }
  protected String getResourceRealPath(IWBundle iwb, Locale locale) {
    String printFolder =
        iwb.getApplication()
            .getSettings()
            .getProperty("company_portal.print_contract_folder", "/print/contract/");

    if (locale != null) {
      return iwb.getResourcesRealPath(locale) + printFolder;
    } else {
      return iwb.getResourcesRealPath() + printFolder;
    }
  }
  private void init(IWContext iwc) {
    this.bundle = getBundle(iwc);
    this.iwrb = this.bundle.getResourceBundle(iwc);
    this.iwc = iwc;
    setAutoCreate(false);
    if (iwc.isParameterSet(this.prmClrCache)) {
      clearCache(iwc);
    }
    this._currentLocale = iwc.getCurrentLocale();
    this._currentLocaleId = ICLocaleBusiness.getLocaleId(this._currentLocale);
    this._hasEditPermission = this.hasEditPermission();
    if (iwc.isInPreviewMode()) {
      this._hasEditPermission = false;
    }
    IWBundle coreBundle = iwc.getIWMainApplication().getCoreBundle();
    this.iCreate = coreBundle.getImage("shared/create.gif");
    this.iDelete = coreBundle.getImage("shared/delete.gif");
    this.iEdit = coreBundle.getImage("shared/edit.gif");
    this.iDetach = coreBundle.getImage("shared/detach.gif");
    try {
      this.layout = (AbstractProductCatalogLayout) this._layoutClass.newInstance();
    } catch (IllegalAccessException iae) {
      iae.printStackTrace(System.err);
    } catch (InstantiationException ie) {
      ie.printStackTrace(System.err);
    }
    try {
      String sCurrentPage = iwc.getParameter(ProductCatalog._VIEW_PAGE);
      String sOrderBy = iwc.getParameter(ProductCatalog._ORDER_BY);
      if (sCurrentPage != null) {
        this.currentPage = Integer.parseInt(sCurrentPage);
      }
      if (sOrderBy != null) {
        this.orderBy = Integer.parseInt(sOrderBy);
      }
    } catch (NumberFormatException n) {
    }

    this.expandedCategories = new Vector();
    String selCat = iwc.getParameter(CATEGORY_ID);

    if (selCat != null) {
      this._selectedCategoryID = Integer.parseInt(selCat);
      addCategoryAsExpanded(selCat);
    }
  }
  protected IWResourceBundle getResourceBundle(IWBundle bundle) {
    Locale locale = getCurrentLocale();
    IWContext iwc = null;
    if (locale == null) {
      iwc = CoreUtil.getIWContext();
    }

    if (locale == null && iwc == null) {
      locale = Locale.ENGLISH;
      LOGGER.warning(
          "Will use default locale ("
              + locale
              + ") for resource bundle, because was unable to resolve both - IWContext and current locale");
    }

    return locale == null ? bundle.getResourceBundle(iwc) : bundle.getResourceBundle(locale);
  }
 private Link getAddAndRemoveUserLinkIcon(IWContext iwc, IWBundle iwb) throws Exception {
   Image icon = iwb.getImage("add_remove_user.gif");
   Link addLink = null;
   if (icon != null) {
     addLink = new Link(icon);
     addLink.setWindowToOpen(ParticipantList.UserGroupSetter.class);
     addLink.addParameter(GroupGroupSetter.PARAMETER_GROUP_ID, this.getGroupId(iwc));
   }
   return addLink;
 }
Esempio n. 8
0
  private void addLocalized(IWContext iwc) {
    Locale locale = iwc.getCurrentLocale();
    DateFormatSymbols symbols = new DateFormatSymbols(locale);
    IWBundle iwb = this.getBundle(iwc);
    IWResourceBundle iwrb = iwb.getResourceBundle(iwc);
    String[] monthStrings;

    if (this.showNullValue) {
      if (this.inShort) {
        this.dayString = iwrb.getLocalizedString(DAY_KEY_S, "D");
        this.monthString = iwrb.getLocalizedString(MONTH_KEY_S, "M");
        this.yearString = iwrb.getLocalizedString(YEAR_KEY_S, "Y");
      } else {
        this.dayString = iwrb.getLocalizedString(DAY_KEY, "Day");
        this.monthString = iwrb.getLocalizedString(MONTH_KEY, "Month");
        this.yearString = iwrb.getLocalizedString(YEAR_KEY, "Year");
      }
      this.theDay.setMenuElementDisplayString("00", this.dayString);
      this.theMonth.setMenuElementDisplayString("00", this.monthString);

      if (this.showYear) {
        this.theYear.setMenuElementDisplayString("YY", this.yearString);
      }
    }
    if (this.inShort) {
      monthStrings = symbols.getShortMonths();
    } else {
      monthStrings = symbols.getMonths();
    }

    for (int i = 1; i <= 12; i++) {
      String value = Integer.toString(i);

      if (i < 10) {
        value = "0" + value;
      }

      this.theMonth.setMenuElementDisplayString(value, monthStrings[i - 1]);
    }
  }
 /* (non-Javadoc)
  * @see com.idega.user.app.ToolbarElement#getName(com.idega.presentation.IWContext)
  */
 public String getName(IWContext iwc) {
   IWBundle bundle =
       iwc.getApplicationContext().getIWMainApplication().getBundle(IW_BUNDLE_IDENTIFIER);
   IWResourceBundle resourceBundle = bundle.getResourceBundle(iwc);
   return resourceBundle.getLocalizedString("button.generate_year", "Generate Year Group");
 }
  @Override
  protected void initializeComponent(FacesContext context) {
    super.initializeComponent(context);

    IWContext iwc = IWContext.getIWContext(context);
    IWBundle bundle = getBundle(context, IWBundleStarter.IW_BUNDLE_IDENTIFIER);
    IWResourceBundle iwrb = bundle.getResourceBundle(iwc);

    Layer container = new Layer();
    add(container);

    PublicEventCreator creator = new PublicEventCreator();
    creator.setOnEventCreated(
        "function() {window.parent.showLoadingMessage('"
            .concat(iwrb.getLocalizedString("reloading", "Reloading..."))
            .concat("');window.parent.reloadPage();}"));
    container.add(creator);

    Layer events = new Layer();
    container.add(events);
    IFrame frame =
        new IFrame("eventsViewer", "http://bedework.sidan.is/cal/main/showMain.rdo", 750, 600);
    events.add(frame);

    //        IWContext iwc = IWContext.getIWContext(context);
    //        if (!iwc.isLoggedOn()) {
    //            return;
    //        }
    //
    //        HtmlTag div =
    // (HtmlTag)context.getApplication().createComponent(HtmlTag.COMPONENT_TYPE);
    //        div.setValue(divTag);
    //        div.setStyleClass("calendarEventCreator");
    //
    //        IWBundle bundle = getBundle(context, IWBundleStarter.IW_BUNDLE_IDENTIFIER);
    //        IWResourceBundle iwrb = bundle.getResourceBundle(iwc);
    //
    //        GenericButton gb = new GenericButton();
    //        div.getChildren().add(gb);
    //        gb.setValue(iwrb.getLocalizedString("show_event", "Show event"));
    //
    //        PresentationUtil.addStyleSheetToHeader(iwc,
    // web2Business.getBundleURIToFancyBoxStyleFile());
    //
    //        List<String> jsFiles = new ArrayList<String>();
    //        jsFiles.add(jQuery.getBundleURIToJQueryLib());
    //        jsFiles.addAll(web2Business.getBundleURIsToFancyBoxScriptFiles());
    //
    // jsFiles.add(bundle.getVirtualPathWithFileNameString("javascript/EventCreationHelper.js"));
    //        PresentationUtil.addJavaScriptSourcesLinesToHeader(iwc, jsFiles);
    //        String action = "EventCreationHelper.initializeHiddenLink();";
    //        if (!CoreUtil.isSingleComponentRenderingProcess(iwc)) {
    //            action = "jQuery(window).load(function() {" + action + "});";
    //        }
    //
    //        PresentationUtil.addJavaScriptActionToBody(iwc, action);
    //        gb.setOnClick("EventCreationHelper.showPublicEventsWindow();");
    //
    //        getChildren().add(div);

    //        HtmlTag div =
    // (HtmlTag)context.getApplication().createComponent(HtmlTag.COMPONENT_TYPE);
    //        div.setValue(divTag);
    //
    //        IWBundle bundle = getBundle(context, IWBundleStarter.IW_BUNDLE_IDENTIFIER);
    //        FaceletComponent facelet =
    // (FaceletComponent)context.getApplication().createComponent(FaceletComponent.COMPONENT_TYPE);
    //        facelet.setFaceletURI(bundle.getFaceletURI("EventViewer.xhtml"));
    //
    //        div.getChildren().add(facelet);
    //        getChildren().add(div);
  }
 /* (non-Javadoc)
  * @see com.idega.user.app.ToolbarElement#getName(com.idega.presentation.IWContext)
  */
 public String getName(IWContext iwc) {
   IWBundle bundle =
       iwc.getApplicationContext().getIWMainApplication().getBundle(IW_BUNDLE_IDENTIFIER);
   IWResourceBundle resourceBundle = bundle.getResourceBundle(iwc);
   return resourceBundle.getLocalizedString("button.marathon_runner_import", "Runner import");
 }
 public Image getLinkImage(IWBundle bundle) {
   return bundle.getImage("shared/edit.gif");
 }
Esempio n. 13
0
 private Image getChooser(IWBundle bundle) {
   if (this._buttonImage == null) {
     setChooseButtonImage(bundle.getImage("open.gif", "Choose"));
   }
   return this._buttonImage;
 }
 public ValueExpression getLinkTypeName(IWBundle bundle) {
   return bundle.getValueExpression("link_type_document");
 }
Esempio n. 15
0
  @SuppressWarnings("unchecked")
  @Override
  protected void initializeComponent(FacesContext context) {
    ELUtil.getInstance().autowire(this);
    iwc = IWContext.getIWContext(context);
    if (!iwc.isLoggedOn()) {
      return;
    }
    if (userId == null) {
      userId = iwc.getCurrentUserId();
    }

    //        HtmlTag div = new
    // HtmlTag();//(HtmlTag)context.getApplication().createComponent(HtmlTag.COMPONENT_TYPE);
    //        getChildren().add(div);
    //        div.setValue(divTag);
    Layer main = new Layer();
    this.add(main);

    IWBundle bundle = getBundle(context, IWBundleStarter.IW_BUNDLE_IDENTIFIER);
    iwrb = bundle.getResourceBundle(iwc);

    if (groupId == null) {
      Label label = new Label();
      main.add(label);
      label.addText(iwrb.getLocalizedString("no_group_set", "No group set"));
      return;
    }

    Group group = null;
    Collection<Group> groups = null;
    try {
      group = this.getUserBusiness().getGroupBusiness().getGroupByGroupID(Integer.valueOf(groupId));
      groups = this.getUserBusiness().getUserGroups(userId);
    } catch (Exception e) {
      Logger.getLogger(this.getClass().getName())
          .log(Level.WARNING, "failed getting groups by ids", e);
    }

    GenericButton joinButton = new GenericButton();
    main.add(joinButton);
    GenericButton leaveButton = new GenericButton();
    main.add(leaveButton);

    StringBuilder parameters =
        new StringBuilder()
            .append(this.userId)
            .append(CoreConstants.JS_STR_PARAM_SEPARATOR)
            .append(this.groupId)
            .append("','#")
            .append(joinButton.getId())
            .append("','#")
            .append(leaveButton.getId())
            .append(CoreConstants.JS_STR_PARAM_END);

    joinButton.setValue(iwrb.getLocalizedString("join", "Join"));
    String action =
        new StringBuilder("GroupJoinerHelper.joinGroup('").append(parameters).toString();
    joinButton.setOnClick(action);
    leaveButton.setValue(iwrb.getLocalizedString("leave", "Leave"));
    action = new StringBuilder("GroupJoinerHelper.leaveGroup('").append(parameters).toString();
    leaveButton.setOnClick(action);

    if (groups.contains(group)) {
      joinButton.setStyleAttribute("display : none;");
    } else {
      leaveButton.setStyleAttribute("display : none;");
    }

    addActions(main);
  }