private SimpleComboBox<Integer> getMinutesComboBox() {
   if (minutesComboBox == null) {
     minutesComboBox = new SimpleComboBox<Integer>();
     minutesComboBox.setAllowBlank(false);
     minutesComboBox.setFieldLabel("Minutes");
     minutesComboBox.add(15);
     minutesComboBox.add(30);
     minutesComboBox.add(45);
     minutesComboBox.setSimpleValue(15);
   }
   return minutesComboBox;
 }
 private SimpleComboBox<Integer> getHoursComboBox() {
   if (hoursComboBox == null) {
     hoursComboBox = new SimpleComboBox<Integer>();
     hoursComboBox.setAllowBlank(false);
     hoursComboBox.setFieldLabel("Hours");
     hoursComboBox.add(0);
     hoursComboBox.add(1);
     hoursComboBox.add(2);
     hoursComboBox.add(4);
     hoursComboBox.add(8);
     hoursComboBox.add(12);
     hoursComboBox.add(18);
     hoursComboBox.setSimpleValue(0);
   }
   return hoursComboBox;
 }
 private SimpleComboBox<Integer> getCpusComboBox() {
   if (cpusComboBox == null) {
     cpusComboBox = new SimpleComboBox<Integer>();
     cpusComboBox.setAllowBlank(false);
     cpusComboBox.setFieldLabel("No. CPUs");
     cpusComboBox.add(1);
     cpusComboBox.add(2);
     cpusComboBox.add(4);
     cpusComboBox.add(8);
     cpusComboBox.add(16);
     cpusComboBox.add(32);
     cpusComboBox.add(64);
     cpusComboBox.add(128);
     cpusComboBox.setSimpleValue(1);
   }
   return cpusComboBox;
 }
 private SimpleComboBox<Integer> getDaysComboBox() {
   if (daysComboBox == null) {
     daysComboBox = new SimpleComboBox<Integer>();
     daysComboBox.setAllowBlank(false);
     daysComboBox.setFieldLabel("Days");
     daysComboBox.add(0);
     daysComboBox.add(1);
     daysComboBox.add(2);
     daysComboBox.add(3);
     daysComboBox.add(4);
     daysComboBox.add(7);
     daysComboBox.add(14);
     daysComboBox.add(21);
     daysComboBox.setSimpleValue(0);
   }
   return daysComboBox;
 }
  // ******************************************************
  // Method: getPanel
  //
  // ******************************************************
  private FormPanel getPanel() {
    FormLayout formLayout = new FormLayout(LabelAlign.LEFT);
    formLayout.setLabelWidth(160);

    FormPanel formPanel = new FormPanel();
    formPanel.setHeight(350);
    formPanel.setLayout(formLayout);
    formPanel.setPadding(10);
    formPanel.setFrame(false);
    formPanel.setBorders(false);
    formPanel.setBodyBorder(false);
    formPanel.setHeaderVisible(false);

    FormData formData = new FormData("95%");

    availableJndiNamesComboBox = new SimpleComboBox<String>();
    availableJndiNamesComboBox.add("FIT_DATA_TEST");
    availableJndiNamesComboBox.add("FIT_SOURCE_TEST");
    availableJndiNamesComboBox.add("FIT_CONFIG_TEST");
    availableJndiNamesComboBox.setAllowBlank(false);
    availableJndiNamesComboBox.setForceSelection(true);
    availableJndiNamesComboBox.setEditable(false);
    availableJndiNamesComboBox.setTriggerAction(TriggerAction.ALL);
    availableJndiNamesComboBox.setFieldLabel("Source JNDI*");
    availableJndiNamesComboBox.setSimpleValue("FIT_CONFIG_TEST");
    formPanel.add(availableJndiNamesComboBox, formData);

    sourceSqlQueryTextArea = new TextArea();
    sourceSqlQueryTextArea.setFieldLabel("Sql Query*");
    sourceSqlQueryTextArea.setAllowBlank(false);
    formPanel.add(sourceSqlQueryTextArea, new FormData(314, 200));

    setupRulesCheckBox = new CheckBox();
    setupRulesCheckBox.setFieldLabel("Setup Rules?");
    setupRulesCheckBox.setBoxLabel("");
    formPanel.add(setupRulesCheckBox, formData);
    return formPanel;
  }
  private SimpleComboBox<String> createConditionsCombo() {
    this.operatorCombo = new SimpleComboBox<String>();
    operatorCombo.setEditable(false);
    operatorCombo.setTypeAhead(true);
    operatorCombo.setTriggerAction(ComboBox.TriggerAction.ALL);
    operatorCombo.setWidth(50);

    for (OperatorType operator : OperatorType.values()) {
      operatorCombo.add(operator.toString());
    }
    //        conditionsCombo.setSimpleValue(OperatorType.EQUAL);
    operatorCombo.disable();
    return operatorCombo;
  }
  private SimpleComboBox<String> getVoComboBox() {
    if (voComboBox == null) {
      voComboBox = new SimpleComboBox<String>();
      voComboBox.setAllowBlank(false);
      voComboBox.setForceSelection(true);
      voComboBox.setEditable(false);
      voComboBox.setFieldLabel("Submit as");
      voComboBox.addListener(
          Events.Valid,
          new Listener<BaseEvent>() {

            public void handleEvent(BaseEvent be) {

              //					xxx

              fillVersionsComboBox();
              String fqan = voComboBox.getSimpleValue();
              if (fqan != null && !"".equals(fqan)) {
                UserEnvironment.getInstance().setUserProperty(Constants.DEFAULT_FQAN, fqan);
              }
            }
          });

      String lastFqan = UserEnvironment.getInstance().getUserProperty(Constants.DEFAULT_FQAN);
      boolean useLastFqan = false;
      String firstValue = null;
      for (String vo : UserEnvironment.getInstance().getAllFqans()) {

        // I know, I know.
        if ("/ARCS".equals(vo)) {
          continue;
        }
        if (firstValue == null) {
          firstValue = vo;
        }
        if (vo.equals(lastFqan)) {
          useLastFqan = true;
        }
        voComboBox.add(vo);
      }

      //			if (useLastFqan) {
      //				voComboBox.setSimpleValue(lastFqan);
      //			} else {
      //				voComboBox.setSimpleValue(firstValue);
      //			}
    }
    return voComboBox;
  }
  protected void onRender(Element target, int index) {
    super.onRender(target, index);

    final FitLayout fl = new FitLayout();

    LayoutContainer layoutContainer = new LayoutContainer();
    layoutContainer.setBorders(false);
    layoutContainer.setLayout(fl);

    VerticalPanel vp = new VerticalPanel();
    vp.setSpacing(3);

    ContentPanel cpGrid = new ContentPanel();
    cpGrid.setHeaderVisible(true);
    cpGrid.setHeading("Lista Dipendenti.");
    cpGrid.setBorders(false);
    cpGrid.setFrame(true);
    cpGrid.setHeight((h - 65));
    cpGrid.setWidth(w - 250);
    cpGrid.setScrollMode(Scroll.AUTO);
    cpGrid.setLayout(new FitLayout());
    cpGrid.setButtonAlign(HorizontalAlignment.CENTER);
    Resizable r = new Resizable(cpGrid);

    btnPrint = new Button();
    btnPrint.setEnabled(true);
    btnPrint.setIcon(AbstractImagePrototype.create(MyImages.INSTANCE.print24()));
    btnPrint.setIconAlign(IconAlign.TOP);
    btnPrint.setToolTip("Stampa");
    btnPrint.setSize(26, 26);
    btnPrint.addSelectionListener(
        new SelectionListener<ButtonEvent>() {

          @Override
          public void componentSelected(ButtonEvent ce) {
            SessionManagementService.Util.getInstance()
                .setDatiReportCostiDip(
                    "RIEP.COSTI",
                    store.getModels(),
                    new AsyncCallback<Boolean>() {

                      @Override
                      public void onFailure(Throwable caught) {
                        Window.alert("Error on setNomeReport()");
                      }

                      @Override
                      public void onSuccess(Boolean result) {
                        if (result) fp.submit();
                        else
                          Window.alert(
                              "Problemi durante il settaggio dei parametri in Sessione (http)");
                      }
                    });
          }
        });

    btnAdd = new Button();
    btnAdd.setStyleAttribute("padding-left", "2px");
    btnAdd.setIcon(AbstractImagePrototype.create(MyImages.INSTANCE.add()));
    btnAdd.setIconAlign(IconAlign.TOP);
    btnAdd.setSize(26, 26);
    btnAdd.setToolTip("Nuova Offerta");
    btnAdd.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            RiepilogoCostiDipendentiModel am =
                new RiepilogoCostiDipendentiModel(
                    0, 0, "", "0.00", "", "0", "0.00", "0.00", "0.00", "0.00", "0.00", "0.00", "",
                    "", "");

            gridRiepilogo.stopEditing();
            store.insert(am, 0);
            gridRiepilogo.startEditing(store.indexOf(am), 0);
          }
        });

    btnConfirm = new Button();
    btnConfirm.setEnabled(true);
    btnConfirm.setIcon(AbstractImagePrototype.create(MyImages.INSTANCE.confirm()));
    btnConfirm.setIconAlign(IconAlign.TOP);
    btnConfirm.setToolTip("Conferma modifiche");
    btnConfirm.setSize(26, 26);
    btnConfirm.addSelectionListener(
        new SelectionListener<ButtonEvent>() {

          @Override
          public void componentSelected(ButtonEvent ce) {

            RiepilogoCostiDipendentiModel c = new RiepilogoCostiDipendentiModel();

            for (Record record : store.getModifiedRecords()) {

              c = (RiepilogoCostiDipendentiModel) record.getModel();

              AdministrationService.Util.getInstance()
                  .editDatiCostiAzienda(
                      c,
                      new AsyncCallback<Boolean>() {

                        @Override
                        public void onFailure(Throwable caught) {
                          Window.alert("Errore di connessione on insertNewOffertaWithRda();");
                        }

                        @Override
                        public void onSuccess(Boolean result) {
                          if (result) {
                            caricaTabellaDati();
                          } else {
                            Window.alert(
                                "error: Impossibile effettuare l'inserimento/modifica dei dati!");
                          }
                        }
                      });
            }
          }
        });

    if ((ruolo.compareTo("PM") == 0)) {
      btnConfirm.disable();
      btnAdd.disable();
    }

    smplcmbxSede = new SimpleComboBox<String>();
    smplcmbxSede.setFieldLabel("Sede");
    smplcmbxSede.setWidth(65);
    smplcmbxSede.setEmptyText("Sede..");
    smplcmbxSede.setAllowBlank(false);
    smplcmbxSede.add("T");
    smplcmbxSede.add("B");
    smplcmbxSede.setStyleAttribute("padding-left", "2px");
    smplcmbxSede.addListener(
        Events.Select,
        new Listener<BaseEvent>() {
          @Override
          public void handleEvent(BaseEvent be) {
            caricaTabellaDati();
          }
        });

    // caricaTabellaDati();

    cm = new ColumnModel(createColumns());
    gridRiepilogo = new EditorGrid<RiepilogoCostiDipendentiModel>(store, cm);
    gridRiepilogo.setBorders(false);
    gridRiepilogo.setColumnLines(true);
    gridRiepilogo.setStripeRows(true);
    gridRiepilogo.setItemId("grid");
    gridRiepilogo.setSelectionModel(csm);

    fp.setMethod(FormPanel.METHOD_POST);
    fp.setAction(url);
    fp.addSubmitCompleteHandler(new FormSubmitCompleteHandler());
    fp.add(btnPrint);
    ContentPanel cp = new ContentPanel();
    cp.setHeaderVisible(false);
    cp.add(fp);

    ToolBar tlBar = new ToolBar();
    tlBar.add(smplcmbxSede);
    tlBar.add(btnAdd);
    tlBar.add(btnConfirm);
    tlBar.add(new SeparatorToolItem());
    tlBar.add(cp);

    cpGrid.setTopComponent(tlBar);
    cpGrid.add(gridRiepilogo);

    layoutContainer.add(cpGrid, new FitData(3, 3, 3, 3));

    add(layoutContainer);
  }
Example #9
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);
  }
  public RightPropertiesPanel() {

    setHeading(Constants.MENU_PROPS);
    setLayout(new FitLayout());

    ToolBar toolBarSelection = new ToolBar();
    LabelToolItem labelComponents = new LabelToolItem("Component:   ");
    toolBarSelection.add(labelComponents);
    labelComponents.setVisible(true);
    setTopComponent(toolBarSelection);

    listComponents = new SimpleComboBox<String>();
    updateFileList("Folders", listComponents);
    listComponents.add(Constants.COMPONENT_SPMANAGERWEB_NAME);
    listComponents.add("Test");
    listComponents.setForceSelection(true);
    listComponents.setEditable(false);
    listComponents.setTriggerAction(ComboBox.TriggerAction.ALL);
    listComponents.setEmptyText("- Choose a component -");
    listComponents.setFieldLabel("Component");
    listComponents.setWidth(200);
    toolBarSelection.add(listComponents);

    listComponents.addSelectionChangedListener(
        new SelectionChangedListener() {

          @Override
          public void selectionChanged(SelectionChangedEvent se) {
            selectedComponent = listComponents.getSimpleValue();
            output.setEmptyText(
                "Select a component and configuration file to display and press \"Load\"");
            updateFileList(selectedComponent, listFiles);
          }
        });

    LabelToolItem labelFiles = new LabelToolItem("    File:   ");
    toolBarSelection.add(labelFiles);
    labelFiles.setVisible(true);

    listFiles = new SimpleComboBox<String>();
    listFiles.setForceSelection(true);
    listFiles.setEditable(false);
    listFiles.setTriggerAction(ComboBox.TriggerAction.ALL);
    listFiles.setEmptyText("-Choose a file-");
    listFiles.setFieldLabel("File");
    listFiles.setAutoWidth(false);
    listFiles.setWidth(250);
    toolBarSelection.add(listFiles);

    listFiles.addSelectionChangedListener(
        new SelectionChangedListener() {

          @Override
          public void selectionChanged(SelectionChangedEvent se) {
            output.setEmptyText(
                "Select a component and configuration file to display and press \"Load\"");
            output.clear();
          }
        });

    Button loadButton = new Button("Load");
    toolBarSelection.add(loadButton);

    loadButton.addSelectionListener(
        new SelectionListener<ButtonEvent>() {

          @Override
          public void componentSelected(ButtonEvent ce) {
            updateFileContent();
          }
        });

    currentOutput = "Select a component and configuration file to display and press \"Load\"";
    output = new TextArea();
    output.addStyleName("demo-TextArea");
    output.setWidth("800px");
    output.setHeight("400px");
    output.setReadOnly(true);
    output.setEmptyText("Select a component and configuration file to display and press \"Load\"");
    output.setVisible(true);
    add(output);
  }
  protected void onRender(Element parent, int index) {
    super.onRender(parent, index);
    setLayout(new FitLayout());
    setId("network-dhcp-nat");
    FormData formData = new FormData();
    formData.setWidth(250);

    m_formPanel = new FormPanel();
    m_formPanel.setFrame(false);
    m_formPanel.setBodyBorder(false);
    m_formPanel.setHeaderVisible(false);
    m_formPanel.setLayout(new FlowLayout());
    m_formPanel.setStyleAttribute("min-width", "775px");
    m_formPanel.setStyleAttribute("padding-left", "30px");

    FieldSet fieldSet = new FieldSet();
    FormLayout layoutAccount = new FormLayout();
    layoutAccount.setLabelWidth(Constants.LABEL_WIDTH_FORM);
    fieldSet.setLayout(layoutAccount);
    fieldSet.setBorders(false);

    //
    // Tool Tip Box
    //
    toolTipField.setText(defaultToolTip);
    fieldSet.add(toolTipField);

    //
    // Router Mode
    //
    m_modeCombo = new SimpleComboBox<String>();
    m_modeCombo.setName("comboMode");
    m_modeCombo.setFieldLabel(MSGS.netRouterMode());
    m_modeCombo.setEditable(false);
    m_modeCombo.setTypeAhead(true);
    m_modeCombo.setTriggerAction(TriggerAction.ALL);
    for (GwtNetRouterMode mode : GwtNetRouterMode.values()) {
      m_modeCombo.add(MessageUtils.get(mode.name()));
    }
    m_modeCombo.setSimpleValue(MessageUtils.get(GwtNetRouterMode.netRouterDchpNat.name()));
    m_modeCombo.setValidator(
        new Validator() {
          public String validate(Field<?> field, String value) {
            if (m_tcpIpConfigTab.isDhcp()
                && !value.equals(MessageUtils.get(GwtNetRouterMode.netRouterOff.toString()))) {
              return MSGS.netRouterConfiguredForDhcpError();
            }

            return null;
          }
        });
    m_modeCombo.addSelectionChangedListener(
        new SelectionChangedListener<SimpleComboValue<String>>() {
          @Override
          public void selectionChanged(SelectionChangedEvent<SimpleComboValue<String>> se) {
            refreshForm();
          }
        });
    m_modeCombo.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netRouterToolTipMode()));
    m_modeCombo.addStyleName("kura-combobox");
    m_modeCombo.addPlugin(m_dirtyPlugin);
    fieldSet.add(m_modeCombo, formData);

    //
    // DHCP Beginning Address
    //
    m_dhcpBeginAddressField = new TextField<String>();
    m_dhcpBeginAddressField.setAllowBlank(true);
    m_dhcpBeginAddressField.setName("dhcpBeginAddress");
    m_dhcpBeginAddressField.setFieldLabel(MSGS.netRouterDhcpBeginningAddress());
    m_dhcpBeginAddressField.setRegex(IPV4_REGEX);
    m_dhcpBeginAddressField.getMessages().setRegexText(MSGS.netIPv4InvalidAddress());
    m_dhcpBeginAddressField.addPlugin(m_dirtyPlugin);
    m_dhcpBeginAddressField.setStyleAttribute("margin-top", Constants.LABEL_MARGIN_TOP_SEPARATOR);
    m_dhcpBeginAddressField.addStyleName("kura-textfield");
    m_dhcpBeginAddressField.addListener(
        Events.OnMouseOver, new MouseOverListener(MSGS.netRouterToolTipDhcpBeginAddr()));
    fieldSet.add(m_dhcpBeginAddressField, formData);

    //
    // DHCP Ending Address
    //
    m_dhcpEndAddressField = new TextField<String>();
    m_dhcpEndAddressField.setAllowBlank(true);
    m_dhcpEndAddressField.setName("dhcpEndAddress");
    m_dhcpEndAddressField.setFieldLabel(MSGS.netRouterDhcpEndingAddress());
    m_dhcpEndAddressField.setRegex(IPV4_REGEX);
    m_dhcpEndAddressField.getMessages().setRegexText(MSGS.netIPv4InvalidAddress());
    m_dhcpEndAddressField.addListener(
        Events.OnMouseOver, new MouseOverListener(MSGS.netRouterToolTipDhcpEndAddr()));
    m_dhcpEndAddressField.addStyleName("kura-textfield");
    ;
    m_dhcpEndAddressField.addPlugin(m_dirtyPlugin);
    fieldSet.add(m_dhcpEndAddressField, formData);

    //
    // DHCP Subnet Mask
    //
    m_dhcpSubnetMaskField = new TextField<String>();
    m_dhcpSubnetMaskField.setAllowBlank(true);
    m_dhcpSubnetMaskField.setName("dhcpSubnetMask");
    m_dhcpSubnetMaskField.setFieldLabel(MSGS.netRouterDhcpSubnetMask());
    m_dhcpSubnetMaskField.setRegex(IPV4_REGEX);
    m_dhcpSubnetMaskField.addListener(
        Events.OnMouseOver, new MouseOverListener(MSGS.netRouterToolTipDhcpSubnet()));
    m_dhcpSubnetMaskField.getMessages().setRegexText(MSGS.netIPv4InvalidAddress());
    m_dhcpSubnetMaskField.addStyleName("kura-textfield");
    m_dhcpSubnetMaskField.addPlugin(m_dirtyPlugin);
    fieldSet.add(m_dhcpSubnetMaskField, formData);

    //
    // DHCP Default Lease
    //
    m_dhcpLeaseDefaultField = new NumberField();
    m_dhcpLeaseDefaultField.setPropertyEditorType(Integer.class);
    m_dhcpLeaseDefaultField.setAllowDecimals(false);
    m_dhcpLeaseDefaultField.setAllowNegative(false);
    m_dhcpLeaseDefaultField.setMaxValue(Integer.MAX_VALUE);
    m_dhcpLeaseDefaultField.setAllowBlank(true);
    m_dhcpLeaseDefaultField.setName("dhcpDefaultLease");
    m_dhcpLeaseDefaultField.setFieldLabel(MSGS.netRouterDhcpDefaultLease());
    m_dhcpLeaseDefaultField.addListener(
        Events.OnMouseOver, new MouseOverListener(MSGS.netRouterToolTipDhcpDefaultLeaseTime()));
    m_dhcpLeaseDefaultField.addPlugin(m_dirtyPlugin);
    fieldSet.add(m_dhcpLeaseDefaultField, formData);

    //
    // DHCP Max Lease
    //
    m_dhcpLeaseMaxField = new NumberField();
    m_dhcpLeaseMaxField.setPropertyEditorType(Integer.class);
    m_dhcpLeaseMaxField.setAllowDecimals(false);
    m_dhcpLeaseMaxField.setAllowNegative(false);
    m_dhcpLeaseMaxField.setMaxValue(Integer.MAX_VALUE);
    m_dhcpLeaseMaxField.setAllowBlank(true);
    m_dhcpLeaseMaxField.setName("dhcpMaxLease");
    m_dhcpLeaseMaxField.setFieldLabel(MSGS.netRouterDhcpMaxLease());
    m_dhcpLeaseMaxField.addListener(
        Events.OnMouseOver, new MouseOverListener(MSGS.netRouterToolTipDhcpMaxLeaseTime()));
    m_dhcpLeaseMaxField.addPlugin(m_dirtyPlugin);
    fieldSet.add(m_dhcpLeaseMaxField, formData);

    //
    // Pass DNS
    //
    m_passDnsRadioTrue = new Radio();
    m_passDnsRadioTrue.setBoxLabel(MSGS.trueLabel());
    m_passDnsRadioTrue.setItemId("true");

    m_passDnsRadioFalse = new Radio();
    m_passDnsRadioFalse.setBoxLabel(MSGS.falseLabel());
    m_passDnsRadioFalse.setItemId("false");

    m_passDnsRadioGroup = new RadioGroup();
    m_passDnsRadioGroup.setName("dhcpPassDns");
    m_passDnsRadioGroup.setFieldLabel(MSGS.netRouterPassDns());
    m_passDnsRadioGroup.add(m_passDnsRadioTrue);
    m_passDnsRadioGroup.add(m_passDnsRadioFalse);
    m_passDnsRadioGroup.addPlugin(m_dirtyPlugin);
    m_passDnsRadioGroup.addListener(
        Events.OnMouseOver, new MouseOverListener(MSGS.netRouterToolTipPassDns()));
    fieldSet.add(m_passDnsRadioGroup, formData);

    m_formPanel.add(fieldSet);
    add(m_formPanel);
    setScrollMode(Scroll.AUTO);
    m_initialized = true;
  }
  public TaskGrid() {
    setLayout(new FlowLayout(10));
    getAriaSupport().setPresentation(true);

    final NumberFormat currency = NumberFormat.getCurrencyFormat();
    final NumberFormat number = NumberFormat.getFormat("0.00");
    // final NumberCellRenderer<Grid<Stock>> numberRenderer = new NumberCellRenderer<Grid<Stock>>(
    //		currency);

    /*
    GridCellRenderer<Stock> change = new GridCellRenderer<Stock>() {
    	public String render(Stock model, String property,
    			ColumnData config, int rowIndex, int colIndex,
    			ListStore<Stock> store, Grid<Stock> grid) {
    		Object o = model.get(property);

    		String v = "(not set)";
    		if(o == null) {
    			double val = (Double)o;
    			String style = val < 0 ? "red"
    					: GXT.isHighContrastMode ? "#00ff5a" : "green";
    			v = number.format(val);

    		}

    		return "<span qtitle='"
    				+ cm.getColumnById(property).getHeader() + "' qtip='"
    				+ v + "' style='font-weight: bold;color:" + style
    				+ "'>" + v + "</span>";
    	}
    };*/

    /*
    GridCellRenderer<Stock> gridNumber = new GridCellRenderer<Stock>() {
    	public String render(Stock model, String property,
    			ColumnData config, int rowIndex, int colIndex,
    			ListStore<Stock> store, Grid<Stock> grid) {
    		return numberRenderer.render(null, property,
    				model.get(property));
    	}
    };*/

    List<ColumnConfig> configs = new ArrayList<ColumnConfig>();

    ColumnConfig column = new ColumnConfig();
    column.setId("name");
    column.setHeader("Linkset name");
    column.setWidth(200);
    column.setRowHeader(true);
    configs.add(column);

    column = new ColumnConfig();
    column.setId("direction");
    column.setHeader("Direction");
    column.setAlignment(HorizontalAlignment.RIGHT);
    column.setWidth(100);
    configs.add(column);

    column = new ColumnConfig();
    column.setId("sampled");
    column.setHeader("Sampled");
    column.setAlignment(HorizontalAlignment.RIGHT);
    column.setWidth(100);
    configs.add(column);

    column = new ColumnConfig();
    column.setId("sampleSize");
    column.setHeader("Sample size");
    column.setAlignment(HorizontalAlignment.RIGHT);
    column.setWidth(75);
    // column.setRenderer(gridNumber);
    configs.add(column);

    /*
    column = new ColumnConfig("change", "Change", 100);
    column.setAlignment(HorizontalAlignment.RIGHT);
    //column.setRenderer(change);
    configs.add(column);
    */

    column = new ColumnConfig("date", "Finished", 100);
    column.setAlignment(HorizontalAlignment.RIGHT);
    column.setDateTimeFormat(DateTimeFormat.getFormat("MM/dd/yyyy"));
    configs.add(column);

    // ListStore<TaskDescription> store = new ListStore<TaskDescription>();
    // store.add(getStocks());

    // store.add(TaskData.getStocks());

    // store.add(getStocks());

    cm = new ColumnModel(configs);

    ContentPanel cp = new ContentPanel();
    cp.setBodyBorder(true);
    // cp.setIcon(Resources.ICONS.table());
    cp.setHeading("Available Linksets");
    cp.setButtonAlign(HorizontalAlignment.CENTER);
    cp.setLayout(new FitLayout());
    cp.getHeader().setIconAltText("Grid Icon");
    cp.setSize(600, 300);

    // final Grid<TaskDescription>
    grid = new Grid<TaskDescription>(getStocks(), cm);
    grid.setStyleAttribute("borderTop", "none");
    grid.setAutoExpandColumn("name");
    grid.setBorders(false);
    grid.setStripeRows(true);
    grid.setColumnLines(true);
    grid.setColumnReordering(true);
    grid.getAriaSupport().setLabelledBy(cp.getHeader().getId() + "-label");
    cp.add(grid);

    ToolBar toolBar = new ToolBar();
    toolBar.getAriaSupport().setLabel("Grid Options");

    toolBar.add(new LabelToolItem("Selection Mode: "));
    final SimpleComboBox<String> type = new SimpleComboBox<String>();
    type.getAriaSupport().setLabelledBy(toolBar.getItem(0).getId());
    type.setTriggerAction(TriggerAction.ALL);
    type.setEditable(false);
    type.setFireChangeEventOnSetValue(true);
    type.setWidth(100);
    type.add("Row");
    type.add("Cell");
    type.setSimpleValue("Row");
    type.addListener(
        Events.Change,
        new Listener<FieldEvent>() {
          public void handleEvent(FieldEvent be) {
            boolean cell = type.getSimpleValue().equals("Cell");
            grid.getSelectionModel().deselectAll();
            if (cell) {
              grid.setSelectionModel(new CellSelectionModel<TaskDescription>());
            } else {
              grid.setSelectionModel(new GridSelectionModel<TaskDescription>());
            }
          }
        });
    toolBar.add(type);

    cp.setTopComponent(toolBar);

    add(cp);

    // needed to enable quicktips (qtitle for the heading and qtip for the
    // content) that are setup in the change GridCellRenderer
    new QuickTip(grid);
  }
Example #13
0
  private void createNewUSerDialog() {
    setButtons("");
    setLayout(new FitLayout());
    setHeading(HarvesterUI.CONSTANTS.addUser());
    setIcon(HarvesterUI.ICONS.add16());
    setResizable(false);
    setModal(true);
    setSize(600, 200);
    setBodyBorder(false);
    FormData formData = new FormData("95%");

    newUserFormPanel = new DefaultFormPanel();
    newUserFormPanel.setHeaderVisible(false);

    newUserFormPanel.setLayout(new EditableFormLayout(175));

    userNameField = new TextField<String>();
    userNameField.setFieldLabel(HarvesterUI.CONSTANTS.username() + HarvesterUI.REQUIRED_STR);
    userNameField.setId("userNameField");
    userNameField.setMinLength(4);
    userNameField.setAllowBlank(false);
    newUserFormPanel.add(userNameField, formData);

    Validator usernameValidator =
        new Validator() {
          public String validate(Field<?> field, String s) {
            if (!s.matches("^[A-Za-z0-9]+(?:[ _-][A-Za-z0-9]+)*$"))
              return HarvesterUI.CONSTANTS.usernameValidateMessage();
            return null;
          }
        };
    userNameField.setValidator(usernameValidator);

    emailField = new TextField<String>();
    emailField.setFieldLabel(HarvesterUI.CONSTANTS.email() + HarvesterUI.REQUIRED_STR);
    emailField.setId("emailField");
    emailField.setAllowBlank(false);
    newUserFormPanel.add(emailField, formData);

    Validator emailValidator =
        new Validator() {
          public String validate(Field<?> field, String s) {
            if (!s.matches("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}"))
              return HarvesterUI.CONSTANTS.emailValidateMessage();
            return null;
          }
        };
    emailField.setValidator(emailValidator);

    roleCombo = new SimpleComboBox<String>();
    roleCombo.setEditable(false);
    roleCombo.setFieldLabel(HarvesterUI.CONSTANTS.role() + HarvesterUI.REQUIRED_STR);
    roleCombo.setTriggerAction(ComboBox.TriggerAction.ALL);
    for (UserRole userRole : UserRole.values()) {
      if (userRole != UserRole.ANONYMOUS) roleCombo.add(userRole.name());
    }
    roleCombo.setValue(roleCombo.getStore().getAt(0));
    newUserFormPanel.add(roleCombo, formData);

    saveButton =
        new Button(
            HarvesterUI.CONSTANTS.save(),
            HarvesterUI.ICONS.save_icon(),
            new SelectionListener<ButtonEvent>() {
              @Override
              public void componentSelected(ButtonEvent be) {
                AsyncCallback<User> callback =
                    new AsyncCallback<User>() {
                      public void onFailure(Throwable caught) {
                        new ServerExceptionDialog(
                                "Failed to get response from server", caught.getMessage())
                            .show();
                      }

                      public void onSuccess(User user) {
                        AsyncCallback<ResponseState> callback =
                            new AsyncCallback<ResponseState>() {
                              public void onFailure(Throwable caught) {
                                new ServerExceptionDialog(
                                        "Failed to get response from server", caught.getMessage())
                                    .show();
                              }

                              public void onSuccess(ResponseState result) {
                                unmask();
                                if (result == ResponseState.USER_ALREADY_EXISTS) {
                                  HarvesterUI.UTIL_MANAGER.getErrorBox(
                                      HarvesterUI.CONSTANTS.newUser(),
                                      HarvesterUI.CONSTANTS.usernameAlreadyExists());
                                  return;
                                }
                                hide();
                                userManagementGrid.getStore().add(newUser);
                                HarvesterUI.UTIL_MANAGER.getSaveBox(
                                    HarvesterUI.CONSTANTS.newUser(),
                                    HarvesterUI.CONSTANTS.saveNewUserSuccess());
                                Dispatcher.get().dispatch(AppEvents.ViewUserManagementForm);
                              }
                            };
                        mask(HarvesterUI.CONSTANTS.saveUserMask());
                        newUserFormPanel.submit();
                        String role = roleCombo.getValue().getValue().trim();
                        String userName = userNameField.getValue().trim();
                        String email = emailField.getValue().trim();
                        String password = "******";
                        newUser = new User(userName, password, role, email, 15);
                        service.saveNewUser(newUser, callback);
                      }
                    };
                String userName = userNameField.getValue();
                service.getUser(userName, callback);
              }
            });
    newUserFormPanel.addButton(saveButton);
    newUserFormPanel.addButton(
        new Button(
            HarvesterUI.CONSTANTS.cancel(),
            HarvesterUI.ICONS.cancel_icon(),
            new SelectionListener<ButtonEvent>() {
              @Override
              public void componentSelected(ButtonEvent be) {
                hide();
                Dispatcher.get().dispatch(AppEvents.ViewUserManagementForm);
              }
            }));

    newUserFormPanel.setButtonAlign(Style.HorizontalAlignment.CENTER);

    FormButtonBinding binding = new FormButtonBinding(newUserFormPanel);
    binding.addButton(saveButton);

    add(newUserFormPanel);
  }