mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-12 02:02:16 +10:00
cloud work - user management
This commit is contained in:
+2
-1
@@ -41,7 +41,8 @@ public enum IconLoader {
|
||||
"briefcase_into.png"), RotateCW("rotate_cw.png"), RotateCCW(
|
||||
"rotate_ccw.png"), ElementInto("element_into.png"), Arrow(
|
||||
"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;
|
||||
|
||||
|
||||
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.common.IPlugInPort;
|
||||
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.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.NewUserDialog;
|
||||
import org.diylc.swing.plugins.cloud.view.UserEditDialog;
|
||||
import org.diylc.swing.plugins.cloud.view.UploadDialog;
|
||||
import org.diylc.swing.plugins.file.BomDialog;
|
||||
import org.diylc.swingframework.AboutDialog;
|
||||
@@ -141,8 +141,8 @@ public class DialogFactory {
|
||||
return dialog;
|
||||
}
|
||||
|
||||
public NewUserDialog createNewUserDialog(UserEntity existingUser) {
|
||||
NewUserDialog dialog = new NewUserDialog(mainFrame, existingUser);
|
||||
public UserEditDialog createUserEditDialog(UserEntity existingUser) {
|
||||
UserEditDialog dialog = new UserEditDialog(mainFrame, existingUser);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
|
||||
+74
-9
@@ -14,15 +14,16 @@ import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.ITask;
|
||||
import org.diylc.core.IView;
|
||||
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.swing.ISwingUI;
|
||||
import org.diylc.swing.gui.DialogFactory;
|
||||
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.NewUserDialog;
|
||||
import org.diylc.swing.plugins.cloud.view.UserEditDialog;
|
||||
import org.diylc.swing.plugins.cloud.view.UploadDialog;
|
||||
import org.diylc.swing.plugins.file.FileFilterEnum;
|
||||
import org.diylc.swingframework.ButtonDialog;
|
||||
@@ -47,6 +48,7 @@ public class CloudPlugIn implements IPlugIn, CloudListener {
|
||||
private ManageAccountAction manageAccountAction;
|
||||
|
||||
private UploadAction uploadAction;
|
||||
private ChangePasswordAction changePasswordAction;
|
||||
private ManageProjectsAction manageProjectsAction;
|
||||
|
||||
public CloudPlugIn(ISwingUI swingUI) {
|
||||
@@ -64,6 +66,7 @@ public class CloudPlugIn implements IPlugIn, CloudListener {
|
||||
swingUI.injectMenuAction(getManageProjectsAction(), ONLINE_TITLE);
|
||||
swingUI.injectMenuAction(null, ONLINE_TITLE);
|
||||
swingUI.injectMenuAction(getManageAccountAction(), ONLINE_TITLE);
|
||||
swingUI.injectMenuAction(getChangePasswordAction(), ONLINE_TITLE);
|
||||
swingUI.injectMenuAction(getLogOutAction(), ONLINE_TITLE);
|
||||
|
||||
// default state
|
||||
@@ -146,6 +149,14 @@ public class CloudPlugIn implements IPlugIn, CloudListener {
|
||||
}
|
||||
return uploadAction;
|
||||
}
|
||||
|
||||
public ChangePasswordAction getChangePasswordAction() {
|
||||
if (changePasswordAction == null)
|
||||
{
|
||||
changePasswordAction = new ChangePasswordAction();
|
||||
}
|
||||
return changePasswordAction;
|
||||
}
|
||||
|
||||
public ManageProjectsAction getManageProjectsAction() {
|
||||
if (manageProjectsAction == null) {
|
||||
@@ -247,8 +258,8 @@ public class CloudPlugIn implements IPlugIn, CloudListener {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
NewUserDialog dialog = DialogFactory.getInstance()
|
||||
.createNewUserDialog(null);
|
||||
UserEditDialog dialog = DialogFactory.getInstance()
|
||||
.createUserEditDialog(null);
|
||||
dialog.setVisible(true);
|
||||
}
|
||||
}
|
||||
@@ -265,9 +276,63 @@ public class CloudPlugIn implements IPlugIn, CloudListener {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
NewUserDialog dialog = DialogFactory.getInstance()
|
||||
.createNewUserDialog(null);
|
||||
dialog.setVisible(true);
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+17
-22
@@ -26,8 +26,8 @@ import javax.swing.event.ChangeListener;
|
||||
|
||||
import org.diylc.common.DrawOption;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.swing.plugins.cloud.presenter.CloudException;
|
||||
import org.diylc.swing.plugins.cloud.presenter.CloudPresenter;
|
||||
import org.diylc.plugins.cloud.presenter.CloudException;
|
||||
import org.diylc.plugins.cloud.presenter.CloudPresenter;
|
||||
import org.diylc.swingframework.ButtonDialog;
|
||||
|
||||
public class UploadDialog extends ButtonDialog {
|
||||
@@ -87,43 +87,38 @@ public class UploadDialog extends ButtonDialog {
|
||||
gbc.gridheight = 1;
|
||||
gbc.gridx = 1;
|
||||
gbc.weightx = 0;
|
||||
gbc.insets = new Insets(4, 2, 2, 2);
|
||||
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||
mainPanel.add(new JLabel("Project Name: "), gbc);
|
||||
|
||||
gbc.gridy = 1;
|
||||
mainPanel.add(new JLabel("Category:"), gbc);
|
||||
|
||||
gbc.gridy = 2;
|
||||
mainPanel.add(new JLabel("Description: "), gbc);
|
||||
|
||||
gbc.gridy = 3;
|
||||
mainPanel.add(new JLabel("Keywords: "), gbc);
|
||||
|
||||
gbc.gridx = 2;
|
||||
gbc.gridy = 0;
|
||||
gbc.weightx = 1;
|
||||
gbc.insets = new Insets(2, 2, 2, 2);
|
||||
mainPanel.add(getNameField(), gbc);
|
||||
|
||||
gbc.gridx = 1;
|
||||
gbc.gridy = 1;
|
||||
gbc.weightx = 0;
|
||||
mainPanel.add(new JLabel("Category:"), gbc);
|
||||
|
||||
gbc.gridx = 2;
|
||||
gbc.weightx = 1;
|
||||
mainPanel.add(getCategoryBox(), gbc);
|
||||
|
||||
gbc.gridx = 1;
|
||||
gbc.gridy = 2;
|
||||
gbc.weightx = 0;
|
||||
|
||||
mainPanel.add(new JLabel("Description: "), gbc);
|
||||
|
||||
gbc.gridx = 2;
|
||||
gbc.weightx = 1;
|
||||
gbc.weighty = 1;
|
||||
gbc.fill = GridBagConstraints.BOTH;
|
||||
mainPanel.add(getDescriptionArea(), gbc);
|
||||
|
||||
gbc.gridx = 1;
|
||||
|
||||
gbc.gridy = 3;
|
||||
gbc.weightx = 0;
|
||||
gbc.weighty = 0;
|
||||
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||
mainPanel.add(new JLabel("Keywords: "), gbc);
|
||||
|
||||
gbc.gridx = 2;
|
||||
gbc.weighty = 0;
|
||||
gbc.weightx = 1;
|
||||
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||
mainPanel.add(getKeywordsField(), gbc);
|
||||
|
||||
gbc.gridx = 0;
|
||||
|
||||
+29
-19
@@ -17,12 +17,12 @@ import javax.swing.JTextField;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
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;
|
||||
|
||||
public class NewUserDialog extends ButtonDialog {
|
||||
public class UserEditDialog extends ButtonDialog {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private JPanel mainPanel;
|
||||
|
||||
@@ -41,13 +41,15 @@ public class NewUserDialog extends ButtonDialog {
|
||||
|
||||
private UserEntity existingEntity;
|
||||
|
||||
public NewUserDialog(JFrame owner, UserEntity existingEntity) {
|
||||
super(owner, "New Account", new String[] { OK, CANCEL });
|
||||
public UserEditDialog(JFrame owner, UserEntity existingEntity) {
|
||||
super(owner, existingEntity == null ? "New Account" : "Manage Account",
|
||||
new String[] { OK, CANCEL });
|
||||
|
||||
this.existingEntity = existingEntity;
|
||||
|
||||
setMinimumSize(new Dimension(240, 32));
|
||||
layoutGui();
|
||||
refreshState();
|
||||
userNameField.setText(System.getProperty("user.name"));
|
||||
this.existingEntity = existingEntity;
|
||||
refreshState();
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
@@ -77,20 +79,22 @@ public class NewUserDialog extends ButtonDialog {
|
||||
mainPanel.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));
|
||||
|
||||
GridBagConstraints gbc = new GridBagConstraints();
|
||||
gbc.anchor = GridBagConstraints.LINE_START;
|
||||
gbc.anchor = GridBagConstraints.NORTHWEST;
|
||||
gbc.fill = GridBagConstraints.NONE;
|
||||
gbc.insets = new Insets(2, 2, 2, 2);
|
||||
gbc.insets = new Insets(4, 2, 2, 2);
|
||||
|
||||
gbc.gridx = 0;
|
||||
|
||||
gbc.gridy = 0;
|
||||
mainPanel.add(new JLabel("User Name:"), gbc);
|
||||
|
||||
gbc.gridy = 1;
|
||||
mainPanel.add(new JLabel("Password:"), gbc);
|
||||
if (existingEntity == null) {
|
||||
gbc.gridy = 1;
|
||||
mainPanel.add(new JLabel("Password:"), gbc);
|
||||
|
||||
gbc.gridy = 2;
|
||||
mainPanel.add(new JLabel("Confirm Password:"), gbc);
|
||||
gbc.gridy = 2;
|
||||
mainPanel.add(new JLabel("Confirm Password:"), gbc);
|
||||
}
|
||||
|
||||
gbc.gridy = 3;
|
||||
mainPanel.add(new JLabel("eMail:"), gbc);
|
||||
@@ -103,16 +107,19 @@ public class NewUserDialog extends ButtonDialog {
|
||||
|
||||
gbc.gridx = 1;
|
||||
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||
gbc.insets = new Insets(2, 2, 2, 2);
|
||||
gbc.weightx = 1;
|
||||
|
||||
gbc.gridy = 0;
|
||||
mainPanel.add(getUserNameField(), gbc);
|
||||
|
||||
gbc.gridy = 1;
|
||||
mainPanel.add(getPasswordField(), gbc);
|
||||
if (existingEntity == null) {
|
||||
gbc.gridy = 1;
|
||||
mainPanel.add(getPasswordField(), gbc);
|
||||
|
||||
gbc.gridy = 2;
|
||||
mainPanel.add(getConfirmPasswordField(), gbc);
|
||||
gbc.gridy = 2;
|
||||
mainPanel.add(getConfirmPasswordField(), gbc);
|
||||
}
|
||||
|
||||
gbc.gridy = 3;
|
||||
mainPanel.add(getEmailField(), gbc);
|
||||
@@ -148,7 +155,7 @@ public class NewUserDialog extends ButtonDialog {
|
||||
if (userNameField == null) {
|
||||
userNameField = new JTextField();
|
||||
if (existingEntity != null) {
|
||||
userNameField.setText(existingEntity.getUserName());
|
||||
userNameField.setText(existingEntity.getUsername());
|
||||
userNameField.setEditable(false);
|
||||
}
|
||||
userNameField.getDocument().addDocumentListener(
|
||||
@@ -282,6 +289,9 @@ public class NewUserDialog extends ButtonDialog {
|
||||
bioArea = new JTextArea();
|
||||
if (existingEntity != null)
|
||||
bioArea.setText(existingEntity.getBio());
|
||||
bioArea.setFont(getUserNameField().getFont());
|
||||
bioArea.setBorder(getUserNameField().getBorder());
|
||||
bioArea.setPreferredSize(new Dimension(192, 69));
|
||||
bioArea.getDocument().addDocumentListener(new DocumentListener() {
|
||||
|
||||
@Override
|
||||
Reference in New Issue
Block a user