Examples of UIButton


Examples of com.ardor3d.extension.ui.UIButton

        final UIFrame optionsFrame = new UIFrame("Controls", EnumSet.noneOf(FrameButtons.class));

        final UIPanel basePanel = optionsFrame.getContentPanel();
        basePanel.setLayout(new AnchorLayout());

        runWalkButton = new UIButton("Start running...");
        runWalkButton.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, basePanel, Alignment.TOP_LEFT, 5, -5));
        runWalkButton.addActionListener(new ActionListener() {
            boolean walk = true;

            public void actionPerformed(final ActionEvent event) {
                if (!walk) {
                    if (manager.getBaseAnimationLayer().doTransition("walk")) {
                        runWalkButton.setButtonText("Start running...");
                        walk = true;
                    }
                } else {
                    if (manager.getBaseAnimationLayer().doTransition("run")) {
                        runWalkButton.setButtonText("Start walking...");
                        walk = false;
                    }
                }
            }
        });
        basePanel.add(runWalkButton);

        punchButton = new UIButton("PUNCH!");
        punchButton
                .setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, runWalkButton, Alignment.BOTTOM_LEFT, 0, -5));
        punchButton.addActionListener(new ActionListener() {
            public void actionPerformed(final ActionEvent event) {
                manager.findAnimationLayer("punch").setCurrentState("punch_right", true);
View Full Code Here

Examples of com.ardor3d.extension.ui.UIButton

        final UIFrame optionsFrame = new UIFrame("Controls", EnumSet.noneOf(FrameButtons.class));

        final UIPanel basePanel = optionsFrame.getContentPanel();
        basePanel.setLayout(new AnchorLayout());

        final UIButton loadSceneButton = new UIButton("Load next scene");
        loadSceneButton.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, basePanel, Alignment.TOP_LEFT, 5, -5));
        loadSceneButton.addActionListener(new ActionListener() {
            public void actionPerformed(final ActionEvent event) {
                final File file = daeFiles.get(fileIndex);
                try {
                    loadColladaModel(new URLResourceSource(file.toURI().toURL()));
                    t1.setText(file.getName());
View Full Code Here

Examples of com.ardor3d.extension.ui.UIButton

                _pssmPass.setMaxShadowDistance(distSlider.getValue());
                distLabel.setText("Max Shadow Distance: " + distSlider.getValue());
            }
        });

        final UIButton updateCamera = new UIButton("Update Shadow Camera");
        updateCamera.setSelectable(true);
        updateCamera.setSelected(true);
        updateCamera.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent event) {
                _pssmPass.setUpdateMainCamera(updateCamera.isSelected());
                updateText();
            }
        });

        final UIButton rotateLight = new UIButton("Rotate Light");
        rotateLight.setSelectable(true);
        rotateLight.setSelected(false);
        rotateLight.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent event) {
                moveLight = rotateLight.isSelected();
                updateText();
            }
        });

        final UIPanel panel = new UIPanel(new RowLayout(false, true, false));
View Full Code Here

Examples of com.ardor3d.extension.ui.UIButton

        final UIFrame optionsFrame = new UIFrame("Controls", EnumSet.noneOf(FrameButtons.class));

        final UIPanel basePanel = optionsFrame.getContentPanel();
        basePanel.setLayout(new AnchorLayout());

        runWalkButton = new UIButton("Start running...");
        runWalkButton.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, basePanel, Alignment.TOP_LEFT, 5, -5));
        runWalkButton.addActionListener(new ActionListener() {
            boolean walk = true;

            public void actionPerformed(final ActionEvent event) {
                if (!walk) {
                    if (manager.getBaseAnimationLayer().doTransition("walk")) {
                        runWalkButton.setButtonText("Start running...");
                        walk = true;
                    }
                } else {
                    if (manager.getBaseAnimationLayer().doTransition("run")) {
                        runWalkButton.setButtonText("Start walking...");
                        walk = false;
                    }
                }
            }
        });
        basePanel.add(runWalkButton);

        punchButton = new UIButton("PUNCH!");
        punchButton
                .setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, runWalkButton, Alignment.BOTTOM_LEFT, 0, -5));
        punchButton.addActionListener(new ActionListener() {
            public void actionPerformed(final ActionEvent event) {
                manager.findAnimationLayer("punch").setCurrentState("punch_right", true);
                punchButton.setEnabled(false);
            }
        });
        basePanel.add(punchButton);

        playPauseButton = new UIButton("Pause");
        playPauseButton.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, punchButton, Alignment.BOTTOM_LEFT, 0,
                -5));
        playPauseButton.addActionListener(new ActionListener() {
            public void actionPerformed(final ActionEvent event) {
                if (playPauseButton.getText().equals("Pause")) {
                    manager.pause();
                    playPauseButton.setButtonText("Play");
                } else {
                    manager.play();
                    playPauseButton.setButtonText("Pause");
                }
            }
        });
        basePanel.add(playPauseButton);

        stopButton = new UIButton("Stop");
        stopButton
                .setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, playPauseButton, Alignment.BOTTOM_LEFT, 0, -5));
        stopButton.addActionListener(new ActionListener() {
            public void actionPerformed(final ActionEvent event) {
                manager.stop();
View Full Code Here

Examples of org.apache.myfaces.tobago.component.UIButton

    }
  }

  public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException {

    UIButton button = (UIButton) component;
    String clientId = button.getClientId(facesContext);

    CommandRendererHelper helper = new CommandRendererHelper(facesContext, button, CommandRendererHelper.Tag.BUTTON);

    TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);

    LabelWithAccessKey label = new LabelWithAccessKey(button);

    writer.startElement(HtmlElements.BUTTON, button);
    writer.writeAttribute(HtmlAttributes.TYPE, createButtonType(button), false);
    writer.writeNameAttribute(clientId);
    writer.writeIdAttribute(clientId);
    HtmlRendererUtils.writeDataAttributes(facesContext, writer, button);
    HtmlRendererUtils.renderTip(button, writer);
    writer.writeAttribute(HtmlAttributes.DISABLED, helper.isDisabled());
    Integer tabIndex = button.getTabIndex();
    if (tabIndex != null) {
      writer.writeAttribute(HtmlAttributes.TABINDEX, tabIndex);
    }
    if (helper.getOnclick() != null) {
      writer.writeAttribute(HtmlAttributes.ONCLICK, helper.getOnclick(), true);
    }
    Style style = new Style(facesContext, button);
    writer.writeStyleAttribute(style);
    HtmlRendererUtils.renderDojoDndItem(component, writer, true);
    writer.writeClassAttribute(Classes.create(button));
    writer.flush(); // force closing the start tag

    String image = (String) button.getAttributes().get(Attributes.IMAGE);
    if (image != null) {
      if (ResourceManagerUtils.isAbsoluteResource(image)) {
        // absolute Path to image : nothing to do
      } else {
        image = getImageWithPath(facesContext, image, helper.isDisabled());
      }
      writer.startElement(HtmlElements.IMG, null);
      writer.writeAttribute(HtmlAttributes.SRC, image, true);
      String tip = button.getTip();
      writer.writeAttribute(HtmlAttributes.ALT, tip != null ? tip : "", true);
      writer.endElement(HtmlElements.IMG);
    }

    if (label.getText() != null) {
      writer.startElement(HtmlElements.SPAN, null);
      HtmlRendererUtils.writeLabelWithAccessKey(writer, label);
      writer.endElement(HtmlElements.SPAN);
    }

    writer.endElement(HtmlElements.BUTTON);
    if (label.getAccessKey() != null) {
      if (LOG.isInfoEnabled()
          && !AccessKeyMap.addAccessKey(facesContext, label.getAccessKey())) {
        LOG.info("duplicated accessKey : " + label.getAccessKey());
      }
      HtmlRendererUtils.addClickAcceleratorKey(
          facesContext, button.getClientId(facesContext), label.getAccessKey());
    }

    if (ComponentUtils.getBooleanAttribute(component, Attributes.DEFAULT_COMMAND)) {
      boolean transition = ComponentUtils.getBooleanAttribute(button, Attributes.TRANSITION);
      HtmlRendererUtils.setDefaultTransition(facesContext, transition);

      HtmlRendererUtils.writeScriptLoader(facesContext, null, new String[]{
          "Tobago.setDefaultAction('" + button.getClientId(facesContext) + "')"});     
    }
  }
View Full Code Here

Examples of org.apache.myfaces.tobago.component.UIButton

  }

  @Override
  public Measure getPreferredWidth(FacesContext facesContext, Configurable component) {

    UIButton button = (UIButton) component;
    Measure width = Measure.ZERO;
    boolean image = button.getImage() != null;
    if (image) {
      width = getResourceManager().getThemeMeasure(facesContext, button, "imageWidth");
    }
    LabelWithAccessKey label = new LabelWithAccessKey(button);
View Full Code Here

Examples of org.apache.myfaces.tobago.component.UIButton

    layoutOfButtons.setRows("auto");

    box.getChildren().add(buttonPanel);
    box.onComponentPopulated(facesContext, parent);

    final UIButton okButton = (UIButton) CreateComponentUtils.createComponent(
        facesContext, UIButton.COMPONENT_TYPE, RendererTypes.BUTTON, "ok");
    buttonPanel.getChildren().add(okButton);
    okButton.setValueExpression(Attributes.LABEL, expressionFactory.createValueExpression(
        elContext, "#{tobagoContext.resourceBundle.datePickerOk}", String.class));
    ComponentUtils.putDataAttributeWithPrefix(okButton, DataAttributes.DATE_PICKER_OK, true);
    okButton.getAttributes().put(Attributes.POPUP_CLOSE, "afterSubmit");
    okButton.setOmit(true);
    final UIButton cancelButton = (UIButton) CreateComponentUtils.createComponent(
        facesContext, UIButton.COMPONENT_TYPE, RendererTypes.BUTTON, "cancel");
    buttonPanel.getChildren().add(cancelButton);
    cancelButton.setValueExpression(Attributes.LABEL, expressionFactory.createValueExpression(
        elContext, "#{tobagoContext.resourceBundle.datePickerCancel}", String.class));
    cancelButton.getAttributes().put(Attributes.POPUP_CLOSE, "immediate");

    buttonPanel.onComponentPopulated(facesContext, parent);
  }
View Full Code Here

Examples of org.apache.myfaces.tobago.component.UIButton

  private static final Logger LOG = LoggerFactory.getLogger(ButtonRenderer.class);

  public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException {

    final UIButton button = (UIButton) component;
    final String clientId = button.getClientId(facesContext);
    final boolean disabled = button.isDisabled();
    final LabelWithAccessKey label = new LabelWithAccessKey(button);

    final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);

    writer.startElement(HtmlElements.BUTTON, button);
    writer.writeAttribute(HtmlAttributes.TYPE, HtmlButtonTypes.BUTTON, false);
    writer.writeNameAttribute(clientId);
    writer.writeIdAttribute(clientId);
    HtmlRendererUtils.writeDataAttributes(facesContext, writer, button);
    HtmlRendererUtils.renderTip(button, writer);
    writer.writeAttribute(HtmlAttributes.DISABLED, disabled);

    if (!disabled) {
      final CommandMap map = new CommandMap(new Command(facesContext, button));
      writer.writeAttribute(DataAttributes.COMMANDS, JsonUtils.encode(map), true);

      writer.writeAttribute(HtmlAttributes.HREF, "#", false);

      if (label.getAccessKey() != null) {
        writer.writeAttribute(HtmlAttributes.ACCESSKEY, Character.toString(label.getAccessKey()), false);
      }

      final Integer tabIndex = button.getTabIndex();
      if (tabIndex != null) {
        writer.writeAttribute(HtmlAttributes.TABINDEX, tabIndex);
      }
    }

    Style style = new Style(facesContext, button);
    writer.writeStyleAttribute(style);
    HtmlRendererUtils.renderDojoDndItem(component, writer, true);
    writer.writeClassAttribute(Classes.create(button));
    if (((UIButton) component).isDefaultCommand()) {
      final AbstractUIForm form = ComponentUtils.findAncestor(component, AbstractUIForm.class);
      writer.writeAttribute(DataAttributes.DEFAULT, form.getClientId(facesContext), false);
    }
    writer.flush(); // force closing the start tag

    String image = (String) button.getAttributes().get(Attributes.IMAGE);
    if (image != null) {
      if (ResourceManagerUtils.isAbsoluteResource(image)) {
        // absolute Path to image : nothing to do
      } else {
        image = getImageWithPath(facesContext, image, disabled);
      }
      writer.startElement(HtmlElements.IMG, null);
      writer.writeAttribute(HtmlAttributes.SRC, image, true);
      String tip = button.getTip();
      writer.writeAttribute(HtmlAttributes.ALT, tip != null ? tip : "", true);
      writer.endElement(HtmlElements.IMG);
    }

    if (label.getText() != null) {
      writer.startElement(HtmlElements.SPAN, null);
      HtmlRendererUtils.writeLabelWithAccessKey(writer, label);
      writer.endElement(HtmlElements.SPAN);
    }

    writer.endElement(HtmlElements.BUTTON);
    if (label.getAccessKey() != null) {
      if (LOG.isInfoEnabled()
          && !AccessKeyMap.addAccessKey(facesContext, label.getAccessKey())) {
        LOG.info("duplicated accessKey : " + label.getAccessKey());
      }
      HtmlRendererUtils.addClickAcceleratorKey(
          facesContext, button.getClientId(facesContext), label.getAccessKey());
    }
  }
View Full Code Here

Examples of org.apache.myfaces.tobago.component.UIButton

  }

  @Override
  public Measure getPreferredWidth(FacesContext facesContext, Configurable component) {

    UIButton button = (UIButton) component;
    Measure width = Measure.ZERO;
    boolean image = button.getImage() != null;
    if (image) {
      width = getResourceManager().getThemeMeasure(facesContext, button, "imageWidth");
    }
    LabelWithAccessKey label = new LabelWithAccessKey(button);
View Full Code Here

Examples of org.apache.myfaces.tobago.component.UIButton

  }

  @Override
  protected void setProperties(final UIComponent uiComponent) {
    super.setProperties(uiComponent);
    final UIButton component = (UIButton) uiComponent;
    final FacesContext context = FacesContext.getCurrentInstance();
    final Application application = context.getApplication();
    if (actionListener != null) {
      component.addActionListener(new javax.faces.event.MethodExpressionActionListener(actionListener));
    }
    if (accessKey != null) {
      if (!accessKey.isLiteralText()) {
        component.setValueExpression("accessKey", accessKey);
      } else {
        component.setAccessKey(accessKey.getExpressionString().charAt(0));
      }
    }
    if (markup != null) {
      if (!markup.isLiteralText()) {
        component.setValueExpression("markup", markup);
      } else {
        component.setMarkup(org.apache.myfaces.tobago.context.Markup.valueOf(markup.getExpressionString()));
      }
    }
    if (link != null) {
      component.setValueExpression("link", link);
    }

    if (labelWithAccessKey != null) {
      component.setValueExpression("labelWithAccessKey", labelWithAccessKey);
    }

    if (defaultCommand != null) {
      if (!defaultCommand.isLiteralText()) {
        component.setValueExpression("defaultCommand", defaultCommand);
      } else {
        component.setDefaultCommand(Boolean.parseBoolean(defaultCommand.getExpressionString()));
      }
    }
    if (tabIndex != null) {
      if (!tabIndex.isLiteralText()) {
        component.setValueExpression("tabIndex", tabIndex);
      } else {
        component.setTabIndex(Integer.parseInt(tabIndex.getExpressionString()));
      }
    }
    if (tip != null) {
      component.setValueExpression("tip", tip);
    }

    if (inline != null) {
      if (!inline.isLiteralText()) {
        component.setValueExpression("inline", inline);
      } else {
        component.setInline(Boolean.parseBoolean(inline.getExpressionString()));
      }
    }
    if (action != null) {
      component.setActionExpression(action);
    }
    if (resource != null) {
      component.setValueExpression("resource", resource);
    }

    if (jsfResource != null) {
      if (!jsfResource.isLiteralText()) {
        component.setValueExpression("jsfResource", jsfResource);
      } else {
        component.setJsfResource(Boolean.parseBoolean(jsfResource.getExpressionString()));
      }
    }
    if (transition != null) {
      if (!transition.isLiteralText()) {
        component.setValueExpression("transition", transition);
      } else {
        component.setTransition(Boolean.parseBoolean(transition.getExpressionString()));
      }
    }
    if (image != null) {
      component.setValueExpression("image", image);
    }

    if (label != null) {
      component.setValueExpression("label", label);
    }

    if (immediate != null) {
      if (!immediate.isLiteralText()) {
        component.setValueExpression("immediate", immediate);
      } else {
        component.setImmediate(Boolean.parseBoolean(immediate.getExpressionString()));
      }
    }
    if (renderedPartially != null) {
      if (!renderedPartially.isLiteralText()) {
        component.setValueExpression("renderedPartially", renderedPartially);
      } else {
        component.setRenderedPartially(splitList(renderedPartially.getExpressionString()));
      }
    }
    if (target != null) {
      component.setValueExpression("target", target);
    }

    if (onclick != null) {
      component.setValueExpression("onclick", onclick);
    }

    if (disabled != null) {
      if (!disabled.isLiteralText()) {
        component.setValueExpression("disabled", disabled);
      } else {
        component.setDisabled(Boolean.parseBoolean(disabled.getExpressionString()));
      }
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.