예제 #1
0
  private LayoutContainer createContentContainer() {
    LayoutContainer contentContainer = new LayoutContainer();
    contentContainer.setBorders(false);
    contentContainer.setSize(340, 170);
    HBoxLayout tabbarContainerLayout = new HBoxLayout();
    tabbarContainerLayout.setHBoxLayoutAlign(HBoxLayoutAlign.TOP);
    contentContainer.setLayout(tabbarContainerLayout);

    LayoutContainer contentItemsContainer = new LayoutContainer();
    contentItemsContainer.setBorders(true);
    contentItemsContainer.setWidth(230);
    contentItemsContainer.setHeight(160);
    contentItemsContainer.setLayout(new FitLayout());
    contentItemsContainer.setStyleAttribute("backgroundColor", "white");
    // overflow-auto style is for IE hack.
    contentItemsContainer.addStyleName("overflow-auto");

    TreeStore<BeanModel> deviceContentTreeStore = new TreeStore<BeanModel>();
    deviceContentTree = TreePanelBuilder.buildDeviceContentTree(deviceContentTreeStore);
    contentItemsContainer.add(deviceContentTree);

    LayoutContainer buttonsContainer = new LayoutContainer();
    buttonsContainer.setSize(110, 160);
    buttonsContainer.setBorders(false);
    buttonsContainer.setLayout(new RowLayout(Orientation.VERTICAL));

    Button addCommandBtn = new Button("Add command");
    addCommandBtn.addSelectionListener(new AddCommandListener());

    Button addSensorBtn = new Button("Add sensor");
    addSensorBtn.addSelectionListener(new AddSensorListener());

    Button addSwitchBtn = new Button("Add switch");
    addSwitchBtn.addSelectionListener(new AddSwitchListener());

    Button addSliderBtn = new Button("Add slider");
    addSliderBtn.addSelectionListener(new AddSliderListener());

    Button deleteBtn = new Button("Delete");
    deleteBtn.addSelectionListener(new DeleteContentListener());

    buttonsContainer.add(addCommandBtn, new RowData(110, -1, new Margins(5)));
    buttonsContainer.add(addSensorBtn, new RowData(110, -1, new Margins(5)));
    buttonsContainer.add(addSwitchBtn, new RowData(110, -1, new Margins(5)));
    buttonsContainer.add(addSliderBtn, new RowData(110, -1, new Margins(5)));
    buttonsContainer.add(deleteBtn, new RowData(110, -1, new Margins(5)));

    contentContainer.add(contentItemsContainer);
    contentContainer.add(buttonsContainer);
    return contentContainer;
  }
예제 #2
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();
              }
            }
          }
        });
  }