use of com.google.cloud.tools.intellij.project.CloudProject in project google-cloud-intellij by GoogleCloudPlatform.
the class CloneCloudRepositoryDialog method getCurrentUrlText.
@Nullable
private String getCurrentUrlText() {
CloudProject selectedProject = projectSelector.getSelectedProject();
Optional<CredentialedUser> selectedUser = selectedProject == null ? Optional.empty() : Services.getLoginService().getLoggedInUser(selectedProject.googleUsername());
if (selectedProject == null || !selectedUser.isPresent() || StringUtil.isEmpty(repositorySelector.getText())) {
return null;
}
return GcpHttpAuthDataProvider.getGcpUrl(selectedProject.projectId(), repositorySelector.getText());
}
use of com.google.cloud.tools.intellij.project.CloudProject in project google-cloud-intellij by GoogleCloudPlatform.
the class CloneCloudRepositoryDialog method updateButtons.
/**
* Check fields and display error in the wrapper if there is a problem.
*/
private void updateButtons() {
CloudProject selectedProject = projectSelector.getSelectedProject();
Optional<CredentialedUser> selectedUser = selectedProject == null ? Optional.empty() : Services.getLoginService().getLoggedInUser(selectedProject.googleUsername());
if (selectedProject != null && !selectedUser.isPresent()) {
setErrorText(GctBundle.message("cloud.repository.dialog.invalid.project"));
setOKActionEnabled(false);
return;
}
if (!StringUtil.isEmpty(repositorySelector.getText()) && StringUtil.isEmpty(repositorySelector.getSelectedRepository())) {
setErrorText(GctBundle.message("cloud.repository.dialog.invalid.repository"));
setOKActionEnabled(false);
return;
}
if (!selectedUser.isPresent() || StringUtil.isEmpty(repositorySelector.getSelectedRepository())) {
setErrorText(null);
setOKActionEnabled(false);
return;
}
if (StringUtil.isEmpty(parentDirectory.getText()) || StringUtil.isEmpty(directoryName.getText())) {
setErrorText(null);
setOKActionEnabled(false);
return;
}
File file = new File(parentDirectory.getText(), directoryName.getText());
if (file.exists()) {
setErrorText(GctBundle.message("clonefromgcp.destination.exists.error"));
setOKActionEnabled(false);
return;
}
if (!file.getParentFile().exists()) {
setErrorText(GctBundle.message("clonefromgcp.parent.missing.error"));
setOKActionEnabled(false);
return;
}
setErrorText(null);
setOKActionEnabled(true);
}
use of com.google.cloud.tools.intellij.project.CloudProject in project google-cloud-intellij by GoogleCloudPlatform.
the class GoogleCloudApiSelectorPanelTest method getManagementUI_withLibraryAndProjectSelected_isEnabled.
@Test
public void getManagementUI_withLibraryAndProjectSelected_isEnabled() {
CloudLibrary library = LIBRARY_1.toCloudLibrary();
GoogleCloudApiSelectorPanel panel = new GoogleCloudApiSelectorPanel(ImmutableList.of(library), testFixture.getProject());
JTable table = panel.getCloudLibrariesTable();
checkAddLibraryCheckbox(table, 0);
panel.getDetailsPanel().setCloudLibrary(library, BOM_VERSION, panel.getApiManagementMap().get(library));
CloudProject cloudProject = CloudProject.create("name", "id", "user");
ProjectSelector projectSelector = panel.getProjectSelector();
projectSelector.setSelectedProject(cloudProject);
projectSelector.getProjectSelectionListeners().forEach(listener -> listener.projectSelected(cloudProject));
assertThat(panel.getDetailsPanel().getEnableApiCheckbox().isEnabled()).isTrue();
assertThat(panel.getDetailsPanel().getManagementInfoPanel().isVisible()).isFalse();
}
use of com.google.cloud.tools.intellij.project.CloudProject in project google-cloud-intellij by GoogleCloudPlatform.
the class AppEngineDeploymentConfigurationPanelTest method projectSelector_invalidProjectSelected_infoPanelShowsError.
@Test
public void projectSelector_invalidProjectSelected_infoPanelShowsError() {
CloudProject project = CloudProject.create("projectId", "projectId", "some-user-id");
when(projectSelector.getSelectedProject()).thenReturn(project);
deploymentConfiguration.setCloudProjectName("projectName");
deploymentConfiguration.setGoogleUsername("some-user-id");
configurationPanel.resetEditorFrom(deploymentConfiguration);
verify(infoPanel).setMessage(GctBundle.getString("appengine.infopanel.no.region"), true);
}
use of com.google.cloud.tools.intellij.project.CloudProject in project google-cloud-intellij by GoogleCloudPlatform.
the class AppEngineDeploymentConfigurationPanelTest method projectSelector_validProjectSelected_infoPanelShowsProjectDetails.
@Test
public void projectSelector_validProjectSelected_infoPanelShowsProjectDetails() {
String projectId = "projectId";
String googleUsername = "some-user-id";
CloudProject project = CloudProject.create(projectId, projectId, googleUsername);
when(credentialedUser.getCredential()).thenReturn(credential);
when(mockGoogleLoginService.getLoggedInUser(googleUsername)).thenReturn(Optional.of(credentialedUser));
when(projectSelector.getSelectedProject()).thenReturn(project);
deploymentConfiguration.setCloudProjectName(projectId);
deploymentConfiguration.setGoogleUsername(googleUsername);
configurationPanel.resetEditorFrom(deploymentConfiguration);
verify(infoPanel).refresh(projectId, credential);
}
Aggregations