View Javadoc

1   /**
2    * Copyright (C) 2008 Atlassian
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *    http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package com.atlassian.theplugin.idea.crucible;
17  
18  import com.atlassian.theplugin.commons.crucible.CrucibleServerFacade;
19  import com.atlassian.theplugin.commons.crucible.api.model.Review;
20  import com.atlassian.theplugin.commons.exception.ServerPasswordNotProvidedException;
21  import com.atlassian.theplugin.commons.remoteapi.RemoteApiException;
22  import com.atlassian.theplugin.commons.remoteapi.ServerData;
23  import com.atlassian.theplugin.idea.config.ProjectCfgManagerImpl;
24  import com.intellij.openapi.project.Project;
25  import com.intellij.openapi.vcs.changes.ChangeList;
26  import org.jetbrains.annotations.NotNull;
27  
28  public class CrucibleCreatePostCommitReviewFromChangeListForm extends AbstractCrucibleCreatePostCommitReviewForm {
29  	private final ChangeList[] changes;
30  
31  	private static String getReviewTitle(final ChangeList[] changes) {
32  		if (changes != null && changes.length == 1) {
33  			return changes[0].getName();
34  		} else {
35  			return "";
36  		}
37  
38  	}
39  
40  	public CrucibleCreatePostCommitReviewFromChangeListForm(final Project project,
41  			final CrucibleServerFacade crucibleServerFacade,
42  			final ChangeList[] changes, @NotNull final ProjectCfgManagerImpl projectCfgManager) {
43  		super(project, crucibleServerFacade, getReviewTitle(changes), projectCfgManager);
44  		this.changes = changes;
45  		setCustomComponent(null);
46  		pack();
47  	}
48  
49  	@Override
50  	protected Review createReview(final ServerData server, final ReviewProvider reviewProvider)
51  			throws RemoteApiException, ServerPasswordNotProvidedException {
52  		return createReviewImpl(server, reviewProvider, changes);
53  	}
54  
55  }