no message
This commit is contained in:
117
src/_VisualDVM/GlobalData/User/UI/UserFields.form
Normal file
117
src/_VisualDVM/GlobalData/User/UI/UserFields.form
Normal file
@@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="_VisualDVM.GlobalData.User.UI.UserFields">
|
||||
<grid id="27dc6" binding="content" layout-manager="GridLayoutManager" row-count="4" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="500" height="400"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="374e0" class="javax.swing.JTextField" binding="tfLogin" custom-create="true">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<vspacer id="9bcf9">
|
||||
<constraints>
|
||||
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<component id="33ebe" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<font name="Times New Roman" size="16" style="2"/>
|
||||
<text value="логин"/>
|
||||
</properties>
|
||||
</component>
|
||||
<tabbedpane id="936e5" binding="AuthenticationTabs">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
|
||||
<minimum-size width="-1" height="80"/>
|
||||
<preferred-size width="200" height="80"/>
|
||||
<maximum-size width="-1" height="80"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<enabled value="true"/>
|
||||
<font name="Times New Roman" size="14" style="0"/>
|
||||
</properties>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="55883" binding="PasswordTab" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<tabbedpane title="по паролю"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<font/>
|
||||
</properties>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<vspacer id="d5d71">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<component id="75250" class="javax.swing.JButton" binding="bPasswordVisibility">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<icon value="icons/HidePassword.png"/>
|
||||
<text value=""/>
|
||||
<toolTipText value="Показывать пароль"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="82048" class="javax.swing.JPasswordField" binding="tfPassword" custom-create="true">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</tabbedpane>
|
||||
<component id="be99c" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="9" fill="0" indent="2" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<font name="Times New Roman" size="16" style="2"/>
|
||||
<text value="вход"/>
|
||||
<verticalAlignment value="0"/>
|
||||
<verticalTextPosition value="0"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="e064b" class="javax.swing.JTextField" binding="tfWorkspace" custom-create="true">
|
||||
<constraints>
|
||||
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<editable value="false"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="7bee1" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<font name="Times New Roman" size="16" style="2"/>
|
||||
<text value="папка"/>
|
||||
<toolTipText value="рабочая папка визуализатора"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
45
src/_VisualDVM/GlobalData/User/UI/UserFields.java
Normal file
45
src/_VisualDVM/GlobalData/User/UI/UserFields.java
Normal file
@@ -0,0 +1,45 @@
|
||||
package _VisualDVM.GlobalData.User.UI;
|
||||
import Common.Utils.CommonUtils;
|
||||
import Common.Visual.Menus.TextEditorMenu;
|
||||
import Common.Visual.TextField.StyledPasswordField;
|
||||
import Common.Visual.TextField.StyledTextField;
|
||||
import Common.Visual.Windows.Dialog.DialogFields;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
public class UserFields implements DialogFields {
|
||||
public JPanel content;
|
||||
public JTextField tfLogin;
|
||||
public JTabbedPane AuthenticationTabs;
|
||||
public JPanel PasswordTab;
|
||||
public JPasswordField tfPassword;
|
||||
public JTextField tfWorkspace;
|
||||
char mask;
|
||||
char unmask = (char) 0;
|
||||
boolean password_visible = false;
|
||||
private JButton bPasswordVisibility;
|
||||
public UserFields() {
|
||||
mask = tfPassword.getEchoChar();
|
||||
bPasswordVisibility.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
password_visible = !password_visible;
|
||||
tfPassword.setEchoChar(password_visible ? unmask : mask);
|
||||
bPasswordVisibility.setIcon(CommonUtils.getIcon("/icons/" + (password_visible ? "Show" : "Hide") + "Password.png"));
|
||||
}
|
||||
});
|
||||
}
|
||||
@Override
|
||||
public Component getContent() {
|
||||
return content;
|
||||
}
|
||||
private void createUIComponents() {
|
||||
// TODO: place custom component creation code here
|
||||
tfLogin = new StyledTextField();
|
||||
tfPassword = new StyledPasswordField();
|
||||
tfPassword.setComponentPopupMenu(new TextEditorMenu(tfPassword));
|
||||
tfWorkspace = new StyledTextField();
|
||||
}
|
||||
}
|
||||
79
src/_VisualDVM/GlobalData/User/User.java
Normal file
79
src/_VisualDVM/GlobalData/User/User.java
Normal file
@@ -0,0 +1,79 @@
|
||||
package _VisualDVM.GlobalData.User;
|
||||
import Common.CommonConstants;
|
||||
import _VisualDVM.Current;
|
||||
import Common.Database.Objects.iDBObject;
|
||||
import _VisualDVM.GlobalData.Machine.Machine;
|
||||
import _VisualDVM.TestingSystem.DVM.UserConnection;
|
||||
import com.sun.org.glassfish.gmbal.Description;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Paths;
|
||||
public class User extends iDBObject {
|
||||
public String login;
|
||||
public String password = "";
|
||||
public int machine_id = CommonConstants.Nan;
|
||||
public UserAuthentication authentication = UserAuthentication.password;
|
||||
public String workspace = ""; //рабочая папка визуализатора пользователя на машине. полный путь.
|
||||
public UserState state = UserState.initial;
|
||||
/*
|
||||
@Description("DEFAULT '?'")
|
||||
public String email = "?";
|
||||
*/
|
||||
//--
|
||||
public User(Machine machine_in, String login_in, String password_in) {
|
||||
machine_id = machine_in.id;
|
||||
login = login_in;
|
||||
password = password_in;
|
||||
}
|
||||
public User(String login_in, String password_in) {
|
||||
login = login_in;
|
||||
password = password_in;
|
||||
}
|
||||
public User(String login_in, String password_in, String workspace_in) {
|
||||
login = login_in;
|
||||
password = password_in;
|
||||
workspace = workspace_in;
|
||||
}
|
||||
public User() {
|
||||
}
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return Current.HasMachine() && Current.getMachine().id == machine_id;
|
||||
}
|
||||
@Override
|
||||
public String getDialogName() {
|
||||
return login;
|
||||
}
|
||||
public String getRemoteProjectsPath() {
|
||||
return workspace + "/projects";
|
||||
}
|
||||
//-ЛОКАЛЬНЫЙ СЛУЧАЙ-----------------------------------------------------------------------
|
||||
public File getLocalWorkspace() {
|
||||
return new File(workspace);
|
||||
}
|
||||
public File getLocalProjectsDir() {
|
||||
return Paths.get(workspace, "projects").toFile();
|
||||
}
|
||||
public File getLocalModulesDir() {
|
||||
return Paths.get(workspace, "modules").toFile();
|
||||
}
|
||||
|
||||
public File getHeaderCodeFile() {
|
||||
return Paths.get(workspace, "modules", "Process_r.h").toFile();
|
||||
}
|
||||
public File getStarterCodeFile() {
|
||||
return Paths.get(workspace, "modules", "starter.cpp").toFile();
|
||||
}
|
||||
public File getStarterFile() {
|
||||
return Paths.get(workspace, "modules", "starter").toFile();
|
||||
}
|
||||
public File getLauncherCodeFile() {
|
||||
return Paths.get(workspace, "modules", "launcher.cpp").toFile();
|
||||
}
|
||||
public File getLauncherFile() {
|
||||
return Paths.get(workspace, "modules", "launcher").toFile();
|
||||
}
|
||||
//-
|
||||
@Description("IGNORE")
|
||||
public UserConnection connection = null;
|
||||
}
|
||||
14
src/_VisualDVM/GlobalData/User/UserAuthentication.java
Normal file
14
src/_VisualDVM/GlobalData/User/UserAuthentication.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package _VisualDVM.GlobalData.User;
|
||||
public enum UserAuthentication {
|
||||
password,
|
||||
key;
|
||||
public String getDescription() {
|
||||
switch (this) {
|
||||
case password:
|
||||
return "по паролю";
|
||||
case key:
|
||||
return "по ключу";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
24
src/_VisualDVM/GlobalData/User/UserState.java
Normal file
24
src/_VisualDVM/GlobalData/User/UserState.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package _VisualDVM.GlobalData.User;
|
||||
import Common.Visual.StatusEnum;
|
||||
import Common.Visual.Fonts.VisualiserFonts;
|
||||
public enum UserState implements StatusEnum {
|
||||
initial, //на пользователя еще не заходили.
|
||||
ready, //рудимент.
|
||||
ready_to_work;//пользователь готов к работе,все установлено.
|
||||
@Override
|
||||
public VisualiserFonts getFont() {
|
||||
return this == UserState.ready_to_work ? VisualiserFonts.GoodState : StatusEnum.super.getFont();
|
||||
}
|
||||
@Override
|
||||
public String getDescription() {
|
||||
switch (this) {
|
||||
case initial:
|
||||
case ready:
|
||||
return "не проинициализирован";
|
||||
case ready_to_work:
|
||||
return "готов к работе";
|
||||
default:
|
||||
return StatusEnum.super.getDescription();
|
||||
}
|
||||
}
|
||||
}
|
||||
114
src/_VisualDVM/GlobalData/User/UsersDBTable.java
Normal file
114
src/_VisualDVM/GlobalData/User/UsersDBTable.java
Normal file
@@ -0,0 +1,114 @@
|
||||
package _VisualDVM.GlobalData.User;
|
||||
import _VisualDVM.Current;
|
||||
import Common.Visual.DataSetControlForm;
|
||||
import Common.Visual.Tables.TableRenderers;
|
||||
import _VisualDVM.Visual.UI;
|
||||
import Common.Visual.Windows.Dialog.DBObjectDialog;
|
||||
import Common.Database.Objects.DBObject;
|
||||
import Common.Database.Tables.FKBehaviour;
|
||||
import Common.Database.Tables.FKCurrentObjectBehaviuor;
|
||||
import Common.Database.Tables.FKDataBehaviour;
|
||||
import Common.Database.Tables.iDBTable;
|
||||
import _VisualDVM.GlobalData.Machine.MachineType;
|
||||
import _VisualDVM.GlobalData.Tasks.CompilationTask.CompilationTask;
|
||||
import _VisualDVM.GlobalData.Tasks.RunTask.RunTask;
|
||||
import _VisualDVM.GlobalData.User.UI.UserFields;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
public class UsersDBTable extends iDBTable<User> {
|
||||
public UsersDBTable() {
|
||||
super(User.class);
|
||||
}
|
||||
@Override
|
||||
public String getSingleDescription() {
|
||||
return "пользователь";
|
||||
}
|
||||
@Override
|
||||
public String getPluralDescription() {
|
||||
return "пользователи";
|
||||
}
|
||||
@Override
|
||||
public LinkedHashMap<Class<? extends DBObject>, FKBehaviour> getFKDependencies() {
|
||||
LinkedHashMap<Class<? extends DBObject>, FKBehaviour> res = new LinkedHashMap<>();
|
||||
res.put(CompilationTask.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.ACTIVE));
|
||||
res.put(RunTask.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.PASSIVE));
|
||||
return res;
|
||||
}
|
||||
@Override
|
||||
public DBObjectDialog<User, UserFields> getDialog() {
|
||||
return new DBObjectDialog<User, UserFields>(UserFields.class) {
|
||||
@Override
|
||||
public void SetEditLimits() {
|
||||
fields.tfLogin.setEditable(false);
|
||||
}
|
||||
@Override
|
||||
public void fillFields() {
|
||||
if (Current.getMachine().type.equals(MachineType.Local)) {
|
||||
Result.login = "этот пользователь";
|
||||
fields.tfLogin.setEditable(false);
|
||||
}
|
||||
fields.tfLogin.setText(Result.login);
|
||||
fields.tfPassword.setText(Result.password);
|
||||
fields.tfWorkspace.setText(Result.workspace);
|
||||
}
|
||||
@Override
|
||||
public void validateFields() {
|
||||
if (fields.tfLogin.getText().isEmpty())
|
||||
Log.Writeln_("Логин пользователя не может быть пустым");
|
||||
}
|
||||
@Override
|
||||
public void ProcessResult() {
|
||||
Result.machine_id = Current.getMachine().id;
|
||||
Result.login = fields.tfLogin.getText();
|
||||
Result.authentication = UserAuthentication.password;
|
||||
Result.password = new String(fields.tfPassword.getPassword());
|
||||
}
|
||||
@Override
|
||||
public int getDefaultHeight() {
|
||||
return 250;
|
||||
}
|
||||
};
|
||||
}
|
||||
@Override
|
||||
protected DataSetControlForm createUI() {
|
||||
return new DataSetControlForm(this) {
|
||||
@Override
|
||||
protected void AdditionalInitColumns() {
|
||||
columns.get(0).setVisible(false);
|
||||
columns.get(2).setRenderer(TableRenderers.RendererStatusEnum);
|
||||
}
|
||||
@Override
|
||||
public void ShowCurrentObject() throws Exception {
|
||||
super.ShowCurrentObject();
|
||||
// UI.getMainWindow().ShowCurrentCompiler();
|
||||
UI.credentialsBar.ShowUser();
|
||||
}
|
||||
@Override
|
||||
public void ShowNoCurrentObject() throws Exception {
|
||||
super.ShowNoCurrentObject();
|
||||
// UI.getMainWindow().ShowCurrentCompiler();
|
||||
UI.credentialsBar.ShowNoUser();
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
@Override
|
||||
public String[] getUIColumnNames() {
|
||||
return new String[]{"Логин", "Статус"};
|
||||
}
|
||||
@Override
|
||||
public Object getFieldAt(User object, int columnIndex) {
|
||||
switch (columnIndex) {
|
||||
case 1:
|
||||
return object.login;
|
||||
case 2:
|
||||
return object.state;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public Current CurrentName() {
|
||||
return Current.User;
|
||||
}
|
||||
}
|
||||
11
src/_VisualDVM/GlobalData/User/UsersMenuBar.java
Normal file
11
src/_VisualDVM/GlobalData/User/UsersMenuBar.java
Normal file
@@ -0,0 +1,11 @@
|
||||
package _VisualDVM.GlobalData.User;
|
||||
import Common.Visual.Menus.DataMenuBar;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
public class UsersMenuBar extends DataMenuBar {
|
||||
public UsersMenuBar() {
|
||||
super("пользователи", PassCode_2021.AddUser,
|
||||
PassCode_2021.EditUser,
|
||||
PassCode_2021.InitialiseUser,
|
||||
PassCode_2021.DeleteUser);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user