Esempio n. 1
0
 /**
  * Generates HTML for a tree item with an attached icon.
  *
  * @param imageProto the image prototype to use
  * @param title the title of the item
  * @return the resultant HTML
  */
 private HTML imageItemHTML(ImageResource res, String title) {
   AbstractImagePrototype imageProto = AbstractImagePrototype.create(res);
   HTML label = new HTML(imageProto.getHTML() + " " + title);
   label.addClickHandler(this);
   label.addClickHandler((ClickHandler) parent);
   return label;
 }
Esempio n. 2
0
  public CreateGroupWidget(UserGroup parent) {
    initComponents();
    this.parent = parent;

    int row = 0;

    createTable.setWidget(row, 0, closeLink);
    createTable.getFlexCellFormatter().setColSpan(row, 0, 2);
    row += 1;

    createTable.setHTML(row, 0, "<b>Name</b>");
    createTable.setWidget(row, 1, groupName);
    row += 1;

    createTable.setHTML(row, 0, "<b>Description</b>");
    createTable.setWidget(row, 1, groupDescription);
    row += 1;

    createTable.setWidget(row, 0, table);
    createTable.getFlexCellFormatter().setColSpan(row, 0, 2);
    row += 1;

    createTable.setWidget(row, 0, createButton);
    createTable.getFlexCellFormatter().setHorizontalAlignment(row, 0, HasAlignment.ALIGN_RIGHT);
    createTable.setWidget(row, 1, cancelButton);

    popup.setWidget(createTable);
    popup.setGlassEnabled(true);
    popup.setGlassStyleName("dialog_box_glass");
    closeLink.addClickHandler(new CloseWidgetHandler());
    cancelButton.addClickHandler(new CloseWidgetHandler());
  }
  /**
   * Sets the state icon.
   *
   * <p>The state icon indicates if a resource is exported, secure, etc.
   *
   * <p>
   *
   * @param icon the state icon
   */
  public void setStateIcon(StateIcon icon) {

    if (m_stateIcon == null) {
      m_stateIcon = new HTML();
      m_stateIcon.addClickHandler(m_iconSuperClickHandler);
      m_contentPanel.add(m_stateIcon);
    }
    String iconTitle = null;
    switch (icon) {
      case export:
        m_stateIcon.setStyleName(
            I_CmsLayoutBundle.INSTANCE.listItemWidgetCss().stateIcon()
                + " "
                + I_CmsLayoutBundle.INSTANCE.listItemWidgetCss().export());
        iconTitle = Messages.get().key(Messages.GUI_ICON_TITLE_EXPORT_0);
        break;
      case secure:
        m_stateIcon.setStyleName(
            I_CmsLayoutBundle.INSTANCE.listItemWidgetCss().stateIcon()
                + " "
                + I_CmsLayoutBundle.INSTANCE.listItemWidgetCss().secure());
        iconTitle = Messages.get().key(Messages.GUI_ICON_TITLE_SECURE_0);
        break;
      default:
        m_stateIcon.setStyleName(I_CmsLayoutBundle.INSTANCE.listItemWidgetCss().stateIcon());
        break;
    }
    m_stateIcon.setTitle(concatIconTitles(m_iconTitle, iconTitle));
    m_stateIcon.getElement().getStyle().setCursor(Style.Cursor.POINTER);
  }
Esempio n. 4
0
  private void updateBreadcrump() {
    breadcrumb.clear();

    int i = 1;
    for (final Entry item : history) {
      String name = item.getName().equals("/") ? "/Root" : item.getName();
      HTML link = new HTML(name);
      link.addClickHandler(new BreadcrumbClick(i, item));
      breadcrumb.add(link);
      i++;
    }
  }
Esempio n. 5
0
 public void setEditable(boolean isEditable) {
   if (this.isEditable != isEditable) {
     this.isEditable = isEditable;
     if (this.isEditable) {
       if (allowHtml) {
         myRegistration = myHtmlView.addClickHandler(this);
       } else {
         myRegistration = myTextView.addClickHandler(this);
       }
       // buildTooltipPopup();
     } else {
       myRegistration.removeHandler();
       //        myMouseOverHandlerRegistration.removeHandler();
       //        myMouseOutHandlerRegistration.removeHandler();
     }
   }
 }
Esempio n. 6
0
  public void addLink(String text, ClickHandler handler) {

    HTML html = new HTML();
    html.setHTML("<a href='javascript:void(0)'>" + text + "</a>");

    html.addClickHandler(handler);
    html.addStyleName("link-bar");

    if (numLinks == 0) {
      html.addStyleName("link-bar-first");
    }

    links.add(html);

    bar.add(html);

    numLinks++;
  }
Esempio n. 7
0
  private void displayNotification(final Message message) {

    String actualMessage =
        message.getConciseMessage().length() > 40
            ? message.getConciseMessage().substring(0, 40) + " ..."
            : message.getConciseMessage();

    displayPopup = new DefaultPopup(DefaultPopup.Arrow.RIGHTTOP);

    final HTML label = new HTML(message.getSeverity().getTag() + "&nbsp;" + actualMessage);

    label.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent clickEvent) {
            if (message.isSticky()) {
              MessageCenterView.this.lastSticky = null;
            }
            messageDisplay.clear();
            displayPopup.hide();
            showDetail(message);
          }
        });

    label.addStyleName("notification-display");
    final String css = getSeverityStyle(message.severity);
    label.addStyleName(css);

    displayPopup.setWidget(label);

    int width = 250;
    int height = 16;

    displayPopup.setPopupPosition(
        messageButton.getAbsoluteLeft() - (width + 2 - messageButton.getOffsetWidth() + 85),
        messageButton.getAbsoluteTop() - 2);

    displayPopup.show();

    displayPopup.setWidth(width + "px");
    displayPopup.setHeight(height + "px");
  }
Esempio n. 8
0
  /**
   * Create the list of Contacts.
   *
   * @param images the {@link Images} used in the Contacts
   * @return the list of contacts
   */
  @ShowcaseSource
  private VerticalPanel createContactsItem(Images images) {
    // Create a popup to show the contact info when a contact is clicked
    HorizontalPanel contactPopupContainer = new HorizontalPanel();
    contactPopupContainer.setSpacing(5);
    contactPopupContainer.add(new Image(images.defaultContact()));
    final HTML contactInfo = new HTML();
    contactPopupContainer.add(contactInfo);
    final PopupPanel contactPopup = new PopupPanel(true, false);
    contactPopup.setWidget(contactPopupContainer);

    // Create the list of contacts
    VerticalPanel contactsPanel = new VerticalPanel();
    contactsPanel.setSpacing(4);
    String[] contactNames = constants.cwStackPanelContacts();
    String[] contactEmails = constants.cwStackPanelContactsEmails();
    for (int i = 0; i < contactNames.length; i++) {
      final String contactName = contactNames[i];
      final String contactEmail = contactEmails[i];
      final HTML contactLink =
          new HTML("<a href=\"javascript:undefined;\">" + contactName + "</a>");
      contactsPanel.add(contactLink);

      // Open the contact info popup when the user clicks a contact
      contactLink.addClickHandler(
          new ClickHandler() {
            public void onClick(ClickEvent event) {
              // Set the info about the contact
              contactInfo.setHTML(contactName + "<br><i>" + contactEmail + "</i>");

              // Show the popup of contact info
              int left = contactLink.getAbsoluteLeft() + 14;
              int top = contactLink.getAbsoluteTop() + 14;
              contactPopup.setPopupPosition(left, top);
              contactPopup.show();
            }
          });
    }
    return contactsPanel;
  }
  /**
   * Sets the lock icon.
   *
   * <p>
   *
   * @param icon the icon to use
   * @param iconTitle the icon title
   */
  public void setLockIcon(LockIcon icon, String iconTitle) {

    if (m_lockIcon == null) {
      m_lockIcon = new HTML();
      m_lockIcon.addClickHandler(m_iconSuperClickHandler);
      m_contentPanel.add(m_lockIcon);
    }
    switch (icon) {
      case CLOSED:
        m_lockIcon.setStyleName(
            I_CmsLayoutBundle.INSTANCE.listItemWidgetCss().lockIcon()
                + " "
                + I_CmsLayoutBundle.INSTANCE.listItemWidgetCss().lockClosed());
        break;
      case OPEN:
        m_lockIcon.setStyleName(
            I_CmsLayoutBundle.INSTANCE.listItemWidgetCss().lockIcon()
                + " "
                + I_CmsLayoutBundle.INSTANCE.listItemWidgetCss().lockOpen());
        break;
      case SHARED_CLOSED:
        m_lockIcon.setStyleName(
            I_CmsLayoutBundle.INSTANCE.listItemWidgetCss().lockIcon()
                + " "
                + I_CmsLayoutBundle.INSTANCE.listItemWidgetCss().lockSharedClosed());
        break;
      case SHARED_OPEN:
        m_lockIcon.setStyleName(
            I_CmsLayoutBundle.INSTANCE.listItemWidgetCss().lockIcon()
                + " "
                + I_CmsLayoutBundle.INSTANCE.listItemWidgetCss().lockSharedOpen());
        break;
      case NONE:
      default:
        m_lockIcon.setStyleName(I_CmsLayoutBundle.INSTANCE.listItemWidgetCss().lockIcon());
    }

    m_lockIcon.setTitle(concatIconTitles(m_iconTitle, iconTitle));
    m_lockIcon.getElement().getStyle().setCursor(Style.Cursor.POINTER);
  }
Esempio n. 10
0
  public void init(final KieImageType imageType, final int containersRunningCount) {
    if (imageType == null) return;

    final SafeUri imageUri = ClientUtils.getImageUri(imageType);
    typeNameText.setText(imageType.getName());
    if (containersRunningCount < 0) {
      countText.setVisible(false);
    } else if (containersRunningCount == 0
        && showCreateButton
        && !KieImageCategory.OTHERS.equals(imageType.getCategory())) {
      countText.setText(Constants.INSTANCE.createNew());
      countText.setTitle(Constants.INSTANCE.createNewForThisType());
      countText.addStyleName(style.createNewButton());
      countText.addClickHandler(
          new ClickHandler() {
            @Override
            public void onClick(ClickEvent clickEvent) {
              KieImageTypeView.this.fireEvent(new CreateContainerEvent(imageType));
            }
          });
      countText.setVisible(true);
    } else {
      countText.setText(Integer.toString(containersRunningCount));
      countText.removeStyleName(style.createNewButton());
      countText.setVisible(true);
    }

    typeImage.setUrl(imageUri);
    typeImage.setSize(size, size);
    typeImage.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent clickEvent) {
            KieImageTypeView.this.fireEvent(new ImageTypeSelectedEvent(imageType));
          }
        });
    mainPanel.setVisible(true);
  }
Esempio n. 11
0
  public SurveyWidget(Survey s, Images images, Composite parent) {
    this.survey = s;
    this.images = images;
    this.parent = parent;

    tree = new Tree(images);
    String title = s.getName() + " ";
    SurveyStatus status = survey.getStatus();
    switch (status) {
      case ACTIVE:
        title += "<span style='color:green'>(Active)</span>";
        break;
      case CANCELLED:
        title += "<span style='color:red'>(Cancelled)</span>";
        break;
      case EXPIRED:
        title += "(Expired)";
    }
    rootHTML = imageItemHTML(images.inbox(), title);
    root = new TreeItem(rootHTML);
    tree.addItem(root);

    tree.addSelectionHandler(
        new SelectionHandler<TreeItem>() {

          public void onSelection(SelectionEvent<TreeItem> event) {
            TreeItem item = event.getSelectedItem();

            if (promptMap.containsKey(item)) {
              Prompt p = promptMap.get(item);
              Messages.get().displaySurveyInput(p, 0);
            }
          }
        });

    detailsHTML = imageItemHTML(images.drafts(), "Details");
    detailsHTML.addClickHandler(
        new ClickHandler() {

          public void onClick(ClickEvent event) {
            if (detailsModel == null) {
              JSONRequest request = new JSONRequest();
              request.doFetchURL(
                  AoAPI.SURVEY_DETAILS + survey.getId() + "/", new SurveyDetailsRequester());
            } else {
              DetailsDialog details = new DetailsDialog(detailsModel);
              details.show();
              details.center();
            }
          }
        });

    TreeItem details = new TreeItem(detailsHTML);
    root.addItem(details);

    if (status == SurveyStatus.ACTIVE) {
      cancelHTML = imageItemHTML(images.reject_sm(), "Cancel");
      cancelHTML.addClickHandler(
          new ClickHandler() {
            public void onClick(ClickEvent event) {
              confirm =
                  new AreYouSureDialog(
                      "Are you sure you want to cancel all future calls for this broadcast?");
              confirm.show();
              confirm.center();

              confirm.addCloseHandler(
                  new CloseHandler<PopupPanel>() {
                    public void onClose(CloseEvent<PopupPanel> event) {
                      if (confirm.isConfirmed()) {
                        JSONRequest request = new JSONRequest();
                        request.doFetchURL(
                            AoAPI.CANCEL_SURVEY + survey.getId() + "/",
                            new CancelSurveyRequester());
                      }
                    }
                  });
            }
          });

      TreeItem cancel = new TreeItem(cancelHTML);
      root.addItem(cancel);
    }
  }
Esempio n. 12
0
  public void init() {
    TotalBudget.getInstance();

    Integer height = null;
    Integer width = null;
    Map<String, List<String>> parameters = Window.Location.getParameterMap();
    if (parameters.containsKey("w") && parameters.containsKey("h")) {
      height = Integer.parseInt(parameters.get("h").get(0));
      width = Integer.parseInt(parameters.get("w").get(0));
    }

    mResultsGrid = new ResultGrid();
    mResultsGrid.setWidth("100%");

    Integer pieWidth = width == null ? 485 : width;
    Integer pieHeight = height == null ? 400 : height;
    mPieCharter = new PieCharter(this, mEmbedded, pieWidth, pieHeight);
    mPieCharter.setWidth(pieWidth + "px");
    mPieCharter.setHeight(pieHeight + "px");

    Integer timeWidth = width == null ? 686 : width;
    Integer timeHeight = height == null ? 400 : height;
    mTimeLineCharter = new TimeLineCharter(this, mEmbedded, timeWidth, timeHeight);
    mTimeLineCharter.setWidth(timeWidth + "px");
    mTimeLineCharter.setHeight(timeHeight + "px");

    mBreadcrumbs = new HTML("");
    mBreadcrumbs.setHeight("20px");
    mBreadcrumbs.setWidth("100%");

    mYearSelection = new ListBox();
    mYearSelection.addChangeHandler(
        new ChangeHandler() {
          @Override
          public void onChange(ChangeEvent event) {
            Integer index = mYearSelection.getSelectedIndex();
            String yearStr = mYearSelection.getItemText(index);
            Integer year;
            try {
              year = Integer.parseInt(yearStr);
            } catch (Exception e) {
              yearStr = yearStr.split(" ")[0];
              year = Integer.parseInt(yearStr);
            }
            selectYear(year);
          }
        });

    mSearchBox = new SuggestBox(new BudgetSuggestionOracle());
    mSearchBox.setWidth("300px");
    mSearchBox.setAutoSelectEnabled(false);
    mSearchBox.addSelectionHandler(
        new SelectionHandler<Suggestion>() {
          @Override
          public void onSelection(SelectionEvent<Suggestion> event) {
            final BudgetSuggestion bs = (BudgetSuggestion) event.getSelectedItem();

            BudgetAPICaller api = new BudgetAPICaller();
            api.setCode(bs.getCode());
            api.setParameter("depth", "0");
            api.setParameter("text", bs.getTitle());

            api.go(
                new BudgetAPICallback() {

                  @Override
                  public void onSuccess(JSONArray data) {
                    if (data.size() > 0) {
                      Integer year =
                          (int) data.get(0).isObject().get("year").isNumber().doubleValue();
                      newCodeAndYear(bs.getCode(), year);
                    }
                  }
                });
          }
        });

    mSummary1 = new Label();
    mSummary2 = new Label();
    mSummary2_1 = new Label();
    mSummary3 = new HTML();
    mSummary3_1 = new HTML();

    try {
      mBudgetNews = new BudgetNews();
    } catch (Exception e) {
      Log.error("Failed to init mBudgetNews", e);
    }

    mCheatSheet = new HTML("(הסברים)");
    final DecoratedPopupPanel simplePopup = new DecoratedPopupPanel(true);
    simplePopup.setWidth("450px");
    HTML simplePopupContents =
        new HTML(
            "<h4>מונחון מקוצר</h4>"
                + "<lu>"
                + "<li><b>נטו</b>: <u>תקציב הוצאה נטו</u> – הסכום המותר להוצאה בשנה כלשהי כפי שמפורט בחוק התקציב. תקציב זה מכונה גם \"תקציב המזומנים\".</li>"
                + "<li><b>ברוטו</b>: <u>תקציב ההוצאה נטו</u> בתוספת <u>תקציב ההוצאה המותנית בהכנסה</u> – תקציב נוסף המותר בהוצאה, ובלבד שיתקבלו תקבולים למימון ההוצאה מגורמים חוץ-ממשלתיים. תקבולים אלו אינם כוללים אגרה המשולמת לאוצר המדינה שהוטלה על-פי חיקוק שנחקק אחרי תחילת שנת הכספים 1992, ואינה כוללת הכנסה שמקורה במלווה (חוץ מתקציבי פיתוח וחשבון הון).</li>"
                + "<li><b>הקצאה</b>: <u>תקציב מקורי</u> – התקציב שאושר בכנסת במסגרת חוק התקציב. ייתכנו הבדלים בין הצעת התקציב לבין התקציב שיאושר בכנסת בסופו של דבר.</li>"
                + "<li><b>הקצאה מעודכנת</b>: <u>תקציב על שינוייו</u> – תקציב המדינה עשוי להשתנות במהלך השנה. שינויים אלו כוללים תוספות, הפחתות והעברות תקציביות בין סעיפי תקציב (באישור ועדת הכספים של הכנסת). נוסף על כך, פעמים רבות מועברים עודפים מחויבים משנה קודמת הנכללים בתקציב זה. רוב השינויים בתקציב דורשים את אישורה של ועדת הכספים של הכנסת. התקציב בסוף השנה הכולל את השינויים שנעשו בו במהלך השנה נקרא התקציב על שינוייו או התקציב המאושר.</li>"
                + "<li><b>שימוש</b>:  <u>ביצוע</u> – התקציב שכבר נוצל ושולם בפועל על-ידי החשב.</li>"
                + "<li><b>ערך ריאלי ונומינלי</b>:  ראו הסבר ב<a href='http://he.wikipedia.org/wiki/%D7%A2%D7%A8%D7%9A_%D7%A8%D7%99%D7%90%D7%9C%D7%99_%D7%95%D7%A2%D7%A8%D7%9A_%D7%A0%D7%95%D7%9E%D7%99%D7%A0%D7%9C%D7%99' target ='_blank'>ויקיפדיה</a>.</li>"
                + "<li><b>ערך יחסי</b>:  האחוז היחסי של סעיף זה מכלל תקציב המדינה</li>"
                + "</lu>"
                + "<br/>"
                + "<i>לחץ מחוץ לחלונית זו לסגירתה</i>"
                + "<br/>"
                + "מקור: <a href='http://www.knesset.gov.il/mmm/data/docs/m02217.doc' target='_blank'>מסמך Word ממחלקת המחקר של הכנסת</a>"
                + "<p><b>התקציב הפתוח הוא פרויקט התנדבותי של עמותת 'הסדנא לידע ציבורי'. הנתונים המופיעים"
                + " בתקציב הפתוח נסמכים על פרסומי המדינה ואינם באים לשקף כל דעה שהיא. אין לסדנא לידע ציבורי"
                + " כל אחריות על השימוש בפרויקט וראוי לבדוק את הנתונים לגופם במקורותיהם לפני הסתמכות עליהם.</b></p>");
    simplePopupContents.setStyleName("obudget-cheatsheet-popup");
    simplePopup.setWidget(simplePopupContents);
    mCheatSheet.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            Widget source = (Widget) event.getSource();
            int left = source.getAbsoluteLeft() + 10;
            int top = source.getAbsoluteTop() + 10;
            simplePopup.setPopupPosition(left, top);
            simplePopup.show();
          }
        });

    History.addValueChangeHandler(this);
  }
Esempio n. 13
0
  public Widget asWidget() {

    HorizontalPanel layout = new HorizontalPanel();
    layout.getElement().setAttribute("title", "Notification Center");
    layout.setStyleName("notification-center");

    messageButton = new HTML(MESSAGE_LABEL + ": " + messageCenter.getNewMessageCount());
    messageButton.addStyleName("notification-button");

    ClickHandler clickHandler =
        new ClickHandler() {
          public void onClick(ClickEvent event) {

            int numMessages = fetchMessages(messagePopup);
            if (numMessages == 0) numMessages = 1;

            int width = 250;
            int height = numMessages * 35;

            messagePopup.setPopupPosition(
                messageButton.getAbsoluteLeft() - (width + 10 - messageButton.getOffsetWidth()),
                messageButton.getAbsoluteTop() + 25);

            messagePopup.show();
            Scheduler.get()
                .scheduleDeferred(
                    new Scheduler.ScheduledCommand() {
                      @Override
                      public void execute() {
                        messagePopup.focusOnFirstMessage();
                      }
                    });

            messagePopup.setWidth(width + "px");
            messagePopup.setHeight(height + "px");
          }
        };

    messageButton.addClickHandler(clickHandler);

    messageDisplay = new HorizontalPanel();
    messageDisplay.getElement().setAttribute("role", "log");
    messageDisplay.getElement().setAttribute("aria-live", "polite");
    messageDisplay.getElement().setAttribute("aria-atomic", "true");

    layout.add(messageDisplay);
    layout.add(messageButton);

    messageDisplay
        .getElement()
        .getParentElement()
        .setAttribute("style", "width:100%;padding-right:5px");
    messageDisplay.getElement().getParentElement().setAttribute("align", "right");

    messageButton.getElement().getParentElement().setAttribute("style", "width:60px");
    messageButton.getElement().getParentElement().setAttribute("align", "right");

    // register listener
    messageCenter.addMessageListener(this);
    Console.getEventBus().addHandler(ReloadEvent.TYPE, this);

    return layout;
  }
Esempio n. 14
0
  public ComboBox(String cssSuffix) {

    cellList =
        new CellList<String>(
            new TextCell() {
              @Override
              public void render(Context context, String data, SafeHtmlBuilder sb) {
                String cssName =
                    (context.getIndex() % 2 > 0)
                        ? "combobox-item combobox-item-odd"
                        : "combobox-item";

                if (data.equals(currentValue.getText())) cssName += " combobox-item-selected";

                sb.append(TEMPLATE.item(cssName, data));
              }
            });

    final SingleSelectionModel<String> selectionModel = new SingleSelectionModel<String>();
    cellList.setSelectionModel(selectionModel);

    selectionModel.addSelectionChangeHandler(
        new SelectionChangeEvent.Handler() {
          public void onSelectionChange(SelectionChangeEvent event) {
            String selectedValue = selectionModel.getSelectedObject();

            currentValue.setHTML(selectedValue);
            popup.hide();

            onSelection(selectedValue);
          }
        });

    final String panelId = "popup_" + HTMLPanel.createUniqueId();
    popup =
        new PopupPanel(true, true) {

          @Override
          protected void onPreviewNativeEvent(Event.NativePreviewEvent event) {
            if (Event.ONKEYUP == event.getTypeInt()) {
              if (event.getNativeEvent().getKeyCode() == ESCAPE) {
                // Dismiss when escape is pressed
                popup.hide();
              }
            }
          }

          public void onBrowserEvent(Event event) {
            super.onBrowserEvent(event);
          }
        };

    popup.getElement().setId(panelId);

    popup.setStyleName("default-popup");

    popup.setWidget(cellList);

    currentValue = new HTML("&nbsp;");
    currentValue.setStyleName("combobox-value" + cssSuffix);

    header = new HorizontalPanel();
    header.setStyleName("combobox" + cssSuffix);
    header.add(currentValue);

    Image img = new Image(Icons.INSTANCE.comboPicker());
    header.add(img);

    currentValue.getElement().getParentElement().setAttribute("width", "100%");

    img.getParent().getElement().setAttribute("width", "18");

    header.getElement().setAttribute("width", "100%");
    header.getElement().setAttribute("cellspacing", "0");
    header.getElement().setAttribute("cellpadding", "0");
    header.getElement().setAttribute("border", "0");

    ClickHandler clickHandler =
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent clickEvent) {
            openPanel();
          }
        };

    currentValue.addClickHandler(clickHandler);
    img.addClickHandler(clickHandler);
  }
Esempio n. 15
0
  public Widget asWidget() {

    if (null == cellTable.getSelectionModel())
      cellTable.setSelectionModel(new SingleSelectionModel<T>());

    cellTable
        .getSelectionModel()
        .addSelectionChangeHandler(
            new SelectionChangeEvent.Handler() {
              @Override
              public void onSelectionChange(SelectionChangeEvent selectionChangeEvent) {
                T selection =
                    ((SingleSelectionModel<T>) cellTable.getSelectionModel()).getSelectedObject();
                String displayValue = renderer.render(selection);
                currentDisplayedValue.setText(displayValue);
              }
            });

    final String panelId = "popup_" + HTMLPanel.createUniqueId();
    popup =
        new PopupPanel(true, true) {

          @Override
          protected void onPreviewNativeEvent(Event.NativePreviewEvent event) {
            if (Event.ONKEYUP == event.getTypeInt()) {
              if (event.getNativeEvent().getKeyCode() == ESCAPE) {
                // Dismiss when escape is pressed
                popup.hide();
              }
            }
          }

          public void onBrowserEvent(Event event) {
            super.onBrowserEvent(event);
          }
        };

    popup.getElement().setId(panelId);

    popup.setStyleName("default-popup");

    /*popup.addCloseHandler(new CloseHandler<PopupPanel>() {
        public void onClose(CloseEvent<PopupPanel> event) {

        }
    });*/

    VerticalPanel layout = new VerticalPanel();
    layout.setStyleName("fill-layout-width");
    layout.addStyleName("tablepicker-popup");

    if (description != null) layout.add(new Label(description));

    layout.add(cellTable);

    DefaultPager pager = new DefaultPager();
    pager.setDisplay(cellTable);
    layout.add(pager);

    popup.setWidget(layout);

    currentDisplayedValue = new HTML("&nbsp;");
    currentDisplayedValue.setStyleName("table-picker-value");

    header = new HorizontalPanel();
    header.setStyleName("table-picker");
    header.add(currentDisplayedValue);

    Image img = new Image(ConsoleIcons.INSTANCE.tablePicker());
    header.add(img);

    currentDisplayedValue.getElement().getParentElement().setAttribute("width", "100%");

    img.getParent().getElement().setAttribute("width", "18");

    header.getElement().setAttribute("width", "100%");
    header.getElement().setAttribute("cellspacing", "0");
    header.getElement().setAttribute("cellpadding", "0");
    header.getElement().setAttribute("border", "0");

    ClickHandler clickHandler =
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent clickEvent) {
            openPanel();
          }
        };

    currentDisplayedValue.addClickHandler(clickHandler);
    img.addClickHandler(clickHandler);

    return header;
  }
Esempio n. 16
0
  @Inject
  public EditFolderView() {
    this.res = ShelfCBundle.INSTANCE;
    folderDescription =
        new FolderEditableTextAreaUc() {
          @Override
          public void onEditDisabled(String text) {
            descriptionAlertMessageLbl.addStyleName("titleAlertMessageDeActive");
            descriptionAlertMessageLbl.removeStyleName("titleAlertMessageActive");
            editFolderDescSaveButton.getElement().getStyle().setDisplay(Display.NONE);
            editFolderDescSaveButtonCancel.getElement().getStyle().setDisplay(Display.NONE);
            collectionDo.setGoals(text);
            getUiHandlers().updateCollectionInfo(collectionDo.getGooruOid(), null, text);
          }

          @Override
          public void checkCharacterLimit(String text) {
            if (text.length() >= 415) {
              descriptionAlertMessageLbl.addStyleName("titleAlertMessageActive");
              descriptionAlertMessageLbl.removeStyleName("titleAlertMessageDeActive");
            } else {
              descriptionAlertMessageLbl.addStyleName("titleAlertMessageDeActive");
              descriptionAlertMessageLbl.removeStyleName("titleAlertMessageActive");
            }
          }
        };

    folderTitle =
        new FolderEditableLabelUc() {
          @Override
          public void onEditDisabled(String text) {
            titleAlertMessageLbl.addStyleName("titleAlertMessageDeActive");
            titleAlertMessageLbl.removeStyleName("titleAlertMessageActive");
            collectionDo.setTitle(text);
            editFolderSaveButton.getElement().getStyle().setDisplay(Display.NONE);
            editFolderSaveButtonCancel.getElement().getStyle().setDisplay(Display.NONE);
            getUiHandlers().updateCollectionInfo(collectionDo.getGooruOid(), text, null);
          }

          @Override
          public void checkCharacterLimit(String text) {
            if (text.length() >= 50) {
              titleAlertMessageLbl.addStyleName("titleAlertMessageActive");
              titleAlertMessageLbl.removeStyleName("titleAlertMessageDeActive");
            } else {
              titleAlertMessageLbl.addStyleName("titleAlertMessageDeActive");
              titleAlertMessageLbl.removeStyleName("titleAlertMessageActive");
            }
          }
        };
    FolderCBundle.INSTANCE.css().ensureInjected();
    res.css().ensureInjected();
    setWidget(uiBinder.createAndBindUi(this));

    simplePencilFocPanel.addMouseOverHandler(new hideEditPencil());
    simplePencilFocPanel.addMouseOutHandler(new showEditPencil());
    collectionEditImageLbl.addClickHandler(new OnEditImageClick());
    editFolderTitle.addClickHandler(new OnEditImageClick());

    editFolderSaveButton.getElement().getStyle().setDisplay(Display.NONE);
    editFolderSaveButtonCancel.getElement().getStyle().setDisplay(Display.NONE);
    editFolderDescSaveButton.getElement().getStyle().setDisplay(Display.NONE);
    editFolderDescSaveButtonCancel.getElement().getStyle().setDisplay(Display.NONE);
    simplePencilPanel.getElement().getStyle().setDisplay(Display.NONE);
    backToSearchFloPanel.getElement().getStyle().setDisplay(Display.NONE);

    collectionDescriptionTitleContainer.addMouseOverHandler(new OnCollectionDescriptionClick());
    collectionDescriptionTitleContainer.addMouseOutHandler(new OnCollectionDescriptionOut());
    simplePencilPanel.addClickHandler(new OpenCollectionEditDescription());
    editFolderDesc.addClickHandler(new OpenCollectionEditDescription());

    myFolderRightContainer.addMouseOverHandler(new ActionPanelHover());
    myFolderRightContainer.addMouseOutHandler(new ActionPanelOut());

    folderDeleteLabel.setVisible(false);
    infoTabVc.addClickHandler(this);
    contentTabVc.addClickHandler(this);
    backToSearchHtml.addClickHandler(new BackToSearchHtmlClick());
    collectionEditImageLbl.setVisible(false);
  }