Skip to content

Commit 8488c76

Browse files
committed
Merge with HEAD
2 parents 34e0ad9 + accae1c commit 8488c76

48 files changed

Lines changed: 1257 additions & 335 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
eclipse.preferences.version=1
2+
encoding/<project>=UTF-8
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
activeProfiles=
2+
eclipse.preferences.version=1
3+
resolveWorkspaceProjects=true
4+
version=1

plugins/com.google.cloud.tools.eclipse.appengine.deploy.ui.test/src/com/google/cloud/tools/eclipse/appengine/deploy/ui/StandardDeployPreferencesPanelTest.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@
3636
import com.google.cloud.tools.eclipse.projectselector.model.GcpProject;
3737
import com.google.cloud.tools.eclipse.test.util.ui.ShellTestResource;
3838
import com.google.cloud.tools.login.Account;
39+
import java.util.ArrayDeque;
3940
import java.util.Arrays;
4041
import java.util.HashSet;
42+
import java.util.Queue;
4143
import org.eclipse.core.databinding.ValidationStatusProvider;
4244
import org.eclipse.core.resources.IProject;
4345
import org.eclipse.core.resources.ProjectScope;
@@ -186,13 +188,17 @@ public void testProjectSavedInPreferencesSelected() throws ProjectRepositoryExce
186188
StandardDeployPreferencesPanel deployPanel =
187189
new StandardDeployPreferencesPanel(parent, project, loginService, layoutChangedHandler,
188190
true, projectRepository);
189-
for (Control control : deployPanel.getChildren()) {
191+
Queue<Control> children = new ArrayDeque<>(Arrays.asList(deployPanel.getChildren()));
192+
while (!children.isEmpty()) {
193+
Control control = children.poll();
190194
if (control instanceof ProjectSelector) {
191195
ProjectSelector projectSelector = (ProjectSelector) control;
192196
IStructuredSelection selection = projectSelector.getViewer().getStructuredSelection();
193197
assertThat(selection.size(), is(1));
194198
assertThat(((GcpProject) selection.getFirstElement()).getId(), is("projectId1"));
195199
return;
200+
} else if (control instanceof Composite) {
201+
children.addAll(Arrays.asList(((Composite) control).getChildren()));
196202
}
197203
};
198204
fail("Did not find ProjectSelector widget");

plugins/com.google.cloud.tools.eclipse.appengine.deploy.ui/META-INF/MANIFEST.MF

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ Import-Package: com.google.api.client.auth.oauth2;version="[1.22.0,1.23.0)",
2626
com.google.cloud.tools.eclipse.ui.util,
2727
com.google.cloud.tools.eclipse.ui.util.console,
2828
com.google.cloud.tools.eclipse.ui.util.databinding,
29+
com.google.cloud.tools.eclipse.ui.util.event,
30+
com.google.cloud.tools.eclipse.ui.util.images,
2931
com.google.cloud.tools.eclipse.usagetracker,
3032
com.google.cloud.tools.eclipse.util,
3133
com.google.cloud.tools.eclipse.util.status,

plugins/com.google.cloud.tools.eclipse.appengine.deploy.ui/src/com/google/cloud/tools/eclipse/appengine/deploy/ui/StandardDeployPreferencesPanel.java

Lines changed: 74 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
import com.google.cloud.tools.eclipse.ui.util.databinding.BucketNameValidator;
3030
import com.google.cloud.tools.eclipse.ui.util.databinding.ProjectSelectorValidator;
3131
import com.google.cloud.tools.eclipse.ui.util.databinding.ProjectVersionValidator;
32+
import com.google.cloud.tools.eclipse.ui.util.event.OpenUriSelectionListener;
33+
import com.google.cloud.tools.eclipse.ui.util.event.OpenUriSelectionListener.ErrorDialogErrorHandler;
34+
import com.google.cloud.tools.eclipse.ui.util.images.SharedImages;
3235
import com.google.cloud.tools.eclipse.util.status.StatusUtil;
3336
import com.google.common.annotations.VisibleForTesting;
3437
import com.google.common.base.Preconditions;
@@ -63,14 +66,16 @@
6366
import org.eclipse.jface.layout.GridDataFactory;
6467
import org.eclipse.jface.layout.GridLayoutFactory;
6568
import org.eclipse.swt.SWT;
66-
import org.eclipse.swt.events.ControlAdapter;
67-
import org.eclipse.swt.events.ControlEvent;
69+
import org.eclipse.swt.events.SelectionAdapter;
70+
import org.eclipse.swt.events.SelectionEvent;
6871
import org.eclipse.swt.graphics.Font;
72+
import org.eclipse.swt.graphics.Image;
6973
import org.eclipse.swt.layout.GridData;
7074
import org.eclipse.swt.layout.GridLayout;
7175
import org.eclipse.swt.widgets.Button;
7276
import org.eclipse.swt.widgets.Composite;
7377
import org.eclipse.swt.widgets.Label;
78+
import org.eclipse.swt.widgets.Link;
7479
import org.eclipse.swt.widgets.Text;
7580
import org.eclipse.ui.forms.events.ExpansionAdapter;
7681
import org.eclipse.ui.forms.events.ExpansionEvent;
@@ -81,6 +86,8 @@ public class StandardDeployPreferencesPanel extends DeployPreferencesPanel {
8186

8287
private static final String APPENGINE_VERSIONS_URL =
8388
"https://console.cloud.google.com/appengine/versions";
89+
private static final String CREATE_GCP_PROJECT_WITH_GAE_URL =
90+
"https://console.cloud.google.com/projectselector/appengine/create?lang=java";
8491

8592
private static final Logger logger = Logger.getLogger(
8693
StandardDeployPreferencesPanel.class.getName());
@@ -99,6 +106,8 @@ public class StandardDeployPreferencesPanel extends DeployPreferencesPanel {
99106

100107
private ExpandableComposite expandableComposite;
101108

109+
private Image refreshIcon;
110+
102111
@VisibleForTesting
103112
DeployPreferencesModel model;
104113
private ObservablesManager observables;
@@ -122,6 +131,8 @@ public StandardDeployPreferencesPanel(Composite parent, IProject project,
122131

123132
this.projectRepository = projectRepository;
124133

134+
refreshIcon = SharedImages.createRefreshIcon(getDisplay());
135+
125136
createCredentialSection(loginService);
126137

127138
createProjectIdSection();
@@ -316,17 +327,45 @@ private void createProjectIdSection() {
316327
Label projectIdLabel = new Label(this, SWT.LEAD);
317328
projectIdLabel.setText(Messages.getString("project"));
318329
projectIdLabel.setToolTipText(Messages.getString("tooltip.project.id"));
319-
GridDataFactory.swtDefaults().align(SWT.BEGINNING, SWT.BEGINNING).applyTo(projectIdLabel);
320-
projectSelector = new ProjectSelector(this);
321-
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER)
322-
.grab(true, false).hint(400, 150).applyTo(projectSelector);
323-
accountSelector.addSelectionListener(new Runnable() {
330+
GridDataFactory.swtDefaults().align(SWT.BEGINNING, SWT.BEGINNING).span(1, 3)
331+
.applyTo(projectIdLabel);
332+
333+
Label select = new Label(this, SWT.WRAP);
334+
select.setText(Messages.getString("projectselector.selectProject"));
335+
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.BEGINNING)
336+
.applyTo(select);
337+
338+
Link createNewProject = new Link(this, SWT.NONE);
339+
createNewProject.setText(Messages.getString("projectselector.createproject",
340+
CREATE_GCP_PROJECT_WITH_GAE_URL));
341+
createNewProject.setToolTipText(Messages.getString("projectselector.createproject.tooltip"));
342+
FontUtil.convertFontToItalic(createNewProject);
343+
createNewProject.addSelectionListener(
344+
new OpenUriSelectionListener(new ErrorDialogErrorHandler(getShell())));
345+
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.BEGINNING)
346+
.applyTo(createNewProject);
347+
348+
Composite projectSelectorComposite = new Composite(this, SWT.NONE);
349+
GridLayoutFactory.fillDefaults().numColumns(2).spacing(0, 0).applyTo(projectSelectorComposite);
350+
GridDataFactory.fillDefaults().grab(true, false).applyTo(projectSelectorComposite);
351+
352+
projectSelector = new ProjectSelector(projectSelectorComposite);
353+
GridDataFactory.fillDefaults().grab(true, false).hint(SWT.DEFAULT, 200)
354+
.applyTo(projectSelector);
355+
356+
final Button refreshProjectsButton = new Button(projectSelectorComposite, SWT.NONE);
357+
refreshProjectsButton.setImage(refreshIcon);
358+
GridDataFactory.swtDefaults().align(SWT.END, SWT.BEGINNING).applyTo(refreshProjectsButton);
359+
refreshProjectsButton.addSelectionListener(new SelectionAdapter() {
324360
@Override
325-
public void run() {
326-
Credential selectedCredential = accountSelector.getSelectedCredential();
327-
projectSelector.setProjects(retrieveProjects(selectedCredential));
361+
public void widgetSelected(SelectionEvent event) {
362+
refreshProjectsForSelectedCredential();
328363
}
329364
});
365+
366+
accountSelector.addSelectionListener(
367+
new RefreshProjectOnAccountSelection(refreshProjectsButton));
368+
330369
projectSelector.addSelectionChangedListener(
331370
new ProjectSelectorSelectionChangedListener(accountSelector,
332371
projectRepository,
@@ -371,7 +410,7 @@ private void createAdvancedSection() {
371410
expandableComposite.setClient(bucketComposite);
372411
expandableComposite.addExpansionListener(new ExpansionAdapter() {
373412
@Override
374-
public void expansionStateChanged(ExpansionEvent e) {
413+
public void expansionStateChanged(ExpansionEvent event) {
375414
handleExpansionStateChanged();
376415
}
377416
});
@@ -407,6 +446,11 @@ private Composite createBucketSection(Composite parent) {
407446
return bucketComposite;
408447
}
409448

449+
private void refreshProjectsForSelectedCredential() {
450+
Credential selectedCredential = accountSelector.getSelectedCredential();
451+
projectSelector.setProjects(retrieveProjects(selectedCredential));
452+
}
453+
410454
private List<GcpProject> retrieveProjects(Credential selectedCredential) {
411455
try {
412456
if (selectedCredential == null) {
@@ -425,6 +469,21 @@ private List<GcpProject> retrieveProjects(Credential selectedCredential) {
425469
}
426470
}
427471

472+
public final class RefreshProjectOnAccountSelection implements Runnable {
473+
474+
private final Button refreshProjectsButton;
475+
476+
public RefreshProjectOnAccountSelection(Button refreshProjectsButton) {
477+
this.refreshProjectsButton = refreshProjectsButton;
478+
}
479+
480+
@Override
481+
public void run() {
482+
refreshProjectsForSelectedCredential();
483+
refreshProjectsButton.setEnabled(accountSelector.getSelectedCredential() != null);
484+
}
485+
}
486+
428487
private final class ProjectIdToGcpProjectConverter extends Converter {
429488

430489
private ProjectIdToGcpProjectConverter() {
@@ -441,7 +500,7 @@ public Object convert(Object fromObject) {
441500
try {
442501
return projectRepository.getProject(accountSelector.getSelectedCredential(),
443502
(String) fromObject);
444-
} catch (ProjectRepositoryException e) {
503+
} catch (ProjectRepositoryException ex) {
445504
return null;
446505
}
447506
}
@@ -528,6 +587,9 @@ public void dispose() {
528587
if (observables != null) {
529588
observables.dispose();
530589
}
590+
if (refreshIcon != null) {
591+
refreshIcon.dispose();
592+
}
531593
super.dispose();
532594
}
533595

plugins/com.google.cloud.tools.eclipse.appengine.deploy.ui/src/com/google/cloud/tools/eclipse/appengine/deploy/ui/messages.properties

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ tooltip.stop.previous.version=If checked, stops the previously running version w
4040
new version that receives all traffic.
4141
tooltip.staging.bucket=The Google Cloud Storage bucket used to stage files for deployment. \
4242
If not specified, the application''s default code bucket is used.
43+
44+
#Project selector
45+
projectselector.selectProject=Select a Google Cloud Platform project
46+
projectselector.createproject=Create a project in the <a href="{0}">Cloud Console</a>. Then refresh this list.
47+
projectselector.createproject.tooltip=Opens the Cloud Console in a browser. You will need to refresh the project list \
48+
after the project is created.
4349
projectselector.retrieveproject.error.title=Failed to retrieve projects
4450
projectselector.retrieveproject.error.message=An error occurred while retrieving projects: {0}
4551
projectselector.retrieveapplication.error.title=Failed to retrieve App Engine application

plugins/com.google.cloud.tools.eclipse.appengine.flex/plugin.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
point="org.eclipse.ui.menus">
8080
<menuContribution
8181
allPopups="false"
82-
locationURI="menu:com.google.cloud.tools.eclipse.appengine.actions.new">
82+
locationURI="menu:com.google.cloud.tools.eclipse.appengine.actions.new?after=com.google.cloud.tools.eclipse.appengine.flexible">
8383
<command
8484
commandId="org.eclipse.ui.newWizard"
8585
style="push">

plugins/com.google.cloud.tools.eclipse.appengine.libraries.test/src/com/google/cloud/tools/eclipse/appengine/libraries/AppEngineLibrariesInPluginXmlTest.java

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public void testAppEngineApiLibraryConfig() throws URISyntaxException {
7676
assertThat(mavenCoordinates.getRepository(), is("central"));
7777
assertThat(mavenCoordinates.getGroupId(), is("com.google.appengine"));
7878
assertThat(mavenCoordinates.getArtifactId(), is("appengine-api-1.0-sdk"));
79-
assertThat(mavenCoordinates.getVersion(), is("LATEST"));
79+
assertThat(mavenCoordinates.getVersion(), is("1.9.50"));
8080
assertThat(mavenCoordinates.getType(), is("jar"));
8181
assertNull(mavenCoordinates.getClassifier());
8282

@@ -118,7 +118,7 @@ public void testEndpointsLibraryConfig() throws URISyntaxException {
118118
assertThat(mavenCoordinates.getRepository(), is("central"));
119119
assertThat(mavenCoordinates.getGroupId(), is("com.google.appengine"));
120120
assertThat(mavenCoordinates.getArtifactId(), is("appengine-endpoints"));
121-
assertThat(mavenCoordinates.getVersion(), is("LATEST"));
121+
assertThat(mavenCoordinates.getVersion(), is("1.9.50"));
122122
assertThat(mavenCoordinates.getType(), is("jar"));
123123
assertNull(mavenCoordinates.getClassifier());
124124
assertThat(libraryFile.getJavadocUri(),
@@ -153,7 +153,7 @@ public void testObjectifyLibraryConfig() throws URISyntaxException {
153153
assertThat(objectifyMavenCoordinates.getRepository(), is("central"));
154154
assertThat(objectifyMavenCoordinates.getGroupId(), is("com.googlecode.objectify"));
155155
assertThat(objectifyMavenCoordinates.getArtifactId(), is("objectify"));
156-
assertThat(objectifyMavenCoordinates.getVersion(), is("5.1.14"));
156+
assertThat(objectifyMavenCoordinates.getVersion(), is("5.1.15"));
157157
assertThat(objectifyMavenCoordinates.getType(), is("jar"));
158158
assertNull(objectifyMavenCoordinates.getClassifier());
159159

@@ -230,23 +230,37 @@ public void testJspApiLibraryConfig() throws URISyntaxException {
230230
assertNotNull(jspApiLibrary.getLibraryDependencies());
231231
assertTrue(jspApiLibrary.getLibraryDependencies().isEmpty());
232232

233-
assertThat(jspApiLibrary.getLibraryFiles().size(), is(1));
234-
LibraryFile libraryFile = jspApiLibrary.getLibraryFiles().get(0);
235-
assertThat(libraryFile.getJavadocUri(), is(new URI(
233+
assertThat(jspApiLibrary.getLibraryFiles().size(), is(2));
234+
LibraryFile jspApi = jspApiLibrary.getLibraryFiles().get(0);
235+
assertThat(jspApi.getJavadocUri(), is(new URI(
236236
"http://docs.oracle.com/cd/E17802_01/products/products/jsp/2.1/docs/jsp-2_1-pfd2/")));
237-
assertNull(libraryFile.getSourceUri());
237+
assertNull(jspApi.getSourceUri());
238238

239-
assertNotNull(libraryFile.getMavenCoordinates());
240-
MavenCoordinates mavenCoordinates = libraryFile.getMavenCoordinates();
239+
assertNotNull(jspApi.getMavenCoordinates());
240+
MavenCoordinates mavenCoordinates = jspApi.getMavenCoordinates();
241241
assertThat(mavenCoordinates.getRepository(), is("central"));
242242
assertThat(mavenCoordinates.getGroupId(), is("javax.servlet.jsp"));
243243
assertThat(mavenCoordinates.getArtifactId(), is("jsp-api"));
244244
assertThat(mavenCoordinates.getVersion(), is("2.1"));
245245
assertThat(mavenCoordinates.getType(), is("jar"));
246246
assertNull(mavenCoordinates.getClassifier());
247247

248-
assertNotNull(libraryFile.getFilters());
249-
assertTrue(libraryFile.getFilters().isEmpty());
248+
assertTrue(jspApi.getFilters().isEmpty());
249+
250+
LibraryFile jstlApi = jspApiLibrary.getLibraryFiles().get(1);
251+
assertThat(jstlApi.getJavadocUri(), is(new URI("https://jstl.java.net/")));
252+
assertNull(jstlApi.getSourceUri());
253+
254+
assertNotNull(jstlApi.getMavenCoordinates());
255+
MavenCoordinates jstlCoordinates = jstlApi.getMavenCoordinates();
256+
assertThat(jstlCoordinates.getRepository(), is("central"));
257+
assertThat(jstlCoordinates.getGroupId(), is("javax.servlet"));
258+
assertThat(jstlCoordinates.getArtifactId(), is("jstl"));
259+
assertThat(jstlCoordinates.getVersion(), is("1.2"));
260+
assertThat(jstlCoordinates.getType(), is("jar"));
261+
assertNull(jstlCoordinates.getClassifier());
262+
263+
assertTrue(jstlApi.getFilters().isEmpty());
250264
}
251265

252266
}

plugins/com.google.cloud.tools.eclipse.appengine.libraries.test/src/com/google/cloud/tools/eclipse/appengine/libraries/PomTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,6 @@ public void testAddDependencies()
124124
Assert.assertEquals("com.example.group3", groupId3.getTextContent());
125125
Element artifactId3 = getOnlyChild(child3, "artifactId");
126126
Assert.assertEquals("artifact3", artifactId3.getTextContent());
127-
Element version3 = getOnlyChild(child3, "version");
128-
Assert.assertEquals("LATEST", version3.getTextContent());
129127

130128
// now make sure the comment didn't move to the end
131129
// https://bugs.openjdk.java.net/browse/JDK-8146163

0 commit comments

Comments
 (0)