Skip to content

Commit 2fe8e48

Browse files
committed
Display email in settings when logged in, and note that email can be used to log in
1 parent 0be5b14 commit 2fe8e48

File tree

6 files changed

+101
-57
lines changed

6 files changed

+101
-57
lines changed

maven-wrapper/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
<dependency>
4747
<groupId>${project.groupId}</groupId>
4848
<artifactId>core</artifactId>
49-
<version>0.10.5-SNAPSHOT</version>
49+
<version>0.10.6-SNAPSHOT</version>
5050
</dependency>
5151
<dependency>
5252
<groupId>${project.groupId}</groupId>

tmc-plugin/src/fi/helsinki/cs/tmc/coreimpl/TmcCoreSettingsImpl.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.nio.file.Path;
2222
import java.nio.file.Paths;
2323
import java.util.Locale;
24+
2425
import org.apache.http.impl.conn.SystemDefaultRoutePlanner;
2526
import org.openide.filesystems.FileObject;
2627
import org.openide.filesystems.FileUtil;
@@ -31,7 +32,9 @@ public class TmcCoreSettingsImpl implements TmcSettings {
3132

3233

3334
private static final String PREF_BASE_URL = "baseUrl";
35+
private static final String PREF_ID = "id";
3436
private static final String PREF_USERNAME = "username";
37+
private static final String PREF_EMAIL = "email";
3538
private static final String PREF_PASSWORD = "password";
3639
private static final String PREF_PROJECT_ROOT_DIR = "projectRootDir";
3740
private static final String PREF_CHECK_FOR_UPDATES_IN_BACKGROUND = "checkForUpdatesInBackground";
@@ -182,6 +185,31 @@ public void setOrganization(Optional<Organization> organization) {
182185
}
183186
}
184187

188+
@Override
189+
public Optional<String> getEmail() {
190+
return Optional.of(settings.get(PREF_EMAIL, ""));
191+
}
192+
193+
@Override
194+
public void setEmail(String email) {
195+
settings.put(PREF_EMAIL, email);
196+
}
197+
198+
@Override
199+
public Optional<Integer> getId() {
200+
String idAsString = settings.get(PREF_ID, "");
201+
if (idAsString.isEmpty()) {
202+
return Optional.absent();
203+
}
204+
int id = Integer.parseInt(idAsString);
205+
return Optional.of(id);
206+
}
207+
208+
@Override
209+
public void setId(int id) {
210+
settings.put(PREF_ID, "" + id);
211+
}
212+
185213
public static class SavedEvent implements TmcEvent {}
186214

187215
public TmcCoreSettingsImpl() {
@@ -220,6 +248,7 @@ public Optional<String> getUsername() {
220248
return Optional.of(settings.get(PREF_USERNAME, tailoring.getDefaultUsername()));
221249
}
222250

251+
@Override
223252
public void setUsername(String username) {
224253
settings.put(PREF_USERNAME, username);
225254
}

tmc-plugin/src/fi/helsinki/cs/tmc/ui/Bundle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ DownloadOrUpdateExercisesDialog.closeButton.text=Close
2626
LoginDialog.loginButton.text=Log in
2727
LoginDialog.cancelButton.text=Cancel
2828
LoginDialog.titleLabel.text=Log in to TMC
29-
LoginDialog.usernameLabel.text=Username
29+
LoginDialog.usernameLabel.text=Email or username
3030
LoginDialog.passwordLabel.text=Password
3131
LoginDialog.title=TMC Login
3232
SubmissionResultWaitingDialog.waitingLabel.text=Waiting for results from the server.

tmc-plugin/src/fi/helsinki/cs/tmc/ui/LoginDialog.form

Lines changed: 38 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -33,34 +33,44 @@
3333
<DimensionLayout dim="0">
3434
<Group type="103" groupAlignment="0" attributes="0">
3535
<Group type="102" attributes="0">
36-
<EmptySpace min="12" pref="12" max="-2" attributes="0"/>
37-
<Component id="titleLabel" min="-2" max="-2" attributes="0"/>
38-
</Group>
39-
<Group type="102" attributes="0">
40-
<EmptySpace min="12" pref="12" max="-2" attributes="0"/>
41-
<Component id="serverLabel" min="-2" max="-2" attributes="0"/>
42-
<EmptySpace min="38" pref="38" max="-2" attributes="0"/>
43-
<Component id="addressLabel" min="-2" pref="214" max="-2" attributes="0"/>
44-
<EmptySpace min="12" pref="12" max="-2" attributes="0"/>
45-
<Component id="changeServerButton" min="-2" max="-2" attributes="0"/>
46-
</Group>
47-
<Group type="102" attributes="0">
48-
<EmptySpace min="12" pref="12" max="-2" attributes="0"/>
49-
<Component id="usernameLabel" min="-2" max="-2" attributes="0"/>
50-
<EmptySpace min="12" pref="12" max="-2" attributes="0"/>
51-
<Component id="usernameField" min="-2" pref="292" max="-2" attributes="0"/>
52-
</Group>
53-
<Group type="102" attributes="0">
54-
<EmptySpace min="12" pref="12" max="-2" attributes="0"/>
55-
<Component id="passwordLabel" min="-2" max="-2" attributes="0"/>
56-
<EmptySpace min="15" pref="15" max="-2" attributes="0"/>
57-
<Component id="passwordField" min="-2" pref="292" max="-2" attributes="0"/>
58-
</Group>
59-
<Group type="102" attributes="0">
60-
<EmptySpace min="268" pref="268" max="-2" attributes="0"/>
61-
<Component id="loginButton" min="-2" max="-2" attributes="0"/>
62-
<EmptySpace min="6" pref="6" max="-2" attributes="0"/>
63-
<Component id="cancelButton" min="-2" max="-2" attributes="0"/>
36+
<Group type="103" groupAlignment="0" attributes="0">
37+
<Group type="102" attributes="0">
38+
<EmptySpace min="12" pref="12" max="-2" attributes="0"/>
39+
<Component id="titleLabel" min="-2" max="-2" attributes="0"/>
40+
</Group>
41+
<Group type="102" attributes="0">
42+
<EmptySpace min="12" pref="12" max="-2" attributes="0"/>
43+
<Component id="serverLabel" min="-2" max="-2" attributes="0"/>
44+
<EmptySpace min="38" pref="38" max="-2" attributes="0"/>
45+
<Component id="addressLabel" min="-2" pref="214" max="-2" attributes="0"/>
46+
<EmptySpace min="12" pref="12" max="-2" attributes="0"/>
47+
<Component id="changeServerButton" min="-2" max="-2" attributes="0"/>
48+
</Group>
49+
<Group type="102" attributes="0">
50+
<EmptySpace min="268" pref="268" max="-2" attributes="0"/>
51+
<Component id="loginButton" min="-2" max="-2" attributes="0"/>
52+
<EmptySpace min="6" pref="6" max="-2" attributes="0"/>
53+
<Component id="cancelButton" min="-2" max="-2" attributes="0"/>
54+
</Group>
55+
<Group type="102" alignment="1" attributes="0">
56+
<EmptySpace min="12" pref="12" max="-2" attributes="0"/>
57+
<Group type="103" groupAlignment="0" attributes="0">
58+
<Group type="102" alignment="1" attributes="0">
59+
<Component id="usernameLabel" min="-2" max="-2" attributes="0"/>
60+
<EmptySpace max="-2" attributes="0"/>
61+
</Group>
62+
<Group type="102" alignment="0" attributes="0">
63+
<Component id="passwordLabel" min="-2" max="-2" attributes="0"/>
64+
<EmptySpace min="-2" pref="72" max="-2" attributes="0"/>
65+
</Group>
66+
</Group>
67+
<Group type="103" groupAlignment="0" max="-2" attributes="0">
68+
<Component id="passwordField" pref="235" max="32767" attributes="0"/>
69+
<Component id="usernameField" max="32767" attributes="0"/>
70+
</Group>
71+
</Group>
72+
</Group>
73+
<EmptySpace min="-2" pref="57" max="-2" attributes="0"/>
6474
</Group>
6575
</Group>
6676
</DimensionLayout>

tmc-plugin/src/fi/helsinki/cs/tmc/ui/LoginDialog.java

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -155,30 +155,35 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
155155
layout.setHorizontalGroup(
156156
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
157157
.addGroup(layout.createSequentialGroup()
158-
.addGap(12, 12, 12)
159-
.addComponent(titleLabel))
160-
.addGroup(layout.createSequentialGroup()
161-
.addGap(12, 12, 12)
162-
.addComponent(serverLabel)
163-
.addGap(38, 38, 38)
164-
.addComponent(addressLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 214, javax.swing.GroupLayout.PREFERRED_SIZE)
165-
.addGap(12, 12, 12)
166-
.addComponent(changeServerButton))
167-
.addGroup(layout.createSequentialGroup()
168-
.addGap(12, 12, 12)
169-
.addComponent(usernameLabel)
170-
.addGap(12, 12, 12)
171-
.addComponent(usernameField, javax.swing.GroupLayout.PREFERRED_SIZE, 292, javax.swing.GroupLayout.PREFERRED_SIZE))
172-
.addGroup(layout.createSequentialGroup()
173-
.addGap(12, 12, 12)
174-
.addComponent(passwordLabel)
175-
.addGap(15, 15, 15)
176-
.addComponent(passwordField, javax.swing.GroupLayout.PREFERRED_SIZE, 292, javax.swing.GroupLayout.PREFERRED_SIZE))
177-
.addGroup(layout.createSequentialGroup()
178-
.addGap(268, 268, 268)
179-
.addComponent(loginButton)
180-
.addGap(6, 6, 6)
181-
.addComponent(cancelButton))
158+
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
159+
.addGroup(layout.createSequentialGroup()
160+
.addGap(12, 12, 12)
161+
.addComponent(titleLabel))
162+
.addGroup(layout.createSequentialGroup()
163+
.addGap(12, 12, 12)
164+
.addComponent(serverLabel)
165+
.addGap(38, 38, 38)
166+
.addComponent(addressLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 214, javax.swing.GroupLayout.PREFERRED_SIZE)
167+
.addGap(12, 12, 12)
168+
.addComponent(changeServerButton))
169+
.addGroup(layout.createSequentialGroup()
170+
.addGap(268, 268, 268)
171+
.addComponent(loginButton)
172+
.addGap(6, 6, 6)
173+
.addComponent(cancelButton))
174+
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
175+
.addGap(12, 12, 12)
176+
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
177+
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
178+
.addComponent(usernameLabel)
179+
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
180+
.addGroup(layout.createSequentialGroup()
181+
.addComponent(passwordLabel)
182+
.addGap(72, 72, 72)))
183+
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
184+
.addComponent(passwordField, javax.swing.GroupLayout.DEFAULT_SIZE, 235, Short.MAX_VALUE)
185+
.addComponent(usernameField))))
186+
.addGap(57, 57, 57))
182187
);
183188
layout.setVerticalGroup(
184189
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

tmc-plugin/src/fi/helsinki/cs/tmc/ui/PreferencesPanel.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@
4949
}
5050

5151
private void updateFields() {
52-
final Optional<String> username = this.settings.getUsername();
52+
final Optional<String> email = this.settings.getEmail();
5353
final JLabel login = this.loginLabel;
5454
final JButton logout = this.logoutButton;
55-
if (username.isPresent()) {
56-
login.setText("Logged in as " + username.get());
55+
if (email.isPresent()) {
56+
login.setText("Logged in as " + email.get());
5757
logout.setEnabled(true);
5858
} else {
5959
login.setText("Not logged in!");

0 commit comments

Comments
 (0)