コード例 #1
0
  private void addAuthorizedModulesToMenu(Layout menuHolder, String moduleKey) {
    Collection<Module> allowedModules = modules.values();
    for (Iterator<Module> iterator = allowedModules.iterator(); iterator.hasNext(); ) {
      Module testModule = iterator.next();
      if (!SecurityManager.getInstance().isUserAuthorizedToViewModule(testModule.getModuleKey())) {
        iterator.remove();
        if (moduleKey != null && moduleKey.equals(testModule.getModuleKey())) {
          moduleKey = null;
        }
      }
    }

    // The module being requested is not visible to the current user.  Set the default to
    // the first module (if one is available).
    if (moduleKey == null && allowedModules.size() > 0) {
      moduleKey = allowedModules.iterator().next().getModuleKey();
    }

    for (Module module : allowedModules) {
      boolean selected = module.getModuleKey().equals(moduleKey);
      Label primaryMenuLabel = buildPrimaryMenuOption(module, selected);
      menuHolder.addMember(primaryMenuLabel);
      menuHolder.addMember(buildMenuSpacer());
      moduleLabelMap.put(module.getModuleKey(), primaryMenuLabel);
    }
  }
コード例 #2
0
ファイル: UIFormBlock.java プロジェクト: StexX/KiWi-OSE
  /**
   * Generates the view layout. Takes the getFieldOrder and generates a field for each entry in the
   * dataMap
   *
   * @return
   */
  private Layout getViewForm() {
    Layout panel = new VLayout();
    panel.setWidth(300);
    panel.setDefaultHeight(10);

    for (String field : getFieldOrder()) {
      UIFormFieldValue uiField = dataMap.get(field);
      if (uiField == null) {
        log("!!uiField for " + field + " was null!");
      }

      addViewElement(panel, field, uiField.getLabel(), uiField.getValue());
    }

    final Button editButton = new Button("Edit " + getFormLabel());
    editButton.setPadding(5);
    editButton.addClickHandler(
        new ClickHandler() {

          @Override
          public void onClick(ClickEvent event) {
            switchToEdit();
          }
        });
    if (dataMap.get("editable") != null)
      editButton.setDisabled(!(Boolean) (dataMap.get("editable").getValue()));

    panel.addMember(editButton);

    return panel;
  }
コード例 #3
0
ファイル: GarsCom.java プロジェクト: Biot-Savart/GarsCom
  /** This is the entry point method. */
  public void onModuleLoad() {
    loading = new LoadingWindow();

    VLayout main = new VLayout();
    main.setWidth("100%");
    main.setHeight100();
    main.setAlign(Alignment.CENTER);

    Layout imgLayout = new Layout();
    content = new HLayout();
    content.setHeight100();

    Img header = new Img("GarsComLogo.jpg");
    header.setWidth(600);
    header.setHeight(130);
    header.setAlign(Alignment.CENTER);
    imgLayout.addMember(header);
    imgLayout.setWidth("100%");
    imgLayout.setAlign(Alignment.CENTER);

    main.addMember(imgLayout);
    main.addMember(content);

    Tabs tabs = new Tabs();
    content.addMember(tabs);

    main.draw();
  }
コード例 #4
0
ファイル: UIFormBlock.java プロジェクト: StexX/KiWi-OSE
 /** clears the layout and shows the new generated view. */
 public void switchToView(boolean refresh) {
   layout.removeMembers(layout.getMembers());
   if (refresh) {
     getViewPanel(); // gets the data first!
   } else {
     layout.addMember(getViewForm());
   }
 }
コード例 #5
0
  @Override
  protected void onInit() {
    super.onInit();
    Layout layout = new VLayout();
    layout.setPadding(5);
    layout.setMembersMargin(5);
    layout.addMember(getConnectionForm());
    layout.setDefaultLayoutAlign(Alignment.CENTER);
    layout.setLayoutAlign(Alignment.CENTER);

    if (this.showInstallButton) {
      agentConfigXmlUploadForm = createAgentConfigXmlUploadForm();
      layout.addMember(agentConfigXmlUploadForm);
      /* For now, don't allow users to upload and ship their own env script to a remote machine; that might have security implications.
       * If we want to allow this, just uncomment these lines and you are good to go because everything else that is needed
       * is already in place and working as of April 2014.
      rhqAgentEnvUploadForm = createAgentEnvUploadForm();
      layout.addMember(rhqAgentEnvUploadForm);
      */
    }

    HTMLFlow header = new HTMLFlow("");
    header.setStyleName("headerItem");
    header.setExtraSpace(5);
    layout.addMember(header);
    layout.addMember(getButtons());

    addMember(layout);
  }
 private void replaceContent(Layout layout, Canvas content) {
   if (content != null) {
     content.setWidth100();
     content.setHeight100();
     if (layout.hasMember(content)) {
       content.setVisible(true);
     } else {
       layout.addMember(content);
       // TODO: needed ?  content.setVisible(true);
     }
   }
 }
コード例 #7
0
ファイル: UIFormBlock.java プロジェクト: StexX/KiWi-OSE
 /**
  * Put a label-value pair on the panel for view. Only happens if the value is not empty.
  *
  * @param panel
  * @param label
  * @param value
  */
 private void addViewElement(Layout panel, String label, String value) {
   if (value != null && value.trim() != "") {
     final HTML element = new HTML(label + ": <b>" + value + "</b>");
     element.setHeight("2em");
     panel.addMember(element);
   }
 }
コード例 #8
0
ファイル: UIFormBlock.java プロジェクト: StexX/KiWi-OSE
  public Canvas getViewPanel() {
    getData(
        new AsyncCallback<LinkedHashMap<String, UIFormFieldValue>>() {

          @Override
          public void onSuccess(LinkedHashMap<String, UIFormFieldValue> result) {
            dataMap = result;
            layout.addMember(getViewForm());
          }

          @Override
          public void onFailure(Throwable caught) {
            SC.warn("Couldn't load " + getFormLabel() + "(" + caught.getMessage() + ")");
          }
        });

    layout.setPadding(10);
    return layout;
  }
コード例 #9
0
    HtmlUploadComponentImpl(final UploadComponentOptions options, final boolean zip) {
      this.zip = zip;
      if (zip) {
        types = "*.zip";
        typesDescription = "Zip";
      } else {
        types = options.getTypes() == null ? null : options.getTypes();
        typesDescription =
            options.getTypesDescription() == null ? null : options.getTypesDescription();
      }
      this.options = options;
      if (isMultiple()) {
        formPanel.setHeight("125px");
        scrollPanel.setHeight("125px");
        formPanel.setWidth("320px");
        scrollPanel.setWidth("320px");
      } else {
        formPanel.setHeight("30px");
        scrollPanel.setHeight("30px");
        formPanel.setWidth("310px");
        scrollPanel.setWidth("310px");
      }

      panel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);

      formPanel.setWidget(scrollPanel);
      formPanel.setAction(GWT.getHostPageBaseURL() + "fileupload?zip=" + zip);
      formPanel.setEncoding(FormPanel.ENCODING_MULTIPART);
      formPanel.setMethod(FormPanel.METHOD_POST);
      formPanel.addSubmitHandler(
          new SubmitHandler() {
            public void onSubmit(final SubmitEvent submitEvent) {}
          });
      formPanel.addSubmitCompleteHandler(
          new SubmitCompleteHandler() {
            public void onSubmitComplete(final SubmitCompleteEvent completeEvent) {
              System.out.println("Submit complete " + completeEvent.getResults());
              final String result = completeEvent.getResults();
              try {
                final List<FileSource> fileSources = toFileSources(result);
                options.getCompletionCallback().onSuccess(fileSources);
              } catch (final Exception e) {
                options.getCompletionCallback().onFailure(e);
              }
            }
          });
      final Layout parent = getParentCanvas(options);
      // final String parentPreix;
      // if(isZip) {
      //  parentPrefix = DomConstants.UPLOAD_PANEL_ZIP;
      // } else {
      //  parentPrefix = DomConstants.UPLOAD_PANEL_PLAIN;
      // }

      parent.setWidth100();
      if (debug) {
        parent.setBorder("1px solid pink");
      }
      parent.setAlign(VerticalAlignment.CENTER);
      parent.setLayoutAlign(VerticalAlignment.CENTER);
      final Layout wrapperLayout = new VLayout();
      // wrapperLayout.setHeight100();
      wrapperLayout.setWidth100();
      if (isMultiple()) {
        wrapperLayout.setHeight("140px");
      } else {
        wrapperLayout.setHeight("30px");
      }
      if (debug) {
        wrapperLayout.setBorder("1px solid blue");
      }
      wrapperLayout.setAlign(VerticalAlignment.CENTER);
      wrapperLayout.setLayoutAlign(VerticalAlignment.CENTER);
      /*
       * wrapperLayout.setGroupTitle(isMultiple() ? "File(s)" : (zip ? "Zip File" : "File"));
       * wrapperLayout.setIsGroup(true);
       * wrapperLayout.setPadding(15);
       * wrapperLayout.setLayoutAlign(Alignment.CENTER);
       * wrapperLayout.setAlign(Alignment.CENTER);
       */
      if (isMultiple()) {
        final Label addLabel =
            SmartUtils.smartParagraph(
                "<span style=\"color:blue;cursor:pointer; text-decoration: underline;\">Add Upload</span>");
        addLabel.addClickHandler(
            new ClickHandler() {
              public void onClick(final ClickEvent clickEvent) {
                addFileUploadWidget();
              }
            });
        wrapperLayout.addMember(addLabel);
      }
      wrapperLayout.addMember(formPanel);
      parent.addMember(wrapperLayout);
      // parent.setLayoutAlign(Alignment.CENTER);
      // parent.setAlign(Alignment.CENTER);
      addFileUploadWidget();
      setWidget(parent);
      parent.addDrawHandler(
          new DrawHandler() {

            public void onDraw(DrawEvent event) {
              if (zip) {
                parent.getDOM().addClassName(DomConstants.UPLOAD_PANEL_ZIP);
              } else {
                parent.getDOM().addClassName(DomConstants.UPLOAD_PANEL_PLAIN);
              }
            }
          });
    }
コード例 #10
0
    FlashUploadComponentImpl(final UploadComponentOptions options) {
      filesGrid.setHeight(100);
      filesGrid.setWidth100();
      if (options.isAllowMultiple()) {
        filesGrid.setEmptyMessage("No files selected.");
      } else {
        filesGrid.setEmptyMessage("File not selected.");
      }
      final ListGridField nameField = new ListGridField("name", "File Name");
      nameField.setType(ListGridFieldType.TEXT);
      nameField.setWidth("*");

      filesGrid.setFields(nameField);

      final UploadBuilder builder = new UploadBuilder();
      // Configure which file types may be selected
      if (options.getTypes() != null) {
        builder.setFileTypes(options.getTypes());
      }
      if (options.getTypesDescription() != null) {
        builder.setFileTypesDescription(options.getTypesDescription());
      }
      if (options.getTypesDescription() != null) {
        builder.setFileTypesDescription(options.getTypesDescription());
      }
      clientId = getUniqueId();

      final HTMLPane pane = new HTMLPane();
      pane.setHeight(22);
      builder.setButtonPlaceholderID(clientId);
      builder.setButtonHeight(22);
      builder.setButtonWidth(100);
      pane.setWidth(100);
      if (options.isAllowMultiple()) {
        builder.setButtonImageURL(GWT.getHostPageBaseURL() + "images/uploadImageAddFiles.jpg");
      } else {
        builder.setButtonImageURL(GWT.getHostPageBaseURL() + "images/uploadImageChooseFile.jpg");
      }
      // Use ButtonAction.SELECT_FILE to only allow selection of a single file

      builder.setButtonAction(
          options.isAllowMultiple() ? ButtonAction.SELECT_FILES : ButtonAction.SELECT_FILE);
      builder.setFileQueuedHandler(
          new FileQueuedHandler() {
            public void onFileQueued(final FileQueuedEvent queuedEvent) {
              if (!options.isAllowMultiple()) {
                SmartUtils.removeAllRecords(filesGrid);
              }
              final ListGridRecord record = new ListGridRecord();
              record.setAttribute("id", queuedEvent.getFile().getId());
              record.setAttribute("name", queuedEvent.getFile().getName());
              filesGrid.addData(record);
            }
          });
      builder.setUploadSuccessHandler(
          new UploadSuccessHandler() {
            public void onUploadSuccess(final UploadSuccessEvent uploadEvent) {
              try {
                filesUploaded++;
                bytesUploaded += uploadEvent.getFile().getSize();
                final String serverResponse = uploadEvent.getServerData();
                fileSources.addAll(toFileSources(serverResponse));
                updateUrl();
                if (upload.getStats().getFilesQueued() > 0) {
                  upload.startUpload();
                } else {
                  options.getCompletionCallback().onSuccess(fileSources);
                }
              } catch (final Exception e) {
                options.getCompletionCallback().onFailure(e);
              }
            }
          });
      builder.setUploadErrorHandler(
          new UploadErrorHandler() {
            public void onUploadError(final UploadErrorEvent e) {
              options
                  .getCompletionCallback()
                  .onFailure(new Exception("Upload failed " + e.getMessage()));
            }
          });

      // The button to start the transfer
      final Layout parent = getParentCanvas(options);
      setWidget(parent);

      // pane.setMargin(5);
      pane.setContents("<span id=\"" + clientId + "\" />");
      reg =
          get()
              .addDrawHandler(
                  new DrawHandler() {
                    public void onDraw(final DrawEvent event) {
                      upload = builder.build();
                      reg.removeHandler();
                    }
                  });
      final Button removeButton = SmartUtils.getButton("Remove File", Resources.CROSS);
      removeButton.addClickHandler(
          new ClickHandler() {
            public void onClick(final ClickEvent event) {
              final ListGridRecord record = filesGrid.getSelectedRecord();
              final String id = record.getAttribute("id");
              filesGrid.removeData(record);
              upload.cancelUpload(id, false);
            }
          });
      SmartUtils.enabledWhenHasSelection(removeButton, filesGrid);
      removeButton.setDisabled(true);
      if (!options.isAllowMultiple()) {
        removeButton.hide();
      }

      final CanvasWithOpsLayout<ClientListGrid> layout =
          new CanvasWithOpsLayout<ClientListGrid>(filesGrid, pane, removeButton);
      if (debug) {
        layout.setBorder("1px solid red");
        parent.setBorder("1px solid orange");
      }
      parent.addMember(layout);
    }
コード例 #11
0
 private static Layout getParentCanvas(final UploadComponentOptions options) {
   final Layout canvas = new Layout();
   canvas.setWidth100();
   canvas.setHeight100();
   return canvas;
 }
コード例 #12
0
  public FormDefinitionPanel(
      FormDefinition definition,
      FieldDefinitionListValue listValue,
      DocType docType,
      DocPanelSettingDataComplete dataComplete) {
    super();
    this.listValue = listValue;
    this.dataComplete = dataComplete;
    this.docType = docType;
    this.setWidth100();
    this.setHeight100();
    ArrayList<FormGroup> formGroups = definition.getFormGroups();
    formitemMap = new HashMap<String, FieldDefinitionItem>();
    ArrayList<MyDynamicForm> dynFields = new ArrayList<MyDynamicForm>();
    for (FormGroup formGroup : formGroups) {
      ArrayList<FieldDefinition> fields = formGroup.getFieldDefinitions();
      MyDynamicForm dynamicForm = new MyDynamicForm();
      dynamicForm.setNewLine(formGroup.getNewLine() == 1);
      ArrayList<FormItem> items = new ArrayList<FormItem>();
      for (FieldDefinition fieldDefinition : fields) {
        FieldDefinitionItem fi = createField(fieldDefinition);
        if (fi != null) {
          items.add(fi.getFormItem());
          if (fieldDefinition.isFieldReadOnly()) fi.getFormItem().setCanEdit(false);
          formitemMap.put(fieldDefinition.getFieldName(), fi);
        }
      }

      //
      dynamicForm.setAlign(Alignment.LEFT);
      switch (formGroup.getLabelOrientation()) {
        case FormGroup.FTORIENTATION_LEFT:
          dynamicForm.setTitleOrientation(TitleOrientation.LEFT);
          break;
        case FormGroup.FTORIENTATION_TOP:
          dynamicForm.setTitleOrientation(TitleOrientation.TOP);
          break;
        case FormGroup.FTORIENTATION_RIGHT:
          dynamicForm.setTitleOrientation(TitleOrientation.RIGHT);
          break;
        default:
          break;
      }

      int numofColumns = 0;
      if (definition.isHorizontal()) {
        numofColumns = formGroup.getNumofColumns() > 0 ? formGroup.getNumofColumns() : 1;
      } else {

        numofColumns = formGroup.getNumofColumns() > 0 ? formGroup.getNumofColumns() : items.size();
      }
      numofColumns =
          numofColumns * (formGroup.getLabelOrientation() == FormGroup.FTORIENTATION_TOP ? 1 : 2);
      dynamicForm.setNumCols(numofColumns);

      if (formGroup.getGroupHeight() != null && !formGroup.getGroupHeight().isEmpty()) {
        dynamicForm.setHeight(formGroup.getGroupHeight());
      }

      if (formGroup.getGroupWidth() != null && !formGroup.getGroupWidth().isEmpty()) {
        dynamicForm.setWidth(formGroup.getGroupWidth());
      }
      dynamicForm.setFields(items.toArray(new FormItem[] {}));
      dynFields.add(dynamicForm);
      if (formGroup.getGroupTitle() != null && formGroup.getGroupTitle().length() > 0) {
        dynamicForm.setIsGroup(true);
        dynamicForm.setGroupTitle(
            DocFlow.getCaption(formGroup.getFieldCaptionId(), formGroup.getGroupTitle()));
      }
      // this.addMember(dynamicForm);
      listValue.setFieldDefinitionListValue(formitemMap, this);
    }
    Layout container = this;
    if (definition.isHorizontal()) {
      container = createNewPanel();
    }

    for (MyDynamicForm dynamicForm : dynFields) {
      if (dynamicForm.isNewLine()) {
        container = createNewPanel();
      }
      container.addMember(dynamicForm);
    }

    Set<String> fieldKeys = formitemMap.keySet();

    for (String key : fieldKeys) {
      final FieldDefinitionItem item = formitemMap.get(key);
      FieldDefinition fieldDef = item.getFieldDef();
      if (fieldDef.getCalculatorClass() != null) {
        final ICalculatorClass classCalculator =
            listValue.getCalculetorClass(fieldDef.getCalculatorClass());
        if (classCalculator != null) {
          item.getFormItem()
              .addChangedHandler(
                  new ChangedHandler() {
                    @Override
                    public void onChanged(ChangedEvent event) {
                      classCalculator.calculate(formitemMap, item);
                    }
                  });
        }
      }
      if (fieldDef.isClearComboValue()) {
        PickerIcon eraserValuePicker =
            new PickerIcon(
                new Picker("eraser.png"),
                new FormItemClickHandler() {
                  public void onFormItemClick(FormItemIconClickEvent event) {
                    item.getFormItem().setValue((Object) null);
                    fireChangedEvent(item.getFormItem());
                  }
                });
        item.getFormItem().setIcons(eraserValuePicker);
      }

      if ((fieldDef.getFieldType() == FieldDefinition.FT_COMBO
          || fieldDef.getFieldType() == FieldDefinition.FT_SELECTION)) {
        if (fieldDef.getFieldSelectMethode() > 0) {
          String depFields = fieldDef.getDependencyFields();
          depFields = depFields == null ? "" : depFields;
          final String[] depFieldNames = depFields.split(";");
          final String parent_type = fieldDef.getFieldSelectMethode() + "";
          if (depFieldNames.length > 0 && depFieldNames[0].length() > 0) {
            item.getFormItem()
                .addChangedHandler(
                    new ChangedHandler() {
                      @Override
                      public void onChanged(ChangedEvent event) {
                        if (settingMyself) return;
                        try {
                          settingMyself = true;
                          comboValueChanged(depFieldNames, event.getValue(), parent_type);
                        } finally {
                          settingMyself = false;
                        }
                      }
                    });
          }
        }
      }
    }
  }
コード例 #13
0
  private Layout getButtons() {
    buttonsForm = new HLayout();

    installButton = new EnhancedIButton(MSG.view_remoteAgentInstall_installAgent());
    installButton.setExtraSpace(10);
    installButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent clickEvent) {
            absPathValidator.setPerformCheck(true);
            try {
              if (connectionForm.validate()) {
                new CheckSSHConnectionCallback() {
                  @Override
                  protected void doActualWork() {
                    installAgent();
                  }
                }.execute();
              }
            } finally {
              absPathValidator.setPerformCheck(false);
            }
          }
        });

    uninstallButton = new EnhancedIButton(MSG.view_remoteAgentInstall_uninstallAgent());
    uninstallButton.setExtraSpace(10);
    uninstallButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent clickEvent) {
            absPathValidator.setPerformCheck(true);
            try {
              if (connectionForm.validate()) {
                new CheckSSHConnectionCallback() {
                  @Override
                  protected void doActualWork() {
                    uninstallAgent();
                  }
                }.execute();
              }
            } finally {
              absPathValidator.setPerformCheck(false);
            }
          }
        });

    startButton = new EnhancedIButton(MSG.common_label_startAgent());
    startButton.setExtraSpace(10);
    startButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent clickEvent) {
            if (connectionForm.validate()) {
              new CheckSSHConnectionCallback() {
                @Override
                protected void doActualWork() {
                  startAgent();
                }
              }.execute();
            }
          }
        });

    stopButton = new EnhancedIButton(MSG.view_remoteAgentInstall_stopAgent());
    stopButton.setExtraSpace(10);
    stopButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent clickEvent) {
            if (connectionForm.validate()) {
              new CheckSSHConnectionCallback() {
                @Override
                protected void doActualWork() {
                  stopAgent();
                }
              }.execute();
            }
          }
        });

    ArrayList<Canvas> buttons = new ArrayList<Canvas>(3);
    if (this.showInstallButton) {
      buttons.add(installButton);
    }
    if (this.showUninstallButton
        && initialAgentInstall != null
        && initialAgentInstall.getAgentName() != null) {
      buttons.add(
          uninstallButton); // note we only show this if we were given the agent name because that
                            // is required to be known to uninstall
    }
    if (this.showStartButton) {
      buttons.add(startButton);
    }
    if (this.showStopButton) {
      buttons.add(stopButton);
    }

    if (buttons.size() > 0) {
      buttonsForm.setAlign(Alignment.CENTER);
      buttonsForm.setMembers(buttons.toArray(new Canvas[buttons.size()]));
    }

    return buttonsForm;
  }
コード例 #14
0
ファイル: UIFormBlock.java プロジェクト: StexX/KiWi-OSE
  /**
   * Generate the form layout.
   *
   * @return
   */
  private Layout createEditForm() {

    /** The layout panel we're generating */
    Layout resPanel = new VLayout();

    editForm = new DynamicForm();
    editForm.setWidth(400);

    FormItem[] fieldList = new FormItem[] {};

    /*
     * Generate a FormField for each field
     */
    for (String field : getFieldOrder()) {
      UIFormFieldValue formField = dataMap.get(field);
      if (formField != null) {
        FormItem formFieldItem = createFormField(field, formField);
        if (formFieldItem != null) fieldList[fieldList.length] = formFieldItem;
        else log("!!formfield " + field + " creation gave back null!");
      } else log("!!formfield definition for " + field + " was null!");
    }
    editForm.setFields(fieldList);
    resPanel.addMember(editForm);

    final Button saveButton = new Button("Save " + getFormLabel());
    saveButton.setAutoFit(true);
    saveButton.addClickHandler(
        new ClickHandler() {

          @Override
          public void onClick(ClickEvent event) {
            save(
                new AsyncCallback<Void>() {

                  @Override
                  public void onSuccess(Void result) {
                    switchToView(true);
                  }

                  @Override
                  public void onFailure(Throwable caught) {
                    SC.warn("Caught exception: " + caught.getMessage());
                  }
                });
          }
        });

    final Button cancelButton = new Button("cancel");
    cancelButton.setAutoFit(true);
    cancelButton.addClickHandler(
        new ClickHandler() {

          @Override
          public void onClick(ClickEvent event) {
            switchToView(false);
          }
        });
    HLayout buttons = new HLayout();
    buttons.addMember(saveButton);

    buttons.addMember(cancelButton);
    buttons.setHeight("5em");
    buttons.setMembersMargin(5);
    resPanel.addMember(buttons);

    return resPanel;
  }
コード例 #15
0
ファイル: UIFormBlock.java プロジェクト: StexX/KiWi-OSE
 /** clears the layout and shows the new generated edit form. */
 public void switchToEdit() {
   layout.removeMembers(layout.getMembers());
   layout.addMember(createEditForm());
 }
コード例 #16
0
  public void generateLegend() {

    // TODO cleanup/extract method(s)

    setWidth("365px"); // TODO make configurable (Legend width)
    // setWidth("27%");
    setHeight100();
    setMargin(2);
    setMinWidth(220);
    // setOverflow(Overflow.CLIP_H);

    this.topButtons = new HLayout();
    this.topButtons.setTabIndex(-1);
    this.topButtons.setHeight(1);
    this.topButtons.setAlign(Alignment.RIGHT);
    this.topButtons.setReverseOrder(true);

    ImageButton us =
        new ImageButton("us_lang", "../img/icons/gb.png", i18n.usLang(), i18n.usLangExtended());
    View.getView().registerTooltip(us);
    ImageButton de =
        new ImageButton("de_lang", "../img/icons/de.png", i18n.deLang(), i18n.deLangExtended());
    View.getView().registerTooltip(de);
    ImageButton ttips =
        new ImageButton("ttips", "../img/icons/comment.png", i18n.ttips(), i18n.ttipsExtended());
    View.getView().registerTooltip(ttips);
    ImageButton help =
        new ImageButton("help", "../img/icons/help.png", i18n.help(), i18n.helpExtended());
    View.getView().registerTooltip(help);
    ImageButton logger =
        new ImageButton("logger", "../img/icons/report.png", i18n.logger(), i18n.loggerExtended());
    View.getView().registerTooltip(logger);

    ImageButton impressum =
        new ImageButton(
            "impressum", "../img/icons/information.png", i18n.Impressum(), i18n.Impressum());

    Label imprint = new Label(i18n.Impressum());
    imprint.setTooltip(i18n.Impressum());
    imprint.setStyleName("label");
    imprint.setWidth(60);

    View.getView().registerTooltip(impressum);
    View.getView().switchDetailedTooltips();

    imprint.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            new Impressum().show();
          }
        });

    help.addClickHandler(
        new ClickHandler() {

          public void onClick(ClickEvent event) {
            String helpUrl = GWT.getHostPageBaseURL() + i18n.helpPath();
            Window.open(helpUrl, "", "");
          }
        });

    // this.topButtons.addMember(us);
    // this.topButtons.addMember(de);
    // this.topButtons.addMember(ttips);
    // this.topButtons.addMember(help);
    // this.topButtons.addMember(logger);
    // this.topButtons.addMember(imprint);

    addMember(this.topButtons);

    // Button addTS = new Button(I18N.sosClient.addNewTimeseries());
    // addTS.setIcon("../img/icons/chart_curve_add_new.png");

    // ImageButton addTS = new ImageButton("addTSLegend",
    // "../img/icons/chart_curve_add_new.png",
    // I18N.sosClient.picker(),
    // I18N.sosClient.pickerExtended());
    // View.getInstance().registerTooltip(addTS);

    // addTS.addClickHandler(new ClickHandler() {
    // public void onClick(ClickEvent evt) {
    // StationSelector.getInst().show();
    // }
    // });

    // addTS.setPadding(2);
    // addTS.setSize("32px", "32px");
    // addTS.setAlign(Alignment.CENTER);

    // Label addTSLabel = new Label(I18N.sosClient.addNewTimeseries());
    // addTSLabel.setHeight(20);
    // addTSLabel.setWidth100();
    // addTSLabel.setPadding(8);
    // addTSLabel.setStyleName("legendAddBoxLabel");
    // addTSLabel.setCursor(Cursor.HAND);
    // addTSLabel.setAlign(Alignment.CENTER);

    // HLayout add = new HLayout();
    // add.setStyleName("legendAddBox");
    // add.setAutoHeight();
    // add.addMember(addTS);
    // add.addMember(addTSLabel);
    // add.addClickHandler(new ClickHandler() {
    // public void onClick(ClickEvent event) {
    // StationSelector.getInst().show();
    // }
    // });

    // zip-export CSV
    // this.exportZipCSV =
    // new ImageButton("diagExportZipCSV", "../img/icons/folder_csv.png", i18nManager.i18nSOSClient
    // .exportZipCSV(), i18nManager.i18nSOSClient.exportZipCSVExtended());

    // View.getInstance().registerTooltip(this.exportZipCSV);

    // zip-export XLS
    // this.exportPDFallInOne =
    // new ImageButton("diagExportPDFallIneOne", "../img/icons/page_white_acrobat_add.png",
    // i18nManager.i18nSOSClient.exportPDFallInOne(),
    // i18nManager.i18nSOSClient.exportPDFallInOneExtended());
    // View.getInstance().registerTooltip(this.exportPDFallInOne);

    Button exportZipCSV = new Button(i18n.csv());
    exportZipCSV.setIcon("../img/icons/table.png");
    exportZipCSV.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            controller.exportTo(ExportType.CSV_ZIP);
          }
        });

    Button exportPDFallInOne = new Button(i18n.pdf());
    exportPDFallInOne.setStyleName("input");
    exportPDFallInOne.setIcon("../img/icons/page_white_acrobat_add.png");
    exportPDFallInOne.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            controller.exportTo(ExportType.PDF_ALL_IN_ONE);
          }
        });

    createExportLoadingSpinner();

    HStack menuStack = new HStack();
    // menuStack.setAlign(Alignment.CENTER);
    menuStack.setHeight100();
    Label space = new Label();
    Label addTS = createAddTimeSeriesLabelButton();
    exportButton = createExportLabelButton();
    sesTabButton = createSESTabLabelButton();
    space.setWidth("1%");
    exportButton.setWidth("20%");
    exportLoadingSpinner.setTop(5);
    exportLoadingSpinner.setWidth("2%");
    menuStack.addMember(addTS);
    menuStack.addMember(space);
    if (ClientUtils.isSesEnabled()) {
      addTS.setWidth("38%");
      sesTabButton.setWidth("35%");
      menuStack.addMember(sesTabButton);
      menuStack.addMember(space);
    } else {
      addTS.setWidth("75%");
    }

    menuStack.addMember(exportButton);
    menuStack.addMember(exportLoadingSpinner);
    setExportButtonActiv(false);

    VStack vMenuStack = new VStack();
    vMenuStack.addMember(menuStack);
    vMenuStack.setHeight(28);
    addMember(vMenuStack);

    // create export menu
    createExportMenu();
    addChild(exportMenu);

    VStack separator = new VStack();
    separator.setHeight("3px");
    addMember(separator);

    this.legend = new VStack();
    this.legend.setOverflow(Overflow.AUTO);
    this.legend.setHeight("*");
    this.legend.setShowResizeBar(true);
    addMember(this.legend);
    // this.intro = new HTMLFlow(I18N.sosClient.intro());
    // this.legend.addMember(this.intro);

    addMember(separator);

    Layout layout = new Layout();
    layout.addMember(createMapContent());
    layout.setWidth100();
    layout.setHeight("40%");
    addMember(layout);

    // this.footer = new HLayout();
    // this.footer.setTabIndex( -1);
    // addMember(this.footer);

  }