Skip to content

Commit

Permalink
gh-4135 Add isDefault to UI screens WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
at055612 committed Mar 7, 2024
1 parent 52408b0 commit 4b75d48
Show file tree
Hide file tree
Showing 33 changed files with 734 additions and 108 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public final class ColumnSizeConstants {
public static final int BIG_COL = 400;
public static final int DATE_COL = 200;
public static final int DATE_AND_DURATION_COL = 320;
public static final int UUID_COL = 200;

private ColumnSizeConstants() {
// Constants.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@
import stroom.data.store.impl.fs.client.presenter.FsVolumeEditPresenter.FsVolumeEditView;
import stroom.data.store.impl.fs.client.presenter.FsVolumeGroupEditPresenter;
import stroom.data.store.impl.fs.client.presenter.FsVolumeGroupEditPresenter.FsVolumeGroupEditView;
import stroom.data.store.impl.fs.client.presenter.NewFsVolumeGroupPresenter;
import stroom.data.store.impl.fs.client.presenter.NewFsVolumeGroupPresenter.NewFsVolumeGroupView;
import stroom.data.store.impl.fs.client.view.FsVolumeEditViewImpl;
import stroom.data.store.impl.fs.client.view.FsVolumeGroupEditViewImpl;
import stroom.data.store.impl.fs.client.view.NewFsVolumeGroupViewImpl;

public class FsVolumeModule extends PluginModule {

Expand All @@ -37,5 +40,10 @@ protected void configure() {
FsVolumeGroupEditPresenter.class,
FsVolumeGroupEditView.class,
FsVolumeGroupEditViewImpl.class);

bindPresenterWidget(
NewFsVolumeGroupPresenter.class,
NewFsVolumeGroupView.class,
NewFsVolumeGroupViewImpl.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,9 @@ private void enableButtons() {
deleteButton.setEnabled(enabled);
}

void show(final FsVolumeGroup volumeGroup, final String title, final Consumer<FsVolumeGroup> consumer) {
void show(final FsVolumeGroup volumeGroup,
final String title,
final Consumer<FsVolumeGroup> consumer) {
if (!opening) {
opening = true;
open(volumeGroup, title, consumer);
Expand Down Expand Up @@ -262,12 +264,20 @@ void hide() {
opening = false;
}


// --------------------------------------------------------------------------------


public interface FsVolumeGroupEditView extends View, Focus {

String getName();

void setName(String name);

boolean isDefault();

void setDefault(final boolean isDefault);

void setListView(View listView);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,21 @@

package stroom.data.store.impl.fs.client.presenter;

import stroom.data.client.presenter.ColumnSizeConstants;
import stroom.data.client.presenter.CriteriaUtil;
import stroom.data.client.presenter.RestDataProvider;
import stroom.data.grid.client.EndColumn;
import stroom.data.grid.client.MyDataGrid;
import stroom.data.grid.client.PagerView;
import stroom.data.store.impl.fs.shared.FsVolumeGroup;
import stroom.data.store.impl.fs.shared.FsVolumeGroupResource;
import stroom.dispatch.client.Rest;
import stroom.dispatch.client.RestFactory;
import stroom.entity.shared.ExpressionCriteria;
import stroom.util.client.DataGridUtil;
import stroom.util.shared.ResultPage;
import stroom.widget.util.client.MultiSelectionModel;
import stroom.widget.util.client.MultiSelectionModelImpl;

import com.google.gwt.cell.client.TextCell;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.cellview.client.Column;
import com.google.gwt.view.client.Range;
import com.google.inject.Inject;
import com.google.web.bindery.event.shared.EventBus;
Expand Down Expand Up @@ -69,8 +67,9 @@ protected void exec(final Range range,
final Consumer<ResultPage<FsVolumeGroup>> dataConsumer,
final Consumer<Throwable> throwableConsumer) {
CriteriaUtil.setRange(criteria, range);
final Rest<ResultPage<FsVolumeGroup>> rest = restFactory.create();
rest

restFactory.builder()
.forResultPageOf(FsVolumeGroup.class)
.onSuccess(dataConsumer)
.onFailure(throwableConsumer)
.call(FS_VOLUME_GROUP_RESOURCE)
Expand All @@ -85,15 +84,21 @@ protected void exec(final Range range,
*/
private void initTableColumns() {
// Name.
final Column<FsVolumeGroup, String> volumeColumn = new Column<FsVolumeGroup, String>(new TextCell()) {
@Override
public String getValue(final FsVolumeGroup volume) {
return volume.getName();
}
};
dataGrid.addResizableColumn(volumeColumn, "Name", 400);

dataGrid.addEndColumn(new EndColumn<>());
dataGrid.addResizableColumn(
DataGridUtil.copyTextColumnBuilder(FsVolumeGroup::getName).build(),
"Name",
400);
// UUID
dataGrid.addResizableColumn(
DataGridUtil.copyTextColumnBuilder(FsVolumeGroup::getUuid).build(),
"UUID",
ColumnSizeConstants.UUID_COL);
// Is Default
dataGrid.addColumn(
DataGridUtil.readOnlyTickBoxColumnBuilder(FsVolumeGroup::isDefaultVolume).build(),
"Default Group",
ColumnSizeConstants.CHECKBOX_COL);
DataGridUtil.addEndColumn(dataGrid);
}

public MultiSelectionModel<FsVolumeGroup> getSelectionModel() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ protected void onBind() {

private void add() {
final NewFsVolumeGroupPresenter presenter = newFsVolumeGroupPresenterProvider.get();
presenter.show("", name -> {
presenter.show(name -> {
if (name != null) {
final Rest<FsVolumeGroup> rest = restFactory.create();
rest
restFactory.builder()
.forType(FsVolumeGroup.class)
.onSuccess(volumeGroup -> {
edit(volumeGroup);
presenter.hide();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import stroom.data.store.impl.fs.shared.FsVolumeResource;
import stroom.data.store.impl.fs.shared.FsVolumeType;
import stroom.data.store.impl.fs.shared.S3ClientConfig;
import stroom.dispatch.client.Rest;
import stroom.dispatch.client.RestFactory;
import stroom.preferences.client.DateTimeFormatter;
import stroom.util.shared.GwtNullSafe;
Expand Down Expand Up @@ -92,8 +91,9 @@ protected void exec(final Range range,
final Consumer<ResultPage<FsVolume>> dataConsumer,
final Consumer<Throwable> throwableConsumer) {
CriteriaUtil.setRange(criteria, range);
final Rest<ResultPage<FsVolume>> rest = restFactory.create();
rest

restFactory.builder()
.forResultPageOf(FsVolume.class)
.onSuccess(dataConsumer)
.onFailure(throwableConsumer)
.call(FS_VOLUME_RESOURCE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,34 @@
package stroom.data.store.impl.fs.client.presenter;

import stroom.alert.client.event.AlertEvent;
import stroom.alert.client.event.ConfirmEvent;
import stroom.data.store.impl.fs.client.presenter.NewFsVolumeGroupPresenter.NewFsVolumeGroupView;
import stroom.data.store.impl.fs.shared.FsVolumeGroup;
import stroom.data.store.impl.fs.shared.FsVolumeGroupResource;
import stroom.dispatch.client.Rest;
import stroom.dispatch.client.RestFactory;
import stroom.entity.client.presenter.NameDocumentView;
import stroom.util.shared.ResultPage;
import stroom.util.shared.GwtNullSafe;
import stroom.widget.popup.client.event.HidePopupEvent;
import stroom.widget.popup.client.event.HidePopupRequestEvent;
import stroom.widget.popup.client.event.ShowPopupEvent;
import stroom.widget.popup.client.presenter.PopupType;
import stroom.widget.popup.client.view.DefaultHideRequestUiHandlers;
import stroom.widget.popup.client.view.HideRequestUiHandlers;

import com.google.gwt.core.shared.GWT;
import com.google.gwt.user.client.ui.Focus;
import com.google.inject.Inject;
import com.google.web.bindery.event.shared.EventBus;
import com.gwtplatform.mvp.client.HasUiHandlers;
import com.gwtplatform.mvp.client.MyPresenterWidget;
import com.gwtplatform.mvp.client.View;

import java.util.function.Consumer;

public class NewFsVolumeGroupPresenter
extends MyPresenterWidget<NameDocumentView>
extends MyPresenterWidget<NewFsVolumeGroupView>
implements HidePopupRequestEvent.Handler {

private Consumer<String> consumer;
private Consumer<FsVolumeGroup> consumer;

private static final FsVolumeGroupResource FS_VOLUME_GROUP_RESOURCE =
GWT.create(FsVolumeGroupResource.class);
Expand All @@ -51,16 +55,16 @@ public class NewFsVolumeGroupPresenter

@Inject
public NewFsVolumeGroupPresenter(final EventBus eventBus,
final NameDocumentView view,
final NewFsVolumeGroupView view,
final RestFactory restFactory) {
super(eventBus, view);
this.restFactory = restFactory;
}

public void show(final String name, final Consumer<String> consumer) {
public void show(final Consumer<FsVolumeGroup> consumer) {
this.consumer = consumer;
getView().setUiHandlers(new DefaultHideRequestUiHandlers(this));
getView().setName(name);

ShowPopupEvent.builder(this)
.popupType(PopupType.OK_CANCEL_DIALOG)
.caption("New")
Expand All @@ -74,14 +78,16 @@ public void show(final String name, final Consumer<String> consumer) {
public void onHideRequest(final HidePopupRequestEvent e) {
if (e.isOk()) {
final String name = getView().getName().trim();
if (name.length() == 0) {
AlertEvent.fireError(
NewFsVolumeGroupPresenter.this,
"You must provide a name",
null);
} else {
final Rest<ResultPage<FsVolumeGroup>> rest = restFactory.create();
rest
final boolean isDefault = getView().isDefault();

final Runnable action = () -> {
final FsVolumeGroup volumeGroup = FsVolumeGroup.builder()
.withName(name)
.withDefaultVolume(isDefault)
.build();

restFactory.builder()
.forType(FsVolumeGroup.class)
.onSuccess(result -> {
if (result != null) {
AlertEvent.fireError(
Expand All @@ -91,11 +97,31 @@ public void onHideRequest(final HidePopupRequestEvent e) {
+ "' is already in use by another group.",
null);
} else {
consumer.accept(name);
consumer.accept(volumeGroup);
}
})
.call(FS_VOLUME_GROUP_RESOURCE)
.fetchByName(name);
};

if (GwtNullSafe.isBlankString(name)) {
AlertEvent.fireError(
NewFsVolumeGroupPresenter.this,
"You must provide a name",
null);
} else if (isDefault) {
ConfirmEvent.fireWarn(
NewFsVolumeGroupPresenter.this,
"You are setting this Volume Group as the default group.\n" +
"This will remove the default state from any existing default volume group.\n\n" +
"Do you wish to continue?",
ok -> {
if (ok) {
action.run();
}
});
} else {
action.run();
}
} else {
consumer.accept(null);
Expand All @@ -105,4 +131,20 @@ public void onHideRequest(final HidePopupRequestEvent e) {
public void hide() {
HidePopupEvent.builder(this).fire();
}


// --------------------------------------------------------------------------------


public interface NewFsVolumeGroupView
extends View, Focus, HasUiHandlers<HideRequestUiHandlers> {

String getName();

void setName(String name);

boolean isDefault();

void setDefault(final boolean isDefault);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package stroom.data.store.impl.fs.client.view;

import stroom.data.store.impl.fs.client.presenter.FsVolumeGroupEditPresenter.FsVolumeGroupEditView;
import stroom.util.shared.GwtNullSafe;
import stroom.widget.tickbox.client.view.CustomCheckBox;

import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
Expand All @@ -34,6 +36,8 @@ public class FsVolumeGroupEditViewImpl extends ViewImpl implements FsVolumeGroup
@UiField
TextBox name;
@UiField
CustomCheckBox isDefaultCheckBox;
@UiField
SimplePanel list;

@Inject
Expand Down Expand Up @@ -61,11 +65,25 @@ public void setName(final String name) {
this.name.setText(name);
}

@Override
public boolean isDefault() {
return GwtNullSafe.isTrue(this.isDefaultCheckBox.getValue());
}

@Override
public void setDefault(final boolean isDefault) {
this.isDefaultCheckBox.setValue(isDefault);
}

@Override
public void setListView(final View listView) {
list.setWidget(listView.asWidget());
}


// --------------------------------------------------------------------------------


public interface Binder extends UiBinder<Widget, FsVolumeGroupEditViewImpl> {

}
Expand Down
Loading

0 comments on commit 4b75d48

Please sign in to comment.