mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
cloud work - user management
This commit is contained in:
Binary file not shown.
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package org.diylc.swing.plugins.cloud.model;
|
package org.diylc.plugins.cloud.model;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
+14
-1
@@ -1,4 +1,4 @@
|
|||||||
package org.diylc.swing.plugins.cloud.model;
|
package org.diylc.plugins.cloud.model;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -62,6 +62,19 @@ public interface ServiceAPI {
|
|||||||
@ParamName("password") String password,
|
@ParamName("password") String password,
|
||||||
@ParamName("machineId") String machineId);
|
@ParamName("machineId") String machineId);
|
||||||
|
|
||||||
|
/***
|
||||||
|
* Retrieves current user's details.
|
||||||
|
*
|
||||||
|
* @param username
|
||||||
|
* @param password
|
||||||
|
* @param machineId
|
||||||
|
* @return string with an error message if it fails, or an instance of
|
||||||
|
* {@link UserEntity} if it succeeds.
|
||||||
|
*/
|
||||||
|
Object getUserDetails(@ParamName("username") String username,
|
||||||
|
@ParamName("token") String token,
|
||||||
|
@ParamName("machineId") String machineId);
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* Tries to authenticate with the token that was previously created by
|
* Tries to authenticate with the token that was previously created by
|
||||||
* calling login() function.
|
* calling login() function.
|
||||||
+13
-44
@@ -1,4 +1,4 @@
|
|||||||
package org.diylc.swing.plugins.cloud.model;
|
package org.diylc.plugins.cloud.model;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
@@ -6,46 +6,25 @@ public class UserEntity implements Serializable {
|
|||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private int id;
|
private String username;
|
||||||
private String userName;
|
|
||||||
private String password;
|
|
||||||
private String email;
|
private String email;
|
||||||
private String website;
|
private String website;
|
||||||
private String bio;
|
private String bio;
|
||||||
|
|
||||||
public UserEntity(int id, String userName, String password, String email,
|
public UserEntity(String userName, String email, String website, String bio) {
|
||||||
String website, String bio) {
|
|
||||||
super();
|
super();
|
||||||
this.id = id;
|
this.username = username;
|
||||||
this.userName = userName;
|
|
||||||
this.password = password;
|
|
||||||
this.email = email;
|
this.email = email;
|
||||||
this.website = website;
|
this.website = website;
|
||||||
this.bio = bio;
|
this.bio = bio;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId() {
|
public String getUsername() {
|
||||||
return id;
|
return username;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(int id) {
|
public void setUsername(String username) {
|
||||||
this.id = id;
|
this.username = username;
|
||||||
}
|
|
||||||
|
|
||||||
public String getUserName() {
|
|
||||||
return userName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUserName(String userName) {
|
|
||||||
this.userName = userName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPassword() {
|
|
||||||
return password;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPassword(String password) {
|
|
||||||
this.password = password;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEmail() {
|
public String getEmail() {
|
||||||
@@ -78,11 +57,8 @@ public class UserEntity implements Serializable {
|
|||||||
int result = 1;
|
int result = 1;
|
||||||
result = prime * result + ((bio == null) ? 0 : bio.hashCode());
|
result = prime * result + ((bio == null) ? 0 : bio.hashCode());
|
||||||
result = prime * result + ((email == null) ? 0 : email.hashCode());
|
result = prime * result + ((email == null) ? 0 : email.hashCode());
|
||||||
result = prime * result + id;
|
|
||||||
result = prime * result
|
result = prime * result
|
||||||
+ ((password == null) ? 0 : password.hashCode());
|
+ ((username == null) ? 0 : username.hashCode());
|
||||||
result = prime * result
|
|
||||||
+ ((userName == null) ? 0 : userName.hashCode());
|
|
||||||
result = prime * result + ((website == null) ? 0 : website.hashCode());
|
result = prime * result + ((website == null) ? 0 : website.hashCode());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -106,17 +82,10 @@ public class UserEntity implements Serializable {
|
|||||||
return false;
|
return false;
|
||||||
} else if (!email.equals(other.email))
|
} else if (!email.equals(other.email))
|
||||||
return false;
|
return false;
|
||||||
if (id != other.id)
|
if (username == null) {
|
||||||
return false;
|
if (other.username != null)
|
||||||
if (password == null) {
|
|
||||||
if (other.password != null)
|
|
||||||
return false;
|
return false;
|
||||||
} else if (!password.equals(other.password))
|
} else if (!username.equals(other.username))
|
||||||
return false;
|
|
||||||
if (userName == null) {
|
|
||||||
if (other.userName != null)
|
|
||||||
return false;
|
|
||||||
} else if (!userName.equals(other.userName))
|
|
||||||
return false;
|
return false;
|
||||||
if (website == null) {
|
if (website == null) {
|
||||||
if (other.website != null)
|
if (other.website != null)
|
||||||
@@ -128,7 +97,7 @@ public class UserEntity implements Serializable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "UserEntity [userName=" + userName + "]";
|
return "UserEntity [userName=" + username + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package org.diylc.swing.plugins.cloud.presenter;
|
package org.diylc.plugins.cloud.presenter;
|
||||||
|
|
||||||
public class CloudException extends Exception {
|
public class CloudException extends Exception {
|
||||||
|
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package org.diylc.swing.plugins.cloud.presenter;
|
package org.diylc.plugins.cloud.presenter;
|
||||||
|
|
||||||
public interface CloudListener {
|
public interface CloudListener {
|
||||||
|
|
||||||
+24
-5
@@ -1,17 +1,15 @@
|
|||||||
package org.diylc.swing.plugins.cloud.presenter;
|
package org.diylc.plugins.cloud.presenter;
|
||||||
|
|
||||||
import java.awt.image.RenderedImage;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.NetworkInterface;
|
import java.net.NetworkInterface;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||||
import org.diylc.swing.plugins.cloud.model.ServiceAPI;
|
import org.diylc.plugins.cloud.model.ServiceAPI;
|
||||||
|
import org.diylc.plugins.cloud.model.UserEntity;
|
||||||
|
|
||||||
import com.diyfever.httpproxy.PhpFlatProxy;
|
import com.diyfever.httpproxy.PhpFlatProxy;
|
||||||
import com.diyfever.httpproxy.ProxyFactory;
|
import com.diyfever.httpproxy.ProxyFactory;
|
||||||
@@ -160,6 +158,27 @@ public class CloudPresenter {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UserEntity getUserDetails() throws CloudException {
|
||||||
|
String username = ConfigurationManager.getInstance().readString(
|
||||||
|
USERNAME_KEY, null);
|
||||||
|
String token = ConfigurationManager.getInstance().readString(TOKEN_KEY,
|
||||||
|
null);
|
||||||
|
|
||||||
|
Object res;
|
||||||
|
try {
|
||||||
|
res = service.getUserDetails(username, token, getMachineId());
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new CloudException(e);
|
||||||
|
}
|
||||||
|
if (res instanceof String)
|
||||||
|
throw new CloudException(res.toString());
|
||||||
|
if (res instanceof UserEntity)
|
||||||
|
return (UserEntity) res;
|
||||||
|
throw new CloudException(
|
||||||
|
"Unexpected server response received for category list: "
|
||||||
|
+ res.getClass().getName());
|
||||||
|
}
|
||||||
|
|
||||||
private String getMachineId() {
|
private String getMachineId() {
|
||||||
if (machineId == null) {
|
if (machineId == null) {
|
||||||
try {
|
try {
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package org.diylc.swing.plugins.cloud.presenter;
|
package org.diylc.plugins.cloud.presenter;
|
||||||
|
|
||||||
public class NotConnectedException extends Exception {
|
public class NotConnectedException extends Exception {
|
||||||
|
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package org.diylc.swing.plugins.cloud.presenter;
|
package org.diylc.plugins.cloud.presenter;
|
||||||
|
|
||||||
public class NotExistsException extends Exception {
|
public class NotExistsException extends Exception {
|
||||||
|
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package org.diylc.swing.plugins.cloud.presenter;
|
package org.diylc.plugins.cloud.presenter;
|
||||||
|
|
||||||
public class NotLoggedInException extends Exception {
|
public class NotLoggedInException extends Exception {
|
||||||
|
|
||||||
@@ -2,5 +2,7 @@
|
|||||||
/.apt_generated
|
/.apt_generated
|
||||||
/log/
|
/log/
|
||||||
/build/
|
/build/
|
||||||
|
/library/
|
||||||
|
/lib/diylc-core.jar
|
||||||
autoSave.diy
|
autoSave.diy
|
||||||
config.xml
|
config.xml
|
||||||
+2
-1
@@ -41,7 +41,8 @@ public enum IconLoader {
|
|||||||
"briefcase_into.png"), RotateCW("rotate_cw.png"), RotateCCW(
|
"briefcase_into.png"), RotateCW("rotate_cw.png"), RotateCCW(
|
||||||
"rotate_ccw.png"), ElementInto("element_into.png"), Arrow(
|
"rotate_ccw.png"), ElementInto("element_into.png"), Arrow(
|
||||||
"arrow.png"), Cloud("cloud.png"), CloudUp("cloud_up.png"), CloudGear(
|
"arrow.png"), Cloud("cloud.png"), CloudUp("cloud_up.png"), CloudGear(
|
||||||
"cloud_gear.png"), IdCardEdit("id_card_edit.png");
|
"cloud_gear.png"), IdCardEdit("id_card_edit.png"), KeyEdit(
|
||||||
|
"key_edit.png");
|
||||||
|
|
||||||
protected String name;
|
protected String name;
|
||||||
|
|
||||||
|
|||||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 924 B |
+5
-5
@@ -11,12 +11,12 @@ import javax.swing.filechooser.FileFilter;
|
|||||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||||
import org.diylc.common.IPlugInPort;
|
import org.diylc.common.IPlugInPort;
|
||||||
import org.diylc.common.PropertyWrapper;
|
import org.diylc.common.PropertyWrapper;
|
||||||
|
import org.diylc.plugins.cloud.model.UserEntity;
|
||||||
|
import org.diylc.plugins.cloud.presenter.CloudPresenter;
|
||||||
import org.diylc.swing.gui.components.OverwritePromptFileChooser;
|
import org.diylc.swing.gui.components.OverwritePromptFileChooser;
|
||||||
import org.diylc.swing.gui.editor.PropertyEditorDialog;
|
import org.diylc.swing.gui.editor.PropertyEditorDialog;
|
||||||
import org.diylc.swing.plugins.cloud.model.UserEntity;
|
|
||||||
import org.diylc.swing.plugins.cloud.presenter.CloudPresenter;
|
|
||||||
import org.diylc.swing.plugins.cloud.view.LoginDialog;
|
import org.diylc.swing.plugins.cloud.view.LoginDialog;
|
||||||
import org.diylc.swing.plugins.cloud.view.NewUserDialog;
|
import org.diylc.swing.plugins.cloud.view.UserEditDialog;
|
||||||
import org.diylc.swing.plugins.cloud.view.UploadDialog;
|
import org.diylc.swing.plugins.cloud.view.UploadDialog;
|
||||||
import org.diylc.swing.plugins.file.BomDialog;
|
import org.diylc.swing.plugins.file.BomDialog;
|
||||||
import org.diylc.swingframework.AboutDialog;
|
import org.diylc.swingframework.AboutDialog;
|
||||||
@@ -141,8 +141,8 @@ public class DialogFactory {
|
|||||||
return dialog;
|
return dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NewUserDialog createNewUserDialog(UserEntity existingUser) {
|
public UserEditDialog createUserEditDialog(UserEntity existingUser) {
|
||||||
NewUserDialog dialog = new NewUserDialog(mainFrame, existingUser);
|
UserEditDialog dialog = new UserEditDialog(mainFrame, existingUser);
|
||||||
return dialog;
|
return dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+74
-9
@@ -14,15 +14,16 @@ import org.diylc.common.IPlugInPort;
|
|||||||
import org.diylc.common.ITask;
|
import org.diylc.common.ITask;
|
||||||
import org.diylc.core.IView;
|
import org.diylc.core.IView;
|
||||||
import org.diylc.images.IconLoader;
|
import org.diylc.images.IconLoader;
|
||||||
|
import org.diylc.plugins.cloud.model.UserEntity;
|
||||||
|
import org.diylc.plugins.cloud.presenter.CloudException;
|
||||||
|
import org.diylc.plugins.cloud.presenter.CloudListener;
|
||||||
|
import org.diylc.plugins.cloud.presenter.CloudPresenter;
|
||||||
import org.diylc.presenter.Presenter;
|
import org.diylc.presenter.Presenter;
|
||||||
import org.diylc.swing.ISwingUI;
|
import org.diylc.swing.ISwingUI;
|
||||||
import org.diylc.swing.gui.DialogFactory;
|
import org.diylc.swing.gui.DialogFactory;
|
||||||
import org.diylc.swing.gui.DummyView;
|
import org.diylc.swing.gui.DummyView;
|
||||||
import org.diylc.swing.plugins.cloud.presenter.CloudException;
|
|
||||||
import org.diylc.swing.plugins.cloud.presenter.CloudListener;
|
|
||||||
import org.diylc.swing.plugins.cloud.presenter.CloudPresenter;
|
|
||||||
import org.diylc.swing.plugins.cloud.view.LoginDialog;
|
import org.diylc.swing.plugins.cloud.view.LoginDialog;
|
||||||
import org.diylc.swing.plugins.cloud.view.NewUserDialog;
|
import org.diylc.swing.plugins.cloud.view.UserEditDialog;
|
||||||
import org.diylc.swing.plugins.cloud.view.UploadDialog;
|
import org.diylc.swing.plugins.cloud.view.UploadDialog;
|
||||||
import org.diylc.swing.plugins.file.FileFilterEnum;
|
import org.diylc.swing.plugins.file.FileFilterEnum;
|
||||||
import org.diylc.swingframework.ButtonDialog;
|
import org.diylc.swingframework.ButtonDialog;
|
||||||
@@ -47,6 +48,7 @@ public class CloudPlugIn implements IPlugIn, CloudListener {
|
|||||||
private ManageAccountAction manageAccountAction;
|
private ManageAccountAction manageAccountAction;
|
||||||
|
|
||||||
private UploadAction uploadAction;
|
private UploadAction uploadAction;
|
||||||
|
private ChangePasswordAction changePasswordAction;
|
||||||
private ManageProjectsAction manageProjectsAction;
|
private ManageProjectsAction manageProjectsAction;
|
||||||
|
|
||||||
public CloudPlugIn(ISwingUI swingUI) {
|
public CloudPlugIn(ISwingUI swingUI) {
|
||||||
@@ -64,6 +66,7 @@ public class CloudPlugIn implements IPlugIn, CloudListener {
|
|||||||
swingUI.injectMenuAction(getManageProjectsAction(), ONLINE_TITLE);
|
swingUI.injectMenuAction(getManageProjectsAction(), ONLINE_TITLE);
|
||||||
swingUI.injectMenuAction(null, ONLINE_TITLE);
|
swingUI.injectMenuAction(null, ONLINE_TITLE);
|
||||||
swingUI.injectMenuAction(getManageAccountAction(), ONLINE_TITLE);
|
swingUI.injectMenuAction(getManageAccountAction(), ONLINE_TITLE);
|
||||||
|
swingUI.injectMenuAction(getChangePasswordAction(), ONLINE_TITLE);
|
||||||
swingUI.injectMenuAction(getLogOutAction(), ONLINE_TITLE);
|
swingUI.injectMenuAction(getLogOutAction(), ONLINE_TITLE);
|
||||||
|
|
||||||
// default state
|
// default state
|
||||||
@@ -147,6 +150,14 @@ public class CloudPlugIn implements IPlugIn, CloudListener {
|
|||||||
return uploadAction;
|
return uploadAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ChangePasswordAction getChangePasswordAction() {
|
||||||
|
if (changePasswordAction == null)
|
||||||
|
{
|
||||||
|
changePasswordAction = new ChangePasswordAction();
|
||||||
|
}
|
||||||
|
return changePasswordAction;
|
||||||
|
}
|
||||||
|
|
||||||
public ManageProjectsAction getManageProjectsAction() {
|
public ManageProjectsAction getManageProjectsAction() {
|
||||||
if (manageProjectsAction == null) {
|
if (manageProjectsAction == null) {
|
||||||
manageProjectsAction = new ManageProjectsAction();
|
manageProjectsAction = new ManageProjectsAction();
|
||||||
@@ -247,8 +258,8 @@ public class CloudPlugIn implements IPlugIn, CloudListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
NewUserDialog dialog = DialogFactory.getInstance()
|
UserEditDialog dialog = DialogFactory.getInstance()
|
||||||
.createNewUserDialog(null);
|
.createUserEditDialog(null);
|
||||||
dialog.setVisible(true);
|
dialog.setVisible(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -265,9 +276,63 @@ public class CloudPlugIn implements IPlugIn, CloudListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
NewUserDialog dialog = DialogFactory.getInstance()
|
swingUI.executeBackgroundTask(new ITask<UserEntity>() {
|
||||||
.createNewUserDialog(null);
|
|
||||||
dialog.setVisible(true);
|
@Override
|
||||||
|
public UserEntity doInBackground() throws Exception {
|
||||||
|
return cloudPresenter.getUserDetails();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void failed(Exception e) {
|
||||||
|
swingUI.showMessage(
|
||||||
|
"Failed to retreive user details from the server.",
|
||||||
|
"Cloud Error", IView.ERROR_MESSAGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void complete(UserEntity result) {
|
||||||
|
UserEditDialog dialog = DialogFactory.getInstance()
|
||||||
|
.createUserEditDialog(result);
|
||||||
|
dialog.setVisible(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ChangePasswordAction extends AbstractAction {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public ChangePasswordAction() {
|
||||||
|
super();
|
||||||
|
putValue(AbstractAction.NAME, "Change Password");
|
||||||
|
putValue(AbstractAction.SMALL_ICON, IconLoader.KeyEdit.getIcon());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
swingUI.executeBackgroundTask(new ITask<UserEntity>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UserEntity doInBackground() throws Exception {
|
||||||
|
return cloudPresenter.getUserDetails();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void failed(Exception e) {
|
||||||
|
swingUI.showMessage(
|
||||||
|
"Failed to retreive user details from the server.",
|
||||||
|
"Cloud Error", IView.ERROR_MESSAGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void complete(UserEntity result) {
|
||||||
|
UserEditDialog dialog = DialogFactory.getInstance()
|
||||||
|
.createUserEditDialog(result);
|
||||||
|
dialog.setVisible(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+16
-21
@@ -26,8 +26,8 @@ import javax.swing.event.ChangeListener;
|
|||||||
|
|
||||||
import org.diylc.common.DrawOption;
|
import org.diylc.common.DrawOption;
|
||||||
import org.diylc.common.IPlugInPort;
|
import org.diylc.common.IPlugInPort;
|
||||||
import org.diylc.swing.plugins.cloud.presenter.CloudException;
|
import org.diylc.plugins.cloud.presenter.CloudException;
|
||||||
import org.diylc.swing.plugins.cloud.presenter.CloudPresenter;
|
import org.diylc.plugins.cloud.presenter.CloudPresenter;
|
||||||
import org.diylc.swingframework.ButtonDialog;
|
import org.diylc.swingframework.ButtonDialog;
|
||||||
|
|
||||||
public class UploadDialog extends ButtonDialog {
|
public class UploadDialog extends ButtonDialog {
|
||||||
@@ -87,43 +87,38 @@ public class UploadDialog extends ButtonDialog {
|
|||||||
gbc.gridheight = 1;
|
gbc.gridheight = 1;
|
||||||
gbc.gridx = 1;
|
gbc.gridx = 1;
|
||||||
gbc.weightx = 0;
|
gbc.weightx = 0;
|
||||||
|
gbc.insets = new Insets(4, 2, 2, 2);
|
||||||
gbc.fill = GridBagConstraints.HORIZONTAL;
|
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||||
mainPanel.add(new JLabel("Project Name: "), gbc);
|
mainPanel.add(new JLabel("Project Name: "), gbc);
|
||||||
|
|
||||||
gbc.gridx = 2;
|
|
||||||
gbc.weightx = 1;
|
|
||||||
mainPanel.add(getNameField(), gbc);
|
|
||||||
|
|
||||||
gbc.gridx = 1;
|
|
||||||
gbc.gridy = 1;
|
gbc.gridy = 1;
|
||||||
gbc.weightx = 0;
|
|
||||||
mainPanel.add(new JLabel("Category:"), gbc);
|
mainPanel.add(new JLabel("Category:"), gbc);
|
||||||
|
|
||||||
gbc.gridx = 2;
|
|
||||||
gbc.weightx = 1;
|
|
||||||
mainPanel.add(getCategoryBox(), gbc);
|
|
||||||
|
|
||||||
gbc.gridx = 1;
|
|
||||||
gbc.gridy = 2;
|
gbc.gridy = 2;
|
||||||
gbc.weightx = 0;
|
|
||||||
|
|
||||||
mainPanel.add(new JLabel("Description: "), gbc);
|
mainPanel.add(new JLabel("Description: "), gbc);
|
||||||
|
|
||||||
|
gbc.gridy = 3;
|
||||||
|
mainPanel.add(new JLabel("Keywords: "), gbc);
|
||||||
|
|
||||||
gbc.gridx = 2;
|
gbc.gridx = 2;
|
||||||
|
gbc.gridy = 0;
|
||||||
|
gbc.weightx = 1;
|
||||||
|
gbc.insets = new Insets(2, 2, 2, 2);
|
||||||
|
mainPanel.add(getNameField(), gbc);
|
||||||
|
|
||||||
|
gbc.gridy = 1;
|
||||||
|
mainPanel.add(getCategoryBox(), gbc);
|
||||||
|
|
||||||
|
gbc.gridy = 2;
|
||||||
gbc.weightx = 1;
|
gbc.weightx = 1;
|
||||||
gbc.weighty = 1;
|
gbc.weighty = 1;
|
||||||
gbc.fill = GridBagConstraints.BOTH;
|
gbc.fill = GridBagConstraints.BOTH;
|
||||||
mainPanel.add(getDescriptionArea(), gbc);
|
mainPanel.add(getDescriptionArea(), gbc);
|
||||||
|
|
||||||
gbc.gridx = 1;
|
|
||||||
gbc.gridy = 3;
|
gbc.gridy = 3;
|
||||||
gbc.weightx = 0;
|
|
||||||
gbc.weighty = 0;
|
gbc.weighty = 0;
|
||||||
gbc.fill = GridBagConstraints.HORIZONTAL;
|
|
||||||
mainPanel.add(new JLabel("Keywords: "), gbc);
|
|
||||||
|
|
||||||
gbc.gridx = 2;
|
|
||||||
gbc.weightx = 1;
|
gbc.weightx = 1;
|
||||||
|
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||||
mainPanel.add(getKeywordsField(), gbc);
|
mainPanel.add(getKeywordsField(), gbc);
|
||||||
|
|
||||||
gbc.gridx = 0;
|
gbc.gridx = 0;
|
||||||
|
|||||||
+27
-17
@@ -17,10 +17,10 @@ import javax.swing.JTextField;
|
|||||||
import javax.swing.event.DocumentEvent;
|
import javax.swing.event.DocumentEvent;
|
||||||
import javax.swing.event.DocumentListener;
|
import javax.swing.event.DocumentListener;
|
||||||
|
|
||||||
import org.diylc.swing.plugins.cloud.model.UserEntity;
|
import org.diylc.plugins.cloud.model.UserEntity;
|
||||||
import org.diylc.swingframework.ButtonDialog;
|
import org.diylc.swingframework.ButtonDialog;
|
||||||
|
|
||||||
public class NewUserDialog extends ButtonDialog {
|
public class UserEditDialog extends ButtonDialog {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@@ -41,13 +41,15 @@ public class NewUserDialog extends ButtonDialog {
|
|||||||
|
|
||||||
private UserEntity existingEntity;
|
private UserEntity existingEntity;
|
||||||
|
|
||||||
public NewUserDialog(JFrame owner, UserEntity existingEntity) {
|
public UserEditDialog(JFrame owner, UserEntity existingEntity) {
|
||||||
super(owner, "New Account", new String[] { OK, CANCEL });
|
super(owner, existingEntity == null ? "New Account" : "Manage Account",
|
||||||
|
new String[] { OK, CANCEL });
|
||||||
|
|
||||||
|
this.existingEntity = existingEntity;
|
||||||
|
|
||||||
setMinimumSize(new Dimension(240, 32));
|
setMinimumSize(new Dimension(240, 32));
|
||||||
layoutGui();
|
layoutGui();
|
||||||
refreshState();
|
refreshState();
|
||||||
userNameField.setText(System.getProperty("user.name"));
|
|
||||||
this.existingEntity = existingEntity;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUserName() {
|
public String getUserName() {
|
||||||
@@ -77,20 +79,22 @@ public class NewUserDialog extends ButtonDialog {
|
|||||||
mainPanel.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));
|
mainPanel.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));
|
||||||
|
|
||||||
GridBagConstraints gbc = new GridBagConstraints();
|
GridBagConstraints gbc = new GridBagConstraints();
|
||||||
gbc.anchor = GridBagConstraints.LINE_START;
|
gbc.anchor = GridBagConstraints.NORTHWEST;
|
||||||
gbc.fill = GridBagConstraints.NONE;
|
gbc.fill = GridBagConstraints.NONE;
|
||||||
gbc.insets = new Insets(2, 2, 2, 2);
|
gbc.insets = new Insets(4, 2, 2, 2);
|
||||||
|
|
||||||
gbc.gridx = 0;
|
gbc.gridx = 0;
|
||||||
|
|
||||||
gbc.gridy = 0;
|
gbc.gridy = 0;
|
||||||
mainPanel.add(new JLabel("User Name:"), gbc);
|
mainPanel.add(new JLabel("User Name:"), gbc);
|
||||||
|
|
||||||
gbc.gridy = 1;
|
if (existingEntity == null) {
|
||||||
mainPanel.add(new JLabel("Password:"), gbc);
|
gbc.gridy = 1;
|
||||||
|
mainPanel.add(new JLabel("Password:"), gbc);
|
||||||
|
|
||||||
gbc.gridy = 2;
|
gbc.gridy = 2;
|
||||||
mainPanel.add(new JLabel("Confirm Password:"), gbc);
|
mainPanel.add(new JLabel("Confirm Password:"), gbc);
|
||||||
|
}
|
||||||
|
|
||||||
gbc.gridy = 3;
|
gbc.gridy = 3;
|
||||||
mainPanel.add(new JLabel("eMail:"), gbc);
|
mainPanel.add(new JLabel("eMail:"), gbc);
|
||||||
@@ -103,16 +107,19 @@ public class NewUserDialog extends ButtonDialog {
|
|||||||
|
|
||||||
gbc.gridx = 1;
|
gbc.gridx = 1;
|
||||||
gbc.fill = GridBagConstraints.HORIZONTAL;
|
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc.insets = new Insets(2, 2, 2, 2);
|
||||||
gbc.weightx = 1;
|
gbc.weightx = 1;
|
||||||
|
|
||||||
gbc.gridy = 0;
|
gbc.gridy = 0;
|
||||||
mainPanel.add(getUserNameField(), gbc);
|
mainPanel.add(getUserNameField(), gbc);
|
||||||
|
|
||||||
gbc.gridy = 1;
|
if (existingEntity == null) {
|
||||||
mainPanel.add(getPasswordField(), gbc);
|
gbc.gridy = 1;
|
||||||
|
mainPanel.add(getPasswordField(), gbc);
|
||||||
|
|
||||||
gbc.gridy = 2;
|
gbc.gridy = 2;
|
||||||
mainPanel.add(getConfirmPasswordField(), gbc);
|
mainPanel.add(getConfirmPasswordField(), gbc);
|
||||||
|
}
|
||||||
|
|
||||||
gbc.gridy = 3;
|
gbc.gridy = 3;
|
||||||
mainPanel.add(getEmailField(), gbc);
|
mainPanel.add(getEmailField(), gbc);
|
||||||
@@ -148,7 +155,7 @@ public class NewUserDialog extends ButtonDialog {
|
|||||||
if (userNameField == null) {
|
if (userNameField == null) {
|
||||||
userNameField = new JTextField();
|
userNameField = new JTextField();
|
||||||
if (existingEntity != null) {
|
if (existingEntity != null) {
|
||||||
userNameField.setText(existingEntity.getUserName());
|
userNameField.setText(existingEntity.getUsername());
|
||||||
userNameField.setEditable(false);
|
userNameField.setEditable(false);
|
||||||
}
|
}
|
||||||
userNameField.getDocument().addDocumentListener(
|
userNameField.getDocument().addDocumentListener(
|
||||||
@@ -282,6 +289,9 @@ public class NewUserDialog extends ButtonDialog {
|
|||||||
bioArea = new JTextArea();
|
bioArea = new JTextArea();
|
||||||
if (existingEntity != null)
|
if (existingEntity != null)
|
||||||
bioArea.setText(existingEntity.getBio());
|
bioArea.setText(existingEntity.getBio());
|
||||||
|
bioArea.setFont(getUserNameField().getFont());
|
||||||
|
bioArea.setBorder(getUserNameField().getBorder());
|
||||||
|
bioArea.setPreferredSize(new Dimension(192, 69));
|
||||||
bioArea.getDocument().addDocumentListener(new DocumentListener() {
|
bioArea.getDocument().addDocumentListener(new DocumentListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
+1
-1
@@ -8,7 +8,7 @@ import javax.swing.JFrame;
|
|||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
|
|
||||||
import org.apache.log4j.BasicConfigurator;
|
import org.apache.log4j.BasicConfigurator;
|
||||||
import org.diylc.swing.plugins.cloud.model.ProjectEntity;
|
import org.diylc.plugins.cloud.model.ProjectEntity;
|
||||||
import org.diylc.swingframework.objecttable.IActionProcessor;
|
import org.diylc.swingframework.objecttable.IActionProcessor;
|
||||||
import org.diylc.swingframework.objecttable.ObjectListTable;
|
import org.diylc.swingframework.objecttable.ObjectListTable;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user