protected Widget getContent(AssetContentItem contentItem) {
   // Add the content
   HTML contentHTML = new HTML(contentItem.getContent());
   // So that lightbox centering in firefox works, enclose each sized <object>
   // with a div styled to exactly that size.
   NodeList<Element> objectElements = contentHTML.getElement().getElementsByTagName("object");
   Document document = Document.get();
   for (int i = 0, len = objectElements.getLength(); i < len; i++) {
     Element objectElement = objectElements.getItem(i);
     String width = objectElement.getAttribute("width");
     String height = objectElement.getAttribute("height");
     if (width.matches("[0-9]+%?") && height.matches("[0-9]+%?")) {
       DivElement div = document.createDivElement();
       div.getStyle().setProperty("width", width + (width.endsWith("%") ? "" : "px"));
       div.getStyle().setProperty("height", height + (height.endsWith("%") ? "" : "px"));
       objectElement.getParentElement().replaceChild(div, objectElement);
       div.appendChild(objectElement);
     }
   }
   // In case there are images within the content, we should fire a PopupImageLoadedEvent
   // so that any popup window displaying this view has a chance to reposition itself.
   NodeList<Element> imageElements = contentHTML.getElement().getElementsByTagName("img");
   for (int i = 0; i < imageElements.getLength(); i++) {
     ImageElement image = imageElements.getItem(i).cast();
     addImageLoadHandler(image);
   }
   return contentHTML;
 }
  @UiConstructor
  public PreviewResourceView(CollectionItemDo collectionItemDo, int itemIndex) {
    initWidget(uiBinder.createAndBindUi(this));
    resourceThumbContainer.getElement().setId("fpnlResourceThumbContainer");
    resourceImageContainer.getElement().setId("fpnlResourceImageContainer");
    resourceThumbnail.getElement().setId("imgResourceThumbnail");
    resourceTypeImage.getElement().setId("lblResourceTypeImage");
    resourceNumber.getElement().setId("lblResourceNumber");
    resourceTitle.getElement().setId("htmlResourceTitle");
    resourceIndex.getElement().setId("lblResourceIndex");
    resourceHoverTitle.getElement().setId("htmlResourceHoverTitle");
    resourceCategory.getElement().setId("lblResourceCategory");
    resourceSourceName.getElement().setId("lblResourceSourceName");
    ratingWidgetPanel.getElement().setId("fpnlRatingWidgetPanel");
    this.collectionItemDo = collectionItemDo;
    setNavigationResourceTitle(collectionItemDo.getResource().getTitle());
    if (collectionItemDo.getResource().getResourceFormat() != null) {
      setResourceTypeIcon(collectionItemDo.getResource().getResourceFormat().getDisplayName());
    }
    setResourceCategory();
    setReourceSourceName();
    setResourceSequence(itemIndex + 1);
    setResourcePlayLink();

    if (AppClientFactory.getCurrentPlaceToken().equalsIgnoreCase(PlaceTokens.COLLECTION_PLAY)) {
      setAvgRatingWidget();
      AppClientFactory.getEventBus()
          .addHandler(UpdateRatingsInRealTimeEvent.TYPE, setRatingWidgetMetaData);
    }
  }
 public void setNavigationResourceTitle(String title) {
   resourceTitle.setHTML(getHTML(title));
   resourceTitle.getElement().setAttribute("alt", getHTML(title));
   resourceTitle.getElement().setAttribute("title", getHTML(title));
   resourceHoverTitle.setHTML(getHTML(title));
   resourceHoverTitle.getElement().setAttribute("alt", getHTML(title));
   resourceHoverTitle.getElement().setAttribute("title", getHTML(title));
 }
Example #4
0
 public void startTable() {
   HTML headers = new HTML();
   headers.getElement().addClassName("login-table-header");
   headers.setText("Cliente");
   table.setWidget(0, 0, headers);
   headers = new HTML();
   headers.getElement().addClassName("login-table-header");
   headers.setText("Fecha Inicio");
   table.setWidget(0, 1, headers);
   headers = new HTML();
   headers.getElement().addClassName("login-table-header");
   headers.setText("Fecha Fin");
   table.setWidget(0, 2, headers);
 }
 public PreviewResourceView() {
   initWidget(uiBinder.createAndBindUi(this));
   resourceThumbContainer.getElement().setId("fpnlResourceThumbContainer");
   resourceImageContainer.getElement().setId("fpnlResourceImageContainer");
   resourceThumbnail.getElement().setId("imgResourceThumbnail");
   resourceTypeImage.getElement().setId("lblResourceTypeImage");
   resourceNumber.getElement().setId("lblResourceNumber");
   resourceTitle.getElement().setId("htmlResourceTitle");
   resourceIndex.getElement().setId("lblResourceIndex");
   resourceHoverTitle.getElement().setId("htmlResourceHoverTitle");
   resourceCategory.getElement().setId("lblResourceCategory");
   resourceSourceName.getElement().setId("lblResourceSourceName");
   ratingWidgetPanel.getElement().setId("fpnlRatingWidgetPanel");
 }
  public CarouselViewGwtImpl() {

    scrollPanel.removeFromParent();

    carousel = new Carousel();

    main.add(carousel);

    for (int i = 0; i < 5; i++) {
      RootFlexPanel rootFlexPanel = new RootFlexPanel();
      ScrollPanel scrollPanel2 = new ScrollPanel();
      scrollPanel2.setScrollingEnabledX(false);
      // scrollPanel2.setWidth("100%");

      Panel flowPanel3 = new Panel();
      flowPanel3.setRound(true);
      for (int j = 0; j < 10; j++) {
        HTML html = new HTML("Slide: " + (i + 1));
        html.getElement().getStyle().setMarginBottom(300, Unit.PX);
        flowPanel3.add(html);
      }

      scrollPanel2.setWidget(flowPanel3);
      rootFlexPanel.add(scrollPanel2);
      carousel.add(rootFlexPanel);
    }
  }
  /**
   * 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);
  }
 @Override
 public void print(String text) {
   HTML html = new HTML();
   html.setHTML("<pre style='margin:0px; font-size: 11px;'>" + text + "</pre>");
   html.getElement().setAttribute("style", "padding-left: 2px;");
   consoleArea.add(html);
 }
 public void output(String text, String color) {
   DivElement div = Document.get().createDivElement();
   div.setInnerText(text);
   div.setAttribute("style", "color:" + color);
   messages.getElement().appendChild(div);
   scrollPanel.scrollToBottom();
 }
Example #10
0
 public void onMouseDown(MouseDownEvent event) {
   setMouseDown(true);
   updateCSS();
   DOM.setCapture(view.getElement());
   dragStartX = event.getX();
   dragStartY = event.getY();
   event.preventDefault();
 }
 @Override
 public Widget cloneDisplay(Map<String, Object> data) {
   HTML html = new HTML();
   html.setHTML(this.html.getHTML());
   populate(html);
   super.populateActions(html.getElement());
   return html;
 }
 public void onMouseDown(Widget sender, int x, int y) {
   dragging = true;
   DOM.setCapture(caption.getElement());
   hide();
   show();
   dragStartX = x;
   dragStartY = y;
 }
Example #13
0
 private void updateCSS() {
   Element element = view.getElement();
   element.setClassName("node");
   element.addClassName(model.getState());
   element.addClassName(model.getKind());
   if (isMouseDown()) {
     element.addClassName("down");
   }
 }
Example #14
0
  public Widget asWidget() {

    // last element to the right
    HTML placeHolder = new HTML();
    this.bar.add(placeHolder);
    placeHolder.getElement().getParentElement().setAttribute("style", "width:100%");

    return bar;
  }
Example #15
0
  public static HTML makeProcessInfoDiv() {
    Element processDiv = DOM.createDiv();
    processDiv.setId("process_info");
    processDiv.appendChild(DOM.createElement("svg"));

    HTML processHtml = new HTML(processDiv.getString());
    processHtml.getElement().setId(_DRUPAL_GWTVIZ_PROCESS_ID);
    return processHtml;
  }
Example #16
0
  public static HTML makeChartDiv() {

    Element chartDiv = DOM.createDiv();
    chartDiv.setId("chart");
    chartDiv.appendChild(DOM.createElement("svg"));

    HTML chartHtml = new HTML(chartDiv.getString());
    chartHtml.getElement().setId(_DRUPAL_GWTVIZ_CHART_ID);
    return chartHtml;
  }
Example #17
0
  /**
   * Prints a new line into the log window by adding a p-tag including given text as HTML.
   *
   * <p>
   *
   * @param text the text to print
   */
  public void printLine(String text) {

    if (!DEBUG) {
      return;
    }
    @SuppressWarnings("unused")
    Element child = DOM.createElement("p");
    child.setInnerHTML(text);
    m_html.getElement().insertFirst(child);
  }
  public boolean onEventPreview(Event event) {
    // We need to preventDefault() on mouseDown events (outside of the
    // DialogBox content) to keep text from being selected when it
    // is dragged.
    if (DOM.eventGetType(event) == Event.ONMOUSEDOWN) {
      if (DOM.isOrHasChild(caption.getElement(), DOM.eventGetTarget(event))) {
        DOM.eventPreventDefault(event);
      }
    }

    return super.onEventPreview(event);
  }
  /**
   * The constructor sets up the UI and passes the data fetching parameters to the sub widgets
   *
   * @param service
   * @param documentID
   * @param instructor
   * @param unsavedDocumentStrategy
   */
  public InstructorPreferencesView(
      CachedOpenWorkingCopyDocument openDocument, InstructorGWT instructor) {
    this.openDocument = openDocument;

    instructor.verify();

    this.instructor = instructor;

    HTML instructorName = new HTML("Instructor Time Preferences");
    instructorName.setStyleName("bigBold");
    DOM.setElementAttribute(instructorName.getElement(), "id", "instructorName");
    InstructorPreferencesView.this.add(instructorName);

    InstructorPreferencesView.this.timePrefs =
        new TimePrefsWidget(
            InstructorPreferencesView.this.openDocument, InstructorPreferencesView.this.instructor);

    InstructorPreferencesView.this.setSpacing(20);

    InstructorPreferencesView.this.add(timePrefs);
    InstructorPreferencesView.this.setStyleName("preferencesPanel");

    InstructorPreferencesView.this.coursePrefs =
        new CoursePrefsWidget(
            InstructorPreferencesView.this.openDocument, InstructorPreferencesView.this.instructor);
    InstructorPreferencesView.this.coursePrefs.setStyleName("otherCenterness");
    InstructorPreferencesView.this.coursePrefs.afterPush();

    HTML cprefs = new HTML("Instructor Course Preferences");
    cprefs.addStyleName("bigBold");
    InstructorPreferencesView.this.add(cprefs);

    InstructorPreferencesView.this.add(coursePrefs);

    closebutton =
        new Button(
            "Close",
            new ClickHandler() {
              public void onClick(ClickEvent event) {
                parent.hide();
              }
            });

    if (additionalCloseHandler != null) {
      closebutton.addClickHandler(additionalCloseHandler);
      additionalCloseHandler = null;
    }
    DOM.setElementAttribute(closebutton.getElement(), "id", "s_prefCloseBtn");
    InstructorPreferencesView.this.add(closebutton);
    InstructorPreferencesView.this.setCellHorizontalAlignment(closebutton, ALIGN_RIGHT);
  }
Example #20
0
  @Test
  public void html_withAnchor() {
    // Arrange
    HTML widget = new HTML("<a href=\"foo\" target=\"bar\">baz</a>");

    // Act
    NodeList<Element> nodeList = widget.getElement().getElementsByTagName("a");

    // Assert
    assertEquals(1, nodeList.getLength());
    AnchorElement anchor = nodeList.getItem(0).cast();
    assertEquals("foo", anchor.getHref());
    assertEquals("bar", anchor.getTarget());
  }
Example #21
0
  NodePresenter(VGraphExplorer parent, NodeProxy model) {
    this.parent = parent;
    this.model = model;
    graph = parent.getGraph();

    view.setTitle(model.getId());
    Style style = view.getElement().getStyle();
    style.setLeft(model.getX(), Unit.PX);
    style.setTop(model.getY(), Unit.PX);

    view.addDomHandler(this, MouseDownEvent.getType());
    view.addDomHandler(this, MouseMoveEvent.getType());
    view.addDomHandler(this, MouseUpEvent.getType());

    parent.add(view);
  }
Example #22
0
  private void limitToBoundingBox() {
    Element element = view.getElement();
    Style style = element.getStyle();

    int width = element.getOffsetWidth();
    model.setWidth(width);
    int xRadius = width / 2;
    int leftEdge = model.getX() - xRadius;
    leftEdge = limit(0, leftEdge, parent.getOffsetWidth() - width);
    model.setX(leftEdge + xRadius);
    style.setLeft(leftEdge, Unit.PX);

    int height = element.getOffsetHeight();
    model.setHeight(height);
    int yRadius = height / 2;
    int topEdge = model.getY() - yRadius;
    topEdge = limit(0, topEdge, parent.getOffsetHeight() - height);
    model.setY(topEdge + yRadius);
    style.setTop(topEdge, Unit.PX);
  }
  /**
   * 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);
  }
  @Inject
  public QuestionResourceView() {
    setWidget(uiBinder.createAndBindUi(this));
    questiontext.getElement().setInnerHTML(i18n.GL0308());
    questiontext.getElement().setId("pnlQuestiontext");
    questiontext.getElement().setAttribute("alt", i18n.GL0308());
    questiontext.getElement().setAttribute("title", i18n.GL0308());

    hintsButton.setText(i18n.GL0667());
    hintsButton.getElement().setId("btnHintsButton");
    hintsButton.getElement().setAttribute("alt", i18n.GL0667());
    hintsButton.getElement().setAttribute("title", i18n.GL0667());

    explanaionButton.setText(i18n.GL0316());
    explanaionButton.getElement().setId("btnexplanaionButton");
    explanaionButton.getElement().setAttribute("alt", i18n.GL0316());
    explanaionButton.getElement().setAttribute("title", i18n.GL0316());

    openEndedQuestionText.getElement().setId("htmlOpenEndedQuestionText");
    questionContainer.getElement().setId("fpnlQuestionContainer");
    openEndedQuestionImage.getElement().setId("imgOpenEndedQuestionImage");
    hintsContainer.getElement().setId("fpnlHintsContainer");
    explanationContainer.getElement().setId("pnlExplanationContainer");
  }
  private ToolStrip toolstripButtons() {

    final TextBox filter = new TextBox();
    filter.setMaxLength(30);
    filter.setVisibleLength(20);
    filter.getElement().setAttribute("style", "float:right; width:120px;");
    filter.addKeyUpHandler(
        keyUpEvent -> {
          String word = filter.getText();
          if (word != null && word.trim().length() > 0) {
            filter(word);
          } else {
            clearFilter();
          }
        });

    ToolStrip topLevelTools = new ToolStrip();

    final HTML label = new HTML(Console.CONSTANTS.commom_label_filter() + ":&nbsp;");
    label.getElement().setAttribute("style", "padding-top:8px;");
    topLevelTools.addToolWidget(label);
    topLevelTools.addToolWidget(filter);

    enableBtn =
        new ToolButton(Console.CONSTANTS.common_label_enable(), event -> presenter.enable());
    disableBtn =
        new ToolButton(Console.CONSTANTS.common_label_disable(), event -> presenter.disable());
    refreshBtn =
        new ToolButton(Console.CONSTANTS.common_label_refresh(), event -> presenter.loadChanges());

    topLevelTools.addToolButtonRight(enableBtn);
    topLevelTools.addToolButtonRight(disableBtn);
    topLevelTools.addToolButtonRight(refreshBtn);

    return topLevelTools;
  }
Example #26
0
 public void onMouseUp(MouseUpEvent event) {
   Element element = view.getElement();
   if (!isDragging()) {
     updateCSS();
     limitToBoundingBox();
     if (NodeProxy.EXPANDED.equals(model.getState())) {
       model.setState(NodeProxy.COLLAPSED);
       for (NodeProxy neighbor : graph.getNeighbors(model)) {
         boolean collapsed = NodeProxy.COLLAPSED.equals(neighbor.getState());
         boolean leafNode = graph.degree(neighbor) == 1;
         if (collapsed && leafNode) {
           graph.removeNode(neighbor);
         }
       }
     }
     parent.toggle(model);
   } else {
     parent.save(model, true);
     setDragging(false);
   }
   setMouseDown(false);
   DOM.releaseCapture(element);
   event.preventDefault();
 }
Example #27
0
  @Override
  protected void onRender(Element parent, int index) {
    super.onRender(parent, index);

    final Stock stock = TestData.getStocks().get(0);

    HorizontalPanel hp = new HorizontalPanel();
    hp.setSpacing(10);

    StringBuffer sb = new StringBuffer();
    sb.append("<div class=text style='line-height: 1.5em'>");
    sb.append("<b>Name:</b> {name}<br>");
    sb.append("<b>Symbol:</b> {symbol}<br>");
    sb.append("<b>Last:</b> {last}<br>");
    sb.append("<b>Change:</b> {[new Number(values.change).toFixed(2)]}<br>");
    sb.append("<b>Updated:</b> {date:date(\"MM/dd/y\")}<br>");
    sb.append("</div>");

    final XTemplate template = XTemplate.create(sb.toString());
    final HTML html = new HTML();
    html.setWidth("160px");
    template.overwrite(html.getElement(), Util.getJsObject(stock));
    hp.add(html);
    // update template when model changes
    stock.addChangeListener(
        new ChangeListener() {
          public void modelChanged(ChangeEvent event) {
            template.overwrite(html.getElement(), Util.getJsObject(stock));
          }
        });

    FormPanel panel = new FormPanel();
    panel.setHeaderVisible(false);
    panel.setWidth(350);

    TextField<String> name = new TextField<String>();
    name.setName("nameField");
    name.setFieldLabel("Name");
    panel.add(name);

    TextField<String> symbol = new TextField<String>();
    symbol.setName("symbol");
    symbol.setFieldLabel("Symbol");
    panel.add(symbol);

    NumberField open = new NumberField();
    open.setName("last");
    open.setFieldLabel("Last");
    panel.add(open);

    NumberField change = new NumberField();
    change.setName("change");
    change.setFieldLabel("Change");
    change.setFormat(NumberFormat.getDecimalFormat());
    panel.add(change);

    DateField last = new DateField();
    last.setName("date");
    last.setFieldLabel("Updated");
    panel.add(last);

    SimpleComboBox<String> scb = new SimpleComboBox<String>();
    for (Stock s : TestData.getStocks()) {
      scb.add(s.getName());
    }
    scb.setFieldLabel("Name");
    scb.setForceSelection(true);
    scb.setTypeAhead(true);
    scb.setName("company");
    scb.setTriggerAction(TriggerAction.ALL);
    panel.add(scb);

    hp.add(panel);

    FormBinding binding = new FormBinding(panel);
    // manually add bindings
    binding.addFieldBinding(new FieldBinding(name, "name"));
    binding.addFieldBinding(new FieldBinding(symbol, "symbol"));
    binding.addFieldBinding(new SimpleComboBoxFieldBinding(scb, "name"));

    // auto bind remaining fields, field name must match model property name
    binding.autoBind();
    binding.bind(stock);

    add(hp);
  }
Example #28
0
  public Widget asWidget() {

    final TabPanel tabs = new TabPanel();
    tabs.setStyleName("default-tabpanel");

    // -------

    VerticalPanel layout = new VerticalPanel();
    layout.setStyleName("window-content");

    // Create a FormPanel and point it at a service.
    final FormPanel form = new FormPanel();
    String url = Console.getBootstrapContext().getProperty(BootstrapContext.DEPLOYMENT_API);
    form.setAction(url);

    form.setEncoding(FormPanel.ENCODING_MULTIPART);
    form.setMethod(FormPanel.METHOD_POST);

    // Create a panel to hold all of the form widgets.
    VerticalPanel panel = new VerticalPanel();
    panel.getElement().setAttribute("style", "width:100%");
    form.setWidget(panel);

    // Create a FileUpload widgets.
    final FileUpload upload = new FileUpload();
    upload.setName("uploadFormElement");
    panel.add(upload);

    final HTML errorMessages = new HTML("Please chose a file!");
    errorMessages.setStyleName("error-panel");
    errorMessages.setVisible(false);
    panel.add(errorMessages);

    // Add a 'submit' button.

    ClickHandler cancelHandler =
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            window.hide();
          }
        };

    ClickHandler submitHandler =
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {

            errorMessages.setVisible(false);

            // verify form
            String filename = upload.getFilename();

            if (tabs.getTabBar().getSelectedTab() == 1) {
              // unmanaged content
              if (unmanagedForm.validate().hasErrors()) {
                return;
              } else {
                wizard.onCreateUnmanaged(unmanagedForm.getUpdatedEntity());
              }
            } else if (filename != null && !filename.equals("")) {
              loading =
                  Feedback.loading(
                      Console.CONSTANTS.common_label_plaseWait(),
                      Console.CONSTANTS.common_label_requestProcessed(),
                      new Feedback.LoadingCallback() {
                        @Override
                        public void onCancel() {}
                      });
              form.submit();
            } else {
              errorMessages.setVisible(true);
            }
          }
        };

    DialogueOptions options =
        new DialogueOptions(
            Console.CONSTANTS.common_label_next(), submitHandler,
            Console.CONSTANTS.common_label_cancel(), cancelHandler);

    // Add an event handler to the form.
    form.addSubmitCompleteHandler(
        new FormPanel.SubmitCompleteHandler() {
          @Override
          public void onSubmitComplete(FormPanel.SubmitCompleteEvent event) {

            getLoading().hide();

            String html = event.getResults();

            // Step 1: upload content, retrieve hash value
            try {

              String json = html;

              try {
                if (!GWT.isScript()) // TODO: Formpanel weirdness
                json = html.substring(html.indexOf(">") + 1, html.lastIndexOf("<"));
              } catch (StringIndexOutOfBoundsException e) {
                // if I get this exception it means I shouldn't strip out the html
                // this issue still needs more research
                Log.debug("Failed to strip out HTML.  This should be preferred?");
              }

              JSONObject response = JSONParser.parseLenient(json).isObject();
              JSONObject result = response.get("result").isObject();
              String hash = result.get("BYTES_VALUE").isString().stringValue();
              // step2: assign name and group
              wizard.onUploadComplete(upload.getFilename(), hash);

            } catch (Exception e) {
              Log.error(Console.CONSTANTS.common_error_failedToDecode() + ": " + html, e);
            }

            // Option 2: Unmanaged content

          }
        });

    String stepText =
        "<h3>"
            + Console.CONSTANTS.common_label_step()
            + "1/2: "
            + Console.CONSTANTS.common_label_deploymentSelection()
            + "</h3>";
    layout.add(new HTML(stepText));
    HTML description = new HTML();
    description.setHTML(Console.CONSTANTS.common_label_chooseFile());
    description.getElement().setAttribute("style", "padding-bottom:15px;");
    layout.add(description);
    layout.add(form);
    tabs.add(layout, "Managed");

    // Unmanaged form only for new deployments
    if (!wizard.isUpdate()) {
      VerticalPanel unmanagedPanel = new VerticalPanel();
      unmanagedPanel.setStyleName("window-content");

      String unmanagedText =
          "<h3>" + Console.CONSTANTS.common_label_step() + "1/1: Specify Deployment</h3>";
      unmanagedPanel.add(new HTML(unmanagedText));

      unmanagedForm = new Form<DeploymentRecord>(DeploymentRecord.class);
      TextAreaItem path = new TextAreaItem("path", "Path");
      TextBoxItem relativeTo = new TextBoxItem("relativeTo", "Relative To", false);

      TextBoxItem name = new TextBoxItem("name", "Name");
      TextBoxItem runtimeName = new TextBoxItem("runtimeName", "Runtime Name");
      CheckBoxItem archive = new CheckBoxItem("archive", "Is Archive?");
      archive.setValue(true);
      unmanagedForm.setFields(path, relativeTo, archive, name, runtimeName);
      unmanagedPanel.add(unmanagedForm.asWidget());
      tabs.add(unmanagedPanel, "Unmanaged");
    }

    tabs.selectTab(0);
    return new WindowContentBuilder(tabs, options).build();
  }
Example #29
0
  public WindowHeader(String title, final PopupPanel callback) {

    final HorizontalPanel header = new HorizontalPanel();
    header.setStyleName("default-window-header");

    HTML titleText = new HTML(title);
    titleText.setStyleName("default-window-title");

    Image closeIcon = new Image(Icons.INSTANCE.close());
    closeIcon.setAltText("Close");
    closeIcon.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent clickEvent) {
            callback.hide();
          }
        });

    Image maximizeIcon = new Image(Icons.INSTANCE.maximize());
    maximizeIcon.setAltText("Min/Maximize");
    maximizeIcon.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent clickEvent) {

            int width = origWidth;
            int height = origHeight;

            int top = origTop;
            int left = origLeft;

            if (origWidth == -1) {
              origWidth = getOffsetWidth();
              origHeight = (int) (origWidth / 1.618) + 50; // TODO: this fails "getOffsetHeight()";
              origLeft = getAbsoluteLeft();
              origTop = getAbsoluteTop();

              width = Window.getClientWidth() - 50;
              height = Window.getClientHeight() - 50;

              top = 25;
              left = 25;
            } else {
              origWidth = -1;
              origHeight = -1;
              origLeft = -1;
              origTop = -1;
            }

            callback.hide();

            callback.setPopupPosition(top, left);
            callback.setWidth(width + "px");
            callback.setHeight(height + "px");

            callback.show();
          }
        });

    header.add(titleText);
    header.add(maximizeIcon);
    header.add(closeIcon);

    initWidget(header);

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

    maximizeIcon.getElement().getParentElement().setAttribute("width", "16px");
    maximizeIcon
        .getElement()
        .getParentElement()
        .setAttribute("style", "width:16px;padding-right:5px");

    closeIcon.getElement().getParentElement().setAttribute("width", "16px");
    closeIcon.getElement().getParentElement().setAttribute("style", "width:16px;padding-right:5px");
  }
Example #30
0
 public String getAsHtml(String name) {
   htmlName = new HTML();
   htmlName.getElement().setInnerHTML(name);
   return htmlName.getHTML();
 }