return btn;
}
private Button getCopyButton(final String snapshotName,
final String packageName) {
final RepositoryServiceAsync serv = RepositoryServiceFactory.getService();
Button btn = new Button( constants.Copy() );
btn.addClickListener( new ClickListener() {
public void onClick(Widget w) {
serv.listSnapshots( packageName,
new GenericCallback<SnapshotInfo[]>() {
public void onSuccess(final SnapshotInfo[] snaps) {
final FormStylePopup copy = new FormStylePopup( "images/snapshot.png",
Format.format( constants.CopySnapshotText(),
snapshotName ) );
final List<RadioButton> options = new ArrayList<RadioButton>();
VerticalPanel vert = new VerticalPanel();
for ( int i = 0; i < snaps.length; i++ ) {
RadioButton existing = new RadioButton( "snapshotNameGroup",
snaps[i].name ); //NON-NLS
options.add( existing );
vert.add( existing );
}
HorizontalPanel newNameHorizontalPanel = new HorizontalPanel();
final TextBox newNameTextBox = new TextBox();
final String newNameText = constants.NEW() + ": ";
final RadioButton newNameRadioButton = new RadioButton( "snapshotNameGroup",
newNameText);
newNameHorizontalPanel.add(newNameRadioButton);
newNameTextBox.setEnabled(false);
newNameRadioButton.addClickListener(new ClickListener() {
public void onClick(Widget w) {
newNameTextBox.setEnabled(true);
}
});
newNameHorizontalPanel.add(newNameTextBox);
options.add(newNameRadioButton);
vert.add(newNameHorizontalPanel);
copy.addAttribute(constants.ExistingSnapshots(),
vert );
Button ok = new Button( constants.OK() );
copy.addAttribute( "", ok );
ok.addClickListener( new ClickListener() {
public void onClick(Widget w) {
boolean oneButtonIsSelected = false;
for ( RadioButton rb : options ) {
if ( rb.isChecked() ) {
oneButtonIsSelected = true;
break;
}
}
if (!oneButtonIsSelected) {
Window.alert(constants.YouHaveToEnterOrChoseALabelNameForTheSnapshot());
return;
}
if ( newNameRadioButton.isChecked() ) {
if ( checkUnique( snaps,
newNameTextBox.getText() ) ) {
serv.copyOrRemoveSnapshot( packageName,
snapshotName,
false,
newNameTextBox.getText(),
new GenericCallback() {
public void onSuccess(Object data) {
copy.hide();
Window.alert( Format.format( constants.CreatedSnapshot0ForPackage1(),
newNameTextBox.getText(),
packageName ) );
}
} );
}
} else {
for ( RadioButton rb : options ) {
if ( rb.isChecked() ) {
final String newName = rb.getText();
serv.copyOrRemoveSnapshot( packageName,
snapshotName,
false,
newName,
new GenericCallback() {
public void onSuccess(Object data) {