/**
   * Creates new component design panel for visible components.
   *
   * @param nonVisibleComponentsPanel corresponding panel for non-visible components
   */
  public SimpleVisibleComponentsPanel(
      final SimpleEditor editor, SimpleNonVisibleComponentsPanel nonVisibleComponentsPanel) {
    this.nonVisibleComponentsPanel = nonVisibleComponentsPanel;
    projectEditor = editor.getProjectEditor();

    // Initialize UI
    phoneScreen = new VerticalPanel();
    phoneScreen.setStylePrimaryName("ode-SimpleFormDesigner");

    checkboxShowHiddenComponents =
        new CheckBox(MESSAGES.showHiddenComponentsCheckbox()) {
          @Override
          protected void onLoad() {
            // onLoad is called immediately after a widget becomes attached to the browser's
            // document.
            boolean showHiddenComponents =
                Boolean.parseBoolean(
                    projectEditor.getProjectSettingsProperty(
                        SettingsConstants.PROJECT_YOUNG_ANDROID_SETTINGS,
                        SettingsConstants.YOUNG_ANDROID_SETTINGS_SHOW_HIDDEN_COMPONENTS));
            checkboxShowHiddenComponents.setValue(showHiddenComponents);
          }
        };
    checkboxShowHiddenComponents.addValueChangeHandler(
        new ValueChangeHandler<Boolean>() {
          @Override
          public void onValueChange(ValueChangeEvent<Boolean> event) {
            boolean isChecked = event.getValue(); // auto-unbox from Boolean to boolean
            projectEditor.changeProjectSettingsProperty(
                SettingsConstants.PROJECT_YOUNG_ANDROID_SETTINGS,
                SettingsConstants.YOUNG_ANDROID_SETTINGS_SHOW_HIDDEN_COMPONENTS,
                isChecked ? "True" : "False");
            if (form != null) {
              form.refresh();
            }
          }
        });
    phoneScreen.add(checkboxShowHiddenComponents);

    initWidget(phoneScreen);
  }
コード例 #2
0
ファイル: TagMenuPopup.java プロジェクト: e-gius/catma
  public TagMenuPopup(TaggerEditor vTagger, String lastSelectedColor) {
    super(true);
    getElement().addClassName("tagmenu-popup");
    this.setText("Annotations");
    this.vTagger = vTagger;
    this.lastSelectedColor = lastSelectedColor;
    root = new TreeItem("Available annotations");
    final Tree tree = new Tree();
    tree.addItem(root);
    root.setState(true);
    root.setStyleName("tagger_menu_root");

    final VerticalPanel vPanel = new VerticalPanel();

    if (vTagger.hasSelection()) {

      final VerticalPanel annotationCreationPanel = new VerticalPanel();
      annotationCreationPanel.setSpacing(5);
      annotationCreationPanel.setWidth("100%");
      final TextArea annotationBodyInput = new TextArea();
      annotationBodyInput.setWidth("90%");
      annotationCreationPanel.add(annotationBodyInput);
      final HorizontalPanel annotationCreationButtonPanel = new HorizontalPanel();
      annotationCreationButtonPanel.setSpacing(5);
      final Label colorLabel = new HTML("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
      final ColorPicker colorPicker =
          new ColorPicker() {
            @Override
            public void onChange(Widget sender) {
              super.onChange(sender);
              colorLabel
                  .getElement()
                  .setAttribute("style", "background:#" + this.getHexColor() + ";");
            }
          };
      try {
        if (lastSelectedColor != null) {
          colorPicker.setHex(lastSelectedColor);
        } else {
          int[] randomColor = getRandomColor();
          colorPicker.setRGB(randomColor[0], randomColor[1], randomColor[2]);
        }
      } catch (Exception e) {
        // well...
      }
      colorLabel
          .getElement()
          .setAttribute("style", "background:#" + colorPicker.getHexColor() + ";");

      HorizontalPanel colorPanel = new HorizontalPanel();
      colorPanel.setSpacing(5);
      PushButton colorButton = new PushButton("Change color...");
      colorPanel.add(colorButton);

      colorPanel.add(colorLabel);

      HandlerRegistration colorButtonReg =
          colorButton.addClickHandler(
              new ClickHandler() {

                public void onClick(ClickEvent event) {

                  annotationCreationPanel.insert(
                      colorPicker,
                      annotationCreationPanel.getWidgetIndex(annotationCreationButtonPanel));
                  TagMenuPopup.this.center();
                }
              });
      handlerRegistrations.add(colorButtonReg);
      annotationCreationPanel.add(colorPanel);

      PushButton saveButton = new PushButton("Save");
      // saveButton.setStylePrimaryName("tagger-pushButton");
      HandlerRegistration saveButtonReg =
          saveButton.addClickHandler(
              new ClickHandler() {

                public void onClick(ClickEvent event) {
                  //	TagMenuPopup.this.vTagger.createAndAddTagIntance(colorPicker.getHexColor());
                  TagMenuPopup.this.lastSelectedColor = colorPicker.getHexColor();
                  hide();
                }
              });
      handlerRegistrations.add(saveButtonReg);

      PushButton cancelButton = new PushButton("Cancel");
      // cancelButton.setStylePrimaryName("tagger-pushButton");

      annotationCreationButtonPanel.add(saveButton);
      annotationCreationButtonPanel.add(cancelButton);
      annotationCreationPanel.add(annotationCreationButtonPanel);

      PushButton addAnnotationButton = new PushButton("Add annotation...");
      // addAnnotationButton.setStylePrimaryName("tagger-pushButton");

      HandlerRegistration addAnnotationBtReg =
          addAnnotationButton.addClickHandler(
              new ClickHandler() {

                public void onClick(ClickEvent event) {
                  vPanel.insert(annotationCreationPanel, vPanel.getWidgetIndex(tree));
                }
              });
      handlerRegistrations.add(addAnnotationBtReg);
      vPanel.add(addAnnotationButton);

      HandlerRegistration cancelButtonReg =
          cancelButton.addClickHandler(
              new ClickHandler() {
                public void onClick(ClickEvent event) {
                  annotationBodyInput.setText("");
                  vPanel.remove(annotationCreationPanel);
                }
              });

      handlerRegistrations.add(cancelButtonReg);
    }

    vPanel.add(tree);
    vPanel.setStylePrimaryName("tagger_menu");
    setWidget(vPanel);
  }