Ejemplo n.º 1
0
  private void showAddNewComment() {
    newCommentLayout.clear();
    final TextArea comment = new TextArea();
    comment.setWidth("100%");
    newCommentLayout.add(comment);

    Button ok = new Button(constants.OK());
    Button cancel = new Button(constants.Cancel());

    ok.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent sender) {
            sendNewComment(comment.getText());
          }
        });

    cancel.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent sender) {
            showNewCommentButton();
          }
        });

    HorizontalPanel hp = new HorizontalPanel();
    hp.add(ok);
    hp.add(cancel);

    newCommentLayout.add(hp);

    comment.setFocus(true);
  }
Ejemplo n.º 2
0
  public DeletePopup(final CommandWithCommitMessage command) {
    super(CommonImages.INSTANCE.edit(), "Delete this item");

    checkInCommentTextBox.setTitle("Check in comment");
    checkInCommentTextBox.setWidth("200px");
    addAttribute("Check in comment:", checkInCommentTextBox);

    final HorizontalPanel hp = new HorizontalPanel();
    final Button create = new Button("Delete item");
    create.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent arg0) {

            if (!Window.confirm("Are you sure you want to delete this asset?")) {
              return;
            }

            hide();
            command.execute(checkInCommentTextBox.getText());
          }
        });
    hp.add(create);

    Button cancel = new Button("Cancel");
    cancel.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent arg0) {
            hide();
          }
        });
    hp.add(new HTML("&nbsp"));
    hp.add(cancel);
    addAttribute("", hp);
  }
Ejemplo n.º 3
0
  private Panel createNewNameInput(final ScrollPanel contentPanel) {
    VerticalPanel form = new VerticalPanel();
    HorizontalPanel nameForm = new HorizontalPanel();
    nameForm.add(new Label("Name"));
    final TextBox nameTextBox = new TextBox();
    nameTextBox.setName("personName");
    nameForm.add(nameTextBox);
    form.add(nameForm);
    Button saveButton =
        new Button(
            "Store",
            new ClickListener() {
              public void onClick(Widget sender) {
                String name = nameTextBox.getText();
                RaffleServiceGwtRemoteAsync service = RaffleServiceGwtRemote.App.getInstance();
                AsyncCallback callback =
                    new AsyncCallback() {
                      public void onFailure(Throwable caught) {
                        GWT.log("Failure while creating a new name", caught);
                      }

                      public void onSuccess(Object result) {
                        contentPanel.setWidget(new Label("Name is stored"));
                      }
                    };
                service.storeName(name, callback);
              }
            });
    form.add(saveButton);
    return form;
  }
Ejemplo n.º 4
0
  public void run(final RootPanel rp, final String nick) {

    if (Cookies.getCookie(nick) == null) Cookies.setCookie(nick, "" + 0);

    cl.setPageSize(500);

    final Button sendMessage =
        new Button(
            "sendMessage",
            new ClickHandler() {

              public void onClick(ClickEvent event) {

                if (!message.getText().equals("")) {
                  new Post().postJson(SERVERURL, nick.toString(), message.getText());
                  message.setText("");
                }
              }
            });

    rp.get("mainDiv2").setVisible(true);
    message.getElement().setAttribute("placeholder", "Introduce your message");
    message.getElement().setAttribute("id", "message");

    cl.getElement().setAttribute("id", "chatBox");

    sendMessage.getElement().setAttribute("id", "sendMessage");
    sendMessage.setText("Send");

    vp.getElement().setAttribute("id", "verticalPanel");
    hp.getElement().setAttribute("id", "horizontalPanel");

    panel.getElement().setAttribute("id", "scroller");

    hp.add(message);
    hp.add(sendMessage);
    panel.add(cl);
    vp.add(panel);

    vp.add(hp);
    rp.get("mainDiv2").add(vp);

    Timer t =
        new Timer() {
          @Override
          public void run() {
            getMessages();

            if (chatList != null && Integer.parseInt(Cookies.getCookie(nick)) < chatList.size()) {
              cl.setRowCount(chatList.size() + 1, true);
              cl.setRowData(
                  Integer.parseInt(Cookies.getCookie(nick)),
                  chatList.subList(Integer.parseInt(Cookies.getCookie(nick)), chatList.size()));
              panel.setVerticalScrollPosition(panel.getMaximumVerticalScrollPosition() - 1);
              Cookies.setCookie(nick, "" + chatList.size());
            }
          }
        };
    t.scheduleRepeating(1000);
  }
  public WorkspaceManager() {
    PrettyFormLayout form = new PrettyFormLayout();
    form.addHeader(
        GuvnorImages.INSTANCE.WorkspaceManager(),
        new HTML("<b>" + constants.ManageWorkspaces() + "</b>"));
    form.startSection(constants.Workspaces());

    form.addAttribute("", buildDoubleList());

    HorizontalPanel hPanel = new HorizontalPanel();
    Button create = new Button(constants.AddWorkspace());
    create.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent w) {
            WorkspaceEditor newCat =
                new WorkspaceEditor(
                    new Command() {
                      public void execute() {
                        refreshWorkspaceList();
                      }
                    });

            newCat.show();
          }
        });

    Button remove = new Button(constants.DeleteSelectedWorkspace());
    remove.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent w) {
            if (availableWorkspacesListBox.getSelectedIndex() == -1) {
              Window.alert(constants.PleaseSelectAWorkspaceToRemove());
              return;
            }
            removeWorkspace();
          }
        });

    Button updateWorkspace = new Button(constants.UpdateSelectedWorkspace());
    updateWorkspace.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent w) {
            if (availableWorkspacesListBox.getSelectedIndex() == -1) {
              Window.alert(constants.PleaseSelectAWorkspaceToUpdate());
              return;
            }

            updateWorkspace();
          }
        });
    hPanel.add(create);
    hPanel.add(remove);
    hPanel.add(updateWorkspace);

    form.addAttribute("", hPanel);

    form.endSection();
    initWidget(form);
  }
  public static Widget getLoadingMessage(String customMessage) {
    HorizontalPanel hp = new HorizontalPanel();
    hp.add(new Image(DisclosureImages.INSTANCE.getLoadingImage()));
    hp.add(new HTMLPanel(customMessage));
    hp.setSpacing(5);

    return hp;
  }
Ejemplo n.º 7
0
  private void showNewCommentButton() {
    newCommentLayout.clear();

    HorizontalPanel hp = new HorizontalPanel();

    Button createNewComment = new Button(constants.AddADiscussionComment());
    createNewComment.setEnabled(!this.readOnly);
    hp.add(createNewComment);

    if (UserCapabilities.INSTANCE.hasCapability(Capability.SHOW_ADMIN)) {
      Button adminClearAll = new Button(constants.EraseAllComments());
      adminClearAll.setEnabled(!readOnly);
      hp.add(adminClearAll);
      adminClearAll.addClickHandler(
          new ClickHandler() {
            public void onClick(ClickEvent sender) {
              if (Window.confirm(constants.EraseAllCommentsWarning())) {
                assetService.clearAllDiscussionsForAsset(
                    artifact.getUuid(),
                    new GenericCallback<java.lang.Void>() {
                      public void onSuccess(Void v) {
                        updateCommentList(new ArrayList<DiscussionRecord>());
                      }
                    });
              }
            }
          });
    }

    final String feedURL =
        GWT.getModuleBaseURL()
            + "feed/discussion?package="
            + ((Asset) artifact).getMetaData().getModuleName()
            + "&assetName="
            + URL.encode(artifact.getName())
            + "&viewUrl="
            + Util.getSelfURL();
    Image image = new Image(images.feed());
    image.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent arg0) {
            Window.open(feedURL, "_blank", null);
          }
        });
    hp.add(image);

    newCommentLayout.add(hp);

    newCommentLayout.setCellHorizontalAlignment(hp, HasHorizontalAlignment.ALIGN_RIGHT);
    createNewComment.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent sender) {
            showAddNewComment();
          }
        });
  }
Ejemplo n.º 8
0
 /** Constructs a Toolbar part. */
 public Toolbar() {
   resources = GWT.create(MyResources.class);
   buttons = new ArrayList<Widget>();
   toolBar = new HorizontalPanel();
   toolBar.setHeight("30px");
   toolBar.setWidth("100%");
   toolBar.setStylePrimaryName("lab-Tools-Panel");
   toolBar.add(buildToolBar());
   initWidget(toolBar);
 }
Ejemplo n.º 9
0
  public StatusBarWidget() {
    Binder binder = GWT.create(Binder.class);
    HorizontalPanel hpanel = binder.createAndBindUi(this);
    hpanel.setVerticalAlignment(HorizontalPanel.ALIGN_TOP);

    hpanel.setCellWidth(hpanel.getWidget(2), "100%");

    initWidget(hpanel);

    height_ = 16;
  }
Ejemplo n.º 10
0
 public void updateRow(int row) {
   WalrusInfoWeb walrus = this.walrusList.get(row);
   Grid g = (Grid) this.grid.getWidget(row, 0);
   HorizontalPanel p = (HorizontalPanel) g.getWidget(0, 1);
   walrus.setHost(((TextBox) p.getWidget(0)).getText());
   int widgetStartIndex = 1;
   ArrayList<String> properties = walrus.getProperties();
   for (int i = 0; i < (properties.size() / 4); ++i) {
     if (properties.get(4 * i).startsWith("KEYVALUE"))
       properties.set(4 * i + 2, ((TextBox) g.getWidget(widgetStartIndex + i, 1)).getText());
   }
 }
Ejemplo n.º 11
0
  @Override
  protected Widget createMainWidget() {
    VerticalPanel panel = new VerticalPanel();
    panel.setStyleName(ThemeStyles.INSTANCE.fileUploadPanel());

    // directory panel
    HorizontalPanel directoryPanel = new HorizontalPanel();
    directoryPanel.setWidth("100%");
    directoryPanel.setStyleName(ThemeStyles.INSTANCE.fileUploadField());

    // directory name (informational field)
    panel.add(new Label("Target directory:"));
    directoryNameWidget_ = new DirectoryNameWidget();
    directoryNameWidget_.setDirectory(targetDirectory_);
    directoryPanel.add(directoryNameWidget_);

    // browse directory button
    // JJA: removed browse button (was causing confusion for users who
    // thought it was what they should press to browse local files)
    /*
    Button browseButton = new Button("Browse...",
                                     new BrowseDirectoryClickHandler());
    browseButton.getElement().getStyle().setMarginRight(5, Unit.PX);
    directoryPanel.add(browseButton);
    directoryPanel.setCellHorizontalAlignment(
                                        browseButton,
                                        HasHorizontalAlignment.ALIGN_RIGHT);
    */
    panel.add(directoryPanel);

    // filename field
    panel.add(new Label("File to upload:"));
    fileUpload_ = new FileUpload();
    fileUpload_.setStyleName(ThemeStyles.INSTANCE.fileUploadField());
    fileUpload_.setName("file");
    panel.add(fileUpload_);

    // zip file tip field
    HTML tip =
        new HTML(
            "<b>TIP</b>: To upload multiple files or a "
                + "directory, create a zip file. The zip file will "
                + "be automatically expanded after upload.");
    tip.addStyleName(ThemeStyles.INSTANCE.fileUploadField());
    tip.addStyleName(ThemeStyles.INSTANCE.fileUploadTipLabel());
    panel.add(tip);

    // target directory hidden field
    targetDirectoryHidden_ = new Hidden("targetDirectory", targetDirectory_.getPath());
    panel.add(targetDirectoryHidden_);

    return panel;
  }
Ejemplo n.º 12
0
 private void addSuggestPanel() {
   HorizontalPanel langPanel = new HorizontalPanel();
   langPanel.setSpacing(5);
   langPanel.add(new HTML("Enter language:"));
   MultiWordSuggestOracle langChoices = new ProgrammingLanguageOracle();
   SuggestBox langBox = new SuggestBox(langChoices);
   langPanel.add(langBox);
   Button searchButton = new Button("Send to Google");
   searchButton.addClickHandler(new SearchHandler(langBox));
   langPanel.add(searchButton);
   RootPanel.get("suggest-panel").add(langPanel);
 }
Ejemplo n.º 13
0
  private void init(
      final boolean isOpen, final DisclosurePanelImages images, final String headerText) {
    this.isOpen = isOpen;
    clickableHeader = new DefaultHeader(images, headerText);
    initWidget(mainPanel);
    headerPanel.add(clickableHeader);
    headerPanel.add(staticHeader);
    mainPanel.add(headerPanel);

    setStyleName(STYLENAME_DEFAULT);
    setContentDisplay();
  }
Ejemplo n.º 14
0
  public EditorController(String divID, int width, int height) {

    VerticalPanel vp = new VerticalPanel();
    HorizontalPanel hp = new HorizontalPanel();

    SimplePanel topToolBoxWrapper = new SimplePanel();

    ToggleButtonListener toggleButtonListener = new ToggleButtonListener();

    topToolBox = new TopToolBox(this, toggleButtonListener);
    topToolBox.setStyleName("jsmoleditor-topToolBox");

    topToolBoxWrapper.setWidget(topToolBox);
    topToolBoxWrapper.setStyleName("jsmoleditor-topTooBoxWrapper");
    topToolBoxWrapper.setWidth(width + "px");

    SimplePanel sideToolBoxWrapper = new SimplePanel();
    elementToolBox = new ElementToolBox(this, toggleButtonListener);

    sideToolBoxWrapper.setWidget(elementToolBox);
    sideToolBoxWrapper.setStyleName("jsmoleditor-elementToolBoxWrapper");
    sideToolBoxWrapper.setHeight((height - 24) + "px");

    VerticalPanel vp2 = new VerticalPanel();

    ExtendedCanvas canvas = new ExtendedCanvas(width - 24, height - 48);
    StatusBar statusBar = new StatusBar(width - 24, 24);
    statusBar.setHTML("Copyright chemhack.com");
    renderer = new CanvasRenderer(this, canvas);

    vp2.add(canvas);
    vp2.add(statusBar);

    hp.add(sideToolBoxWrapper);
    hp.add(vp2);

    vp.add(topToolBoxWrapper);
    vp.add(hp);

    RootPanel rootPanel = RootPanel.get(divID);
    rootPanel.setPixelSize(width, height);
    rootPanel.add(vp);

    KeyboardShortCutEventPreview preview =
        new KeyboardShortCutEventPreview(this); // TODO deal with multiple editor instance?

    DOM.addEventPreview(preview);

    EditorMouseListener listener = new EditorMouseListener(this);
    canvas.addMouseListener(listener);
    canvas.addMouseWheelListener(listener);
  }
Ejemplo n.º 15
0
  public static Widget getMessage(ImageResource imageResource, String customMessage) {
    HorizontalPanel hp = new HorizontalPanel();
    hp.setSpacing(5);

    hp.add(new Image(imageResource.getSafeUri()));

    InlineLabel label = new InlineLabel(customMessage);
    label.getElement().getStyle().setFontWeight(Style.FontWeight.NORMAL);
    label.getElement().getStyle().setFloat(Style.Float.LEFT);
    hp.add(label);

    return hp;
  }
Ejemplo n.º 16
0
  private void doBuild(
      final Panel buildResults,
      final String statusOperator,
      final String statusValue,
      final boolean enableStatusSelector,
      final String categoryOperator,
      final String category,
      final boolean enableCategorySelector,
      final String customSelector) {
    buildResults.clear();

    final HorizontalPanel busy = new HorizontalPanel();
    busy.add(new Label(constants.ValidatingAndBuildingPackagePleaseWait()));
    busy.add(new Image(images.redAnime()));

    buildResults.add(busy);

    Scheduler scheduler = Scheduler.get();
    scheduler.scheduleDeferred(
        new Command() {
          public void execute() {
            RepositoryServiceFactory.getPackageService()
                .buildPackage(
                    conf.getUuid(),
                    true,
                    buildMode,
                    statusOperator,
                    statusValue,
                    enableStatusSelector,
                    categoryOperator,
                    category,
                    enableCategorySelector,
                    customSelector,
                    new GenericCallback<BuilderResult>() {
                      public void onSuccess(BuilderResult result) {
                        LoadingPopup.close();
                        if (result == null || !result.hasLines()) {
                          showSuccessfulBuild(buildResults);
                        } else {
                          showBuilderErrors(result, buildResults, clientFactory);
                        }
                      }

                      public void onFailure(Throwable t) {
                        buildResults.clear();
                        super.onFailure(t);
                      }
                    });
          }
        });
  }
Ejemplo n.º 17
0
 private void addPanelForPopups() {
   HorizontalPanel buttonPanel = new HorizontalPanel();
   buttonPanel.setSpacing(10);
   Button button1 = new Button("DialogBox");
   button1.addClickHandler(new DialogHandler());
   buttonPanel.add(button1);
   Button button2 = new Button("PopupPanel");
   button2.addClickHandler(new PopupHandler());
   buttonPanel.add(button2);
   Button button3 = new Button("Native Dialog (Alert) Box");
   button3.addClickHandler(new AlertHandler());
   buttonPanel.add(button3);
   RootPanel.get("popup-buttons").add(buttonPanel);
 }
Ejemplo n.º 18
0
  public OrderDetails() {
    main = new HorizontalPanel();
    initWidget(main);
    main.setWidth("100%");

    parent = null;
  }
Ejemplo n.º 19
0
 public WalrusInfoTable(String sessionId) {
   this.sessionId = sessionId;
   this.setStyleName("euca-config-component");
   this.setSpacing(2);
   this.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
   //		this.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
   Label walrusesHeader = new Label("Walrus Configuration:");
   walrusesHeader.setStyleName("euca-section-header");
   this.add(walrusesHeader);
   this.noWalrusesLabel.setText("No Walrus hosts registered");
   this.noWalrusesLabel.setStyleName("euca-greeting-disabled");
   HorizontalPanel grid_and_hint = new HorizontalPanel();
   grid_and_hint.add(this.grid);
   grid_and_hint.add(this.hint);
   this.hint.setWidth("100");
   this.add(grid_and_hint);
   HorizontalPanel hpanel = new HorizontalPanel();
   hpanel.setSpacing(2);
   hpanel.add(add_button);
   hpanel.add(new EucaButton("Save Walrus configuration", new SaveCallback(this)));
   hpanel.add(this.statusLabel);
   //		this.statusLabel.setWidth ("250");
   this.statusLabel.setText("");
   this.statusLabel.setStyleName("euca-greeting-pending");
   this.add(hpanel);
   rebuildTable();
   EucalyptusWebBackend.App.getInstance()
       .getWalrusList(this.sessionId, new GetWalrusListCallback(this));
 }
Ejemplo n.º 20
0
 public ManagePanel(StockServiceAsync stockSvc) {
   lastModified.addStyleName("small-label");
   hp.setWidth("100%");
   rankGrid = new Grid(1, HEADERS.length);
   setSpacing(4);
   this.stockSvc = stockSvc;
   hp.add(refreshBtn);
   this.add(hp);
   this.add(rankGrid);
   refreshBtn.addClickHandler(
       new ClickHandler() {
         public void onClick(ClickEvent event) {
           removeGrids();
           refreshBtn.setEnabled(false);
           loadData();
         }
       });
   Util.createGridHeader(rankGrid, HEADERS);
 }
Ejemplo n.º 21
0
 private void addMenuPanel() {
   HorizontalPanel searchPanel = new HorizontalPanel();
   searchPanel.setSpacing(5);
   searchPanel.add(new HTML("Enter language:"));
   MultiWordSuggestOracle langChoices = new ProgrammingLanguageOracle();
   final SuggestBox langBox = new SuggestBox(langChoices);
   searchPanel.add(langBox);
   MenuBar mainMenu = new MenuBar();
   MenuBar searchMenu = new SearchMenuBar(langBox);
   mainMenu.addItem("Search", searchMenu);
   Command alertCommand =
       new Command() {
         public void execute() {
           Window.alert("Selection is " + langBox.getText());
         }
       };
   mainMenu.addItem("Alert", alertCommand);
   MenuBar modifierMenu = new ModifierMenuBar(langBox);
   mainMenu.addItem("Modify", modifierMenu);
   searchPanel.add(mainMenu);
   RootPanel.get("menu-panel").add(searchPanel);
 }
Ejemplo n.º 22
0
  public VersionBrowser(
      ClientFactory clientFactory, EventBus eventBus, String uuid, boolean isPackage) {
    this.clientFactory = clientFactory;
    this.eventBus = eventBus;
    this.uuid = uuid;
    this.isPackage = isPackage;

    HorizontalPanel wrapper = new HorizontalPanel();

    ClickHandler clickHandler =
        new ClickHandler() {

          public void onClick(ClickEvent event) {
            clickLoadHistory();
          }
        };
    layout = new FlexTable();
    ClickableLabel vh = new ClickableLabel(constants.VersionHistory1(), clickHandler);
    layout.setWidget(0, 0, vh);
    layout.getCellFormatter().setStyleName(0, 0, "metadata-Widget"); // NON-NLS
    FlexCellFormatter formatter = layout.getFlexCellFormatter();
    formatter.setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_LEFT);

    refresh = new ImageButton(images.refresh());

    refresh.addClickHandler(clickHandler);

    layout.setWidget(0, 1, refresh);
    formatter.setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_RIGHT);

    wrapper.setStyleName("version-browser-Border");

    wrapper.add(layout);

    layout.setWidth("100%");
    wrapper.setWidth("100%");

    initWidget(wrapper);
  }
Ejemplo n.º 23
0
 private HorizontalPanel buildParameterEntry(String key, String value) {
   HorizontalPanel entry = new HorizontalPanel();
   entry.setSpacing(5);
   entry.add(buildParameterTextBox(key));
   entry.add(buildEqualsLabel());
   entry.add(buildParameterTextBox(value));
   entry.add(buildRemoveParameterButton(entry));
   return entry;
 }
Ejemplo n.º 24
0
  public void onModuleLoad() {
    // Create table for stock data.
    stocksFlexTable.setText(0, 0, "Symbol");
    stocksFlexTable.setText(0, 1, "Price");
    stocksFlexTable.setText(0, 2, "Change");
    stocksFlexTable.setText(0, 3, "Remove");

    // Assemble Add Stock panel.
    addPanel.add(newSymbolTextBox);
    addPanel.add(addStockButton);

    // Assemble Main panel.
    mainPanel.add(stocksFlexTable);
    mainPanel.add(addPanel);
    mainPanel.add(lastUpdateLabel);

    // Associate the Main panel with the HTML host page.
    RootPanel.get("stockList").add(mainPanel);

    // Move cursor focus to the input box.
    newSymbolTextBox.setFocus(true);

    initHandlers();
  }
  public DebugAgentsMessagesMapWindow() {

    statusBar.add(mousexLabel);
    statusBar.add(mouseyLabel);
    mousexLabel.setWidth("100px");

    infoWindow = MessageInfoWindowOnCanvas.getInstance();
    infoWindow.setCanvas(gwtBitsCanvas);

    calculatePositions();
    mainAgentsPanel.add(gwtBitsCanvas);

    mainAgentsPanel.add(statusBar);
    mainAgentsPanel.add(propertyPanel);

    initWidget(mainAgentsPanel);

    gwtBitsCanvas.addMouseMoveHandler(
        new MouseMoveHandler() {
          public void onMouseMove(MouseMoveEvent event) {
            mouseX = event.getRelativeX(gwtBitsCanvas.getElement());
            mouseY = event.getRelativeY(gwtBitsCanvas.getElement());
            mousexLabel.setText("" + mouseX);
            mouseyLabel.setText("" + mouseY);
            //
            //                IAgent newagent =getSelectedAgent();
            //                if (currentAgent != newagent){
            //                    setNewAgentSelected(newagent);
            //                }
          }
        });

    gwtBitsCanvas.addMouseOverAgentHandler(
        new MouseOverCanvasItemHandler() {
          @Override
          public void mouseOverCanvasItem(GwtBitsCanvasItemBaseClass canvasItem) {
            propertyPanel.clear();
            propertyPanel.add(new Label(canvasItem.getDebugString()));
          }
        });

    Esb.register(this);
    Esb.registerScreenPosition(this, 0.9, 0.9);
  }
  public DescriptionCellEditor() {
    super();

    ensureResources();
    setStyleName("");

    addCloseHandler(
        new CloseHandler<PopupPanel>() {
          @Override
          public void onClose(CloseEvent<PopupPanel> event) {
            if (event.isAutoClosed()) {
              commit();
              hide();
            }
          }
        });

    VerticalPanel verticalPanel = new VerticalPanel();

    textArea = new RichTextArea();
    textArea.setTabIndex(0);
    textArea.addStyleName(resources.style().bDescriptionCellEditor__editor());
    textArea.addKeyDownHandler(
        new KeyDownHandler() {
          @Override
          public void onKeyDown(KeyDownEvent event) {
            int keyCode = event.getNativeKeyCode();
            if (keyCode == KeyCodes.KEY_ESCAPE) {
              cancelButton.setFocus(true); // or grid did not get back focus
              hide();
            } else if (keyCode == KeyCodes.KEY_ENTER && event.isControlKeyDown()) {
              okButton.setFocus(true); // or grid did not get back focus
              okButton.click();
            }
          }
        });
    VerticalPanel textAreaPanel = new VerticalPanel();
    textAreaPanel.add(textArea);

    HorizontalPanel buttonPanel = new HorizontalPanel();

    okButton = new Button(strings.ok());
    okButton.addStyleName(resources.style().bDescriptionCellEditor__ok());
    okButton.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            commit();
            hide();
          }
        });
    buttonPanel.add(okButton);

    cancelButton = new Button(strings.cancel());
    cancelButton.addStyleName(resources.style().bDescriptionCellEditor__cancel());
    cancelButton.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            hide();
          }
        });
    buttonPanel.add(cancelButton);

    textAreaPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
    textAreaPanel.add(buttonPanel);

    RichTextToolbar textToolbar = new RichTextToolbar(textArea);
    SimplePanel toolBarPanel = new SimplePanel(textToolbar);
    toolBarPanel.addStyleName(resources.style().bDescriptionCellEditor__toolbar());

    verticalPanel.add(toolBarPanel);
    verticalPanel.add(textAreaPanel);

    add(verticalPanel);
  }
Ejemplo n.º 27
0
 private void removeAllWidgets(HorizontalPanel panel) {
   for (int i = panel.getWidgetCount() - 1; i >= 0; i--) panel.remove(i);
 }
  public MediaSourcePanel(
      final DeviceAudioOutServiceAsync service, final MediaSourcePanelListener listener) {
    this.service = service;
    this.listener = listener;

    source = new ListBox(false);
    source.addChangeHandler(
        new ChangeHandler() {
          @Override
          public void onChange(ChangeEvent event) {
            int selectedIndex = source.getSelectedIndex();

            if (selectedIndex >= 0)
              service.setMediaSource(
                  source.getItemText(selectedIndex),
                  new AsyncCallback<Void>() {
                    @Override
                    public void onFailure(Throwable caught) {}

                    @Override
                    public void onSuccess(Void result) {
                      updateNavItem();
                    }
                  });
          }
        });
    add(source);
    navigation = new ListBox(true);
    add(navigation);

    add = new Button("Add to queue");
    add.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            service.addToQueue(
                getSelectedNavItem(),
                new AsyncCallback<Void>() {
                  @Override
                  public void onFailure(Throwable caught) {}

                  @Override
                  public void onSuccess(Void result) {
                    listener.itemAddedToQueue();
                  }
                });
          }
        });

    open = new Button("Open");
    open.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            selectNavItem(getSelectedNavItem());
          }
        });

    back = new Button("Back");
    back.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            moveBackToParent();
          }
        });

    HorizontalPanel buttonPanel = new HorizontalPanel();
    buttonPanel.add(add);
    buttonPanel.add(open);
    buttonPanel.add(back);
    add(buttonPanel);
  }
Ejemplo n.º 29
0
  public void onModuleLoad() {
    final HorizontalPanel hPanel = new HorizontalPanel();
    final Label messagesReceived = new Label("Messaged Received: ");
    final Label messagesReceivedVal = new Label();

    class Counter {
      int count = 0;

      public void increment() {
        messagesReceivedVal.setText(String.valueOf(++count));
      }
    }

    final Counter counter = new Counter();

    for (int i = 0; i < 7; i++) {
      final VerticalPanel panel = new VerticalPanel();

      final Button startStopButton = new Button("Start" + i);
      final TextBox resultBox = new TextBox();
      resultBox.setEnabled(false);

      final String receiverName = "RandomNumberReceiver" + i;

      final Style resultStyle = resultBox.getElement().getStyle();

      /** Create a callback receiver to receive the data from the server. */
      final MessageCallback receiver =
          new MessageCallback() {
            public void callback(Message message) {
              counter.increment();
              Double value = message.get(Double.class, "Data");
              resultBox.setText(String.valueOf(value));

              if (value > 0.5d) {
                resultStyle.setProperty("backgroundColor", "green");
              } else {
                resultStyle.setProperty("backgroundColor", "red");
              }
            }
          };

      /** Subscribe to the receiver using the recevierName. */
      ErraiBus.get().subscribe(receiverName, receiver);

      final int num = i;

      startStopButton.addClickHandler(
          new ClickHandler() {
            public void onClick(ClickEvent clickEvent) {
              /** Send a message to Start/Stop the task on the server. */
              MessageBuilder.createMessage()
                  .toSubject("AsyncService")
                  .command(startStopButton.getText())
                  .with(MessageParts.ReplyTo, receiverName)
                  .noErrorHandling()
                  .sendNowWith(ErraiBus.get());

              /**
               * Flip-flop the value of the button every time it's pushed between 'Start' and 'Stop'
               */
              startStopButton.setText(
                  ("Start" + num).equals(startStopButton.getText()) ? "Stop" + num : "Start" + num);
            }
          });

      panel.add(startStopButton);
      panel.add(resultBox);

      hPanel.add(panel);
    }

    final VerticalPanel outerPanel = new VerticalPanel();
    outerPanel.add(hPanel);

    final HorizontalPanel messageCounter = new HorizontalPanel();
    messageCounter.add(messagesReceived);
    messageCounter.add(messagesReceivedVal);

    outerPanel.add(messageCounter);

    RootPanel.get().add(outerPanel);
  }
Ejemplo n.º 30
0
  /** **************************************************************** ObjectWidget */
  public void setValue(FromServer element) {
    boolean edit;
    Supplier supp;
    CustomCaptionPanel frame;

    super.setValue(element);
    main.clear();

    if (element != null) {
      supp = (Supplier) element.getObject("supplier");
      edit = (supp.iAmReference() && element.sharingStatus() <= ACL.ACL_READWRITE);
    } else {
      edit = false;
    }

    frame = new CustomCaptionPanel("Attributi");
    main.add(frame);
    main.setCellWidth(frame, "50%");

    supplier = new NameLabelWidget();
    frame.addPair("Fornitore", widgetWarp("supplier", supplier));

    status = Order.doOrderStatusSelector(edit);
    frame.addPair("Stato", widgetWarp("status", status));

    if (edit == true) anticipated = new PercentageBox();
    else anticipated = new PercentageViewer();

    frame.addPair("Anticipo", widgetWarp("anticipated", (Widget) anticipated));

    frame = new CustomCaptionPanel("Date");
    main.add(frame);
    main.setCellWidth(frame, "50%");

    if (edit == true) {
      BankMovementSelector bms;

      startdate = new DateSelector();
      enddate = new DateSelector();
      shippingdate = new DateSelector();

      bms = new BankMovementSelector();
      bms.setDefaultType(BankMovement.ORDER_PAYMENT);
      bms.setDefaultTargetSupplier(element.getObject("supplier"));
      bms.setDefaultNote("Pagamento ordine a " + element.getObject("supplier").getString("name"));
      payment = bms;
    } else {
      startdate = new DateViewer();
      enddate = new DateViewer();
      shippingdate = new DateViewer();
      payment = new BankMovementCellViewer();
    }

    frame.addPair("Data apertura", widgetWarp("startdate", (Widget) startdate));
    frame.addPair("Data chiusura", widgetWarp("enddate", (Widget) enddate));
    frame.addPair("Data consegna", widgetWarp("shippingdate", (Widget) shippingdate));

    if (Session.getGAS().getBool("use_bank") == true)
      frame.addPair("Pagamento", widgetWarp("payment_event", (Widget) payment));

    if (element != null) {
      supplier.setValue(element.getObject("supplier"));
      status.setVal(element.getInt("status"));
      anticipated.setValue(element.getString("anticipated"));
      startdate.setValue(element.getDate("startdate"));
      enddate.setValue(element.getDate("enddate"));
      shippingdate.setValue(element.getDate("shippingdate"));
      payment.setValue(element.getObject("payment_event"));
    }
  }