private void adjustListBox(boolean value) {
   applications.setEnabled(value);
   regions.setEnabled(value);
   if (!value) {
     for (int index = 0; index < applications.getItemCount(); index++) {
       applications.setItemSelected(index, false);
     }
     for (int index = 0; index < regions.getItemCount(); index++) {
       regions.setItemSelected(index, false);
     }
   }
 }
示例#2
0
文件: Term.java 项目: scbd/vocbench
    public void initLayout() {
      lang = new ListBox();
      lang =
          Convert.makeSelectedLanguageListBox(
              (ArrayList<String[]>) MainApp.getLanguage(), tObj.getLang());
      lang.setWidth("100%");
      lang.setEnabled(false);

      term = new TextBox();
      term.setText(tObj.getLabel());
      term.setWidth("100%");

      main = new CheckBox(constants.conceptPreferredTerm());
      if (tObj.isMainLabel()) {
        main.setValue(tObj.isMainLabel());
        // main.setEnabled(false);
      }

      Grid table = new Grid(2, 2);
      table.setWidget(0, 0, new HTML(constants.conceptTerm()));
      table.setWidget(1, 0, new HTML(constants.conceptLanguage()));
      table.setWidget(0, 1, term);
      table.setWidget(1, 1, lang);
      table.setWidth("100%");
      table.getColumnFormatter().setWidth(1, "80%");

      VerticalPanel vp = new VerticalPanel();
      vp.add(GridStyle.setTableConceptDetailStyleleft(table, "gslRow1", "gslCol1", "gslPanel1"));
      vp.add(main);
      vp.setSpacing(0);
      vp.setWidth("100%");
      vp.setCellHorizontalAlignment(main, HasHorizontalAlignment.ALIGN_RIGHT);

      addWidget(vp);
    }
  public void setEnabled(boolean enabled) {
    this.enabled = enabled;

    lbPoolSize.setEnabled(enabled);
    rbPreferLarger.setEnabled(enabled);
    rbPreferSmaller.setEnabled(enabled);
  }
  public WorkItemFloatParameterWidget(
      PortableFloatParameterDefinition ppd, IBindingProvider bindingProvider, boolean isReadOnly) {
    super(ppd, bindingProvider);
    this.parameterName.setText(ppd.getName());
    this.parameterEditor.setEnabled(!isReadOnly);

    // Setup widget to select a literal value
    if (ppd.getValue() != null) {
      this.parameterEditor.setText(Float.toString(ppd.getValue()));
    }

    // Setup widget to use bindings
    Set<String> bindings = bindingProvider.getBindings(ppd.getClassName());
    if (bindings.size() > 0) {
      lstAvailableBindings.clear();
      lstAvailableBindings.addItem(CommonConstants.INSTANCE.Choose());
      lstAvailableBindings.setEnabled(true && !isReadOnly);
      lstAvailableBindings.setVisible(true);
      int selectedIndex = 0;
      for (String binding : bindings) {
        lstAvailableBindings.addItem(binding);
        if (binding.equals(ppd.getBinding())) {
          selectedIndex = lstAvailableBindings.getItemCount() - 1;
        }
      }
      lstAvailableBindings.setSelectedIndex(selectedIndex);
      parameterEditor.setEnabled(selectedIndex == 0 && !isReadOnly);
    }
  }
示例#5
0
  private Widget addWidget(AddRecord recordTable) {
    Widget widget = new Widget();
    if (recordTable.getFieldType().equals(SQL_TYPE_STRING)) {
      widget = new TextBox();
      if (recordTable.getFieldType() != null) {
        ((TextBox) widget).setValue(recordTable.getFieldValue());
        ((TextBox) widget).setEnabled(recordTable.isEditable());
      }
    } else if (recordTable.getFieldType().equals(SQL_TYPE_DATE)) {
      widget = new DateBox();
      ((DateBox) widget).setEnabled(recordTable.isEditable());
    } else if (recordTable.getFieldType().equals(SQL_TYPE_LIST_STRING)) {
      final ListBox listBox = new ListBox();
      listBox.setEnabled(recordTable.isEditable());
      for (RefRecord rec : recordTable.getListRefRecord()) {
        listBox.addItem(rec.getValue(), String.valueOf(rec.getKey()));
      }

      widget = listBox;
    } else {
      widget = new TextBox();
      if (recordTable.getFieldValue() != null) {
        ((TextBox) widget).setValue(recordTable.getFieldValue());
        ((TextBox) widget).setEnabled(recordTable.isEditable());
      }
    }
    return widget;
  }
 protected void disableCells() {
   workingSetMode.setEnabled(false);
   workingSetName.setEnabled(false);
   description.setEnabled(false);
   filterPanel.setEnabled(false);
   notes.setEnabled(false);
   people.disable();
 }
  // Actual drop-down
  private Widget getDropDown() {

    String selected = "";
    String selectedText = "";

    box = new ListBox();
    box.setEnabled(!isReadOnly);
    box.addItem(HumanReadableConstants.INSTANCE.noCEPWindow(), "");

    for (int i = 0; i < operators.size(); i++) {
      String op = operators.get(i);
      box.addItem(HumanReadable.getOperatorDisplayName(op), op);
      if (op.equals(hcw.getWindow().getOperator())) {
        selected = op;
        selectedText = HumanReadable.getOperatorDisplayName(op);
        box.setSelectedIndex(i + 1);
      }
    }
    selectItem(hcw.getWindow().getOperator());

    // Fire event to ensure parent Widgets correct their state depending on selection
    final HasValueChangeHandlers<OperatorSelection> source = this;
    final OperatorSelection selection = new OperatorSelection(selected, selectedText);
    Scheduler.get()
        .scheduleFinally(
            new Command() {

              public void execute() {
                operatorChanged(selection);
                ValueChangeEvent.fire(source, selection);
              }
            });

    // Signal parent Widget whenever a change happens
    box.addChangeHandler(
        new ChangeHandler() {

          public void onChange(ChangeEvent event) {
            String selected = box.getValue(box.getSelectedIndex());
            String selectedText = box.getItemText(box.getSelectedIndex());
            OperatorSelection selection = new OperatorSelection(selected, selectedText);
            operatorChanged(selection);
            ValueChangeEvent.fire(source, selection);
          }
        });

    return box;
  }
  @Override
  public void formEnable(boolean enabled) {
    navigationEnabled(enabled);
    saveChangesEnabled(enabled);

    variableDetailTabs.setVisible(enabled);

    variableName.setEnabled(enabled);
    removeButton.setEnabled(enabled);
    addButton.setEnabled(true); // Regardless of form state the add button is enabled.
    valueType.setEnabled(enabled);
    repeatableCheckbox.setEnabled(enabled);
    occurrenceGroup.setEnabled(enabled);
    unit.setEnabled(enabled);
    mimeType.setEnabled(enabled);
  }
示例#9
0
  /** Fetch categories */
  private void fetchCategories() {
    btnApply.setEnabled(false);
    lstParent.clear();
    lstParent.setEnabled(false);
    lstParent.addItem("Fetching items ... ");
    ICategory.Util.getInstance()
        .getAllCategories(
            new AsyncCallback<List<XCategory>>() {

              @Override
              public void onSuccess(List<XCategory> result) {
                if (result == null) {
                  onFailure(new IllegalArgumentException("Null returned"));
                }
                lstParent.clear();

                for (XCategory cat : result) lstParent.addItem(cat.name);

                selectCategory();

                lstParent.setEnabled(true);
                btnApply.setEnabled(true);
              }

              /** Select category if */
              private void selectCategory() {
                if (original == null) return;

                int max = lstParent.getItemCount();
                for (int i = 0; i < max; i++)
                  if (lstParent.getItemText(i).equals(original.name)) {
                    lstParent.setSelectedIndex(i);
                    return;
                  }
                lstParent.addItem(original.name);
                lstParent.setSelectedIndex(max);
              }

              @Override
              public void onFailure(Throwable caught) {
                lstParent.clear();
                lstParent.setEnabled(false);
                lstParent.addItem("Error fetching categories");
                btnApply.setEnabled(false);
              }
            });
  }
  private ListBox loadBoundFacts(String binding) {
    ListBox listBox = new ListBox();
    listBox.addItem(GuidedDecisionTableConstants.INSTANCE.Choose());
    List<String> factBindings = rm.getLHSBoundFacts();

    for (int index = 0; index < factBindings.size(); index++) {
      String boundName = factBindings.get(index);
      if (!"".equals(boundName)) {
        listBox.addItem(boundName);
        if (boundName.equals(binding)) {
          listBox.setSelectedIndex(index + 1);
        }
      }
    }

    listBox.setEnabled(listBox.getItemCount() > 1);
    if (listBox.getItemCount() == 1) {
      listBox.clear();
      listBox.addItem(GuidedDecisionTableConstants.INSTANCE.NoPatternBindingsAvailable());
    }
    return listBox;
  }
  public WorkItemObjectParameterWidget(
      PortableObjectParameterDefinition ppd, IBindingProvider bindingProvider, boolean isReadOnly) {
    super(ppd, bindingProvider);

    // Setup widget to use bindings
    this.parameterName.setText(ppd.getName());
    Set<String> bindings = bindingProvider.getBindings(ppd.getClassName());
    if (bindings.size() > 0) {
      lstAvailableBindings.clear();
      lstAvailableBindings.addItem(Constants.INSTANCE.Choose());
      lstAvailableBindings.setEnabled(true && !isReadOnly);
      lstAvailableBindings.setVisible(true);
      int selectedIndex = 0;
      for (String binding : bindings) {
        lstAvailableBindings.addItem(binding);
        if (binding.equals(ppd.getBinding())) {
          selectedIndex = lstAvailableBindings.getItemCount() - 1;
        }
      }
      lstAvailableBindings.setSelectedIndex(selectedIndex);
    }
  }
示例#12
0
    GroupPanel(CheckBoxItem box, Group group, List<Application> apps, List<Region> regions) {
      this.group = group;
      this.box = box;
      box.addValueChangeHandler(
          new ValueChangeHandler<Boolean>() {

            public void onValueChange(ValueChangeEvent<Boolean> event) {
              adjustListBox(event.getValue());
            }
          });

      add(box);
      if (group.hasApplications()) {
        add(new Label("applications"));
        add(applications);
        if (apps != null && !apps.isEmpty()) {
          applications.clear();
          for (Application a : apps) {
            applications.addItem(a.toDisplay(), a.getId() + "");
          }
        } else {
          applications.addItem("loading . . .");
        }
        applications.setEnabled(false);
      }
      if (group.hasRegions()) {
        add(new Label("regions"));
        add(this.regions);
        if (regions != null && !regions.isEmpty()) {
          regions.clear();
          for (Region a : regions) {
            this.regions.addItem(a.toDisplay(), a.getId() + "");
          }
        } else {
          this.regions.addItem("loading . . .");
        }
        this.regions.setEnabled(false);
      }
    }
  private void save(final int saveMode) {
    enableSaveButtons(false);

    String date = dateCreatedHTML.getText();
    String manager = managerHTML.getText();
    String descriptionText = XMLUtils.clean(description.getText());
    String notesText = XMLUtils.clean(notes.getText());
    final String name = XMLUtils.clean(workingSetName.getText());
    final String errorFilter = filterPanel.checkValidity();

    // CHECK TO MAKE SURE FIELDS ARE ENTERED IN
    if (name == null || name.trim().equals("")) {
      WindowUtils.errorAlert("Please enter a working set name.");
      enableSaveButtons(true);
      return;
    }

    if (errorFilter != null) {
      WindowUtils.errorAlert(errorFilter);
    } else if (descriptionText == null || descriptionText.trim().equals("")) {
      WindowUtils.errorAlert("Please enter a working set description.");
      enableSaveButtons(true);
      return;
    } else if (workingSetMode.getSelectedIndex() != PRIVATEINDEX
        && workingSetMode.getSelectedIndex() != PUBLICINDEX) {
      WindowUtils.errorAlert("Please select the working set type.");
      enableSaveButtons(true);
      return;
    }

    // HAVEN'T SAVED BEFORE
    if (id == null) {
      final WorkingSetData currentWorkingSet = new WorkingSetData();
      currentWorkingSet.setDate(date);
      currentWorkingSet.setCreator(manager);
      currentWorkingSet.setDescription(descriptionText);
      currentWorkingSet.setNotes(notesText);
      currentWorkingSet.setWorkingSetName(name);
      currentWorkingSet.setMode(workingSetMode.getItemText(workingSetMode.getSelectedIndex()));
      currentWorkingSet.setPeople(people.getItemsInList());
      currentWorkingSet.setFilter(filterPanel.getFilter());

      if (currentWorkingSet.getMode().equalsIgnoreCase(WorkingSetData.PRIVATE)) {
        savePrivateWorkingSet(currentWorkingSet, saveMode);
        workingSetMode.setEnabled(false);
      } else {
        savePublicWorkingSet(currentWorkingSet, saveMode);
        workingSetMode.setEnabled(false);
      }

      // this.manager.workingSetHierarchy.update();
      WSStore.getStore().update();
    }
    // ALREADY HAVE BEEN SAVED BEFORE, REALLY EDITTING
    else {

      final WorkingSetData currentWorkingSet =
          (WorkingSetData) WorkingSetCache.impl.getWorkingSets().get(id);

      if (currentWorkingSet != null) {
        currentWorkingSet.setDescription(descriptionText);
        currentWorkingSet.setNotes(notesText);
        currentWorkingSet.setWorkingSetName(name);
        currentWorkingSet.setPeople(people.getItemsInList());
        currentWorkingSet.setFilter(filterPanel.getFilter());
        String mode = currentWorkingSet.getMode();
        String newMode = workingSetMode.getItemText(workingSetMode.getSelectedIndex());

        if (!mode.equalsIgnoreCase(newMode)) {

          // CHANGING TO PRIVATE
          if (newMode.equalsIgnoreCase(WorkingSetData.PRIVATE)) {

            WindowUtils.confirmAlert(
                "Warning",
                "Changing a working set from public to private creates"
                    + " a copy of the working set into your private directory but does not"
                    + " delete the working set out of the public directory.",
                new Listener<MessageBoxEvent>() {
                  public void handleEvent(MessageBoxEvent be) {
                    if (be.getType() == Events.Close) {
                      if (be.getButtonClicked().getType().equals(MessageBox.OK)) {
                        savePublicToPrivateWorkingSet(currentWorkingSet, saveMode);
                      }
                    }
                  }
                });
          }

          // CHANGING TO PUBLIC
          if (newMode.equalsIgnoreCase(WorkingSetData.PRIVATE)) {

            WindowUtils.confirmAlert(
                "Warning",
                "Changing a working set from private to public will allow your "
                    + "working set to be viewed by other people.",
                new Listener<MessageBoxEvent>() {
                  public void handleEvent(MessageBoxEvent be) {
                    if (be.getType() == Events.Close) {
                      if (be.getButtonClicked().getType().equals(MessageBox.OK)) {
                        savePrivateToPublicWorkingSet(currentWorkingSet, saveMode);
                      }
                    }
                  }
                });
          }
        } else if (currentWorkingSet.getMode().equalsIgnoreCase(WorkingSetData.PRIVATE))
          savePrivateWorkingSet(currentWorkingSet, saveMode);
        else savePublicWorkingSet(currentWorkingSet, saveMode);
      }
    }
  }
  private void populatePanel() {
    player1Box = new ListBox(false);
    populatePlayerBox(player1Box);
    Label vsLabel = new Label(" spelade mot ");
    player2Box = new ListBox(false);
    populatePlayerBox(player2Box);
    HorizontalPanel playerPanel = Spelstegen.createStandardHorizontalPanel();
    playerPanel.add(player1Box);
    playerPanel.add(vsLabel);
    playerPanel.add(player2Box);

    sportBox = new ListBox(false);
    if (league.getSports().size() > 1) {
      sportBox.addItem("Välj sport");
      for (Sport sport : league.getSports()) {
        sportBox.addItem(sport.getName());
      }
    } else {
      sportBox.addItem(league.getSports().get(0).getName());
      sportBox.setEnabled(false);
    }

    HorizontalPanel sportPanel = Spelstegen.createStandardHorizontalPanel();
    sportPanel.add(new Label("i:"));
    sportPanel.add(sportBox);

    Label setLabel = new Label("Spel om bäst av");
    oneSet = new RadioButton("setSelection", "1");
    threeSet = new RadioButton("setSelection", "3");
    fiveSet = new RadioButton("setSelection", "5");
    oneSet.setValue(true);
    SetClickHandler setClickHandler = new SetClickHandler();
    oneSet.addClickHandler(setClickHandler);
    threeSet.addClickHandler(setClickHandler);
    fiveSet.addClickHandler(setClickHandler);
    Label setLabel2 = new Label(" set");
    HorizontalPanel setPanel = Spelstegen.createStandardHorizontalPanel();
    setPanel.add(setLabel);
    setPanel.add(oneSet);
    setPanel.add(threeSet);
    setPanel.add(fiveSet);
    setPanel.add(setLabel2);

    player1Score = new ArrayList<TextBox>(5);
    player2Score = new ArrayList<TextBox>(5);
    scorePanel = new VerticalPanel();
    scorePanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    setScoreBoxes(1);

    saveButton = new PushButton("Spara");
    if (loggedInPlayer != null) {
      saveButton.setEnabled(loggedInPlayer.isLeagueAdmin(league.getId()));
    }
    saveButton.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            submitMatch();
          }
        });

    HorizontalPanel buttonPanel = Spelstegen.createStandardHorizontalPanel();
    buttonPanel.add(saveButton);
    mainPanel.add(playerPanel);
    mainPanel.add(sportPanel);
    mainPanel.add(setPanel);
    mainPanel.add(scorePanel);
    mainPanel.add(buttonPanel);
  }
示例#15
0
 @Override
 public void setEnabled(boolean b) {
   listBox.setEnabled(b);
 }
示例#16
0
  public LayoutContainer getRightSide() {
    RowLayout layout = new RowLayout();
    // layout.setMargin(0);
    // layout.setSpacing(0);

    ButtonBar south = new ButtonBar();
    south.setAlignment(HorizontalAlignment.RIGHT);
    final Button complete =
        new Button(
            "Complete Split",
            new SelectionListener<ButtonEvent>() {
              @Override
              public void componentSelected(ButtonEvent ce) {
                onClose();
              }
            });
    south.add(complete);
    complete.setEnabled(false);

    LayoutContainer container = new LayoutContainer();
    container.setLayout(layout);
    container.setLayoutOnChange(true);

    final DataList moveList = new DataList();
    final ListBox listBox = new ListBox();
    listBox.addChangeHandler(
        new ChangeHandler() {
          public void onChange(ChangeEvent event) {
            moveList.removeAll();
            ArrayList<String> list =
                parentToChildList.get(listBox.getValue(listBox.getSelectedIndex()));
            if (list == null) return;
            Iterator<String> iterator = list.listIterator();
            while (iterator.hasNext()) {
              // FIXME: look at this, i just fix this and dont know if it's right. CS
              String nodeID = iterator.next();
              Taxon cur = TaxonomyCache.impl.getTaxon(nodeID);
              DataListItem li = new DataListItem(cur.getFullName());
              li.setData("nodeID", nodeID);
              li.setData("node", cur);
              moveList.add(li);
            }
            layout();
          }
        });

    Menu m = new Menu();
    MenuItem item = new MenuItem();
    item.setText("Remove");
    item.addSelectionListener(
        new SelectionListener<MenuEvent>() {
          @Override
          public void componentSelected(MenuEvent ce) {
            DataListItem item = (DataListItem) ce.getSource();
            ArrayList<String> list =
                parentToChildList.get(listBox.getValue(listBox.getSelectedIndex()));
            if (list != null) list.remove(item.getData("nodeID"));

            moveList.remove(item);
            children.add(item);
            layout();
          }
        });
    m.add(item);
    moveList.setContextMenu(m);

    VerticalPanel table = new VerticalPanel();
    table.add(new HTML("Current Taxonomic Group: "));
    table.add(listBox);
    listBox.setWidth("100%");
    listBox.setEnabled(false);

    final ButtonBar bar = new ButtonBar();
    bar.setAlignment(HorizontalAlignment.RIGHT);
    final Button addChild =
        new Button(
            "Add Child",
            new SelectionListener<ButtonEvent>() {
              @Override
              public void componentSelected(ButtonEvent ce) {
                List<DataListItem> sel = children.getSelectedItems();
                if (sel == null) return;
                ArrayList<String> list =
                    parentToChildList.get(listBox.getValue(listBox.getSelectedIndex()));
                for (DataListItem selected : sel) {
                  children.remove(selected);
                  String nodeID = selected.getData("nodeID");
                  if (!list.contains(nodeID)) {
                    list.add(nodeID);
                    DataListItem item = new DataListItem(selected.getText());
                    item.setData("nodeID", nodeID);
                    item.setData("node", selected.getData("node"));
                    moveList.add(item);
                  }
                }
                layout();
              }
            });
    addChild.setEnabled(false);
    bar.add(addChild);
    bar.add(
        new Button(
            "Create New Taxon",
            new SelectionListener<ButtonEvent>() {
              @Override
              public void componentSelected(ButtonEvent ce) {
                TaxonomyCache.impl.fetchTaxon(
                    currentNode.getParentId(),
                    false,
                    new GenericCallback<Taxon>() {
                      public void onFailure(Throwable caught) {
                        WindowUtils.errorAlert(
                            "Error",
                            "Could not " + "find parent level to attach new taxonomic concept to.");
                      }

                      public void onSuccess(Taxon result) {
                        complete.setEnabled(true);

                        final CreateNewTaxonPanel panel = new CreateNewTaxonPanel(result);
                        panel.addListener(
                            Events.StateChange,
                            new Listener<BaseEvent>() {
                              public void handleEvent(BaseEvent be) {
                                Taxon newNode = (Taxon) be.getSource();
                                parentToChildList.put(
                                    newNode.getId() + "", new ArrayList<String>());
                                listBox.addItem(newNode.getFullName(), newNode.getId() + "");
                                listBox.setSelectedIndex(listBox.getItemCount() - 1);
                                listBox.setEnabled(true);
                                moveList.removeAll();
                                addChild.setEnabled(true);
                              }
                            });
                        panel.show();
                      }
                    });
              }
            }));

    container.add(table, new RowData(1d, 25));
    container.add(bar, new RowData(1d, 25));
    container.add(new HTML("Children to add to new taxon:"), new RowData(1d, 25));
    container.add(moveList, new RowData(1d, 1d));
    container.add(south, new RowData(1d, 25));

    return container;
  }
  public ActionRetractFactPopup(
      final GuidedDecisionTable52 model,
      final GenericColumnCommand refreshGrid,
      final ActionRetractFactCol52 col,
      final boolean isNew,
      final boolean isReadOnly) {
    super(GuidedDecisionTableConstants.INSTANCE.ColumnConfigurationDeleteAFact());
    this.rm = new BRLRuleModel(model);
    this.editingCol = cloneActionRetractColumn(col);
    this.model = model;

    // Show available pattern bindings, if Limited Entry
    if (model.getTableFormat() == TableFormat.LIMITED_ENTRY) {
      final LimitedEntryActionRetractFactCol52 ler =
          (LimitedEntryActionRetractFactCol52) editingCol;
      final ListBox patterns = loadBoundFacts(ler.getValue().getStringValue());
      patterns.setEnabled(!isReadOnly);
      if (!isReadOnly) {
        patterns.addClickHandler(
            new ClickHandler() {

              public void onClick(ClickEvent event) {
                int index = patterns.getSelectedIndex();
                if (index > -1) {
                  ler.getValue().setStringValue(patterns.getValue(index));
                }
              }
            });
      }
      addAttribute(GuidedDecisionTableConstants.INSTANCE.FactToDeleteColon(), patterns);
    }

    // Column header
    final TextBox header = new TextBox();
    header.setText(col.getHeader());
    header.setEnabled(!isReadOnly);
    if (!isReadOnly) {
      header.addChangeHandler(
          new ChangeHandler() {
            public void onChange(ChangeEvent event) {
              editingCol.setHeader(header.getText());
            }
          });
    }
    addAttribute(GuidedDecisionTableConstants.INSTANCE.ColumnHeaderDescription(), header);

    // Hide column tick-box
    addAttribute(
        new StringBuilder(GuidedDecisionTableConstants.INSTANCE.HideThisColumn())
            .append(GuidedDecisionTableConstants.COLON)
            .toString(),
        DTCellValueWidgetFactory.getHideColumnIndicator(editingCol));

    // Apply button
    add(
        new ModalFooterOKCancelButtons(
            new Command() {
              @Override
              public void execute() {
                applyChanges(refreshGrid, col, isNew);
              }
            },
            new Command() {
              @Override
              public void execute() {
                hide();
              }
            }));
  }
  private Widget getEditorWidget(final RuleAttribute at, final int idx, final boolean isReadOnly) {
    Widget editor = null;

    final String attributeName = at.getAttributeName();
    if (attributeName.equals(RULEFLOW_GROUP_ATTR)
        || attributeName.equals(AGENDA_GROUP_ATTR)
        || attributeName.equals(ACTIVATION_GROUP_ATTR)
        || attributeName.equals(TIMER_ATTR)
        || attributeName.equals(CALENDARS_ATTR)) {
      final TextBox tb = TextBoxFactory.getTextBox(DataType.TYPE_STRING);
      tb.setValue(at.getValue());
      tb.setEnabled(!isReadOnly);
      if (!isReadOnly) {
        tb.addValueChangeHandler(
            new ValueChangeHandler<String>() {

              public void onValueChange(ValueChangeEvent<String> event) {
                at.setValue(tb.getValue());
              }
            });
      }
      editor = tb;

    } else if (attributeName.equals(SALIENCE_ATTR)) {
      final TextBox tb = TextBoxFactory.getTextBox(DataType.TYPE_NUMERIC_INTEGER);
      tb.setValue(at.getValue());
      tb.setEnabled(!isReadOnly);
      if (!isReadOnly) {
        tb.addValueChangeHandler(
            new ValueChangeHandler<String>() {

              public void onValueChange(ValueChangeEvent<String> event) {
                at.setValue(tb.getValue());
              }
            });
      }
      editor = tb;

    } else if (attributeName.equals(DURATION_ATTR)) {
      final TextBox tb = TextBoxFactory.getTextBox(DataType.TYPE_NUMERIC_LONG);
      tb.setValue(at.getValue());
      tb.setEnabled(!isReadOnly);
      if (!isReadOnly) {
        tb.addValueChangeHandler(
            new ValueChangeHandler<String>() {

              public void onValueChange(ValueChangeEvent<String> event) {
                at.setValue(tb.getValue());
              }
            });
      }
      editor = tb;

    } else if (attributeName.equals(NO_LOOP_ATTR)
        || attributeName.equals(LOCK_ON_ACTIVE_ATTR)
        || attributeName.equals(AUTO_FOCUS_ATTR)
        || attributeName.equals(ENABLED_ATTR)) {
      editor = checkBoxEditor(at, isReadOnly);

    } else if (attributeName.equals(DATE_EFFECTIVE_ATTR)
        || attributeName.equals(DATE_EXPIRES_ATTR)) {
      if (isReadOnly) {
        final TextBox tb = TextBoxFactory.getTextBox(DataType.TYPE_STRING);
        tb.setValue(at.getValue());
        tb.setEnabled(false);
      } else {
        final PopupDatePicker dp = new PopupDatePicker(false);
        dp.setValue(at.getValue());
        dp.addValueChangeHandler(
            new ValueChangeHandler<Date>() {

              public void onValueChange(ValueChangeEvent<Date> event) {
                at.setValue(PopupDatePicker.convertToString(event));
              }
            });
        editor = dp;
      }
    } else if (attributeName.equals(DIALECT_ATTR)) {
      final ListBox lb = new ListBox();
      lb.addItem(DIALECTS[0]);
      lb.addItem(DIALECTS[1]);
      lb.setEnabled(!isReadOnly);
      if (!isReadOnly) {
        lb.addChangeHandler(
            new ChangeHandler() {
              @Override
              public void onChange(ChangeEvent event) {
                final int selectedIndex = lb.getSelectedIndex();
                if (selectedIndex < 0) {
                  return;
                }
                at.setValue(lb.getValue(selectedIndex));
              }
            });
      }
      if (at.getValue() == null || at.getValue().isEmpty()) {
        lb.setSelectedIndex(1);
        at.setValue(DIALECTS[1]);
      } else if (at.getValue().equals(DIALECTS[0])) {
        lb.setSelectedIndex(0);
      } else if (at.getValue().equals(DIALECTS[1])) {
        lb.setSelectedIndex(1);
      } else {
        lb.setSelectedIndex(1);
        at.setValue(DIALECTS[1]);
      }
      editor = lb;
    }

    DirtyableHorizontalPane horiz = new DirtyableHorizontalPane();
    if (editor != null) {
      horiz.add(editor);
      if (!isReadOnly) {
        horiz.add(getRemoveIcon(idx));
      }
    }

    return horiz;
  }
  public I2CRegistersPanel() {

    service_ = initGSON.initGSON();

    mainPanel_ = new HorizontalPanel();

    cbcList_ = new ListBox(true); // TODO enables multiple select

    cbcList_.addItem("Waiting...");
    cbcList_.setEnabled(false);
    cbcList_.addChangeHandler(
        new ChangeHandler() {
          public void onChange(ChangeEvent event) {
            getI2CValues();
          }
        });

    cbcList_.setVisibleItemCount(0);
    mainPanel_.add(cbcList_);
    mainPanel_.add(echo_);

    registerValues.put(null, null);
    cbcNames.put(null, null);
    rpcContainer.add(cbcNames); // sends an empty request

    rpcMessage myparams = new rpcMessage();
    myparams.setMethod("connectedCBCNames");
    myparams.setParams(rpcContainer); // send an empty request, returns connected names

    service_.connectedCBCService(
        myparams,
        new MethodCallback<cbcNamesResponse>() {

          @Override
          public void onFailure(Method method, Throwable exception) {
            // TODO Auto-generated method stub
            Window.alert(exception.getMessage().toString());
          }

          @Override
          public void onSuccess(Method method, cbcNamesResponse response) {

            cbcList_.removeItem(0);
            for (final String cbcName : response.getResult()) {
              cbcList_.addItem(cbcName);
            }
            cbcList_.setEnabled(true);
            cbcList_.setVisibleItemCount(response.getResult().size());
            getI2CValues();
          }
        });

    mainSettings_ = new DisclosurePanel("Main control registers");
    channelMasks_ = new DisclosurePanel("Channel masks");
    channelTrims_ = new DisclosurePanel("Channel trims");
    HorizontalPanel verticalPanelForI2C = new HorizontalPanel();
    verticalPanelForI2C.add(mainSettings_);
    verticalPanelForI2C.add(channelMasks_);
    verticalPanelForI2C.add(channelTrims_);
    mainPanel_.add(verticalPanelForI2C);

    mainSettings_.add(
        addRegisters(
            new String[] {
              "FrontEndControl",
              "TriggerLatency",
              "HitDetectSLVS",
              "Ipre1",
              "Ipre2",
              "Ipsf",
              "Ipa",
              "Ipaos",
              "Vpafb",
              "Icomp",
              "Vpc",
              "Vplus",
              "VCth",
              "TestPulsePot",
              "SelTestPulseDel&ChanGroup",
              "MiscTestPulseCtrl&AnalogMux",
              "TestPulseChargePumpCurrent",
              "TestPulseChargeMirrCascodeVolt",
              "CwdWindow&Coincid",
              "MiscStubLogic"
            }));
    channelMasks_.add(
        addRegisters(
            new String[] {
              "MaskChannelFrom008downto001",
              "MaskChannelFrom016downto009",
              "MaskChannelFrom024downto017",
              "MaskChannelFrom032downto025",
              "MaskChannelFrom040downto033",
              "MaskChannelFrom048downto041",
              "MaskChannelFrom056downto049",
              "MaskChannelFrom064downto057",
              "MaskChannelFrom072downto065",
              "MaskChannelFrom080downto073",
              "MaskChannelFrom088downto081",
              "MaskChannelFrom096downto089",
              "MaskChannelFrom104downto097",
              "MaskChannelFrom112downto105",
              "MaskChannelFrom120downto113",
              "MaskChannelFrom128downto121",
              "MaskChannelFrom136downto129",
              "MaskChannelFrom144downto137",
              "MaskChannelFrom152downto145",
              "MaskChannelFrom160downto153",
              "MaskChannelFrom168downto161",
              "MaskChannelFrom176downto169",
              "MaskChannelFrom184downto177",
              "MaskChannelFrom192downto185",
              "MaskChannelFrom200downto193",
              "MaskChannelFrom208downto201",
              "MaskChannelFrom216downto209",
              "MaskChannelFrom224downto217",
              "MaskChannelFrom232downto225",
              "MaskChannelFrom240downto233",
              "MaskChannelFrom248downto241",
              "MaskChannelFrom254downto249"
            }));
    channelTrims_.add(
        addRegisters(
            new String[] {
              "Channel001",
              "Channel002",
              "Channel003",
              "Channel004",
              "Channel005",
              "Channel006",
              "Channel007",
              "Channel008",
              "Channel009",
              "Channel010",
              "Channel011",
              "Channel012",
              "Channel013",
              "Channel014",
              "Channel015",
              "Channel016",
              "Channel017",
              "Channel018",
              "Channel019",
              "Channel020",
              "Channel021",
              "Channel022",
              "Channel023",
              "Channel024",
              "Channel025",
              "Channel026",
              "Channel027",
              "Channel028",
              "Channel029",
              "Channel030",
              "Channel031",
              "Channel032",
              "Channel033",
              "Channel034",
              "Channel035",
              "Channel036",
              "Channel037",
              "Channel038",
              "Channel039",
              "Channel040",
              "Channel041",
              "Channel042",
              "Channel043",
              "Channel044",
              "Channel045",
              "Channel046",
              "Channel047",
              "Channel048",
              "Channel049",
              "Channel050",
              "Channel051",
              "Channel052",
              "Channel053",
              "Channel054",
              "Channel055",
              "Channel056",
              "Channel057",
              "Channel058",
              "Channel059",
              "Channel060",
              "Channel061",
              "Channel062",
              "Channel063",
              "Channel064",
              "Channel065",
              "Channel066",
              "Channel067",
              "Channel068",
              "Channel069",
              "Channel070",
              "Channel071",
              "Channel072",
              "Channel073",
              "Channel074",
              "Channel075",
              "Channel076",
              "Channel077",
              "Channel078",
              "Channel079",
              "Channel080",
              "Channel081",
              "Channel082",
              "Channel083",
              "Channel084",
              "Channel085",
              "Channel086",
              "Channel087",
              "Channel088",
              "Channel089",
              "Channel090",
              "Channel091",
              "Channel092",
              "Channel093",
              "Channel094",
              "Channel095",
              "Channel096",
              "Channel097",
              "Channel098",
              "Channel099",
              "Channel100",
              "Channel101",
              "Channel102",
              "Channel103",
              "Channel104",
              "Channel105",
              "Channel106",
              "Channel107",
              "Channel108",
              "Channel109",
              "Channel110",
              "Channel111",
              "Channel112",
              "Channel113",
              "Channel114",
              "Channel115",
              "Channel116",
              "Channel117",
              "Channel118",
              "Channel119",
              "Channel120",
              "Channel121",
              "Channel122",
              "Channel123",
              "Channel124",
              "Channel125",
              "Channel126",
              "Channel127",
              "Channel128",
              "Channel129",
              "Channel130",
              "Channel131",
              "Channel132",
              "Channel133",
              "Channel134",
              "Channel135",
              "Channel136",
              "Channel137",
              "Channel138",
              "Channel139",
              "Channel140",
              "Channel141",
              "Channel142",
              "Channel143",
              "Channel144",
              "Channel145",
              "Channel146",
              "Channel147",
              "Channel148",
              "Channel149",
              "Channel150",
              "Channel151",
              "Channel152",
              "Channel153",
              "Channel154",
              "Channel155",
              "Channel156",
              "Channel157",
              "Channel158",
              "Channel159",
              "Channel160",
              "Channel161",
              "Channel162",
              "Channel163",
              "Channel164",
              "Channel165",
              "Channel166",
              "Channel167",
              "Channel168",
              "Channel169",
              "Channel170",
              "Channel171",
              "Channel172",
              "Channel173",
              "Channel174",
              "Channel175",
              "Channel176",
              "Channel177",
              "Channel178",
              "Channel179",
              "Channel180",
              "Channel181",
              "Channel182",
              "Channel183",
              "Channel184",
              "Channel185",
              "Channel186",
              "Channel187",
              "Channel188",
              "Channel189",
              "Channel190",
              "Channel191",
              "Channel192",
              "Channel193",
              "Channel194",
              "Channel195",
              "Channel196",
              "Channel197",
              "Channel198",
              "Channel199",
              "Channel200",
              "Channel201",
              "Channel202",
              "Channel203",
              "Channel204",
              "Channel205",
              "Channel206",
              "Channel207",
              "Channel208",
              "Channel209",
              "Channel210",
              "Channel211",
              "Channel212",
              "Channel213",
              "Channel214",
              "Channel215",
              "Channel216",
              "Channel217",
              "Channel218",
              "Channel219",
              "Channel220",
              "Channel221",
              "Channel222",
              "Channel223",
              "Channel224",
              "Channel225",
              "Channel226",
              "Channel227",
              "Channel228",
              "Channel229",
              "Channel230",
              "Channel231",
              "Channel232",
              "Channel233",
              "Channel234",
              "Channel235",
              "Channel236",
              "Channel237",
              "Channel238",
              "Channel239",
              "Channel240",
              "Channel241",
              "Channel242",
              "Channel243",
              "Channel244",
              "Channel245",
              "Channel246",
              "Channel247",
              "Channel248",
              "Channel249",
              "Channel250",
              "Channel251",
              "Channel252",
              "Channel253",
              "Channel254",
              "ChannelDummy"
            }));
  }
 public void setReadOnly(boolean p_readOnly) {
   m_name.setEnabled(!p_readOnly);
   m_description.setEnabled(!p_readOnly);
   m_maxPlayerCount.setEnabled(!p_readOnly);
 }
示例#21
0
 public void setEnabled(boolean enabled) {
   box.setEnabled(enabled);
   applications.setEnabled(enabled);
 }
  public ActionRetractFactPopup(
      final GuidedDecisionTable52 model,
      final GenericColumnCommand refreshGrid,
      final ActionRetractFactCol52 col,
      final boolean isNew,
      final boolean isReadOnly) {
    this.rm = new BRLRuleModel(model);
    this.editingCol = cloneActionRetractColumn(col);
    this.model = model;

    setTitle(GuidedDecisionTableConstants.INSTANCE.ColumnConfigurationDeleteAFact());
    setModal(false);

    // Show available pattern bindings, if Limited Entry
    if (model.getTableFormat() == TableFormat.LIMITED_ENTRY) {
      final LimitedEntryActionRetractFactCol52 ler =
          (LimitedEntryActionRetractFactCol52) editingCol;
      final ListBox patterns = loadBoundFacts(ler.getValue().getStringValue());
      patterns.setEnabled(!isReadOnly);
      if (!isReadOnly) {
        patterns.addClickHandler(
            new ClickHandler() {

              public void onClick(ClickEvent event) {
                int index = patterns.getSelectedIndex();
                if (index > -1) {
                  ler.getValue().setStringValue(patterns.getValue(index));
                }
              }
            });
      }
      addAttribute(GuidedDecisionTableConstants.INSTANCE.FactToDeleteColon(), patterns);
    }

    // Column header
    final TextBox header = new TextBox();
    header.setText(col.getHeader());
    header.setEnabled(!isReadOnly);
    if (!isReadOnly) {
      header.addChangeHandler(
          new ChangeHandler() {
            public void onChange(ChangeEvent event) {
              editingCol.setHeader(header.getText());
            }
          });
    }
    addAttribute(GuidedDecisionTableConstants.INSTANCE.ColumnHeaderDescription(), header);

    // Hide column tick-box
    addAttribute(
        new StringBuilder(GuidedDecisionTableConstants.INSTANCE.HideThisColumn())
            .append(GuidedDecisionTableConstants.COLON)
            .toString(),
        DTCellValueWidgetFactory.getHideColumnIndicator(editingCol));

    Button apply = new Button(GuidedDecisionTableConstants.INSTANCE.ApplyChanges());
    apply.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent w) {
            if (null == editingCol.getHeader() || "".equals(editingCol.getHeader())) {
              Window.alert(
                  GuidedDecisionTableConstants.INSTANCE
                      .YouMustEnterAColumnHeaderValueDescription());
              return;
            }
            if (isNew) {
              if (!unique(editingCol.getHeader())) {
                Window.alert(
                    GuidedDecisionTableConstants.INSTANCE
                        .ThatColumnNameIsAlreadyInUsePleasePickAnother());
                return;
              }

            } else {
              if (!col.getHeader().equals(editingCol.getHeader())) {
                if (!unique(editingCol.getHeader())) {
                  Window.alert(
                      GuidedDecisionTableConstants.INSTANCE
                          .ThatColumnNameIsAlreadyInUsePleasePickAnother());
                  return;
                }
              }
            }

            // Pass new\modified column back for handling
            refreshGrid.execute(editingCol);
            hide();
          }
        });
    addAttribute("", apply);
  }
  private void buildContent(RowData data) {
    grid = new FlexTable();
    grid.setCellSpacing(5);

    HTML html = new HTML("Working Set Name:  ");
    html.addStyleName("color-dark-blue");
    workingSetName = new TextBox();
    grid.setWidget(0, 0, html);
    grid.setWidget(0, 1, workingSetName);
    workingSetName.setSize("95%", "100%");

    html = new HTML("Creator:  ");
    html.addStyleName("color-dark-blue");
    managerHTML = new HTML();
    grid.setWidget(1, 0, html);
    grid.setWidget(1, 1, managerHTML);

    html = new HTML("Date Created:  ");
    html.addStyleName("color-dark-blue");
    dateCreatedHTML = new HTML();
    grid.setWidget(2, 0, html);
    grid.setWidget(2, 1, dateCreatedHTML);

    html = new HTML("Working Set Type:  ");
    html.addStyleName("color-dark-blue");
    workingSetMode = new ListBox(false);
    workingSetMode.insertItem("none selected", 0);
    workingSetMode.insertItem(WorkingSetData.PRIVATE, PRIVATEINDEX);
    workingSetMode.insertItem(WorkingSetData.PUBLIC, PUBLICINDEX);
    workingSetMode.setVisibleItemCount(1);
    workingSetMode.setEnabled(false);
    workingSetMode.setSelectedIndex(PUBLICINDEX);
    grid.setWidget(3, 0, html);
    grid.setWidget(3, 1, workingSetMode);

    html = new HTML("Associated People:  ");
    html.addStyleName("color-dark-blue");
    people = new SISCompleteList(this, 400);
    grid.setWidget(PEOPLECELL, 0, html);
    grid.setWidget(PEOPLECELL, 1, people);

    html = new HTML("Assessment Scope:  ");
    html.addStyleName("color-dark-blue");
    filterPanel = new AssessmentFilterPanel(new AssessmentFilter(), false, true, false, true);
    grid.setWidget(5, 0, html);
    grid.setWidget(5, 1, filterPanel);

    html = new HTML("Description:  ");
    html.addStyleName("color-dark-blue");
    description = new TextArea();
    grid.setWidget(6, 0, html);
    grid.setWidget(6, 1, description);
    description.setSize("95%", "100%");

    html = new HTML("Working Set Notes: ");
    html.addStyleName("color-dark-blue");
    notes = new TextArea();
    grid.setWidget(7, 0, html);
    grid.setWidget(7, 1, notes);
    notes.setSize("95%", "100%");

    grid.getColumnFormatter().setWidth(0, "130px");
    grid.getColumnFormatter().setWidth(1, "400px");
    grid.getRowFormatter().addStyleName(5, "vertical-align-top");
    grid.getRowFormatter().addStyleName(6, "vertical-align-top");
    grid.getRowFormatter().addStyleName(7, "vertical-align-top");
    grid.getCellFormatter().setHeight(6, 1, "200px");
    grid.getCellFormatter().setHeight(7, 1, "200px");

    HorizontalPanel hp = new HorizontalPanel();
    hp.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
    hp.addStyleName("expert-border");
    hp.add(grid);

    // add(hp, data);

    LayoutContainer widget = new LayoutContainer();
    widget.setScrollMode(Scroll.AUTO);
    widget.setLayout(new FillLayout());
    widget.add(hp);
    add(widget, data);
    grid.setWidth("100%");
  }