public CopyPopup( final Path path, final Validator validator, final CommandWithFileNameAndCommitMessage command) { super(CommonImages.INSTANCE.edit(), CommonConstants.INSTANCE.CopyPopupTitle()); checkNotNull("validator", validator); checkNotNull("path", path); checkNotNull("command", command); // Make sure it appears on top of other popups getElement().getStyle().setZIndex(Integer.MAX_VALUE); setGlassEnabled(true); nameTextBox.setTitle(CommonConstants.INSTANCE.NewName()); nameTextBox.setWidth("200px"); addAttribute(CommonConstants.INSTANCE.NewNameColon(), nameTextBox); checkInCommentTextBox.setTitle(CommonConstants.INSTANCE.CheckInComment()); checkInCommentTextBox.setWidth("200px"); addAttribute(CommonConstants.INSTANCE.CheckInCommentColon(), checkInCommentTextBox); final HorizontalPanel hp = new HorizontalPanel(); final Button create = new Button(CommonConstants.INSTANCE.CopyPopupCreateACopy()); create.addClickHandler( new ClickHandler() { public void onClick(final ClickEvent arg0) { final String baseFileName = nameTextBox.getText(); final String originalFileName = path.getFileName(); final String extension = (originalFileName.lastIndexOf(".") > 0 ? originalFileName.substring(originalFileName.lastIndexOf(".")) : ""); final String fileName = baseFileName + extension; validator.validate( fileName, new ValidatorCallback() { @Override public void onSuccess() { hide(); command.execute( new FileNameAndCommitMessage( baseFileName, checkInCommentTextBox.getText())); } @Override public void onFailure() { Window.alert(CommonConstants.INSTANCE.InvalidFileName0(baseFileName)); } }); } }); hp.add(create); final Button cancel = new Button(CommonConstants.INSTANCE.Cancel()); cancel.addClickHandler( new ClickHandler() { public void onClick(final ClickEvent arg0) { hide(); } }); hp.add(new HTML(" ")); hp.add(cancel); addAttribute("", hp); }