Search in sources :

Example 31 with FlowPanel

use of com.google.gwt.user.client.ui.FlowPanel in project rstudio by rstudio.

the class InstallPackageDialog method createMainWidget.

@Override
protected Widget createMainWidget() {
    // vertical panel
    VerticalPanel mainPanel = new VerticalPanel();
    mainPanel.setSpacing(2);
    mainPanel.setStylePrimaryName(RESOURCES.styles().mainWidget());
    // source type
    reposCaption_ = new CaptionWithHelp("Install from:", "Configuring Repositories", "configuring_repositories");
    reposCaption_.setIncludeVersionInfo(false);
    reposCaption_.setWidth("100%");
    mainPanel.add(reposCaption_);
    packageSourceListBox_ = new ListBox();
    packageSourceListBox_.setStylePrimaryName(RESOURCES.styles().packageSourceListBox());
    packageSourceListBox_.addStyleName(RESOURCES.styles().extraBottomPad());
    JsArrayString repos = installContext_.selectedRepositoryNames();
    if (repos.length() == 1) {
        packageSourceListBox_.addItem("Repository (" + repos.get(0) + ")");
    } else {
        StringBuilder reposItem = new StringBuilder();
        reposItem.append("Repository (");
        for (int i = 0; i < repos.length(); i++) {
            if (i != 0)
                reposItem.append(", ");
            reposItem.append(repos.get(i));
        }
        reposItem.append(")");
        packageSourceListBox_.addItem(reposItem.toString());
    }
    packageSourceListBox_.addItem("Package Archive File (" + installContext_.packageArchiveExtension() + ")");
    mainPanel.add(packageSourceListBox_);
    // source panel container
    sourcePanel_ = new SimplePanel();
    sourcePanel_.setStylePrimaryName(RESOURCES.styles().packageSourcePanel());
    // repos source panel
    reposSourcePanel_ = new FlowPanel();
    Label packagesLabel = new Label("Packages (separate multiple with space or comma):");
    packagesLabel.setStylePrimaryName(RESOURCES.styles().packagesLabel());
    reposSourcePanel_.add(packagesLabel);
    packagesTextBox_ = new MultipleItemSuggestTextBox();
    packagesSuggestBox_ = new SuggestBox(new PackageOracle(), packagesTextBox_);
    packagesSuggestBox_.setWidth("100%");
    packagesSuggestBox_.setLimit(20);
    packagesSuggestBox_.addStyleName(RESOURCES.styles().extraBottomPad());
    reposSourcePanel_.add(packagesSuggestBox_);
    sourcePanel_.setWidget(reposSourcePanel_);
    mainPanel.add(sourcePanel_);
    // archive source panel
    packageArchiveFile_ = new TextBoxWithButton("Package archive:", "Browse...", browseForArchiveClickHandler_);
    // create check box here because manageUIState accesses it
    installDependenciesCheckBox_ = new CheckBox();
    if (defaultInstallOptions_.getInstallFromRepository())
        packageSourceListBox_.setSelectedIndex(0);
    else
        packageSourceListBox_.setSelectedIndex(1);
    manageUIState();
    packageSourceListBox_.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent event) {
            manageUIState();
            if (!installFromRepository())
                packageArchiveFile_.click();
        }
    });
    mainPanel.add(new Label("Install to Library:"));
    // library list box
    libraryListBox_ = new ListBox();
    libraryListBox_.setWidth("100%");
    libraryListBox_.addStyleName(RESOURCES.styles().extraBottomPad());
    JsArrayString libPaths = installContext_.getWriteableLibraryPaths();
    int selectedIndex = 0;
    for (int i = 0; i < libPaths.length(); i++) {
        String libPath = libPaths.get(i);
        if (!installContext_.isDevModeOn()) {
            if (defaultInstallOptions_.getLibraryPath().equals(libPath))
                selectedIndex = i;
        }
        if (libPath.equals(installContext_.getDefaultLibraryPath()))
            libPath = libPath + " [Default]";
        libraryListBox_.addItem(libPath);
    }
    libraryListBox_.setSelectedIndex(selectedIndex);
    mainPanel.add(libraryListBox_);
    // install dependencies check box
    installDependenciesCheckBox_.addStyleName(RESOURCES.styles().installDependenciesCheckBox());
    installDependenciesCheckBox_.setText("Install dependencies");
    installDependenciesCheckBox_.setValue(defaultInstallOptions_.getInstallDependencies());
    mainPanel.add(installDependenciesCheckBox_);
    mainPanel.add(new HTML("<br/>"));
    return mainPanel;
}
Also used : MultipleItemSuggestTextBox(org.rstudio.core.client.widget.MultipleItemSuggestTextBox) Label(com.google.gwt.user.client.ui.Label) SimplePanel(com.google.gwt.user.client.ui.SimplePanel) HTML(com.google.gwt.user.client.ui.HTML) JsArrayString(com.google.gwt.core.client.JsArrayString) JsArrayString(com.google.gwt.core.client.JsArrayString) VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) SuggestBox(com.google.gwt.user.client.ui.SuggestBox) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) TextBoxWithButton(org.rstudio.core.client.widget.TextBoxWithButton) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) CheckBox(com.google.gwt.user.client.ui.CheckBox) FlowPanel(com.google.gwt.user.client.ui.FlowPanel) CaptionWithHelp(org.rstudio.core.client.widget.CaptionWithHelp) ListBox(com.google.gwt.user.client.ui.ListBox)

Example 32 with FlowPanel

use of com.google.gwt.user.client.ui.FlowPanel in project rstudio by rstudio.

the class PackageActionConfirmationDialog method createMainWidget.

@Override
protected Widget createMainWidget() {
    FlowPanel flowPanel = new FlowPanel();
    String explanatoryText = getExplanatoryText();
    if (explanatoryText.length() > 0) {
        Label text = new Label(explanatoryText);
        text.setStylePrimaryName(RESOURCES.styles().explanatoryText());
        flowPanel.add(text);
    }
    actionsTable_ = new CellTable<PendingAction>(15, GWT.<PackagesCellTableResources>create(PackagesCellTableResources.class));
    actionsTable_.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
    actionsTable_.setSelectionModel(new NoSelectionModel<PendingAction>());
    actionsTable_.setWidth("100%", true);
    ActionColumn actionColumn = new ActionColumn();
    actionsTable_.addColumn(actionColumn);
    actionsTable_.setColumnWidth(actionColumn, 30, Unit.PX);
    addTableColumns(actionsTable_);
    ScrollPanel scrollPanel = new ScrollPanel();
    scrollPanel.setWidget(actionsTable_);
    scrollPanel.setStylePrimaryName(RESOURCES.styles().mainWidget());
    flowPanel.add(scrollPanel);
    // query for updates
    actionsDS_.requestData(new SimpleRequestCallback<JsArray<T>>() {

        @Override
        public void onResponseReceived(JsArray<T> actions) {
            if (actions != null && actions.length() > 0) {
                ArrayList<PendingAction> pendingActions = new ArrayList<PendingAction>();
                for (int i = 0; i < actions.length(); i++) pendingActions.add(new PendingAction(actions.get(i), false));
                actionsTable_.setPageSize(pendingActions.size());
                actionsDataProvider_ = new ListDataProvider<PendingAction>();
                actionsDataProvider_.setList(pendingActions);
                actionsDataProvider_.addDataDisplay(actionsTable_);
                enableCancelButton(true);
                selectAllButton_.setEnabled(true);
                selectNoneButton_.setEnabled(true);
            } else {
                closeDialog();
                showNoActionsRequired();
            }
        }

        @Override
        public void onError(ServerError error) {
            closeDialog();
            super.onError(error);
        }
    });
    return flowPanel;
}
Also used : ListDataProvider(com.google.gwt.view.client.ListDataProvider) JsArray(com.google.gwt.core.client.JsArray) ServerError(org.rstudio.studio.client.server.ServerError) Label(com.google.gwt.user.client.ui.Label) ArrayList(java.util.ArrayList) GWT(com.google.gwt.core.client.GWT) FlowPanel(com.google.gwt.user.client.ui.FlowPanel) ScrollPanel(com.google.gwt.user.client.ui.ScrollPanel)

Example 33 with FlowPanel

use of com.google.gwt.user.client.ui.FlowPanel in project openremote by openremote.

the class DatapointBrowser method createChart.

protected void createChart() {
    addLabel(environment.getMessages().historicalData());
    Canvas canvas = Canvas.createIfSupported();
    if (canvas == null) {
        add(new Label(environment.getMessages().canvasNotSupported()));
        return;
    }
    canvas.getCanvasElement().setWidth(width);
    canvas.getCanvasElement().setHeight(height);
    FlowPanel canvasContainer = new FlowPanel();
    canvasContainer.setWidth(width + "px");
    canvasContainer.setHeight(height + "px");
    canvasContainer.getElement().getStyle().setProperty("margin", "0 auto");
    canvasContainer.add(canvas);
    add(canvasContainer);
    Form controlForm = new Form();
    controlForm.getElement().getStyle().setWidth(width, PX);
    controlForm.getElement().getStyle().setMarginTop(0.4, EM);
    controlForm.getElement().getStyle().setProperty("margin", "0 auto");
    add(controlForm);
    FormGroup controlFormGroup = new FormGroup();
    controlForm.add(controlFormGroup);
    FormLabel controlFormLabel = new FormLabel(environment.getMessages().showChartAggregatedFor());
    controlFormLabel.addStyleName("end-justified");
    controlFormGroup.setFormLabel(controlFormLabel);
    FormField controlFormField = new FormField();
    controlFormGroup.setFormField(controlFormField);
    intervalListBox = new FormValueListBox<>(new AbstractRenderer<DatapointInterval>() {

        @Override
        public String render(DatapointInterval interval) {
            return environment.getMessages().datapointInterval(interval.name());
        }
    });
    intervalListBox.addValueChangeHandler(event -> refresh(timestamp));
    intervalListBox.setValue(interval);
    intervalListBox.setAcceptableValues(Arrays.asList(DatapointInterval.values()));
    intervalListBox.setEnabled(true);
    controlFormField.add(intervalListBox);
    timeOutput = new FormOutputText();
    timeOutput.addStyleName("flex");
    timeOutput.getElement().getStyle().setFontSize(0.8, EM);
    controlFormField.add(timeOutput);
    FormGroupActions controlFormActions = new FormGroupActions();
    controlFormGroup.setFormGroupActions(controlFormActions);
    FormButton previousButton = new FormButton();
    previousButton.setIcon("arrow-circle-left");
    previousButton.setText(environment.getMessages().previous());
    previousButton.addClickHandler(event -> refresh(calculateTimestamp(true)));
    controlFormActions.add(previousButton);
    nextButton = new FormButton();
    nextButton.setIcon("arrow-circle-right");
    nextButton.setText(environment.getMessages().next());
    nextButton.addClickHandler(event -> refresh(calculateTimestamp(false)));
    controlFormActions.add(nextButton);
    chart = ChartUtil.createLineChart(canvas.getContext2d());
    // TODO: Ugly, sometimes the chart is not ready (chart == undefined but !null in Java...) so we wait a bit
    Browser.getWindow().setTimeout(() -> refresh(timestamp), 50);
}
Also used : DatapointInterval(org.openremote.model.datapoint.DatapointInterval) Canvas(com.google.gwt.canvas.client.Canvas) Label(com.google.gwt.user.client.ui.Label) AbstractRenderer(com.google.gwt.text.shared.AbstractRenderer) FlowPanel(com.google.gwt.user.client.ui.FlowPanel)

Example 34 with FlowPanel

use of com.google.gwt.user.client.ui.FlowPanel in project openremote by openremote.

the class MapInfoPanel method setItems.

public void setItems(List<MapInfoItem> infoItems) {
    contentPanel.clear();
    int itemLineHeightPixels = 20;
    int itemMarginPixels = 8;
    int itemHeightPixels = itemLineHeightPixels + (itemMarginPixels * 2);
    int totalMaxHeight = itemHeightPixels * MAX_ITEMS_BEFORE_SCROLLING;
    for (MapInfoItem infoItem : infoItems) {
        IconLabel itemIcon = new IconLabel(infoItem.getIcon());
        itemIcon.addStyleName(style.infoItemIcon());
        FormLabel itemLabel = new FormLabel(TextUtil.ellipsize(infoItem.getLabel(), 35));
        itemLabel.addStyleName("flex");
        itemLabel.addStyleName(style.infoItemLabel());
        Widget itemValue = createItemValue(infoItem);
        itemValue.addStyleName(style.infoItemValue());
        FlowPanel itemPanel = new FlowPanel();
        itemPanel.addStyleName("flex-none layout horizontal center");
        itemPanel.addStyleName(style.infoItem());
        itemPanel.add(itemIcon);
        itemPanel.add(itemLabel);
        itemPanel.add(itemValue);
        contentPanel.add(itemPanel);
    }
    // Show up to 6 items, then start scrolling
    panel.setHeight(Math.min((infoItems.size() * itemHeightPixels), totalMaxHeight) + "px");
    // If the panel is already shown, "blink" it so users know there is an update
    if (isOpen()) {
        contentPanel.addStyleName(widgetStyle.HighlightBackground());
        Browser.getWindow().setTimeout(() -> {
            contentPanel.removeStyleName(widgetStyle.HighlightBackground());
        }, 250);
    }
}
Also used : IconLabel(org.openremote.app.client.widget.IconLabel) Widget(com.google.gwt.user.client.ui.Widget) FlowPanel(com.google.gwt.user.client.ui.FlowPanel) FormLabel(org.openremote.app.client.widget.FormLabel)

Example 35 with FlowPanel

use of com.google.gwt.user.client.ui.FlowPanel in project openremote by openremote.

the class ValueEditors method createArrayEditor.

public static IsWidget createArrayEditor(ArrayValue currentValue, Consumer<ArrayValue> onValueModified, Optional<Long> timestamp, boolean readOnly, String label, String title, JsonEditor jsonEditor) {
    Consumer<Value> updateConsumer = readOnly ? null : value -> onValueModified.accept(Values.getArray(value).orElse(null));
    FlowPanel panel = new FlowPanel();
    panel.setStyleName("flex layout horizontal center or-ValueEditor or-ArrayValueEditor");
    IsWidget widget = createJsonEditorWidget(jsonEditor, readOnly, label, title, currentValue, updateConsumer);
    FlowPanel widgetWrapper = new FlowPanel();
    widgetWrapper.setStyleName("flex layout horizontal center");
    widgetWrapper.add(widget);
    panel.add(widgetWrapper);
    timestamp.ifPresent(time -> addTimestampLabel(time, panel));
    return panel;
}
Also used : IsWidget(com.google.gwt.user.client.ui.IsWidget) FlowPanel(com.google.gwt.user.client.ui.FlowPanel)

Aggregations

FlowPanel (com.google.gwt.user.client.ui.FlowPanel)81 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)18 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)15 Button (com.google.gwt.user.client.ui.Button)14 Label (com.google.gwt.user.client.ui.Label)12 Grid (com.google.gwt.user.client.ui.Grid)10 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)8 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)7 SmallHeading (com.google.gerrit.client.ui.SmallHeading)6 Element (com.google.gwt.dom.client.Element)6 CheckBox (com.google.gwt.user.client.ui.CheckBox)6 CellFormatter (com.google.gwt.user.client.ui.HTMLTable.CellFormatter)6 InlineLabel (com.google.gwt.user.client.ui.InlineLabel)6 Widget (com.google.gwt.user.client.ui.Widget)6 Test (org.junit.Test)6 ComplexPanel (com.google.gwt.user.client.ui.ComplexPanel)5 HTML (com.google.gwt.user.client.ui.HTML)5 Image (com.google.gwt.user.client.ui.Image)5 IsWidget (com.google.gwt.user.client.ui.IsWidget)5 List (java.util.List)4