Beispiel #1
0
  /** Sets up the tool bar. */
  private void setupToolbar() {
    btnNewForm = new PushButton(FormUtil.createImage(images.newform()));
    btnOpenForm = new PushButton(FormUtil.createImage(images.open()));
    btnSaveForm = new PushButton(FormUtil.createImage(images.save()));

    btnAddNewItem = new PushButton(FormUtil.createImage(images.add()));
    btnAddNewChildItem = new PushButton(FormUtil.createImage(images.addchild()));
    btnDeleteItem = new PushButton(FormUtil.createImage(images.delete()));
    btnMoveItemUp = new PushButton(FormUtil.createImage(images.moveup()));
    btnMoveItemDown = new PushButton(FormUtil.createImage(images.movedown()));

    btnAlignLeft = new PushButton(FormUtil.createImage(images.justifyleft()));
    btnAlignRight = new PushButton(FormUtil.createImage(images.justifyright()));
    btnAlignTop = new PushButton(FormUtil.createImage(images.alignTop()));
    btnAlignBottom = new PushButton(FormUtil.createImage(images.alignBottom()));
    btnSameWidth = new PushButton(FormUtil.createImage(images.samewidth()));
    btnSameHeight = new PushButton(FormUtil.createImage(images.sameheight()));
    btnSameSize = new PushButton(FormUtil.createImage(images.samesize()));

    btnCut = new PushButton(FormUtil.createImage(images.cut()));
    btnCopy = new PushButton(FormUtil.createImage(images.copy()));
    btnPaste = new PushButton(FormUtil.createImage(images.paste()));
    btnRefresh = new PushButton(FormUtil.createImage(images.refresh()));

    btnUndo = new PushButton(FormUtil.createImage(images.undo()));
    btnRedo = new PushButton(FormUtil.createImage(images.redo()));

    btnNewForm.setTitle(LocaleText.get("newForm"));
    btnSaveForm.setTitle(LocaleText.get("save"));

    btnAddNewItem.setTitle(LocaleText.get("addNew"));
    btnAddNewChildItem.setTitle(LocaleText.get("addNewChild"));
    btnDeleteItem.setTitle(LocaleText.get("deleteSelected"));
    btnMoveItemUp.setTitle(LocaleText.get("moveUp"));
    btnMoveItemDown.setTitle(LocaleText.get("moveDown"));

    btnCut.setTitle(LocaleText.get("cut"));
    btnCopy.setTitle(LocaleText.get("copy"));
    btnPaste.setTitle(LocaleText.get("paste"));
    btnRefresh.setTitle(LocaleText.get("refresh"));

    btnAlignLeft.setTitle(LocaleText.get("alignLeft"));
    btnAlignRight.setTitle(LocaleText.get("alignRight"));
    btnAlignTop.setTitle(LocaleText.get("alignTop"));
    btnAlignBottom.setTitle(LocaleText.get("alignBottom"));
    btnSameWidth.setTitle(LocaleText.get("makeSameWidth"));
    btnSameHeight.setTitle(LocaleText.get("makeSameHeight"));
    btnSameSize.setTitle(LocaleText.get("makeSameSize"));

    btnUndo.setTitle(LocaleText.get("undo"));
    btnRedo.setTitle(LocaleText.get("redo"));

    if (Context.isOfflineMode()) panel.add(btnNewForm);

    panel.add(btnOpenForm);

    panel.add(btnSaveForm);

    panel.add(separatorWidget);

    panel.add(btnAddNewItem);
    panel.add(btnAddNewChildItem);
    panel.add(btnDeleteItem);
    panel.add(separatorWidget);
    panel.add(btnMoveItemUp);
    panel.add(btnMoveItemDown);

    panel.add(separatorWidget);
    panel.add(btnCut);
    panel.add(btnCopy);
    panel.add(btnPaste);

    panel.add(separatorWidget);
    panel.add(btnRefresh);

    panel.add(separatorWidget);
    panel.add(btnAlignLeft);
    panel.add(btnAlignRight);
    panel.add(btnAlignTop);
    panel.add(btnAlignBottom);

    panel.add(separatorWidget);
    panel.add(btnSameWidth);
    panel.add(btnSameHeight);
    panel.add(btnSameSize);

    panel.add(separatorWidget);
    panel.add(btnUndo);
    panel.add(btnRedo);

    Label label = new Label(FormDesignerUtil.getTitle());
    panel.add(label);
    panel.setCellWidth(label, "100%");
    panel.setCellHorizontalAlignment(label, HasHorizontalAlignment.ALIGN_CENTER);

    label = new Label(LocaleText.get("language"));
    panel.add(label);
    panel.setCellHorizontalAlignment(label, HasHorizontalAlignment.ALIGN_RIGHT);

    populateLocales();

    cbLanguages.addChangeHandler(
        new ChangeHandler() {
          public void onChange(ChangeEvent event) {
            int index = getLocaleIndex(Context.getLocale().getKey());
            ListBox listBox = (ListBox) event.getSource();
            Locale newLocale =
                new Locale(
                    listBox.getValue(listBox.getSelectedIndex()),
                    listBox.getItemText(listBox.getSelectedIndex()));
            if (!controller.changeLocale(newLocale)) cbLanguages.setSelectedIndex(index);
          }
        });

    panel.add(cbLanguages);
    panel.setCellHorizontalAlignment(cbLanguages, HasHorizontalAlignment.ALIGN_RIGHT);

    // Set a 3 pixels spacing between tool bar buttons.
    panel.setSpacing(3);
  }