Merge "Suggest parent for 'create-project' in the UI."
This commit is contained in:
		@@ -48,6 +48,7 @@ public interface AdminConstants extends Constants {
 | 
			
		||||
  String descriptionNotifications();
 | 
			
		||||
  String buttonSaveGroupOptions();
 | 
			
		||||
  String suggestedGroupLabel();
 | 
			
		||||
  String parentSuggestions();
 | 
			
		||||
 | 
			
		||||
  String headingGroupUUID();
 | 
			
		||||
  String headingOwner();
 | 
			
		||||
 
 | 
			
		||||
@@ -26,6 +26,7 @@ isVisibleToAll = Make group visible to all registered users.
 | 
			
		||||
buttonSaveGroupOptions = Save Group Options
 | 
			
		||||
suggestedGroupLabel = group
 | 
			
		||||
headingParentProjectName = Rights Inherit From
 | 
			
		||||
parentSuggestions = Parent Suggestion
 | 
			
		||||
columnProjectName = Project Name
 | 
			
		||||
 | 
			
		||||
emailOnlyAuthors = Authors
 | 
			
		||||
 
 | 
			
		||||
@@ -20,6 +20,7 @@ import com.google.gerrit.client.Gerrit;
 | 
			
		||||
import com.google.gerrit.client.rpc.GerritCallback;
 | 
			
		||||
import com.google.gerrit.client.ui.HintTextBox;
 | 
			
		||||
import com.google.gerrit.client.ui.ProjectNameSuggestOracle;
 | 
			
		||||
import com.google.gerrit.client.ui.ProjectsTable;
 | 
			
		||||
import com.google.gerrit.client.ui.Screen;
 | 
			
		||||
import com.google.gerrit.reviewdb.Project;
 | 
			
		||||
import com.google.gwt.event.dom.client.ClickEvent;
 | 
			
		||||
@@ -28,6 +29,7 @@ import com.google.gwt.event.dom.client.KeyCodes;
 | 
			
		||||
import com.google.gwt.event.dom.client.KeyPressEvent;
 | 
			
		||||
import com.google.gwt.event.dom.client.KeyPressHandler;
 | 
			
		||||
import com.google.gwt.user.client.History;
 | 
			
		||||
import com.google.gwt.user.client.ui.Anchor;
 | 
			
		||||
import com.google.gwt.user.client.ui.Button;
 | 
			
		||||
import com.google.gwt.user.client.ui.CheckBox;
 | 
			
		||||
import com.google.gwt.user.client.ui.Grid;
 | 
			
		||||
@@ -36,6 +38,8 @@ import com.google.gwt.user.client.ui.VerticalPanel;
 | 
			
		||||
import com.google.gwtexpui.globalkey.client.NpTextBox;
 | 
			
		||||
import com.google.gwtjsonrpc.client.VoidResult;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
public class CreateProjectScreen extends Screen {
 | 
			
		||||
  private NpTextBox project;
 | 
			
		||||
  private Button create;
 | 
			
		||||
@@ -43,6 +47,7 @@ public class CreateProjectScreen extends Screen {
 | 
			
		||||
  private SuggestBox sugestParent;
 | 
			
		||||
  private CheckBox emptyCommit;
 | 
			
		||||
  private CheckBox permissionsOnly;
 | 
			
		||||
  private ProjectsTable suggestedParentsTab;
 | 
			
		||||
 | 
			
		||||
  public CreateProjectScreen() {
 | 
			
		||||
    super();
 | 
			
		||||
@@ -59,7 +64,6 @@ public class CreateProjectScreen extends Screen {
 | 
			
		||||
  protected void onInitUI() {
 | 
			
		||||
    super.onInitUI();
 | 
			
		||||
    setPageTitle(Util.C.createProjectTitle());
 | 
			
		||||
 | 
			
		||||
    addCreateProjectPanel();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@@ -78,7 +82,12 @@ public class CreateProjectScreen extends Screen {
 | 
			
		||||
    fp.add(emptyCommit);
 | 
			
		||||
    fp.add(permissionsOnly);
 | 
			
		||||
    fp.add(create);
 | 
			
		||||
    add(fp);
 | 
			
		||||
    VerticalPanel vp=new VerticalPanel();
 | 
			
		||||
    vp.add(fp);
 | 
			
		||||
    initSuggestedParents();
 | 
			
		||||
    vp.add(suggestedParentsTab);
 | 
			
		||||
    add(vp);
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private void initCreateTxt() {
 | 
			
		||||
@@ -111,6 +120,44 @@ public class CreateProjectScreen extends Screen {
 | 
			
		||||
    parent.setVisibleLength(50);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private void initSuggestedParents() {
 | 
			
		||||
    suggestedParentsTab = new ProjectsTable() {
 | 
			
		||||
      {
 | 
			
		||||
        table.setText(0, 1, Util.C.parentSuggestions());
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      @Override
 | 
			
		||||
      protected void populate(final int row, final Project k) {
 | 
			
		||||
        final Anchor projectLink = new Anchor(k.getName());
 | 
			
		||||
        projectLink.addClickHandler(new ClickHandler() {
 | 
			
		||||
 | 
			
		||||
          @Override
 | 
			
		||||
          public void onClick(ClickEvent event) {
 | 
			
		||||
            sugestParent.setText(getRowItem(row).getName());
 | 
			
		||||
          }
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        table.setWidget(row, 1, projectLink);
 | 
			
		||||
        table.setText(row, 2, k.getDescription());
 | 
			
		||||
 | 
			
		||||
        setRowItem(row, k);
 | 
			
		||||
      }
 | 
			
		||||
    };
 | 
			
		||||
    suggestedParentsTab.setVisible(false);
 | 
			
		||||
 | 
			
		||||
    Util.PROJECT_SVC
 | 
			
		||||
        .suggestParentCandidates(new GerritCallback<List<Project>>() {
 | 
			
		||||
          @Override
 | 
			
		||||
          public void onSuccess(List<Project> result) {
 | 
			
		||||
            if (result != null && !result.isEmpty()) {
 | 
			
		||||
              suggestedParentsTab.setVisible(true);
 | 
			
		||||
              suggestedParentsTab.display(result);
 | 
			
		||||
              suggestedParentsTab.finishDisplay();
 | 
			
		||||
            }
 | 
			
		||||
          }
 | 
			
		||||
        });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private void addGrid(final VerticalPanel fp) {
 | 
			
		||||
    final Grid grid = new Grid(2, 2);
 | 
			
		||||
    grid.setStyleName(Gerrit.RESOURCES.css().infoBlock());
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user