Exemplo n.º 1
0
 /** Override this method is to select the first existent gesture, and show its configuration. */
 @Override
 protected void afterRender() {
   super.afterRender();
   if (existsGestureTypeModels.size() > 0) {
     BeanModel firstCheckedModel = existsGestureTypeModels.get(0);
     gestureTypeListView.getSelectionModel().select(firstCheckedModel, false);
     ListViewEvent<BeanModel> listViewEvent = new ListViewEvent<BeanModel>(gestureTypeListView);
     listViewEvent.setModel(firstCheckedModel);
     gestureTypeListView.fireEvent(Events.Select, listViewEvent);
   }
 }
Exemplo n.º 2
0
  private void createGestureTypeList() {
    ContentPanel gestureTypesContainer = new ContentPanel();
    gestureTypesContainer.setHeaderVisible(false);
    gestureTypesContainer.setLayout(new FitLayout());
    // overflow-auto style is for IE hack.
    gestureTypesContainer.addStyleName("overflow-auto");
    gestureTypesContainer.setBorders(false);
    gestureTypesContainer.setBodyBorder(false);

    ListStore<BeanModel> gestureStore = new ListStore<BeanModel>();
    GestureType[] gestureTypes = GestureType.values();
    existsGestureTypeModels = new ArrayList<BeanModel>();

    for (int i = 0; i < gestureTypes.length; i++) {
      Gesture gesture = new Gesture(gestureTypes[i]);
      gesture.setOid(IDUtil.nextID());
      gestureMaps.put(gestureTypes[i].toString(), gesture);
      BeanModel gestureBeanModel = gesture.getBeanModel();
      gestureStore.add(gestureBeanModel);
      for (Gesture existGesture : gestures) {
        if (gestureTypes[i].equals(existGesture.getType())) {
          gestureMaps.put(existGesture.getType().toString(), existGesture);
          existsGestureTypeModels.add(gestureBeanModel);
        }
      }
    }

    gestureTypeListView =
        new CheckBoxListViewExt<BeanModel>() {
          @Override
          protected void afterRender() {
            super.afterRender();
            for (BeanModel checkedModel : existsGestureTypeModels) {
              this.setChecked(checkedModel, true);
            }
          }
        };
    gestureTypeListView.setStore(gestureStore);
    gestureTypeListView.setDisplayProperty("type");
    gestureTypeListView.setStyleAttribute("overflow", "auto");
    gestureTypesContainer.add(gestureTypeListView);

    BorderLayoutData westData = new BorderLayoutData(LayoutRegion.WEST, 150);
    westData.setMargins(new Margins(0, 5, 0, 0));
    add(gestureTypesContainer, westData);
  }
Exemplo n.º 3
0
  private void createGesturePropertyForm() {
    FormPanel gesturePropertyForm = new FormPanel();
    gesturePropertyForm.setLabelAlign(LabelAlign.TOP);
    gesturePropertyForm.setHeaderVisible(false);

    final Text selectedCommand = new Text(SELECTED_COMMAND);

    ContentPanel commandTreeContainer = new ContentPanel();
    commandTreeContainer.setHeaderVisible(false);
    commandTreeContainer.setBorders(false);
    commandTreeContainer.setBodyBorder(false);
    commandTreeContainer.setSize(240, 150);
    commandTreeContainer.setLayout(new FitLayout());
    commandTreeContainer.setScrollMode(Scroll.AUTO);
    if (devicesAndMacrosTree == null) {
      devicesAndMacrosTree = TreePanelBuilder.buildCommandAndMacroTree();
      commandTreeContainer.add(devicesAndMacrosTree);
    }
    devicesAndMacrosTree.collapseAll();
    final AdapterField commandField = new AdapterField(commandTreeContainer);
    commandField.setFieldLabel("Select a command");
    commandField.setBorders(true);
    devicesAndMacrosTree
        .getSelectionModel()
        .addSelectionChangedListener(
            new SelectionChangedListener<BeanModel>() {
              public void selectionChanged(SelectionChangedEvent<BeanModel> se) {
                BeanModel commandModel = se.getSelectedItem();
                if (commandModel.getBean() != null) {
                  UICommandDTO uiCommand = commandModel.getBean();
                  selectedCommand.setText(SELECTED_COMMAND + uiCommand.getDisplayName());
                  selectedGesture.setUiCommandDTO(uiCommand);
                }
              }
            });

    final NavigateFieldSet navigateSet =
        new NavigateFieldSet(selectedGesture.getNavigate(), groups);
    navigateSet.setStyleAttribute("marginTop", "10px");
    navigateSet.setCheckboxToggle(true);
    navigateSet.addListener(
        Events.BeforeExpand,
        new Listener<FieldSetEvent>() {
          @Override
          public void handleEvent(FieldSetEvent be) {
            if (!selectedGesture.getNavigate().isSet()) {
              selectedGesture.getNavigate().setToLogical(ToLogicalType.setting);
            }
            navigateSet.update(selectedGesture.getNavigate());
          }
        });
    navigateSet.addListener(
        Events.BeforeCollapse,
        new Listener<FieldSetEvent>() {
          @Override
          public void handleEvent(FieldSetEvent be) {
            selectedGesture.getNavigate().clear();
          }
        });
    navigateSet.collapse();

    gesturePropertyForm.add(commandField);
    gesturePropertyForm.add(selectedCommand);
    gesturePropertyForm.add(navigateSet);
    BorderLayoutData centerData = new BorderLayoutData(LayoutRegion.CENTER);
    add(gesturePropertyForm, centerData);

    gestureTypeListView.addListener(
        Events.Select,
        new Listener<ListViewEvent<BeanModel>>() {
          public void handleEvent(ListViewEvent<BeanModel> be) {
            Gesture gesture =
                gestureMaps.get(((Gesture) be.getModel().getBean()).getType().toString());
            if (!gesture.equals(selectedGesture)) {
              selectedGesture = gesture;
              devicesAndMacrosTree.collapseAll();
              if (selectedGesture.getUiCommandDTO() != null) {
                selectedCommand.setText(
                    SELECTED_COMMAND + selectedGesture.getUiCommandDTO().getDisplayName());
              } else {
                selectedCommand.setText(SELECTED_COMMAND);
              }
              if (selectedGesture.getNavigate().isSet()) {
                navigateSet.expand();
                navigateSet.fireEvent(Events.BeforeExpand);
              } else {
                navigateSet.collapse();
              }
            }
          }
        });
  }