рефактиринг интерфейса при отображении полномочий роли пользователя. ввод настройки отменяющей приглашение регистрации при запуске приложения.

This commit is contained in:
2025-02-28 17:46:57 +03:00
parent c551fdd2c9
commit 61d8670416
11 changed files with 90 additions and 62 deletions

View File

@@ -13,19 +13,18 @@ import _VisualDVM.ProjectData.ProjectView;
import _VisualDVM.TestingSystem.Common.TestingServer;
import _VisualDVM.TestingSystem.DVM.RemoteDVMTestingPlanner;
import _VisualDVM.TestingSystem.SAPFOR.PackageModeSupervisor;
import org.apache.commons.io.FileUtils;
import org.fife.ui.rsyntaxtextarea.AbstractTokenMakerFactory;
import org.fife.ui.rsyntaxtextarea.TokenMakerFactory;
import java.io.File;
import java.nio.file.Paths;
public class Global {
//todo свести большинство к содержимому mainModule, сделать различные типы properties, переместить туда глобальный журнал (?)
//todo свести большинство к содержимому mainModule
public static MainModule mainModule = null;
//Режим
public static Mode mode = Mode.Undefined;
//setAdminRights-------------
public static VisualDVMProperties properties= null;
public static VisualDVMProperties properties = null;
public static NormalProperties normalProperties = null;
public static ComponentsServerProperties componentsServerProperties = null;
public static TestingServerProperties testingServerProperties = null;
@@ -79,8 +78,7 @@ public class Global {
Utils_.CheckDirectory(KeysDirectory = new File(Utils_.getHomeDirectory(), Constants.KeyDirectoryName));
try {
Utils_.forceDeleteWithCheck(new File(DataDirectory, "credentials.sqlite"));
}
catch (Exception ex){
} catch (Exception ex) {
ex.printStackTrace();
}
}
@@ -136,7 +134,7 @@ public class Global {
mainModule.DeactivateDB();
if (componentsServer.db != null)
componentsServer.db.Disconnect();
if (componentsServer.credentials_db!=null)
if (componentsServer.credentials_db != null)
componentsServer.credentials_db.Disconnect();
if (testingServer.db != null)
testingServer.db.Disconnect();
@@ -203,8 +201,9 @@ public class Global {
// FoldParserManager.get().addFoldParserMapping("text/FortranSPF", new FortranFolder()); блоки кода. todo
//light_editor.xml-------->>
mainModule.ActivateDB();
// https://habr.com/ru/articles/446888/ сертификат?
mainModule.getPass(PassCode.CheckAccount).Do();
// https://habr.com/ru/articles/446888/ сертификат?
if (Global.normalProperties.OfferRegistrationOnStart)
mainModule.getPass(PassCode.CheckAccount).Do();
//---------------
componentsServer.ActivateDB();
testingServer.ActivateDB();
@@ -251,17 +250,17 @@ public class Global {
File propertiesFile = new File(System.getProperty("user.dir"), "properties");
if (!propertiesFile.exists()) {
mode = Mode.Normal;
properties=normalProperties = Utils_.SynschronizeProperties(propertiesFile, NormalProperties.class);
properties = normalProperties = Utils_.SynschronizeProperties(propertiesFile, NormalProperties.class);
} else {
properties = Utils_.jsonFromFile(propertiesFile, VisualDVMProperties.class);
mode = properties.Mode;
//--->>
switch (mode){
switch (mode) {
case Normal:
normalProperties = Utils_.SynschronizeProperties(propertiesFile, NormalProperties.class);
break;
case Server:
componentsServerProperties = Utils_.SynschronizeProperties(propertiesFile, ComponentsServerProperties.class);
componentsServerProperties = Utils_.SynschronizeProperties(propertiesFile, ComponentsServerProperties.class);
break;
case Testing:
testingServerProperties = Utils_.SynschronizeProperties(propertiesFile, TestingServerProperties.class);

View File

@@ -15,6 +15,8 @@ public class NormalProperties extends VisualDVMProperties {
public String Name = "";
@Expose
public String ServerUserPassword="";
@Expose
public boolean OfferRegistrationOnStart=true;
//--->
@Expose
public String Workspace = "";
@@ -112,6 +114,8 @@ public class NormalProperties extends VisualDVMProperties {
@Override
public String getFieldDescription(String fieldName) {
switch (fieldName) {
case "OfferRegistrationOnStart":
return "Предложение регистрации при запуске";
case "Email":
return "Адрес электронной почты";
case "Kernels":

View File

@@ -63,7 +63,7 @@ public class CheckAccount extends ComponentsServerPass {
@Override
protected void showDone() throws Exception {
if (Global.mainModule.getUI().hasMainWindow()) {
Global.mainModule.getUI().getMainWindow().getCallbackWindow().ShowAccount();
Global.mainModule.getUI().ShowAccount();
if (Global.componentsServer.db.bugReports.getUI().getCurrent() != null)
Global.mainModule.getUI().getMainWindow().getCallbackWindow().ShowCurrentBugReport();
}

View File

@@ -1,4 +1,5 @@
package _VisualDVM.Passes.All;
import _VisualDVM.ComponentsServer.UserAccount.AccountRole;
import _VisualDVM.Global;
import _VisualDVM.Passes.Server.ComponentsServerPass;
import _VisualDVM.Repository.Server.ServerCode;
@@ -13,7 +14,7 @@ public class SynchronizeBugReports extends ComponentsServerPass<Object> {
}
@Override
protected boolean canStart(Object... args) throws Exception {
return Global.mainModule.getAccount().CheckRegistered(Log) && SendRequest(ServerCode.ReceiveBugReportsDatabase);
return !Global.mainModule.getAccount().role.equals(AccountRole.Undefined) && SendRequest(ServerCode.ReceiveBugReportsDatabase);
}
@Override
protected void showPreparation() throws Exception {

View File

@@ -1,7 +1,7 @@
package _VisualDVM.Visual.Interface;
import Common.Visual.VisualizerForm;
public interface CallbackWindow extends VisualizerForm {
void ShowAccount();
void ShowAccountInfo(); //отображение в шапке окна обратной связи имени и прав. возможно убрать если нет регистрации вовсе.
void ShowBugReports();
void ShowNoBugReports();
void ShowCurrentBugReport();
@@ -9,7 +9,7 @@ public interface CallbackWindow extends VisualizerForm {
void ShowSubscription();
//-
default void ShowAll() {
ShowAccount();
ShowAccountInfo();
ShowSubscription();
ShowBugReports();
}
@@ -21,7 +21,8 @@ public interface CallbackWindow extends VisualizerForm {
void ClearBugReportCommentAdditionText();
void FocusRecipients();
void SwitchScreen(boolean small);
void setUndefinedRights();
void setUserRights();
void setAdminRights();
void showNoBugReports();
void showMyOnlyBugReports();
void showAllBugreports();
void showAllBugReportsAdmin();
}

View File

@@ -100,6 +100,51 @@ public class MainUI extends UIModule_ {
return profilesWindow;
}
//---
void showUndefinedRights(){
Global.mainModule.SetUserPassesAccess();
getMainWindow().SwitchTestingTabs(false);
getMainWindow().SwitchAdministrationTab(false);
getTestingMenuBar().showServerAdminLabel(false);
getMainWindow().getCallbackWindow().showNoBugReports();
};
void showUserRights(){
Global.mainModule.SetUserPassesAccess();
getMainWindow().SwitchTestingTabs(false);
getMainWindow().SwitchAdministrationTab(false);
getTestingMenuBar().showServerAdminLabel(false);
getMainWindow().getCallbackWindow().showMyOnlyBugReports();
};
void showDeveloperRights(){
Global.mainModule.SetDeveloperPassesAccess();
getMainWindow().SwitchTestingTabs(true);
getMainWindow().SwitchAdministrationTab(false);
getTestingMenuBar().showServerAdminLabel(false);
getMainWindow().getCallbackWindow().showAllBugreports();
}
void showAdminRights(){
Global.mainModule.SetAdminPassesAccess();
getMainWindow().SwitchTestingTabs(true);
getMainWindow().SwitchAdministrationTab(true);
getTestingMenuBar().showServerAdminLabel(true);
getMainWindow().getCallbackWindow().showAllBugReportsAdmin(); //метод избыточный. возможно.
};
public void ShowAccount(){
getMainWindow().getCallbackWindow().ShowAccountInfo();
switch (Global.mainModule.getAccount().role) {
case Undefined:
showUndefinedRights();
break;
case User:
showUserRights();
break;
case Developer:
showDeveloperRights();
break;
case Admin:
showAdminRights();
break;
default:
break;
}
}
}

View File

@@ -5,6 +5,7 @@ public class SynchronizationSettingsMenu extends PropertiesSubmenu {
public SynchronizationSettingsMenu() {
super("Синхронизация", null,
Global.normalProperties,
"OfferRegistrationOnStart",
"AutoBugReportsLoad",
"AutoTestsLoad");
}

View File

@@ -363,67 +363,34 @@ public class CallbackForm implements FormWithSplitters, CallbackWindow {
accountPanel.add(SC10);
}
@Override
public void setUndefinedRights(){
Global.mainModule.SetUserPassesAccess();
public void showNoBugReports(){
UI.Clear(accountPanel);
accountPanel.add(new CallbackWelcomeForm().content);
Global.mainModule.getUI().getMainWindow().SwitchTestingTabs(false);
Global.mainModule.getUI().getMainWindow().SwitchAdministrationTab(false);
Global.mainModule.getUI().getTestingMenuBar().showServerAdminLabel(false);
adminLabel.setVisible(false);
}
@Override
public void setUserRights() {
public void showMyOnlyBugReports() {
EnableBugreports();
LockMyOnly();
Global.mainModule.SetUserPassesAccess();
Global.mainModule.getUI().getMainWindow().SwitchTestingTabs(false);
Global.mainModule.getUI().getMainWindow().SwitchAdministrationTab(false);
Global.mainModule.getUI().getTestingMenuBar().showServerAdminLabel(false);
adminLabel.setVisible(false);
}
private void setDeveloperRights() {
//возможно перезапуск серверов перетащить во вкладку администрирование? вместе с бекапами. надо подумать.
@Override
public void showAllBugreports() {
EnableBugreports();
UnlockMyOnly();
Global.mainModule.SetDeveloperPassesAccess();
Global.mainModule.getUI().getMainWindow().SwitchTestingTabs(true);
Global.mainModule.getUI().getMainWindow().SwitchAdministrationTab(false);
Global.mainModule.getUI().getTestingMenuBar().showServerAdminLabel(false);
adminLabel.setVisible(false);
}
@Override
public void setAdminRights() {
public void showAllBugReportsAdmin() {
EnableBugreports();
UnlockMyOnly();
Global.mainModule.SetAdminPassesAccess();
//--
Global.mainModule.getUI().getMainWindow().SwitchTestingTabs(true);
Global.mainModule.getUI().getMainWindow().SwitchAdministrationTab(true);
Global.mainModule.getUI().getTestingMenuBar().showServerAdminLabel(true);
adminLabel.setVisible(true);
}
@Override
public void ShowAccount() {
public void ShowAccountInfo() {
lAccountName.setText(Utils_.Brackets(Global.mainModule.getAccount().name));
lAccountMail.setText(Utils_.Brackets(Global.mainModule.getAccount().email));
lAccountRole.setText(Utils_.Brackets(Global.mainModule.getAccount().role.getDescription()));
switch (Global.mainModule.getAccount().role) {
case Undefined:
setUndefinedRights();
break;
case User:
//видит только свои баги.
setUserRights();
break;
case Developer:
setDeveloperRights();
break;
case Admin:
setAdminRights();
break;
default:
break;
}
}
@Override
public void ShowBugReports() {

View File

@@ -238,6 +238,7 @@ public class MainForm extends Form implements MainWindow {
public void Show() {
//приходится идти на это только ПОСЛЕ создания главного окна.
// иначе ссылка на главное окно в методах пустая.
Global.mainModule.getUI().ShowAccount();
getCallbackWindow().ShowAll();
getTestsWindow().ShowAll();
getCredentialsWindow().ShowAll();