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);
    }
  }
  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);
  }
Example #3
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");
 }
  @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);
  }