Disable editing after successful save of Access screen

When the access has been successfully modified for a project,
switch back to the "read-only" view where the widgets are all
disabled and the Edit button is enabled.  This way the user gets
more visual cues that their change has been completed.

Change-Id: Id9afdeda3406ce550194c93dddbecb4d89529779
This commit is contained in:
Shawn O. Pearce
2011-06-14 12:31:05 -07:00
parent a06318288b
commit 7f1cf2861e
2 changed files with 17 additions and 12 deletions

View File

@@ -51,7 +51,10 @@ public class ProjectAccessScreen extends ProjectScreen {
Button edit;
@UiField
Button cancel;
Button cancel1;
@UiField
Button cancel2;
@UiField
ProjectAccessEditor accessEditor;
@@ -90,31 +93,31 @@ public class ProjectAccessScreen extends ProjectScreen {
new ScreenLoadCallback<ProjectAccess>(this) {
@Override
public void preDisplay(ProjectAccess access) {
edit(access);
displayReadOnly(access);
}
});
}
void edit(ProjectAccess access) {
private void displayReadOnly(ProjectAccess access) {
this.access = access;
final boolean editing = !edit.isEnabled();
accessEditor.setEditing(editing);
accessEditor.setEditing(false);
UIObject.setVisible(editTools, !access.getOwnerOf().isEmpty());
cancel.setVisible(editing);
UIObject.setVisible(commitTools, editing);
edit.setEnabled(!access.getOwnerOf().isEmpty());
cancel1.setVisible(false);
UIObject.setVisible(commitTools, false);
driver.edit(access);
}
@UiHandler("edit")
void onEdit(ClickEvent event) {
edit.setEnabled(false);
cancel.setVisible(true);
cancel1.setVisible(true);
UIObject.setVisible(commitTools, true);
accessEditor.setEditing(true);
driver.edit(access);
}
@UiHandler(value={"cancel", "cancel2"})
@UiHandler(value={"cancel1", "cancel2"})
void onCancel(ClickEvent event) {
Gerrit.display(PageLinks.toProjectAcceess(getProjectKey()));
}
@@ -142,9 +145,9 @@ public class ProjectAccessScreen extends ProjectScreen {
new GerritCallback<ProjectAccess>() {
@Override
public void onSuccess(ProjectAccess access) {
commitMessage.setText("");
edit(access);
enable(true);
commitMessage.setText("");
displayReadOnly(access);
}
@Override
@@ -158,5 +161,7 @@ public class ProjectAccessScreen extends ProjectScreen {
private void enable(boolean enabled) {
commitMessage.setEnabled(enabled);
commit.setEnabled(enabled);
cancel1.setEnabled(enabled);
cancel2.setEnabled(enabled);
}
}

View File

@@ -42,7 +42,7 @@ limitations under the License.
<ui:attribute name='text'/>
</g:Button>
<g:Button
ui:field='cancel'
ui:field='cancel1'
text='Cancel'>
<ui:attribute name='text'/>
</g:Button>