From 52eae895ee6de5f97fd5239dfdf3ca6406d0f5fb Mon Sep 17 00:00:00 2001 From: YanSergey Date: Fri, 4 Nov 2022 14:10:57 +0300 Subject: [PATCH 01/70] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BA=D0=BB=D0=B0=D1=81=D1=82=D0=B5?= =?UTF-8?q?=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java index 1b192ee..8e39c25 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java @@ -1930,7 +1930,7 @@ public void widgetSelected(SelectionEvent event) { int dialogResult = dialog.open(); if (dialogResult == 0) { - updateClustersInTree(item[0]); + updateClustersInTree(item[0].getParentItem()); } } }; From 907a591eb94b33160630162a864a94f29460160a Mon Sep 17 00:00:00 2001 From: YanSergey Date: Sat, 5 Nov 2022 13:45:20 +0300 Subject: [PATCH 02/70] =?UTF-8?q?=D0=9F=D0=BE=D0=B2=D1=8B=D1=88=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=B2=D0=B5=D1=80=D1=81=D0=B8=D0=B8=20?= =?UTF-8?q?=D0=B4=D0=BE=200.4.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- clusterAdminApplication/pom.xml | 2 +- clusterAdminLibrary/pom.xml | 2 +- .../src/main/java/ru/yanygin/clusterAdminLibrary/Config.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/clusterAdminApplication/pom.xml b/clusterAdminApplication/pom.xml index 6d61176..8ffa477 100644 --- a/clusterAdminApplication/pom.xml +++ b/clusterAdminApplication/pom.xml @@ -6,7 +6,7 @@ ru.yanygin ru.yanygin.clusterAdminApplication - 0.3.0 + 0.4.0 jar diff --git a/clusterAdminLibrary/pom.xml b/clusterAdminLibrary/pom.xml index d82dc7f..158f493 100644 --- a/clusterAdminLibrary/pom.xml +++ b/clusterAdminLibrary/pom.xml @@ -6,7 +6,7 @@ ru.yanygin ${artifactId} - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT jar diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java index 6e93885..b621539 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java @@ -249,7 +249,7 @@ private Version readCurrentVersion() { // return Version.parse(v); // } - return Version.parse("0.3.0"); + return Version.parse("0.4.0"); } private void runReadUpstreamVersion() { From 41143834729994bdb72bb4f0aa297c22b97bfb9f Mon Sep 17 00:00:00 2001 From: YanSergey Date: Thu, 1 Dec 2022 07:49:57 +0300 Subject: [PATCH 03/70] =?UTF-8?q?=D0=BF=D1=80=D0=BE=D0=BC=D0=B5=D0=B6?= =?UTF-8?q?=D1=83=D1=82=D0=BE=D1=87=D0=BD=D0=BE=D0=B5=20=D1=82=D0=B0=D0=B1?= =?UTF-8?q?=D0=BB=D0=B8=D1=86=D0=B0=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- clusterAdminApplication/scripts/echo.bat | 17 ++ .../clusterAdminLibrary/BackgroundTask.java | 210 ++++++++++++++ .../clusterAdminLibrary/CellValue.java | 18 +- .../yanygin/clusterAdminLibrary/Helper.java | 24 +- .../clusterAdminLibraryUI/ViewerArea.java | 271 ++++++++++++++++-- .../main/resources/icons/taskCompleted.png | Bin 0 -> 533 bytes .../src/main/resources/icons/taskError.png | Bin 0 -> 325 bytes .../src/main/resources/icons/taskRunning.png | Bin 0 -> 854 bytes 8 files changed, 500 insertions(+), 40 deletions(-) create mode 100644 clusterAdminApplication/scripts/echo.bat create mode 100644 clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java create mode 100644 clusterAdminLibrary/src/main/resources/icons/taskCompleted.png create mode 100644 clusterAdminLibrary/src/main/resources/icons/taskError.png create mode 100644 clusterAdminLibrary/src/main/resources/icons/taskRunning.png diff --git a/clusterAdminApplication/scripts/echo.bat b/clusterAdminApplication/scripts/echo.bat new file mode 100644 index 0000000..ec256d9 --- /dev/null +++ b/clusterAdminApplication/scripts/echo.bat @@ -0,0 +1,17 @@ +@echo off +ping 127.0.0.1 -n 10 +echo server: %serverName%:%serverPort% +echo infobase: %infobase% +ping 127.0.0.1 -n 10 +echo server: %serverName%:%serverPort% +echo infobase: %infobase% +ping 127.0.0.1 -n 10 +echo server: %serverName%:%serverPort% +echo infobase: %infobase% +ping 127.0.0.1 -n 10 +echo server: %serverName%:%serverPort% +echo infobase: %infobase% +ping 127.0.0.1 -n 10 +echo server: %serverName%:%serverPort% +echo infobase: %infobase% +echo end diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java new file mode 100644 index 0000000..dbe65c8 --- /dev/null +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java @@ -0,0 +1,210 @@ +package ru.yanygin.clusterAdminLibrary; + +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Date; +import java.util.Map; +import java.util.stream.Stream; +import org.eclipse.swt.graphics.Image; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** Фоновый процесс. */ +public class BackgroundTask { + + private static final Logger LOGGER = LoggerFactory.getLogger("Task"); // $NON-NLS-1$ + + public static int countOfRunning = 0; + + String name; + File script; + Map params; + + Process scriptProcess; + String processOutput = ""; // $NON-NLS-1$ + int exitCode; + boolean isRunning; + + Thread thread; + + Image taskRunning; + Image taskCompleted; + Image taskError; + + Date startDate; + Date finishDate; + + /** + * Инициализация задачи. + * + * @param name - Уникальное имя задания + * @param script - файл скрипта + * @param params - Переменные окружения + */ + public BackgroundTask(String name, File script, Map params) { + this.name = name; + this.script = script; + this.params = params; + + taskRunning = Helper.getImage("taskRunning.png"); // $NON-NLS-1$ + taskCompleted = Helper.getImage("taskCompleted.png"); // $NON-NLS-1$ + taskError = Helper.getImage("taskError.png"); // $NON-NLS-1$ + } + + /** + * Имя задания. + * + * @return name of task + */ + public String getName() { + return name; + } + + /** + * Имя задания. + * + * @return name of task + */ + public String[] getDescription() { + String stateString = ""; + if (isRunning) { + stateString = "run"; + } else if (exitCode != 0) { + stateString = "error"; + } else { + stateString = "done"; + } + + return new String[] { + name, stateString, Helper.dateToString(startDate), Helper.dateToString(finishDate) + }; + } + + /** + * Задание запущено. + * + * @return true если задание еще запущено + */ + public boolean isRunning() { + return isRunning; + } + + /** + * Иконка задачи. + * + * @return Иконка визуализирующая текущее состояние задачи + */ + public Image getIcon() { + if (isRunning) { + return taskRunning; + } else if (exitCode != 0) { + return taskError; + } else { + return taskCompleted; + } + } + + /** + * Дата начала выполнения задания. + * + * @return дату начала выполнения задания + */ + public Date getStartDate() { + return startDate; + } + + /** + * Дата завершения задания. + * + * @return дату нзавершения задания + */ + public Date getFinishDate() { + return finishDate; + } + + /** Запуск фонового задания. */ + public void run() { + + thread = + new Thread( + () -> { + startDate = new Date(); + + var processBuilder = new ProcessBuilder(); + + Map env = processBuilder.environment(); + + params.forEach(env::put); + + processBuilder.command( + "cmd.exe", //$NON-NLS-1$ + "/c", //$NON-NLS-1$ + script.getAbsolutePath()); + try { + scriptProcess = processBuilder.start(); + } catch (Exception excp) { + LOGGER.error("Error launch user script <{}>", script.getName()); // $NON-NLS-1$ + LOGGER.error("\t<{}>", processOutput, excp); // $NON-NLS-1$ + Helper.showMessageBox(excp.getLocalizedMessage()); + return; + } + isRunning = true; + + // Дочерний процесс не сразу стартует и в лог о нем не попадает информация + // try { + // Thread.sleep(1000); + // } catch (InterruptedException excp) { + // LOGGER.error("Error: ", excp); // $NON-NLS-1$ + // } + + LOGGER.debug("Script process runnung = {}", scriptProcess.isAlive()); // $NON-NLS-1$ + + // if (scriptProcess.isAlive()) { + LOGGER.debug( + "Script process parent CMD pid = {}", scriptProcess.pid()); // $NON-NLS-1$ + Stream subprocesses = scriptProcess.children(); + subprocesses.forEach( + subprocess -> + LOGGER.debug( + "\tsubprocess -> {}, pid = {}", //$NON-NLS-1$ + subprocess.info().command().get(), + subprocess.pid())); + + // Читаем вывод скрипта + try { + BufferedReader reader = + new BufferedReader( + new InputStreamReader( + scriptProcess.getInputStream(), "cp866")); // windows-1251, cp866, UTF-8 + // StandardCharsets.UTF_8)); // windows-1251, cp866, UTF-8 + + String line; + while ((line = reader.readLine()) != null) { + processOutput = processOutput.concat(System.lineSeparator()).concat(line); + } + + exitCode = scriptProcess.waitFor(); + + } catch (InterruptedException | IOException excp) { + LOGGER.error("Error: ", excp); // $NON-NLS-1$ + } + + isRunning = false; + finishDate = new Date(); + }); + + thread.start(); + } + + /** + * Получить лог выполнения задачи. + * + * @return лог выполнения задачи + */ + public String getLog() { + return processOutput; + } + +} diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/CellValue.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/CellValue.java index 6ab9d76..a17a843 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/CellValue.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/CellValue.java @@ -1,8 +1,6 @@ package ru.yanygin.clusterAdminLibrary; -import java.text.DateFormat; import java.text.DecimalFormat; -import java.text.SimpleDateFormat; import java.util.Date; /** Value of cell from lists. */ @@ -60,7 +58,7 @@ public CellValue(String name, String descr, Object value, CELL_VALUE_TYPE type) break; case DATE: - this.value = dateToString((Date) value); + this.value = Helper.dateToString((Date) value); break; case SECONDS_INT: @@ -100,20 +98,6 @@ public CellValue(String name, String descr, Object value, CELL_VALUE_TYPE type) } } - /** - * Cast date to string. - * - * @param date - date - * @return date format to string - */ - private String dateToString(Date date) { - - DateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"); //$NON-NLS-1$ - Date emptyDate = new Date(0); - - return date.equals(emptyDate) ? "" : dateFormat.format(date); //$NON-NLS-1$ - } - /** * Cast double value to string. * diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java index 50223a8..ec1552e 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java @@ -2,6 +2,9 @@ import java.io.File; import java.io.FilenameFilter; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; import java.util.HashMap; import java.util.Map; import java.util.UUID; @@ -10,6 +13,7 @@ import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.MessageBox; +import org.eclipse.swt.widgets.Shell; import org.eclipse.wb.swt.SWTResourceManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -23,6 +27,8 @@ public class Helper { public static final UUID EMPTY_UUID = UUID.fromString("00000000-0000-0000-0000-000000000000"); //$NON-NLS-1$ + public static Shell ActiveShell; + private Helper() {} /** @@ -43,7 +49,7 @@ public static Image getImage(String name) { * @param message - текст сообщения */ public static void showMessageBox(String message) { - MessageBox messageBox = new MessageBox(Display.getDefault().getActiveShell()); + MessageBox messageBox = new MessageBox(ActiveShell); messageBox.setMessage(message); messageBox.open(); } @@ -203,4 +209,20 @@ public static Color getOrangeColor() { public static Color getTurquoiseColor() { return new Color(0, 128, 128); } + + /** + * Преобразует дату к строке. + * + * @param date - Дата + * @return Дата строкой + */ + public static String dateToString(Date date) { + Date emptyDate = new Date(0); + if (date == null || date.equals(emptyDate)) { + return ""; + } + + DateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"); // $NON-NLS-1$ + return dateFormat.format(date); + } } diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java index 8e39c25..dd00854 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java @@ -4,12 +4,16 @@ import com._1c.v8.ibis.admin.IInfoBaseInfo; import com._1c.v8.ibis.admin.IWorkingProcessInfo; import com._1c.v8.ibis.admin.IWorkingServerInfo; +import java.io.File; +import java.util.ArrayList; import java.util.Arrays; import java.util.EnumMap; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.Timer; +import java.util.TimerTask; import java.util.UUID; import java.util.stream.Collectors; import org.eclipse.swt.SWT; @@ -42,6 +46,7 @@ import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableColumn; import org.eclipse.swt.widgets.TableItem; +import org.eclipse.swt.widgets.Text; import org.eclipse.swt.widgets.ToolBar; import org.eclipse.swt.widgets.ToolItem; import org.eclipse.swt.widgets.Tree; @@ -50,6 +55,7 @@ import org.eclipse.swt.widgets.Widget; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import ru.yanygin.clusterAdminLibrary.BackgroundTask; import ru.yanygin.clusterAdminLibrary.BaseInfoExtended; import ru.yanygin.clusterAdminLibrary.ClusterProvider; import ru.yanygin.clusterAdminLibrary.ColumnProperties; @@ -120,6 +126,9 @@ public class ViewerArea extends Composite { TabItem tabWorkingProcesses; TabItem tabWorkingServers; TabItem currentTab; + + Table tableTasks; + Text tableTaskLog; ToolItem addToolbarItem; ToolItem editToolbarItem; @@ -160,6 +169,9 @@ public enum TreeItemType { Map serversTreeContextMenus = new EnumMap<>(TreeItemType.class); Map> linksTablesToExtendedClass = new HashMap<>(); + List userScripts = new ArrayList<>(); + Timer taskTimer; // = new Timer(true); + // @Slf4j /** * Конструктор области приложения. @@ -181,40 +193,47 @@ public ViewerArea( super(parent, style); this.clusterProvider = clusterProvider; - // this.clusterProvider.readConfig(); - // this.config = ClusterProvider.getCommonConfig(); this.config = config; + this.setLayout(new FillLayout(SWT.HORIZONTAL)); initIcon(); + initUserScripts(); BaseInfoExtended.init(); + + TabFolder mainTabFolder = new TabFolder(this, SWT.BOTTOM); + + TabItem tabMain = new TabItem(mainTabFolder, SWT.NONE); + tabMain.setText("Main"); - SashForm sashForm = new SashForm(this, SWT.NONE); + // инициализация таблиц управления серверами + SashForm sashServers = new SashForm(mainTabFolder, SWT.NONE); + tabMain.setControl(sashServers); // toolBar = new ToolBar(this, SWT.FLAT | SWT.RIGHT); // Для отладки // toolBar.setBounds(0, 0, 500, 23); // Для отладки initToolbar(toolBar); initMainMenu(menu); + + initServersTree(sashServers); - initServersTree(sashForm); - - TabFolder tabFolder = new TabFolder(sashForm, SWT.NONE); + TabFolder tabFolderServers = new TabFolder(sashServers, SWT.NONE); - tabFolder.addSelectionListener( + tabFolderServers.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent evt) { - currentTab = tabFolder.getSelection()[0]; + currentTab = tabFolderServers.getSelection()[0]; fillTabs(); } }); - tabSessions = initListTable(tabFolder, SessionInfoExtended.class, true); - tabConnections = initListTable(tabFolder, ConnectionInfoExtended.class, false); - tabLocks = initListTable(tabFolder, LockInfoExtended.class, false); - tabWorkingProcesses = initListTable(tabFolder, WorkingProcessInfoExtended.class, false); - tabWorkingServers = initListTable(tabFolder, WorkingServerInfoExtended.class, false); + tabSessions = initListTable(tabFolderServers, SessionInfoExtended.class, true); + tabConnections = initListTable(tabFolderServers, ConnectionInfoExtended.class, false); + tabLocks = initListTable(tabFolderServers, LockInfoExtended.class, false); + tabWorkingProcesses = initListTable(tabFolderServers, WorkingProcessInfoExtended.class, false); + tabWorkingServers = initListTable(tabFolderServers, WorkingServerInfoExtended.class, false); //////////////////////////////////////////// initMaps(); @@ -230,10 +249,8 @@ public void widgetSelected(SelectionEvent evt) { BaseInfoExtended.resetTabsTextCount(); setEnableToolbarItems(); - this.setLayout(new FillLayout(SWT.HORIZONTAL)); - // Пропорции областей - sashForm.setWeights(3, 10); + sashServers.setWeights(3, 10); // Заполнение списка серверов config @@ -244,6 +261,39 @@ public void widgetSelected(SelectionEvent evt) { }); runAutonnectAllServers(); + + // инициализация таблиц заданий + initTaskTab(mainTabFolder); + + } + + private void initTaskTab(TabFolder mainTabFolder) { + TabItem tabJobs = new TabItem(mainTabFolder, SWT.NONE); + tabJobs.setText("Jobs"); + + SashForm sashJobs = new SashForm(mainTabFolder, SWT.NONE); + tabJobs.setControl(sashJobs); + + tableTasks = new Table(sashJobs, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI); + tableTasks.setHeaderVisible(true); + tableTasks.setLinesVisible(true); + tableTasks.addMouseListener(tableTaskMouseClickListener); + + addTaskTableColumn(tableTasks, "Task", 140); + addTaskTableColumn(tableTasks, "State", 50); + addTaskTableColumn(tableTasks, "Start", 120, SWT.RIGHT); + addTaskTableColumn(tableTasks, "End", 120); + + tableTaskLog = new Text(sashJobs, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.READ_ONLY); + tableTaskLog.addListener( + SWT.Modify, + new Listener() { + public void handleEvent(Event e) { + tableTaskLog.setTopIndex(tableTaskLog.getLineCount() - 1); + } + }); + // Пропорции областей + sashJobs.setWeights(4, 10); } private void initIcon() { @@ -406,6 +456,14 @@ private void initServerMenu() { addMenuSeparator(serverMenu); addItemInMenu(serverMenu, Strings.CONTEXT_MENU_REMOVE_SERVER, deleteIcon, deleteServerListener); + + // это для отладки без запуска севрера + addMenuSeparator(serverMenu); + Menu subMenuUserScripts = addItemGroupInMenu(serverMenu, "Пользовательские скрипты", null); + + for (File script : userScripts) { + addItemInMenu(subMenuUserScripts, script.getName(), null, userScriptRunner, script); + } } private void initClusterMenu() { @@ -518,6 +576,14 @@ private void initInfobaseMenu() { Strings.CONTEXT_MENU_TERMINATE_USERS_SESSIONS, null, terminateUsersSessionsListener); + + addMenuSeparator(infobaseMenu); + + Menu subMenuUserScripts = addItemGroupInMenu(infobaseMenu, "Пользовательские скрипты", null); + + for (File script : userScripts) { + addItemInMenu(subMenuUserScripts, script.getName(), null, userScriptRunner, script); + } } private TabItem initListTable( @@ -629,6 +695,23 @@ private void initMaps() { linksTablesToExtendedClass.put(tabWorkingProcesses, WorkingProcessInfoExtended.class); } + private void initUserScripts() { + File userScriptsDir = new File("scripts"); // $NON-NLS-1$ + if (!userScriptsDir.exists()) { + userScriptsDir.mkdir(); + // можно скачивать скрипты с репозитория + } + + if (userScriptsDir.exists() && userScriptsDir.isDirectory()) { + File[] scripts = userScriptsDir.listFiles(); + for (File script : scripts) { + if (script.isFile()) { + userScripts.add(script); + } + } + } + } + private ToolItem addItemInToolbar( ToolBar parent, String text, Image icon, SelectionAdapter listener) { @@ -667,6 +750,18 @@ private MenuItem addItemInMenu(Menu parent, String text, Image icon, SelectionAd return menuItem; } + private MenuItem addItemInMenu( + Menu parent, String text, Image icon, SelectionAdapter listener, Object data) { + + MenuItem menuItem = new MenuItem(parent, SWT.NONE); // SWT.BOLD + menuItem.setText(text); + menuItem.setImage(icon); + menuItem.addSelectionListener(listener); + menuItem.setData(data); + + return menuItem; + } + private MenuItem addRadioItemInMenu( Menu parent, String text, @@ -892,11 +987,7 @@ private void addTableColumn(Table table, String text, ColumnProperties columnPro if (columnVisible != null && columnVisible[numOfColumn]) { newColumn.setResizable(true); - newColumn.setWidth( - // columnWidth == null //TODO нужно ли это еще - // || columnWidth.length <= table.getColumnCount() - // || - columnWidth[numOfColumn] == 0 ? 100 : columnWidth[numOfColumn]); + newColumn.setWidth(columnWidth[numOfColumn] == 0 ? 100 : columnWidth[numOfColumn]); } else { newColumn.setResizable(false); newColumn.setWidth(0); @@ -907,6 +998,20 @@ private void addTableColumn(Table table, String text, ColumnProperties columnPro newColumn.addListener(SWT.Selection, columnSortListener); } + private void addTaskTableColumn(Table table, String text, int width) { + addTaskTableColumn(table, text, width, SWT.LEFT); + } + + private void addTaskTableColumn(Table table, String text, int width, int alignment) { + + var newColumn = new TableColumn(table, SWT.NONE); + newColumn.setText(text); + newColumn.setMoveable(false); + newColumn.setAlignment(alignment); + newColumn.setResizable(true); + newColumn.setWidth(width); + } + private Server getCurrentServer() { return getServer(currentTreeItem); } @@ -2282,6 +2387,103 @@ public void widgetSelected(SelectionEvent event) { } }; + SelectionAdapter userScriptRunner = + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent event) { + TreeItem[] items = serversTree.getSelection(); + if (items.length == 0) { + return; + } + TreeItem infobaseItem = items[0]; + Server server = getServer(infobaseItem); + if (server == null) { + return; + } + + Map env = new HashMap<>(); + + // UUID clusterId = getClusterId(infobaseItem); + // UUID infobaseId = getInfobaseId(infobaseItem); + // File script = (File) event.widget.getData(); + // + // env.put("infobase", server.getInfoBaseName(clusterId, infobaseId)); //$NON-NLS-1$ + // env.put("serverName", server.getAgentHost()); //$NON-NLS-1$ + // env.put("serverPort", server.getAgentPortAsString()); //$NON-NLS-1$ + + File script = (File) event.widget.getData(); + + env.put("infobase", "dev1"); // $NON-NLS-1$ + env.put("serverName", "server123"); // $NON-NLS-1$ + env.put("serverPort", "4541"); // $NON-NLS-1$ + + BackgroundTask task = new BackgroundTask("dev1", script, env); + + addToTasksQueue(task); + } + + public void addToTasksQueue(BackgroundTask task) { + TableItem tableItem = new TableItem(tableTasks, SWT.NONE); + // tableItem.setText(task.getDescription()); + tableItem.setData(task); + tableItem.setChecked(false); + + if (tableTasks.getSelection().length == 0 || BackgroundTask.countOfRunning == 0) { + tableTasks.setSelection(tableItem); + } + + task.run(); + + if (BackgroundTask.countOfRunning == 0) { + taskTimer = new Timer(true); + taskTimer.scheduleAtFixedRate(new TaskChekerTimer(), 1000, 1000); + } + } + + class TaskChekerTimer extends TimerTask { + + @Override + public void run() { + // System.out.println("TimerTask начал свое выполнение в:" + new Date()); + + Display.getDefault() + .asyncExec( + new Runnable() { + public void run() { + TableItem[] items = tableTasks.getItems(); + TableItem[] selectItems = tableTasks.getSelection(); + + BackgroundTask.countOfRunning = 0; + for (TableItem tableItem : items) { + BackgroundTask task = (BackgroundTask) tableItem.getData(); + + tableItem.setText(task.getDescription()); + tableItem.setImage(task.getIcon()); + + if (selectItems.length > 0 + && tableItem.equals(selectItems[0]) + && (task.isRunning() + || tableTaskLog.getLineCount() + != task.getLog().lines().count())) { + tableTaskLog.setText(task.getLog()); + } + + if (task.isRunning()) { + BackgroundTask.countOfRunning++; + } + } + + if (BackgroundTask.countOfRunning == 0) { + taskTimer.cancel(); + } + } + }); + + // System.out.println("TimerTask закончил свое выполнение в:" + new Date()); + } + } + }; + SelectionAdapter createWorkingServerListener = new SelectionAdapter() { @Override @@ -2618,7 +2820,7 @@ public void handleEvent(Event event) { } }; - Listener mouseSelectCellListener = + Listener mouseSelectCellListener = // TODO не используется? new Listener() { @Override public void handleEvent(Event event) { @@ -2720,6 +2922,31 @@ public void keyPressed(KeyEvent e) { } }; + MouseAdapter tableTaskMouseClickListener = + new MouseAdapter() { + @Override + public void mouseDown(MouseEvent event) { + if (event.button != 1) { + return; + } + TableItem[] tableItem = tableTasks.getSelection(); + if (tableItem.length == 0) { + return; + } + + BackgroundTask task = (BackgroundTask) tableItem[0].getData(); + + tableItem[0].setText(task.getDescription()); + + tableTaskLog.setText(task.getLog()); + } + + @Override + public void mouseDoubleClick(MouseEvent e) { + // editItemInTablesListener.widgetSelected(null); + } + }; + private static class Strings { static final String MENU_SERVERS = getString("MainMenu.Servers"); diff --git a/clusterAdminLibrary/src/main/resources/icons/taskCompleted.png b/clusterAdminLibrary/src/main/resources/icons/taskCompleted.png new file mode 100644 index 0000000000000000000000000000000000000000..b826ee8be985adf38e8fcb8bd1e4138ebdc081b0 GIT binary patch literal 533 zcmV+w0_y#VP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGW!vFvR!vP7^J9Gd50jfzvK~y+Tos&-} zgJB%Uf1{x=h08>pQ{E_1b&KSi#t%ZfQ{7dDrT z+RL`r_xtR9-%O_QtxwPM{GR9c`#rzs{k;zPqQzTB1BMZxnREdv0U{s_E_eHl9F3G6 z0M6|gmcblo17*QYrNJK9L68&;>X7Li0>fNap=&UKAn983+N;3Nohs!4g~0{KO${cj znb-bReJ&puGgnIUV3Yy)Sgg6CdYXpB@7V`I%TLI+ z^fvQJN{6YsnnpFI^#=(hmL!@vRcli@mcS;FZ2nm;p0>*zEoa*397E=BN-_Yu%ixuw znTWb#O21dT6f+0o(<*bp_%N+X1_)aLUTC3W*>gETHofqwsF0bWPnd7OMp_3ewEjVx zVB^27d<7=i$}B-Rp#d-|=dAB1ac>JKXBx`>INXH&!0$K?*kGN2N&>!>^*ie{iimsy Xk^7twLA9g{00000NkvXXu0mjfp!(~M literal 0 HcmV?d00001 diff --git a/clusterAdminLibrary/src/main/resources/icons/taskError.png b/clusterAdminLibrary/src/main/resources/icons/taskError.png new file mode 100644 index 0000000000000000000000000000000000000000..4cb1a90848f8895550dee95f3467e530f649f6fd GIT binary patch literal 325 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85o#LL74GE&fi#haqRy{|--sKNBane^Ow$ zE3iSl;O3uI>1>B*^WT?HQEFPK#KG{HPgpViF_XdchCL3O(j*upn}j-^G(5~>xIf8~ zhv~AKbL9=j6Afw{!oq(HHm3YYd(ZGRktrZ5At`42Zn+c3vQFsp=C;M(+7%$D)u5_U zk#=b6l>2up4<7i$F>#>-gJtl-CvG`y3eVjH9L`VFXzVy|tPx#1ZP1_K>z@;j|==^1poj532;bRa{vGXuK)l8uK^eyv3&pl0_#acK~y+Tjgo6f zlVKFcpLg%J+?;Jq-CSPiBB@X&YGkOHNutfN(k^B}2+{}3DCt9xk)H}B#3BRf_Cd?i z%1jNqndZ#QOPOUN8pJM`bLyJ*y36}?j=HG6)E|C(&-;JQ&hwtHVC zH|^+Iu>L6qe^{Ylr$ia5i1-3(*fvjLfGJA&?1-15eRFVF86UH~fQ8#5y0A_lCo} z@W{oamY`7OK<7D~h)_amUmADKWzQ=H@B-$FVAV-V3CGPitPtA*yor|U><=6oP%BSn zt@Ohrp3-uWP_R_jH-1e&#ytXSAK(L+@e8)*m2GZR_)1A%tG-b+Wr(cUU$;0=(Easp6xUQ!?mgX~n<>yGm*r8O)~iINnfhe}zmDxq!L>6?mpXT~PYeXu-$ z>p(JoK^%~W=Iq3@k)hNDF(EE)p#hM)6^3QSa(@kk9B>)X;UEnI3ZVOwp4^?V5%um3 z%(~@j5^b~)d9a2_K7BAKKhT?D&%TNvio`<2=t#ehhfJ~BHu0^=y~`n>5^(N~W$JDn z6Qtw9ABPCfoO{tGlRT{_EG|uJ9W#;}1zN3pl=VOw&_6XpY+b`dTHQ`xEK`w4gN4vD zZ_`cnAAR{}PjorGZOuheFXc9?**N{>U28sG2MWg%CoD!kP8zCp6h{_Y$2nj^3$Hi~ zgWX~Jsumr*%fwQd(rM@LzY2E?ZfyZ@KxzQIDxwKqyCNy4aL~)!PiPu?Z{>Lx?;jGW z_-+~HD^F!?{JQ`O3t&6gHV@PZgrY>Thm>lMUZ`S)B5_06i7al$N_eN^0j&SO Date: Wed, 7 Dec 2022 18:41:02 +0300 Subject: [PATCH 04/70] =?UTF-8?q?=D0=A4=D0=BE=D0=BD=D0=BE=D0=B2=D0=BE?= =?UTF-8?q?=D0=B5=20=D0=BF=D0=BE=D0=B4=D0=BA=D0=BB=D1=8E=D1=87=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BA=20=D1=81=D0=B5=D1=80=D0=B2=D0=B5=D1=80?= =?UTF-8?q?=D0=B0=D0=BC=20=D0=B8=20=D0=B0=D0=B2=D1=82=D0=BE=D0=BE=D0=B1?= =?UTF-8?q?=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=81=D0=BF?= =?UTF-8?q?=D0=B8=D1=81=D0=BA=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- clusterAdminApplication/pom.xml | 2 +- clusterAdminApplication/scripts/echo.bat | 17 - clusterAdminApplication/scripts/echo_fast.bat | 7 + clusterAdminApplication/scripts/echo_long.bat | 9 + ...00\321\203\320\267\320\272\320\260_CF.bat" | 2 + ...00\321\203\320\267\320\272\320\260_DT.bat" | 2 + ...1\200\320\260\321\202\320\276\321\200.bat" | 2 + ...0\270\321\217\321\202\320\270\320\265.bat" | 2 + clusterAdminLibrary/pom.xml | 2 +- .../clusterAdminLibrary/BackgroundTask.java | 246 ++++++--- .../yanygin/clusterAdminLibrary/Config.java | 2 +- .../yanygin/clusterAdminLibrary/Helper.java | 7 +- .../yanygin/clusterAdminLibrary/Server.java | 94 +++- .../clusterAdminLibraryUI/ViewerArea.java | 484 +++++++++++++----- .../src/main/resources/icons/add_24.png | Bin 0 -> 1049 bytes .../src/main/resources/icons/delete_24.png | Bin 0 -> 1614 bytes .../src/main/resources/icons/edit_24.png | Bin 0 -> 1067 bytes ...nect_24.png => server_connectError_24.png} | Bin .../{server_24.png => server_default_24.png} | Bin .../main/resources/icons/updateAuto_24.png | Bin 0 -> 1049 bytes .../icons/{update.png => update_16.png} | Bin .../src/main/resources/icons/update_24.png | Bin 0 -> 853 bytes .../src/main/resources/logback.xml | 7 +- 23 files changed, 664 insertions(+), 221 deletions(-) delete mode 100644 clusterAdminApplication/scripts/echo.bat create mode 100644 clusterAdminApplication/scripts/echo_fast.bat create mode 100644 clusterAdminApplication/scripts/echo_long.bat create mode 100644 "clusterAdminApplication/scripts/\320\222\321\213\320\263\321\200\321\203\320\267\320\272\320\260_CF.bat" create mode 100644 "clusterAdminApplication/scripts/\320\222\321\213\320\263\321\200\321\203\320\267\320\272\320\260_DT.bat" create mode 100644 "clusterAdminApplication/scripts/\320\227\320\260\320\277\321\203\321\201\320\272_\320\232\320\276\320\275\321\204\320\270\320\263\321\203\321\200\320\260\321\202\320\276\321\200.bat" create mode 100644 "clusterAdminApplication/scripts/\320\227\320\260\320\277\321\203\321\201\320\272_\320\237\321\200\320\265\320\264\320\277\321\200\320\270\321\217\321\202\320\270\320\265.bat" create mode 100644 clusterAdminLibrary/src/main/resources/icons/add_24.png create mode 100644 clusterAdminLibrary/src/main/resources/icons/delete_24.png create mode 100644 clusterAdminLibrary/src/main/resources/icons/edit_24.png rename clusterAdminLibrary/src/main/resources/icons/{server_disconnect_24.png => server_connectError_24.png} (100%) rename clusterAdminLibrary/src/main/resources/icons/{server_24.png => server_default_24.png} (100%) create mode 100644 clusterAdminLibrary/src/main/resources/icons/updateAuto_24.png rename clusterAdminLibrary/src/main/resources/icons/{update.png => update_16.png} (100%) create mode 100644 clusterAdminLibrary/src/main/resources/icons/update_24.png diff --git a/clusterAdminApplication/pom.xml b/clusterAdminApplication/pom.xml index 8ffa477..2e57bbf 100644 --- a/clusterAdminApplication/pom.xml +++ b/clusterAdminApplication/pom.xml @@ -6,7 +6,7 @@ ru.yanygin ru.yanygin.clusterAdminApplication - 0.4.0 + 0.4.0.beta1 jar diff --git a/clusterAdminApplication/scripts/echo.bat b/clusterAdminApplication/scripts/echo.bat deleted file mode 100644 index ec256d9..0000000 --- a/clusterAdminApplication/scripts/echo.bat +++ /dev/null @@ -1,17 +0,0 @@ -@echo off -ping 127.0.0.1 -n 10 -echo server: %serverName%:%serverPort% -echo infobase: %infobase% -ping 127.0.0.1 -n 10 -echo server: %serverName%:%serverPort% -echo infobase: %infobase% -ping 127.0.0.1 -n 10 -echo server: %serverName%:%serverPort% -echo infobase: %infobase% -ping 127.0.0.1 -n 10 -echo server: %serverName%:%serverPort% -echo infobase: %infobase% -ping 127.0.0.1 -n 10 -echo server: %serverName%:%serverPort% -echo infobase: %infobase% -echo end diff --git a/clusterAdminApplication/scripts/echo_fast.bat b/clusterAdminApplication/scripts/echo_fast.bat new file mode 100644 index 0000000..25e09c4 --- /dev/null +++ b/clusterAdminApplication/scripts/echo_fast.bat @@ -0,0 +1,7 @@ +# пока что каждый командный файл должен содержать строку chcp 65001 + +@echo off +chcp 65001 +echo server: %serverName%:%managerPort% +echo infobase: %infobase% +echo end diff --git a/clusterAdminApplication/scripts/echo_long.bat b/clusterAdminApplication/scripts/echo_long.bat new file mode 100644 index 0000000..bbe5dff --- /dev/null +++ b/clusterAdminApplication/scripts/echo_long.bat @@ -0,0 +1,9 @@ +# пока что каждый командный файл должен содержать строку chcp 65001 + +@echo off +chcp 65001 +#chcp +ping 127.0.0.1 -n 20 +echo server: %serverName%:%managerPort% +echo infobase: %infobase% +echo end diff --git "a/clusterAdminApplication/scripts/\320\222\321\213\320\263\321\200\321\203\320\267\320\272\320\260_CF.bat" "b/clusterAdminApplication/scripts/\320\222\321\213\320\263\321\200\321\203\320\267\320\272\320\260_CF.bat" new file mode 100644 index 0000000..e10d8c1 --- /dev/null +++ "b/clusterAdminApplication/scripts/\320\222\321\213\320\263\321\200\321\203\320\267\320\272\320\260_CF.bat" @@ -0,0 +1,2 @@ +chcp 65001 +"C:\Program Files\1cv8\common\1cestart.exe" DESIGNER /S %serverName%:%managerPort%\%infobase% /N Администратор /P 1234 /DumpCfg D:\DumpIB\%infobase%.cf \ No newline at end of file diff --git "a/clusterAdminApplication/scripts/\320\222\321\213\320\263\321\200\321\203\320\267\320\272\320\260_DT.bat" "b/clusterAdminApplication/scripts/\320\222\321\213\320\263\321\200\321\203\320\267\320\272\320\260_DT.bat" new file mode 100644 index 0000000..9fd83c2 --- /dev/null +++ "b/clusterAdminApplication/scripts/\320\222\321\213\320\263\321\200\321\203\320\267\320\272\320\260_DT.bat" @@ -0,0 +1,2 @@ +chcp 65001 +"C:\Program Files\1cv8\common\1cestart.exe" DESIGNER /S %serverName%:%managerPort%\%infobase% /N Администратор /P 1234 /DumpIB D:\DumpIB\%infobase%.dt \ No newline at end of file diff --git "a/clusterAdminApplication/scripts/\320\227\320\260\320\277\321\203\321\201\320\272_\320\232\320\276\320\275\321\204\320\270\320\263\321\203\321\200\320\260\321\202\320\276\321\200.bat" "b/clusterAdminApplication/scripts/\320\227\320\260\320\277\321\203\321\201\320\272_\320\232\320\276\320\275\321\204\320\270\320\263\321\203\321\200\320\260\321\202\320\276\321\200.bat" new file mode 100644 index 0000000..dfcd6c8 --- /dev/null +++ "b/clusterAdminApplication/scripts/\320\227\320\260\320\277\321\203\321\201\320\272_\320\232\320\276\320\275\321\204\320\270\320\263\321\203\321\200\320\260\321\202\320\276\321\200.bat" @@ -0,0 +1,2 @@ +chcp 65001 +"C:\Program Files\1cv8\common\1cestart.exe" DESIGNER /S %serverName%:%managerPort%\%infobase% /N Администратор /P 1234 \ No newline at end of file diff --git "a/clusterAdminApplication/scripts/\320\227\320\260\320\277\321\203\321\201\320\272_\320\237\321\200\320\265\320\264\320\277\321\200\320\270\321\217\321\202\320\270\320\265.bat" "b/clusterAdminApplication/scripts/\320\227\320\260\320\277\321\203\321\201\320\272_\320\237\321\200\320\265\320\264\320\277\321\200\320\270\321\217\321\202\320\270\320\265.bat" new file mode 100644 index 0000000..ccc38d5 --- /dev/null +++ "b/clusterAdminApplication/scripts/\320\227\320\260\320\277\321\203\321\201\320\272_\320\237\321\200\320\265\320\264\320\277\321\200\320\270\321\217\321\202\320\270\320\265.bat" @@ -0,0 +1,2 @@ +chcp 65001 +"C:\Program Files\1cv8\common\1cestart.exe" ENTERPRISE /S %serverName%:%managerPort%\%infobase% /N Администратор /P 1234 \ No newline at end of file diff --git a/clusterAdminLibrary/pom.xml b/clusterAdminLibrary/pom.xml index 158f493..7998b73 100644 --- a/clusterAdminLibrary/pom.xml +++ b/clusterAdminLibrary/pom.xml @@ -6,7 +6,7 @@ ru.yanygin ${artifactId} - 0.4.0-SNAPSHOT + 0.4.0.beta1-SNAPSHOT jar diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java index dbe65c8..183e3e6 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java @@ -4,19 +4,26 @@ import java.io.File; import java.io.IOException; import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; import java.util.Date; +import java.util.HashMap; import java.util.Map; import java.util.stream.Stream; import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.widgets.TabItem; +import org.eclipse.swt.widgets.TableItem; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** Фоновый процесс. */ public class BackgroundTask { - private static final Logger LOGGER = LoggerFactory.getLogger("Task"); // $NON-NLS-1$ + private static final Logger LOGGER = LoggerFactory.getLogger("BackgroundTask"); // $NON-NLS-1$ - public static int countOfRunning = 0; + static int countOfRunning = 0; + static int countOfCompleted = 0; + static int countWithError = 0; + static Map taskNamesCounter = new HashMap<>(); String name; File script; @@ -25,13 +32,22 @@ public class BackgroundTask { Process scriptProcess; String processOutput = ""; // $NON-NLS-1$ int exitCode; - boolean isRunning; + + TaskState state; + TaskState stateLast; + + enum TaskState { + RUNNUNG, + DONE, + ERROR + } Thread thread; - Image taskRunning; - Image taskCompleted; - Image taskError; + static Image taskRunning = Helper.getImage("taskRunning.png"); // $NON-NLS-1$ + static Image taskCompleted = Helper.getImage("taskCompleted.png"); // $NON-NLS-1$ + static Image taskError = Helper.getImage("taskError.png"); // $NON-NLS-1$ + // Image currentIcon; Date startDate; Date finishDate; @@ -39,22 +55,93 @@ public class BackgroundTask { /** * Инициализация задачи. * - * @param name - Уникальное имя задания * @param script - файл скрипта * @param params - Переменные окружения */ - public BackgroundTask(String name, File script, Map params) { - this.name = name; + public BackgroundTask(File script, Map params) { + this.script = script; this.params = params; + this.name = generateTaskName(); + + } + + private String generateTaskName() { + String scriptName = script.getName(); + + int taskNumber = taskNamesCounter.getOrDefault(scriptName, 0); + taskNumber++; + taskNamesCounter.put(scriptName, taskNumber); + + return String.format("%s #%d", scriptName, taskNumber); + } + + /** + * Получить количество запущенных заданий. + * + * @return количество запущенных задач + */ + public static int getRunningCount() { + return countOfRunning; + } + + /** + * Установить количество запущенных заданий. + * + * @param count - количество + */ + public static void setCount(int count) { + countOfRunning = count; + } - taskRunning = Helper.getImage("taskRunning.png"); // $NON-NLS-1$ - taskCompleted = Helper.getImage("taskCompleted.png"); // $NON-NLS-1$ - taskError = Helper.getImage("taskError.png"); // $NON-NLS-1$ + /** Сбросить в 0 посчитанное количество заданий. */ + public static void resetCount() { + countOfRunning = 0; + countOfCompleted = 0; + countWithError = 0; } /** - * Имя задания. + * Считает количество запущенных/завершенных заданий. + * + * @param task - задача + */ + public static void calculateCount(BackgroundTask task) { + + if (task.isRunning()) { + countOfRunning++; + } else if (task.exitCode != 0) { + countWithError++; + } else { + countOfCompleted++; + } + } + + /** + * Устанавливает заголовок вкладки с задачами в зависимости от количества запущенных/завершенных + * заданий. + * + * @param tab - вкладка с задачами + */ + public static void setTabTitle(TabItem tab) { + + String title = + String.format( + "Tasks (Run: %d, Completed: %d, Error: %d)", + countOfRunning, countOfCompleted, countWithError); + + // countWithError == 0 + // ? String.format("Tasks (Run: %d, Completed: %d)", countOfRunning, + // countOfCompleted) + // : String.format( + // "Tasks (Run: %d, Completed: %d, Error: %d)", + // countOfRunning, countOfCompleted, countWithError); + + tab.setText(title); + } + + /** + * Получить имя задания. * * @return name of task */ @@ -63,22 +150,37 @@ public String getName() { } /** - * Имя задания. + * Получить описание задания для вывода в списке. * - * @return name of task + * @return описание задания для вывода в списке */ public String[] getDescription() { String stateString = ""; - if (isRunning) { - stateString = "run"; - } else if (exitCode != 0) { - stateString = "error"; - } else { - stateString = "done"; + + switch (state) { + case DONE: + stateString = "done"; + break; + case ERROR: + stateString = "error"; + break; + case RUNNUNG: + default: + stateString = "run"; + break; } + // String paramsAsString = + // params.keySet().stream() + // .map(key -> key + " = " + params.get(key)) + // .collect(Collectors.joining("\n")); + return new String[] { - name, stateString, Helper.dateToString(startDate), Helper.dateToString(finishDate) + name, + stateString, + Helper.dateToString(startDate), + Helper.dateToString(finishDate), + params.toString() }; } @@ -88,42 +190,69 @@ public String[] getDescription() { * @return true если задание еще запущено */ public boolean isRunning() { - return isRunning; + return state == TaskState.RUNNUNG; + } + + /** + * Получить лог выполнения задачи. + * + * @return лог выполнения задачи + */ + public String getLog() { + return processOutput; } /** - * Иконка задачи. + * Получить иконку задачи. * * @return Иконка визуализирующая текущее состояние задачи */ public Image getIcon() { - if (isRunning) { - return taskRunning; - } else if (exitCode != 0) { - return taskError; - } else { - return taskCompleted; + + switch (state) { + case DONE: + return taskCompleted; + case ERROR: + return taskError; + case RUNNUNG: + default: + return taskRunning; } } /** - * Дата начала выполнения задания. + * Получить дату начала выполнения задания. * - * @return дату начала выполнения задания + * @return дата начала выполнения задания */ public Date getStartDate() { return startDate; } /** - * Дата завершения задания. + * Получить дату завершения задания. * - * @return дату нзавершения задания + * @return дата нзавершения задания */ public Date getFinishDate() { return finishDate; } + /** + * Оновить состояние задания. + * + * @param tableItem - элемент таблицы содержащий объект задания + */ + public void update(TableItem tableItem) { + if (state != stateLast) { // обновляем только при изменении состояния + tableItem.setText(this.getDescription()); + tableItem.setImage(this.getIcon()); + stateLast = state; + } + + BackgroundTask.calculateCount(this); + } + /** Запуск фонового задания. */ public void run() { @@ -132,16 +261,23 @@ public void run() { () -> { startDate = new Date(); - var processBuilder = new ProcessBuilder(); - - Map env = processBuilder.environment(); - - params.forEach(env::put); + ProcessBuilder processBuilder = new ProcessBuilder(); + // "cmd.exe", //$NON-NLS-1$ + // "/c", //$NON-NLS-1$ + // "chcp", //$NON-NLS-1$ + // "65001", //$NON-NLS-1$ + // script.getAbsolutePath() + // ).inheritIO(); + // processBuilder.command(script.getAbsolutePath()); processBuilder.command( "cmd.exe", //$NON-NLS-1$ "/c", //$NON-NLS-1$ script.getAbsolutePath()); + + Map env = processBuilder.environment(); + params.forEach(env::put); + try { scriptProcess = processBuilder.start(); } catch (Exception excp) { @@ -150,25 +286,15 @@ public void run() { Helper.showMessageBox(excp.getLocalizedMessage()); return; } - isRunning = true; - - // Дочерний процесс не сразу стартует и в лог о нем не попадает информация - // try { - // Thread.sleep(1000); - // } catch (InterruptedException excp) { - // LOGGER.error("Error: ", excp); // $NON-NLS-1$ - // } + state = TaskState.RUNNUNG; LOGGER.debug("Script process runnung = {}", scriptProcess.isAlive()); // $NON-NLS-1$ - - // if (scriptProcess.isAlive()) { - LOGGER.debug( - "Script process parent CMD pid = {}", scriptProcess.pid()); // $NON-NLS-1$ + LOGGER.debug("Script process parent CMD pid={}", scriptProcess.pid()); // $NON-NLS-1$ Stream subprocesses = scriptProcess.children(); subprocesses.forEach( subprocess -> LOGGER.debug( - "\tsubprocess -> {}, pid = {}", //$NON-NLS-1$ + "\tsubprocess -> {}, pid={}", //$NON-NLS-1$ subprocess.info().command().get(), subprocess.pid())); @@ -177,8 +303,9 @@ public void run() { BufferedReader reader = new BufferedReader( new InputStreamReader( - scriptProcess.getInputStream(), "cp866")); // windows-1251, cp866, UTF-8 - // StandardCharsets.UTF_8)); // windows-1251, cp866, UTF-8 + scriptProcess.getInputStream(), + // "cp866")); // windows-1251, cp866, UTF-8 + StandardCharsets.UTF_8)); String line; while ((line = reader.readLine()) != null) { @@ -191,20 +318,11 @@ public void run() { LOGGER.error("Error: ", excp); // $NON-NLS-1$ } - isRunning = false; + state = exitCode == 0 ? TaskState.DONE : TaskState.ERROR; finishDate = new Date(); }); thread.start(); } - /** - * Получить лог выполнения задачи. - * - * @return лог выполнения задачи - */ - public String getLog() { - return processOutput; - } - } diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java index b621539..cc70354 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java @@ -249,7 +249,7 @@ private Version readCurrentVersion() { // return Version.parse(v); // } - return Version.parse("0.4.0"); + return Version.parse("0.4.0.beta1"); } private void runReadUpstreamVersion() { diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java index ec1552e..72a6dde 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java @@ -13,7 +13,6 @@ import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.MessageBox; -import org.eclipse.swt.widgets.Shell; import org.eclipse.wb.swt.SWTResourceManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -27,8 +26,6 @@ public class Helper { public static final UUID EMPTY_UUID = UUID.fromString("00000000-0000-0000-0000-000000000000"); //$NON-NLS-1$ - public static Shell ActiveShell; - private Helper() {} /** @@ -49,7 +46,9 @@ public static Image getImage(String name) { * @param message - текст сообщения */ public static void showMessageBox(String message) { - MessageBox messageBox = new MessageBox(ActiveShell); + MessageBox messageBox = + new MessageBox(Display.getDefault().getActiveShell()); // SWT.ICON_INFORMATION | SWT.OK + // messageBox.setText("Information"); messageBox.setMessage(message); messageBox.open(); } diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java index 160c948..4e8b7f9 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java @@ -40,7 +40,9 @@ import java.util.UUID; import java.util.stream.Collectors; import java.util.stream.Stream; +import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.TreeItem; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import ru.yanygin.clusterAdminLibraryUI.AuthenticateDialog; @@ -125,7 +127,7 @@ public class Server implements Comparable { @Expose private List favoriteInfobases = new ArrayList<>(); - + private ServerState serverState = ServerState.DISCONNECT; private boolean available; private Process localRasProcess; private String connectionError = ""; //$NON-NLS-1$; @@ -149,6 +151,18 @@ public class Server implements Comparable { private static final String TREE_TITLE_PATTERN = "%s (%s)"; //$NON-NLS-1$ + private static Image defaultIcon = Helper.getImage("server_default_24.png"); // $NON-NLS-1$ + private static Image connectedIcon = Helper.getImage("server_connected_24.png"); // $NON-NLS-1$ + private static Image connectingIcon = Helper.getImage("server_connecting_24.png"); // $NON-NLS-1$ + private static Image connectErrorIcon = Helper.getImage("server_connectError_24.png"); // $NON-NLS-1$ + + private enum ServerState { + DISCONNECT, + CONNECTED, + CONNECTING, + CONNECT_ERROR + } + public enum SaveCredentialsVariant { DISABLE, NAME, @@ -786,22 +800,38 @@ public boolean connectToServer(boolean disconnectAfter, boolean silentMode) { return true; } + available = false; + connectionError = ""; + serverState = ServerState.CONNECTING; + + // все вызовы здесь проверить на Helper.showMessageBox + // этого тут быть не должно, потому что выполняется в отдельном потоке + if (!checkAndRunLocalRas()) { + serverState = ServerState.DISCONNECT; return false; } String currentRasHost = useLocalRas ? "localhost" : this.rasHost; //$NON-NLS-1$ int currentRasPort = useLocalRas ? localRasPort : this.rasPort; - + // try { + // Thread.sleep(30000); + // } catch (InterruptedException e) { // TODO Auto-generated catch block + // e.printStackTrace(); + // } try { - connectToAgent(currentRasHost, currentRasPort, 20); + connectToAgent(currentRasHost, currentRasPort, 120); + serverState = ServerState.CONNECTED; if (disconnectAfter) { disconnectFromAgent(); + serverState = ServerState.DISCONNECT; } } catch (Exception excp) { available = false; + serverState = ServerState.CONNECT_ERROR; + disconnectLocalRas(); connectionError = @@ -810,9 +840,9 @@ public boolean connectToServer(boolean disconnectAfter, boolean silentMode) { this.getServerKey(), getLocalisedMessage(excp)); LOGGER.error(connectionError); - if (!silentMode) { - Helper.showMessageBox(connectionError); - } + // if (!silentMode) { + // Helper.showMessageBox(connectionError); + // } return false; } return true; @@ -970,6 +1000,7 @@ private void connectToAgent(String address, int port, long timeout) { "The connection to server <{}> is already established", //$NON-NLS-1$ this.getServerKey()); available = true; + connectionError = ""; // $NON-NLS-1$ return; } @@ -1377,6 +1408,16 @@ public IClusterInfo getClusterInfo(UUID clusterId) { return clusterInfo; } + /** + * Получение порта менеджера кластера. + * + * @param clusterId - ID кластера + * @return String - порт менеджера кластера + */ + public String getClusterMainPort(UUID clusterId) { + IClusterInfo clusterInfo = getClusterInfo(clusterId); + return clusterInfo == null ? "0" : String.valueOf(clusterInfo.getMainPort()); + } /** * Gets the list of cluster manager descriptions. * @@ -3630,4 +3671,45 @@ public List getResourceConsumptionCounterAccum return agentConnection.getResourceConsumptionCounterAccumulatedValues( clusterId, counterName, object); } + + /** + * Получить иконку с текущим состоянием сервера. + * + * @return Image - иконка текущего состояния сервера + */ + public Image getTreeImage() { + + Image icon; + + switch (serverState) { + case CONNECTED: + icon = connectedIcon; + break; + + case CONNECTING: + icon = connectingIcon; + break; + + case CONNECT_ERROR: + icon = connectErrorIcon; + break; + + case DISCONNECT: + default: + icon = defaultIcon; + break; + } + + return icon; + } + + /** + * Обновить элемент дерева сервера. + * + * @param serverItem - элемент дерева содержащий ссылку на Сервер + */ + public void updateTreeItemState(TreeItem serverItem) { + serverItem.setImage(getTreeImage()); + serverItem.setText(new String[] {getTreeTitle()}); + } } diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java index dd00854..2001d71 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java @@ -5,8 +5,12 @@ import com._1c.v8.ibis.admin.IWorkingProcessInfo; import com._1c.v8.ibis.admin.IWorkingServerInfo; import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; import java.util.ArrayList; import java.util.Arrays; +import java.util.Date; import java.util.EnumMap; import java.util.HashMap; import java.util.List; @@ -15,6 +19,8 @@ import java.util.Timer; import java.util.TimerTask; import java.util.UUID; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import java.util.stream.Collectors; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.SashForm; @@ -34,13 +40,13 @@ import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.MenuItem; -import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.widgets.TabFolder; import org.eclipse.swt.widgets.TabItem; import org.eclipse.swt.widgets.Table; @@ -86,10 +92,10 @@ public class ViewerArea extends Composite { // Image clusterAdd48Icon; // Image infobaseAdd48Icon; - Image serverIcon; - Image serverConnectedIcon; - Image serverDisconnectIcon; - Image serverConnectingIcon; + // Image serverIcon; + // Image serverConnectedIcon; + // Image serverDisconnectIcon; + // Image serverConnectingIcon; Image workingServerIcon; Image infobaseIcon; Image infobasesIcon; @@ -99,11 +105,19 @@ public class ViewerArea extends Composite { Image workingProcessIcon; Image connectActionIcon; Image disconnectActionIcon; - Image editIcon; - Image addIcon; - Image deleteIcon; Image lockUsersIcon; - Image updateIcon; + + Image addIcon16; + Image editIcon16; + Image deleteIcon16; + Image updateIcon16; + + Image addIcon24; + Image editIcon24; + Image deleteIcon24; + Image updateIcon24; + Image updateAutoIcon24; + Image favoritesIcon; Image sortIcon; Image moveUpIcon; @@ -128,6 +142,7 @@ public class ViewerArea extends Composite { TabItem currentTab; Table tableTasks; + TabItem tabTask; Text tableTaskLog; ToolItem addToolbarItem; @@ -170,7 +185,13 @@ public enum TreeItemType { Map> linksTablesToExtendedClass = new HashMap<>(); List userScripts = new ArrayList<>(); - Timer taskTimer; // = new Timer(true); + Timer taskTimer; + Timer serverConnectionTimer; + Timer updateListTimer; + + List waitingConnectServers = new ArrayList<>(); + + UpdateTablesSelectionListener updateTablesListener; // @Slf4j /** @@ -198,6 +219,12 @@ public ViewerArea( initIcon(); initUserScripts(); + initMainMenu(menu); + initToolbar(toolBar); + + // toolBar = new ToolBar(this, SWT.FLAT | SWT.RIGHT); // Для отладки + // toolBar.setBounds(0, 0, 500, 23); // Для отладки + BaseInfoExtended.init(); TabFolder mainTabFolder = new TabFolder(this, SWT.BOTTOM); @@ -209,12 +236,6 @@ public ViewerArea( SashForm sashServers = new SashForm(mainTabFolder, SWT.NONE); tabMain.setControl(sashServers); - // toolBar = new ToolBar(this, SWT.FLAT | SWT.RIGHT); // Для отладки - // toolBar.setBounds(0, 0, 500, 23); // Для отладки - - initToolbar(toolBar); - initMainMenu(menu); - initServersTree(sashServers); TabFolder tabFolderServers = new TabFolder(sashServers, SWT.NONE); @@ -268,13 +289,13 @@ public void widgetSelected(SelectionEvent evt) { } private void initTaskTab(TabFolder mainTabFolder) { - TabItem tabJobs = new TabItem(mainTabFolder, SWT.NONE); - tabJobs.setText("Jobs"); + tabTask = new TabItem(mainTabFolder, SWT.NONE); + tabTask.setText("Task"); - SashForm sashJobs = new SashForm(mainTabFolder, SWT.NONE); - tabJobs.setControl(sashJobs); + SashForm sashTasks = new SashForm(mainTabFolder, SWT.NONE); + tabTask.setControl(sashTasks); - tableTasks = new Table(sashJobs, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI); + tableTasks = new Table(sashTasks, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI); tableTasks.setHeaderVisible(true); tableTasks.setLinesVisible(true); tableTasks.addMouseListener(tableTaskMouseClickListener); @@ -283,8 +304,9 @@ private void initTaskTab(TabFolder mainTabFolder) { addTaskTableColumn(tableTasks, "State", 50); addTaskTableColumn(tableTasks, "Start", 120, SWT.RIGHT); addTaskTableColumn(tableTasks, "End", 120); + addTaskTableColumn(tableTasks, "Params", 120); - tableTaskLog = new Text(sashJobs, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.READ_ONLY); + tableTaskLog = new Text(sashTasks, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.READ_ONLY); tableTaskLog.addListener( SWT.Modify, new Listener() { @@ -293,7 +315,7 @@ public void handleEvent(Event e) { } }); // Пропорции областей - sashJobs.setWeights(4, 10); + sashTasks.setWeights(5, 10); } private void initIcon() { @@ -303,12 +325,12 @@ private void initIcon() { // clusterAdd48Icon = Helper.getImage("cluster_add_48.png"); //$NON-NLS-1$ // infobaseAdd48Icon = Helper.getImage("infobase_add_48.png"); //$NON-NLS-1$ - serverIcon = Helper.getImage("server_24.png"); //$NON-NLS-1$ - serverConnectedIcon = Helper.getImage("server_connected_24.png"); //$NON-NLS-1$ - serverDisconnectIcon = Helper.getImage("server_disconnect_24.png"); //$NON-NLS-1$ - serverConnectingIcon = Helper.getImage("server_connecting_24.png"); //$NON-NLS-1$ - - workingServerIcon = Helper.getImage("working_server_24.png"); //$NON-NLS-1$ + // serverIcon = Helper.getImage("server_24.png"); //$NON-NLS-1$ + // serverConnectedIcon = Helper.getImage("server_connected_24.png"); //$NON-NLS-1$ + // serverDisconnectIcon = Helper.getImage("server_disconnect_24.png"); //$NON-NLS-1$ + // serverConnectingIcon = Helper.getImage("server_connecting_24.png"); //$NON-NLS-1$ + + workingServerIcon = Helper.getImage("working_server_24.png"); // $NON-NLS-1$ // infobaseIcon = Helper.getImage("infobase_24.png"); //$NON-NLS-1$ infobasesIcon = Helper.getImage("infobases_24.png"); //$NON-NLS-1$ clusterIcon = Helper.getImage("cluster_24.png"); //$NON-NLS-1$ @@ -318,12 +340,19 @@ private void initIcon() { connectActionIcon = Helper.getImage("connect_action_24.png"); //$NON-NLS-1$ disconnectActionIcon = Helper.getImage("disconnect_action_24.png"); //$NON-NLS-1$ + lockUsersIcon = Helper.getImage("lock_users_16.png"); // $NON-NLS-1$ + + editIcon16 = Helper.getImage("edit_16.png"); // $NON-NLS-1$ + addIcon16 = Helper.getImage("add_16.png"); // $NON-NLS-1$ + deleteIcon16 = Helper.getImage("delete_16.png"); // $NON-NLS-1$ + updateIcon16 = Helper.getImage("update_16.png"); // $NON-NLS-1$ + + editIcon24 = Helper.getImage("edit_24.png"); // $NON-NLS-1$ + addIcon24 = Helper.getImage("add_24.png"); // $NON-NLS-1$ + deleteIcon24 = Helper.getImage("delete_24.png"); // $NON-NLS-1$ + updateIcon24 = Helper.getImage("update_24.png"); // $NON-NLS-1$ + updateAutoIcon24 = Helper.getImage("updateAuto_24.png"); // $NON-NLS-1$ - editIcon = Helper.getImage("edit_16.png"); //$NON-NLS-1$ - addIcon = Helper.getImage("add_16.png"); //$NON-NLS-1$ - deleteIcon = Helper.getImage("delete_16.png"); //$NON-NLS-1$ - lockUsersIcon = Helper.getImage("lock_users_16.png"); //$NON-NLS-1$ - updateIcon = Helper.getImage("update.png"); //$NON-NLS-1$ favoritesIcon = Helper.getImage("favorites.png"); //$NON-NLS-1$ sortIcon = Helper.getImage("sort.png"); //$NON-NLS-1$ moveUpIcon = Helper.getImage("move_up.png"); //$NON-NLS-1$ @@ -341,15 +370,27 @@ private void initToolbar(ToolBar toolBar) { toolBar.setSize(-1, 48); addToolbarItem = - addItemInToolbar(toolBar, Strings.CONTEXT_MENU_CREATE, addIcon, toolbarListener); + addItemInToolbar(toolBar, Strings.CONTEXT_MENU_CREATE, addIcon24, toolbarListener); editToolbarItem = - addItemInToolbar(toolBar, Strings.CONTEXT_MENU_EDIT, editIcon, toolbarListener); + addItemInToolbar(toolBar, Strings.CONTEXT_MENU_EDIT, editIcon24, toolbarListener); deleteToolbarItem = - addItemInToolbar(toolBar, Strings.CONTEXT_MENU_DELETE, deleteIcon, toolbarListener); + addItemInToolbar(toolBar, Strings.CONTEXT_MENU_DELETE, deleteIcon24, toolbarListener); new ToolItem(toolBar, SWT.SEPARATOR); - addItemInToolbar(toolBar, Strings.CONTEXT_MENU_UPDATE, updateIcon, updateTablesListener); + // addItemInToolbar(toolBar, Strings.CONTEXT_MENU_UPDATE, updateIcon, updateTablesListener); + + ToolItem toolItem = new ToolItem(toolBar, SWT.DROP_DOWN); + toolItem.setText(Strings.CONTEXT_MENU_UPDATE); + toolItem.setImage(updateIcon24); + + updateTablesListener = new UpdateTablesSelectionListener(toolItem); + toolItem.addSelectionListener(updateTablesListener); + + updateTablesListener.add("Включить автообновление"); + updateTablesListener.add("Задать период автообновления"); + + toolBar.pack(); } private void initMainMenu(Menu mainMenu) { @@ -442,9 +483,9 @@ private void initServerMenu() { addMenuSeparator(serverMenu); - addItemInMenu(serverMenu, Strings.CONTEXT_MENU_ADD_SERVER, addIcon, addServerListener); - addItemInMenu(serverMenu, Strings.CONTEXT_MENU_EDIT_SERVER, editIcon, editServerListener); - addItemInMenu(serverMenu, Strings.CONTEXT_MENU_UPDATE, updateIcon, updateServerListener); + addItemInMenu(serverMenu, Strings.CONTEXT_MENU_ADD_SERVER, addIcon16, addServerListener); + addItemInMenu(serverMenu, Strings.CONTEXT_MENU_EDIT_SERVER, editIcon16, editServerListener); + addItemInMenu(serverMenu, Strings.CONTEXT_MENU_UPDATE, updateIcon16, updateServerListener); addMenuSeparator(serverMenu); @@ -455,7 +496,8 @@ private void initServerMenu() { addMenuSeparator(serverMenu); - addItemInMenu(serverMenu, Strings.CONTEXT_MENU_REMOVE_SERVER, deleteIcon, deleteServerListener); + addItemInMenu( + serverMenu, Strings.CONTEXT_MENU_REMOVE_SERVER, deleteIcon16, deleteServerListener); // это для отладки без запуска севрера addMenuSeparator(serverMenu); @@ -470,12 +512,13 @@ private void initClusterMenu() { clusterMenu = new Menu(serversTree); - addItemInMenu(clusterMenu, Strings.CONTEXT_MENU_CREATE_CLUSTER, addIcon, createClusterListener); - addItemInMenu(clusterMenu, Strings.CONTEXT_MENU_EDIT_CLUSTER, editIcon, editClusterListener); - addItemInMenu(clusterMenu, Strings.CONTEXT_MENU_UPDATE, updateIcon, updateClusterListener); + addItemInMenu( + clusterMenu, Strings.CONTEXT_MENU_CREATE_CLUSTER, addIcon16, createClusterListener); + addItemInMenu(clusterMenu, Strings.CONTEXT_MENU_EDIT_CLUSTER, editIcon16, editClusterListener); + addItemInMenu(clusterMenu, Strings.CONTEXT_MENU_UPDATE, updateIcon16, updateClusterListener); addMenuSeparator(clusterMenu); addItemInMenu( - clusterMenu, Strings.CONTEXT_MENU_DELETE_CLUSTER, deleteIcon, deleteClusterListener); + clusterMenu, Strings.CONTEXT_MENU_DELETE_CLUSTER, deleteIcon16, deleteClusterListener); } private void initWorkingServerMenu() { @@ -485,13 +528,13 @@ private void initWorkingServerMenu() { addItemInMenu( workingServerMenu, Strings.CONTEXT_MENU_CREATE_WORKING_SERVER, - addIcon, + addIcon16, createWorkingServerListenerInTree); addItemInMenu( workingServerMenu, Strings.CONTEXT_MENU_EDIT_WORKING_SERVER, - editIcon, + editIcon16, editWorkingServerListenerInTree); } @@ -500,12 +543,12 @@ private void initInfobaseNodeMenu() { infobaseNodeMenu = new Menu(serversTree); addItemInMenu( - infobaseNodeMenu, Strings.CONTEXT_MENU_CREATE_INFOBASE, addIcon, createInfobaseListener); + infobaseNodeMenu, Strings.CONTEXT_MENU_CREATE_INFOBASE, addIcon16, createInfobaseListener); addItemInMenu( infobaseNodeMenu, Strings.CONTEXT_MENU_UPDATE_INFOBASES, - updateIcon, + updateIcon16, updateInfobasesListener); // группа вложенного меню @@ -542,12 +585,13 @@ private void initInfobaseMenu() { infobaseMenu.addListener(SWT.Show, setActiveInfobaseFavoritesActionListener); addItemInMenu( - infobaseMenu, Strings.CONTEXT_MENU_COPY_INFOBASE, addIcon, createInfobaseListener); + infobaseMenu, Strings.CONTEXT_MENU_COPY_INFOBASE, addIcon16, createInfobaseListener); - addItemInMenu(infobaseMenu, Strings.CONTEXT_MENU_EDIT_INFOBASE, editIcon, editInfobaseListener); + addItemInMenu( + infobaseMenu, Strings.CONTEXT_MENU_EDIT_INFOBASE, editIcon16, editInfobaseListener); addItemInMenu( - infobaseMenu, Strings.CONTEXT_MENU_DELETE_INFOBASE, deleteIcon, deleteInfobaseListener); + infobaseMenu, Strings.CONTEXT_MENU_DELETE_INFOBASE, deleteIcon16, deleteInfobaseListener); addMenuSeparator(infobaseMenu); @@ -630,25 +674,25 @@ private void initTableContextMenu( table.setMenu(tableMenu); if (updatable) { - addItemInMenu(tableMenu, Strings.CONTEXT_MENU_UPDATE_F5, updateIcon, updateTablesListener); + addItemInMenu(tableMenu, Strings.CONTEXT_MENU_UPDATE_F5, updateIcon16, updateTablesListener); } if (creatable) { addItemInMenu( tableMenu, Strings.CONTEXT_MENU_CREATE_WORKING_SERVER, - addIcon, + addIcon16, createWorkingServerListener); } if (editable) { String title = tableContextItemEdit.get(tab); - addItemInMenu(tableMenu, title, editIcon, editItemInTablesListener); + addItemInMenu(tableMenu, title, editIcon16, editItemInTablesListener); } if (killable) { String title = tableContextItemDelete.get(tab); - addItemInMenu(tableMenu, title, deleteIcon, deleteItemInTablesListener); + addItemInMenu(tableMenu, title, deleteIcon16, deleteItemInTablesListener); } } @@ -715,7 +759,7 @@ private void initUserScripts() { private ToolItem addItemInToolbar( ToolBar parent, String text, Image icon, SelectionAdapter listener) { - ToolItem toolItem = new ToolItem(parent, SWT.PUSH); + ToolItem toolItem = new ToolItem(parent, SWT.PUSH | SWT.WRAP); toolItem.setText(text); toolItem.setImage(icon); toolItem.addSelectionListener(listener); @@ -791,14 +835,13 @@ private TreeItem addServerItemInServersTree(Server server, int index) { TreeItemType.SERVER, SERVER_INFO, server, - server.isConnected() ? serverConnectedIcon : serverIcon); + server.getTreeImage()); } private TreeItem addClusterItemInServersTree(TreeItem serverItem, IClusterInfo clusterInfo) { Server server = getServer(serverItem); if (server == null) { - LOGGER.error("Error get Server from serverItem"); //$NON-NLS-1$ return null; } @@ -1030,6 +1073,7 @@ private UUID getCurrentWorkingServerId() { private Server getServer(TreeItem item) { if (item == null) { + LOGGER.error("Error get Server from serverItem"); // $NON-NLS-1$ return null; } @@ -1046,6 +1090,7 @@ private Server getServer(TreeItem item) { parentItem = parentItem.getParentItem(); } } + LOGGER.error("Error get Server from serverItem"); // $NON-NLS-1$ return null; } @@ -1117,27 +1162,27 @@ private void runAutonnectAllServers() { private void connectServerItem(TreeItem serverItem, boolean silentMode) { - // async не работает асинхронно - serverItem.setImage(serverConnectingIcon); - Display.getDefault() - .asyncExec( - new Runnable() { + Server server = getServer(serverItem); + if (server == null) { + return; + } - @Override - public void run() { + Thread thread = + new Thread( + () -> { + Date startDate = new Date(); + server.connectToServer(false, silentMode); + Date finishDate = new Date(); + }); - Server server = getServer(serverItem); - if (server == null) { - return; - } - server.connectToServer(false, silentMode); + thread.start(); - serverItem.setImage( // TODO server.getImage() - server.isConnected() ? serverConnectedIcon : serverDisconnectIcon); - serverItem.setText(new String[] {server.getTreeTitle()}); - updateClustersInTree(serverItem); - } - }); + waitingConnectServers.add(serverItem); + if (serverConnectionTimer == null) { + serverConnectionTimer = new Timer(true); + serverConnectionTimer.schedule(new ServerConnectionChekerTimer(), 1000, 1000); + } + server.updateTreeItemState(serverItem); } private void disconnectServerItem(TreeItem serverItem) { @@ -1146,7 +1191,8 @@ private void disconnectServerItem(TreeItem serverItem) { return; } server.disconnectFromAgent(); - serverItem.setImage(serverIcon); + server.updateTreeItemState(serverItem); + // serverItem.setImage(serverIcon); TreeItem[] clusterItems = serverItem.getItems(); for (TreeItem clusterItem : clusterItems) { @@ -1545,7 +1591,10 @@ private void saveCurrentSelectedData(TreeItem treeItem) { private void setEnableToolbarItems() { // включение/выключение активности кнопок тулбара - addToolbarItem.setEnabled(toolbarCreateListeners.get(currentHighlightingType) != null); + addToolbarItem.setEnabled( + serversTree.getSelection().length == 0 + || toolbarCreateListeners.get(currentHighlightingType) != null); + editToolbarItem.setEnabled(toolbarEditListeners.get(currentHighlightingType) != null); deleteToolbarItem.setEnabled(toolbarDeleteListeners.get(currentHighlightingType) != null); } @@ -1728,9 +1777,7 @@ public void widgetSelected(SelectionEvent event) { return; } - var messageBox = new MessageBox(Display.getDefault().getActiveShell()); - messageBox.setMessage(server.getConnectionError()); - messageBox.open(); + Helper.showMessageBox(server.getConnectionError()); } }; @@ -1739,23 +1786,24 @@ public void widgetSelected(SelectionEvent event) { @Override public void widgetSelected(SelectionEvent event) { - if (currentHighlightingType == null) { // пустое дерево + String buttonName = ((ToolItem) event.widget).getText(); + + if (serversTree.getSelection().length == 0 + && Strings.CONTEXT_MENU_CREATE.equals(buttonName)) { addServerListener.widgetSelected(event); return; } - TreeItem[] item = serversTree.getSelection(); - if (item.length == 0) { + if (currentHighlightingType == null) { // пустое дерево или ничего не выбрано return; } Map currListener = null; - String text = ((ToolItem) event.widget).getText(); - if (Strings.CONTEXT_MENU_CREATE.equals(text)) { + if (Strings.CONTEXT_MENU_CREATE.equals(buttonName)) { currListener = toolbarCreateListeners; - } else if (Strings.CONTEXT_MENU_EDIT.equals(text)) { + } else if (Strings.CONTEXT_MENU_EDIT.equals(buttonName)) { currListener = toolbarEditListeners; - } else if (Strings.CONTEXT_MENU_DELETE.equals(text)) { + } else if (Strings.CONTEXT_MENU_DELETE.equals(buttonName)) { currListener = toolbarDeleteListeners; } else { return; @@ -2396,45 +2444,104 @@ public void widgetSelected(SelectionEvent event) { return; } TreeItem infobaseItem = items[0]; + + File script = (File) event.widget.getData(); + Map params = fillParams(script, infobaseItem); + if (params.isEmpty()) { + Helper.showMessageBox("Params is empty"); + return; + } + + BackgroundTask task = new BackgroundTask(script, params); + addToTasksQueue(task); + } + + public Map fillParams(File script, TreeItem infobaseItem) { + Map params = new HashMap<>(); + + UUID clusterId = getClusterId(infobaseItem); + UUID infobaseId = getInfobaseId(infobaseItem); Server server = getServer(infobaseItem); if (server == null) { - return; + LOGGER.error( + "Error get server info {}", //$NON-NLS-1$ + script.getName()); + return params; + } + + String scriptText; + try { + scriptText = Files.readString(Path.of(script.getPath())); + } catch (IOException excp) { + LOGGER.error( + "Error read script {}", //$NON-NLS-1$ + script.getName(), + excp); + return params; } - Map env = new HashMap<>(); + Pattern p = Pattern.compile("\\%.+?\\%"); + // Pattern p = Pattern.compile("[^\\%]++", Pattern.CASE_INSENSITIVE); - // UUID clusterId = getClusterId(infobaseItem); - // UUID infobaseId = getInfobaseId(infobaseItem); - // File script = (File) event.widget.getData(); - // - // env.put("infobase", server.getInfoBaseName(clusterId, infobaseId)); //$NON-NLS-1$ - // env.put("serverName", server.getAgentHost()); //$NON-NLS-1$ - // env.put("serverPort", server.getAgentPortAsString()); //$NON-NLS-1$ + Matcher m = p.matcher(scriptText); + while (m.find()) { + final String foundParam = m.group(); + String paramValue; - File script = (File) event.widget.getData(); + switch (foundParam) { + case "%infobase%": + paramValue = server.getInfoBaseName(clusterId, infobaseId); // $NON-NLS-1$ + break; - env.put("infobase", "dev1"); // $NON-NLS-1$ - env.put("serverName", "server123"); // $NON-NLS-1$ - env.put("serverPort", "4541"); // $NON-NLS-1$ + case "%serverName%": + paramValue = server.getAgentHost(); // $NON-NLS-1$ + break; - BackgroundTask task = new BackgroundTask("dev1", script, env); + case "%agentPort%": + paramValue = server.getAgentPortAsString(); // $NON-NLS-1$ + break; - addToTasksQueue(task); + case "%managerPort%": + paramValue = server.getClusterMainPort(clusterId); // $NON-NLS-1$ + break; + + default: + LOGGER.error( + "Found unknown param {}", //$NON-NLS-1$ + foundParam); + paramValue = ""; // $NON-NLS-1$ + break; + } + + String paramKey = foundParam.replace("%", ""); + params.put(paramKey, paramValue); + } + + // env.put("infobase", server.getInfoBaseName(clusterId, infobaseId)); //$NON-NLS-1$ + // env.put("serverName", server.getAgentHost()); // $NON-NLS-1$ + // env.put("agentPort", server.getAgentPortAsString()); // $NON-NLS-1$ + // env.put("managerPort",String.valueOf(server.getClusterInfo(clusterId).getMainPort())); + // //$NON-NLS-1$ + + // env.put("infobase", "dev1"); // $NON-NLS-1$ + // env.put("serverName", "server123"); // $NON-NLS-1$ + // env.put("serverPort", "4541"); // $NON-NLS-1$ + + return params; } public void addToTasksQueue(BackgroundTask task) { TableItem tableItem = new TableItem(tableTasks, SWT.NONE); - // tableItem.setText(task.getDescription()); tableItem.setData(task); tableItem.setChecked(false); - if (tableTasks.getSelection().length == 0 || BackgroundTask.countOfRunning == 0) { + if (tableTasks.getSelection().length == 0 || BackgroundTask.getRunningCount() == 0) { tableTasks.setSelection(tableItem); } task.run(); - if (BackgroundTask.countOfRunning == 0) { + if (BackgroundTask.getRunningCount() == 0) { taskTimer = new Timer(true); taskTimer.scheduleAtFixedRate(new TaskChekerTimer(), 1000, 1000); } @@ -2444,7 +2551,6 @@ class TaskChekerTimer extends TimerTask { @Override public void run() { - // System.out.println("TimerTask начал свое выполнение в:" + new Date()); Display.getDefault() .asyncExec( @@ -2453,12 +2559,15 @@ public void run() { TableItem[] items = tableTasks.getItems(); TableItem[] selectItems = tableTasks.getSelection(); - BackgroundTask.countOfRunning = 0; + BackgroundTask.resetCount(); + for (TableItem tableItem : items) { BackgroundTask task = (BackgroundTask) tableItem.getData(); + task.update(tableItem); - tableItem.setText(task.getDescription()); - tableItem.setImage(task.getIcon()); + // tableItem.setText(task.getDescription()); + // tableItem.setImage(task.getIcon()); + // BackgroundTask.calculateCount(task); if (selectItems.length > 0 && tableItem.equals(selectItems[0]) @@ -2467,19 +2576,16 @@ public void run() { != task.getLog().lines().count())) { tableTaskLog.setText(task.getLog()); } - - if (task.isRunning()) { - BackgroundTask.countOfRunning++; - } } - if (BackgroundTask.countOfRunning == 0) { + BackgroundTask.setTabTitle(tabTask); + + if (BackgroundTask.getRunningCount() == 0) { taskTimer.cancel(); + taskTimer = null; } } }); - - // System.out.println("TimerTask закончил свое выполнение в:" + new Date()); } } }; @@ -2675,13 +2781,22 @@ public void handleEvent(Event e) { } }; - SelectionAdapter updateTablesListener = - new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - fillTabs(); - } - }; + // SelectionAdapter updateTablesListener = + // new SelectionAdapter() { + // @Override + // public void widgetSelected(SelectionEvent e) { + // if (e.detail == SWT.ARROW) { + // ToolItem item = (ToolItem) e.widget; + // Rectangle rect = item.getBounds(); + // Point pt = item.getParent().toDisplay(new Point(rect.x, rect.y)); + // menu.setLocation(pt.x, pt.y + rect.height); + // menu.setVisible(true); + // } else { + // System.out.println(dropdown.getText() + " Pressed"); + // fillTabs(); + // } + // } + // }; SelectionAdapter editItemInTablesListener = new SelectionAdapter() { @@ -2947,6 +3062,123 @@ public void mouseDoubleClick(MouseEvent e) { } }; + private class ServerConnectionChekerTimer extends TimerTask { + + @Override + public void run() { + + Display.getDefault() + .asyncExec( + new Runnable() { + public void run() { + if (serverConnectionTimer == null) { + return; + } + + List doneItems = new ArrayList<>(); + + for (TreeItem serverItem : waitingConnectServers) { + Server server = getServer(serverItem); + if (server == null) { + return; + } + + if (server.isConnected() || !server.getConnectionError().isBlank()) { + doneItems.add(serverItem); + } + } + + waitingConnectServers.removeAll(doneItems); + if (waitingConnectServers.isEmpty()) { + serverConnectionTimer.cancel(); + serverConnectionTimer = null; + } + + for (TreeItem serverItem : doneItems) { + Server server = getServer(serverItem); + if (server == null) { + return; + } + server.updateTreeItemState(serverItem); + + if (server.isConnected()) { + updateClustersInTree(serverItem); + } + if (!server.getConnectionError().isBlank()) { + Helper.showMessageBox(server.getConnectionError()); + } + } + } + }); + } + } + + private class UpdateListTimer extends TimerTask { + + @Override + public void run() { + // fillTabs(); + + Display.getDefault() + .asyncExec( + new Runnable() { + public void run() { + fillTabs(); + } + }); + } + } + + class UpdateTablesSelectionListener extends SelectionAdapter { + + private ToolItem dropdown; + private Menu menu; + + public UpdateTablesSelectionListener(ToolItem dropdown) { + this.dropdown = dropdown; + menu = new Menu(dropdown.getParent().getShell()); + } + + public void add(String item) { + MenuItem menuItem = new MenuItem(menu, SWT.CHECK); + menuItem.setText(item); + menuItem.addSelectionListener( + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent event) { + MenuItem selected = (MenuItem) event.widget; + + if (selected.getSelection()) { + updateListTimer = new Timer(true); + updateListTimer.schedule(new UpdateListTimer(), 1000, 5000); + dropdown.setImage(updateAutoIcon24); + } else { + updateListTimer.cancel(); + updateListTimer = null; + + // dropdown.setText(Strings.CONTEXT_MENU_UPDATE); // + " \n(ручное)" + dropdown.setImage(updateIcon24); + } + + } + }); + } + + @Override + public void widgetSelected(SelectionEvent event) { + if (event.detail == SWT.ARROW) { + ToolItem item = (ToolItem) event.widget; + Rectangle rect = item.getBounds(); + Point pt = item.getParent().toDisplay(new Point(rect.x, rect.y)); + menu.setLocation(pt.x, pt.y + rect.height); + menu.setVisible(true); + } else { + System.out.println(dropdown.getText() + " Pressed"); + fillTabs(); + } + } + } + private static class Strings { static final String MENU_SERVERS = getString("MainMenu.Servers"); diff --git a/clusterAdminLibrary/src/main/resources/icons/add_24.png b/clusterAdminLibrary/src/main/resources/icons/add_24.png new file mode 100644 index 0000000000000000000000000000000000000000..70d38290cc4bbbe6624c98fe691cd9f6d2c8244f GIT binary patch literal 1049 zcmV+!1m^pRP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!TMsl2?h$09E8kh-QU@DhtppnVxU1TWYAts_5 z2%2fG1|BC1JL}GLPyfvO@vGOJ_Vm?K@Ad1cs;}NxRlR~9Lq7lZ^(U>6bE4in(Mh6x zID7ZzSC8V09Wn`U|ED)!F?;4at!I+YAufV~Z|f`^JpbzPCx7y*F^NvQB+KbI(O0FB z1sOGm7Nk{9#>}%Is_TQewO%w{OBtQaj?uzo>XopM!C=g>1oU`whff&S-@Pp9~nFc@< z<~;!|OiiQ-sx?2SgVngiHvRJZ501)il?UKymBQJeh~VE^I=t4r|I}grp%yMWAaAl> z&^CB#HjCH(dQ|`Be83s@AyDfjZDBK0v*qoZch=(G&u`o^S@w-E27SSZC?2nzB{I&G zrz^Pu=bQ_IW3`~BL%+9?wipi&;Wf zGDBCP2YEt^G>w1~9V5|E@yf%VXc2AqQ~2aF+J_z#1syKtbp4>1cdC3zHnux@xc;5~ z-TXlp?cY?|GhB0pOgr+Rg(sKQV`b%Mmbk|yLgE>qLQ|y6HB{LWx|ZULUvAxB+Vxwh zMz2eUNp+M;a0tId1xl5s1ZT|zB6A-!C;`vlx4)k zJiOhK&%gj696E?U4<0iRyXgfZyBlGcDqaJEbqM6_>;YQyA8ygkYPxI#t3G0SdGgh01s5>ROG)#;2MA(CL;pkJSCF=Yv++MZeckf0;7-^-gvW3GwD7JP&Mdt zR1wqP(_>lD|9E%4DhI1^nZ7}T7RC34zcnqIn*%ohs6c;(noP-b4Yo;FwwM7-W({pH z04?^*n*Xa^>w9;HOaeSTf9BprnS8yhiqi|$GCy5b+3B{Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!T;FXK~zXfg;wit z6jc;I_uhHzYH9P1~SEiZF(&pjUueYAM=pEA04`>t5I`mV>dx$9Qq$<6P4d1~>98V=6C_EcAF zYJ4z~X9*3jYY|Tt^rpVMvP1ogDmRsLdmhcSmhG%o4@3}1s>ZeAtkJ&X-uDiUsPoXl z=&O%+C8n

a$vcQ9wfY!~`Rod|A-qeRm)D`le1sUwkaH%$v_feG()&`94t)1XPO! z#cR@YKW_-{9a>0o>4Ern~uEDz|sO3xduSCtR};=5-}S4m|fnp^?GEAr3|2EKuzIN4i=t$ zpy5KJa@Cbn?(#kZ@kmiAYnedq!>C$7PJu>sUyxxX$Z>JCRwE}`nr3HTeyC@4$s6Ex z4R{m^q(x^45qA9cfhqti#yQ!x^x%skmZq`5C*^=iMiR@{BE*eml699@)kZwZb}^Pr zhe^KNx2-4ccms??lxvchj_@c4A$_DBc?ncrR0x?W1C>mGM^c3g5V{4X2F?W0e3{6t z*>lO3^sR4vo(ml)IlsH7CnenhAdE6yF;U4_a1gRmG3LrN*eE9w4D@9%9wX*S3Owk} z&6DRy+m0mD?fX8>DP34ukURJ1ay1c62Ta)EYe0mZg+c~;^@FK013MHYo(+dD-qJ9xq~Sox>ivVcS)(cK@u2c|3oc3+6U9O!8EGcZLV5XMQkeq-2YF_d zdNh?@^VXq;aV1L}C|Udd(Og9&dx5{Inue)FD#Kw?u}Ka2&_Mx?RLmcHg0SGAC5pgRoJU4q2aRpeR?9b5}L7&}0y z5)B;mgTtue>2f;W+_(A1k&sEqV5qY@(>7nsMm>cbFMv$7z8@GQ%s5faqhMl&d>d1? zCJ-JNt;2Y@psN;)D<-kJE0WWN?9j%}kO@1wrF++!eBr}pyNVgdNc9*-7zJ^(erq$( z)kzfR!ja({yegzr;4Q973bQAiq6!dzh4}y*>2tbfX)+(Xmt*WL(8Sx7J(BrwUJ74g|JJ>WV-X0 zksCTx$*Hv+Jqfow5b^z}2cziqFz+*#Igz-pWBaB<{TD(9N{&7NCw5^dSuVGkKyGt( zwU%gkw)^b&Cl^(2D#ts!wroi`jPIkNTPb>`H> z0dvKQn9!`3y1zXZ{xkSL`C|RXo+xwn>G5Ub)ZV_g`|u|h7EXx%1Owp0HY{)vmjD0& M07*qoM6N<$g71U-umAu6 literal 0 HcmV?d00001 diff --git a/clusterAdminLibrary/src/main/resources/icons/edit_24.png b/clusterAdminLibrary/src/main/resources/icons/edit_24.png new file mode 100644 index 0000000000000000000000000000000000000000..ce67754224c367b6ee7e2e03de2cc4e6e486cf87 GIT binary patch literal 1067 zcmV+`1l0S9P)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!Ts-*8~1-^!ooU5c}|wq%K$pFAB7+1x(X~WXT1p<%QTn za)vCg+mxbbFH35+k}z~bq-{-L85MwsSs=4%;CK)0_G#xfU7+L4Pw|PIF;v#D^VSel z$`;Vn0>EqrfTz$9^eUYVMBbD|(X)y)so6t@UKB`sGuVa=B!lq#X`nn0K?VnQEFK`uWe&UCm0AbyFlQjbK?O5KIfqJOn}=?7U9tiV*o?|Irn2 zrgbNXog0sMhoJ`H4u{Hz)UZtni zEr0i#{8%{Csuo4Ryc(Y@0NPR%NhE}DXUUeSzYuPrEk32Y)gzCbe0fbc(|;z|bN-4n zrQyM)mj&7s0E>_+oZS5rpAzicqdd1OAb;EU(z~bdE~^}p8s16Zk89*9=X9Dv~oEC8tcKq!-}RcEtB^FY?c;5>22fX@B3@B zh8<>9{7bH1Lc1zbG$st|66lY3j>RC5XV zi5Vajv+DU%+g(D+Vkw~f6~Q5P+h$ly>t5XzJtBb92*-s|HSgG l6|!yHh5uP$`Er8-_!|}!moU1hoBaR)002ovPDHLkV1k@x_ZI*F literal 0 HcmV?d00001 diff --git a/clusterAdminLibrary/src/main/resources/icons/server_disconnect_24.png b/clusterAdminLibrary/src/main/resources/icons/server_connectError_24.png similarity index 100% rename from clusterAdminLibrary/src/main/resources/icons/server_disconnect_24.png rename to clusterAdminLibrary/src/main/resources/icons/server_connectError_24.png diff --git a/clusterAdminLibrary/src/main/resources/icons/server_24.png b/clusterAdminLibrary/src/main/resources/icons/server_default_24.png similarity index 100% rename from clusterAdminLibrary/src/main/resources/icons/server_24.png rename to clusterAdminLibrary/src/main/resources/icons/server_default_24.png diff --git a/clusterAdminLibrary/src/main/resources/icons/updateAuto_24.png b/clusterAdminLibrary/src/main/resources/icons/updateAuto_24.png new file mode 100644 index 0000000000000000000000000000000000000000..6b84947efe27ec70e7eaf12016f89fbcac557ea2 GIT binary patch literal 1049 zcmV+!1m^pRP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGizyJUazyWI3i3tDz1FlI#K~zXfm6dB~ zR7VuY=k7CFAK6VJViZ$KXpLGGH5DWzg0C;4)_f>hZHu5Enm~QwtEEMxD7GZT+6oFP z7NNnk6$Fu3XpHHXlGrRH3KBImib@i6HF0%!@AY?P?_PH|Srh;8FR=?;VYiyip$8iVnikMAOl2kf0aY?vP+CY8K`y1hiuq=`&!UR7fjG z{*(F})(}|oswyffR%4Dy8*N{=w@z|?3N~raP^F#0*N_^#6ILaI+mgyC)EI`O=}o~M zxmbNZR#um)Ed+mNw^ez0`83ROh=Zvtt1R66V8q}e*@5I;4mhb6g3AFqG7RGjjO?%x zBz3C2v7s5W5#*k1NJ0AI{|uDD4vt{uLM63_2@czBRaRE!a=YD9MMWS1q%h7vpJiE7 zo0^&;w6jVEPfau(N&X!XTy`kIpAzr_mJJzl*m+o~{a-fK(+f&vgQp!a~|@376VpTdi0;UW}1fAW3D`w@Ad{<`YmBknL8pDQhNal7~-~ zd|bWNG|l7s7vyrePU?#`_mdsoNF6@3ksmG7FGhY}1~Mi^^{u zdIvMsR&}tF675Y z-TM8$Ir^e8Kpwd?`C3o(@MG?zKq;1?Qx#&)|bKU*5$`mv*MuY8M}z z#x{|b9%|cbQjVr&t)%}cr2X45?vdB)DGk-v>P3w>!P|)7QfqC^)5;cF3Oysg9#SrD!Zm>#~V9y@l-qELN}lxdoDinxLD zdX9r-oxdM-R=;rL?(xr`M^;fG<#bEPcMxk5@FDI0u#JI0;IHNr-$}U+Bc)yeicK+N TIb2c-00000NkvXXu0mjf?#A%z literal 0 HcmV?d00001 diff --git a/clusterAdminLibrary/src/main/resources/icons/update.png b/clusterAdminLibrary/src/main/resources/icons/update_16.png similarity index 100% rename from clusterAdminLibrary/src/main/resources/icons/update.png rename to clusterAdminLibrary/src/main/resources/icons/update_16.png diff --git a/clusterAdminLibrary/src/main/resources/icons/update_24.png b/clusterAdminLibrary/src/main/resources/icons/update_24.png new file mode 100644 index 0000000000000000000000000000000000000000..6a28b7937e830318402857ddf4c6129cc6ed6c66 GIT binary patch literal 853 zcmV-b1FHOqP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!2kdb!2!6DYwZ940_sUbK~zXfrIlSs zR6!Vq_wT4_3$0`XT~rrB*e{kLbP<7-H&&E^SXL0^MHz-l(GN*gsk`Lv_I$Imr``6?tp{Gd`DSO{Z_dm)vsOzITJE{i2rJN1 zG#lB`H#C5rRjpq#LNsB#c%G0pza5KPfPwP~wWu7;kiHoFLU+*_%(}Gsc~psp=$jW+ zfI+gt!{`V~m%b@-6a7HDRi+ErbfUmKi_nSW5mPZ2N>Rw%#4LchLAZm8RYxR)=p3p> z`%nYwMgf!%hmOKYR1|EQyhUQ#$>TO1gyy?unScp4oY9a*?#zkG~wS-iD+ z4(9S^nK&HwhpIpz5RgkQE!%WJbSzlwRi?ozO*r?YZ$+N7-x zdBLW=?+J6I{Wm=7AQP?-AG4Li9Gv0jb@T@U#pK&j#J?Tmz8HpMrMtaZEh=e&RKWZz zVco#(voC`^F}8@+4$3NYI%SyCYZyjhxVi9mf!7pRm64H=$5u2mNnX>0FlLxJRhgO7 z3f=8Z^3NB6+9D20ZqMmxZU3znbM*xk2b~iWo)QjmHEACEolW#(_?dPe@xIIDdhq08 f{iK=@g~jq418()T$XOli00000NkvXXu0mjf_KJ=` literal 0 HcmV?d00001 diff --git a/clusterAdminLibrary/src/main/resources/logback.xml b/clusterAdminLibrary/src/main/resources/logback.xml index e9aa088..de37872 100644 --- a/clusterAdminLibrary/src/main/resources/logback.xml +++ b/clusterAdminLibrary/src/main/resources/logback.xml @@ -29,7 +29,12 @@ - + + + + + + From 6deadf394937a002ab2d24e48fd6cb38c11f2ed8 Mon Sep 17 00:00:00 2001 From: YanSergey Date: Sat, 10 Dec 2022 18:14:21 +0300 Subject: [PATCH 05/70] =?UTF-8?q?=D1=80=D0=B5=D1=84=D0=B0=D0=BA=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=B8=D0=BD=D0=B3=20=D0=B8=20=D0=BD=D0=B0=D1=81?= =?UTF-8?q?=D1=82=D1=80=D0=BE=D0=B9=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../clusterAdminLibrary/BackgroundTask.java | 1 - .../yanygin/clusterAdminLibrary/Config.java | 71 +++++++++++- .../yanygin/clusterAdminLibrary/Helper.java | 2 +- .../yanygin/clusterAdminLibrary/Server.java | 21 +++- .../clusterAdminLibraryUI/SettingsDialog.java | 81 ++++++++++--- .../clusterAdminLibraryUI/ViewerArea.java | 108 +++++++++++------- .../clusterAdminLibraryUI/messages.properties | 7 +- .../messages_ru_RU.properties | 7 +- .../main/resources/icons/taskCompleted.png | Bin 533 -> 323 bytes .../src/main/resources/icons/taskRunning.png | Bin 854 -> 668 bytes .../src/main/resources/logback.xml | 15 +-- 11 files changed, 230 insertions(+), 83 deletions(-) diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java index 183e3e6..3f0b22c 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java @@ -47,7 +47,6 @@ enum TaskState { static Image taskRunning = Helper.getImage("taskRunning.png"); // $NON-NLS-1$ static Image taskCompleted = Helper.getImage("taskCompleted.png"); // $NON-NLS-1$ static Image taskError = Helper.getImage("taskError.png"); // $NON-NLS-1$ - // Image currentIcon; Date startDate; Date finishDate; diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java index cc70354..2d692c4 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java @@ -34,7 +34,8 @@ import org.eclipse.swt.widgets.Shell; import org.json.JSONArray; import org.json.JSONObject; -import org.slf4j.Logger; +import ch.qos.logback.classic.Level; +import ch.qos.logback.classic.Logger; import org.slf4j.LoggerFactory; import ru.yanygin.clusterAdminLibrary.ColumnProperties.RowSortDirection; import ru.yanygin.clusterAdminLibrary.InfoBaseInfoShortExt.InfobasesSortDirection; @@ -122,6 +123,14 @@ public class Config { @Expose private InfobasesSortDirection infobasesSortDirection = InfobasesSortDirection.DISABLE; + @SerializedName("ListRefreshRate") + @Expose + private int listRefreshRate = 5000; + + @SerializedName("LoggerLevel") + @Expose + private String loggerLevel = "error"; + @SerializedName("Servers") @Expose private Map servers = new HashMap<>(); @@ -147,8 +156,12 @@ public class Config { private ColumnProperties wsColumnProperties = new ColumnProperties(0); private static final Logger LOGGER = - LoggerFactory.getLogger("clusterAdminLibrary"); //$NON-NLS-1$ - private static final String DEFAULT_CONFIG_PATH = "config.json"; //$NON-NLS-1$ + (Logger) LoggerFactory.getLogger(Config.class.getSimpleName()); + + private static final Logger ROOT_LOGGER = + (Logger) LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME); + + private static final String DEFAULT_CONFIG_PATH = "config.json"; // $NON-NLS-1$ private static final String TEMP_CONFIG_PATH = "config_temp.json"; //$NON-NLS-1$ public static Config currentConfig; @@ -844,6 +857,56 @@ public void setInfobasesSortDirection(InfobasesSortDirection sortDirection) { this.infobasesSortDirection = sortDirection; } + /** + * Получить установленный уровень логирования. + * + * @return уровень логирования + */ + public String getLoggerLevel() { + return loggerLevel; + } + + /** + * Установить уровень логирования. + * + * @param level - уровень логирования + */ + public void setLoggerLevel(String level) { + this.loggerLevel = level; + applyLoggerLevel(); + } + + /** Применить уровень логирования из конфига. */ + private void applyLoggerLevel() { + + ROOT_LOGGER.setLevel(Level.toLevel("info")); + ROOT_LOGGER.info("logger level switching to <{}>", loggerLevel); // $NON-NLS-1$ + ROOT_LOGGER.setLevel(Level.toLevel(loggerLevel)); + + ROOT_LOGGER.error("test logger level = error"); // $NON-NLS-1$ + ROOT_LOGGER.warn("test logger level = warn"); // $NON-NLS-1$ + ROOT_LOGGER.info("test logger level = info"); // $NON-NLS-1$ + ROOT_LOGGER.debug("test logger level = debug"); // $NON-NLS-1$ + } + + /** + * Получить частоту обновления списка. + * + * @return частота обновления списка (миллисекунд) + */ + public int getListRrefreshRate() { + return listRefreshRate; + } + + /** + * Установка частоты обновления списка. + * + * @param refreshRate - частота обновления списка (миллисекунд) + */ + public void setListRrefreshRate(int refreshRate) { + this.listRefreshRate = refreshRate; + } + /** * Получение свойства колонок списков. * @@ -1019,6 +1082,8 @@ public static Config readConfig(String configPath) { java.util.Locale.setDefault(locale); Messages.reloadBundle(locale); // TODO не совсем понятно как работает } + + config.applyLoggerLevel(); } LOGGER.info("Config file read successfully"); //$NON-NLS-1$ return config; diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java index 72a6dde..b062ac2 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java @@ -48,7 +48,7 @@ public static Image getImage(String name) { public static void showMessageBox(String message) { MessageBox messageBox = new MessageBox(Display.getDefault().getActiveShell()); // SWT.ICON_INFORMATION | SWT.OK - // messageBox.setText("Information"); + messageBox.setText("Information"); messageBox.setMessage(message); messageBox.open(); } diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java index 4e8b7f9..9194029 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java @@ -131,6 +131,7 @@ public class Server implements Comparable { private boolean available; private Process localRasProcess; private String connectionError = ""; //$NON-NLS-1$; + boolean silentConnectionMode = false; // private String agentVersion = ""; //$NON-NLS-1$ private String agentVersion = Messages.getString("Server.NotConnect"); //$NON-NLS-1$ @@ -371,6 +372,15 @@ public String getConnectionError() { return connectionError; } + /** + * Показывает, нужно ли выводить ошибку подключения. + * + * @return выводить ошибку подключения + */ + public boolean needShowConnectionError() { + return !connectionError.isBlank() && !silentConnectionMode; + } + /** * Получение ключа сервера в виде "Server:1541". * @@ -777,7 +787,10 @@ private void computeServerParams(String serverAddress) { public boolean isConnected() { boolean isConnected = (agentConnection != null); - if (!isConnected) { + if (isConnected) { + serverState = ServerState.CONNECTED; + } else if (serverState != ServerState.CONNECTING) { + serverState = ServerState.DISCONNECT; LOGGER.info( "The connection a server <{}> is not established", //$NON-NLS-1$ this.getServerKey()); @@ -803,6 +816,7 @@ public boolean connectToServer(boolean disconnectAfter, boolean silentMode) { available = false; connectionError = ""; serverState = ServerState.CONNECTING; + silentConnectionMode = silentMode; // все вызовы здесь проверить на Helper.showMessageBox // этого тут быть не должно, потому что выполняется в отдельном потоке @@ -816,8 +830,8 @@ public boolean connectToServer(boolean disconnectAfter, boolean silentMode) { int currentRasPort = useLocalRas ? localRasPort : this.rasPort; // try { - // Thread.sleep(30000); - // } catch (InterruptedException e) { // TODO Auto-generated catch block + // Thread.sleep(5000); + // } catch (InterruptedException e) { // TODO Искусственная задержка подключения // e.printStackTrace(); // } try { @@ -1046,6 +1060,7 @@ public void disconnectFromAgent() { } finally { agentConnection = null; agentConnector = null; + serverState = ServerState.DISCONNECT; } } diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/SettingsDialog.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/SettingsDialog.java index 1cfa7ed..d5e974a 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/SettingsDialog.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/SettingsDialog.java @@ -47,6 +47,11 @@ public class SettingsDialog extends Dialog { private Button btnRowSortAsPrevious; private Button btnRowSortAsc; private Button btnRowSortDesc; + private Button btnLoggerLevelOff; + private Button btnLoggerLevelError; + private Button btnLoggerLevelWarning; + private Button btnLoggerLevelInfo; + private Button btnLoggerLevelDebug; private static final String LOCALE_RU = "ru-RU"; //$NON-NLS-1$ @@ -130,7 +135,7 @@ protected Control createDialogArea(Composite parent) { Group grpLocale = new Group(container, SWT.NONE); grpLocale.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1)); - grpLocale.setText(Strings.LOCALE); + grpLocale.setText(Strings.LOCALE_TITLE); grpLocale.setLayout(new GridLayout(1, false)); btnLocaleSystem = new Button(grpLocale, SWT.RADIO); @@ -143,7 +148,8 @@ protected Control createDialogArea(Composite parent) { btnLocaleRussian.setText(Strings.LOCALE_RUSSIAN); Group grpHighlight = new Group(container, SWT.NONE); - grpHighlight.setText(Strings.HIGHLIGHT); + grpHighlight.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1)); + grpHighlight.setText(Strings.HIGHLIGHT_TITLE); grpHighlight.setLayout(new GridLayout(2, false)); btnHighlightNewItems = new Button(grpHighlight, SWT.CHECK); @@ -187,7 +193,8 @@ protected Control createDialogArea(Composite parent) { lblWatchSessionsColor.setLayoutData(gdLblWatchSessionsColor); Group grpRowSortDirection = new Group(container, SWT.NONE); - grpRowSortDirection.setText(Strings.ROW_SORT_DIRECTION); + grpRowSortDirection.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1)); + grpRowSortDirection.setText(Strings.ROW_SORT_DIRECTION_TITLE); grpRowSortDirection.setLayout(new GridLayout(1, false)); btnRowSortAsPrevious = new Button(grpRowSortDirection, SWT.RADIO); @@ -199,14 +206,35 @@ protected Control createDialogArea(Composite parent) { btnRowSortDesc = new Button(grpRowSortDirection, SWT.RADIO); btnRowSortDesc.setText(Strings.ROW_SORT_DIRECTION_DESCENDING); - btnReadClipboard = new Button(container, SWT.CHECK); - btnReadClipboard.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1)); + Group grpLoggerLevel = new Group(container, SWT.NONE); + grpLoggerLevel.setLayout(new GridLayout(1, false)); + grpLoggerLevel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1)); + grpLoggerLevel.setText(Strings.LOGGER_LEVEL_TITLE); + + btnLoggerLevelOff = new Button(grpLoggerLevel, SWT.RADIO); + btnLoggerLevelOff.setText("off"); + + btnLoggerLevelError = new Button(grpLoggerLevel, SWT.RADIO); + btnLoggerLevelError.setText("error"); + + btnLoggerLevelWarning = new Button(grpLoggerLevel, SWT.RADIO); + btnLoggerLevelWarning.setText("warning"); + + btnLoggerLevelInfo = new Button(grpLoggerLevel, SWT.RADIO); + btnLoggerLevelInfo.setText("info"); + + btnLoggerLevelDebug = new Button(grpLoggerLevel, SWT.RADIO); + btnLoggerLevelDebug.setText("debug"); + + Group grpOther = new Group(container, SWT.NONE); + grpOther.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1)); + grpOther.setLayout(new GridLayout(1, false)); + + btnReadClipboard = new Button(grpOther, SWT.CHECK); btnReadClipboard.setText(Strings.READ_CLIPBOARD); - btnCheckUpdate = new Button(container, SWT.CHECK); - btnCheckUpdate.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1)); + btnCheckUpdate = new Button(grpOther, SWT.CHECK); btnCheckUpdate.setText(Strings.CHECK_UPDATE); - new Label(container, SWT.NONE); initProperties(); @@ -236,17 +264,25 @@ private void initProperties() { btnReadClipboard.setSelection(config.isReadClipboard()); btnCheckUpdate.setSelection(config.checkingUpdate()); - if (config.getLocale() == null) { + final String locale = config.getLocale(); + if (locale == null) { btnLocaleSystem.setSelection(true); } else { - btnLocaleEnglish.setSelection(config.getLocale().equals(Locale.ENGLISH.toLanguageTag())); - btnLocaleRussian.setSelection(config.getLocale().equals(LOCALE_RU)); + btnLocaleEnglish.setSelection(locale.equals(Locale.ENGLISH.toLanguageTag())); + btnLocaleRussian.setSelection(locale.equals(LOCALE_RU)); } final RowSortDirection rowSortDirection = config.getRowSortDirection(); btnRowSortAsPrevious.setSelection(rowSortDirection == RowSortDirection.DISABLE); btnRowSortAsc.setSelection(rowSortDirection == RowSortDirection.ASC); btnRowSortDesc.setSelection(rowSortDirection == RowSortDirection.DESC); + + final String loggerLevel = config.getLoggerLevel(); + btnLoggerLevelOff.setSelection(loggerLevel.equals(btnLoggerLevelOff.getText())); + btnLoggerLevelError.setSelection(loggerLevel.equals(btnLoggerLevelError.getText())); + btnLoggerLevelWarning.setSelection(loggerLevel.equals(btnLoggerLevelWarning.getText())); + btnLoggerLevelInfo.setSelection(loggerLevel.equals(btnLoggerLevelInfo.getText())); + btnLoggerLevelDebug.setSelection(loggerLevel.equals(btnLoggerLevelDebug.getText())); } private void saveProperties() { @@ -289,6 +325,21 @@ private void saveProperties() { config.setRowSortDirection(RowSortDirection.DISABLE); } + String loggerLevel; + if (btnLoggerLevelOff.getSelection()) { + loggerLevel = btnLoggerLevelOff.getText(); + } else if (btnLoggerLevelError.getSelection()) { + loggerLevel = btnLoggerLevelError.getText(); + } else if (btnLoggerLevelWarning.getSelection()) { + loggerLevel = btnLoggerLevelWarning.getText(); + } else if (btnLoggerLevelInfo.getSelection()) { + loggerLevel = btnLoggerLevelInfo.getText(); + } else if (btnLoggerLevelDebug.getSelection()) { + loggerLevel = btnLoggerLevelDebug.getText(); + } else { + loggerLevel = btnLoggerLevelOff.getText(); + } + config.setLoggerLevel(loggerLevel); } /** @@ -333,24 +384,26 @@ private static class Strings { static final String SHOW_INFOBASE_DESCRIPTION = getString("ShowInfobaseDescription"); static final String SHOW_LOCAL_RAS_CONNECTINFO = getString("ShowLocalRASConnectInfo"); - static final String LOCALE = getString("Locale"); + static final String LOCALE_TITLE = getString("LocaleTitle"); static final String LOCALE_SYSTEM = getString("LocaleSystem"); static final String LOCALE_ENGLISH = getString("LocaleEnglish"); static final String LOCALE_RUSSIAN = getString("LocaleRussian"); - static final String HIGHLIGHT = getString("Highlight"); + static final String HIGHLIGHT_TITLE = getString("HighlightTitle"); static final String HIGHLIGHT_NEW_ITEMS = getString("HighlightNewItems"); static final String HIGHLIGHT_DURATION = getString("HighlightDuration"); static final String SHADOW_SLEEP_SESSIONS = getString("ShadowSleepSessions"); static final String WATCH_SESSIONS = getString("WatchSessions"); - static final String ROW_SORT_DIRECTION = getString("RowSortDirection"); + static final String ROW_SORT_DIRECTION_TITLE = getString("RowSortDirectionTitle"); static final String ROW_SORT_DIRECTION_AS_PREVIOUS = getString("RowSortDirectionAsPrevious"); static final String ROW_SORT_DIRECTION_ASCENDING = getString("RowSortDirectionAscending"); static final String ROW_SORT_DIRECTION_DESCENDING = getString("RowSortDirectionDescending"); static final String READ_CLIPBOARD = getString("ReadClipboard"); static final String CHECK_UPDATE = getString("CheckUpdate"); + + static final String LOGGER_LEVEL_TITLE = getString("LoggerLevelTitle"); static String getString(String key) { return Messages.getString("SettingsDialog." + key); //$NON-NLS-1$ diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java index 2001d71..e0b01f4 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java @@ -10,7 +10,6 @@ import java.nio.file.Path; import java.util.ArrayList; import java.util.Arrays; -import java.util.Date; import java.util.EnumMap; import java.util.HashMap; import java.util.List; @@ -40,7 +39,6 @@ import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; @@ -280,6 +278,7 @@ public void widgetSelected(SelectionEvent evt) { (serverKey, server) -> { addServerItemInServersTree(server); }); + columnServer.pack(); runAutonnectAllServers(); @@ -385,10 +384,6 @@ private void initToolbar(ToolBar toolBar) { toolItem.setImage(updateIcon24); updateTablesListener = new UpdateTablesSelectionListener(toolItem); - toolItem.addSelectionListener(updateTablesListener); - - updateTablesListener.add("Включить автообновление"); - updateTablesListener.add("Задать период автообновления"); toolBar.pack(); } @@ -1072,7 +1067,7 @@ private UUID getCurrentWorkingServerId() { } private Server getServer(TreeItem item) { - if (item == null) { + if (item == null || item.isDisposed()) { LOGGER.error("Error get Server from serverItem"); // $NON-NLS-1$ return null; } @@ -1170,9 +1165,7 @@ private void connectServerItem(TreeItem serverItem, boolean silentMode) { Thread thread = new Thread( () -> { - Date startDate = new Date(); server.connectToServer(false, silentMode); - Date finishDate = new Date(); }); thread.start(); @@ -1190,7 +1183,7 @@ private void disconnectServerItem(TreeItem serverItem) { if (server == null) { return; } - server.disconnectFromAgent(); + server.disconnectFromAgent(); // TODO надо сюда переместить updateTreeItemState и dispose server.updateTreeItemState(serverItem); // serverItem.setImage(serverIcon); @@ -2517,15 +2510,9 @@ public Map fillParams(File script, TreeItem infobaseItem) { params.put(paramKey, paramValue); } - // env.put("infobase", server.getInfoBaseName(clusterId, infobaseId)); //$NON-NLS-1$ - // env.put("serverName", server.getAgentHost()); // $NON-NLS-1$ - // env.put("agentPort", server.getAgentPortAsString()); // $NON-NLS-1$ - // env.put("managerPort",String.valueOf(server.getClusterInfo(clusterId).getMainPort())); - // //$NON-NLS-1$ - - // env.put("infobase", "dev1"); // $NON-NLS-1$ - // env.put("serverName", "server123"); // $NON-NLS-1$ - // env.put("serverPort", "4541"); // $NON-NLS-1$ + // params.put("infobase", "dev1"); // $NON-NLS-1$ + // params.put("serverName", "server123"); // $NON-NLS-1$ + // params.put("managerPort", "4541"); // $NON-NLS-1$ return params; } @@ -3082,6 +3069,7 @@ public void run() { if (server == null) { return; } + server.updateTreeItemState(serverItem); if (server.isConnected() || !server.getConnectionError().isBlank()) { doneItems.add(serverItem); @@ -3099,12 +3087,12 @@ public void run() { if (server == null) { return; } - server.updateTreeItemState(serverItem); + // server.updateTreeItemState(serverItem); if (server.isConnected()) { updateClustersInTree(serverItem); } - if (!server.getConnectionError().isBlank()) { + if (server.needShowConnectionError()) { Helper.showMessageBox(server.getConnectionError()); } } @@ -3131,35 +3119,72 @@ public void run() { class UpdateTablesSelectionListener extends SelectionAdapter { - private ToolItem dropdown; - private Menu menu; + private ToolItem mainButton; + private Menu dropdownMenu; + private int refreshRate = config.getListRrefreshRate(); + + public UpdateTablesSelectionListener(ToolItem mainButton) { + this.mainButton = mainButton; + this.mainButton.addSelectionListener(this); + + dropdownMenu = new Menu(mainButton.getParent().getShell()); + + this.add(dropdownMenu, "Автообновление", SWT.CHECK, null); - public UpdateTablesSelectionListener(ToolItem dropdown) { - this.dropdown = dropdown; - menu = new Menu(dropdown.getParent().getShell()); + // this.add(dropdownMenu, "Задать период автообновления", SWT.PUSH); + Menu subMenuUpdatePeriod = addItemGroupInMenu(dropdownMenu, "Период", null); + // подменю с секундами = 1, 2, 5, 10 + this.add(subMenuUpdatePeriod, "1 сек", SWT.RADIO, 1000); + this.add(subMenuUpdatePeriod, "2 сек", SWT.RADIO, 2000); + this.add(subMenuUpdatePeriod, "5 сек", SWT.RADIO, 5000); + this.add(subMenuUpdatePeriod, "10 сек", SWT.RADIO, 10000); } - public void add(String item) { - MenuItem menuItem = new MenuItem(menu, SWT.CHECK); - menuItem.setText(item); + public void add(Menu parentMenu, String title, int style, Object data) { + MenuItem menuItem = new MenuItem(parentMenu, style); + menuItem.setText(title); + menuItem.setData(data); + if (style == SWT.CHECK) { + menuItem.setImage(updateAutoIcon24); + } + if (style == SWT.RADIO) { + menuItem.setSelection((int) data == refreshRate); + } + menuItem.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { MenuItem selected = (MenuItem) event.widget; - if (selected.getSelection()) { - updateListTimer = new Timer(true); - updateListTimer.schedule(new UpdateListTimer(), 1000, 5000); - dropdown.setImage(updateAutoIcon24); - } else { - updateListTimer.cancel(); - updateListTimer = null; + switch (selected.getStyle()) { + case SWT.CHECK: + if (selected.getSelection()) { + updateListTimer = new Timer(true); + updateListTimer.schedule(new UpdateListTimer(), 1000, refreshRate); + mainButton.setImage(updateAutoIcon24); + } else { + updateListTimer.cancel(); + updateListTimer = null; + mainButton.setImage(updateIcon24); + } + break; + + case SWT.RADIO: + if (selected.getSelection()) { + refreshRate = (int) selected.getData(); + config.setListRrefreshRate(refreshRate); + if (updateListTimer != null) { + updateListTimer.cancel(); + updateListTimer = new Timer(true); + updateListTimer.schedule(new UpdateListTimer(), 1000, refreshRate); + } + } + break; - // dropdown.setText(Strings.CONTEXT_MENU_UPDATE); // + " \n(ручное)" - dropdown.setImage(updateIcon24); + default: + break; } - } }); } @@ -3170,10 +3195,9 @@ public void widgetSelected(SelectionEvent event) { ToolItem item = (ToolItem) event.widget; Rectangle rect = item.getBounds(); Point pt = item.getParent().toDisplay(new Point(rect.x, rect.y)); - menu.setLocation(pt.x, pt.y + rect.height); - menu.setVisible(true); + dropdownMenu.setLocation(pt.x, pt.y + rect.height); + dropdownMenu.setVisible(true); } else { - System.out.println(dropdown.getText() + " Pressed"); fillTabs(); } } diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties index 032c125..1dbbe2f 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties @@ -110,18 +110,19 @@ SettingsDialog.ExpandNodesInTree = Expand nodes in tree SettingsDialog.ExpandServers = Servers SettingsDialog.ExpandWorkingProcesses = Working processes SettingsDialog.ExpandWorkingServers = Working servers -SettingsDialog.Highlight = Highlight SettingsDialog.HighlightDuration = Highlight duration (sec) SettingsDialog.HighlightNewItems = Highlight new items -SettingsDialog.Locale = Locale (need restart) +SettingsDialog.HighlightTitle = Highlight SettingsDialog.LocaleEnglish = English SettingsDialog.LocaleRussian = Russian SettingsDialog.LocaleSystem = System +SettingsDialog.LocaleTitle = Locale (need restart) +SettingsDialog.LoggerLevelTitle = Logger level SettingsDialog.ReadClipboard = Read clipboard (when adding server) -SettingsDialog.RowSortDirection = Row sort direction SettingsDialog.RowSortDirectionAsPrevious = As previous SettingsDialog.RowSortDirectionAscending = Descending SettingsDialog.RowSortDirectionDescending = Ascending +SettingsDialog.RowSortDirectionTitle = Row sort direction SettingsDialog.ShadowSleepSessions = Shadow sleep sessions SettingsDialog.ShowInfo = Additional info SettingsDialog.ShowInfobaseDescription = Show infobase description diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties index dd80728..6b3bf02 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties @@ -110,18 +110,19 @@ SettingsDialog.ExpandNodesInTree = \u0420\u0430\u0437\u0432\u043E\u0440 SettingsDialog.ExpandServers = \u0421\u0435\u0440\u0432\u0435\u0440\u0430 SettingsDialog.ExpandWorkingProcesses = \u0420\u0430\u0431\u043E\u0447\u0438\u0435 \u043F\u0440\u043E\u0446\u0435\u0441\u0441\u044B SettingsDialog.ExpandWorkingServers = \u0420\u0430\u0431\u043E\u0447\u0438\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 -SettingsDialog.Highlight = \u041F\u043E\u0434\u0441\u0432\u0435\u0447\u0438\u0432\u0430\u043D\u0438\u0435 SettingsDialog.HighlightDuration = \u0414\u043B\u0438\u0442\u0435\u043B\u044C\u043D\u043E\u0441\u0442\u044C \u043F\u043E\u0434\u0441\u0432\u0435\u0442\u043A\u0438 (\u0441\u0435\u043A) SettingsDialog.HighlightNewItems = \u041F\u043E\u0434\u0441\u0432\u0435\u0447\u0438\u0432\u0430\u0442\u044C \u043D\u043E\u0432\u044B\u0435 \u0441\u0442\u0440\u043E\u043A\u0438 -SettingsDialog.Locale = \u042F\u0437\u044B\u043A \u0438\u043D\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 (\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044F \u043F\u0435\u0440\u0435\u0437\u0430\u043F\u0443\u0441\u043A) +SettingsDialog.HighlightTitle = \u041F\u043E\u0434\u0441\u0432\u0435\u0447\u0438\u0432\u0430\u043D\u0438\u0435 SettingsDialog.LocaleEnglish = \u0410\u043D\u0433\u043B\u0438\u0439\u0441\u043A\u0438\u0439 SettingsDialog.LocaleRussian = \u0420\u0443\u0441\u0441\u043A\u0438\u0439 SettingsDialog.LocaleSystem = \u0421\u0438\u0441\u0442\u0435\u043C\u043D\u044B\u0439 +SettingsDialog.LocaleTitle = \u042F\u0437\u044B\u043A \u0438\u043D\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 (\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044F \u043F\u0435\u0440\u0435\u0437\u0430\u043F\u0443\u0441\u043A) +SettingsDialog.LoggerLevelTitle = \u0423\u0440\u043E\u0432\u0435\u043D\u044C \u043B\u043E\u0433\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u044F SettingsDialog.ReadClipboard = \u0427\u0438\u0442\u0430\u0442\u044C \u0431\u0443\u0444\u0435\u0440 \u043E\u0431\u043C\u0435\u043D\u0430 (\u043F\u0440\u0438 \u0434\u043E\u0431\u0430\u0432\u043B\u0435\u043D\u0438\u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430) -SettingsDialog.RowSortDirection = \u041D\u0430\u043F\u0440\u0430\u0432\u043B\u0435\u043D\u0438\u0435 \u0441\u043E\u0440\u0442\u0438\u0440\u043E\u0432\u043A\u0438 \u0441\u0442\u0440\u043E\u043A SettingsDialog.RowSortDirectionAsPrevious = \u041A\u0430\u043A \u043F\u0440\u0435\u0434\u044B\u0434\u0443\u0449\u0430\u044F SettingsDialog.RowSortDirectionAscending = \u041F\u043E \u0443\u0431\u044B\u0432\u0430\u043D\u0438\u044E SettingsDialog.RowSortDirectionDescending = \u041F\u043E \u0432\u043E\u0437\u0440\u0430\u0441\u0442\u0430\u043D\u0438\u044E +SettingsDialog.RowSortDirectionTitle = \u041D\u0430\u043F\u0440\u0430\u0432\u043B\u0435\u043D\u0438\u0435 \u0441\u043E\u0440\u0442\u0438\u0440\u043E\u0432\u043A\u0438 \u0441\u0442\u0440\u043E\u043A SettingsDialog.ShadowSleepSessions = \u0417\u0430\u0442\u0435\u043D\u044F\u0442\u044C \u0441\u043F\u044F\u0446\u0438\u0435 \u0441\u0435\u0430\u043D\u0441\u044B SettingsDialog.ShowInfo = \u0414\u043E\u043F\u043E\u043B\u043D\u0438\u0442\u0435\u043B\u044C\u043D\u0430\u044F \u0438\u043D\u0444\u043E\u0440\u043C\u0430\u0446\u0438\u044F SettingsDialog.ShowInfobaseDescription = \u041F\u043E\u043A\u0430\u0437\u044B\u0432\u0430\u0442\u044C \u043E\u043F\u0438\u0441\u0430\u043D\u0438\u0435 \u0438\u043D\u0444\u043E\u0431\u0430\u0437\u044B diff --git a/clusterAdminLibrary/src/main/resources/icons/taskCompleted.png b/clusterAdminLibrary/src/main/resources/icons/taskCompleted.png index b826ee8be985adf38e8fcb8bd1e4138ebdc081b0..6925aedbebc07ddcf4c66a2fbb1befd37a14fc98 100644 GIT binary patch delta 258 zcmV+d0sa1!1j7Q5Nq@os00P1R+mhLk0002kNkla5MTTG^_LSfNP-xErkUZ_x8I_Fe*HBd$^}?7GyMMf=NXXc2sQwy zfE!2^192PBUw=SiFn~|<8{$@nx62Ef1o0B4knjfG1~m;e9(07*qo IM6N<$f`n{n4gdfE delta 470 zcmV;{0V)2&0+j@iNq@rt00P4S3DrAv00051Nkld`;8oplz$xn&g~eM!5nA00yJtH95lD&+x%!3D=n4JNFa*Zx&~E*}^(S4#6> zlmYlythu6knuf&h*#|+)?JDV`Spn<^D`oPTE0KX#zXZI;;&QqbntM%JoE_YvkLJJ| z@RQWj!c06&9e+H|s4?I@QjXMn@lAs9DY?s@NzusDl(Pdc>TLI+^fvQJN{6YsnnpFI z^#=(hmL!@vRcli@mcS;FZ2nm;p0>*zEoa*397E=BN-_Yu%ixuwnTWb#O21dT6f+0o z(<*bp_%N+X1_)aLUTC3W*>gETHofqwsF0bWPnd7OMo(G?E42PWn_%O=t$YP0*~%V9P0+IWi5J9!13jhEB M07*qoM6N<$g0WHH&Hw-a diff --git a/clusterAdminLibrary/src/main/resources/icons/taskRunning.png b/clusterAdminLibrary/src/main/resources/icons/taskRunning.png index cbfdb3da975025a9c0c3a6800154d1610ce31925..2f2a07209f7f747a6ce8099f5aee6bc9c8a3ad36 100644 GIT binary patch delta 606 zcmV-k0-^oZ2AlY00XW8%2`vH0006pNklru4P%~&vq)mchPcj z;~sTiG2JMjo;wk@rmkNxSU{2_Fbutq9hQc80VbH^Vt8A2@Tv}iBmT;N{7{#T9 z?8i6!aACLYI55UAlYWdG+jbN7Ls1l2QPp>s28YPai6>-kWu3g9Um&T6k4W$30akL- z&HRh615pqmAj$fngbA^er$JGJphpZi-qj6fdiy|<<$sGb&HYjKBNB={8=0OV*@8pf zT8PY7u+PTR8P-M0&35s15Kfpk`fuIge$amboWZ+e5RIEdp5(L^5Va#mL)Pk7D6T9* zp4#e?-+ul04pGzW^71*&@6cIz+H)-SKvN_hlZv@6@rxfqC>VR;82SjcSv%)l?98GE=Sp>?rRBKZ2*GAR%c#($Mk zZZ-dKHeKxt(GN|G%%>6|kO_<=6oP%BSnt@Ohrp3-uWP_R_j zH-1e&#ytXSAK(L+@e8)*m2GZR_)1A%tG-b+Wr(cU=`Z2@pVY5=?{q6uERA}ObE(97FTXc~HN<#`wH9}=nfZW-k(Pi1WU zy8sFcU_01057Y^SqC~NWlxmM&sA7d8aYNaOEN;e1c&Fn5tpC5{s(@U%IuNgXL4^DS Y&J&*(b9h5EoB#j-07*qoM6N<$f_dt71ONa4 diff --git a/clusterAdminLibrary/src/main/resources/logback.xml b/clusterAdminLibrary/src/main/resources/logback.xml index de37872..c8d3af0 100644 --- a/clusterAdminLibrary/src/main/resources/logback.xml +++ b/clusterAdminLibrary/src/main/resources/logback.xml @@ -23,21 +23,10 @@ - - - - - - - - - - - - - + + \ No newline at end of file From e6cbd0ff2054d16f2a2e951bd477d196fa59c8c2 Mon Sep 17 00:00:00 2001 From: YanSergey Date: Tue, 13 Dec 2022 20:30:52 +0300 Subject: [PATCH 06/70] =?UTF-8?q?=D1=80=D0=B5=D1=84=D0=B0=D0=BA=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=B8=D0=BD=D0=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../clusterAdminLibrary/BackgroundTask.java | 25 +- .../clusterAdminLibraryUI/ViewerArea.java | 532 +++++++++--------- 2 files changed, 292 insertions(+), 265 deletions(-) diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java index 3f0b22c..5dd97b7 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java @@ -18,14 +18,18 @@ /** Фоновый процесс. */ public class BackgroundTask { - private static final Logger LOGGER = LoggerFactory.getLogger("BackgroundTask"); // $NON-NLS-1$ + static final Logger LOGGER = LoggerFactory.getLogger(BackgroundTask.class.getSimpleName()); static int countOfRunning = 0; static int countOfCompleted = 0; static int countWithError = 0; static Map taskNamesCounter = new HashMap<>(); - String name; + static Image taskRunning = Helper.getImage("taskRunning.png"); //$NON-NLS-1$ + static Image taskCompleted = Helper.getImage("taskCompleted.png"); //$NON-NLS-1$ + static Image taskError = Helper.getImage("taskError.png"); //$NON-NLS-1$ + + String taskName; File script; Map params; @@ -44,10 +48,6 @@ enum TaskState { Thread thread; - static Image taskRunning = Helper.getImage("taskRunning.png"); // $NON-NLS-1$ - static Image taskCompleted = Helper.getImage("taskCompleted.png"); // $NON-NLS-1$ - static Image taskError = Helper.getImage("taskError.png"); // $NON-NLS-1$ - Date startDate; Date finishDate; @@ -61,7 +61,7 @@ public BackgroundTask(File script, Map params) { this.script = script; this.params = params; - this.name = generateTaskName(); + this.taskName = generateTaskName(); } @@ -105,7 +105,7 @@ public static void resetCount() { * * @param task - задача */ - public static void calculateCount(BackgroundTask task) { + private static void calculateCount(BackgroundTask task) { if (task.isRunning()) { countOfRunning++; @@ -137,6 +137,7 @@ public static void setTabTitle(TabItem tab) { // countOfRunning, countOfCompleted, countWithError); tab.setText(title); + tab.setImage(countOfRunning == 0 ? taskCompleted : taskRunning); } /** @@ -144,8 +145,8 @@ public static void setTabTitle(TabItem tab) { * * @return name of task */ - public String getName() { - return name; + public String getTaskName() { + return taskName; } /** @@ -175,7 +176,7 @@ public String[] getDescription() { // .collect(Collectors.joining("\n")); return new String[] { - name, + taskName, stateString, Helper.dateToString(startDate), Helper.dateToString(finishDate), @@ -249,7 +250,7 @@ public void update(TableItem tableItem) { stateLast = state; } - BackgroundTask.calculateCount(this); + calculateCount(this); } /** Запуск фонового задания. */ diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java index e0b01f4..ea53ceb 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java @@ -182,14 +182,15 @@ public enum TreeItemType { Map serversTreeContextMenus = new EnumMap<>(TreeItemType.class); Map> linksTablesToExtendedClass = new HashMap<>(); - List userScripts = new ArrayList<>(); + // List userScripts = new ArrayList<>(); Timer taskTimer; Timer serverConnectionTimer; Timer updateListTimer; List waitingConnectServers = new ArrayList<>(); - UpdateTablesSelectionListener updateTablesListener; + RefreshTablesSelectionListener refreshTablesListener; + // UserScriptRunner userScriptRunner; // @Slf4j /** @@ -216,7 +217,6 @@ public ViewerArea( this.setLayout(new FillLayout(SWT.HORIZONTAL)); initIcon(); - initUserScripts(); initMainMenu(menu); initToolbar(toolBar); @@ -244,7 +244,7 @@ public ViewerArea( @Override public void widgetSelected(SelectionEvent evt) { currentTab = tabFolderServers.getSelection()[0]; - fillTabs(); + refreshCurrentList(); } }); @@ -379,11 +379,11 @@ private void initToolbar(ToolBar toolBar) { // addItemInToolbar(toolBar, Strings.CONTEXT_MENU_UPDATE, updateIcon, updateTablesListener); - ToolItem toolItem = new ToolItem(toolBar, SWT.DROP_DOWN); - toolItem.setText(Strings.CONTEXT_MENU_UPDATE); - toolItem.setImage(updateIcon24); + ToolItem refreshToolbarItem = new ToolItem(toolBar, SWT.DROP_DOWN); + refreshToolbarItem.setText(Strings.CONTEXT_MENU_UPDATE); + refreshToolbarItem.setImage(updateIcon24); - updateTablesListener = new UpdateTablesSelectionListener(toolItem); + refreshTablesListener = new RefreshTablesSelectionListener(refreshToolbarItem); toolBar.pack(); } @@ -494,13 +494,8 @@ private void initServerMenu() { addItemInMenu( serverMenu, Strings.CONTEXT_MENU_REMOVE_SERVER, deleteIcon16, deleteServerListener); - // это для отладки без запуска севрера - addMenuSeparator(serverMenu); - Menu subMenuUserScripts = addItemGroupInMenu(serverMenu, "Пользовательские скрипты", null); - - for (File script : userScripts) { - addItemInMenu(subMenuUserScripts, script.getName(), null, userScriptRunner, script); - } + // TODO это для отладки без запуска сервера - удалить + new UserScriptRunner(serverMenu); } private void initClusterMenu() { @@ -616,13 +611,7 @@ private void initInfobaseMenu() { null, terminateUsersSessionsListener); - addMenuSeparator(infobaseMenu); - - Menu subMenuUserScripts = addItemGroupInMenu(infobaseMenu, "Пользовательские скрипты", null); - - for (File script : userScripts) { - addItemInMenu(subMenuUserScripts, script.getName(), null, userScriptRunner, script); - } + new UserScriptRunner(infobaseMenu); } private TabItem initListTable( @@ -669,7 +658,7 @@ private void initTableContextMenu( table.setMenu(tableMenu); if (updatable) { - addItemInMenu(tableMenu, Strings.CONTEXT_MENU_UPDATE_F5, updateIcon16, updateTablesListener); + addItemInMenu(tableMenu, Strings.CONTEXT_MENU_UPDATE_F5, updateIcon16, refreshTablesListener); } if (creatable) { @@ -734,23 +723,6 @@ private void initMaps() { linksTablesToExtendedClass.put(tabWorkingProcesses, WorkingProcessInfoExtended.class); } - private void initUserScripts() { - File userScriptsDir = new File("scripts"); // $NON-NLS-1$ - if (!userScriptsDir.exists()) { - userScriptsDir.mkdir(); - // можно скачивать скрипты с репозитория - } - - if (userScriptsDir.exists() && userScriptsDir.isDirectory()) { - File[] scripts = userScriptsDir.listFiles(); - for (File script : scripts) { - if (script.isFile()) { - userScripts.add(script); - } - } - } - } - private ToolItem addItemInToolbar( ToolBar parent, String text, Image icon, SelectionAdapter listener) { @@ -802,11 +774,7 @@ private MenuItem addItemInMenu( } private MenuItem addRadioItemInMenu( - Menu parent, - String text, - SelectionAdapter listener, - Object data, - boolean selected) { + Menu parent, String text, SelectionAdapter listener, Object data, boolean selected) { MenuItem menuItem = new MenuItem(parent, SWT.RADIO); menuItem.setText(text); @@ -1173,7 +1141,7 @@ private void connectServerItem(TreeItem serverItem, boolean silentMode) { waitingConnectServers.add(serverItem); if (serverConnectionTimer == null) { serverConnectionTimer = new Timer(true); - serverConnectionTimer.schedule(new ServerConnectionChekerTimer(), 1000, 1000); + serverConnectionTimer.schedule(new ServerConnectionCheckerTimer(), 1000, 1000); } server.updateTreeItemState(serverItem); } @@ -1183,14 +1151,10 @@ private void disconnectServerItem(TreeItem serverItem) { if (server == null) { return; } - server.disconnectFromAgent(); // TODO надо сюда переместить updateTreeItemState и dispose + server.disconnectFromAgent(); server.updateTreeItemState(serverItem); - // serverItem.setImage(serverIcon); - - TreeItem[] clusterItems = serverItem.getItems(); - for (TreeItem clusterItem : clusterItems) { - clusterItem.dispose(); - } + saveCurrentSelectedData(serverItem); + Arrays.stream(serverItem.getItems()).forEach(Widget::dispose); } private void fillServersList() { @@ -1240,6 +1204,7 @@ private void updateClustersInTree(TreeItem serverItem) { // Разворачиваем дерево, если включена настройка serverItem.setExpanded(config.isExpandServersTree()); + columnServer.pack(); } private void updateNodesOfCluster(TreeItem clusterItem, Server server) { @@ -1429,7 +1394,7 @@ private void updateNode( UUID clusterId = getClusterId(clusterItem); } - private void fillTabs() { + private void refreshCurrentList() { Table currentTable = getCurrentTable(); if (currentTable == null) { @@ -1444,7 +1409,7 @@ private void fillTabs() { UUID clusterId = getCurrentClusterId(); UUID infobaseId = getInfobaseId(currentTreeItem); UUID workingProcessId = getCurrentWorkingProcessId(); - TreeItemType treeItemType = getTreeItemType(currentTreeItem); // TODO currentHighlightingType + // TreeItemType treeItemType = getTreeItemType(currentTreeItem); // TODO currentHighlightingType clearTabs(); List list = null; @@ -1452,20 +1417,25 @@ private void fillTabs() { // TODO getSessionsExtendedInfo, getConnectionsExtendedInfo и др. // заменить на одну?, определяемую через map if (currentTab.equals(tabSessions)) { - list = server.getSessionsExtendedInfo(treeItemType, clusterId, workingProcessId, infobaseId); + list = + server.getSessionsExtendedInfo( + currentHighlightingType, clusterId, workingProcessId, infobaseId); } else if (currentTab.equals(tabConnections)) { list = - server.getConnectionsExtendedInfo(treeItemType, clusterId, workingProcessId, infobaseId); + server.getConnectionsExtendedInfo( + currentHighlightingType, clusterId, workingProcessId, infobaseId); } else if (currentTab.equals(tabLocks)) { - list = server.getLocksExtendedInfo(treeItemType, clusterId, infobaseId); + list = server.getLocksExtendedInfo(currentHighlightingType, clusterId, infobaseId); } else if (currentTab.equals(tabWorkingProcesses)) { - list = server.getWorkingProcessesExtendedInfo(treeItemType, clusterId, workingProcessId); + list = + server.getWorkingProcessesExtendedInfo( + currentHighlightingType, clusterId, workingProcessId); } else if (currentTab.equals(tabWorkingServers)) { - list = server.getWorkingServersExtendedInfo(treeItemType, clusterId); + list = server.getWorkingServersExtendedInfo(currentHighlightingType, clusterId); } else { return; @@ -1478,6 +1448,7 @@ private void fillTabs() { private void highlightTreeItem(TreeItem treeItem) { currentTreeItem = treeItem; currentTreeItem.setFont(fontBold); + columnServer.pack(); } private void setActiveContextMenuInTree(TreeItem treeItem) { @@ -1497,8 +1468,6 @@ private void clearTabs() { } private void clickItemInServerTree(int mouseButton) { - // TODO запутанный метод - // его надо переделать, переименовать, переосмыслить места вызова TreeItem[] item = serversTree.getSelection(); if (item.length == 0) { return; @@ -1513,7 +1482,7 @@ private void clickItemInServerTree(int mouseButton) { } saveCurrentSelectedData(treeItem); setEnableToolbarItems(); - fillTabs(); + refreshCurrentList(); break; case 3: // right click @@ -2428,155 +2397,6 @@ public void widgetSelected(SelectionEvent event) { } }; - SelectionAdapter userScriptRunner = - new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - TreeItem[] items = serversTree.getSelection(); - if (items.length == 0) { - return; - } - TreeItem infobaseItem = items[0]; - - File script = (File) event.widget.getData(); - Map params = fillParams(script, infobaseItem); - if (params.isEmpty()) { - Helper.showMessageBox("Params is empty"); - return; - } - - BackgroundTask task = new BackgroundTask(script, params); - addToTasksQueue(task); - } - - public Map fillParams(File script, TreeItem infobaseItem) { - Map params = new HashMap<>(); - - UUID clusterId = getClusterId(infobaseItem); - UUID infobaseId = getInfobaseId(infobaseItem); - Server server = getServer(infobaseItem); - if (server == null) { - LOGGER.error( - "Error get server info {}", //$NON-NLS-1$ - script.getName()); - return params; - } - - String scriptText; - try { - scriptText = Files.readString(Path.of(script.getPath())); - } catch (IOException excp) { - LOGGER.error( - "Error read script {}", //$NON-NLS-1$ - script.getName(), - excp); - return params; - } - - Pattern p = Pattern.compile("\\%.+?\\%"); - // Pattern p = Pattern.compile("[^\\%]++", Pattern.CASE_INSENSITIVE); - - Matcher m = p.matcher(scriptText); - while (m.find()) { - final String foundParam = m.group(); - String paramValue; - - switch (foundParam) { - case "%infobase%": - paramValue = server.getInfoBaseName(clusterId, infobaseId); // $NON-NLS-1$ - break; - - case "%serverName%": - paramValue = server.getAgentHost(); // $NON-NLS-1$ - break; - - case "%agentPort%": - paramValue = server.getAgentPortAsString(); // $NON-NLS-1$ - break; - - case "%managerPort%": - paramValue = server.getClusterMainPort(clusterId); // $NON-NLS-1$ - break; - - default: - LOGGER.error( - "Found unknown param {}", //$NON-NLS-1$ - foundParam); - paramValue = ""; // $NON-NLS-1$ - break; - } - - String paramKey = foundParam.replace("%", ""); - params.put(paramKey, paramValue); - } - - // params.put("infobase", "dev1"); // $NON-NLS-1$ - // params.put("serverName", "server123"); // $NON-NLS-1$ - // params.put("managerPort", "4541"); // $NON-NLS-1$ - - return params; - } - - public void addToTasksQueue(BackgroundTask task) { - TableItem tableItem = new TableItem(tableTasks, SWT.NONE); - tableItem.setData(task); - tableItem.setChecked(false); - - if (tableTasks.getSelection().length == 0 || BackgroundTask.getRunningCount() == 0) { - tableTasks.setSelection(tableItem); - } - - task.run(); - - if (BackgroundTask.getRunningCount() == 0) { - taskTimer = new Timer(true); - taskTimer.scheduleAtFixedRate(new TaskChekerTimer(), 1000, 1000); - } - } - - class TaskChekerTimer extends TimerTask { - - @Override - public void run() { - - Display.getDefault() - .asyncExec( - new Runnable() { - public void run() { - TableItem[] items = tableTasks.getItems(); - TableItem[] selectItems = tableTasks.getSelection(); - - BackgroundTask.resetCount(); - - for (TableItem tableItem : items) { - BackgroundTask task = (BackgroundTask) tableItem.getData(); - task.update(tableItem); - - // tableItem.setText(task.getDescription()); - // tableItem.setImage(task.getIcon()); - // BackgroundTask.calculateCount(task); - - if (selectItems.length > 0 - && tableItem.equals(selectItems[0]) - && (task.isRunning() - || tableTaskLog.getLineCount() - != task.getLog().lines().count())) { - tableTaskLog.setText(task.getLog()); - } - } - - BackgroundTask.setTabTitle(tabTask); - - if (BackgroundTask.getRunningCount() == 0) { - taskTimer.cancel(); - taskTimer = null; - } - } - }); - } - } - }; - SelectionAdapter createWorkingServerListener = new SelectionAdapter() { @Override @@ -2837,7 +2657,7 @@ public void widgetSelected(SelectionEvent e) { int dialogResult = dialog.open(); if (dialogResult == 0) { // clickItemInServerTree(0); // TODO что здесь должно делаться??? - fillTabs(); + refreshCurrentList(); } } else { return; @@ -2997,7 +2817,7 @@ public void keyPressed(KeyEvent e) { break; case SWT.F5: - fillTabs(); + refreshCurrentList(); break; case SWT.DEL: @@ -3049,7 +2869,7 @@ public void mouseDoubleClick(MouseEvent e) { } }; - private class ServerConnectionChekerTimer extends TimerTask { + private class ServerConnectionCheckerTimer extends TimerTask { @Override public void run() { @@ -3111,19 +2931,218 @@ public void run() { .asyncExec( new Runnable() { public void run() { - fillTabs(); + refreshCurrentList(); + } + }); + } + } + + class TaskChekerTimer extends TimerTask { + + @Override + public void run() { + + Display.getDefault() + .asyncExec( + new Runnable() { + public void run() { + TableItem[] items = tableTasks.getItems(); + TableItem[] selectItems = tableTasks.getSelection(); + + BackgroundTask.resetCount(); + + for (TableItem tableItem : items) { + BackgroundTask task = (BackgroundTask) tableItem.getData(); + task.update(tableItem); + + if (selectItems.length > 0 + && tableItem.equals(selectItems[0]) + && (task.isRunning() + || tableTaskLog.getLineCount() != task.getLog().lines().count())) { + tableTaskLog.setText(task.getLog()); + } + } + + BackgroundTask.setTabTitle(tabTask); + + if (BackgroundTask.getRunningCount() == 0) { + taskTimer.cancel(); + taskTimer = null; + } } }); } } - class UpdateTablesSelectionListener extends SelectionAdapter { + class UserScriptRunner extends SelectionAdapter { + + // поля + // private Menu menuUserScripts; + + public UserScriptRunner(Menu parentMenu) { + // this.menuUserScripts = parentMenu; + + addMenuSeparator(parentMenu); + Menu menuUserScripts = addItemGroupInMenu(parentMenu, "Пользовательские скрипты", null); + this.fillUserScriptsItems(menuUserScripts); + } + + public void fillUserScriptsItems(Menu subMenuUserScripts) { + Arrays.stream(subMenuUserScripts.getItems()).forEach(Widget::dispose); + // filter на элемент "Обновить" ??? + + addItemInMenu(subMenuUserScripts, Strings.CONTEXT_MENU_UPDATE, updateIcon16, this, null); + addMenuSeparator(subMenuUserScripts); + + // чтение каталога скриптов и создание подэлементов + readUserScripts() + .forEach( + script -> addItemInMenu(subMenuUserScripts, script.getName(), null, this, script)); + } + + private List readUserScripts() { + if (config.isWindows()) { + return new ArrayList<>(); + } + + File userScriptsDir = new File("scripts"); // $NON-NLS-1$ + if (!userScriptsDir.exists()) { + userScriptsDir.mkdir(); + // можно скачивать скрипты с репозитория + } + // userScripts.clear(); + List userScripts = new ArrayList<>(); + if (userScriptsDir.exists() && userScriptsDir.isDirectory()) { + File[] scripts = userScriptsDir.listFiles(); + for (File script : scripts) { + if (script.isFile()) { + userScripts.add(script); + } + } + } + return userScripts; + } + + @Override + public void widgetSelected(SelectionEvent event) { + TreeItem[] items = serversTree.getSelection(); + if (items.length == 0) { + return; + } + + Object scriptData = event.widget.getData(); + if (scriptData == null) { + Menu subMenuUserScripts = ((MenuItem) event.widget).getParent(); + fillUserScriptsItems(subMenuUserScripts); + return; + } + + File script = (File) event.widget.getData(); + + TreeItem infobaseItem = items[0]; + Map params = fillParams(script, infobaseItem); + if (params.isEmpty()) { + Helper.showMessageBox("Params is empty"); + return; + } + + BackgroundTask task = new BackgroundTask(script, params); + addToTasksQueue(task); + } + + public Map fillParams(File script, TreeItem infobaseItem) { + Map params = new HashMap<>(); + + UUID clusterId = getClusterId(infobaseItem); + UUID infobaseId = getInfobaseId(infobaseItem); + Server server = getServer(infobaseItem); + if (server == null) { + LOGGER.error( + "Error get server info {}", //$NON-NLS-1$ + script.getName()); + return params; + } + + String scriptText; + try { + scriptText = Files.readString(Path.of(script.getPath())); + } catch (IOException excp) { + LOGGER.error( + "Error read script {}", //$NON-NLS-1$ + script.getName(), + excp); + return params; + } + + Pattern p = Pattern.compile("\\%.+?\\%"); + // Pattern p = Pattern.compile("[^\\%]++", Pattern.CASE_INSENSITIVE); + + Matcher m = p.matcher(scriptText); + while (m.find()) { + final String foundParam = m.group(); + String paramValue; + + switch (foundParam) { + case "%infobase%": + paramValue = server.getInfoBaseName(clusterId, infobaseId); // $NON-NLS-1$ + break; + + case "%serverName%": + paramValue = server.getAgentHost(); // $NON-NLS-1$ + break; + + case "%agentPort%": + paramValue = server.getAgentPortAsString(); // $NON-NLS-1$ + break; + + case "%managerPort%": + paramValue = server.getClusterMainPort(clusterId); // $NON-NLS-1$ + break; + + default: + LOGGER.error( + "Found unknown param {}", //$NON-NLS-1$ + foundParam); + paramValue = ""; // $NON-NLS-1$ + break; + } + + String paramKey = foundParam.replace("%", ""); + params.put(paramKey, paramValue); + } + + // params.put("infobase", "dev1"); // $NON-NLS-1$ + // params.put("serverName", "server123"); // $NON-NLS-1$ + // params.put("managerPort", "4541"); // $NON-NLS-1$ + + return params; + } + + public void addToTasksQueue(BackgroundTask task) { + TableItem tableItem = new TableItem(tableTasks, SWT.NONE); + tableItem.setData(task); + tableItem.setChecked(false); + + if (tableTasks.getSelection().length == 0 || BackgroundTask.getRunningCount() == 0) { + tableTasks.setSelection(tableItem); + } + + task.run(); + + if (BackgroundTask.getRunningCount() == 0) { + taskTimer = new Timer(true); + taskTimer.scheduleAtFixedRate(new TaskChekerTimer(), 1000, 1000); + } + } + } + + class RefreshTablesSelectionListener extends SelectionAdapter { private ToolItem mainButton; private Menu dropdownMenu; private int refreshRate = config.getListRrefreshRate(); - public UpdateTablesSelectionListener(ToolItem mainButton) { + public RefreshTablesSelectionListener(ToolItem mainButton) { this.mainButton = mainButton; this.mainButton.addSelectionListener(this); @@ -3146,48 +3165,55 @@ public void add(Menu parentMenu, String title, int style, Object data) { menuItem.setData(data); if (style == SWT.CHECK) { menuItem.setImage(updateAutoIcon24); + menuItem.addSelectionListener(checkItemListener); } if (style == SWT.RADIO) { menuItem.setSelection((int) data == refreshRate); + menuItem.addSelectionListener(radioItemListener); } + } - menuItem.addSelectionListener( - new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - MenuItem selected = (MenuItem) event.widget; - - switch (selected.getStyle()) { - case SWT.CHECK: - if (selected.getSelection()) { - updateListTimer = new Timer(true); - updateListTimer.schedule(new UpdateListTimer(), 1000, refreshRate); - mainButton.setImage(updateAutoIcon24); - } else { - updateListTimer.cancel(); - updateListTimer = null; - mainButton.setImage(updateIcon24); - } - break; - - case SWT.RADIO: - if (selected.getSelection()) { - refreshRate = (int) selected.getData(); - config.setListRrefreshRate(refreshRate); - if (updateListTimer != null) { - updateListTimer.cancel(); - updateListTimer = new Timer(true); - updateListTimer.schedule(new UpdateListTimer(), 1000, refreshRate); - } - } - break; + SelectionAdapter checkItemListener = + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent event) { + MenuItem selected = (MenuItem) event.widget; - default: - break; + if (selected.getStyle() != SWT.CHECK) { + return; + } + if (selected.getSelection()) { + updateListTimer = new Timer(true); + updateListTimer.schedule(new UpdateListTimer(), 1000, refreshRate); + mainButton.setImage(updateAutoIcon24); + } else { + updateListTimer.cancel(); + updateListTimer = null; + mainButton.setImage(updateIcon24); + } + } + }; + + SelectionAdapter radioItemListener = + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent event) { + MenuItem selected = (MenuItem) event.widget; + + if (selected.getStyle() != SWT.RADIO) { + return; + } + if (selected.getSelection()) { + refreshRate = (int) selected.getData(); + config.setListRrefreshRate(refreshRate); + if (updateListTimer != null) { + updateListTimer.cancel(); + updateListTimer = new Timer(true); + updateListTimer.schedule(new UpdateListTimer(), 1000, refreshRate); } } - }); - } + } + }; @Override public void widgetSelected(SelectionEvent event) { @@ -3198,7 +3224,7 @@ public void widgetSelected(SelectionEvent event) { dropdownMenu.setLocation(pt.x, pt.y + rect.height); dropdownMenu.setVisible(true); } else { - fillTabs(); + refreshCurrentList(); } } } From 03c80f92aa5b490f2359c522e75365ae4653162d Mon Sep 17 00:00:00 2001 From: YanSergey Date: Thu, 22 Dec 2022 13:48:55 +0300 Subject: [PATCH 07/70] =?UTF-8?q?=D0=BA=D0=BE=D0=BD=D1=82=D0=B5=D0=BA?= =?UTF-8?q?=D1=81=D1=82=D0=BD=D0=BE=D0=B5=20=D0=BC=D0=B5=D0=BD=D1=8E=20-?= =?UTF-8?q?=20=D0=BA=D0=BE=D0=BF=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D1=82=D1=8C?= =?UTF-8?q?=20=D1=8F=D1=87=D0=B5=D0=B9=D0=BA=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../clusterAdminLibraryUI/ViewerArea.java | 92 +++++++++++-------- .../clusterAdminLibraryUI/messages.properties | 1 + .../messages_ru_RU.properties | 1 + 3 files changed, 54 insertions(+), 40 deletions(-) diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java index ea53ceb..3ea6d8f 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java @@ -201,7 +201,7 @@ public enum TreeItemType { * @param menu - menu * @param toolBar - toolBar * @param clusterProvider - clusterProvider - * @param configPath - путь к файлу конфигурации + * @param config - путь к файлу конфигурации */ public ViewerArea( Composite parent, @@ -226,33 +226,39 @@ public ViewerArea( BaseInfoExtended.init(); TabFolder mainTabFolder = new TabFolder(this, SWT.BOTTOM); - - TabItem tabMain = new TabItem(mainTabFolder, SWT.NONE); - tabMain.setText("Main"); + initServersTab(mainTabFolder); + initTaskTab(mainTabFolder); + + runAutonnectAllServers(); + } + + private void initServersTab(TabFolder mainTabFolder) { + TabItem tabServers = new TabItem(mainTabFolder, SWT.NONE); + tabServers.setText(Strings.MENU_SERVERS); // инициализация таблиц управления серверами SashForm sashServers = new SashForm(mainTabFolder, SWT.NONE); - tabMain.setControl(sashServers); + tabServers.setControl(sashServers); initServersTree(sashServers); - TabFolder tabFolderServers = new TabFolder(sashServers, SWT.NONE); + TabFolder tabFolderLists = new TabFolder(sashServers, SWT.NONE); - tabFolderServers.addSelectionListener( + tabFolderLists.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent evt) { - currentTab = tabFolderServers.getSelection()[0]; + currentTab = tabFolderLists.getSelection()[0]; refreshCurrentList(); } }); - tabSessions = initListTable(tabFolderServers, SessionInfoExtended.class, true); - tabConnections = initListTable(tabFolderServers, ConnectionInfoExtended.class, false); - tabLocks = initListTable(tabFolderServers, LockInfoExtended.class, false); - tabWorkingProcesses = initListTable(tabFolderServers, WorkingProcessInfoExtended.class, false); - tabWorkingServers = initListTable(tabFolderServers, WorkingServerInfoExtended.class, false); + tabSessions = initListTable(tabFolderLists, SessionInfoExtended.class, true); + tabConnections = initListTable(tabFolderLists, ConnectionInfoExtended.class, false); + tabLocks = initListTable(tabFolderLists, LockInfoExtended.class, false); + tabWorkingProcesses = initListTable(tabFolderLists, WorkingProcessInfoExtended.class, false); + tabWorkingServers = initListTable(tabFolderLists, WorkingServerInfoExtended.class, false); //////////////////////////////////////////// initMaps(); @@ -270,21 +276,6 @@ public void widgetSelected(SelectionEvent evt) { // Пропорции областей sashServers.setWeights(3, 10); - - // Заполнение списка серверов - config - .getServers() - .forEach( - (serverKey, server) -> { - addServerItemInServersTree(server); - }); - columnServer.pack(); - - runAutonnectAllServers(); - - // инициализация таблиц заданий - initTaskTab(mainTabFolder); - } private void initTaskTab(TabFolder mainTabFolder) { @@ -318,7 +309,7 @@ public void handleEvent(Event e) { } private void initIcon() { - LOGGER.info("Start init icon"); //$NON-NLS-1$ + LOGGER.debug("Start init icon"); //$NON-NLS-1$ // serverAdd48Icon = Helper.getImage("server_add_48.png"); //$NON-NLS-1$ // clusterAdd48Icon = Helper.getImage("cluster_add_48.png"); //$NON-NLS-1$ @@ -357,7 +348,7 @@ private void initIcon() { moveUpIcon = Helper.getImage("move_up.png"); //$NON-NLS-1$ moveDownIcon = Helper.getImage("move_down.png"); //$NON-NLS-1$ - LOGGER.info("Icon init succesfully"); //$NON-NLS-1$ + LOGGER.debug("Icon init succesfully"); //$NON-NLS-1$ } private void initToolbar(ToolBar toolBar) { @@ -427,6 +418,14 @@ public void handleEvent(Event event) { columnServer.setText(Strings.COLUMN_SERVER); columnServer.setWidth(350); + // Заполнение списка серверов + config + .getServers() + .forEach( + (serverKey, server) -> { + addServerItemInServersTree(server); + }); + columnServer.pack(); } private void initServersTreeContextMenu() { @@ -674,6 +673,9 @@ private void initTableContextMenu( addItemInMenu(tableMenu, title, editIcon16, editItemInTablesListener); } + addItemInMenu( + tableMenu, Strings.CONTEXT_MENU_COPY_CELL_VALUE, null, copyCellValueInTablesListener); + if (killable) { String title = tableContextItemDelete.get(tab); addItemInMenu(tableMenu, title, deleteIcon16, deleteItemInTablesListener); @@ -2730,6 +2732,22 @@ public void widgetSelected(SelectionEvent e) { } }; + SelectionAdapter copyCellValueInTablesListener = + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + + TableItem[] selection = getCurrentTable().getSelection(); + if (selection.length > 0) { + Clipboard clipboard = new Clipboard(Display.getDefault()); + clipboard.setContents( + new Object[] {selection[0].getText(lastSelectColumn)}, + new Transfer[] {TextTransfer.getInstance()}); + clipboard.dispose(); + } + } + }; + Listener switchWatchingListener = new Listener() { @Override @@ -2773,7 +2791,7 @@ public void handleEvent(Event event) { new MouseAdapter() { @Override public void mouseDown(MouseEvent event) { - if (event.button != 1) { + if (event.button != 1 && event.button != 3) { return; } Table currentTable = (Table) event.widget; @@ -2826,15 +2844,7 @@ public void keyPressed(KeyEvent e) { case keyC: if (e.stateMask == SWT.CTRL) { - TableItem[] selection = getCurrentTable().getSelection(); - - if (selection.length > 0) { - Clipboard clipboard = new Clipboard(Display.getDefault()); - clipboard.setContents( - new Object[] {selection[0].getText(lastSelectColumn)}, - new Transfer[] {TextTransfer.getInstance()}); - clipboard.dispose(); - } + copyCellValueInTablesListener.widgetSelected(null); } break; @@ -3252,6 +3262,8 @@ private static class Strings { static final String CONTEXT_MENU_CREATE = getString("ContextMenu.Create"); static final String CONTEXT_MENU_EDIT = getString("ContextMenu.Edit"); static final String CONTEXT_MENU_DELETE = getString("ContextMenu.Delete"); + static final String CONTEXT_MENU_COPY_CELL_VALUE = + getString("ContextMenu.CopyCellValue").concat("\tCtrl+C"); static final String CONTEXT_MENU_ADD_SERVER = getString("ContextMenu.AddServer"); static final String CONTEXT_MENU_EDIT_SERVER = getString("ContextMenu.EditServer"); static final String CONTEXT_MENU_MOVE_UP = getString("ContextMenu.MoveUp"); diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties index 1dbbe2f..ca33705 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties @@ -141,6 +141,7 @@ ViewerArea.ConnPerProcessLimit = Conn per process limit ViewerArea.ContextMenu.AddInFavorites = Add to favorites ViewerArea.ContextMenu.AddServer = Add server ViewerArea.ContextMenu.ConnectToServer = Connect to server +ViewerArea.ContextMenu.CopyCellValue = Copy cell value ViewerArea.ContextMenu.CopyInfobase = Copy infobase ViewerArea.ContextMenu.Create = Create ViewerArea.ContextMenu.CreateCluster = Create cluster diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties index 6b3bf02..9d95ea4 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties @@ -141,6 +141,7 @@ ViewerArea.ConnPerProcessLimit = \u041A\u043E\u043B\u04 ViewerArea.ContextMenu.AddInFavorites = \u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u0432 \u0438\u0437\u0431\u0440\u0430\u043D\u043D\u043E\u0435 ViewerArea.ContextMenu.AddServer = \u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u0441\u0435\u0440\u0432\u0435\u0440 ViewerArea.ContextMenu.ConnectToServer = \u041F\u043E\u0434\u043A\u043B\u044E\u0447\u0438\u0442\u044C\u0441\u044F \u043A \u0441\u0435\u0440\u0432\u0435\u0440\u0443 +ViewerArea.ContextMenu.CopyCellValue = \u041A\u043E\u043F\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u044F\u0447\u0435\u0439\u043A\u0438 ViewerArea.ContextMenu.CopyInfobase = \u0421\u043A\u043E\u043F\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u0438\u043D\u0444\u043E\u0431\u0430\u0437\u0443 ViewerArea.ContextMenu.Create = \u0421\u043E\u0437\u0434\u0430\u0442\u044C ViewerArea.ContextMenu.CreateCluster = \u0421\u043E\u0437\u0434\u0430\u0442\u044C \u043A\u043B\u0430\u0441\u0442\u0435\u0440 From 69c224eadb5efb32a3e3b5dafd87cbb6f4b41e55 Mon Sep 17 00:00:00 2001 From: YanSergey Date: Fri, 23 Dec 2022 13:54:45 +0300 Subject: [PATCH 08/70] Sonar skipTests --- .github/workflows/SonarCloud.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/SonarCloud.yml b/.github/workflows/SonarCloud.yml index 96081e4..244d517 100644 --- a/.github/workflows/SonarCloud.yml +++ b/.github/workflows/SonarCloud.yml @@ -42,7 +42,7 @@ jobs: run: > cd clusterAdminLibrary - mvn -B verify sonar:sonar + mvn -B verify -DskipTests sonar:sonar -Dsonar.projectKey=YanSergey_OneS_ClusterAdmin -Dsonar.projectName="OneS ClusterAdmin" -Dsonar.organization=yansergey From 9bc4875ed4e718405c83cd613cc1081b475d50b1 Mon Sep 17 00:00:00 2001 From: YanSergey Date: Mon, 2 Jan 2023 13:45:43 +0300 Subject: [PATCH 09/70] =?UTF-8?q?=D0=9F=D0=BE=D0=BB=D1=83=D1=87=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BE=D1=82=20=D0=B0=D0=B3=D0=B5=D0=BD?= =?UTF-8?q?=D1=82=D0=B0=20=D0=B2=D0=B5=D1=80=D1=81=D0=B8=D0=B8=20=D1=81?= =?UTF-8?q?=D0=B5=D1=80=D0=B2=D0=B5=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yanygin/clusterAdminLibrary/Server.java | 105 ++++++---- .../clusterAdminLibraryUI/ServerDialog.java | 194 ++++++++---------- .../clusterAdminLibraryUI/messages.properties | 1 + .../messages_ru_RU.properties | 1 + 4 files changed, 157 insertions(+), 144 deletions(-) diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java index 9194029..acf0263 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java @@ -30,6 +30,7 @@ import com._1c.v8.ibis.admin.client.IAgentAdminConnectorFactory; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; +import java.lang.Runtime.Version; import java.text.Collator; import java.util.ArrayList; import java.util.Collections; @@ -79,9 +80,9 @@ public class Server implements Comparable { @Expose private int localRasPort = 0; - @SerializedName("LocalRasV8version") + @SerializedName("V8Version") @Expose - private String localRasV8version = ""; //$NON-NLS-1$ + private String v8version = ""; //$NON-NLS-1$ @SerializedName("Autoconnect") @Expose @@ -89,7 +90,7 @@ public class Server implements Comparable { @Deprecated(since = "0.3.0", forRemoval = true) @SerializedName("SaveCredentials") - @Expose(serialize = false, deserialize = true) // TODO верно ли написал + @Expose(serialize = false, deserialize = true) private boolean saveCredentials = false; @SerializedName("SaveCredentialsVariant") @@ -98,12 +99,12 @@ public class Server implements Comparable { @Deprecated(since = "0.3.0", forRemoval = true) @SerializedName("AgentUser") - @Expose(serialize = false, deserialize = true) // TODO верно ли написал + @Expose(serialize = false, deserialize = true) private String agentUserName = ""; //$NON-NLS-1$ @Deprecated(since = "0.3.0", forRemoval = true) @SerializedName("AgentPassword") - @Expose(serialize = false, deserialize = true) // TODO верно ли написал + @Expose(serialize = false, deserialize = true) private String agentPassword = ""; //$NON-NLS-1$ @SerializedName("AgentCredential") @@ -112,7 +113,7 @@ public class Server implements Comparable { @Deprecated(since = "0.3.0", forRemoval = true) @SerializedName("ClustersCredentials") - @Expose(serialize = false, deserialize = true) // TODO верно ли написал + @Expose(serialize = false, deserialize = true) private Map clustersCredentialsOld = new HashMap<>(); @SerializedName("ClustersCredentialsV3") @@ -130,9 +131,10 @@ public class Server implements Comparable { private ServerState serverState = ServerState.DISCONNECT; private boolean available; private Process localRasProcess; - private String connectionError = ""; //$NON-NLS-1$; + private String connectionError = ""; //$NON-NLS-1$ boolean silentConnectionMode = false; - // private String agentVersion = ""; //$NON-NLS-1$ + + @Deprecated private String agentVersion = Messages.getString("Server.NotConnect"); //$NON-NLS-1$ private IAgentAdminConnector agentConnector; @@ -337,30 +339,21 @@ public void setLocalRasPort(int localRasPort) { } /** - * Получение версии v8 локального RAS. + * Получение версии платформы v8 1C-сервера. * - * @return версия v8 локального RAS + * @return версия платформы v8 1C-сервера */ - public String getLocalRasV8version() { - return localRasV8version; + public String getV8Version() { + return this.v8version; } /** - * Установка версии v8 локального RAS. + * Установка версии платформы v8 1C-сервера. * - * @param localRasV8version - версия v8 локального RAS + * @param v8version - версия платформы v8 1C-сервера */ - public void setLocalRasV8version(String localRasV8version) { - this.localRasV8version = localRasV8version; - } - - /** - * Получение версии агента сервера. - * - * @return версия агента сервера - */ - public String getAgentVersion() { - return agentVersion; + public void setV8Version(String v8version) { + this.v8version = v8version; } /** @@ -405,7 +398,7 @@ public String getTreeTitle() { : ""; //$NON-NLS-1$ var serverVersionPatternPart = commonConfig.isShowServerVersion() - ? String.format(" (%s)", agentVersion) //$NON-NLS-1$ + ? String.format(" (%s)", v8version) //$NON-NLS-1$ : ""; //$NON-NLS-1$ var serverDescriptionPatternPart = commonConfig.isShowServerDescription() && !description.isBlank() @@ -705,19 +698,57 @@ public int compareTo(Server o) { return collator.compare(secondString, firstString); } - private void readAgentVersion() { + private void refreshAgentVersion() { if (!isConnected()) { return; } - + + String newAgentVersionString = ""; try { - agentVersion = agentConnection.getAgentVersion(); - LOGGER.debug( - "Agent version of server <{}> is <{}>", this.getServerKey(), agentVersion); //$NON-NLS-1$ + newAgentVersionString = agentConnection.getAgentVersion(); } catch (Exception e) { - agentVersion = Messages.getString("Server.UnknownAgentVersion"); //$NON-NLS-1$ - LOGGER.error("Unknown agent version of server <{}>", this.getServerKey()); //$NON-NLS-1$ + // для платформы 8.3.10 и ниже agentConnection.getAgentVersion() бросает AgentAdminException + this.v8version = Messages.getString("Server.UnknownAgentVersion"); // $NON-NLS-1$ + LOGGER.error("Unknown agent version of server <{}>", this.getServerKey()); // $NON-NLS-1$ + return; + } + + if (this.v8version.isEmpty()) { + this.v8version = newAgentVersionString; + LOGGER.debug( + "Set Server <{}> version is <{}>", this.getServerKey(), this.v8version); //$NON-NLS-1$ + return; + } + + // agentVersion = agentConnection.getAgentVersion() = [8, 3, 18, 1483] + // agentVersion.feature() = 8 + // agentVersion.interim() = 3 + // agentVersion.update() = 18 + // agentVersion.patch() = 1483 + // для платформы 8.3.15 и ниже agentVersion.patch() = 0 всегда + + Version newAgentVersion = Version.parse(newAgentVersionString); + Version savedV8version = Version.parse(this.v8version); + + boolean v8versionIsActual; + + if (newAgentVersion.version().size() == 3) { + v8versionIsActual = + savedV8version.feature() != newAgentVersion.feature() + || savedV8version.interim() != newAgentVersion.interim() + || savedV8version.update() != newAgentVersion.update(); + + } else { + v8versionIsActual = savedV8version.equals(newAgentVersion); + } + + if (!v8versionIsActual) { + this.v8version = newAgentVersionString; + LOGGER.debug( + "Refresh Server <{}> version is <{}>", //$NON-NLS-1$ + this.getServerKey(), + this.v8version); } } @@ -739,7 +770,7 @@ private String getLocalisedMessage(Throwable excp) { * @return {@code true} если v8 версия 8.3.15 или выше */ public boolean isFifteenOrMoreAgentVersion() { - return agentVersion.compareTo("8.3.15") >= 0; //$NON-NLS-1$ + return v8version.compareTo("8.3.15") >= 0; //$NON-NLS-1$ } /** @@ -878,7 +909,7 @@ private boolean checkAndRunLocalRas() { return true; } - if (localRasV8version.isBlank() || localRasPort == 0) { + if (v8version.isBlank() || localRasPort == 0) { var message = String.format( Messages.getString("Server.LocalRasParamsIsEmpty"), //$NON-NLS-1$ @@ -892,7 +923,7 @@ private boolean checkAndRunLocalRas() { ///////////////////////////// пока только Windows var processBuilder = new ProcessBuilder(); var processOutput = ""; //$NON-NLS-1$ - var localRasPath = Helper.getInstalledV8Versions().get(localRasV8version); + var localRasPath = Helper.getInstalledV8Versions().get(v8version); if (localRasPath == null) { var message = String.format( @@ -1030,7 +1061,7 @@ private void connectToAgent(String address, int port, long timeout) { available = true; connectionError = ""; //$NON-NLS-1$ - readAgentVersion(); + refreshAgentVersion(); LOGGER.debug("Server <{}> is connected now", this.getServerKey()); //$NON-NLS-1$ } diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ServerDialog.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ServerDialog.java index 3de6a0e..5839f5d 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ServerDialog.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ServerDialog.java @@ -63,11 +63,11 @@ public class ServerDialog extends Dialog { private Text txtAgentHost; private Text txtAgentPort; private Text txtLocalRasPort; - + private Combo comboV8Version; private Link txtAgentCredential; - + private Table tableClusterCredentials; private Table tableInfobasesCredentials; @@ -121,15 +121,51 @@ protected Control createDialogArea(Composite parent) { GridLayout glConnectContainer = new GridLayout(2, false); connectContainer.setLayout(glConnectContainer); - Composite composite = new Composite(connectContainer, SWT.NONE); - composite.setLayout(new GridLayout(2, false)); - composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1)); - - Label lblDescription = new Label(composite, SWT.NONE); - lblDescription.setText(Strings.SERVER_DESCRIPTION); + Group grpDescription = new Group(connectContainer, SWT.NONE); + grpDescription.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1)); + grpDescription.setText(Strings.SERVER_DESCRIPTION); + grpDescription.setLayout(new GridLayout(1, false)); - txtDescription = new Text(composite, SWT.BORDER); + txtDescription = new Text(grpDescription, SWT.BORDER); txtDescription.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); + txtDescription.setSize(392, 21); + + Group grpRagentAddress = new Group(connectContainer, SWT.NONE); + grpRagentAddress.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1)); + grpRagentAddress.setText(Strings.AGENT_PARAMETERS); + grpRagentAddress.setLayout(new GridLayout(3, false)); + + Label lblV8Version = new Label(grpRagentAddress, SWT.NONE); + lblV8Version.setText(Strings.V8_VERSION); + + Label lblAgentHost = new Label(grpRagentAddress, SWT.NONE); + lblAgentHost.setText(Strings.HOST); + + Label lblAgentPort = new Label(grpRagentAddress, SWT.NONE); + lblAgentPort.setText(Strings.PORT); + + comboV8Version = new Combo(grpRagentAddress, SWT.NONE); + comboV8Version.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1)); + + txtAgentHost = new Text(grpRagentAddress, SWT.BORDER); + txtAgentHost.addModifyListener( + new ModifyListener() { + @Override + public void modifyText(ModifyEvent e) { + if (rasOnSameHost) { + txtRasHost.setText(((Text) e.widget).getText()); + } + checkRasOnSameHost(); + } + }); + GridData gdtxtAgentHost = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); + gdtxtAgentHost.widthHint = 200; + txtAgentHost.setLayoutData(gdtxtAgentHost); + + txtAgentPort = new Text(grpRagentAddress, SWT.BORDER); + GridData gdtxtAgentPort = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); + gdtxtAgentPort.widthHint = 50; + txtAgentPort.setLayoutData(gdtxtAgentPort); btnAutoconnect = new Button(connectContainer, SWT.CHECK); GridData gdbtnAutoconnect = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); @@ -138,10 +174,20 @@ protected Control createDialogArea(Composite parent) { btnAutoconnect.setText(Strings.AUTOCONNECT_AT_STARTUP); new Label(connectContainer, SWT.NONE); - radioUseRemoteRas = new Button(connectContainer, SWT.RADIO); - GridData gdradioUseRemoteRas = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); - gdradioUseRemoteRas.horizontalIndent = 5; - radioUseRemoteRas.setLayoutData(gdradioUseRemoteRas); + Group grpConnectParameters = new Group(connectContainer, SWT.NONE); + grpConnectParameters.setLayout(new GridLayout(3, false)); + grpConnectParameters.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1)); + grpConnectParameters.setText(Strings.CONNECTION_VARIANT); + new Label(grpConnectParameters, SWT.NONE); + + Label lblRasHost = new Label(grpConnectParameters, SWT.NONE); + lblRasHost.setText(Strings.HOST); + + Label lblRasPort = new Label(grpConnectParameters, SWT.NONE); + lblRasPort.setSize(46, 15); + lblRasPort.setText(Strings.PORT); + + radioUseRemoteRas = new Button(grpConnectParameters, SWT.RADIO); radioUseRemoteRas.setSelection(true); radioUseRemoteRas.addSelectionListener( new SelectionAdapter() { @@ -153,95 +199,32 @@ public void widgetSelected(SelectionEvent e) { radioUseRemoteRas.setBounds(0, 0, 90, 16); radioUseRemoteRas.setText(Strings.USE_REMOTE_RAS); - radioUseLocalRas = new Button(connectContainer, SWT.RADIO); - GridData gdradioUseLocalRas = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); - gdradioUseLocalRas.horizontalIndent = 5; - radioUseLocalRas.setLayoutData(gdradioUseLocalRas); - radioUseLocalRas.setBounds(0, 0, 90, 16); - radioUseLocalRas.setText(Strings.USE_LOCAL_RAS); - - Group grpRemoteRasParameters = new Group(connectContainer, SWT.NONE); - grpRemoteRasParameters.setText(Strings.REMOTE_RAS_PARAMETERS); - grpRemoteRasParameters.setLayout(new GridLayout(2, false)); - - Label lblRasHost = new Label(grpRemoteRasParameters, SWT.NONE); - lblRasHost.setText(Strings.HOST); - - Label lblRasPort = new Label(grpRemoteRasParameters, SWT.NONE); - lblRasPort.setSize(46, 15); - lblRasPort.setText(Strings.PORT); - - txtRasHost = new Text(grpRemoteRasParameters, SWT.BORDER); + txtRasHost = new Text(grpConnectParameters, SWT.BORDER); + GridData gdTxtRasHost = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); + gdTxtRasHost.widthHint = 200; + txtRasHost.setLayoutData(gdTxtRasHost); txtRasHost.addModifyListener( new ModifyListener() { @Override public void modifyText(ModifyEvent e) { - if (rasOnSameHost) { - txtAgentHost.setText(((Text) e.widget).getText()); - } checkRasOnSameHost(); } }); - GridData gdtxtRasHost = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); - gdtxtRasHost.widthHint = 200; - txtRasHost.setLayoutData(gdtxtRasHost); - - txtRasPort = new Text(grpRemoteRasParameters, SWT.BORDER); - GridData gdtxtRasPort = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1); - gdtxtRasPort.widthHint = 50; - txtRasPort.setLayoutData(gdtxtRasPort); - - Group grpLocalRasParameters = new Group(connectContainer, SWT.NONE); - grpLocalRasParameters.setSize(417, 90); - grpLocalRasParameters.setText(Strings.LOCAL_RAS_PARAMETERS); - grpLocalRasParameters.setLayout(new GridLayout(2, false)); - - Label lblV8Version = new Label(grpLocalRasParameters, SWT.NONE); - lblV8Version.setSize(124, 15); - lblV8Version.setText(Strings.V8_VERSION); - - Label lblLocalRasPort = new Label(grpLocalRasParameters, SWT.NONE); - lblLocalRasPort.setSize(77, 15); - lblLocalRasPort.setText(Strings.PORT); - comboV8Version = new Combo(grpLocalRasParameters, SWT.READ_ONLY); - GridData gdcomboV8Version = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); - gdcomboV8Version.widthHint = 140; - comboV8Version.setLayoutData(gdcomboV8Version); - comboV8Version.setSize(389, 21); + txtRasPort = new Text(grpConnectParameters, SWT.BORDER); + GridData gdTxtRasPort = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); + gdTxtRasPort.widthHint = 50; + txtRasPort.setLayoutData(gdTxtRasPort); - txtLocalRasPort = new Text(grpLocalRasParameters, SWT.BORDER); - GridData gdtxtLocalRasPort = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1); - gdtxtLocalRasPort.widthHint = 50; - txtLocalRasPort.setLayoutData(gdtxtLocalRasPort); - - Group grpRagentParameters = new Group(connectContainer, SWT.NONE); - grpRagentParameters.setText(Strings.AGENT_PARAMETERS); - grpRagentParameters.setLayout(new GridLayout(2, false)); - - Label lblAgentHost = new Label(grpRagentParameters, SWT.NONE); - lblAgentHost.setText(Strings.HOST); - - Label lblAgentPort = new Label(grpRagentParameters, SWT.NONE); - lblAgentPort.setText(Strings.PORT); + radioUseLocalRas = new Button(grpConnectParameters, SWT.RADIO); + radioUseLocalRas.setBounds(0, 0, 90, 16); + radioUseLocalRas.setText(Strings.USE_LOCAL_RAS); + new Label(grpConnectParameters, SWT.NONE); - txtAgentHost = new Text(grpRagentParameters, SWT.BORDER); - txtAgentHost.addModifyListener( - new ModifyListener() { - @Override - public void modifyText(ModifyEvent e) { - checkRasOnSameHost(); - } - }); - GridData gdtxtAgentHost = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); - gdtxtAgentHost.widthHint = 200; - txtAgentHost.setLayoutData(gdtxtAgentHost); - - txtAgentPort = new Text(grpRagentParameters, SWT.BORDER); - GridData gdtxtAgentPort = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1); - gdtxtAgentPort.widthHint = 50; - txtAgentPort.setLayoutData(gdtxtAgentPort); - new Label(connectContainer, SWT.NONE); + txtLocalRasPort = new Text(grpConnectParameters, SWT.BORDER); + GridData gdTxtLocalRasPort = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); + gdTxtLocalRasPort.widthHint = 50; + txtLocalRasPort.setLayoutData(gdTxtLocalRasPort); TabItem tabCredentials = new TabItem(tabFolder, SWT.NONE); tabCredentials.setText(Strings.CREDENTIALS); @@ -357,22 +340,20 @@ private void initProperties() { if (server != null) { txtDescription.setText(server.getDescription()); - txtRasHost.setText(server.getRasHost()); - txtRasPort.setText(server.getRasPortAsString()); - + comboV8Version.setItems(getInstalledV8Versions()); + comboV8Version.setText(server.getV8Version()); txtAgentHost.setText(server.getAgentHost()); txtAgentPort.setText(server.getAgentPortAsString()); + btnAutoconnect.setSelection(server.getAutoconnect()); + radioUseRemoteRas.setSelection(!server.getUseLocalRas()); radioUseLocalRas.setSelection(server.getUseLocalRas()); - comboV8Version.setItems(getInstalledV8Versions()); - comboV8Version.setText(server.getLocalRasV8version()); - + txtRasHost.setText(server.getRasHost()); + txtRasPort.setText(server.getRasPortAsString()); txtLocalRasPort.setText(server.getLocalRasPortAsString()); - btnAutoconnect.setSelection(server.getAutoconnect()); - saveCredentialsVariant = server.getSaveCredentialsVariant(); btnSaveCredentialsDisable.setSelection( saveCredentialsVariant.equals(SaveCredentialsVariant.DISABLE)); @@ -455,7 +436,6 @@ private void checkRasOnSameHost() { private void setEnabledRasGroupParameters() { txtRasHost.setEnabled(radioUseRemoteRas.getSelection()); txtRasPort.setEnabled(radioUseRemoteRas.getSelection()); - comboV8Version.setEnabled(!radioUseRemoteRas.getSelection()); txtLocalRasPort.setEnabled(!radioUseRemoteRas.getSelection()); } @@ -463,16 +443,17 @@ private boolean saveNewServerProperties() { try { server.setDescription(txtDescription.getText()); + server.setV8Version(comboV8Version.getText()); server.setAgentHost(txtAgentHost.getText()); server.setAgentPort(Integer.parseInt(txtAgentPort.getText())); + + server.setAutoconnect(btnAutoconnect.getSelection()); + + server.setUseLocalRas(!radioUseRemoteRas.getSelection()); server.setRasHost(txtRasHost.getText()); server.setRasPort(Integer.parseInt(txtRasPort.getText())); - server.setUseLocalRas(!radioUseRemoteRas.getSelection()); server.setLocalRasPort(Integer.parseInt(txtLocalRasPort.getText())); - server.setLocalRasV8version(comboV8Version.getText()); - server.setAutoconnect(btnAutoconnect.getSelection()); - extractSaveCredentialsVariant(); server.setSaveCredentialsVariant(saveCredentialsVariant); @@ -618,14 +599,13 @@ private static class Strings { static final String TITLE_WINDOW = getString("TitleDialog"); static final String CONNECT_PARAMETERS = getString("ConnectParameters"); + static final String CONNECTION_VARIANT = getString("ConnectionVariant"); static final String SERVER_DESCRIPTION = getString("Description"); static final String AUTOCONNECT_AT_STARTUP = getString("AutoconnectAtStartup"); static final String USE_REMOTE_RAS = getString("UseRemoteRAS"); static final String USE_LOCAL_RAS = getString("UseLocalRAS"); - static final String REMOTE_RAS_PARAMETERS = getString("RemoteRASParameters"); static final String HOST = getString("Host"); static final String PORT = getString("Port"); - static final String LOCAL_RAS_PARAMETERS = getString("LocalRASParameters"); static final String V8_VERSION = getString("V8Version"); static final String AGENT_PARAMETERS = getString("AgentParameters"); static final String CREDENTIALS = getString("Credentials"); diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties index ca33705..afa3cee 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties @@ -81,6 +81,7 @@ ServerDialog.CentralServerAdminstrator = Central server adminstrator ServerDialog.ClusterName = Cluster name ServerDialog.ClustersCredentialsGroup = Clusters credentials ServerDialog.ConnectParameters = Connect parameters +ServerDialog.ConnectionVariant = Connection variant ServerDialog.Credentials = Credentials ServerDialog.Description = Description ServerDialog.Host = Host diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties index 9d95ea4..a355e96 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties @@ -81,6 +81,7 @@ ServerDialog.CentralServerAdminstrator = \u0410\u0434\u043C\u0438\u043D\u0438\ ServerDialog.ClusterName = \u0418\u043C\u044F \u043A\u043B\u0430\u0441\u0442\u0435\u0440\u0430 ServerDialog.ClustersCredentialsGroup = \u0414\u0430\u043D\u043D\u044B\u0435 \u0434\u043E\u0441\u0442\u0443\u043F\u0430 \u043A \u043A\u043B\u0430\u0441\u0442\u0435\u0440\u0430\u043C ServerDialog.ConnectParameters = \u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u044B \u043F\u043E\u0434\u043A\u043B\u044E\u0447\u0435\u043D\u0438\u044F +ServerDialog.ConnectionVariant = \u0421\u043F\u043E\u0441\u043E\u0431 \u043F\u043E\u0434\u043A\u043B\u044E\u0447\u0435\u043D\u0438\u044F ServerDialog.Credentials = \u0414\u0430\u043D\u043D\u044B\u0435 \u0434\u043E\u0441\u0442\u0443\u043F\u0430 ServerDialog.Description = \u041E\u043F\u0438\u0441\u0430\u043D\u0438\u0435 ServerDialog.Host = \u0425\u043E\u0441\u0442 From 495cc8348a5395e242a9bc0dc738e8e28025d3fe Mon Sep 17 00:00:00 2001 From: YanSergey Date: Tue, 3 Jan 2023 14:53:47 +0300 Subject: [PATCH 10/70] =?UTF-8?q?=D0=9F=D1=80=D0=BE=D0=B1=D1=80=D0=BE?= =?UTF-8?q?=D1=81=20=D0=B2=D0=B5=D1=80=D1=81=D0=B8=D0=B8=20=D1=81=D0=B5?= =?UTF-8?q?=D1=80=D0=B2=D0=B5=D1=80=D0=B0=20=D0=B2=20=D1=81=D0=BA=D1=80?= =?UTF-8?q?=D0=B8=D0=BF=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ru/yanygin/clusterAdminLibraryUI/ViewerArea.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java index 3ea6d8f..a6452e5 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java @@ -3094,19 +3094,23 @@ public Map fillParams(File script, TreeItem infobaseItem) { switch (foundParam) { case "%infobase%": - paramValue = server.getInfoBaseName(clusterId, infobaseId); // $NON-NLS-1$ + paramValue = server.getInfoBaseName(clusterId, infobaseId); break; case "%serverName%": - paramValue = server.getAgentHost(); // $NON-NLS-1$ + paramValue = server.getAgentHost(); break; case "%agentPort%": - paramValue = server.getAgentPortAsString(); // $NON-NLS-1$ + paramValue = server.getAgentPortAsString(); break; case "%managerPort%": - paramValue = server.getClusterMainPort(clusterId); // $NON-NLS-1$ + paramValue = server.getClusterMainPort(clusterId); + break; + + case "%v8version%": + paramValue = server.getV8Version(); break; default: From d0e70978e47e7c35053b38a83db88342ecdc8ac9 Mon Sep 17 00:00:00 2001 From: "Yanygin.SA" Date: Sat, 22 Jul 2023 15:34:44 +0300 Subject: [PATCH 11/70] =?UTF-8?q?=D0=A3=D1=81=D1=82=D0=B0=D0=BD=D0=BE?= =?UTF-8?q?=D0=B2=D0=BA=D0=B0=20=D0=BF=D1=83=D1=81=D1=82=D1=8B=D1=85=20?= =?UTF-8?q?=D0=BF=D0=B0=D1=80=D0=B0=D0=BC=D0=B5=D1=82=D1=80=D0=BE=D0=B2=20?= =?UTF-8?q?=D0=B8=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BD-=D0=BF=D0=B0=D1=80?= =?UTF-8?q?=D0=BE=D0=BB=D1=8F=20=D0=B2=20=D1=81=D0=BA=D1=80=D0=B8=D0=BF?= =?UTF-8?q?=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- clusterAdminApplication/scripts/echo_fast.bat | 3 + .../BackgroundTaskParams.java | 286 ++++++++++++++++++ .../clusterAdminLibraryUI/ViewerArea.java | 54 +++- .../clusterAdminLibraryUI/messages.properties | 4 + .../messages_ru_RU.properties | 4 + 5 files changed, 336 insertions(+), 15 deletions(-) create mode 100644 clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/BackgroundTaskParams.java diff --git a/clusterAdminApplication/scripts/echo_fast.bat b/clusterAdminApplication/scripts/echo_fast.bat index 25e09c4..31d3d4b 100644 --- a/clusterAdminApplication/scripts/echo_fast.bat +++ b/clusterAdminApplication/scripts/echo_fast.bat @@ -3,5 +3,8 @@ @echo off chcp 65001 echo server: %serverName%:%managerPort% +echo password: %password% echo infobase: %infobase% +echo username: %username% +echo infobase1: %infobase1% echo end diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/BackgroundTaskParams.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/BackgroundTaskParams.java new file mode 100644 index 0000000..bf7742e --- /dev/null +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/BackgroundTaskParams.java @@ -0,0 +1,286 @@ +package ru.yanygin.clusterAdminLibraryUI; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.viewers.CellEditor; +import org.eclipse.jface.viewers.ColumnLabelProvider; +import org.eclipse.jface.viewers.ComboBoxCellEditor; +import org.eclipse.jface.viewers.EditingSupport; +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.TableViewerColumn; +import org.eclipse.jface.viewers.TextCellEditor; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.CCombo; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import ru.yanygin.clusterAdminLibrary.UserPassPair; + +/** Диалог параметров фоновой задачи. */ +public class BackgroundTaskParams extends Dialog { + + private Map params; + private String title; + private Table tableParams; + private Map infobasesCredentials = new HashMap<>(); + private List usernames = new ArrayList<>(); + private String currentUsernameValue = ""; + + /** + * Создание диалога ввода имени пользователя и пароля. + * + * @param parentShell - parent shell + * @param params - текущие имя пользователя и пароль + * @param title - заголовок окна аутентификации + * @param infobasesCredentials - данные доступа к инфобазам + */ + public BackgroundTaskParams( + Shell parentShell, + Map params, + String title, + List infobasesCredentials) { + super(parentShell); + setShellStyle(SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); + + this.params = params; + this.title = title; + + infobasesCredentials.forEach( + up -> { + this.infobasesCredentials.put(up.getUsername(), up.getPassword()); + this.usernames.add(up.getUsername()); + }); + } + + @Override + protected void configureShell(Shell newShell) { + super.configureShell(newShell); + newShell.setText(Strings.TITLE_WINDOW + this.title); + } + + /** + * Create contents of the dialog. + * + * @param parent - parent composite + */ + @Override + protected Control createDialogArea(Composite parent) { + + Composite container = (Composite) super.createDialogArea(parent); + + TableViewer tableViewer = new TableViewer(container, SWT.BORDER | SWT.FULL_SELECTION); + tableParams = tableViewer.getTable(); + tableParams.setLinesVisible(true); + tableParams.setHeaderVisible(true); + tableParams.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); + + tableViewer.setContentProvider(new ParamsContentProvider()); + + TableViewerColumn tableViewerColumnParamKey = new TableViewerColumn(tableViewer, SWT.NONE); + TableColumn clmnParamKey = tableViewerColumnParamKey.getColumn(); + clmnParamKey.setMoveable(true); + clmnParamKey.setWidth(120); + clmnParamKey.setText(Strings.TITLE_PARAMNAME); + // tableViewerColumnParamKey.setEditingSupport(new TableViewerEditingSupport(tableViewer)); + tableViewerColumnParamKey.setLabelProvider( + new ColumnLabelProvider() { + @Override + public String getText(Object element) { + String[] p = (String[]) element; + return p[0]; + } + }); + + TableViewerColumn tableViewerColumnParamValue = new TableViewerColumn(tableViewer, SWT.NONE); + TableColumn clmnParamValue = tableViewerColumnParamValue.getColumn(); + clmnParamValue.setMoveable(true); + clmnParamValue.setWidth(280); + clmnParamValue.setText(Strings.TITLE_PARAMVALUE); + tableViewerColumnParamValue.setEditingSupport(new TableViewerEditingSupport(tableViewer)); + tableViewerColumnParamValue.setLabelProvider( + new ColumnLabelProvider() { + @Override + public String getText(Object element) { + String[] p = (String[]) element; + return p[1]; + } + }); + tableViewer.setInput(params); + + return container; + } + + /** + * Возвращает заполненные пользователем параметры запуска задачи. + * + * @return параметры запуска задачи + */ + public Map getParams() { + return params; + } + + /** + * Create contents of the button bar. + * + * @param parent - parent composite + */ + @Override + protected void createButtonsForButtonBar(Composite parent) { + Button button = + createButton(parent, IDialogConstants.FINISH_ID, IDialogConstants.OK_LABEL, true); + button.addSelectionListener( + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + close(); + } + }); + + createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); + } + + protected boolean isUsernameParam(String e) { + return e.equals("username"); + } + + protected boolean isPasswordParam(String e) { + return e.equals("password"); + } + + class TableViewerEditingSupport extends EditingSupport { + + private TableViewer viewer; + private TextCellEditor textEditor; + private ComboBoxCellEditor usernameEditor; + + public TableViewerEditingSupport(TableViewer viewer) { + super(viewer); + textEditor = new TextCellEditor(viewer.getTable(), SWT.BORDER); + + usernameEditor = + new ComboBoxCellEditor( + viewer.getTable(), usernames.toArray(new String[0]), SWT.SINGLE | SWT.BORDER); + + this.viewer = viewer; + } + + @Override + protected boolean canEdit(Object element) { + String paramKey = ((String[]) element)[0]; + if (isPasswordParam(paramKey)) { + return !currentUsernameValue.isBlank(); + } + return true; + } + + @Override + protected CellEditor getCellEditor(Object element) { + String[] e = (String[]) element; + + if (isUsernameParam(e[0])) { + return usernameEditor; + } else { + return textEditor; + } + } + + @Override + protected Object getValue(Object element) { + String[] e = (String[]) element; + + if (isUsernameParam(e[0])) { + return usernames.indexOf(e[1]); + } else { + return e[1]; + } + } + + @Override + protected void setValue(Object element, Object value) { + String paramKey = ((String[]) element)[0]; + String newParamValue = ""; + Integer valueIndex = null; + + // текстовое поле + if (value instanceof String) { + newParamValue = (String) value; + } + + // поле с выпадающим списком + if (value instanceof Integer) { + valueIndex = (Integer) value; + + if (isUsernameParam(paramKey) && valueIndex >= 0) { + // выбор логина из списка + newParamValue = usernames.get(valueIndex); + currentUsernameValue = newParamValue; + // установка пароля + params.put("password", infobasesCredentials.getOrDefault(newParamValue, "")); + + } else if (isUsernameParam(paramKey) && valueIndex == -1) { + // ввод нового логина вручную + newParamValue = ((CCombo) usernameEditor.getControl()).getText(); + currentUsernameValue = newParamValue; + if (!newParamValue.isBlank()) { + usernames.add(newParamValue); + usernameEditor.setItems(usernames.toArray(new String[0])); + } + } + } + + params.put(paramKey, newParamValue); + viewer.refresh(true); + } + } + + class ParamsContentProvider implements IStructuredContentProvider { + + /** + * Returns the elements in the input, which must be either an array or a Collection + * . + */ + @Override + public Object[] getElements(Object inputElement) { + if (inputElement instanceof Map) { + + + List collection = new ArrayList<>(); + ((Map) inputElement) + .forEach( + (k, v) -> { + if (isPasswordParam(k)) { + // После редактирования пароль прячем за звездочками + collection.add(new String[] {k, v.isBlank() ? "" : "***"}); + } else { + collection.add(new String[] {k, v}); + } + }); + + return collection.toArray(); + } + return new Object[0]; + } + } + + private static class Strings { + + static final String TITLE_WINDOW = getString("Title"); + static final String TITLE_PARAMNAME = getString("ParamName"); + static final String TITLE_PARAMVALUE = getString("ParamValue"); + + static String getString(String key) { + return Messages.getString("BackgroundTaskParams." + key); + } + } +} diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java index a6452e5..8e03274 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java @@ -12,6 +12,7 @@ import java.util.Arrays; import java.util.EnumMap; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Objects; @@ -3011,7 +3012,7 @@ public void fillUserScriptsItems(Menu subMenuUserScripts) { } private List readUserScripts() { - if (config.isWindows()) { + if (!config.isWindows()) { return new ArrayList<>(); } @@ -3051,17 +3052,13 @@ public void widgetSelected(SelectionEvent event) { TreeItem infobaseItem = items[0]; Map params = fillParams(script, infobaseItem); - if (params.isEmpty()) { - Helper.showMessageBox("Params is empty"); - return; + if (!params.isEmpty()) { + addToTasksQueue(new BackgroundTask(script, params)); } - - BackgroundTask task = new BackgroundTask(script, params); - addToTasksQueue(task); } public Map fillParams(File script, TreeItem infobaseItem) { - Map params = new HashMap<>(); + Map params = new LinkedHashMap<>(); UUID clusterId = getClusterId(infobaseItem); UUID infobaseId = getInfobaseId(infobaseItem); @@ -3084,6 +3081,10 @@ public Map fillParams(File script, TreeItem infobaseItem) { return params; } + boolean foundEmptyParams = false; + boolean foundUsernameParam = false; + boolean foundPasswordParam = false; + Pattern p = Pattern.compile("\\%.+?\\%"); // Pattern p = Pattern.compile("[^\\%]++", Pattern.CASE_INSENSITIVE); @@ -3113,21 +3114,44 @@ public Map fillParams(File script, TreeItem infobaseItem) { paramValue = server.getV8Version(); break; + case "%username%": + foundUsernameParam = true; + foundEmptyParams = true; + continue; + + case "%password%": + foundPasswordParam = true; + foundEmptyParams = true; + continue; + default: - LOGGER.error( - "Found unknown param {}", //$NON-NLS-1$ - foundParam); - paramValue = ""; // $NON-NLS-1$ + LOGGER.info("Found unknown param {}", foundParam); + paramValue = ""; + foundEmptyParams = true; break; } String paramKey = foundParam.replace("%", ""); params.put(paramKey, paramValue); } + if (Boolean.TRUE.equals(foundUsernameParam)) { + params.put("username", ""); + } + if (Boolean.TRUE.equals(foundPasswordParam)) { + params.put("password", ""); + } - // params.put("infobase", "dev1"); // $NON-NLS-1$ - // params.put("serverName", "server123"); // $NON-NLS-1$ - // params.put("managerPort", "4541"); // $NON-NLS-1$ + if (foundEmptyParams) { + BackgroundTaskParams taskParamsDialog = + new BackgroundTaskParams( + getShell(), params, script.getName(), server.getInfobasesCredentials()); + int dialogResult = taskParamsDialog.open(); + if (dialogResult != 0) { + return new HashMap<>(); + } + + params = taskParamsDialog.getParams(); + } return params; } diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties index afa3cee..a1703d3 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties @@ -14,6 +14,10 @@ AboutDialog.MainTitle = OneS Cluster Admin AboutDialog.Telegram_Description = Telegram:\r\n%s AboutDialog.TitleDialog = About +BackgroundTaskParams.ParamName = Param name +BackgroundTaskParams.ParamValue = Value +BackgroundTaskParams.Title = Set params for task: + ClusterDialog.AcceptableDeviationOfTheNumberOfServerErrors = Acceptable deviation of the\r\nnumber of server errors (%) ClusterDialog.ClusterName = Cluster name ClusterDialog.ClusterRecyclingKillByMemoryWithDump = Cluster recycling kill by memory with dump diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties index a355e96..27dcab1 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties @@ -14,6 +14,10 @@ AboutDialog.MainTitle = OneS Cluster Admin AboutDialog.Telegram_Description = Telegram:\r\n%s AboutDialog.TitleDialog = \u041E \u043F\u0440\u043E\u0433\u0440\u0430\u043C\u043C\u0435 +BackgroundTaskParams.ParamName = \u0418\u043C\u044F \u043F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u0430 +BackgroundTaskParams.ParamValue = \u0417\u043D\u0430\u0447\u0435\u043D\u0438\u0435 +BackgroundTaskParams.Title = \u0423\u0441\u0442\u0430\u043D\u043E\u0432\u043A\u0430 \u043F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u043E\u0432 \u0434\u043B\u044F \u0437\u0430\u0434\u0430\u0447\u0438: + ClusterDialog.AcceptableDeviationOfTheNumberOfServerErrors = \u0414\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u043E\u0435 \u043E\u0442\u043A\u043B\u043E\u043D\u0435\u043D\u0438\u0435 \u043A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u0430\r\n\u043E\u0448\u0438\u0431\u043E\u043A \u0441\u0435\u0440\u0432\u0435\u0440\u0430 (%) ClusterDialog.ClusterName = \u0418\u043C\u044F \u043A\u043B\u0430\u0441\u0442\u0435\u0440\u0430 ClusterDialog.ClusterRecyclingKillByMemoryWithDump = \u0417\u0430\u043F\u0438\u0441\u044B\u0432\u0430\u0442\u044C \u0434\u0430\u043C\u043F \u043F\u0440\u043E\u0446\u0435\u0441\u0441\u0430 \u043F\u0440\u0438 \u043F\u0440\u0435\u0432\u044B\u0448\u0435\u043D\u0438\u0438 \u043A\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043A\u043E\u0433\u043E \u043E\u0431\u044A\u0435\u043C\u0430 \u043F\u0430\u043C\u044F\u0442\u0438 From 0a1661fb3cfa75440bc401be84476086f6c9005f Mon Sep 17 00:00:00 2001 From: "Yanygin.SA" Date: Sat, 22 Jul 2023 21:29:08 +0300 Subject: [PATCH 12/70] =?UTF-8?q?=D0=94=D0=BE=D1=80=D0=B0=D0=B1=D0=BE?= =?UTF-8?q?=D1=82=D0=B0=D0=BD=20=D0=BF=D0=BE=D0=B8=D1=81=D0=BA=20=D1=83?= =?UTF-8?q?=D1=81=D1=82=D0=B0=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD=D0=BD?= =?UTF-8?q?=D1=8B=D1=85=20=D0=B2=D0=B5=D1=80=D1=81=D0=B8=D0=B9=20V8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yanygin/clusterAdminLibrary/Helper.java | 119 +++++++++++++----- .../yanygin/clusterAdminLibrary/Server.java | 2 +- .../clusterAdminLibraryUI/ServerDialog.java | 15 ++- 3 files changed, 98 insertions(+), 38 deletions(-) diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java index b062ac2..454eb5c 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java @@ -2,6 +2,8 @@ import java.io.File; import java.io.FilenameFilter; +import java.nio.file.Path; +import java.nio.file.Paths; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; @@ -70,10 +72,10 @@ public static int showQuestionBox(String question) { /** * Возвращает список установленных версий платформы V8. * - * @param config - конфиг программы + * @param bitness - разрядность платформы * @return список установленных версий платформы V8 */ - public static Map getInstalledV8Versions() { + public static Map getInstalledV8Versions(String bitness) { LOGGER.debug("Get installed v8 platform versions"); //$NON-NLS-1$ Map versions = new HashMap<>(); @@ -82,52 +84,111 @@ public static Map getInstalledV8Versions() { return versions; } - File v8x64CommonPath = new File("C:\\Program Files\\1cv8"); //$NON-NLS-1$ - File v8x86CommonPath = new File("C:\\Program Files (x86)\\1cv8"); //$NON-NLS-1$ + final String filterWindows = "8.3.\\d\\d.\\d{4}"; // $NON-NLS-1$ + final String filterLinux = "v8.3.\\d\\d.\\d{4}"; // $NON-NLS-1$ + String filterCurrentOs; - FilenameFilter filter = + Path v8runtimeDir; + // Path v8runtimeDirX64; + // Path v8runtimeDirX86; + + if (Config.currentConfig.isWindows()) { + filterCurrentOs = filterWindows; + // для 64-разрядной + // v8runtimeDirX64 = Paths.get(System.getenv("ProgramW6432"), "1cv8"); + // v8runtimeDirX86 = Paths.get(System.getenv("ProgramFiles(x86)"), "1cv8"); + // для 32-разрядной + // v8runtimeDirX86 = Paths.get(System.getenv("ProgramFiles"), "1cv8"); + + v8runtimeDir = + bitness.equals("x64") + ? Paths.get(System.getenv("ProgramW6432"), "1cv8") + : Paths.get(System.getenv("ProgramFiles(x86)"), "1cv8"); + + } else if (Config.currentConfig.isLinux()) { + // filterCurrentOs = filterLinux; + // v8runtimeDirX64 = Paths.get("/opt", "1C", "v8.3", "x86_64"); + // v8runtimeDirX86 = Paths.get("/opt", "1C", "v8.3", "i386"); + // v8runtimeDirX64 = Paths.get("/opt", "1cv8", "x86_64"); + // v8runtimeDirX86 = Paths.get("/opt", "1cv8", "i386"); + + // v8runtimeDir = Paths.get("/opt", "1C"); + return versions; + + } else if (Config.currentConfig.isMacOs()) { + // v8runtimeDir = Paths.get("/opt", "1cv8"); + return versions; + } else { + return versions; + } + LOGGER.debug("Current v8 runtime directory <{}>", v8runtimeDir); // $NON-NLS-1$ + + // File v8x64CommonPath = new File("C:\\Program Files\\1cv8"); // $NON-NLS-1$ + // File v8x86CommonPath = new File("C:\\Program Files (x86)\\1cv8"); // $NON-NLS-1$ + + FilenameFilter filterVersion = new FilenameFilter() { @Override public boolean accept(File f, String name) { - return name.matches("8.3.\\d\\d.\\d{4}"); //$NON-NLS-1$ + return Paths.get(f.getAbsolutePath(), name).toFile().isDirectory() + && name.matches(filterCurrentOs); } }; - try { - if (v8x64CommonPath.exists()) { - File[] v8x64dirs = v8x64CommonPath.listFiles(filter); - for (File dir : v8x64dirs) { - if (dir.isDirectory()) { - File ras = new File(dir.getAbsolutePath().concat("\\bin\\ras.exe")); //$NON-NLS-1$ - if (ras.exists() && ras.isFile()) { - versions.put(dir.getName().concat(" (x86_64)"), ras.getAbsolutePath()); //$NON-NLS-1$ - } + FilenameFilter filterBitnessLinux = + new FilenameFilter() { + @Override + public boolean accept(File f, String name) { + String bitnessPart = bitness.equals("x64") ? "x86_64" : "i386"; + return Paths.get(f.getAbsolutePath(), name).toFile().isDirectory() + && Paths.get(f.getAbsolutePath(), name, bitnessPart).toFile().exists(); } - } - } - } catch (Exception excp) { - LOGGER.error("Error read dir <{}>", v8x64CommonPath.getAbsolutePath(), excp); //$NON-NLS-1$ - } + }; try { - if (v8x86CommonPath.exists()) { - File[] v8x86dirs = v8x86CommonPath.listFiles(filter); - for (File dir : v8x86dirs) { - if (dir.isDirectory()) { - File ras = new File(dir.getAbsolutePath().concat("\\bin\\ras.exe")); //$NON-NLS-1$ - if (ras.exists() && ras.isFile()) { - versions.put(dir.getName(), ras.getAbsolutePath()); //$NON-NLS-1$ - } + if (v8runtimeDir.toFile().exists()) { + File[] versionDirs = v8runtimeDir.toFile().listFiles(filterVersion); + for (File dir : versionDirs) { + LOGGER.debug("Version dir <{}>", dir); // $NON-NLS-1$ + + if (Config.currentConfig.isWindows()) { + versions.put(dir.getName(), dir.getAbsolutePath()); + } else if (dir.list(filterBitnessLinux).length > 0) { + versions.put(dir.getName(), dir.getAbsolutePath()); } } } } catch (Exception excp) { - LOGGER.error("Error read dir <{}>", v8x64CommonPath.getAbsolutePath(), excp); //$NON-NLS-1$ + LOGGER.error( + "Error read dir <{}>", v8runtimeDir.toFile().getAbsolutePath(), excp); // $NON-NLS-1$ } return versions; } + /** + * Возвращает путь к исполняемому файлу RAS. + * + * @param version - версия платформы + * @param bitness - разрядность версии + * @return путь к исполняемому файлу RAS + */ + public static String pathToRas(String version, String bitness) { + + String pathToVersion = getInstalledV8Versions(bitness).get(version); + String osPart; + + if (Config.currentConfig.isWindows()) { + osPart = "bin"; + } else if (Config.currentConfig.isLinux()) { + osPart = bitness.equals("x64") ? "x86_64" : "i386"; + } else { + return null; + } + + return Paths.get(pathToVersion, osPart, "ras").toFile().getAbsolutePath(); + } + /** * Получает белый цвет. * diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java index acf0263..1b2de36 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java @@ -923,7 +923,7 @@ private boolean checkAndRunLocalRas() { ///////////////////////////// пока только Windows var processBuilder = new ProcessBuilder(); var processOutput = ""; //$NON-NLS-1$ - var localRasPath = Helper.getInstalledV8Versions().get(v8version); + var localRasPath = Helper.pathToRas(v8version, "x64"); if (localRasPath == null) { var message = String.format( diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ServerDialog.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ServerDialog.java index 5839f5d..7d96602 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ServerDialog.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ServerDialog.java @@ -121,6 +121,12 @@ protected Control createDialogArea(Composite parent) { GridLayout glConnectContainer = new GridLayout(2, false); connectContainer.setLayout(glConnectContainer); + btnAutoconnect = new Button(connectContainer, SWT.CHECK); + GridData gdbtnAutoconnect = new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1); + gdbtnAutoconnect.horizontalIndent = 5; + btnAutoconnect.setLayoutData(gdbtnAutoconnect); + btnAutoconnect.setText(Strings.AUTOCONNECT_AT_STARTUP); + Group grpDescription = new Group(connectContainer, SWT.NONE); grpDescription.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1)); grpDescription.setText(Strings.SERVER_DESCRIPTION); @@ -167,13 +173,6 @@ public void modifyText(ModifyEvent e) { gdtxtAgentPort.widthHint = 50; txtAgentPort.setLayoutData(gdtxtAgentPort); - btnAutoconnect = new Button(connectContainer, SWT.CHECK); - GridData gdbtnAutoconnect = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); - gdbtnAutoconnect.horizontalIndent = 5; - btnAutoconnect.setLayoutData(gdbtnAutoconnect); - btnAutoconnect.setText(Strings.AUTOCONNECT_AT_STARTUP); - new Label(connectContainer, SWT.NONE); - Group grpConnectParameters = new Group(connectContainer, SWT.NONE); grpConnectParameters.setLayout(new GridLayout(3, false)); grpConnectParameters.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1)); @@ -411,7 +410,7 @@ private String morphToLink(String text) { private String[] getInstalledV8Versions() { List installedV8Versions = new ArrayList<>(); - Helper.getInstalledV8Versions().forEach((desc, path) -> installedV8Versions.add(desc)); + Helper.getInstalledV8Versions("x64").forEach((desc, path) -> installedV8Versions.add(desc)); installedV8Versions.sort(String.CASE_INSENSITIVE_ORDER); return installedV8Versions.toArray(new String[0]); } From 5d0f9279ece672bd5fc81239238a82e3573e05d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Sun, 30 Jul 2023 08:45:59 +0300 Subject: [PATCH 13/70] maven activeProfiles --- clusterAdminLibrary/.settings/org.eclipse.m2e.core.prefs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clusterAdminLibrary/.settings/org.eclipse.m2e.core.prefs b/clusterAdminLibrary/.settings/org.eclipse.m2e.core.prefs index f897a7f..32680bc 100644 --- a/clusterAdminLibrary/.settings/org.eclipse.m2e.core.prefs +++ b/clusterAdminLibrary/.settings/org.eclipse.m2e.core.prefs @@ -1,4 +1,4 @@ -activeProfiles= +activeProfiles=windows-x86_64 eclipse.preferences.version=1 resolveWorkspaceProjects=true version=1 From 233b54b7aed61c0747e0183b7de883157387dcb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Sun, 30 Jul 2023 08:46:24 +0300 Subject: [PATCH 14/70] =?UTF-8?q?=D0=97=D0=B0=D0=BF=D1=83=D1=81=D0=BA=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=BD=D1=84=D0=B8=D0=B3=D1=83=D1=80=D0=B0=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../clusterAdminLibrary/BackgroundTask.java | 69 +++- .../BackgroundTaskParams.java | 30 +- .../clusterAdminLibraryUI/ViewerArea.java | 362 ++++++++++++------ .../clusterAdminLibraryUI/messages.properties | 2 +- .../messages_ru_RU.properties | 2 +- 5 files changed, 322 insertions(+), 143 deletions(-) diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java index 5dd97b7..e4025ce 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java @@ -29,23 +29,34 @@ public class BackgroundTask { static Image taskCompleted = Helper.getImage("taskCompleted.png"); //$NON-NLS-1$ static Image taskError = Helper.getImage("taskError.png"); //$NON-NLS-1$ - String taskName; File script; + String scriptText; + + String scriptName; + + String taskName; Map params; Process scriptProcess; - String processOutput = ""; // $NON-NLS-1$ + String processOutput = ""; //$NON-NLS-1$ int exitCode; TaskState state; TaskState stateLast; + TaskVariant taskVariant; + enum TaskState { RUNNUNG, DONE, ERROR } + enum TaskVariant { + USER_SCRIPT, + V8ACTION + } + Thread thread; Date startDate; @@ -58,15 +69,31 @@ enum TaskState { * @param params - Переменные окружения */ public BackgroundTask(File script, Map params) { - + this.taskVariant = TaskVariant.USER_SCRIPT; + this.script = script; + this.scriptName = script.getName(); this.params = params; this.taskName = generateTaskName(); + } + /** + * Инициализация задачи. + * + * @param scriptText - строка с командой для выполнения действия + * @param scriptName - имя команды + * @param params - Переменные окружения + */ + public BackgroundTask(String scriptText, String scriptName, Map params) { + this.taskVariant = TaskVariant.V8ACTION; + + this.scriptText = scriptText; + this.scriptName = scriptName; + this.params = params; + this.taskName = generateTaskName(); } private String generateTaskName() { - String scriptName = script.getName(); int taskNumber = taskNamesCounter.getOrDefault(scriptName, 0); taskNumber++; @@ -129,12 +156,12 @@ public static void setTabTitle(TabItem tab) { "Tasks (Run: %d, Completed: %d, Error: %d)", countOfRunning, countOfCompleted, countWithError); - // countWithError == 0 - // ? String.format("Tasks (Run: %d, Completed: %d)", countOfRunning, + // countWithError == 0 + // ? String.format("Tasks (Run: %d, Completed: %d)", countOfRunning, // countOfCompleted) - // : String.format( - // "Tasks (Run: %d, Completed: %d, Error: %d)", - // countOfRunning, countOfCompleted, countWithError); + // : String.format( + // "Tasks (Run: %d, Completed: %d, Error: %d)", + // countOfRunning, countOfCompleted, countWithError); tab.setText(title); tab.setImage(countOfRunning == 0 ? taskCompleted : taskRunning); @@ -170,10 +197,10 @@ public String[] getDescription() { break; } - // String paramsAsString = - // params.keySet().stream() - // .map(key -> key + " = " + params.get(key)) - // .collect(Collectors.joining("\n")); + // String paramsAsString = + // params.keySet().stream() + // .map(key -> key + " = " + params.get(key)) + // .collect(Collectors.joining("\n")); return new String[] { taskName, @@ -270,10 +297,13 @@ public void run() { // ).inheritIO(); // processBuilder.command(script.getAbsolutePath()); + String currentCommand = + taskVariant == TaskVariant.USER_SCRIPT ? script.getAbsolutePath() : scriptText; + processBuilder.command( "cmd.exe", //$NON-NLS-1$ "/c", //$NON-NLS-1$ - script.getAbsolutePath()); + currentCommand); // script.getAbsolutePath()); Map env = processBuilder.environment(); params.forEach(env::put); @@ -281,15 +311,15 @@ public void run() { try { scriptProcess = processBuilder.start(); } catch (Exception excp) { - LOGGER.error("Error launch user script <{}>", script.getName()); // $NON-NLS-1$ - LOGGER.error("\t<{}>", processOutput, excp); // $NON-NLS-1$ + LOGGER.error("Error launch user script <{}>", scriptName); //$NON-NLS-1$ + LOGGER.error("\t<{}>", processOutput, excp); //$NON-NLS-1$ Helper.showMessageBox(excp.getLocalizedMessage()); return; } state = TaskState.RUNNUNG; - LOGGER.debug("Script process runnung = {}", scriptProcess.isAlive()); // $NON-NLS-1$ - LOGGER.debug("Script process parent CMD pid={}", scriptProcess.pid()); // $NON-NLS-1$ + LOGGER.debug("Script process runnung = {}", scriptProcess.isAlive()); //$NON-NLS-1$ + LOGGER.debug("Script process parent CMD pid={}", scriptProcess.pid()); //$NON-NLS-1$ Stream subprocesses = scriptProcess.children(); subprocesses.forEach( subprocess -> @@ -315,7 +345,7 @@ public void run() { exitCode = scriptProcess.waitFor(); } catch (InterruptedException | IOException excp) { - LOGGER.error("Error: ", excp); // $NON-NLS-1$ + LOGGER.error("Error: ", excp); //$NON-NLS-1$ } state = exitCode == 0 ? TaskState.DONE : TaskState.ERROR; @@ -324,5 +354,4 @@ public void run() { thread.start(); } - } diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/BackgroundTaskParams.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/BackgroundTaskParams.java index bf7742e..edbb09c 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/BackgroundTaskParams.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/BackgroundTaskParams.java @@ -4,6 +4,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.viewers.CellEditor; @@ -36,7 +37,6 @@ public class BackgroundTaskParams extends Dialog { private Map infobasesCredentials = new HashMap<>(); private List usernames = new ArrayList<>(); private String currentUsernameValue = ""; - /** * Создание диалога ввода имени пользователя и пароля. * @@ -92,7 +92,8 @@ protected Control createDialogArea(Composite parent) { clmnParamKey.setMoveable(true); clmnParamKey.setWidth(120); clmnParamKey.setText(Strings.TITLE_PARAMNAME); - // tableViewerColumnParamKey.setEditingSupport(new TableViewerEditingSupport(tableViewer)); + // tableViewerColumnParamKey.setEditingSupport(new + // TableViewerEditingSupport(tableViewer)); tableViewerColumnParamKey.setLabelProvider( new ColumnLabelProvider() { @Override @@ -130,6 +131,23 @@ public Map getParams() { return params; } + /** + * Возвращает заполненные пользователем параметры запуска задачи. + * + * @return параметры запуска задачи + */ + public void checkUsernameParam() { + String user = params.get("v8username"); + // if (Objects.nonNull(user) && user.isBlank()) { + // params.remove("v8username"); + // params.remove("v8password"); + // } + if (Objects.nonNull(user)) { + params.put("v8username", "\"" + params.get("v8username") + "\""); + params.put("v8password", "\"" + params.get("v8password") + "\""); + } + } + /** * Create contents of the button bar. * @@ -143,6 +161,7 @@ protected void createButtonsForButtonBar(Composite parent) { new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { + checkUsernameParam(); close(); } }); @@ -151,11 +170,11 @@ public void widgetSelected(SelectionEvent e) { } protected boolean isUsernameParam(String e) { - return e.equals("username"); + return e.equals("v8username"); } protected boolean isPasswordParam(String e) { - return e.equals("password"); + return e.equals("v8password"); } class TableViewerEditingSupport extends EditingSupport { @@ -226,7 +245,7 @@ protected void setValue(Object element, Object value) { newParamValue = usernames.get(valueIndex); currentUsernameValue = newParamValue; // установка пароля - params.put("password", infobasesCredentials.getOrDefault(newParamValue, "")); + params.put("v8password", infobasesCredentials.getOrDefault(newParamValue, "")); } else if (isUsernameParam(paramKey) && valueIndex == -1) { // ввод нового логина вручную @@ -254,7 +273,6 @@ class ParamsContentProvider implements IStructuredContentProvider { public Object[] getElements(Object inputElement) { if (inputElement instanceof Map) { - List collection = new ArrayList<>(); ((Map) inputElement) .forEach( diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java index 8e03274..7e1b18b 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java @@ -612,6 +612,13 @@ private void initInfobaseMenu() { terminateUsersSessionsListener); new UserScriptRunner(infobaseMenu); + + // Меню действий с базой + addMenuSeparator(infobaseMenu); + + Menu subMenuInfobaseActions = addItemGroupInMenu(infobaseMenu, "Действия с базой", null); + + addItemInMenu(subMenuInfobaseActions, "Запустить конфигуратор", null, launchDesignerListener); } private TabItem initListTable( @@ -1564,6 +1571,220 @@ private void setEnableToolbarItems() { deleteToolbarItem.setEnabled(toolbarDeleteListeners.get(currentHighlightingType) != null); } + public Map fillParams(File script, TreeItem infobaseItem) { + Map params = new LinkedHashMap<>(); + + String scriptText; + try { + scriptText = Files.readString(Path.of(script.getPath())); + } catch (IOException excp) { + LOGGER.error( + "Error read script {}", //$NON-NLS-1$ + script.getName(), + excp); + return params; + } + + UUID clusterId = getClusterId(infobaseItem); + UUID infobaseId = getInfobaseId(infobaseItem); + Server server = getServer(infobaseItem); + if (server == null) { + LOGGER.error( + "Error get server info {}", //$NON-NLS-1$ + script.getName()); + return params; + } + + boolean foundEmptyParams = false; + boolean foundUsernameParam = false; + boolean foundPasswordParam = false; + + Pattern p = Pattern.compile("\\%.+?\\%"); + // Pattern p = Pattern.compile("[^\\%]++", Pattern.CASE_INSENSITIVE); + + Matcher m = p.matcher(scriptText); + while (m.find()) { + final String foundParam = m.group(); + String paramValue; + + switch (foundParam) { + case "%infobase%": + paramValue = server.getInfoBaseName(clusterId, infobaseId); + break; + + case "%serverName%": + paramValue = server.getAgentHost(); + break; + + case "%agentPort%": + paramValue = server.getAgentPortAsString(); + break; + + case "%managerPort%": + paramValue = server.getClusterMainPort(clusterId); + break; + + case "%v8version%": + paramValue = server.getV8Version(); + break; + + case "%username%": + foundUsernameParam = true; + foundEmptyParams = true; + continue; + + case "%password%": + foundPasswordParam = true; + foundEmptyParams = true; + continue; + + default: + LOGGER.info("Found unknown param {}", foundParam); + paramValue = ""; + foundEmptyParams = true; + break; + } + + String paramKey = foundParam.replace("%", ""); + params.put(paramKey, paramValue); + } + if (Boolean.TRUE.equals(foundUsernameParam)) { + params.put("v8username", ""); + } + if (Boolean.TRUE.equals(foundPasswordParam)) { + params.put("v8password", ""); + } + + if (foundEmptyParams) { + BackgroundTaskParams taskParamsDialog = + new BackgroundTaskParams( + getShell(), params, script.getName(), server.getInfobasesCredentials()); + int dialogResult = taskParamsDialog.open(); + if (dialogResult != 0) { + return new HashMap<>(); + } + + params = taskParamsDialog.getParams(); + } + + return params; + } + + public Map fillParams( + String scriptText, String scriptName, TreeItem infobaseItem) { + Map params = new LinkedHashMap<>(); + + // String scriptText; + // try { + // scriptText = Files.readString(Path.of(script.getPath())); + // } catch (IOException excp) { + // LOGGER.error("Error read script {}", //$NON-NLS-1$ + // script.getName(), excp); + // return params; + // } + + UUID clusterId = getClusterId(infobaseItem); + UUID infobaseId = getInfobaseId(infobaseItem); + Server server = getServer(infobaseItem); + if (server == null) { + LOGGER.error( + "Error get server info {}", //$NON-NLS-1$ + scriptName); + return params; + } + + boolean foundEmptyParams = false; + boolean foundUsernameParam = false; + boolean foundPasswordParam = false; + + Pattern p = Pattern.compile("\\%.+?\\%"); + // Pattern p = Pattern.compile("[^\\%]++", Pattern.CASE_INSENSITIVE); + + Matcher m = p.matcher(scriptText); + while (m.find()) { + final String foundParam = m.group(); + String paramValue; + + switch (foundParam) { + case "%infobase%": + paramValue = server.getInfoBaseName(clusterId, infobaseId); + break; + + case "%serverName%": + paramValue = server.getAgentHost(); + break; + + case "%agentPort%": + paramValue = server.getAgentPortAsString(); + break; + + case "%managerPort%": + paramValue = server.getClusterMainPort(clusterId); + break; + + case "%v8version%": + paramValue = server.getV8Version(); + break; + + case "%username%": + foundUsernameParam = true; + foundEmptyParams = true; + continue; + + case "%password%": + foundPasswordParam = true; + foundEmptyParams = true; + continue; + + default: + LOGGER.info("Found unknown param {}", foundParam); + paramValue = ""; + foundEmptyParams = true; + break; + } + + String paramKey = foundParam.replace("%", ""); + params.put(paramKey, paramValue); + } + if (Boolean.TRUE.equals(foundUsernameParam)) { + params.put("v8username", ""); + } + if (Boolean.TRUE.equals(foundPasswordParam)) { + params.put("v8password", ""); + } + + if (foundEmptyParams) { + BackgroundTaskParams taskParamsDialog = + new BackgroundTaskParams( + getShell(), params, scriptName, server.getInfobasesCredentials()); + int dialogResult = taskParamsDialog.open(); + if (dialogResult != 0) { + return new HashMap<>(); + } + + params = taskParamsDialog.getParams(); + } + + return params; + } + + public void addToTasksQueue(BackgroundTask task) { + TableItem tableItem = new TableItem(tableTasks, SWT.NONE); + tableItem.setData(task); + tableItem.setChecked(false); + + if (tableTasks.getSelection().length == 0 || BackgroundTask.getRunningCount() == 0) { + tableTasks.setSelection(tableItem); + } + + task.run(); + + if (BackgroundTask.getRunningCount() == 0) { + taskTimer = new Timer(true); + taskTimer.scheduleAtFixedRate(new TaskChekerTimer(), 1000, 1000); + } + } + ////////////////////////////////////////////////////////////////////////// // LISTENERS @@ -2400,6 +2621,32 @@ public void widgetSelected(SelectionEvent event) { } }; + SelectionAdapter launchDesignerListener = + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent event) { + TreeItem[] items = serversTree.getSelection(); + if (items.length == 0) { + return; + } + TreeItem infobaseItem = items[0]; + + String script1 = + String.join(" ", + "\"C:\\Program Files\\1cv8\\common\\1cestart.exe\"", + "DESIGNER", + "/S %serverName%:%managerPort%\\%infobase% /N%v8username% /P%v8password%"); + + String script = + "\"C:\\Program Files\\1cv8\\common\\1cestart.exe\" DESIGNER /S %serverName%:%managerPort%\\%infobase% /N%v8username% /P%v8password%"; + + Map params = fillParams(script, "runDesigner", infobaseItem); + if (!params.isEmpty()) { + addToTasksQueue(new BackgroundTask(script, "runDesigner", params)); + } + } + }; + SelectionAdapter createWorkingServerListener = new SelectionAdapter() { @Override @@ -3057,121 +3304,6 @@ public void widgetSelected(SelectionEvent event) { } } - public Map fillParams(File script, TreeItem infobaseItem) { - Map params = new LinkedHashMap<>(); - - UUID clusterId = getClusterId(infobaseItem); - UUID infobaseId = getInfobaseId(infobaseItem); - Server server = getServer(infobaseItem); - if (server == null) { - LOGGER.error( - "Error get server info {}", //$NON-NLS-1$ - script.getName()); - return params; - } - - String scriptText; - try { - scriptText = Files.readString(Path.of(script.getPath())); - } catch (IOException excp) { - LOGGER.error( - "Error read script {}", //$NON-NLS-1$ - script.getName(), - excp); - return params; - } - - boolean foundEmptyParams = false; - boolean foundUsernameParam = false; - boolean foundPasswordParam = false; - - Pattern p = Pattern.compile("\\%.+?\\%"); - // Pattern p = Pattern.compile("[^\\%]++", Pattern.CASE_INSENSITIVE); - - Matcher m = p.matcher(scriptText); - while (m.find()) { - final String foundParam = m.group(); - String paramValue; - - switch (foundParam) { - case "%infobase%": - paramValue = server.getInfoBaseName(clusterId, infobaseId); - break; - - case "%serverName%": - paramValue = server.getAgentHost(); - break; - - case "%agentPort%": - paramValue = server.getAgentPortAsString(); - break; - - case "%managerPort%": - paramValue = server.getClusterMainPort(clusterId); - break; - - case "%v8version%": - paramValue = server.getV8Version(); - break; - - case "%username%": - foundUsernameParam = true; - foundEmptyParams = true; - continue; - - case "%password%": - foundPasswordParam = true; - foundEmptyParams = true; - continue; - - default: - LOGGER.info("Found unknown param {}", foundParam); - paramValue = ""; - foundEmptyParams = true; - break; - } - - String paramKey = foundParam.replace("%", ""); - params.put(paramKey, paramValue); - } - if (Boolean.TRUE.equals(foundUsernameParam)) { - params.put("username", ""); - } - if (Boolean.TRUE.equals(foundPasswordParam)) { - params.put("password", ""); - } - - if (foundEmptyParams) { - BackgroundTaskParams taskParamsDialog = - new BackgroundTaskParams( - getShell(), params, script.getName(), server.getInfobasesCredentials()); - int dialogResult = taskParamsDialog.open(); - if (dialogResult != 0) { - return new HashMap<>(); - } - - params = taskParamsDialog.getParams(); - } - - return params; - } - - public void addToTasksQueue(BackgroundTask task) { - TableItem tableItem = new TableItem(tableTasks, SWT.NONE); - tableItem.setData(task); - tableItem.setChecked(false); - - if (tableTasks.getSelection().length == 0 || BackgroundTask.getRunningCount() == 0) { - tableTasks.setSelection(tableItem); - } - - task.run(); - - if (BackgroundTask.getRunningCount() == 0) { - taskTimer = new Timer(true); - taskTimer.scheduleAtFixedRate(new TaskChekerTimer(), 1000, 1000); - } - } } class RefreshTablesSelectionListener extends SelectionAdapter { diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties index a1703d3..22889d1 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties @@ -16,7 +16,7 @@ AboutDialog.TitleDialog = About BackgroundTaskParams.ParamName = Param name BackgroundTaskParams.ParamValue = Value -BackgroundTaskParams.Title = Set params for task: +BackgroundTaskParams.Title = Set params for task: ClusterDialog.AcceptableDeviationOfTheNumberOfServerErrors = Acceptable deviation of the\r\nnumber of server errors (%) ClusterDialog.ClusterName = Cluster name diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties index 27dcab1..5ded655 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties @@ -16,7 +16,7 @@ AboutDialog.TitleDialog = \u041E \u043F\u0440\u043E\u0433\u0440\u043 BackgroundTaskParams.ParamName = \u0418\u043C\u044F \u043F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u0430 BackgroundTaskParams.ParamValue = \u0417\u043D\u0430\u0447\u0435\u043D\u0438\u0435 -BackgroundTaskParams.Title = \u0423\u0441\u0442\u0430\u043D\u043E\u0432\u043A\u0430 \u043F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u043E\u0432 \u0434\u043B\u044F \u0437\u0430\u0434\u0430\u0447\u0438: +BackgroundTaskParams.Title = \u0423\u0441\u0442\u0430\u043D\u043E\u0432\u043A\u0430 \u043F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u043E\u0432 \u0434\u043B\u044F \u0437\u0430\u0434\u0430\u0447\u0438: ClusterDialog.AcceptableDeviationOfTheNumberOfServerErrors = \u0414\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u043E\u0435 \u043E\u0442\u043A\u043B\u043E\u043D\u0435\u043D\u0438\u0435 \u043A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u0430\r\n\u043E\u0448\u0438\u0431\u043E\u043A \u0441\u0435\u0440\u0432\u0435\u0440\u0430 (%) ClusterDialog.ClusterName = \u0418\u043C\u044F \u043A\u043B\u0430\u0441\u0442\u0435\u0440\u0430 From 721858167dd907789daf0406b4ea56ca09cbb2d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Sun, 30 Jul 2023 08:46:24 +0300 Subject: [PATCH 15/70] =?UTF-8?q?=D0=97=D0=B0=D0=BF=D1=83=D1=81=D0=BA=20?= =?UTF-8?q?=D0=B4=D1=80=D1=83=D0=B3=D0=B8=D1=85=20=D0=BA=D0=BE=D0=BC=D0=B0?= =?UTF-8?q?=D0=BD=D0=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../clusterAdminLibrary/BackgroundTask.java | 104 +++++++++-- .../clusterAdminLibraryUI/ViewerArea.java | 163 ++++-------------- 2 files changed, 120 insertions(+), 147 deletions(-) diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java index e4025ce..ad88a59 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java @@ -5,6 +5,8 @@ import java.io.IOException; import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; import java.util.Date; import java.util.HashMap; import java.util.Map; @@ -20,6 +22,14 @@ public class BackgroundTask { static final Logger LOGGER = LoggerFactory.getLogger(BackgroundTask.class.getSimpleName()); + static final String starterPath = "\"C:\\Program Files\\1cv8\\common\\1cestart.exe\""; + static final String designerCommand = "DESIGNER"; + static final String enterpriseCommand = "ENTERPRISE"; + static final String logonCommand = + "/S%serverName%:%managerPort%\\%infobase% /N%v8username% /P%v8password%"; + // static final String logonComman1 = "/S%v8server%:%v8managerPort%\\%v8infobase% /N%v8username% + // /P%v8password%"; + static int countOfRunning = 0; static int countOfCompleted = 0; static int countWithError = 0; @@ -57,6 +67,15 @@ enum TaskVariant { V8ACTION } + public enum V8ActionVariant { + RUN_DESIGNER, + RUN_ENTERPRISE, + LOAD_CF, + SAVE_CF, + LOAD_DT, + SAVE_DT + } + Thread thread; Date startDate; @@ -66,40 +85,97 @@ enum TaskVariant { * Инициализация задачи. * * @param script - файл скрипта - * @param params - Переменные окружения */ - public BackgroundTask(File script, Map params) { + public BackgroundTask(File script) { this.taskVariant = TaskVariant.USER_SCRIPT; this.script = script; + + try { + this.scriptText = Files.readString(Path.of(script.getPath())); + } catch (IOException excp) { + LOGGER.error( + "Error read script {}", //$NON-NLS-1$ + script.getName(), + excp); + } + this.scriptName = script.getName(); - this.params = params; - this.taskName = generateTaskName(); } /** * Инициализация задачи. * - * @param scriptText - строка с командой для выполнения действия - * @param scriptName - имя команды - * @param params - Переменные окружения + * @param v8ActionVariant - Вариант команды 1С */ - public BackgroundTask(String scriptText, String scriptName, Map params) { + public BackgroundTask(V8ActionVariant v8ActionVariant) { this.taskVariant = TaskVariant.V8ACTION; - this.scriptText = scriptText; - this.scriptName = scriptName; - this.params = params; - this.taskName = generateTaskName(); + if (v8ActionVariant == V8ActionVariant.RUN_ENTERPRISE) { + this.scriptText = String.join(" ", starterPath, enterpriseCommand, logonCommand); + } else { + this.scriptText = String.join(" ", starterPath, designerCommand, logonCommand); + } + + switch (v8ActionVariant) { + case SAVE_CF: + this.scriptText = String.join(" ", this.scriptText, "/DumpCfg %v8FilePath%.cf"); + break; + case LOAD_CF: + this.scriptText = String.join(" ", this.scriptText, "/LoadCfg %v8FilePath%.cf"); + break; + case SAVE_DT: + this.scriptText = String.join(" ", this.scriptText, "/DumpIB %v8FilePath%.dt"); + break; + case LOAD_DT: + this.scriptText = String.join(" ", this.scriptText, "/RestoreIB %v8FilePath%.dt"); + break; + + default: + break; + } + + this.scriptName = v8ActionVariant.toString(); } - private String generateTaskName() { + private void generateTaskName() { int taskNumber = taskNamesCounter.getOrDefault(scriptName, 0); taskNumber++; taskNamesCounter.put(scriptName, taskNumber); - return String.format("%s #%d", scriptName, taskNumber); + if (taskVariant == TaskVariant.USER_SCRIPT) { + this.taskName = String.format("%s (#%d)", scriptName, taskNumber); + } else { + this.taskName = + String.format( + "%s %s:%s/%s (#%d)", + scriptName, + params.get("serverName"), + params.get("managerPort"), + params.get("infobase"), + taskNumber); + } + } + + /** Получить текст скрипта. */ + public String getScriptText() { + return this.scriptText; + } + + /** Получить имя скрипта. */ + public String getScriptName() { + return this.scriptName; + } + + /** + * Установка параметров задачи. + * + * @param params - Параметры задачи + */ + public void setParams(Map params) { + this.params = params; + generateTaskName(); } /** diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java index 7e1b18b..cdde9a2 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java @@ -61,6 +61,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import ru.yanygin.clusterAdminLibrary.BackgroundTask; +import ru.yanygin.clusterAdminLibrary.BackgroundTask.V8ActionVariant; import ru.yanygin.clusterAdminLibrary.BaseInfoExtended; import ru.yanygin.clusterAdminLibrary.ClusterProvider; import ru.yanygin.clusterAdminLibrary.ColumnProperties; @@ -291,7 +292,7 @@ private void initTaskTab(TabFolder mainTabFolder) { tableTasks.setLinesVisible(true); tableTasks.addMouseListener(tableTaskMouseClickListener); - addTaskTableColumn(tableTasks, "Task", 140); + addTaskTableColumn(tableTasks, "Task", 200); addTaskTableColumn(tableTasks, "State", 50); addTaskTableColumn(tableTasks, "Start", 120, SWT.RIGHT); addTaskTableColumn(tableTasks, "End", 120); @@ -306,7 +307,7 @@ public void handleEvent(Event e) { } }); // Пропорции областей - sashTasks.setWeights(5, 10); + sashTasks.setWeights(7, 10); } private void initIcon() { @@ -618,7 +619,16 @@ private void initInfobaseMenu() { Menu subMenuInfobaseActions = addItemGroupInMenu(infobaseMenu, "Действия с базой", null); - addItemInMenu(subMenuInfobaseActions, "Запустить конфигуратор", null, launchDesignerListener); + addItemInMenu(subMenuInfobaseActions, "Запустить конфигуратор", null, launchDesignerListener, V8ActionVariant.RUN_DESIGNER); + addItemInMenu(subMenuInfobaseActions, "Запустить предприятие", null, launchDesignerListener, V8ActionVariant.RUN_ENTERPRISE); + + addMenuSeparator(subMenuInfobaseActions); + addItemInMenu(subMenuInfobaseActions, "Сохранить CF", null, launchDesignerListener, V8ActionVariant.SAVE_CF); + addItemInMenu(subMenuInfobaseActions, "Загрузить CF", null, launchDesignerListener, V8ActionVariant.LOAD_CF); + + addMenuSeparator(subMenuInfobaseActions); + addItemInMenu(subMenuInfobaseActions, "Сохранить DT", null, launchDesignerListener, V8ActionVariant.SAVE_DT); + addItemInMenu(subMenuInfobaseActions, "Загрузить DT", null, launchDesignerListener, V8ActionVariant.LOAD_DT); } private TabItem initListTable( @@ -1571,27 +1581,16 @@ private void setEnableToolbarItems() { deleteToolbarItem.setEnabled(toolbarDeleteListeners.get(currentHighlightingType) != null); } - public Map fillParams(File script, TreeItem infobaseItem) { + private Map fillParams(BackgroundTask backgroundTask, TreeItem infobaseItem) { Map params = new LinkedHashMap<>(); - String scriptText; - try { - scriptText = Files.readString(Path.of(script.getPath())); - } catch (IOException excp) { - LOGGER.error( - "Error read script {}", //$NON-NLS-1$ - script.getName(), - excp); - return params; - } - UUID clusterId = getClusterId(infobaseItem); UUID infobaseId = getInfobaseId(infobaseItem); Server server = getServer(infobaseItem); if (server == null) { LOGGER.error( "Error get server info {}", //$NON-NLS-1$ - script.getName()); + backgroundTask.getScriptName()); return params; } @@ -1602,7 +1601,7 @@ public Map fillParams(File script, TreeItem infobaseItem) { Pattern p = Pattern.compile("\\%.+?\\%"); // Pattern p = Pattern.compile("[^\\%]++", Pattern.CASE_INSENSITIVE); - Matcher m = p.matcher(scriptText); + Matcher m = p.matcher(backgroundTask.getScriptText()); while (m.find()) { final String foundParam = m.group(); String paramValue; @@ -1658,7 +1657,7 @@ public Map fillParams(File script, TreeItem infobaseItem) { if (foundEmptyParams) { BackgroundTaskParams taskParamsDialog = new BackgroundTaskParams( - getShell(), params, script.getName(), server.getInfobasesCredentials()); + getShell(), params, backgroundTask.getScriptName(), server.getInfobasesCredentials()); int dialogResult = taskParamsDialog.open(); if (dialogResult != 0) { return new HashMap<>(); @@ -1670,105 +1669,7 @@ public Map fillParams(File script, TreeItem infobaseItem) { return params; } - public Map fillParams( - String scriptText, String scriptName, TreeItem infobaseItem) { - Map params = new LinkedHashMap<>(); - - // String scriptText; - // try { - // scriptText = Files.readString(Path.of(script.getPath())); - // } catch (IOException excp) { - // LOGGER.error("Error read script {}", //$NON-NLS-1$ - // script.getName(), excp); - // return params; - // } - - UUID clusterId = getClusterId(infobaseItem); - UUID infobaseId = getInfobaseId(infobaseItem); - Server server = getServer(infobaseItem); - if (server == null) { - LOGGER.error( - "Error get server info {}", //$NON-NLS-1$ - scriptName); - return params; - } - - boolean foundEmptyParams = false; - boolean foundUsernameParam = false; - boolean foundPasswordParam = false; - - Pattern p = Pattern.compile("\\%.+?\\%"); - // Pattern p = Pattern.compile("[^\\%]++", Pattern.CASE_INSENSITIVE); - - Matcher m = p.matcher(scriptText); - while (m.find()) { - final String foundParam = m.group(); - String paramValue; - - switch (foundParam) { - case "%infobase%": - paramValue = server.getInfoBaseName(clusterId, infobaseId); - break; - - case "%serverName%": - paramValue = server.getAgentHost(); - break; - - case "%agentPort%": - paramValue = server.getAgentPortAsString(); - break; - - case "%managerPort%": - paramValue = server.getClusterMainPort(clusterId); - break; - - case "%v8version%": - paramValue = server.getV8Version(); - break; - - case "%username%": - foundUsernameParam = true; - foundEmptyParams = true; - continue; - - case "%password%": - foundPasswordParam = true; - foundEmptyParams = true; - continue; - - default: - LOGGER.info("Found unknown param {}", foundParam); - paramValue = ""; - foundEmptyParams = true; - break; - } - - String paramKey = foundParam.replace("%", ""); - params.put(paramKey, paramValue); - } - if (Boolean.TRUE.equals(foundUsernameParam)) { - params.put("v8username", ""); - } - if (Boolean.TRUE.equals(foundPasswordParam)) { - params.put("v8password", ""); - } - - if (foundEmptyParams) { - BackgroundTaskParams taskParamsDialog = - new BackgroundTaskParams( - getShell(), params, scriptName, server.getInfobasesCredentials()); - int dialogResult = taskParamsDialog.open(); - if (dialogResult != 0) { - return new HashMap<>(); - } - - params = taskParamsDialog.getParams(); - } - - return params; - } - - public void addToTasksQueue(BackgroundTask task) { + private void addToTasksQueue(BackgroundTask task) { TableItem tableItem = new TableItem(tableTasks, SWT.NONE); tableItem.setData(task); tableItem.setChecked(false); @@ -2629,20 +2530,15 @@ public void widgetSelected(SelectionEvent event) { if (items.length == 0) { return; } - TreeItem infobaseItem = items[0]; - - String script1 = - String.join(" ", - "\"C:\\Program Files\\1cv8\\common\\1cestart.exe\"", - "DESIGNER", - "/S %serverName%:%managerPort%\\%infobase% /N%v8username% /P%v8password%"); - String script = - "\"C:\\Program Files\\1cv8\\common\\1cestart.exe\" DESIGNER /S %serverName%:%managerPort%\\%infobase% /N%v8username% /P%v8password%"; + TreeItem infobaseItem = items[0]; + BackgroundTask backgroundTask = + new BackgroundTask((V8ActionVariant) event.widget.getData()); - Map params = fillParams(script, "runDesigner", infobaseItem); + Map params = fillParams(backgroundTask, infobaseItem); if (!params.isEmpty()) { - addToTasksQueue(new BackgroundTask(script, "runDesigner", params)); + backgroundTask.setParams(params); + addToTasksQueue(backgroundTask); } } }; @@ -3295,15 +3191,16 @@ public void widgetSelected(SelectionEvent event) { return; } - File script = (File) event.widget.getData(); - TreeItem infobaseItem = items[0]; - Map params = fillParams(script, infobaseItem); + File script = (File) scriptData; + + BackgroundTask backgroundTask = new BackgroundTask(script); + Map params = fillParams(backgroundTask, infobaseItem); if (!params.isEmpty()) { - addToTasksQueue(new BackgroundTask(script, params)); + backgroundTask.setParams(params); + addToTasksQueue(backgroundTask); } } - } class RefreshTablesSelectionListener extends SelectionAdapter { From 380d00ad5c111fd51953615b5fa96161bcf633e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Tue, 1 Aug 2023 21:05:57 +0300 Subject: [PATCH 16/70] =?UTF-8?q?=D1=80=D0=B5=D1=84=D0=B0=D0=BA=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=B8=D0=BD=D0=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- clusterAdminApplication/scripts/echo_fast.bat | 8 ++--- clusterAdminApplication/scripts/echo_long.bat | 4 +-- ...00\321\203\320\267\320\272\320\260_CF.bat" | 2 +- ...00\321\203\320\267\320\272\320\260_DT.bat" | 2 +- ...1\200\320\260\321\202\320\276\321\200.bat" | 2 +- ...0\270\321\217\321\202\320\270\320\265.bat" | 2 +- .../clusterAdminLibrary/BackgroundTask.java | 4 +-- .../BackgroundTaskParams.java | 29 +++++++-------- .../clusterAdminLibraryUI/ViewerArea.java | 36 +++++++++++-------- .../clusterAdminLibraryUI/messages.properties | 7 ++++ .../messages_ru_RU.properties | 7 ++++ 11 files changed, 60 insertions(+), 43 deletions(-) diff --git a/clusterAdminApplication/scripts/echo_fast.bat b/clusterAdminApplication/scripts/echo_fast.bat index 31d3d4b..49eeac1 100644 --- a/clusterAdminApplication/scripts/echo_fast.bat +++ b/clusterAdminApplication/scripts/echo_fast.bat @@ -2,9 +2,9 @@ @echo off chcp 65001 -echo server: %serverName%:%managerPort% -echo password: %password% -echo infobase: %infobase% -echo username: %username% +echo server: %v8serverName%:%v8managerPort% +echo password: %v8password% +echo infobase: %v8infobase% +echo username: %v8username% echo infobase1: %infobase1% echo end diff --git a/clusterAdminApplication/scripts/echo_long.bat b/clusterAdminApplication/scripts/echo_long.bat index bbe5dff..4e2a565 100644 --- a/clusterAdminApplication/scripts/echo_long.bat +++ b/clusterAdminApplication/scripts/echo_long.bat @@ -4,6 +4,6 @@ chcp 65001 #chcp ping 127.0.0.1 -n 20 -echo server: %serverName%:%managerPort% -echo infobase: %infobase% +echo server: %v8serverName%:%v8managerPort% +echo infobase: %v8infobase% echo end diff --git "a/clusterAdminApplication/scripts/\320\222\321\213\320\263\321\200\321\203\320\267\320\272\320\260_CF.bat" "b/clusterAdminApplication/scripts/\320\222\321\213\320\263\321\200\321\203\320\267\320\272\320\260_CF.bat" index e10d8c1..56e233d 100644 --- "a/clusterAdminApplication/scripts/\320\222\321\213\320\263\321\200\321\203\320\267\320\272\320\260_CF.bat" +++ "b/clusterAdminApplication/scripts/\320\222\321\213\320\263\321\200\321\203\320\267\320\272\320\260_CF.bat" @@ -1,2 +1,2 @@ chcp 65001 -"C:\Program Files\1cv8\common\1cestart.exe" DESIGNER /S %serverName%:%managerPort%\%infobase% /N Администратор /P 1234 /DumpCfg D:\DumpIB\%infobase%.cf \ No newline at end of file +"C:\Program Files\1cv8\common\1cestart.exe" DESIGNER /S %v8serverName%:%v8managerPort%\%v8infobase% /N Администратор /P 1234 /DumpCfg D:\DumpIB\%v8infobase%.cf \ No newline at end of file diff --git "a/clusterAdminApplication/scripts/\320\222\321\213\320\263\321\200\321\203\320\267\320\272\320\260_DT.bat" "b/clusterAdminApplication/scripts/\320\222\321\213\320\263\321\200\321\203\320\267\320\272\320\260_DT.bat" index 9fd83c2..9ae7f40 100644 --- "a/clusterAdminApplication/scripts/\320\222\321\213\320\263\321\200\321\203\320\267\320\272\320\260_DT.bat" +++ "b/clusterAdminApplication/scripts/\320\222\321\213\320\263\321\200\321\203\320\267\320\272\320\260_DT.bat" @@ -1,2 +1,2 @@ chcp 65001 -"C:\Program Files\1cv8\common\1cestart.exe" DESIGNER /S %serverName%:%managerPort%\%infobase% /N Администратор /P 1234 /DumpIB D:\DumpIB\%infobase%.dt \ No newline at end of file +"C:\Program Files\1cv8\common\1cestart.exe" DESIGNER /S %v8serverName%:%v8managerPort%\%v8infobase% /N Администратор /P 1234 /DumpIB D:\DumpIB\%v8infobase%.dt \ No newline at end of file diff --git "a/clusterAdminApplication/scripts/\320\227\320\260\320\277\321\203\321\201\320\272_\320\232\320\276\320\275\321\204\320\270\320\263\321\203\321\200\320\260\321\202\320\276\321\200.bat" "b/clusterAdminApplication/scripts/\320\227\320\260\320\277\321\203\321\201\320\272_\320\232\320\276\320\275\321\204\320\270\320\263\321\203\321\200\320\260\321\202\320\276\321\200.bat" index dfcd6c8..1f0079d 100644 --- "a/clusterAdminApplication/scripts/\320\227\320\260\320\277\321\203\321\201\320\272_\320\232\320\276\320\275\321\204\320\270\320\263\321\203\321\200\320\260\321\202\320\276\321\200.bat" +++ "b/clusterAdminApplication/scripts/\320\227\320\260\320\277\321\203\321\201\320\272_\320\232\320\276\320\275\321\204\320\270\320\263\321\203\321\200\320\260\321\202\320\276\321\200.bat" @@ -1,2 +1,2 @@ chcp 65001 -"C:\Program Files\1cv8\common\1cestart.exe" DESIGNER /S %serverName%:%managerPort%\%infobase% /N Администратор /P 1234 \ No newline at end of file +"C:\Program Files\1cv8\common\1cestart.exe" DESIGNER /S %v8serverName%:%v8managerPort%\%v8infobase% /N Администратор /P 1234 \ No newline at end of file diff --git "a/clusterAdminApplication/scripts/\320\227\320\260\320\277\321\203\321\201\320\272_\320\237\321\200\320\265\320\264\320\277\321\200\320\270\321\217\321\202\320\270\320\265.bat" "b/clusterAdminApplication/scripts/\320\227\320\260\320\277\321\203\321\201\320\272_\320\237\321\200\320\265\320\264\320\277\321\200\320\270\321\217\321\202\320\270\320\265.bat" index ccc38d5..d52a921 100644 --- "a/clusterAdminApplication/scripts/\320\227\320\260\320\277\321\203\321\201\320\272_\320\237\321\200\320\265\320\264\320\277\321\200\320\270\321\217\321\202\320\270\320\265.bat" +++ "b/clusterAdminApplication/scripts/\320\227\320\260\320\277\321\203\321\201\320\272_\320\237\321\200\320\265\320\264\320\277\321\200\320\270\321\217\321\202\320\270\320\265.bat" @@ -1,2 +1,2 @@ chcp 65001 -"C:\Program Files\1cv8\common\1cestart.exe" ENTERPRISE /S %serverName%:%managerPort%\%infobase% /N Администратор /P 1234 \ No newline at end of file +"C:\Program Files\1cv8\common\1cestart.exe" ENTERPRISE /S %v8serverName%:%v8managerPort%\%v8infobase% /N Администратор /P 1234 \ No newline at end of file diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java index ad88a59..b798eba 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java @@ -26,9 +26,7 @@ public class BackgroundTask { static final String designerCommand = "DESIGNER"; static final String enterpriseCommand = "ENTERPRISE"; static final String logonCommand = - "/S%serverName%:%managerPort%\\%infobase% /N%v8username% /P%v8password%"; - // static final String logonComman1 = "/S%v8server%:%v8managerPort%\\%v8infobase% /N%v8username% - // /P%v8password%"; + "/S%v8serverName%:%v8managerPort%\\%v8infobase% /N%v8username% /P%v8password%"; static int countOfRunning = 0; static int countOfCompleted = 0; diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/BackgroundTaskParams.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/BackgroundTaskParams.java index edbb09c..d40866e 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/BackgroundTaskParams.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/BackgroundTaskParams.java @@ -31,12 +31,16 @@ /** Диалог параметров фоновой задачи. */ public class BackgroundTaskParams extends Dialog { + private static final String USERNAME_TITLE = "v8username"; + private static final String PASSWORD_TITLE = "v8password"; + private Map params; private String title; private Table tableParams; private Map infobasesCredentials = new HashMap<>(); private List usernames = new ArrayList<>(); private String currentUsernameValue = ""; + /** * Создание диалога ввода имени пользователя и пароля. * @@ -131,20 +135,13 @@ public Map getParams() { return params; } - /** - * Возвращает заполненные пользователем параметры запуска задачи. - * - * @return параметры запуска задачи - */ - public void checkUsernameParam() { - String user = params.get("v8username"); - // if (Objects.nonNull(user) && user.isBlank()) { - // params.remove("v8username"); - // params.remove("v8password"); - // } + /** Экранирокание имени пользователя и пароля. */ + private void checkUsernameParam() { + String user = params.get(USERNAME_TITLE); + if (Objects.nonNull(user)) { - params.put("v8username", "\"" + params.get("v8username") + "\""); - params.put("v8password", "\"" + params.get("v8password") + "\""); + params.put(USERNAME_TITLE, "\"" + params.get(USERNAME_TITLE) + "\""); + params.put(PASSWORD_TITLE, "\"" + params.get(PASSWORD_TITLE) + "\""); } } @@ -170,11 +167,11 @@ public void widgetSelected(SelectionEvent e) { } protected boolean isUsernameParam(String e) { - return e.equals("v8username"); + return e.equals(USERNAME_TITLE); } protected boolean isPasswordParam(String e) { - return e.equals("v8password"); + return e.equals(PASSWORD_TITLE); } class TableViewerEditingSupport extends EditingSupport { @@ -245,7 +242,7 @@ protected void setValue(Object element, Object value) { newParamValue = usernames.get(valueIndex); currentUsernameValue = newParamValue; // установка пароля - params.put("v8password", infobasesCredentials.getOrDefault(newParamValue, "")); + params.put(PASSWORD_TITLE, infobasesCredentials.getOrDefault(newParamValue, "")); } else if (isUsernameParam(paramKey) && valueIndex == -1) { // ввод нового логина вручную diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java index cdde9a2..94aecc4 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java @@ -617,18 +617,18 @@ private void initInfobaseMenu() { // Меню действий с базой addMenuSeparator(infobaseMenu); - Menu subMenuInfobaseActions = addItemGroupInMenu(infobaseMenu, "Действия с базой", null); + Menu subMenuInfobaseActions = addItemGroupInMenu(infobaseMenu, Strings.CONTEXT_MENU_INFOBASE_ACTIONS, null); - addItemInMenu(subMenuInfobaseActions, "Запустить конфигуратор", null, launchDesignerListener, V8ActionVariant.RUN_DESIGNER); - addItemInMenu(subMenuInfobaseActions, "Запустить предприятие", null, launchDesignerListener, V8ActionVariant.RUN_ENTERPRISE); + addItemInMenu(subMenuInfobaseActions, Strings.CONTEXT_MENU_RUN_ENTERPRISE, null, launchV8ActionListener, V8ActionVariant.RUN_ENTERPRISE); + addItemInMenu(subMenuInfobaseActions, Strings.CONTEXT_MENU_RUN_DESIGNER, null, launchV8ActionListener, V8ActionVariant.RUN_DESIGNER); addMenuSeparator(subMenuInfobaseActions); - addItemInMenu(subMenuInfobaseActions, "Сохранить CF", null, launchDesignerListener, V8ActionVariant.SAVE_CF); - addItemInMenu(subMenuInfobaseActions, "Загрузить CF", null, launchDesignerListener, V8ActionVariant.LOAD_CF); + addItemInMenu(subMenuInfobaseActions, Strings.CONTEXT_MENU_SAVE_CF, null, launchV8ActionListener, V8ActionVariant.SAVE_CF); + addItemInMenu(subMenuInfobaseActions, Strings.CONTEXT_MENU_LOAD_CF, null, launchV8ActionListener, V8ActionVariant.LOAD_CF); addMenuSeparator(subMenuInfobaseActions); - addItemInMenu(subMenuInfobaseActions, "Сохранить DT", null, launchDesignerListener, V8ActionVariant.SAVE_DT); - addItemInMenu(subMenuInfobaseActions, "Загрузить DT", null, launchDesignerListener, V8ActionVariant.LOAD_DT); + addItemInMenu(subMenuInfobaseActions, Strings.CONTEXT_MENU_SAVE_DT, null, launchV8ActionListener, V8ActionVariant.SAVE_DT); + addItemInMenu(subMenuInfobaseActions, Strings.CONTEXT_MENU_LOAD_DT, null, launchV8ActionListener, V8ActionVariant.LOAD_DT); } private TabItem initListTable( @@ -1607,19 +1607,19 @@ private Map fillParams(BackgroundTask backgroundTask, TreeItem i String paramValue; switch (foundParam) { - case "%infobase%": + case "%v8infobase%": paramValue = server.getInfoBaseName(clusterId, infobaseId); break; - case "%serverName%": + case "%v8serverName%": paramValue = server.getAgentHost(); break; - case "%agentPort%": + case "%v8agentPort%": paramValue = server.getAgentPortAsString(); break; - case "%managerPort%": + case "%v8managerPort%": paramValue = server.getClusterMainPort(clusterId); break; @@ -1627,12 +1627,12 @@ private Map fillParams(BackgroundTask backgroundTask, TreeItem i paramValue = server.getV8Version(); break; - case "%username%": + case "%v8username%": foundUsernameParam = true; foundEmptyParams = true; continue; - case "%password%": + case "%v8password%": foundPasswordParam = true; foundEmptyParams = true; continue; @@ -2522,7 +2522,7 @@ public void widgetSelected(SelectionEvent event) { } }; - SelectionAdapter launchDesignerListener = + SelectionAdapter launchV8ActionListener = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { @@ -3373,6 +3373,14 @@ private static class Strings { static final String CONTEXT_MENU_KILL_CONNECTION_DEL = getString("ContextMenu.KillConnection").concat("\tDEL"); + static final String CONTEXT_MENU_INFOBASE_ACTIONS = getString("ContextMenu.InfobaseActions.Group"); + static final String CONTEXT_MENU_RUN_DESIGNER = getString("ContextMenu.InfobaseActions.RunDesigner"); + static final String CONTEXT_MENU_RUN_ENTERPRISE = getString("ContextMenu.InfobaseActions.RunEnterprise"); + static final String CONTEXT_MENU_SAVE_CF = getString("ContextMenu.InfobaseActions.SaveCf"); + static final String CONTEXT_MENU_LOAD_CF = getString("ContextMenu.InfobaseActions.LoadCf"); + static final String CONTEXT_MENU_SAVE_DT = getString("ContextMenu.InfobaseActions.SaveDt"); + static final String CONTEXT_MENU_LOAD_DT = getString("ContextMenu.InfobaseActions.LoadDt"); + static String getString(String key) { return Messages.getString("ViewerArea." + key); //$NON-NLS-1$ } diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties index 22889d1..a558ee2 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties @@ -163,6 +163,13 @@ ViewerArea.ContextMenu.EditCluster = Edit cluster ViewerArea.ContextMenu.EditInfobase = Edit infobase ViewerArea.ContextMenu.EditServer = Edit server ViewerArea.ContextMenu.EditWorkingServer = Edit working server +ViewerArea.ContextMenu.InfobaseActions.Group = Actions with the infobase +ViewerArea.ContextMenu.InfobaseActions.LoadCf = Load CF +ViewerArea.ContextMenu.InfobaseActions.LoadDt = Load DT +ViewerArea.ContextMenu.InfobaseActions.RunDesigner = Designer +ViewerArea.ContextMenu.InfobaseActions.RunEnterprise = Enterprise +ViewerArea.ContextMenu.InfobaseActions.SaveCf = Save CF +ViewerArea.ContextMenu.InfobaseActions.SaveDt = Save DT ViewerArea.ContextMenu.KillConnection = Kill connection ViewerArea.ContextMenu.KillSession = Kill session ViewerArea.ContextMenu.LockSessionsNow = Lock sessions now diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties index 5ded655..0be74f1 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties @@ -163,6 +163,13 @@ ViewerArea.ContextMenu.EditCluster = \u0420\u0435\u0434\u04 ViewerArea.ContextMenu.EditInfobase = \u0420\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u0438\u043D\u0444\u043E\u0431\u0430\u0437\u0443 ViewerArea.ContextMenu.EditServer = \u0420\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u0441\u0435\u0440\u0432\u0435\u0440 ViewerArea.ContextMenu.EditWorkingServer = \u0420\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u0440\u0430\u0431\u043E\u0447\u0438\u0439 \u0441\u0435\u0440\u0432\u0435\u0440 +ViewerArea.ContextMenu.InfobaseActions.Group = \u0414\u0435\u0439\u0441\u0442\u0432\u0438\u044F \u0441 \u0431\u0430\u0437\u043E\u0439 +ViewerArea.ContextMenu.InfobaseActions.LoadCf = \u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C CF +ViewerArea.ContextMenu.InfobaseActions.LoadDt = \u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C DT +ViewerArea.ContextMenu.InfobaseActions.RunDesigner = \u041A\u043E\u043D\u0444\u0438\u0433\u0443\u0440\u0430\u0442\u043E\u0440 +ViewerArea.ContextMenu.InfobaseActions.RunEnterprise = \u041F\u0440\u0435\u0434\u043F\u0440\u0438\u044F\u0442\u0438\u0435 +ViewerArea.ContextMenu.InfobaseActions.SaveCf = \u0421\u043E\u0445\u0440\u0430\u043D\u0438\u0442\u044C CF +ViewerArea.ContextMenu.InfobaseActions.SaveDt = \u0421\u043E\u0445\u0440\u0430\u043D\u0438\u0442\u044C DT ViewerArea.ContextMenu.KillConnection = \u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0441\u043E\u0435\u0434\u0438\u043D\u0435\u043D\u0438\u0435 ViewerArea.ContextMenu.KillSession = \u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0441\u0435\u0430\u043D\u0441 ViewerArea.ContextMenu.LockSessionsNow = \u041D\u0435\u043C\u0435\u0434\u043B\u0435\u043D\u043D\u043E \u0437\u0430\u0431\u043B\u043E\u043A\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u0441\u0435\u0430\u043D\u0441\u044B From ff87ef4f5ec08bb0ff76563b82e0f2a5bd9fd2bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Thu, 3 Aug 2023 21:48:19 +0300 Subject: [PATCH 17/70] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B4=D0=B8=D0=B0=D0=BB=D0=BE=D0=B3?= =?UTF-8?q?=D0=B0=20=D0=B2=D1=8B=D0=B1=D0=BE=D1=80=D0=B0=20=D1=84=D0=B0?= =?UTF-8?q?=D0=B9=D0=BB=D0=B0=20=D0=B2=20=D0=BF=D0=B0=D1=80=D0=B0=D0=BC?= =?UTF-8?q?=D0=B5=D1=82=D1=80=D0=B0=D1=85=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../clusterAdminLibrary/BackgroundTask.java | 8 +-- .../BackgroundTaskParams.java | 51 +++++++++++++++++++ .../clusterAdminLibraryUI/messages.properties | 8 +-- .../messages_ru_RU.properties | 8 +-- 4 files changed, 65 insertions(+), 10 deletions(-) diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java index b798eba..9f486f7 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java @@ -117,16 +117,16 @@ public BackgroundTask(V8ActionVariant v8ActionVariant) { switch (v8ActionVariant) { case SAVE_CF: - this.scriptText = String.join(" ", this.scriptText, "/DumpCfg %v8FilePath%.cf"); + this.scriptText = String.join(" ", this.scriptText, "/DumpCfg %v8FilePath.cf%"); break; case LOAD_CF: - this.scriptText = String.join(" ", this.scriptText, "/LoadCfg %v8FilePath%.cf"); + this.scriptText = String.join(" ", this.scriptText, "/LoadCfg %v8FilePath.cf%"); break; case SAVE_DT: - this.scriptText = String.join(" ", this.scriptText, "/DumpIB %v8FilePath%.dt"); + this.scriptText = String.join(" ", this.scriptText, "/DumpIB %v8FilePath.dt%"); break; case LOAD_DT: - this.scriptText = String.join(" ", this.scriptText, "/RestoreIB %v8FilePath%.dt"); + this.scriptText = String.join(" ", this.scriptText, "/RestoreIB %v8FilePath.dt%"); break; default: diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/BackgroundTaskParams.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/BackgroundTaskParams.java index d40866e..2e8432f 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/BackgroundTaskParams.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/BackgroundTaskParams.java @@ -1,5 +1,6 @@ package ru.yanygin.clusterAdminLibraryUI; +import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -10,6 +11,7 @@ import org.eclipse.jface.viewers.CellEditor; import org.eclipse.jface.viewers.ColumnLabelProvider; import org.eclipse.jface.viewers.ComboBoxCellEditor; +import org.eclipse.jface.viewers.DialogCellEditor; import org.eclipse.jface.viewers.EditingSupport; import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.jface.viewers.TableViewer; @@ -23,6 +25,7 @@ import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.FileDialog; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableColumn; @@ -40,6 +43,8 @@ public class BackgroundTaskParams extends Dialog { private Map infobasesCredentials = new HashMap<>(); private List usernames = new ArrayList<>(); private String currentUsernameValue = ""; + private String currentFilenameExt = ""; + private String currentFilepath = ""; /** * Создание диалога ввода имени пользователя и пароля. @@ -174,11 +179,28 @@ protected boolean isPasswordParam(String e) { return e.equals(PASSWORD_TITLE); } + protected boolean isFilepathParam(String[] e) { + + if (e[0].toLowerCase().contains("filepath.cf")) { + currentFilenameExt = "*.cf"; + currentFilepath = e[1]; + return true; + } + if (e[0].toLowerCase().contains("filepath.dt")) { + currentFilenameExt = "*.dt"; + currentFilepath = e[1]; + return true; + } + + return false; + } + class TableViewerEditingSupport extends EditingSupport { private TableViewer viewer; private TextCellEditor textEditor; private ComboBoxCellEditor usernameEditor; + private DialogCellEditor filenameEditor; public TableViewerEditingSupport(TableViewer viewer) { super(viewer); @@ -188,6 +210,30 @@ public TableViewerEditingSupport(TableViewer viewer) { new ComboBoxCellEditor( viewer.getTable(), usernames.toArray(new String[0]), SWT.SINGLE | SWT.BORDER); + filenameEditor = + new DialogCellEditor(viewer.getTable()) { + @Override + protected Object openDialogBox(Control cellEditorWindow) { + + final String[] filterNames = {String.format(Strings.FILTER_NAME, currentFilenameExt)}; + final String[] filterExt = {currentFilenameExt}; + + FileDialog dialog = new FileDialog(cellEditorWindow.getShell(), SWT.OPEN); + if (currentFilepath.isBlank()) { + dialog.setFileName(currentFilenameExt); + } else { + File file = new File(currentFilepath); + dialog.setFileName(file.getName()); + dialog.setFilterPath(file.getPath()); + } + dialog.setText(Strings.TITLE_FILEDIALOG); + dialog.setFilterNames(filterNames); + dialog.setFilterExtensions(filterExt); + + return dialog.open(); + } + }; + this.viewer = viewer; } @@ -206,6 +252,8 @@ protected CellEditor getCellEditor(Object element) { if (isUsernameParam(e[0])) { return usernameEditor; + } else if (isFilepathParam(e)) { + return filenameEditor; } else { return textEditor; } @@ -294,6 +342,9 @@ private static class Strings { static final String TITLE_PARAMNAME = getString("ParamName"); static final String TITLE_PARAMVALUE = getString("ParamValue"); + static final String TITLE_FILEDIALOG = getString("TitleFileDialog"); + static final String FILTER_NAME = getString("FilterName"); + static String getString(String key) { return Messages.getString("BackgroundTaskParams." + key); } diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties index a558ee2..7a6372d 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties @@ -14,9 +14,11 @@ AboutDialog.MainTitle = OneS Cluster Admin AboutDialog.Telegram_Description = Telegram:\r\n%s AboutDialog.TitleDialog = About -BackgroundTaskParams.ParamName = Param name -BackgroundTaskParams.ParamValue = Value -BackgroundTaskParams.Title = Set params for task: +BackgroundTaskParams.FilterName = Files 1C (%s) +BackgroundTaskParams.ParamName = Param name +BackgroundTaskParams.ParamValue = Value +BackgroundTaskParams.Title = Set params for task: +BackgroundTaskParams.TitleFileDialog = Specify the location and file name ClusterDialog.AcceptableDeviationOfTheNumberOfServerErrors = Acceptable deviation of the\r\nnumber of server errors (%) ClusterDialog.ClusterName = Cluster name diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties index 0be74f1..fb1a02e 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties @@ -14,9 +14,11 @@ AboutDialog.MainTitle = OneS Cluster Admin AboutDialog.Telegram_Description = Telegram:\r\n%s AboutDialog.TitleDialog = \u041E \u043F\u0440\u043E\u0433\u0440\u0430\u043C\u043C\u0435 -BackgroundTaskParams.ParamName = \u0418\u043C\u044F \u043F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u0430 -BackgroundTaskParams.ParamValue = \u0417\u043D\u0430\u0447\u0435\u043D\u0438\u0435 -BackgroundTaskParams.Title = \u0423\u0441\u0442\u0430\u043D\u043E\u0432\u043A\u0430 \u043F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u043E\u0432 \u0434\u043B\u044F \u0437\u0430\u0434\u0430\u0447\u0438: +BackgroundTaskParams.FilterName = \u0424\u0430\u0439\u043B\u044B 1\u0421 (%s) +BackgroundTaskParams.ParamName = \u0418\u043C\u044F \u043F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u0430 +BackgroundTaskParams.ParamValue = \u0417\u043D\u0430\u0447\u0435\u043D\u0438\u0435 +BackgroundTaskParams.Title = \u0423\u0441\u0442\u0430\u043D\u043E\u0432\u043A\u0430 \u043F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u043E\u0432 \u0434\u043B\u044F \u0437\u0430\u0434\u0430\u0447\u0438: +BackgroundTaskParams.TitleFileDialog = \u0423\u043A\u0430\u0436\u0438\u0442\u0435 \u0440\u0430\u0441\u043F\u043E\u043B\u043E\u0436\u0435\u043D\u0438\u0435 \u0438 \u0438\u043C\u044F \u0444\u0430\u0439\u043B\u0430 ClusterDialog.AcceptableDeviationOfTheNumberOfServerErrors = \u0414\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u043E\u0435 \u043E\u0442\u043A\u043B\u043E\u043D\u0435\u043D\u0438\u0435 \u043A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u0430\r\n\u043E\u0448\u0438\u0431\u043E\u043A \u0441\u0435\u0440\u0432\u0435\u0440\u0430 (%) ClusterDialog.ClusterName = \u0418\u043C\u044F \u043A\u043B\u0430\u0441\u0442\u0435\u0440\u0430 From 6f4bf3918ec7b81a9622ffd5a6c335d4b09e2c2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Sun, 13 Aug 2023 12:27:26 +0300 Subject: [PATCH 18/70] =?UTF-8?q?=D0=9D=D0=B0=D0=B1=D1=80=D0=BE=D1=81?= =?UTF-8?q?=D0=BE=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yanygin/clusterAdminLibrary/Helper.java | 18 ++++- .../clusterAdminLibraryUI/InfobaseDialog.java | 75 ++++++++++++++++++- 2 files changed, 88 insertions(+), 5 deletions(-) diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java index 454eb5c..f95a769 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java @@ -23,6 +23,8 @@ public class Helper { private static final Logger LOGGER = LoggerFactory.getLogger("ClusterProvider"); //$NON-NLS-1$ + private static final DateFormat simpleDateFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"); + private static final DateFormat reverseDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); /** Пустой UUID. */ public static final UUID EMPTY_UUID = @@ -281,8 +283,20 @@ public static String dateToString(Date date) { if (date == null || date.equals(emptyDate)) { return ""; } + return simpleDateFormat.format(date); + } - DateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"); // $NON-NLS-1$ - return dateFormat.format(date); + /** + * Преобразует дату к строке ("yyyy-MM-dd hh:MM:ss"). + * + * @param date - Дата + * @return Дата строкой + */ + public static String dateToStringReverse(Date date) { + Date emptyDate = new Date(0); + if (date == null || date.equals(emptyDate)) { + return ""; + } + return reverseDateFormat.format(date); } } diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/InfobaseDialog.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/InfobaseDialog.java index 676193f..5770b71 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/InfobaseDialog.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/InfobaseDialog.java @@ -5,7 +5,9 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Calendar; import java.util.Date; +import java.util.GregorianCalendar; import java.util.List; import java.util.UUID; import org.eclipse.jface.dialogs.Dialog; @@ -16,10 +18,12 @@ import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.layout.RowLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.DateTime; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; @@ -66,6 +70,10 @@ public class InfobaseDialog extends Dialog { private Button btnSheduledJobsDenied; private Button btnAllowDistributeLicense; private Button btnExternalSessionManagerRequired; + private DateTime deniedFrom_Date; + private DateTime deniedFrom_Time; + private Button btnDeniedStartEdit; + private Button btnDeniedStartClear; /** * Create the dialog. @@ -192,10 +200,53 @@ protected Control createDialogArea(Composite parent) { lblDeniedFrom.setText(Strings.SESSIONS_DENIED_FROM); Composite compositeDeniedFrom = new Composite(container, SWT.NONE); - compositeDeniedFrom.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); - compositeDeniedFrom.setLayout(new FillLayout(SWT.HORIZONTAL)); + compositeDeniedFrom.setLayout(new RowLayout(SWT.HORIZONTAL)); - deniedFromDate = new Text(compositeDeniedFrom, SWT.BORDER | SWT.DATE | SWT.DROP_DOWN); + deniedFromDate = new Text(compositeDeniedFrom, SWT.BORDER); + + deniedFrom_Date = new DateTime(compositeDeniedFrom, SWT.BORDER | SWT.DROP_DOWN); + deniedFrom_Date.addSelectionListener( + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + + Calendar calendar = + new GregorianCalendar( + deniedFrom_Date.getYear(), + deniedFrom_Date.getMonth(), + deniedFrom_Date.getDay(), + deniedFrom_Time.getHours(), + deniedFrom_Time.getMinutes(), + deniedFrom_Time.getSeconds()); + + deniedFromDate.setText(Helper.dateToStringReverse(calendar.getTime())); + } + }); + deniedFrom_Time = new DateTime(compositeDeniedFrom, SWT.BORDER | SWT.TIME); + + btnDeniedStartEdit = new Button(compositeDeniedFrom, SWT.NONE); + btnDeniedStartEdit.addSelectionListener( + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + deniedFrom_Date.setVisible(true); + deniedFrom_Time.setVisible(true); + deniedFromDate.setVisible(false); + } + }); + btnDeniedStartEdit.setText("..."); + + btnDeniedStartClear = new Button(compositeDeniedFrom, SWT.NONE); + btnDeniedStartClear.addSelectionListener( + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + deniedFrom_Date.setVisible(false); + deniedFrom_Time.setVisible(false); + deniedFromDate.setVisible(true); + } + }); + btnDeniedStartClear.setText("x"); Label lblDeniedTo = new Label(container, SWT.NONE); lblDeniedTo.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); @@ -292,7 +343,25 @@ private void initProperties() { // Lock properties btnSessionsDenied.setSelection(infoBaseInfo.isSessionsDenied()); + + boolean dateIsEmpty = infoBaseInfo.getDeniedFrom().equals(emptyDate); + + deniedFromDate.setVisible(dateIsEmpty); + deniedFrom_Date.setVisible(!dateIsEmpty); + deniedFrom_Time.setVisible(!dateIsEmpty); + deniedFromDate.setText(convertDateToString(infoBaseInfo.getDeniedFrom())); + if (!dateIsEmpty) { + deniedFrom_Date.setDate( + infoBaseInfo.getDeniedFrom().getYear(), + infoBaseInfo.getDeniedFrom().getMonth(), + infoBaseInfo.getDeniedFrom().getDay()); + deniedFrom_Time.setTime( + infoBaseInfo.getDeniedFrom().getHours(), + infoBaseInfo.getDeniedFrom().getMinutes(), + infoBaseInfo.getDeniedFrom().getSeconds()); + } + deniedToDate.setText(convertDateToString(infoBaseInfo.getDeniedTo())); txtDeniedMessage.setText(infoBaseInfo.getDeniedMessage()); From d3bdba21c18e786fae2b3084ea06d7d70445061d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Thu, 4 Jan 2024 12:25:37 +0300 Subject: [PATCH 19/70] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BA=D0=BE=D0=BC=D0=B0=D0=BD=D0=B4?= =?UTF-8?q?=D1=8B=20=D0=B2=20=D0=BC=D0=B5=D0=BD=D1=8E=20=D0=BA=D0=BB=D0=B0?= =?UTF-8?q?=D1=81=D1=82=D0=B5=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../clusterAdminLibraryUI/ViewerArea.java | 60 +++++++++++++++++++ .../WorkingServerDialog.java | 1 + .../clusterAdminLibraryUI/messages.properties | 1 + .../messages_ru_RU.properties | 1 + 4 files changed, 63 insertions(+) diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java index 8e03274..cbcbe95 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java @@ -509,6 +509,10 @@ private void initClusterMenu() { addMenuSeparator(clusterMenu); addItemInMenu( clusterMenu, Strings.CONTEXT_MENU_DELETE_CLUSTER, deleteIcon16, deleteClusterListener); + + addMenuSeparator(clusterMenu); + addItemInMenu( + clusterMenu, Strings.CONTEXT_MENU_RESTART_PROCESSES, null, restartWorkingProcessesListener); } private void initWorkingServerMenu() { @@ -2093,6 +2097,61 @@ public void widgetSelected(SelectionEvent event) { } }; + SelectionAdapter restartWorkingProcessesListener = + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent event) { + TreeItem[] item = serversTree.getSelection(); + if (item.length == 0) { + return; + } + final TreeItem clusterItem = item[0]; + + Server server = getServer(clusterItem); + UUID clusterId = getClusterId(clusterItem); + if (server == null || clusterId == null) { + return; + } + + Thread thread = + new Thread( + () -> { + IClusterInfo clusterInfo = server.getClusterInfo(clusterId); + + final int oldLifeTimeLimit = clusterInfo.getLifeTimeLimit(); + final boolean oldRecyclingKillProcesses = + clusterInfo.isClusterRecyclingKillProblemProcesses(); + final int oldExpirationTimeout = clusterInfo.getExpirationTimeout(); + + clusterInfo.setLifeTimeLimit(10); + clusterInfo.setClusterRecyclingKillProblemProcesses(true); + clusterInfo.setExpirationTimeout(20); + + if (!server.regCluster(clusterInfo)) { + Helper.showMessageBox("Error edit cluster"); + } + + // подождать 10 секунд и вернуть все назад + try { + Thread.sleep(10000); + } catch (InterruptedException excp) { + LOGGER.error("Error: ", excp); // $NON-NLS-1$ + } + + clusterInfo.setLifeTimeLimit(oldLifeTimeLimit); + + clusterInfo.setClusterRecyclingKillProblemProcesses(oldRecyclingKillProcesses); + clusterInfo.setExpirationTimeout(oldExpirationTimeout); + + if (!server.regCluster(clusterInfo)) { + Helper.showMessageBox("Error edit cluster"); + } + }); + + thread.start(); + } + }; + SelectionAdapter createInfobaseListener = // TODO вызывается из контекстного меню и из тулбара // нет ли ошибки serversTree.getSelection() при вызове из тулбара @@ -3302,6 +3361,7 @@ private static class Strings { static final String CONTEXT_MENU_CREATE_CLUSTER = getString("ContextMenu.CreateCluster"); static final String CONTEXT_MENU_EDIT_CLUSTER = getString("ContextMenu.EditCluster"); static final String CONTEXT_MENU_DELETE_CLUSTER = getString("ContextMenu.DeleteCluster"); + static final String CONTEXT_MENU_RESTART_PROCESSES = getString("ContextMenu.RestartProcesses"); static final String CONTEXT_MENU_CREATE_WORKING_SERVER = getString("ContextMenu.CreateWorkingServer"); diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/WorkingServerDialog.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/WorkingServerDialog.java index f98e6e6..52b3431 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/WorkingServerDialog.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/WorkingServerDialog.java @@ -72,6 +72,7 @@ public class WorkingServerDialog extends Dialog { * @param server - server * @param clusterId - cluster ID * @param workingServerId - working server ID (null для создания нового) + * @wbp.parser.constructor */ public WorkingServerDialog( Shell parentShell, Server server, UUID clusterId, UUID workingServerId) { diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties index a1703d3..c3cd2fd 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties @@ -174,6 +174,7 @@ ViewerArea.ContextMenu.OrderInfobasesByFaforitesAndName = By favorites/name ViewerArea.ContextMenu.OrderInfobasesByName = By name ViewerArea.ContextMenu.OrganizeServers = Sort everything ViewerArea.ContextMenu.RemoveServer = Remove server +ViewerArea.ContextMenu.RestartProcesses = Restart working processes ViewerArea.ContextMenu.SessionManage = Session manage ViewerArea.ContextMenu.ShowConnectionError = Show connection error ViewerArea.ContextMenu.TerminateAllSessions = Terminate all sessions diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties index 27dcab1..857c1f0 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties @@ -174,6 +174,7 @@ ViewerArea.ContextMenu.OrderInfobasesByFaforitesAndName = \u041F\u043E \u0438\u0 ViewerArea.ContextMenu.OrderInfobasesByName = \u041F\u043E \u0438\u043C\u0435\u043D\u0438 ViewerArea.ContextMenu.OrganizeServers = \u041E\u0442\u0441\u043E\u0440\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u0432\u0441\u0435 ViewerArea.ContextMenu.RemoveServer = \u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0441\u0435\u0440\u0432\u0435\u0440 +ViewerArea.ContextMenu.RestartProcesses = \u041F\u0435\u0440\u0435\u0437\u0430\u043F\u0443\u0441\u0442\u0438\u0442\u044C \u0440\u0430\u0431\u043E\u0447\u0438\u0435 \u043F\u0440\u043E\u0446\u0435\u0441\u0441\u044B ViewerArea.ContextMenu.SessionManage = \u0423\u043F\u0440\u0430\u0432\u043B\u0435\u043D\u0438\u0435 \u0441\u0435\u0430\u043D\u0441\u0430\u043C\u0438 ViewerArea.ContextMenu.ShowConnectionError = \u041F\u043E\u043A\u0430\u0437\u0430\u0442\u044C \u043E\u0448\u0438\u0431\u043A\u0443 \u043F\u043E\u0434\u043A\u043B\u044E\u0447\u0435\u043D\u0438\u044F ViewerArea.ContextMenu.TerminateAllSessions = \u0417\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u044C \u0432\u0441\u0435 \u0441\u0435\u0430\u043D\u0441\u044B From e5d487ed08ead748ac06c171ca538938836bd143 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Thu, 4 Jan 2024 19:10:51 +0300 Subject: [PATCH 20/70] =?UTF-8?q?=D0=98=D0=BC=D0=BF=D0=BE=D1=80=D1=82=20?= =?UTF-8?q?=D0=BD=D0=BE=D0=B2=D1=8B=D1=85=20=D1=81=D0=B5=D1=80=D0=B2=D0=B5?= =?UTF-8?q?=D1=80=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yanygin/clusterAdminLibrary/Config.java | 39 +++++++++++--- .../yanygin/clusterAdminLibrary/Helper.java | 52 +++++++++++++++++++ .../clusterAdminLibraryUI/ViewerArea.java | 14 +++-- 3 files changed, 89 insertions(+), 16 deletions(-) diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java index 2d692c4..01e8008 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java @@ -1,5 +1,7 @@ package ru.yanygin.clusterAdminLibrary; +import ch.qos.logback.classic.Level; +import ch.qos.logback.classic.Logger; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonIOException; @@ -20,7 +22,8 @@ import java.net.HttpURLConnection; import java.net.URL; import java.nio.charset.StandardCharsets; -import java.util.ArrayList; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.HashMap; import java.util.List; import java.util.Locale; @@ -34,8 +37,6 @@ import org.eclipse.swt.widgets.Shell; import org.json.JSONArray; import org.json.JSONObject; -import ch.qos.logback.classic.Level; -import ch.qos.logback.classic.Logger; import org.slf4j.LoggerFactory; import ru.yanygin.clusterAdminLibrary.ColumnProperties.RowSortDirection; import ru.yanygin.clusterAdminLibrary.InfoBaseInfoShortExt.InfobasesSortDirection; @@ -135,6 +136,10 @@ public class Config { @Expose private Map servers = new HashMap<>(); + @SerializedName("IbasesPath") + @Expose + private String ibasesPath = ""; + @SerializedName("SessionColumnProperties") @Expose private ColumnProperties sessionColumnProperties = new ColumnProperties(0); @@ -473,11 +478,11 @@ public void close() { * @param newServers - список новых серверов * @return список серверов, которые были реально добавлены */ - public List addNewServers(List newServers) { + public Map addNewServers(List newServers) { // Пакетное добавление серверов в список, предполагается для механизма импорта из списка // информационных баз - List addedServers = new ArrayList<>(); + Map addedServers = new HashMap<>(); // Имя сервера, которое приходит сюда не равно Представлению сервера, выводимому в списке // Имя сервера. оно же Key в map и json, строка вида Server:1541, с обязательным указанием порта @@ -485,11 +490,16 @@ public List addNewServers(List newServers) { // если порт менеджера не задан - ставим стандартный 1541 // переделать for (String serverName : newServers) { - if (!servers.containsKey(serverName)) { + String[] adr = serverName.split(":"); // $NON-NLS-1$ + String agentHost = adr[0]; + int agentPort = Integer.parseInt(adr[1]) - 1; + String serverNameAgentPort = agentHost.concat(":").concat(Integer.toString(agentPort)); + + if (!servers.containsKey(serverNameAgentPort)) { Server serverConfig = new Server(serverName); - servers.put(serverName, serverConfig); + servers.put(serverNameAgentPort, serverConfig); - addedServers.add(serverName); + addedServers.put(serverNameAgentPort, serverConfig); } } @@ -907,6 +917,19 @@ public void setListRrefreshRate(int refreshRate) { this.listRefreshRate = refreshRate; } + /** + * Получить путь к файлу со списком информационных баз. + * + * @return Путь к списку информационных баз + */ + public Path getIbasesPath() { + if (ibasesPath.isBlank()) { + return Paths.get(System.getenv("USERPROFILE"), "appdata\\roaming\\1c\\1cestart\\ibases.v8i"); + } else { + return Paths.get(ibasesPath); + } + } + /** * Получение свойства колонок списков. * diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java index 454eb5c..725849b 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java @@ -1,15 +1,22 @@ package ru.yanygin.clusterAdminLibrary; +import java.io.BufferedReader; import java.io.File; +import java.io.FileReader; import java.io.FilenameFilter; +import java.io.IOException; import java.nio.file.Path; import java.nio.file.Paths; import java.text.DateFormat; import java.text.SimpleDateFormat; +import java.util.ArrayList; import java.util.Date; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.UUID; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Image; @@ -285,4 +292,49 @@ public static String dateToString(Date date) { DateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"); // $NON-NLS-1$ return dateFormat.format(date); } + + /** Ищет новые сервера в файле списка инфобаз v8i. */ + public static Map findNewServers() { + List foundServers = new ArrayList<>(); + + Path ibasesPath = Config.currentConfig.getIbasesPath(); + String ibasesText = ""; + + if (ibasesPath.toFile().exists()) { + try (BufferedReader br = new BufferedReader(new FileReader(ibasesPath.toFile()))) { + StringBuilder sb = new StringBuilder(); + String line = br.readLine(); + while (line != null) { + sb.append(line); + sb.append(System.lineSeparator()); + line = br.readLine(); + } + ibasesText = sb.toString(); + } catch (IOException excp) { + LOGGER.error("Error: ", excp); // $NON-NLS-1$ + return new HashMap<>(); + } + } + + Pattern p = Pattern.compile("Srvr=\"(.*?)\";Ref"); + Matcher m = p.matcher(ibasesText); + while (m.find()) { + String serverAddress = m.group(1).toLowerCase(); + + String[] adr = serverAddress.split(":"); // $NON-NLS-1$ + String agentHost = adr[0]; + + int agentPort; + if (adr.length == 1) { + agentPort = 1541; + serverAddress = agentHost.concat(":").concat(Integer.toString(agentPort)); + } + + if (!foundServers.contains(serverAddress)) { + foundServers.add(serverAddress); + } + } + + return Config.currentConfig.addNewServers(foundServers); + } } diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java index 8e03274..96a4d41 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java @@ -387,8 +387,7 @@ private void initMainMenu(Menu mainMenu) { } Menu serversGroup = addItemGroupInMenu(mainMenu, Strings.MENU_SERVERS, null); - addItemInMenu(serversGroup, Strings.MENU_FIND_SERVERS, null, findNewServersListener) - .setEnabled(false); + addItemInMenu(serversGroup, Strings.MENU_FIND_SERVERS, null, findNewServersListener); addItemInMenu(serversGroup, Strings.MENU_CONNECT_ALL_SERVERS, null, connectAllServersListener); addItemInMenu( serversGroup, Strings.MENU_DISCONNECT_ALL_SERVERS, null, disconnectAllServersListener); @@ -1160,10 +1159,6 @@ private void disconnectServerItem(TreeItem serverItem) { Arrays.stream(serverItem.getItems()).forEach(Widget::dispose); } - private void fillServersList() { - // TODO Auto-generated method stub - } - private void updateClustersInTree(TreeItem serverItem) { Server server = getServer(serverItem); @@ -1630,9 +1625,12 @@ public void widgetSelected(SelectionEvent e) { new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - List newServers = clusterProvider.findNewServers(); + Map newServers = Helper.findNewServers(); if (!newServers.isEmpty()) { - fillServersList(); + newServers.forEach( + (serverKey, server) -> { + addServerItemInServersTree(server); + }); } } }; From 3a0c7a79340ed6fb381fd6761e443051b29f4559 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Fri, 5 Jan 2024 17:50:22 +0300 Subject: [PATCH 21/70] =?UTF-8?q?=D0=98=D0=BC=D0=BF=D0=BE=D1=80=D1=82=20?= =?UTF-8?q?=D0=B8=D0=B7=20=D1=88=D1=82=D0=B0=D1=82=D0=BD=D0=BE=D0=B9=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=BD=D1=81=D0=BE=D0=BB=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yanygin/clusterAdminLibrary/Config.java | 2 +- .../yanygin/clusterAdminLibrary/Helper.java | 83 +++++++++++++------ 2 files changed, 59 insertions(+), 26 deletions(-) diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java index 01e8008..40befc2 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java @@ -924,7 +924,7 @@ public void setListRrefreshRate(int refreshRate) { */ public Path getIbasesPath() { if (ibasesPath.isBlank()) { - return Paths.get(System.getenv("USERPROFILE"), "appdata\\roaming\\1c\\1cestart\\ibases.v8i"); + return Paths.get(System.getenv("APPDATA"), "1c\\1cestart\\ibases.v8i"); } else { return Paths.get(ibasesPath); } diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java index 725849b..5e538b4 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java @@ -297,44 +297,77 @@ public static String dateToString(Date date) { public static Map findNewServers() { List foundServers = new ArrayList<>(); + // Читаем файл со списком инфобаз стартера Path ibasesPath = Config.currentConfig.getIbasesPath(); - String ibasesText = ""; + String ibasesText = readTextFile(ibasesPath); - if (ibasesPath.toFile().exists()) { - try (BufferedReader br = new BufferedReader(new FileReader(ibasesPath.toFile()))) { - StringBuilder sb = new StringBuilder(); - String line = br.readLine(); - while (line != null) { - sb.append(line); - sb.append(System.lineSeparator()); - line = br.readLine(); + if (!ibasesText.isBlank()) { + + Pattern p = Pattern.compile("Srvr=\"(.*?)\";Ref"); + Matcher m = p.matcher(ibasesText); + while (m.find()) { + String serverAddress = m.group(1).toLowerCase(); + + String[] adr = serverAddress.split(":"); // $NON-NLS-1$ + String agentHost = adr[0]; + + int agentPort; + if (adr.length == 1) { + agentPort = 1541; + serverAddress = agentHost.concat(":").concat(Integer.toString(agentPort)); + } + + if (!foundServers.contains(serverAddress)) { + foundServers.add(serverAddress); } - ibasesText = sb.toString(); - } catch (IOException excp) { - LOGGER.error("Error: ", excp); // $NON-NLS-1$ - return new HashMap<>(); } } - Pattern p = Pattern.compile("Srvr=\"(.*?)\";Ref"); - Matcher m = p.matcher(ibasesText); - while (m.find()) { - String serverAddress = m.group(1).toLowerCase(); + // читаем файл со списком серверов зарегистрированных в штатной консоли + Path srvPath = Paths.get(System.getenv("LOCALAPPDATA"), "1c\\1cv8\\appsrvrs.lst"); + String srvText = readTextFile(srvPath); - String[] adr = serverAddress.split(":"); // $NON-NLS-1$ - String agentHost = adr[0]; + if (!srvText.isBlank()) { + Pattern p = Pattern.compile("\\{\"tcp\",(.*,.*?),.*\\}"); + Matcher m = p.matcher(srvText); + while (m.find()) { + String serverAddress = m.group(1).toLowerCase(); - int agentPort; - if (adr.length == 1) { - agentPort = 1541; + String[] adr = serverAddress.split(","); // $NON-NLS-1$ + String agentHost = adr[0].replace("\"", ""); + int agentPort = Integer.parseInt(adr[1]) + 1; serverAddress = agentHost.concat(":").concat(Integer.toString(agentPort)); - } - if (!foundServers.contains(serverAddress)) { - foundServers.add(serverAddress); + if (!foundServers.contains(serverAddress)) { + foundServers.add(serverAddress); + } } } + + if (foundServers.isEmpty()) { + return new HashMap<>(); + } return Config.currentConfig.addNewServers(foundServers); } + + private static String readTextFile(Path textFile) { + if (textFile.toFile().exists()) { + try (BufferedReader br = new BufferedReader(new FileReader(textFile.toFile()))) { + StringBuilder sb = new StringBuilder(); + String line = br.readLine(); + while (line != null) { + sb.append(line); + sb.append(System.lineSeparator()); + line = br.readLine(); + } + return sb.toString(); + } catch (IOException excp) { + LOGGER.error("Error: ", excp); // $NON-NLS-1$ + return ""; + } + } + + return ""; + } } From 84d0dc4c555c7ff6b45f1aa1c2c47fe624d2f64e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Fri, 12 Jan 2024 16:17:42 +0300 Subject: [PATCH 22/70] =?UTF-8?q?=D0=A2=D0=BE=D0=BB=D1=8C=D0=BA=D0=BE=20?= =?UTF-8?q?=D0=B2=D1=80=D0=B5=D0=BC=D1=8F=20=D0=B2=20=D1=82=D0=B5=D0=BA?= =?UTF-8?q?=D1=83=D1=89=D0=B5=D0=B9=20=D0=B4=D0=B0=D1=82=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yanygin/clusterAdminLibrary/Config.java | 22 +++++++++++++++++++ .../yanygin/clusterAdminLibrary/Helper.java | 12 ++++++++-- .../clusterAdminLibraryUI/SettingsDialog.java | 9 +++++++- .../clusterAdminLibraryUI/messages.properties | 1 + .../messages_ru_RU.properties | 1 + 5 files changed, 42 insertions(+), 3 deletions(-) diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java index 2d692c4..b5c4c2f 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java @@ -131,6 +131,10 @@ public class Config { @Expose private String loggerLevel = "error"; + @SerializedName("ShowCurrentDateAsTime") + @Expose + private boolean showCurrentDateAsTime = false; + @SerializedName("Servers") @Expose private Map servers = new HashMap<>(); @@ -524,6 +528,24 @@ public void setCheckingUpdate(boolean checkingUpdate) { this.checkingUpdate = checkingUpdate; } + /** + * Показывать только время в текущей дате. + * + * @return текущее значение + */ + public boolean showCurrentDateAsTime() { + return showCurrentDateAsTime; + } + + /** + * Установка отображения только времени в текущей дате. + * + * @param showCurrentDateAsTime - новое значение + */ + public void setShowCurrentDateAsTime(boolean showCurrentDateAsTime) { + this.showCurrentDateAsTime = showCurrentDateAsTime; + } + /** * Получает список зарегистрированных серверов. * diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java index 454eb5c..1c5efa7 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java @@ -24,6 +24,11 @@ public class Helper { private static final Logger LOGGER = LoggerFactory.getLogger("ClusterProvider"); //$NON-NLS-1$ + private static final DateFormat normalDateFormat = + new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"); // $NON-NLS-1$ + private static final DateFormat currentDayDateFormat = + new SimpleDateFormat("HH:mm:ss"); // $NON-NLS-1$ + /** Пустой UUID. */ public static final UUID EMPTY_UUID = UUID.fromString("00000000-0000-0000-0000-000000000000"); //$NON-NLS-1$ @@ -282,7 +287,10 @@ public static String dateToString(Date date) { return ""; } - DateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"); // $NON-NLS-1$ - return dateFormat.format(date); + if (Config.currentConfig.showCurrentDateAsTime()) { + return currentDayDateFormat.format(date); + } else { + return normalDateFormat.format(date); + } } } diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/SettingsDialog.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/SettingsDialog.java index d5e974a..1d9d6d5 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/SettingsDialog.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/SettingsDialog.java @@ -44,6 +44,7 @@ public class SettingsDialog extends Dialog { private Button btnShadowSleepSessions; private Button btnReadClipboard; private Button btnCheckUpdate; + private Button btnShowCurrentDateAsTime; private Button btnRowSortAsPrevious; private Button btnRowSortAsc; private Button btnRowSortDesc; @@ -235,6 +236,9 @@ protected Control createDialogArea(Composite parent) { btnCheckUpdate = new Button(grpOther, SWT.CHECK); btnCheckUpdate.setText(Strings.CHECK_UPDATE); + + btnShowCurrentDateAsTime = new Button(grpOther, SWT.CHECK); + btnShowCurrentDateAsTime.setText(Strings.SHOW_CURRENT_DATE_AS_TIME); new Label(container, SWT.NONE); initProperties(); @@ -263,6 +267,7 @@ private void initProperties() { btnShadowSleepSessions.setSelection(config.isShadeSleepingSessions()); btnReadClipboard.setSelection(config.isReadClipboard()); btnCheckUpdate.setSelection(config.checkingUpdate()); + btnShowCurrentDateAsTime.setSelection(config.showCurrentDateAsTime()); final String locale = config.getLocale(); if (locale == null) { @@ -306,6 +311,7 @@ private void saveProperties() { config.setShadowSleepSessions(btnShadowSleepSessions.getSelection()); config.setReadClipboard(btnReadClipboard.getSelection()); config.setCheckingUpdate(btnCheckUpdate.getSelection()); + config.setShowCurrentDateAsTime(btnShowCurrentDateAsTime.getSelection()); if (btnLocaleSystem.getSelection()) { config.setLocale(null); @@ -402,7 +408,8 @@ private static class Strings { static final String READ_CLIPBOARD = getString("ReadClipboard"); static final String CHECK_UPDATE = getString("CheckUpdate"); - + static final String SHOW_CURRENT_DATE_AS_TIME = getString("ShowCurrentDateAsTime"); + static final String LOGGER_LEVEL_TITLE = getString("LoggerLevelTitle"); static String getString(String key) { diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties index a1703d3..0e8e10d 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties @@ -129,6 +129,7 @@ SettingsDialog.RowSortDirectionAscending = Descending SettingsDialog.RowSortDirectionDescending = Ascending SettingsDialog.RowSortDirectionTitle = Row sort direction SettingsDialog.ShadowSleepSessions = Shadow sleep sessions +SettingsDialog.ShowCurrentDateAsTime = Show current date as time SettingsDialog.ShowInfo = Additional info SettingsDialog.ShowInfobaseDescription = Show infobase description SettingsDialog.ShowLocalRASConnectInfo = About connecting via a local RAS diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties index 27dcab1..1154959 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties @@ -129,6 +129,7 @@ SettingsDialog.RowSortDirectionAscending = \u041F\u043E \u0443\u0431\u044B\u043 SettingsDialog.RowSortDirectionDescending = \u041F\u043E \u0432\u043E\u0437\u0440\u0430\u0441\u0442\u0430\u043D\u0438\u044E SettingsDialog.RowSortDirectionTitle = \u041D\u0430\u043F\u0440\u0430\u0432\u043B\u0435\u043D\u0438\u0435 \u0441\u043E\u0440\u0442\u0438\u0440\u043E\u0432\u043A\u0438 \u0441\u0442\u0440\u043E\u043A SettingsDialog.ShadowSleepSessions = \u0417\u0430\u0442\u0435\u043D\u044F\u0442\u044C \u0441\u043F\u044F\u0446\u0438\u0435 \u0441\u0435\u0430\u043D\u0441\u044B +SettingsDialog.ShowCurrentDateAsTime = \u041F\u043E\u043A\u0430\u0437\u044B\u0432\u0430\u0442\u044C \u0442\u043E\u043B\u044C\u043A\u043E \u0432\u0440\u0435\u043C\u044F \u0432 \u0442\u0435\u043A\u0443\u0449\u0438\u0445 \u0434\u0430\u0442\u0430\u0445 SettingsDialog.ShowInfo = \u0414\u043E\u043F\u043E\u043B\u043D\u0438\u0442\u0435\u043B\u044C\u043D\u0430\u044F \u0438\u043D\u0444\u043E\u0440\u043C\u0430\u0446\u0438\u044F SettingsDialog.ShowInfobaseDescription = \u041F\u043E\u043A\u0430\u0437\u044B\u0432\u0430\u0442\u044C \u043E\u043F\u0438\u0441\u0430\u043D\u0438\u0435 \u0438\u043D\u0444\u043E\u0431\u0430\u0437\u044B SettingsDialog.ShowLocalRASConnectInfo = \u041E \u043F\u043E\u0434\u043A\u043B\u044E\u0447\u0435\u043D\u0438\u0438 \u0447\u0435\u0440\u0435\u0437 \u043B\u043E\u043A\u0430\u043B\u044C\u043D\u044B\u0439 RAS From 347116987273823b581fa951c1e13c5df89a06eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Wed, 17 Jan 2024 09:11:42 +0300 Subject: [PATCH 23/70] =?UTF-8?q?=D0=A1=D0=BB=D0=B5=D0=B6=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=B7=D0=B0=20=D1=81=D0=B5=D1=81=D1=81=D0=B8?= =?UTF-8?q?=D0=B5=D0=B9=20=D0=B2=20=D0=BA=D0=BE=D0=BD=D1=82=D0=B5=D0=BA?= =?UTF-8?q?=D1=81=D1=82=D0=BD=D0=BE=D0=B5=20=D0=BC=D0=B5=D0=BD=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../clusterAdminLibraryUI/ViewerArea.java | 17 +++++++++++++++++ .../clusterAdminLibraryUI/messages.properties | 1 + .../messages_ru_RU.properties | 1 + 3 files changed, 19 insertions(+) diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java index 8e03274..9851e10 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java @@ -674,6 +674,7 @@ private void initTableContextMenu( addItemInMenu(tableMenu, title, editIcon16, editItemInTablesListener); } + addItemInMenu(tableMenu, Strings.CONTEXT_MENU_WATCH_SESSION, null, switchWatchingMenuListener); addItemInMenu( tableMenu, Strings.CONTEXT_MENU_COPY_CELL_VALUE, null, copyCellValueInTablesListener); @@ -2749,6 +2750,21 @@ public void widgetSelected(SelectionEvent e) { } }; + SelectionAdapter switchWatchingMenuListener = + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + + TableItem[] selection = getCurrentTable().getSelection(); + if (selection.length > 0) { + TableItem item = selection[0]; + item.setChecked(!item.getChecked()); + SessionInfoExtended ext = (SessionInfoExtended) item.getData(EXTENDED_INFO); + ext.switchWatching(item, item.getChecked()); + } + } + }; + Listener switchWatchingListener = new Listener() { @Override @@ -3290,6 +3306,7 @@ private static class Strings { static final String CONTEXT_MENU_CREATE = getString("ContextMenu.Create"); static final String CONTEXT_MENU_EDIT = getString("ContextMenu.Edit"); static final String CONTEXT_MENU_DELETE = getString("ContextMenu.Delete"); + static final String CONTEXT_MENU_WATCH_SESSION = getString("ContextMenu.WatchSession"); static final String CONTEXT_MENU_COPY_CELL_VALUE = getString("ContextMenu.CopyCellValue").concat("\tCtrl+C"); static final String CONTEXT_MENU_ADD_SERVER = getString("ContextMenu.AddServer"); diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties index a1703d3..750a069 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties @@ -181,6 +181,7 @@ ViewerArea.ContextMenu.TerminateUsersSessions = Terminate users sessio ViewerArea.ContextMenu.Update = Update ViewerArea.ContextMenu.UpdateInfobases = Update infobases ViewerArea.ContextMenu.ViewSession = Session info +ViewerArea.ContextMenu.WatchSession = Watch session ViewerArea.DedicatedManagers = Dedicated managers ViewerArea.DeleteClusterQuestion = Deleting a cluster will delete its settings and the list of registered information databases. Do you really want to delete the cluster? ViewerArea.DeleteServerQuestion = Do you really want to remove the server from the list? diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties index 27dcab1..b641480 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties @@ -181,6 +181,7 @@ ViewerArea.ContextMenu.TerminateUsersSessions = \u0417\u0430\u0432\u04 ViewerArea.ContextMenu.Update = \u041E\u0431\u043D\u043E\u0432\u0438\u0442\u044C ViewerArea.ContextMenu.UpdateInfobases = \u041E\u0431\u043D\u043E\u0432\u0438\u0442\u044C \u0438\u043D\u0444\u043E\u0431\u0430\u0437\u044B ViewerArea.ContextMenu.ViewSession = \u0418\u043D\u0444\u043E\u0440\u043C\u0430\u0446\u0438\u044F \u043E \u0441\u0435\u0441\u0441\u0438\u0438 +ViewerArea.ContextMenu.WatchSession = \u0421\u043B\u0435\u0434\u0438\u0442\u044C \u0437\u0430 \u0441\u0435\u0430\u043D\u0441\u043E\u043C ViewerArea.DedicatedManagers = \u041C\u0435\u043D\u0435\u0434\u0436\u0435\u0440 \u043F\u043E\u0434 \u043A\u0430\u0436\u0434\u044B\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 ViewerArea.DeleteClusterQuestion = \u0423\u0434\u0430\u043B\u0435\u043D\u0438\u0435 \u043A\u043B\u0430\u0441\u0442\u0435\u0440\u0430 \u043F\u0440\u0438\u0432\u0435\u0434\u0435\u0442 \u043A \u0443\u0434\u0430\u043B\u0435\u043D\u0438\u044E \u0435\u0433\u043E \u043D\u0430\u0441\u0442\u0440\u043E\u0435\u043A \u0438 \u0441\u043F\u0438\u0441\u043A\u0430 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043E\u0432\u0430\u043D\u043D\u044B\u0445 \u0438\u043D\u0444\u043E\u0440\u043C\u0430\u0446\u0438\u043E\u043D\u043D\u044B\u0445 \u0431\u0430\u0437. \u0412\u044B \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043B\u044C\u043D\u043E \u0445\u043E\u0442\u0438\u0442\u0435 \u0443\u0434\u0430\u043B\u0438\u0442\u044C \u043A\u043B\u0430\u0441\u0442\u0435\u0440? ViewerArea.DeleteServerQuestion = \u0412\u044B \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043B\u044C\u043D\u043E \u0445\u043E\u0442\u0438\u0442\u0435 \u0443\u0434\u0430\u043B\u0438\u0442\u044C \u0441\u0435\u0440\u0432\u0435\u0440 \u0438\u0437 \u0441\u043F\u0438\u0441\u043A\u0430? From c9361fd3cd6ae5e0eabf16dc70a0d911a3a39121 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Wed, 31 Jan 2024 13:48:01 +0300 Subject: [PATCH 24/70] =?UTF-8?q?=D0=94=D0=B2=D0=B0=20=D0=B2=D0=B8=D0=B4?= =?UTF-8?q?=D0=B6=D0=B5=D1=82=D0=B0=20(=D0=B4=D0=B0=D1=82=D0=B0=20+=20?= =?UTF-8?q?=D0=B2=D1=80=D0=B5=D0=BC=D1=8F)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../clusterAdminLibraryUI/InfobaseDialog.java | 198 +++++++++++++----- 1 file changed, 147 insertions(+), 51 deletions(-) diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/InfobaseDialog.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/InfobaseDialog.java index 5770b71..95fd3b9 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/InfobaseDialog.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/InfobaseDialog.java @@ -15,6 +15,8 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.FontData; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; @@ -41,11 +43,16 @@ public class InfobaseDialog extends Dialog { private final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); //$NON-NLS-1$ private final Date emptyDate = new Date(0); + private Font fontNormal; + private Font fontMicro; private Server server; private UUID clusterId; private UUID infoBaseId; private boolean creationMode = false; + private boolean deniedEditNewMode = false; + private boolean deniedFromIsEmpty = true; + private boolean deniedToIsEmpty = true; // Controls private Text txtInfobaseName; @@ -59,9 +66,6 @@ public class InfobaseDialog extends Dialog { private Text txtExternalSessionManagerConnectionString; private Text txtSecurityProfile; private Text txtSafeModeSecurityProfile; - private Text txtDeniedMessage; - private Text deniedFromDate; - private Text deniedToDate; private Combo comboSecurityLevel; private Combo comboServerDbType; @@ -70,10 +74,16 @@ public class InfobaseDialog extends Dialog { private Button btnSheduledJobsDenied; private Button btnAllowDistributeLicense; private Button btnExternalSessionManagerRequired; - private DateTime deniedFrom_Date; - private DateTime deniedFrom_Time; - private Button btnDeniedStartEdit; + + private Text txtDeniedMessage; + private Text txtDeniedFromDate; + private DateTime deniedFromDate; + private DateTime deniedFromTime; + private Text txtDeniedToDate; + private Button btnDeniedSwitchMode; private Button btnDeniedStartClear; + private DateTime deniedToDate; + private DateTime deniedToTime; /** * Create the dialog. @@ -200,50 +210,67 @@ protected Control createDialogArea(Composite parent) { lblDeniedFrom.setText(Strings.SESSIONS_DENIED_FROM); Composite compositeDeniedFrom = new Composite(container, SWT.NONE); - compositeDeniedFrom.setLayout(new RowLayout(SWT.HORIZONTAL)); + compositeDeniedFrom.setLayout(null); - deniedFromDate = new Text(compositeDeniedFrom, SWT.BORDER); + txtDeniedFromDate = new Text(compositeDeniedFrom, SWT.BORDER); + txtDeniedFromDate.setBounds(0, 0, 165, 21); - deniedFrom_Date = new DateTime(compositeDeniedFrom, SWT.BORDER | SWT.DROP_DOWN); - deniedFrom_Date.addSelectionListener( + deniedFromDate = new DateTime(compositeDeniedFrom, SWT.BORDER | SWT.DROP_DOWN); + deniedFromDate.setBounds(0, 0, 91, 21); + deniedFromDate.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Calendar calendar = new GregorianCalendar( - deniedFrom_Date.getYear(), - deniedFrom_Date.getMonth(), - deniedFrom_Date.getDay(), - deniedFrom_Time.getHours(), - deniedFrom_Time.getMinutes(), - deniedFrom_Time.getSeconds()); - - deniedFromDate.setText(Helper.dateToStringReverse(calendar.getTime())); + deniedFromDate.getYear(), + deniedFromDate.getMonth(), + deniedFromDate.getDay(), + deniedFromTime.getHours(), + deniedFromTime.getMinutes(), + deniedFromTime.getSeconds()); + + deniedFromIsEmpty = false; + setDeniedFieldsState(); + + txtDeniedFromDate.setText(Helper.dateToStringReverse(calendar.getTime())); } }); - deniedFrom_Time = new DateTime(compositeDeniedFrom, SWT.BORDER | SWT.TIME); + + deniedFromTime = new DateTime(compositeDeniedFrom, SWT.BORDER | SWT.TIME); + deniedFromTime.setBounds(95, 0, 70, 21); - btnDeniedStartEdit = new Button(compositeDeniedFrom, SWT.NONE); - btnDeniedStartEdit.addSelectionListener( + btnDeniedSwitchMode = new Button(compositeDeniedFrom, SWT.NONE); + btnDeniedSwitchMode.setBounds(170, 0, 28, 21); + btnDeniedSwitchMode.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - deniedFrom_Date.setVisible(true); - deniedFrom_Time.setVisible(true); - deniedFromDate.setVisible(false); + deniedEditNewMode = !deniedEditNewMode; + + txtDeniedFromDate.setVisible(!deniedEditNewMode); + deniedFromDate.setVisible(deniedEditNewMode); + deniedFromTime.setVisible(deniedEditNewMode); + + txtDeniedToDate.setVisible(!deniedEditNewMode); + deniedToDate.setVisible(deniedEditNewMode); + deniedToTime.setVisible(deniedEditNewMode); } }); - btnDeniedStartEdit.setText("..."); + btnDeniedSwitchMode.setText("<=>"); btnDeniedStartClear = new Button(compositeDeniedFrom, SWT.NONE); + btnDeniedStartClear.setBounds(200, 0, 21, 21); btnDeniedStartClear.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - deniedFrom_Date.setVisible(false); - deniedFrom_Time.setVisible(false); - deniedFromDate.setVisible(true); + deniedFromIsEmpty = true; + deniedToIsEmpty = true; + setDeniedFieldsState(); + txtDeniedFromDate.setText(""); + txtDeniedToDate.setText(""); } }); btnDeniedStartClear.setText("x"); @@ -253,10 +280,37 @@ public void widgetSelected(SelectionEvent e) { lblDeniedTo.setText(Strings.SESSIONS_DENIED_TO); Composite compositeDeniedTo = new Composite(container, SWT.NONE); + compositeDeniedTo.setLayout(null); compositeDeniedTo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); - compositeDeniedTo.setLayout(new FillLayout(SWT.HORIZONTAL)); - deniedToDate = new Text(compositeDeniedTo, SWT.BORDER); + txtDeniedToDate = new Text(compositeDeniedTo, SWT.BORDER); + txtDeniedToDate.setBounds(0, 0, 165, 21); + + deniedToDate = new DateTime(compositeDeniedTo, SWT.BORDER | SWT.DROP_DOWN); + deniedToDate.setBounds(0, 0, 91, 21); + deniedToDate.addSelectionListener( + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + + Calendar calendar = + new GregorianCalendar( + deniedToDate.getYear(), + deniedToDate.getMonth(), + deniedToDate.getDay(), + deniedToDate.getHours(), + deniedToDate.getMinutes(), + deniedToDate.getSeconds()); + + deniedToIsEmpty = false; + setDeniedFieldsState(); + + txtDeniedToDate.setText(Helper.dateToStringReverse(calendar.getTime())); + } + }); + + deniedToTime = new DateTime(compositeDeniedTo, SWT.BORDER | SWT.TIME); + deniedToTime.setBounds(95, 0, 70, 21); Label lblDeniedMessage = new Label(container, SWT.NONE); lblDeniedMessage.setText(Strings.SESSIONS_DENIED_MESSAGE); @@ -313,6 +367,12 @@ public void widgetSelected(SelectionEvent e) { txtSafeModeSecurityProfile = new Text(container, SWT.BORDER); txtSafeModeSecurityProfile.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); + FontData fontData = deniedFromDate.getFont().getFontData()[0]; + fontNormal = + new Font( + getParentShell().getDisplay(), fontData.getName(), fontData.getHeight(), SWT.NORMAL); + fontMicro = new Font(getParentShell().getDisplay(), fontData.getName(), 1, SWT.NORMAL); + initProperties(); return container; @@ -344,25 +404,34 @@ private void initProperties() { // Lock properties btnSessionsDenied.setSelection(infoBaseInfo.isSessionsDenied()); - boolean dateIsEmpty = infoBaseInfo.getDeniedFrom().equals(emptyDate); - - deniedFromDate.setVisible(dateIsEmpty); - deniedFrom_Date.setVisible(!dateIsEmpty); - deniedFrom_Time.setVisible(!dateIsEmpty); - - deniedFromDate.setText(convertDateToString(infoBaseInfo.getDeniedFrom())); - if (!dateIsEmpty) { - deniedFrom_Date.setDate( - infoBaseInfo.getDeniedFrom().getYear(), - infoBaseInfo.getDeniedFrom().getMonth(), - infoBaseInfo.getDeniedFrom().getDay()); - deniedFrom_Time.setTime( - infoBaseInfo.getDeniedFrom().getHours(), - infoBaseInfo.getDeniedFrom().getMinutes(), - infoBaseInfo.getDeniedFrom().getSeconds()); + // для отладки, заменить на чтение из конфига + deniedEditNewMode = true; + + // Дата запрета входа Начальная + Date deniedFrom = infoBaseInfo.getDeniedFrom(); + deniedFromIsEmpty = deniedFrom.equals(emptyDate); + + txtDeniedFromDate.setText(convertDateToString(deniedFrom)); + if (!deniedFromIsEmpty) { + deniedFromDate.setDate( + deniedFrom.getYear() + 1900, deniedFrom.getMonth(), deniedFrom.getDate()); + deniedFromTime.setTime( + deniedFrom.getHours(), deniedFrom.getMinutes(), deniedFrom.getSeconds()); } + // Дата запрета входа начальная - deniedToDate.setText(convertDateToString(infoBaseInfo.getDeniedTo())); + // Дата запрета входа Конечная + Date deniedTo = infoBaseInfo.getDeniedTo(); + deniedToIsEmpty = deniedTo.equals(emptyDate); + + txtDeniedToDate.setText(convertDateToString(deniedTo)); + if (!deniedToIsEmpty) { + deniedToDate.setDate(deniedTo.getYear() + 1900, deniedTo.getMonth(), deniedTo.getDate()); + deniedToTime.setTime(deniedTo.getHours(), deniedTo.getMinutes(), deniedTo.getSeconds()); + } + // Дата запрета входа Конечная + + setDeniedFieldsState(); txtDeniedMessage.setText(infoBaseInfo.getDeniedMessage()); txtPermissionCode.setText(infoBaseInfo.getPermissionCode()); @@ -402,8 +471,8 @@ private boolean checkVariablesFromControls() { } List checksDateControls = new ArrayList<>(); - checksDateControls.add(deniedFromDate); - checksDateControls.add(deniedToDate); + checksDateControls.add(txtDeniedFromDate); + checksDateControls.add(txtDeniedToDate); for (Text control : checksDateControls) { if (control.getText().isBlank()) { @@ -445,8 +514,8 @@ private boolean saveInfobaseProperties() { // Lock properties infoBaseInfo.setSessionsDenied(btnSessionsDenied.getSelection()); - infoBaseInfo.setDeniedFrom(convertStringToDate(deniedFromDate.getText())); - infoBaseInfo.setDeniedTo(convertStringToDate(deniedToDate.getText())); + infoBaseInfo.setDeniedFrom(convertStringToDate(txtDeniedFromDate.getText())); + infoBaseInfo.setDeniedTo(convertStringToDate(txtDeniedToDate.getText())); infoBaseInfo.setDeniedMessage(txtDeniedMessage.getText()); infoBaseInfo.setPermissionCode(txtPermissionCode.getText()); @@ -488,6 +557,33 @@ private String convertDateToString(Date date) { return date.equals(emptyDate) ? EMPTY_STRING : dateFormat.format(date); } + private void setDeniedFieldsState() { + + if (deniedFromIsEmpty) { + deniedFromDate.setFont(fontMicro); + deniedFromTime.setFont(fontMicro); + } else { + deniedFromDate.setFont(fontNormal); + deniedFromTime.setFont(fontNormal); + } + + if (deniedToIsEmpty) { + deniedToDate.setFont(fontMicro); + deniedToTime.setFont(fontMicro); + } else { + deniedToDate.setFont(fontNormal); + deniedToTime.setFont(fontNormal); + } + + deniedFromDate.setVisible(deniedEditNewMode); + deniedFromTime.setVisible(deniedEditNewMode); + txtDeniedFromDate.setVisible(!deniedEditNewMode); + + deniedToDate.setVisible(deniedEditNewMode); + deniedToTime.setVisible(deniedEditNewMode); + txtDeniedToDate.setVisible(!deniedEditNewMode); + } + /** * Create contents of the button bar. * From 1efac54ed710214e90e173eebbb4a07a0886d48f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Tue, 13 Feb 2024 19:07:46 +0300 Subject: [PATCH 25/70] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=81=D1=82=D1=80=D0=BE=D0=BA?= =?UTF-8?q?=20=D0=B0=D1=83=D1=82=D0=B5=D0=BD=D1=82=D0=B8=D1=84=D0=B8=D0=BA?= =?UTF-8?q?=D0=B0=D1=86=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/ru/yanygin/clusterAdminLibrary/Server.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java index 1b2de36..fb44505 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java @@ -1013,8 +1013,8 @@ private boolean checkAutenticateAgent() { String[] rightStrings = { // TODO проверить английские варианты "Недостаточно прав пользователя на управление центральным сервером", "Администратор центрального сервера не аутентифицирован", - "The user's rights to manage the central server are insufficient", - "The administrator of the central server is not authenticated" + "The user's rights to manage the central server are insufficient", // не проверено + "Main server administrator is not authenticated" }; for (String rightString : rightStrings) { if (excp.getLocalizedMessage().contains(rightString)) { @@ -1175,8 +1175,8 @@ private boolean checkAutenticateCluster(UUID clusterId) { String[] rightStrings = { // TODO проверить английские варианты "Недостаточно прав пользователя на управление кластером", "Администратор кластера не аутентифицирован", - "Insufficient user rights to manage the cluster", - "The cluster administrator is not authenticated" + "Insufficient user rights to manage cluster", + "The cluster administrator is not authenticated" // не проверено }; for (String rightString : rightStrings) { if (excp.getLocalizedMessage().toLowerCase().contains(rightString.toLowerCase())) { From 8060ea167555b496ad7ef71373d68b144a98b99a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Thu, 15 Feb 2024 13:53:23 +0300 Subject: [PATCH 26/70] =?UTF-8?q?=D0=A0=D0=B5=D0=B4=D0=B0=D0=BA=D1=82?= =?UTF-8?q?=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=B0=D0=B4?= =?UTF-8?q?=D0=BC=D0=B8=D0=BD=D0=B8=D1=81=D1=82=D1=80=D0=B0=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=20=D0=BA=D0=BB=D0=B0=D1=81=D1=82=D0=B5=D1=80?= =?UTF-8?q?=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yanygin/clusterAdminLibrary/Server.java | 89 +++++- .../AdminEditDialog.java | 256 ++++++++++++++++ .../clusterAdminLibraryUI/AdminsDialog.java | 274 ++++++++++++++++++ .../clusterAdminLibraryUI/ViewerArea.java | 30 ++ .../clusterAdminLibraryUI/messages.properties | 13 + .../messages_ru_RU.properties | 13 + 6 files changed, 666 insertions(+), 9 deletions(-) create mode 100644 clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/AdminEditDialog.java create mode 100644 clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/AdminsDialog.java diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java index 1b2de36..6f46f04 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java @@ -1634,16 +1634,71 @@ public boolean unregCluster(UUID clusterId) { * @param clusterId - ID кластера * @return список администраторов кластера */ - private List getClusterAdmins(UUID clusterId) { + public List getClusterAdmins(UUID clusterId) { LOGGER.debug( - "Gets the list of cluster administrators in the cluster <{}>", //$NON-NLS-1$ + "Gets the list administrators in the cluster <{}>", //$NON-NLS-1$ clusterId); + if (!isConnected()) { + LOGGER.debug( + "The connection a cluster <{}> is not established", //$NON-NLS-1$ + clusterId); return new ArrayList<>(); } - // TODO - return null; + if (!checkAutenticateAgent()) { + return new ArrayList<>(); + } + + List clusterAdmins; + try { + clusterAdmins = agentConnection.getClusterAdmins(clusterId); + } catch (Exception excp) { + LOGGER.error( + "Error get cluster admins", //$NON-NLS-1$ + excp); + return new ArrayList<>(); + } + + return clusterAdmins; + } + + /** + * Регистрация нового или изменение существующего администратора кластера. + * + *

Требует аутентификации в кластере + * + * @param clusterId - ID кластера + * @param info - информация о администраторе + * @return {@code true} в случае успешной регистрации + */ + public boolean regClusterAdmin(UUID clusterId, IRegUserInfo info) { + LOGGER.debug( + "Registration administrator in the cluster <{}>", //$NON-NLS-1$ + clusterId); + + if (!isConnected()) { + LOGGER.debug( + "The connection a cluster <{}> is not established", //$NON-NLS-1$ + clusterId); + return false; + } + + if (!checkAutenticateAgent()) { + return false; + } + + try { + agentConnection.regClusterAdmin(clusterId, info); + } catch (Exception excp) { + LOGGER.error( + "Error registration cluster admin", //$NON-NLS-1$ + excp); + Helper.showMessageBox(excp.getLocalizedMessage()); + return false; + } + + return true; } /** @@ -1652,18 +1707,34 @@ private List getClusterAdmins(UUID clusterId) { *

Требует аутентификации в кластере * * @param clusterId - ID кластера - * @param name - имя администратора + * @param username - имя администратора */ - private void unregClusterAdmin(UUID clusterId, String name) { + public boolean unregClusterAdmin(UUID clusterId, String username) { LOGGER.debug( "Deletes a cluster administrator in the cluster <{}>", //$NON-NLS-1$ clusterId); if (!isConnected()) { - return; + LOGGER.debug( + "The connection a cluster <{}> is not established", //$NON-NLS-1$ + clusterId); + return false; } - // TODO - return; + if (!checkAutenticateAgent()) { + return false; + } + + try { + agentConnection.unregClusterAdmin(clusterId, username); + } catch (Exception excp) { + LOGGER.error( + "Error unregistration cluster admin", //$NON-NLS-1$ + excp); + Helper.showMessageBox(excp.getLocalizedMessage()); + return false; + } + + return true; } /** diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/AdminEditDialog.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/AdminEditDialog.java new file mode 100644 index 0000000..8404788 --- /dev/null +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/AdminEditDialog.java @@ -0,0 +1,256 @@ +package ru.yanygin.clusterAdminLibraryUI; + +import com._1c.v8.ibis.admin.IRegUserInfo; +import com._1c.v8.ibis.admin.RegUserInfo; +import java.util.UUID; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; +import ru.yanygin.clusterAdminLibrary.Helper; +import ru.yanygin.clusterAdminLibrary.Server; + +/** Диалог редактирования администратора. */ +public class AdminEditDialog extends Dialog { + + private Server server; + private UUID clusterId; + private IRegUserInfo userInfo; + + private Text txtUsername; + private Text txtPassword; + private Text txtPasswordConfirm; + private Text txtSysUsername; + private Text txtDescription; + private Button btnPasswordAuthAllowed; + private Button btnSysAuthAllowed; + + private boolean passIsModified = false; + + /** + * Создание диалога редактирования администратора. + * + * @param parentShell - parent shell + * @param server - Сервер + * @param clusterId - ID кластера + * @param userInfo - IRegUserInfo пользователя + * @wbp.parser.constructor + */ + public AdminEditDialog(Shell parentShell, Server server, UUID clusterId, IRegUserInfo userInfo) { + super(parentShell); + setShellStyle(SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); + + this.server = server; + this.clusterId = clusterId; + this.userInfo = userInfo; + } + + @Override + protected void configureShell(Shell newShell) { + newShell.setMinimumSize(new Point(300, 39)); + super.configureShell(newShell); + + if (userInfo == null) { + newShell.setText(Strings.TITLE_NEW); + } else { + newShell.setText(Strings.TITLE_EDIT); + } + } + + /** + * Create contents of the dialog. + * + * @param parent - parent composite + */ + @Override + protected Control createDialogArea(Composite parent) { + + Composite container = (Composite) super.createDialogArea(parent); + GridLayout gridLayout = (GridLayout) container.getLayout(); + gridLayout.numColumns = 2; + + Label lblUsername = new Label(container, SWT.NONE); + lblUsername.setText(Strings.NAME); + + txtUsername = new Text(container, SWT.BORDER); + txtUsername.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); + + Label lblDescription = new Label(container, SWT.NONE); + lblDescription.setText(Strings.DESCRIPTION); + + txtDescription = new Text(container, SWT.BORDER); + txtDescription.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); + + btnPasswordAuthAllowed = new Button(container, SWT.CHECK); + btnPasswordAuthAllowed.setText(Strings.PASSWORD_AUTH_ALLOWED); + btnPasswordAuthAllowed.addSelectionListener( + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + txtPassword.setEditable(btnPasswordAuthAllowed.getSelection()); + txtPasswordConfirm.setEditable(btnPasswordAuthAllowed.getSelection()); + } + }); + + new Label(container, SWT.NONE); + + Label lblPassword = new Label(container, SWT.NONE); + lblPassword.setText(Strings.PASSWORD); + + txtPassword = new Text(container, SWT.BORDER | SWT.PASSWORD); + txtPassword.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); + + Label lblPasswordConfirm = new Label(container, SWT.NONE); + lblPasswordConfirm.setText(Strings.PASSWORD_CONFIRM); + + txtPasswordConfirm = new Text(container, SWT.BORDER | SWT.PASSWORD); + txtPasswordConfirm.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); + + btnSysAuthAllowed = new Button(container, SWT.CHECK); + btnSysAuthAllowed.setText(Strings.SYS_AUTH_ALLOWED); + btnSysAuthAllowed.addSelectionListener( + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + txtSysUsername.setEditable(btnSysAuthAllowed.getSelection()); + } + }); + + new Label(container, SWT.NONE); + + Label lblSysUsername = new Label(container, SWT.NONE); + lblSysUsername.setText(Strings.SYS_USERNAME); + + txtSysUsername = new Text(container, SWT.BORDER); + txtSysUsername.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); + + initProperties(); + + parent.pack(); + + return container; + } + + /** + * Получает итоговую информацию об администраторе. + * + * @return IRegUserInfo информация об администраторе + */ + public IRegUserInfo getUserinfo() { + return userInfo; + } + + private void initProperties() { + if (userInfo != null) { + this.txtUsername.setText(userInfo.getName()); + this.txtDescription.setText(userInfo.getDescr()); + + this.btnPasswordAuthAllowed.setSelection(userInfo.isPasswordAuthAllowed()); + this.txtPassword.setText(userInfo.getPassword()); + this.txtPasswordConfirm.setText(userInfo.getPassword()); + + this.btnSysAuthAllowed.setSelection(userInfo.isSysAuthAllowed()); + this.txtSysUsername.setText(userInfo.getSysUserName()); + } + + txtPassword.addModifyListener( + new ModifyListener() { + public void modifyText(ModifyEvent e) { + passIsModified = true; + } + }); + txtPasswordConfirm.addModifyListener( + new ModifyListener() { + public void modifyText(ModifyEvent e) { + passIsModified = true; + } + }); + txtPassword.setEditable(btnPasswordAuthAllowed.getSelection()); + txtPasswordConfirm.setEditable(btnPasswordAuthAllowed.getSelection()); + txtSysUsername.setEditable(btnSysAuthAllowed.getSelection()); + } + + private boolean regClusterAdmin() { + if (passIsModified && !txtPassword.getText().equals(txtPasswordConfirm.getText())) { + Helper.showMessageBox(Strings.PASSWORDS_NOT_MATCH); + return false; + } + + if (userInfo == null) { + userInfo = + new RegUserInfo( + txtUsername.getText(), + txtDescription.getText(), + txtPassword.getText(), + btnPasswordAuthAllowed.getSelection(), + btnSysAuthAllowed.getSelection(), + txtSysUsername.getText()); + } else { + + userInfo.setName(txtUsername.getText()); + userInfo.setDescr(txtDescription.getText()); + + userInfo.setSysAuthAllowed(btnPasswordAuthAllowed.getSelection()); + userInfo.setPassword(txtPassword.getText()); + + userInfo.setSysAuthAllowed(btnSysAuthAllowed.getSelection()); + userInfo.setSysUserName(txtSysUsername.getText()); + } + + return server.regClusterAdmin(clusterId, userInfo); + } + + /** + * Create contents of the button bar. + * + * @param parent - parent composite + */ + @Override + protected void createButtonsForButtonBar(Composite parent) { + Button button = + createButton(parent, IDialogConstants.FINISH_ID, IDialogConstants.OK_LABEL, true); + button.addSelectionListener( + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + if (regClusterAdmin()) { + close(); + } + } + }); + + createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); + } + + private static class Strings { + + static final String TITLE_EDIT = getString("TitleEdit"); + static final String TITLE_NEW = getString("TitleNew"); + + static final String NAME = getString("Name"); + static final String DESCRIPTION = getString("Description"); + static final String PASSWORD_AUTH_ALLOWED = getString("PasswordAuthAllowed"); + static final String PASSWORD = getString("Password"); + static final String PASSWORD_CONFIRM = getString("PasswordConfirm"); + static final String SYS_AUTH_ALLOWED = getString("SysAuthAllowed"); + static final String SYS_USERNAME = getString("SysUsername"); + + static final String PASSWORDS_NOT_MATCH = getString("PasswordsNotMatch"); + + static String getString(String key) { + return Messages.getString("AdminDialog." + key); // $NON-NLS-1$ + } + } +} diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/AdminsDialog.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/AdminsDialog.java new file mode 100644 index 0000000..537409b --- /dev/null +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/AdminsDialog.java @@ -0,0 +1,274 @@ +package ru.yanygin.clusterAdminLibraryUI; + +import com._1c.v8.ibis.admin.IRegUserInfo; +import java.util.UUID; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.KeyAdapter; +import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.events.MouseAdapter; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.swt.widgets.TableItem; +import org.eclipse.swt.widgets.ToolBar; +import org.eclipse.swt.widgets.ToolItem; +import ru.yanygin.clusterAdminLibrary.Helper; +import ru.yanygin.clusterAdminLibrary.Server; + +/** Диалог редактирования администратора. */ +public class AdminsDialog extends Dialog { + + private Server server; + private UUID clusterId; + + private Table tableAdmins; + + final Image addIcon16 = Helper.getImage("add_16.png"); // $NON-NLS-1$ + final Image editIcon16 = Helper.getImage("edit_16.png"); // $NON-NLS-1$ + final Image deleteIcon16 = Helper.getImage("delete_16.png"); // $NON-NLS-1$ + + /** + * Create the dialog. + * + * @param parentShell - parent shell + * @param server - server params + * @param clusterId - Id кластера + */ + public AdminsDialog(Shell parentShell, Server server, UUID clusterId) { + super(parentShell); + setShellStyle(SWT.DIALOG_TRIM); + + this.server = server; + this.clusterId = clusterId; + } + + @Override + protected void configureShell(Shell newShell) { + super.configureShell(newShell); + newShell.setText(Strings.TITLE_WINDOW); + } + + /** + * Create contents of the dialog. + * + * @param parent - parent composite + */ + @Override + protected Control createDialogArea(Composite parent) { + + Composite container = (Composite) super.createDialogArea(parent); + + ToolBar toolBar = new ToolBar(container, SWT.FLAT | SWT.RIGHT); + + ToolItem toolBarAdd = new ToolItem(toolBar, SWT.NONE); + toolBarAdd.setImage(addIcon16); + toolBarAdd.setText(Strings.TOOLBAR_ADD); + toolBarAdd.addSelectionListener( + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + addAdmin(); + } + }); + + ToolItem toolBarEdit = new ToolItem(toolBar, SWT.NONE); + toolBarEdit.setImage(editIcon16); + toolBarEdit.setText(Strings.TOOLBAR_EDIT); + toolBarEdit.addSelectionListener( + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + editAdmin(); + } + }); + + ToolItem toolBarDelete = new ToolItem(toolBar, SWT.NONE); + toolBarDelete.setImage(deleteIcon16); + toolBarDelete.setText(Strings.TOOLBAR_DELETE); + toolBarDelete.addSelectionListener( + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + delAdmin(); + } + }); + + tableAdmins = new Table(container, SWT.BORDER | SWT.CHECK | SWT.FULL_SELECTION | SWT.MULTI); + tableAdmins.setHeaderVisible(true); + tableAdmins.setLinesVisible(true); + tableAdmins.addKeyListener(keyPressListener); + tableAdmins.addMouseListener(mouseDoubleClickListener); + + TableColumn tcName = new TableColumn(tableAdmins, SWT.NONE); + tcName.setWidth(120); + tcName.setText(Strings.NAME); + + TableColumn tcDescr = new TableColumn(tableAdmins, SWT.NONE); + tcDescr.setWidth(150); + tcDescr.setText(Strings.DESCRIPTION); + + TableColumn tcPasswordAuthAllowed = new TableColumn(tableAdmins, SWT.NONE); + tcPasswordAuthAllowed.setWidth(110); + tcPasswordAuthAllowed.setText(Strings.PASSWORD_AUTH_ALLOWED); + + TableColumn tcSysAuthAllowed = new TableColumn(tableAdmins, SWT.NONE); + tcSysAuthAllowed.setWidth(80); + tcSysAuthAllowed.setText(Strings.SYS_AUTH_ALLOWED); + + TableColumn tcSysUsername = new TableColumn(tableAdmins, SWT.NONE); + tcSysUsername.setWidth(120); + tcSysUsername.setText(Strings.SYS_USERNAME); + + initProperties(); + + parent.pack(); + + return container; + } + + private void initProperties() { + if (server != null) { + fillTableAdmins(); + } + } + + private void fillTableAdmins() { + + tableAdmins.removeAll(); + server + .getClusterAdmins(clusterId) + .forEach( + (userInfo) -> { + TableItem adminItem = new TableItem(tableAdmins, SWT.NONE); + adminItem.setText(getTableAdminsItemText(userInfo)); + adminItem.setData(userInfo); + }); + tableAdmins.pack(); + } + + private String[] getTableAdminsItemText(IRegUserInfo userInfo) { + return new String[] { + userInfo.getName(), + userInfo.getDescr(), + String.valueOf(userInfo.isPasswordAuthAllowed()), + String.valueOf(userInfo.isSysAuthAllowed()), + userInfo.getSysUserName() + }; + } + + /** + * Create contents of the button bar. + * + * @param parent - parent composite + */ + @Override + protected void createButtonsForButtonBar(Composite parent) { + Button button = + createButton(parent, IDialogConstants.CLOSE_ID, IDialogConstants.CLOSE_LABEL, true); + button.addSelectionListener( + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + close(); + } + }); + } + + private KeyAdapter keyPressListener = + new KeyAdapter() { + @Override + public void keyPressed(KeyEvent e) { + if (e.keyCode == SWT.DEL) { + delAdmin(); + } + } + }; + + private MouseAdapter mouseDoubleClickListener = + new MouseAdapter() { + @Override + public void mouseDoubleClick(MouseEvent e) { + editAdmin(); + } + }; + + private void addAdmin() { + + AdminEditDialog adminEditDialog = + new AdminEditDialog(Display.getDefault().getActiveShell(), server, clusterId, null); + + if (adminEditDialog.open() == 0) { + IRegUserInfo userInfo = adminEditDialog.getUserinfo(); + + TableItem adminItem = new TableItem(tableAdmins, SWT.NONE); + adminItem.setText(getTableAdminsItemText(userInfo)); + adminItem.setData(userInfo); + } + } + + private void editAdmin() { + TableItem[] admins = tableAdmins.getSelection(); + if (admins.length == 0) { + return; + } + + TableItem adminItem = admins[0]; + + IRegUserInfo userInfo = (IRegUserInfo) adminItem.getData(); + + AdminEditDialog adminEditDialog = + new AdminEditDialog(Display.getDefault().getActiveShell(), server, clusterId, userInfo); + + if (adminEditDialog.open() == 0) { + userInfo = adminEditDialog.getUserinfo(); + adminItem.setText(getTableAdminsItemText(userInfo)); + adminItem.setData(userInfo); + } + } + + private void delAdmin() { + TableItem[] admins = tableAdmins.getSelection(); + if (admins.length == 0) { + return; + } + + int answer = Helper.showQuestionBox(Messages.getString("Удалить ?")); + if (answer == SWT.YES) { + for (TableItem adminItem : admins) { + + IRegUserInfo userInfo = (IRegUserInfo) adminItem.getData(); + if (server.unregClusterAdmin(clusterId, userInfo.getName())) { + adminItem.dispose(); + } + } + } + } + + private static class Strings { + + static final String TITLE_WINDOW = getString("TitleList"); + static final String NAME = getString("Name"); + static final String DESCRIPTION = getString("Description"); + static final String PASSWORD_AUTH_ALLOWED = getString("PasswordAuthAllowed"); + static final String SYS_AUTH_ALLOWED = getString("SysAuthAllowed"); + static final String SYS_USERNAME = getString("SysUsername"); + + static final String TOOLBAR_ADD = Messages.getString("ViewerArea.ContextMenu.Create"); + static final String TOOLBAR_EDIT = getString("ViewerArea.ContextMenu.Edit"); + static final String TOOLBAR_DELETE = getString("ViewerArea.ContextMenu.Delete"); + + static String getString(String key) { + return Messages.getString("AdminDialog." + key); + } + } +} diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java index 8e03274..36f0672 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java @@ -509,6 +509,8 @@ private void initClusterMenu() { addMenuSeparator(clusterMenu); addItemInMenu( clusterMenu, Strings.CONTEXT_MENU_DELETE_CLUSTER, deleteIcon16, deleteClusterListener); + + addItemInMenu(clusterMenu, Strings.CONTEXT_MENU_ADMINS, null, editClusterAdminsListener); } private void initWorkingServerMenu() { @@ -2093,6 +2095,33 @@ public void widgetSelected(SelectionEvent event) { } }; + SelectionAdapter editClusterAdminsListener = + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent event) { + TreeItem[] item = serversTree.getSelection(); + if (item.length == 0) { + return; + } + + Server server = getServer(item[0]); + UUID clusterId = getClusterId(item[0]); + + AdminsDialog dialog; + try { + dialog = new AdminsDialog(getParent().getDisplay().getActiveShell(), server, clusterId); + } catch (Exception excp) { + LOGGER.error( + "Error init AdminsDialog for cluster id {}", //$NON-NLS-1$ + clusterId, + excp); + return; + } + + dialog.open(); + } + }; + SelectionAdapter createInfobaseListener = // TODO вызывается из контекстного меню и из тулбара // нет ли ошибки serversTree.getSelection() при вызове из тулбара @@ -3302,6 +3331,7 @@ private static class Strings { static final String CONTEXT_MENU_CREATE_CLUSTER = getString("ContextMenu.CreateCluster"); static final String CONTEXT_MENU_EDIT_CLUSTER = getString("ContextMenu.EditCluster"); static final String CONTEXT_MENU_DELETE_CLUSTER = getString("ContextMenu.DeleteCluster"); + static final String CONTEXT_MENU_ADMINS = getString("ContextMenu.Admins"); static final String CONTEXT_MENU_CREATE_WORKING_SERVER = getString("ContextMenu.CreateWorkingServer"); diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties index a1703d3..d22d6ac 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties @@ -14,6 +14,18 @@ AboutDialog.MainTitle = OneS Cluster Admin AboutDialog.Telegram_Description = Telegram:\r\n%s AboutDialog.TitleDialog = About +AdminDialog.Description = Description +AdminDialog.Name = Name +AdminDialog.Password = Password +AdminDialog.PasswordAuthAllowed = Pass auth. +AdminDialog.PasswordConfirm = Confirm +AdminDialog.PasswordsNotMatch = The entered passwords do not match +AdminDialog.SysAuthAllowed = OS auth. +AdminDialog.SysUsername = User +AdminDialog.TitleEdit = Cluster administrator settings +AdminDialog.TitleList = Administrators +AdminDialog.TitleNew = New cluster administrator + BackgroundTaskParams.ParamName = Param name BackgroundTaskParams.ParamValue = Value BackgroundTaskParams.Title = Set params for task: @@ -145,6 +157,7 @@ ViewerArea.ColumnServer = Server ViewerArea.ConnPerProcessLimit = Conn per process limit ViewerArea.ContextMenu.AddInFavorites = Add to favorites ViewerArea.ContextMenu.AddServer = Add server +ViewerArea.ContextMenu.Admins = Administrators ViewerArea.ContextMenu.ConnectToServer = Connect to server ViewerArea.ContextMenu.CopyCellValue = Copy cell value ViewerArea.ContextMenu.CopyInfobase = Copy infobase diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties index 27dcab1..e70d511 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties @@ -14,6 +14,18 @@ AboutDialog.MainTitle = OneS Cluster Admin AboutDialog.Telegram_Description = Telegram:\r\n%s AboutDialog.TitleDialog = \u041E \u043F\u0440\u043E\u0433\u0440\u0430\u043C\u043C\u0435 +AdminDialog.Description = \u041E\u043F\u0438\u0441\u0430\u043D\u0438\u0435 +AdminDialog.Name = \u0418\u043C\u044F +AdminDialog.Password = \u041F\u0430\u0440\u043E\u043B\u044C +AdminDialog.PasswordAuthAllowed = \u0410\u0443\u0442\u0435\u043D\u0442. \u043F\u0430\u0440\u043E\u043B\u0435\u043C +AdminDialog.PasswordConfirm = \u041F\u043E\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043D\u0438\u0435 +AdminDialog.PasswordsNotMatch = \u0412\u0432\u0435\u0434\u0435\u043D\u043D\u044B\u0435 \u043F\u0430\u0440\u043E\u043B\u0438 \u043D\u0435 \u0441\u043E\u0432\u043F\u0430\u0434\u0430\u044E\u0442 +AdminDialog.SysAuthAllowed = \u0410\u0443\u0442\u0435\u043D\u0442. \u041E\u0421 +AdminDialog.SysUsername = \u041F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u0442\u0435\u043B\u044C +AdminDialog.TitleEdit = \u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u044B \u0430\u0434\u043C\u0438\u043D\u0438\u0441\u0442\u0440\u0430\u0442\u043E\u0440\u0430 \u043A\u043B\u0430\u0441\u0442\u0435\u0440\u0430 +AdminDialog.TitleList = \u0410\u0434\u043C\u0438\u043D\u0438\u0441\u0442\u0440\u0430\u0442\u043E\u0440\u044B +AdminDialog.TitleNew = \u041D\u043E\u0432\u044B\u0439 \u0430\u0434\u043C\u0438\u043D\u0438\u0441\u0442\u0440\u0430\u0442\u043E\u0440 \u043A\u043B\u0430\u0441\u0442\u0435\u0440\u0430 + BackgroundTaskParams.ParamName = \u0418\u043C\u044F \u043F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u0430 BackgroundTaskParams.ParamValue = \u0417\u043D\u0430\u0447\u0435\u043D\u0438\u0435 BackgroundTaskParams.Title = \u0423\u0441\u0442\u0430\u043D\u043E\u0432\u043A\u0430 \u043F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u043E\u0432 \u0434\u043B\u044F \u0437\u0430\u0434\u0430\u0447\u0438: @@ -145,6 +157,7 @@ ViewerArea.ColumnServer = \u0421\u0435\u0440\u04 ViewerArea.ConnPerProcessLimit = \u041A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E \u0441\u043E\u0435\u0434\u0438\u043D\u0435\u043D\u0438\u0439 \u043D\u0430 \u0440\u0430\u0431\u043E\u0447\u0438\u0439 \u043F\u0440\u043E\u0446\u0435\u0441\u0441 ViewerArea.ContextMenu.AddInFavorites = \u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u0432 \u0438\u0437\u0431\u0440\u0430\u043D\u043D\u043E\u0435 ViewerArea.ContextMenu.AddServer = \u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u0441\u0435\u0440\u0432\u0435\u0440 +ViewerArea.ContextMenu.Admins = \u0410\u0434\u043C\u0438\u043D\u0438\u0441\u0442\u0440\u0430\u0442\u043E\u0440\u044B ViewerArea.ContextMenu.ConnectToServer = \u041F\u043E\u0434\u043A\u043B\u044E\u0447\u0438\u0442\u044C\u0441\u044F \u043A \u0441\u0435\u0440\u0432\u0435\u0440\u0443 ViewerArea.ContextMenu.CopyCellValue = \u041A\u043E\u043F\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u044F\u0447\u0435\u0439\u043A\u0438 ViewerArea.ContextMenu.CopyInfobase = \u0421\u043A\u043E\u043F\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u0438\u043D\u0444\u043E\u0431\u0430\u0437\u0443 From 7b6f3455e113df57e56d5a6e188bc8cbd73da228 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Sat, 17 Feb 2024 16:02:15 +0300 Subject: [PATCH 27/70] =?UTF-8?q?=D0=90=D0=B4=D0=BC=D0=B8=D0=BD=D0=B8?= =?UTF-8?q?=D1=81=D1=82=D1=80=D0=B0=D1=82=D0=BE=D1=80=D1=8B=20=D1=86=D0=B5?= =?UTF-8?q?=D0=BD=D1=82=D1=80=D0=B0=D0=BB=D1=8C=D0=BD=D0=BE=D0=B3=D0=BE=20?= =?UTF-8?q?=D1=81=D0=B5=D1=80=D0=B2=D0=B5=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yanygin/clusterAdminLibrary/Server.java | 126 ++++++++++++++++-- .../AdminEditDialog.java | 17 ++- .../clusterAdminLibraryUI/AdminsDialog.java | 35 +++-- .../clusterAdminLibraryUI/ViewerArea.java | 23 +++- .../clusterAdminLibraryUI/messages.properties | 7 +- .../messages_ru_RU.properties | 7 +- 6 files changed, 180 insertions(+), 35 deletions(-) diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java index 6f46f04..67e2b62 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java @@ -1636,7 +1636,7 @@ public boolean unregCluster(UUID clusterId) { */ public List getClusterAdmins(UUID clusterId) { LOGGER.debug( - "Gets the list administrators in the cluster <{}>", //$NON-NLS-1$ + "Getting a list of cluster administrators <{}>", //$NON-NLS-1$ clusterId); if (!isConnected()) { @@ -1646,7 +1646,7 @@ public List getClusterAdmins(UUID clusterId) { return new ArrayList<>(); } - if (!checkAutenticateAgent()) { + if (!checkAutenticateCluster(clusterId)) { return new ArrayList<>(); } @@ -1655,7 +1655,7 @@ public List getClusterAdmins(UUID clusterId) { clusterAdmins = agentConnection.getClusterAdmins(clusterId); } catch (Exception excp) { LOGGER.error( - "Error get cluster admins", //$NON-NLS-1$ + "Error getting the list of cluster administrators", //$NON-NLS-1$ excp); return new ArrayList<>(); } @@ -1674,7 +1674,7 @@ public List getClusterAdmins(UUID clusterId) { */ public boolean regClusterAdmin(UUID clusterId, IRegUserInfo info) { LOGGER.debug( - "Registration administrator in the cluster <{}>", //$NON-NLS-1$ + "Administrator registration on the cluster <{}>", //$NON-NLS-1$ clusterId); if (!isConnected()) { @@ -1684,7 +1684,7 @@ public boolean regClusterAdmin(UUID clusterId, IRegUserInfo info) { return false; } - if (!checkAutenticateAgent()) { + if (!checkAutenticateCluster(clusterId)) { return false; } @@ -1692,7 +1692,7 @@ public boolean regClusterAdmin(UUID clusterId, IRegUserInfo info) { agentConnection.regClusterAdmin(clusterId, info); } catch (Exception excp) { LOGGER.error( - "Error registration cluster admin", //$NON-NLS-1$ + "Error registering the administrator of the cluster", //$NON-NLS-1$ excp); Helper.showMessageBox(excp.getLocalizedMessage()); return false; @@ -1711,7 +1711,7 @@ public boolean regClusterAdmin(UUID clusterId, IRegUserInfo info) { */ public boolean unregClusterAdmin(UUID clusterId, String username) { LOGGER.debug( - "Deletes a cluster administrator in the cluster <{}>", //$NON-NLS-1$ + "Deletes the cluster administrator in the cluster <{}>", //$NON-NLS-1$ clusterId); if (!isConnected()) { LOGGER.debug( @@ -1720,7 +1720,7 @@ public boolean unregClusterAdmin(UUID clusterId, String username) { return false; } - if (!checkAutenticateAgent()) { + if (!checkAutenticateCluster(clusterId)) { return false; } @@ -1728,7 +1728,115 @@ public boolean unregClusterAdmin(UUID clusterId, String username) { agentConnection.unregClusterAdmin(clusterId, username); } catch (Exception excp) { LOGGER.error( - "Error unregistration cluster admin", //$NON-NLS-1$ + "Error unregistration cluster administrator", //$NON-NLS-1$ + excp); + Helper.showMessageBox(excp.getLocalizedMessage()); + return false; + } + + return true; + } + + /** + * Получение списка администраторов центрального сервера. + * + *

Требует аутентификации на центральном сервере + * + * @return список администраторов кластера + */ + public List getAgentAdmins() { + LOGGER.debug( + "Getting the list of administrators on the main server <{}>", //$NON-NLS-1$ + getServerKey()); + + if (!isConnected()) { + LOGGER.debug( + "The connection a server <{}> is not established", //$NON-NLS-1$ + getServerKey()); + return new ArrayList<>(); + } + + if (!checkAutenticateAgent()) { + return new ArrayList<>(); + } + + List clusterAdmins; + try { + clusterAdmins = agentConnection.getAgentAdmins(); + } catch (Exception excp) { + LOGGER.error( + "Error getting the list of administrators of the main server", //$NON-NLS-1$ + excp); + return new ArrayList<>(); + } + + return clusterAdmins; + } + + /** + * Регистрация нового или изменение существующего администратора центрального сервера. + * + *

Требует аутентификации на центральном сервере + * + * @param info - информация о администраторе + * @return {@code true} в случае успешной регистрации + */ + public boolean regAgentAdmin(IRegUserInfo info) { + LOGGER.debug( + "Administrator registration on the main server <{}>", //$NON-NLS-1$ + getServerKey()); + + if (!isConnected()) { + LOGGER.debug( + "The connection a server <{}> is not established", //$NON-NLS-1$ + getServerKey()); + return false; + } + + if (!checkAutenticateAgent()) { + return false; + } + + try { + agentConnection.regAgentAdmin(info); + } catch (Exception excp) { + LOGGER.error( + "Error registering the administrator of the main server", //$NON-NLS-1$ + excp); + Helper.showMessageBox(excp.getLocalizedMessage()); + return false; + } + + return true; + } + + /** + * Удаление администратора центрального сервера. + * + *

Требует аутентификации на центральном сервере + * + * @param username - имя администратора + */ + public boolean unregAgentAdmin(String username) { + LOGGER.debug( + "Deleting an administrator on the main server <{}>", //$NON-NLS-1$ + getServerKey()); + if (!isConnected()) { + LOGGER.debug( + "The connection a server <{}> is not established", //$NON-NLS-1$ + getServerKey()); + return false; + } + + if (!checkAutenticateAgent()) { + return false; + } + + try { + agentConnection.unregAgentAdmin(username); + } catch (Exception excp) { + LOGGER.error( + "Error unregistration of the main server administrator", //$NON-NLS-1$ excp); Helper.showMessageBox(excp.getLocalizedMessage()); return false; diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/AdminEditDialog.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/AdminEditDialog.java index 8404788..1d3c845 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/AdminEditDialog.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/AdminEditDialog.java @@ -63,9 +63,9 @@ protected void configureShell(Shell newShell) { super.configureShell(newShell); if (userInfo == null) { - newShell.setText(Strings.TITLE_NEW); + newShell.setText(clusterId == null ? Strings.TITLE_SERVER_NEW : Strings.TITLE_CLUSTER_NEW); } else { - newShell.setText(Strings.TITLE_EDIT); + newShell.setText(clusterId == null ? Strings.TITLE_SERVER_EDIT : Strings.TITLE_CLUSTER_EDIT); } } @@ -209,7 +209,12 @@ private boolean regClusterAdmin() { userInfo.setSysUserName(txtSysUsername.getText()); } - return server.regClusterAdmin(clusterId, userInfo); + boolean unregOk = + clusterId == null + ? server.regAgentAdmin(userInfo) + : server.regClusterAdmin(clusterId, userInfo); + + return unregOk; } /** @@ -236,8 +241,10 @@ public void widgetSelected(SelectionEvent e) { private static class Strings { - static final String TITLE_EDIT = getString("TitleEdit"); - static final String TITLE_NEW = getString("TitleNew"); + static final String TITLE_CLUSTER_EDIT = getString("TitleClusterEdit"); + static final String TITLE_CLUSTER_NEW = getString("TitleClusterNew"); + static final String TITLE_SERVER_EDIT = getString("TitleServerEdit"); + static final String TITLE_SERVER_NEW = getString("TitleServerNew"); static final String NAME = getString("Name"); static final String DESCRIPTION = getString("Description"); diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/AdminsDialog.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/AdminsDialog.java index 537409b..35cb0fb 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/AdminsDialog.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/AdminsDialog.java @@ -1,6 +1,7 @@ package ru.yanygin.clusterAdminLibraryUI; import com._1c.v8.ibis.admin.IRegUserInfo; +import java.util.List; import java.util.UUID; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogConstants; @@ -145,14 +146,15 @@ private void initProperties() { private void fillTableAdmins() { tableAdmins.removeAll(); - server - .getClusterAdmins(clusterId) - .forEach( - (userInfo) -> { - TableItem adminItem = new TableItem(tableAdmins, SWT.NONE); - adminItem.setText(getTableAdminsItemText(userInfo)); - adminItem.setData(userInfo); - }); + List admins = + clusterId == null ? server.getAgentAdmins() : server.getClusterAdmins(clusterId); + + admins.forEach( + (userInfo) -> { + TableItem adminItem = new TableItem(tableAdmins, SWT.NONE); + adminItem.setText(getTableAdminsItemText(userInfo)); + adminItem.setData(userInfo); + }); tableAdmins.pack(); } @@ -213,6 +215,7 @@ private void addAdmin() { TableItem adminItem = new TableItem(tableAdmins, SWT.NONE); adminItem.setText(getTableAdminsItemText(userInfo)); adminItem.setData(userInfo); + getShell().pack(); } } @@ -242,15 +245,21 @@ private void delAdmin() { return; } - int answer = Helper.showQuestionBox(Messages.getString("Удалить ?")); + int answer = Helper.showQuestionBox(Strings.ANSWER_DELETE); if (answer == SWT.YES) { for (TableItem adminItem : admins) { IRegUserInfo userInfo = (IRegUserInfo) adminItem.getData(); - if (server.unregClusterAdmin(clusterId, userInfo.getName())) { + boolean unregOk = + clusterId == null + ? server.unregAgentAdmin(userInfo.getName()) + : server.unregClusterAdmin(clusterId, userInfo.getName()); + + if (unregOk) { adminItem.dispose(); } } + getShell().pack(); } } @@ -263,9 +272,11 @@ private static class Strings { static final String SYS_AUTH_ALLOWED = getString("SysAuthAllowed"); static final String SYS_USERNAME = getString("SysUsername"); + static final String ANSWER_DELETE = getString("AnswerDelete"); + static final String TOOLBAR_ADD = Messages.getString("ViewerArea.ContextMenu.Create"); - static final String TOOLBAR_EDIT = getString("ViewerArea.ContextMenu.Edit"); - static final String TOOLBAR_DELETE = getString("ViewerArea.ContextMenu.Delete"); + static final String TOOLBAR_EDIT = Messages.getString("ViewerArea.ContextMenu.Edit"); + static final String TOOLBAR_DELETE = Messages.getString("ViewerArea.ContextMenu.Delete"); static String getString(String key) { return Messages.getString("AdminDialog." + key); diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java index 36f0672..916c3e7 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java @@ -482,6 +482,11 @@ private void initServerMenu() { addItemInMenu(serverMenu, Strings.CONTEXT_MENU_EDIT_SERVER, editIcon16, editServerListener); addItemInMenu(serverMenu, Strings.CONTEXT_MENU_UPDATE, updateIcon16, updateServerListener); + addMenuSeparator(serverMenu); + MenuItem adminsItem = + addItemInMenu(serverMenu, Strings.CONTEXT_MENU_ADMINS, null, editAdminsListener); + adminsItem.setData("disconnectItem", true); + addMenuSeparator(serverMenu); addItemInMenu(serverMenu, Strings.CONTEXT_MENU_MOVE_UP, moveUpIcon, serversMoveUpListener); @@ -505,12 +510,15 @@ private void initClusterMenu() { addItemInMenu( clusterMenu, Strings.CONTEXT_MENU_CREATE_CLUSTER, addIcon16, createClusterListener); addItemInMenu(clusterMenu, Strings.CONTEXT_MENU_EDIT_CLUSTER, editIcon16, editClusterListener); + addItemInMenu(clusterMenu, Strings.CONTEXT_MENU_ADMINS, null, editAdminsListener); + + addMenuSeparator(clusterMenu); addItemInMenu(clusterMenu, Strings.CONTEXT_MENU_UPDATE, updateIcon16, updateClusterListener); + addMenuSeparator(clusterMenu); addItemInMenu( clusterMenu, Strings.CONTEXT_MENU_DELETE_CLUSTER, deleteIcon16, deleteClusterListener); - addItemInMenu(clusterMenu, Strings.CONTEXT_MENU_ADMINS, null, editClusterAdminsListener); } private void initWorkingServerMenu() { @@ -2095,7 +2103,7 @@ public void widgetSelected(SelectionEvent event) { } }; - SelectionAdapter editClusterAdminsListener = + SelectionAdapter editAdminsListener = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { @@ -2103,9 +2111,15 @@ public void widgetSelected(SelectionEvent event) { if (item.length == 0) { return; } + TreeItem treeItem = item[0]; + TreeItemType treeItemType = getTreeItemType(treeItem); + if (treeItemType != TreeItemType.SERVER && treeItemType != TreeItemType.CLUSTER) { + LOGGER.error("Invalid item type for AdminsDialog"); // $NON-NLS-1$ + return; + } - Server server = getServer(item[0]); - UUID clusterId = getClusterId(item[0]); + Server server = getServer(treeItem); + UUID clusterId = getClusterId(treeItem); AdminsDialog dialog; try { @@ -2117,7 +2131,6 @@ public void widgetSelected(SelectionEvent event) { excp); return; } - dialog.open(); } }; diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties index d22d6ac..ed06fdd 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties @@ -14,6 +14,7 @@ AboutDialog.MainTitle = OneS Cluster Admin AboutDialog.Telegram_Description = Telegram:\r\n%s AboutDialog.TitleDialog = About +AdminDialog.AnswerDelete = Remove the administrator? AdminDialog.Description = Description AdminDialog.Name = Name AdminDialog.Password = Password @@ -22,9 +23,11 @@ AdminDialog.PasswordConfirm = Confirm AdminDialog.PasswordsNotMatch = The entered passwords do not match AdminDialog.SysAuthAllowed = OS auth. AdminDialog.SysUsername = User -AdminDialog.TitleEdit = Cluster administrator settings +AdminDialog.TitleClusterEdit = Cluster administrator settings +AdminDialog.TitleClusterNew = New cluster administrator AdminDialog.TitleList = Administrators -AdminDialog.TitleNew = New cluster administrator +AdminDialog.TitleServerEdit = Main server administrator settings +AdminDialog.TitleServerNew = New main server administrator BackgroundTaskParams.ParamName = Param name BackgroundTaskParams.ParamValue = Value diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties index e70d511..ebdb095 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties @@ -14,6 +14,7 @@ AboutDialog.MainTitle = OneS Cluster Admin AboutDialog.Telegram_Description = Telegram:\r\n%s AboutDialog.TitleDialog = \u041E \u043F\u0440\u043E\u0433\u0440\u0430\u043C\u043C\u0435 +AdminDialog.AnswerDelete = \u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0430\u0434\u043C\u0438\u043D\u0438\u0441\u0442\u0440\u0430\u0442\u043E\u0440\u0430? AdminDialog.Description = \u041E\u043F\u0438\u0441\u0430\u043D\u0438\u0435 AdminDialog.Name = \u0418\u043C\u044F AdminDialog.Password = \u041F\u0430\u0440\u043E\u043B\u044C @@ -22,9 +23,11 @@ AdminDialog.PasswordConfirm = \u041F\u043E\u0434\u0442\u0432\u0435\u0440\u04 AdminDialog.PasswordsNotMatch = \u0412\u0432\u0435\u0434\u0435\u043D\u043D\u044B\u0435 \u043F\u0430\u0440\u043E\u043B\u0438 \u043D\u0435 \u0441\u043E\u0432\u043F\u0430\u0434\u0430\u044E\u0442 AdminDialog.SysAuthAllowed = \u0410\u0443\u0442\u0435\u043D\u0442. \u041E\u0421 AdminDialog.SysUsername = \u041F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u0442\u0435\u043B\u044C -AdminDialog.TitleEdit = \u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u044B \u0430\u0434\u043C\u0438\u043D\u0438\u0441\u0442\u0440\u0430\u0442\u043E\u0440\u0430 \u043A\u043B\u0430\u0441\u0442\u0435\u0440\u0430 +AdminDialog.TitleClusterEdit = \u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u044B \u0430\u0434\u043C\u0438\u043D\u0438\u0441\u0442\u0440\u0430\u0442\u043E\u0440\u0430 \u043A\u043B\u0430\u0441\u0442\u0435\u0440\u0430 +AdminDialog.TitleClusterNew = \u041D\u043E\u0432\u044B\u0439 \u0430\u0434\u043C\u0438\u043D\u0438\u0441\u0442\u0440\u0430\u0442\u043E\u0440 \u043A\u043B\u0430\u0441\u0442\u0435\u0440\u0430 AdminDialog.TitleList = \u0410\u0434\u043C\u0438\u043D\u0438\u0441\u0442\u0440\u0430\u0442\u043E\u0440\u044B -AdminDialog.TitleNew = \u041D\u043E\u0432\u044B\u0439 \u0430\u0434\u043C\u0438\u043D\u0438\u0441\u0442\u0440\u0430\u0442\u043E\u0440 \u043A\u043B\u0430\u0441\u0442\u0435\u0440\u0430 +AdminDialog.TitleServerEdit = \u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u044B \u0430\u0434\u043C\u0438\u043D\u0438\u0441\u0442\u0440\u0430\u0442\u043E\u0440\u0430 \u0446\u0435\u043D\u0442\u0440\u0430\u043B\u044C\u043D\u043E\u0433\u043E \u0441\u0435\u0440\u0432\u0435\u0440\u0430 +AdminDialog.TitleServerNew = \u041D\u043E\u0432\u044B\u0439 \u0430\u0434\u043C\u0438\u043D\u0438\u0441\u0442\u0440\u0430\u0442\u043E\u0440 \u0446\u0435\u043D\u0442\u0440\u0430\u043B\u044C\u043D\u043E\u0433\u043E \u0441\u0435\u0440\u0432\u0435\u0440\u0430 BackgroundTaskParams.ParamName = \u0418\u043C\u044F \u043F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u0430 BackgroundTaskParams.ParamValue = \u0417\u043D\u0430\u0447\u0435\u043D\u0438\u0435 From 8e35f854f04f3f445d54fedffcf5f7174bc96ca5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Sun, 17 Mar 2024 18:24:24 +0300 Subject: [PATCH 28/70] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BA=D0=BB?= =?UTF-8?q?=D1=8E=D1=87=D0=B0=D1=82=D0=B5=D0=BB=D1=8F=20=D1=80=D0=B5=D0=B6?= =?UTF-8?q?=D0=B8=D0=BC=D0=B0=20=D0=B2=D0=B2=D0=BE=D0=B4=D0=B0=20=D0=B4?= =?UTF-8?q?=D0=B0=D1=82=D1=8B=20=D0=B8=20=D1=88=D0=B0=D0=B1=D0=BB=D0=BE?= =?UTF-8?q?=D0=BD=D0=B0=20=D1=81=D0=BE=D0=BE=D0=B1=D1=89=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=20=D0=B2=20=D0=BD=D0=B0=D1=81=D1=82=D1=80=D0=BE=D0=B9?= =?UTF-8?q?=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yanygin/clusterAdminLibrary/Config.java | 44 ++++++++++++ .../clusterAdminLibraryUI/SettingsDialog.java | 45 +++++++++++- .../clusterAdminLibraryUI/messages.properties | 68 ++++++++++--------- .../messages_ru_RU.properties | 68 ++++++++++--------- 4 files changed, 161 insertions(+), 64 deletions(-) diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java index 2d692c4..3cbee3f 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java @@ -131,6 +131,14 @@ public class Config { @Expose private String loggerLevel = "error"; + @SerializedName("InfobaseDeniedFriendlyEditMode") + @Expose + private boolean infobaseDeniedFriendlyEditMode = true; + + @SerializedName("InfobaseDeniedMessagePattern") + @Expose + private String infobaseDeniedMessagePattern = ""; + @SerializedName("Servers") @Expose private Map servers = new HashMap<>(); @@ -995,6 +1003,42 @@ public Version getLatestVersion() { return latestVersion; } + /** + * Установлен удобный вариант установки даты запрета входа в инфобазу. + * + * @return истина = удобный вариант установки даты + */ + public boolean getInfobaseDeniedFriendlyEditMode() { + return infobaseDeniedFriendlyEditMode; + } + + /** + * Устанавливает удобный вариант установки даты запрета входа в инфобазу. + * + * @param infobaseDeniedFriendlyEditMode - истина = удобный вариант установки даты + */ + public void setInfobaseDeniedFriendlyEditMode(boolean infobaseDeniedFriendlyEditMode) { + this.infobaseDeniedFriendlyEditMode = infobaseDeniedFriendlyEditMode; + } + + /** + * Возвращает шаблон текста запрета входа в инфобазу. + * + * @return Шаблон текста запрета входа + */ + public String getInfobaseDeniedMessagePattern() { + return infobaseDeniedMessagePattern; + } + + /** + * Устанавливает шаблон текста запрета входа в инфобазу. + * + * @param infobaseDeniedMessagePattern - Шаблон текста запрета входа + */ + public void setInfobaseDeniedMessagePattern(String infobaseDeniedMessagePattern) { + this.infobaseDeniedMessagePattern = infobaseDeniedMessagePattern; + } + /** * Возвращает путь к файлу конфига. * diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/SettingsDialog.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/SettingsDialog.java index d5e974a..2935a47 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/SettingsDialog.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/SettingsDialog.java @@ -7,6 +7,7 @@ import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; @@ -54,6 +55,10 @@ public class SettingsDialog extends Dialog { private Button btnLoggerLevelDebug; private static final String LOCALE_RU = "ru-RU"; //$NON-NLS-1$ + private Label lblInfobaseDeniedEditMode; + private Text txtInfobaseDeniedPattern; + private Button btnInfobaseDeniedStandardEditMode; + private Button btnInfobaseDeniedFriendlyEditMode; /** * Создание диалога настроек сервера. @@ -235,7 +240,31 @@ protected Control createDialogArea(Composite parent) { btnCheckUpdate = new Button(grpOther, SWT.CHECK); btnCheckUpdate.setText(Strings.CHECK_UPDATE); - new Label(container, SWT.NONE); + + Group grpInfobaseDenied = new Group(container, SWT.NONE); + grpInfobaseDenied.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1)); + grpInfobaseDenied.setLayout(new GridLayout(1, false)); + + lblInfobaseDeniedEditMode = new Label(grpInfobaseDenied, SWT.CHECK); + lblInfobaseDeniedEditMode.setText(Strings.INFOBASE_DENIED_EDIT_MODE); + + Composite compositeInfobaseDeniedEditMode = new Composite(grpInfobaseDenied, SWT.NONE); + compositeInfobaseDeniedEditMode.setLayout(new FillLayout(SWT.HORIZONTAL)); + + btnInfobaseDeniedStandardEditMode = new Button(compositeInfobaseDeniedEditMode, SWT.RADIO); + btnInfobaseDeniedStandardEditMode.setText(Strings.INFOBASE_DENIED_STANDARD_EDIT_MODE); + + btnInfobaseDeniedFriendlyEditMode = new Button(compositeInfobaseDeniedEditMode, SWT.RADIO); + btnInfobaseDeniedFriendlyEditMode.setText(Strings.INFOBASE_DENIED_FRIENDLY_EDIT_MODE); + + Label lblInfobaseDeniedPattern = new Label(grpInfobaseDenied, SWT.NONE); + lblInfobaseDeniedPattern.setText(Strings.INFOBASE_DENIED_MESSAGE_PATTERN); + + txtInfobaseDeniedPattern = new Text(grpInfobaseDenied, SWT.BORDER | SWT.WRAP | SWT.MULTI); + GridData gdTxtInfobaseDeniedPattern = new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1); + gdTxtInfobaseDeniedPattern.widthHint = 200; + gdTxtInfobaseDeniedPattern.heightHint = 61; + txtInfobaseDeniedPattern.setLayoutData(gdTxtInfobaseDeniedPattern); initProperties(); @@ -263,6 +292,10 @@ private void initProperties() { btnShadowSleepSessions.setSelection(config.isShadeSleepingSessions()); btnReadClipboard.setSelection(config.isReadClipboard()); btnCheckUpdate.setSelection(config.checkingUpdate()); + + btnInfobaseDeniedStandardEditMode.setSelection(!config.getInfobaseDeniedFriendlyEditMode()); + btnInfobaseDeniedFriendlyEditMode.setSelection(config.getInfobaseDeniedFriendlyEditMode()); + txtInfobaseDeniedPattern.setText(config.getInfobaseDeniedMessagePattern()); final String locale = config.getLocale(); if (locale == null) { @@ -306,6 +339,8 @@ private void saveProperties() { config.setShadowSleepSessions(btnShadowSleepSessions.getSelection()); config.setReadClipboard(btnReadClipboard.getSelection()); config.setCheckingUpdate(btnCheckUpdate.getSelection()); + config.setInfobaseDeniedFriendlyEditMode(btnInfobaseDeniedFriendlyEditMode.getSelection()); + config.setInfobaseDeniedMessagePattern(txtInfobaseDeniedPattern.getText()); if (btnLocaleSystem.getSelection()) { config.setLocale(null); @@ -402,7 +437,13 @@ private static class Strings { static final String READ_CLIPBOARD = getString("ReadClipboard"); static final String CHECK_UPDATE = getString("CheckUpdate"); - + static final String INFOBASE_DENIED_EDIT_MODE = getString("InfobaseDeniedEditMode"); + static final String INFOBASE_DENIED_STANDARD_EDIT_MODE = + getString("InfobaseDeniedStandardEditMode"); + static final String INFOBASE_DENIED_FRIENDLY_EDIT_MODE = + getString("InfobaseDeniedFriendlyEditMode"); + static final String INFOBASE_DENIED_MESSAGE_PATTERN = getString("InfobaseDeniedMessagePattern"); + static final String LOGGER_LEVEL_TITLE = getString("LoggerLevelTitle"); static String getString(String key) { diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties index a1703d3..c8c1e6d 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties @@ -64,6 +64,7 @@ InfobaseDialog.ExternalSessionManagement = External session management InfobaseDialog.InfobaseName = Name InfobaseDialog.LeaveDatabaseUnchanged = Leave the database and its contents unchanged InfobaseDialog.Locale = Locale +InfobaseDialog.PutSessionsDeniedMessage = Fill on the template InfobaseDialog.RequiredUseOfExternalManagement = Required use of external management InfobaseDialog.SafeModeSecurityProfile = Safe mode security profile InfobaseDialog.SecurityProfile = Security profile @@ -75,6 +76,7 @@ InfobaseDialog.SessionsDeniedParameter = Denied parameter InfobaseDialog.SessionsDeniedTo = Denied to (yyyy-mm-dd hh:mm:ss): InfobaseDialog.SessionsPermissionCode = Permission code InfobaseDialog.SheduledJobsDenied = Sheduled jobs denied +InfobaseDialog.SwitchDeniedEditingMode = Switch between the user-friendly and the regular version InfobaseDialog.TitleDialog = Infobase parameters InfobaseDialog.TitleDropInfobaseParameters = Delete infobase InfobaseDialog.YouNeedToEnter = you need to enter @@ -108,37 +110,41 @@ ServerDialog.UseRemoteRAS = Use remote RAS ServerDialog.Username = Username ServerDialog.V8Version = V8 version -SettingsDialog.CheckUpdate = Check update -SettingsDialog.ExpandClusters = Clusters -SettingsDialog.ExpandInfobases = Infobases -SettingsDialog.ExpandNodesInTree = Expand nodes in tree -SettingsDialog.ExpandServers = Servers -SettingsDialog.ExpandWorkingProcesses = Working processes -SettingsDialog.ExpandWorkingServers = Working servers -SettingsDialog.HighlightDuration = Highlight duration (sec) -SettingsDialog.HighlightNewItems = Highlight new items -SettingsDialog.HighlightTitle = Highlight -SettingsDialog.LocaleEnglish = English -SettingsDialog.LocaleRussian = Russian -SettingsDialog.LocaleSystem = System -SettingsDialog.LocaleTitle = Locale (need restart) -SettingsDialog.LoggerLevelTitle = Logger level -SettingsDialog.ReadClipboard = Read clipboard (when adding server) -SettingsDialog.RowSortDirectionAsPrevious = As previous -SettingsDialog.RowSortDirectionAscending = Descending -SettingsDialog.RowSortDirectionDescending = Ascending -SettingsDialog.RowSortDirectionTitle = Row sort direction -SettingsDialog.ShadowSleepSessions = Shadow sleep sessions -SettingsDialog.ShowInfo = Additional info -SettingsDialog.ShowInfobaseDescription = Show infobase description -SettingsDialog.ShowLocalRASConnectInfo = About connecting via a local RAS -SettingsDialog.ShowNodesInTree = Show nodes in tree -SettingsDialog.ShowServerDescription = Show server description -SettingsDialog.ShowServerVersion = Show server version -SettingsDialog.ShowWorkingProcesses = Working processes -SettingsDialog.ShowWorkingServers = Working servers -SettingsDialog.TitleDialog = Parameters of the application -SettingsDialog.WatchSessions = Watch sessions color +SettingsDialog.CheckUpdate = Check update +SettingsDialog.ExpandClusters = Clusters +SettingsDialog.ExpandInfobases = Infobases +SettingsDialog.ExpandNodesInTree = Expand nodes in tree +SettingsDialog.ExpandServers = Servers +SettingsDialog.ExpandWorkingProcesses = Working processes +SettingsDialog.ExpandWorkingServers = Working servers +SettingsDialog.HighlightDuration = Highlight duration (sec) +SettingsDialog.HighlightNewItems = Highlight new items +SettingsDialog.HighlightTitle = Highlight +SettingsDialog.InfobaseDeniedEditMode = Infobase denied editing mode: +SettingsDialog.InfobaseDeniedFriendlyEditMode = User-friendly +SettingsDialog.InfobaseDeniedMessagePattern = Infobase denied message pattern: +SettingsDialog.InfobaseDeniedStandardEditMode = Standard +SettingsDialog.LocaleEnglish = English +SettingsDialog.LocaleRussian = Russian +SettingsDialog.LocaleSystem = System +SettingsDialog.LocaleTitle = Locale (need restart) +SettingsDialog.LoggerLevelTitle = Logger level +SettingsDialog.ReadClipboard = Read clipboard (when adding server) +SettingsDialog.RowSortDirectionAsPrevious = As previous +SettingsDialog.RowSortDirectionAscending = Descending +SettingsDialog.RowSortDirectionDescending = Ascending +SettingsDialog.RowSortDirectionTitle = Row sort direction +SettingsDialog.ShadowSleepSessions = Shadow sleep sessions +SettingsDialog.ShowInfo = Additional info +SettingsDialog.ShowInfobaseDescription = Show infobase description +SettingsDialog.ShowLocalRASConnectInfo = About connecting via a local RAS +SettingsDialog.ShowNodesInTree = Show nodes in tree +SettingsDialog.ShowServerDescription = Show server description +SettingsDialog.ShowServerVersion = Show server version +SettingsDialog.ShowWorkingProcesses = Working processes +SettingsDialog.ShowWorkingServers = Working servers +SettingsDialog.TitleDialog = Parameters of the application +SettingsDialog.WatchSessions = Watch sessions color ViewerArea.Active = Active ViewerArea.ColumnServer = Server diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties index 27dcab1..9fbf6d5 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties @@ -64,6 +64,7 @@ InfobaseDialog.ExternalSessionManagement = \u0412\u043D\u0435\u0448\u043D\ InfobaseDialog.InfobaseName = \u0418\u043C\u044F InfobaseDialog.LeaveDatabaseUnchanged = \u041E\u0441\u0442\u0430\u0432\u0438\u0442\u044C \u0431\u0430\u0437\u0443 \u0434\u0430\u043D\u043D\u044B\u0445 \u0438 \u0435\u0435 \u0441\u043E\u0434\u0435\u0440\u0436\u0438\u043C\u043E\u0435 \u0431\u0435\u0437 \u0438\u0437\u043C\u0435\u043D\u0435\u043D\u0438\u0439 InfobaseDialog.Locale = \u042F\u0437\u044B\u043A (\u0421\u0442\u0440\u0430\u043D\u0430) +InfobaseDialog.PutSessionsDeniedMessage = \u0417\u0430\u043F\u043E\u043B\u043D\u0438\u0442\u044C \u043F\u043E \u0448\u0430\u0431\u043B\u043E\u043D\u0443 InfobaseDialog.RequiredUseOfExternalManagement = \u041E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u043E\u0435 \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u043D\u0438\u0435 \u0432\u043D\u0435\u0448\u043D\u0435\u0433\u043E \u0443\u043F\u0440\u0430\u0432\u043B\u0435\u043D\u0438\u044F InfobaseDialog.SafeModeSecurityProfile = \u041F\u0440\u043E\u0444\u0438\u043B\u044C \u0431\u0435\u0437\u043E\u043F\u0430\u0441\u043D\u043E\u0441\u0442\u0438\r\n\u0431\u0435\u0437\u043E\u043F\u0430\u0441\u043D\u043E\u0433\u043E \u0440\u0435\u0436\u0438\u043C\u0430 InfobaseDialog.SecurityProfile = \u041F\u0440\u043E\u0444\u0438\u043B\u044C \u0431\u0435\u0437\u043E\u043F\u0430\u0441\u043D\u043E\u0441\u0442\u0438 @@ -75,6 +76,7 @@ InfobaseDialog.SessionsDeniedParameter = \u041F\u0430\u0440\u0430\u043C\ InfobaseDialog.SessionsDeniedTo = \u041A\u043E\u043D\u0435\u0446 (yyyy-mm-dd hh:mm:ss): InfobaseDialog.SessionsPermissionCode = \u041A\u043E\u0434 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043D\u0438\u044F InfobaseDialog.SheduledJobsDenied = \u0411\u043B\u043E\u043A\u0438\u0440\u043E\u0432\u043A\u0430 \u0440\u0435\u0433\u043B\u0430\u043C\u0435\u043D\u0442\u043D\u044B\u0445 \u0437\u0430\u0434\u0430\u043D\u0438\u0439 \u0432\u043A\u043B\u044E\u0447\u0435\u043D\u0430 +InfobaseDialog.SwitchDeniedEditingMode = \u041F\u0435\u0440\u0435\u043A\u043B\u044E\u0447\u0438\u0442\u044C \u043C\u0435\u0436\u0434\u0443 \u0443\u043B\u0443\u0447\u0448\u0435\u043D\u043D\u044B\u043C \u0438 \u043E\u0431\u044B\u0447\u043D\u044B\u043C \u0432\u0430\u0440\u0438\u0430\u043D\u0442\u043E\u043C InfobaseDialog.TitleDialog = \u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u044B \u0438\u043D\u0444\u043E\u0431\u0430\u0437\u044B InfobaseDialog.TitleDropInfobaseParameters = \u0423\u0434\u0430\u043B\u0435\u043D\u0438\u0435 \u0438\u043D\u0444\u043E\u0431\u0430\u0437\u044B InfobaseDialog.YouNeedToEnter = \u043D\u0443\u0436\u043D\u043E \u0437\u0430\u043F\u043E\u043B\u043D\u0438\u0442\u044C @@ -108,37 +110,41 @@ ServerDialog.UseRemoteRAS = \u0418\u0441\u043F\u043E\u043B\u044C\ ServerDialog.Username = \u0418\u043C\u044F \u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u0442\u0435\u043B\u044F ServerDialog.V8Version = \u0412\u0435\u0440\u0441\u0438\u044F V8 -SettingsDialog.CheckUpdate = \u041F\u0440\u043E\u0432\u0435\u0440\u044F\u0442\u044C \u043E\u0431\u043D\u043E\u0432\u043B\u0435\u043D\u0438\u044F -SettingsDialog.ExpandClusters = \u041A\u043B\u0430\u0441\u0442\u0435\u0440\u044B -SettingsDialog.ExpandInfobases = \u0418\u043D\u0444\u043E\u0431\u0430\u0437\u044B -SettingsDialog.ExpandNodesInTree = \u0420\u0430\u0437\u0432\u043E\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u044C \u0443\u0437\u043B\u044B \u0432 \u0434\u0435\u0440\u0435\u0432\u0435 -SettingsDialog.ExpandServers = \u0421\u0435\u0440\u0432\u0435\u0440\u0430 -SettingsDialog.ExpandWorkingProcesses = \u0420\u0430\u0431\u043E\u0447\u0438\u0435 \u043F\u0440\u043E\u0446\u0435\u0441\u0441\u044B -SettingsDialog.ExpandWorkingServers = \u0420\u0430\u0431\u043E\u0447\u0438\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 -SettingsDialog.HighlightDuration = \u0414\u043B\u0438\u0442\u0435\u043B\u044C\u043D\u043E\u0441\u0442\u044C \u043F\u043E\u0434\u0441\u0432\u0435\u0442\u043A\u0438 (\u0441\u0435\u043A) -SettingsDialog.HighlightNewItems = \u041F\u043E\u0434\u0441\u0432\u0435\u0447\u0438\u0432\u0430\u0442\u044C \u043D\u043E\u0432\u044B\u0435 \u0441\u0442\u0440\u043E\u043A\u0438 -SettingsDialog.HighlightTitle = \u041F\u043E\u0434\u0441\u0432\u0435\u0447\u0438\u0432\u0430\u043D\u0438\u0435 -SettingsDialog.LocaleEnglish = \u0410\u043D\u0433\u043B\u0438\u0439\u0441\u043A\u0438\u0439 -SettingsDialog.LocaleRussian = \u0420\u0443\u0441\u0441\u043A\u0438\u0439 -SettingsDialog.LocaleSystem = \u0421\u0438\u0441\u0442\u0435\u043C\u043D\u044B\u0439 -SettingsDialog.LocaleTitle = \u042F\u0437\u044B\u043A \u0438\u043D\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 (\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044F \u043F\u0435\u0440\u0435\u0437\u0430\u043F\u0443\u0441\u043A) -SettingsDialog.LoggerLevelTitle = \u0423\u0440\u043E\u0432\u0435\u043D\u044C \u043B\u043E\u0433\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u044F -SettingsDialog.ReadClipboard = \u0427\u0438\u0442\u0430\u0442\u044C \u0431\u0443\u0444\u0435\u0440 \u043E\u0431\u043C\u0435\u043D\u0430 (\u043F\u0440\u0438 \u0434\u043E\u0431\u0430\u0432\u043B\u0435\u043D\u0438\u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430) -SettingsDialog.RowSortDirectionAsPrevious = \u041A\u0430\u043A \u043F\u0440\u0435\u0434\u044B\u0434\u0443\u0449\u0430\u044F -SettingsDialog.RowSortDirectionAscending = \u041F\u043E \u0443\u0431\u044B\u0432\u0430\u043D\u0438\u044E -SettingsDialog.RowSortDirectionDescending = \u041F\u043E \u0432\u043E\u0437\u0440\u0430\u0441\u0442\u0430\u043D\u0438\u044E -SettingsDialog.RowSortDirectionTitle = \u041D\u0430\u043F\u0440\u0430\u0432\u043B\u0435\u043D\u0438\u0435 \u0441\u043E\u0440\u0442\u0438\u0440\u043E\u0432\u043A\u0438 \u0441\u0442\u0440\u043E\u043A -SettingsDialog.ShadowSleepSessions = \u0417\u0430\u0442\u0435\u043D\u044F\u0442\u044C \u0441\u043F\u044F\u0446\u0438\u0435 \u0441\u0435\u0430\u043D\u0441\u044B -SettingsDialog.ShowInfo = \u0414\u043E\u043F\u043E\u043B\u043D\u0438\u0442\u0435\u043B\u044C\u043D\u0430\u044F \u0438\u043D\u0444\u043E\u0440\u043C\u0430\u0446\u0438\u044F -SettingsDialog.ShowInfobaseDescription = \u041F\u043E\u043A\u0430\u0437\u044B\u0432\u0430\u0442\u044C \u043E\u043F\u0438\u0441\u0430\u043D\u0438\u0435 \u0438\u043D\u0444\u043E\u0431\u0430\u0437\u044B -SettingsDialog.ShowLocalRASConnectInfo = \u041E \u043F\u043E\u0434\u043A\u043B\u044E\u0447\u0435\u043D\u0438\u0438 \u0447\u0435\u0440\u0435\u0437 \u043B\u043E\u043A\u0430\u043B\u044C\u043D\u044B\u0439 RAS -SettingsDialog.ShowNodesInTree = \u041F\u043E\u043A\u0430\u0437\u044B\u0432\u0430\u0442\u044C \u0443\u0437\u043B\u044B \u0432 \u0434\u0435\u0440\u0435\u0432\u0435 -SettingsDialog.ShowServerDescription = \u041F\u043E\u043A\u0430\u0437\u044B\u0432\u0430\u0442\u044C \u043E\u043F\u0438\u0441\u0430\u043D\u0438\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 -SettingsDialog.ShowServerVersion = \u041F\u043E\u043A\u0430\u0437\u044B\u0432\u0430\u0442\u044C \u0432\u0435\u0440\u0441\u0438\u044E \u0441\u0435\u0440\u0432\u0435\u0440\u0430 -SettingsDialog.ShowWorkingProcesses = \u0420\u0430\u0431\u043E\u0447\u0438\u0435 \u043F\u0440\u043E\u0446\u0435\u0441\u0441\u044B -SettingsDialog.ShowWorkingServers = \u0420\u0430\u0431\u043E\u0447\u0438\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 -SettingsDialog.TitleDialog = \u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u044B \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u044F -SettingsDialog.WatchSessions = \u0426\u0432\u0435\u0442 \u043E\u0442\u0441\u043B\u0435\u0436\u0438\u0432\u0430\u0435\u043C\u044B\u0445 \u0441\u0435\u0441\u0441\u0438\u0439 +SettingsDialog.CheckUpdate = \u041F\u0440\u043E\u0432\u0435\u0440\u044F\u0442\u044C \u043E\u0431\u043D\u043E\u0432\u043B\u0435\u043D\u0438\u044F +SettingsDialog.ExpandClusters = \u041A\u043B\u0430\u0441\u0442\u0435\u0440\u044B +SettingsDialog.ExpandInfobases = \u0418\u043D\u0444\u043E\u0431\u0430\u0437\u044B +SettingsDialog.ExpandNodesInTree = \u0420\u0430\u0437\u0432\u043E\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u044C \u0443\u0437\u043B\u044B \u0432 \u0434\u0435\u0440\u0435\u0432\u0435 +SettingsDialog.ExpandServers = \u0421\u0435\u0440\u0432\u0435\u0440\u0430 +SettingsDialog.ExpandWorkingProcesses = \u0420\u0430\u0431\u043E\u0447\u0438\u0435 \u043F\u0440\u043E\u0446\u0435\u0441\u0441\u044B +SettingsDialog.ExpandWorkingServers = \u0420\u0430\u0431\u043E\u0447\u0438\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 +SettingsDialog.HighlightDuration = \u0414\u043B\u0438\u0442\u0435\u043B\u044C\u043D\u043E\u0441\u0442\u044C \u043F\u043E\u0434\u0441\u0432\u0435\u0442\u043A\u0438 (\u0441\u0435\u043A) +SettingsDialog.HighlightNewItems = \u041F\u043E\u0434\u0441\u0432\u0435\u0447\u0438\u0432\u0430\u0442\u044C \u043D\u043E\u0432\u044B\u0435 \u0441\u0442\u0440\u043E\u043A\u0438 +SettingsDialog.HighlightTitle = \u041F\u043E\u0434\u0441\u0432\u0435\u0447\u0438\u0432\u0430\u043D\u0438\u0435 +SettingsDialog.InfobaseDeniedEditMode = \u0412\u0430\u0440\u0438\u0430\u043D\u0442 \u0440\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u044F \u0434\u0430\u0442\u044B \u0437\u0430\u043F\u0440\u0435\u0442\u0430 \u0432\u0445\u043E\u0434\u0430 \u0432 \u0438\u043D\u0444\u043E\u0431\u0430\u0437\u044B: +SettingsDialog.InfobaseDeniedFriendlyEditMode = \u0423\u043B\u0443\u0447\u0448\u0435\u043D\u043D\u044B\u0439 +SettingsDialog.InfobaseDeniedMessagePattern = \u0428\u0430\u0431\u043B\u043E\u043D \u0441\u043E\u043E\u0431\u0449\u0435\u043D\u0438\u044F \u0431\u043B\u043E\u043A\u0438\u0440\u043E\u0432\u043A\u0438 \u0438\u043D\u0444\u043E\u0431\u0430\u0437\u044B: +SettingsDialog.InfobaseDeniedStandardEditMode = \u0421\u0442\u0430\u043D\u0434\u0430\u0440\u0442\u043D\u044B\u0439 +SettingsDialog.LocaleEnglish = \u0410\u043D\u0433\u043B\u0438\u0439\u0441\u043A\u0438\u0439 +SettingsDialog.LocaleRussian = \u0420\u0443\u0441\u0441\u043A\u0438\u0439 +SettingsDialog.LocaleSystem = \u0421\u0438\u0441\u0442\u0435\u043C\u043D\u044B\u0439 +SettingsDialog.LocaleTitle = \u042F\u0437\u044B\u043A \u0438\u043D\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 (\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044F \u043F\u0435\u0440\u0435\u0437\u0430\u043F\u0443\u0441\u043A) +SettingsDialog.LoggerLevelTitle = \u0423\u0440\u043E\u0432\u0435\u043D\u044C \u043B\u043E\u0433\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u044F +SettingsDialog.ReadClipboard = \u0427\u0438\u0442\u0430\u0442\u044C \u0431\u0443\u0444\u0435\u0440 \u043E\u0431\u043C\u0435\u043D\u0430 (\u043F\u0440\u0438 \u0434\u043E\u0431\u0430\u0432\u043B\u0435\u043D\u0438\u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430) +SettingsDialog.RowSortDirectionAsPrevious = \u041A\u0430\u043A \u043F\u0440\u0435\u0434\u044B\u0434\u0443\u0449\u0430\u044F +SettingsDialog.RowSortDirectionAscending = \u041F\u043E \u0443\u0431\u044B\u0432\u0430\u043D\u0438\u044E +SettingsDialog.RowSortDirectionDescending = \u041F\u043E \u0432\u043E\u0437\u0440\u0430\u0441\u0442\u0430\u043D\u0438\u044E +SettingsDialog.RowSortDirectionTitle = \u041D\u0430\u043F\u0440\u0430\u0432\u043B\u0435\u043D\u0438\u0435 \u0441\u043E\u0440\u0442\u0438\u0440\u043E\u0432\u043A\u0438 \u0441\u0442\u0440\u043E\u043A +SettingsDialog.ShadowSleepSessions = \u0417\u0430\u0442\u0435\u043D\u044F\u0442\u044C \u0441\u043F\u044F\u0446\u0438\u0435 \u0441\u0435\u0430\u043D\u0441\u044B +SettingsDialog.ShowInfo = \u0414\u043E\u043F\u043E\u043B\u043D\u0438\u0442\u0435\u043B\u044C\u043D\u0430\u044F \u0438\u043D\u0444\u043E\u0440\u043C\u0430\u0446\u0438\u044F +SettingsDialog.ShowInfobaseDescription = \u041F\u043E\u043A\u0430\u0437\u044B\u0432\u0430\u0442\u044C \u043E\u043F\u0438\u0441\u0430\u043D\u0438\u0435 \u0438\u043D\u0444\u043E\u0431\u0430\u0437\u044B +SettingsDialog.ShowLocalRASConnectInfo = \u041E \u043F\u043E\u0434\u043A\u043B\u044E\u0447\u0435\u043D\u0438\u0438 \u0447\u0435\u0440\u0435\u0437 \u043B\u043E\u043A\u0430\u043B\u044C\u043D\u044B\u0439 RAS +SettingsDialog.ShowNodesInTree = \u041F\u043E\u043A\u0430\u0437\u044B\u0432\u0430\u0442\u044C \u0443\u0437\u043B\u044B \u0432 \u0434\u0435\u0440\u0435\u0432\u0435 +SettingsDialog.ShowServerDescription = \u041F\u043E\u043A\u0430\u0437\u044B\u0432\u0430\u0442\u044C \u043E\u043F\u0438\u0441\u0430\u043D\u0438\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 +SettingsDialog.ShowServerVersion = \u041F\u043E\u043A\u0430\u0437\u044B\u0432\u0430\u0442\u044C \u0432\u0435\u0440\u0441\u0438\u044E \u0441\u0435\u0440\u0432\u0435\u0440\u0430 +SettingsDialog.ShowWorkingProcesses = \u0420\u0430\u0431\u043E\u0447\u0438\u0435 \u043F\u0440\u043E\u0446\u0435\u0441\u0441\u044B +SettingsDialog.ShowWorkingServers = \u0420\u0430\u0431\u043E\u0447\u0438\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 +SettingsDialog.TitleDialog = \u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u044B \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u044F +SettingsDialog.WatchSessions = \u0426\u0432\u0435\u0442 \u043E\u0442\u0441\u043B\u0435\u0436\u0438\u0432\u0430\u0435\u043C\u044B\u0445 \u0441\u0435\u0441\u0441\u0438\u0439 ViewerArea.Active = \u0410\u043A\u0442\u0438\u0432\u043D\u044B\u0439 ViewerArea.ColumnServer = \u0421\u0435\u0440\u0432\u0435\u0440 From 9eb95b918f75e195d6d002bd73f5ba621e051542 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Sun, 17 Mar 2024 18:27:38 +0300 Subject: [PATCH 29/70] =?UTF-8?q?=D0=94=D0=BE=D1=80=D0=B0=D0=B1=D0=BE?= =?UTF-8?q?=D1=82=D0=BA=D0=B0=20=D0=BE=D0=BA=D0=BD=D0=B0=20=D0=B8=D0=BD?= =?UTF-8?q?=D1=84=D0=BE=D0=B1=D0=B0=D0=B7=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../clusterAdminLibraryUI/InfobaseDialog.java | 292 +++++++++++++----- .../src/main/resources/icons/tumblerOff.png | Bin 0 -> 5671 bytes .../src/main/resources/icons/tumblerOn.png | Bin 0 -> 5681 bytes 3 files changed, 216 insertions(+), 76 deletions(-) create mode 100644 clusterAdminLibrary/src/main/resources/icons/tumblerOff.png create mode 100644 clusterAdminLibrary/src/main/resources/icons/tumblerOn.png diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/InfobaseDialog.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/InfobaseDialog.java index 95fd3b9..e60bb08 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/InfobaseDialog.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/InfobaseDialog.java @@ -13,14 +13,15 @@ import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.FontData; -import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.graphics.Image; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.layout.RowLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; @@ -29,6 +30,7 @@ import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; +import ru.yanygin.clusterAdminLibrary.Config; import ru.yanygin.clusterAdminLibrary.Helper; import ru.yanygin.clusterAdminLibrary.Server; @@ -42,6 +44,7 @@ public class InfobaseDialog extends Dialog { private static final String EMPTY_STRING = ""; //$NON-NLS-1$ private final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); //$NON-NLS-1$ + private final DateFormat dateDeniedFormat = new SimpleDateFormat("H:mm"); // $NON-NLS-1$ private final Date emptyDate = new Date(0); private Font fontNormal; private Font fontMicro; @@ -50,10 +53,13 @@ public class InfobaseDialog extends Dialog { private UUID clusterId; private UUID infoBaseId; private boolean creationMode = false; - private boolean deniedEditNewMode = false; + private boolean deniedFriendlyEditMode = false; private boolean deniedFromIsEmpty = true; private boolean deniedToIsEmpty = true; + private final Image tumblerOn = Helper.getImage("tumblerOn.png"); + private final Image tumblerOff = Helper.getImage("tumblerOff.png"); + // Controls private Text txtInfobaseName; private Text txtServerDbName; @@ -81,9 +87,13 @@ public class InfobaseDialog extends Dialog { private DateTime deniedFromTime; private Text txtDeniedToDate; private Button btnDeniedSwitchMode; - private Button btnDeniedStartClear; + private Button btnDeniedFromClear; private DateTime deniedToDate; private DateTime deniedToTime; + private Button btnDeniedToClear; + private Combo comboDeniedFrom; + private Combo comboDeniedTo; + private Button btnPutDeniedMessage; /** * Create the dialog. @@ -95,7 +105,7 @@ public class InfobaseDialog extends Dialog { */ public InfobaseDialog(Shell parentShell, Server server, UUID clusterId, UUID infoBaseId) { super(parentShell); - setShellStyle(SWT.DIALOG_TRIM | SWT.RESIZE | SWT.APPLICATION_MODAL); + setShellStyle(SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); this.server = server; this.clusterId = clusterId; @@ -213,67 +223,82 @@ protected Control createDialogArea(Composite parent) { compositeDeniedFrom.setLayout(null); txtDeniedFromDate = new Text(compositeDeniedFrom, SWT.BORDER); - txtDeniedFromDate.setBounds(0, 0, 165, 21); + txtDeniedFromDate.setBounds(0, 1, 185, 21); + txtDeniedFromDate.addModifyListener( + new ModifyListener() { + public void modifyText(ModifyEvent e) { + Date deniedFrom = convertStringToDate(txtDeniedFromDate.getText()); + setValueOnDateTimeFields(deniedFrom, deniedFromDate, deniedFromTime); + comboDeniedFrom.select(deniedFromTime.getHours() * 4); + } + }); deniedFromDate = new DateTime(compositeDeniedFrom, SWT.BORDER | SWT.DROP_DOWN); - deniedFromDate.setBounds(0, 0, 91, 21); + deniedFromDate.setBounds(0, 1, 91, 21); deniedFromDate.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - - Calendar calendar = - new GregorianCalendar( - deniedFromDate.getYear(), - deniedFromDate.getMonth(), - deniedFromDate.getDay(), - deniedFromTime.getHours(), - deniedFromTime.getMinutes(), - deniedFromTime.getSeconds()); - - deniedFromIsEmpty = false; - setDeniedFieldsState(); - - txtDeniedFromDate.setText(Helper.dateToStringReverse(calendar.getTime())); + convertDeniedFromDateToClassicTextField(); } }); - + deniedFromTime = new DateTime(compositeDeniedFrom, SWT.BORDER | SWT.TIME); - deniedFromTime.setBounds(95, 0, 70, 21); + deniedFromTime.setBounds(96, 1, 70, 21); + deniedFromTime.addSelectionListener( + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + convertDeniedFromDateToClassicTextField(); + } + }); - btnDeniedSwitchMode = new Button(compositeDeniedFrom, SWT.NONE); - btnDeniedSwitchMode.setBounds(170, 0, 28, 21); + btnDeniedSwitchMode = new Button(compositeDeniedFrom, SWT.CENTER); + btnDeniedSwitchMode.setToolTipText(Strings.SWITCH_DENIED_EDITING_MODE); + btnDeniedSwitchMode.setBounds(215, 1, 28, 21); + btnDeniedSwitchMode.setImage(tumblerOn); btnDeniedSwitchMode.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - deniedEditNewMode = !deniedEditNewMode; - - txtDeniedFromDate.setVisible(!deniedEditNewMode); - deniedFromDate.setVisible(deniedEditNewMode); - deniedFromTime.setVisible(deniedEditNewMode); - - txtDeniedToDate.setVisible(!deniedEditNewMode); - deniedToDate.setVisible(deniedEditNewMode); - deniedToTime.setVisible(deniedEditNewMode); + deniedFriendlyEditMode = !deniedFriendlyEditMode; + Config.currentConfig.setInfobaseDeniedFriendlyEditMode(deniedFriendlyEditMode); + setDeniedFieldsState(); + setImageOnDeniedSwitchButton(); } }); - btnDeniedSwitchMode.setText("<=>"); - btnDeniedStartClear = new Button(compositeDeniedFrom, SWT.NONE); - btnDeniedStartClear.setBounds(200, 0, 21, 21); - btnDeniedStartClear.addSelectionListener( + btnDeniedFromClear = new Button(compositeDeniedFrom, SWT.NONE); + btnDeniedFromClear.setText("x"); + btnDeniedFromClear.setBounds(190, 1, 21, 21); + btnDeniedFromClear.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { deniedFromIsEmpty = true; - deniedToIsEmpty = true; setDeniedFieldsState(); txtDeniedFromDate.setText(""); - txtDeniedToDate.setText(""); } }); - btnDeniedStartClear.setText("x"); + + comboDeniedFrom = new Combo(compositeDeniedFrom, SWT.READ_ONLY); + comboDeniedFrom.setBounds(95, 0, 90, 21); + comboDeniedFrom.addSelectionListener( + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + + int curTimeIndex = comboDeniedFrom.getSelectionIndex(); + int curHourIndex = curTimeIndex - (curTimeIndex % 4); + String curHour = comboDeniedFrom.getItem(curHourIndex).substring(0, 2); + + deniedFromTime.setHours(Integer.parseInt(curHour)); + deniedFromTime.setMinutes(15 * (curTimeIndex % 4)); + deniedFromTime.setSeconds(0); + + convertDeniedFromDateToClassicTextField(); + } + }); Label lblDeniedTo = new Label(container, SWT.NONE); lblDeniedTo.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); @@ -284,39 +309,95 @@ public void widgetSelected(SelectionEvent e) { compositeDeniedTo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); txtDeniedToDate = new Text(compositeDeniedTo, SWT.BORDER); - txtDeniedToDate.setBounds(0, 0, 165, 21); + txtDeniedToDate.setBounds(0, 1, 185, 21); + txtDeniedToDate.addModifyListener( + new ModifyListener() { + public void modifyText(ModifyEvent e) { + Date deniedTo = convertStringToDate(txtDeniedToDate.getText()); + setValueOnDateTimeFields(deniedTo, deniedToDate, deniedToTime); + comboDeniedTo.select(deniedToTime.getHours() * 4); + } + }); deniedToDate = new DateTime(compositeDeniedTo, SWT.BORDER | SWT.DROP_DOWN); - deniedToDate.setBounds(0, 0, 91, 21); + deniedToDate.setBounds(0, 1, 91, 21); deniedToDate.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { + convertDeniedToToClassicTextField(); + } + }); - Calendar calendar = - new GregorianCalendar( - deniedToDate.getYear(), - deniedToDate.getMonth(), - deniedToDate.getDay(), - deniedToDate.getHours(), - deniedToDate.getMinutes(), - deniedToDate.getSeconds()); + deniedToTime = new DateTime(compositeDeniedTo, SWT.BORDER | SWT.TIME); + deniedToTime.setBounds(95, 1, 70, 21); + deniedToTime.addSelectionListener( + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + convertDeniedToToClassicTextField(); + } + }); - deniedToIsEmpty = false; - setDeniedFieldsState(); + comboDeniedTo = new Combo(compositeDeniedTo, SWT.READ_ONLY); + comboDeniedTo.setBounds(95, 0, 90, 23); + // comboDeniedTo.select(0); + comboDeniedTo.addSelectionListener( + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + + int curTimeIndex = comboDeniedTo.getSelectionIndex(); + int curHourIndex = curTimeIndex - (curTimeIndex % 4); + String curHour = comboDeniedTo.getItem(curHourIndex).substring(0, 2); + + deniedToTime.setHours(Integer.parseInt(curHour)); + deniedToTime.setMinutes(15 * (curTimeIndex % 4)); + deniedToTime.setSeconds(0); - txtDeniedToDate.setText(Helper.dateToStringReverse(calendar.getTime())); + convertDeniedToToClassicTextField(); } }); - deniedToTime = new DateTime(compositeDeniedTo, SWT.BORDER | SWT.TIME); - deniedToTime.setBounds(95, 0, 70, 21); + btnDeniedToClear = new Button(compositeDeniedTo, SWT.NONE); + btnDeniedToClear.setText("x"); + btnDeniedToClear.setBounds(190, 1, 21, 21); + btnDeniedToClear.addSelectionListener( + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + deniedToIsEmpty = true; + setDeniedFieldsState(); + txtDeniedToDate.setText(""); + } + }); Label lblDeniedMessage = new Label(container, SWT.NONE); lblDeniedMessage.setText(Strings.SESSIONS_DENIED_MESSAGE); - txtDeniedMessage = new Text(container, SWT.BORDER | SWT.MULTI); + btnPutDeniedMessage = new Button(container, SWT.READ_ONLY); + btnPutDeniedMessage.setText(Strings.PUT_SESSIONS_DENIED_MESSAGE); + btnPutDeniedMessage.addSelectionListener( + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + + Date deniedFrom = getDeniedDate(deniedFromDate, deniedFromTime); + Date deniedTo = getDeniedDate(deniedToDate, deniedToTime); + + String deniedMessage = + String.format( + Config.currentConfig.getInfobaseDeniedMessagePattern(), + dateDeniedFormat.format(deniedFrom), + dateDeniedFormat.format(deniedTo)); + + txtDeniedMessage.setText(deniedMessage); + } + }); + + txtDeniedMessage = new Text(container, SWT.BORDER | SWT.WRAP | SWT.MULTI); GridData gdtxtDeniedMessage = new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1); + gdtxtDeniedMessage.widthHint = 200; gdtxtDeniedMessage.heightHint = 63; txtDeniedMessage.setLayoutData(gdtxtDeniedMessage); @@ -373,6 +454,20 @@ public void widgetSelected(SelectionEvent e) { getParentShell().getDisplay(), fontData.getName(), fontData.getHeight(), SWT.NORMAL); fontMicro = new Font(getParentShell().getDisplay(), fontData.getName(), 1, SWT.NORMAL); + for (int i = 0; i < 24; i++) { + comboDeniedFrom.add(String.format("%02d:00:00", i)); + comboDeniedFrom.add(" 15:00"); + comboDeniedFrom.add(" 30:00"); + comboDeniedFrom.add(" 45:00"); + + comboDeniedTo.add(String.format("%02d:00:00", i)); + comboDeniedTo.add(" 15:00"); + comboDeniedTo.add(" 30:00"); + comboDeniedTo.add(" 45:00"); + } + comboDeniedFrom.select(0); + comboDeniedTo.select(0); + initProperties(); return container; @@ -404,31 +499,33 @@ private void initProperties() { // Lock properties btnSessionsDenied.setSelection(infoBaseInfo.isSessionsDenied()); - // для отладки, заменить на чтение из конфига - deniedEditNewMode = true; + deniedFriendlyEditMode = Config.currentConfig.getInfobaseDeniedFriendlyEditMode(); + setImageOnDeniedSwitchButton(); // Дата запрета входа Начальная Date deniedFrom = infoBaseInfo.getDeniedFrom(); deniedFromIsEmpty = deniedFrom.equals(emptyDate); - txtDeniedFromDate.setText(convertDateToString(deniedFrom)); - if (!deniedFromIsEmpty) { - deniedFromDate.setDate( - deniedFrom.getYear() + 1900, deniedFrom.getMonth(), deniedFrom.getDate()); - deniedFromTime.setTime( - deniedFrom.getHours(), deniedFrom.getMinutes(), deniedFrom.getSeconds()); + if (deniedFromIsEmpty) { + deniedFromTime.setTime(deniedFromTime.getHours(), 0, 0); + } else { + txtDeniedFromDate.setText(convertDateToString(deniedFrom)); + setValueOnDateTimeFields(deniedFrom, deniedFromDate, deniedFromTime); } + comboDeniedFrom.select(deniedFromTime.getHours() * 4); // Дата запрета входа начальная // Дата запрета входа Конечная Date deniedTo = infoBaseInfo.getDeniedTo(); deniedToIsEmpty = deniedTo.equals(emptyDate); - txtDeniedToDate.setText(convertDateToString(deniedTo)); - if (!deniedToIsEmpty) { - deniedToDate.setDate(deniedTo.getYear() + 1900, deniedTo.getMonth(), deniedTo.getDate()); - deniedToTime.setTime(deniedTo.getHours(), deniedTo.getMinutes(), deniedTo.getSeconds()); + if (deniedToIsEmpty) { + deniedToTime.setTime(deniedToTime.getHours() + 1, 0, 0); + } else { + txtDeniedToDate.setText(convertDateToString(deniedTo)); + setValueOnDateTimeFields(deniedTo, deniedToDate, deniedToTime); } + comboDeniedTo.select(deniedToTime.getHours() * 4); // Дата запрета входа Конечная setDeniedFieldsState(); @@ -557,6 +654,11 @@ private String convertDateToString(Date date) { return date.equals(emptyDate) ? EMPTY_STRING : dateFormat.format(date); } + private void setValueOnDateTimeFields(Date date, DateTime dateField, DateTime timeField) { + dateField.setDate(date.getYear() + 1900, date.getMonth(), date.getDate()); + timeField.setTime(date.getHours(), date.getMinutes(), date.getSeconds()); + } + private void setDeniedFieldsState() { if (deniedFromIsEmpty) { @@ -575,15 +677,51 @@ private void setDeniedFieldsState() { deniedToTime.setFont(fontNormal); } - deniedFromDate.setVisible(deniedEditNewMode); - deniedFromTime.setVisible(deniedEditNewMode); - txtDeniedFromDate.setVisible(!deniedEditNewMode); + deniedFromDate.setVisible(deniedFriendlyEditMode); + deniedFromTime.setVisible(deniedFriendlyEditMode); + comboDeniedFrom.setVisible(deniedFriendlyEditMode); + txtDeniedFromDate.setVisible(!deniedFriendlyEditMode); + + deniedToDate.setVisible(deniedFriendlyEditMode); + deniedToTime.setVisible(deniedFriendlyEditMode); + comboDeniedTo.setVisible(deniedFriendlyEditMode); + txtDeniedToDate.setVisible(!deniedFriendlyEditMode); + } + + private void convertDeniedFromDateToClassicTextField() { - deniedToDate.setVisible(deniedEditNewMode); - deniedToTime.setVisible(deniedEditNewMode); - txtDeniedToDate.setVisible(!deniedEditNewMode); + deniedFromIsEmpty = false; + setDeniedFieldsState(); + + Date deniedDate = getDeniedDate(deniedFromDate, deniedFromTime); + txtDeniedFromDate.setText(Helper.dateToStringReverse(deniedDate)); + } + + private void convertDeniedToToClassicTextField() { + + deniedToIsEmpty = false; + setDeniedFieldsState(); + + Date deniedDate = getDeniedDate(deniedToDate, deniedToTime); + txtDeniedToDate.setText(Helper.dateToStringReverse(deniedDate)); } - + + private Date getDeniedDate(DateTime date, DateTime time) { + Calendar calendar = + new GregorianCalendar( + date.getYear(), + date.getMonth(), + date.getDay(), + time.getHours(), + time.getMinutes(), + time.getSeconds()); + return calendar.getTime(); + } + + private void setImageOnDeniedSwitchButton() { + btnDeniedSwitchMode.setImage(deniedFriendlyEditMode ? tumblerOn : tumblerOff); + } + /** * Create contents of the button bar. * @@ -635,6 +773,8 @@ private static class Strings { static final String SESSIONS_DENIED_FROM = getString("SessionsDeniedFrom"); static final String SESSIONS_DENIED_TO = getString("SessionsDeniedTo"); static final String SESSIONS_DENIED_MESSAGE = getString("SessionsDeniedMessage"); + static final String PUT_SESSIONS_DENIED_MESSAGE = getString("PutSessionsDeniedMessage"); + static final String SWITCH_DENIED_EDITING_MODE = getString("SwitchDeniedEditingMode"); static final String SESSIONS_PERMISSION_CODE = getString("SessionsPermissionCode"); static final String SESSIONS_DENIED_PARAMETER = getString("SessionsDeniedParameter"); static final String SHEDULED_JOBS_DENIED = getString("SheduledJobsDenied"); diff --git a/clusterAdminLibrary/src/main/resources/icons/tumblerOff.png b/clusterAdminLibrary/src/main/resources/icons/tumblerOff.png new file mode 100644 index 0000000000000000000000000000000000000000..1def590ae18c2d847b3a0b9112b618a0ec5540ce GIT binary patch literal 5671 zcmc&%2{@E{+aHobF{mtsF`Vp(0DRY#~__btr^W zlG91HP@R&HPRdpsC93zaI_tf=%*LQt$UC%u8|3ANb``!2bf9{F4voTvQDlZBG zf!14?;~jvz?EJM>82EnSr~eVS3DJzKjX9W$BAKt&89V}&zUi(lzJ5txSUj~#=08dE~wiJl_U3wxMmoY3EZ_gb8 zg$XDg3R4GJIhocREDu@>zIXpYM3ypJ@Su>uM4QcKvbQ=)+4&K1)cj5u~P(c8~VZt<&LQ z+RZJXP2+PesDVE^34|)`%Bo+qwb7{0#dcqLlgvHOo)QA(K33Dfm%pAKy)xG+4?5Hm zefZksX{|ERuvRV5Z@se~4|PFd7YmsRj~Z$uta0#YL8F?OiX%==$&x9JC@GmKiO;r? z4LMipX(|R|XWzHG>AkZeoeG1MZPw6Iwf?Pub`kBerKUeS@}tt4FFZwIqYQuX>_%zA ziRepb?puN@)0PYkoIW zcnvZ+BwQM%#S&uty7^-`7%bwnYLmH8QJBP4L&e8JqDIKaBGX}q?bgT}p}kf&8*S5F z-5PHBLjHyTBYgJI2CFdIp-nf1#lS)&WfcC{OXZE`(w&hl5Mhc$wNbqtc!Nlju?Sc~ z$~d6ivru+NcyUf(q1-1$tVm{LnPGUlo7cMYCqp8i-&$*Ryr^8NboJ)Ob%4ENCNK7~ z1aAtrMu@#oV5vR>DMjphF*&jGBL*kBJN!>@7+6w1_mnJj-JR9%%yQ%WPn<0^I~6B- zQGiaUi8pwuhC0;(VcN@XSWPgK%k{C(Dzw`mRw-Pmxc7Lmse&o*LZH2lJ-N`O%S>DD za#WAm(+hR&lCOohn`*#r#~8-f^WeG6ylw4Qkh1I6=fzaq_V<7yEmA8}rCJQEHow~9 z2}Z}JHF{LMcMdL9=ux_VN3=ZR@s1Ju5tk7#UvO5~>`u{(7S`B}?OP;L&X)YDa4YlH z`hK+|V*ctk)t(EFpQR0QCh|X;9@Y7R4H0ZGj8pTH9$Bk=Lgluav1(2dD}EwuBEejx zSn_i8F+A+Z)`|rGGyZA1rbjIkl!xP8%{x?->1&3;!&`=7!>VakJn(DM#%`F;G5ff@$F>8OmMtwS>$8W0F0_Q63PK zCa&9?{)S+kyUDR3Puz}1rBYJvoxJCHzvs8CWQBZXZLRY%S`kircG+ycRCgfvmpgP3 z+P!Jj%a$jTTkdNman23?w((x&z24-YZMG?XiMGjos(tET?F8~K6o3ok^2-nQ=iY8{ zc;oOizcimehE4l?2OJC-kD!w`x6875e%{g56ChX1e^Huu`_t)=F|HFiL9BZQQ zUguh87VKm~XtdpGn@1STQgcttNh_@0cg>dLZh1h%)w{&0pyymwMpX*GjDLE1mBQ87 z@K*Uu;miXyvTi3CSH}!`HwTtyMY!j>$2{i+JNG$cmo(Uhwu5{R`TmObLdYUjR02avf)m#=MWg#$;{wmNkJ|FQR5-Z{MY2-q3)An-uImC3QclxKuyiLO{xd!6=^OBj`qGb-bJXMhCY|(J+WV2W}1=9`tm9mDZKg ze9ZWILFdWM>VsBypEjj5*{VKP9kEHZ;hLA4XY|*wN~+-rxWqRJuM$5eN~nhJ5wWFP zHs#;Fl=br7L_$Cv{df8kdie0C;fUcpZ=aqK7xeuP{W?@bxe`>35V50;*kEUNgP@yC z&vr?iQPa?Ti?8Bh;I+HW;IyDtN?Fj@b#Hrb7w@3=#7WFh%w^90eGQ8Hm9E#*!aton zzFvB>K1T65{_(k+!v#kZ=dRA}OK;Tili9w}M^m zg8JG+nm=FW?cp`?#>H6@&x$@2j(fEqF4T?EOAVN?AUl)$uAgD1r*AlaD&1hqfP%dK z7VeGfPl~H&q6XqSH{BpSMg?nsdL1+F+VJ-9PM^!nyvmJAtC~+VXN4%uex5jzJ*dA; zcH92Y_PLy@%ue?%0p3e)3tx>N%O~*HXH6MAdFcDJ_e);K*+`qBtYST_pqi<5{Z_Zq zY-yaf)=bOYIvj)kIe%NLw$EacGK{~3r^Q{Ts{LmYX7j~@ZGvg=r)~zkrdPk;D>+k= z`AG8$Z|cC*^{35R}(;C{LE_JQT~n+&(wx`F8ztk)Bn z@vq}Mc8%5u}!niJkQUrf5#nq7)={)+vF)4n)Ib|y1I2zDTFh3ITYi; zA6Wghsi4o&{r3jk)Zr&3S=C|HW>*{!!dqnO;zKzfwFZ6rYA5^>#azZK#x-`o4tf3M z_2j!-1zon;UskV5ot$H;Jp;x{kO<4%g#!YKNzGpZoxLG*z+OF_=*)Gtw!)H`zAzGn z=|P40`?3HuFn8|uXOYO>R4&AWN~1IMq2sj;Pzar(58b!Z8ez>cp?cBH1KCu^KpP@C z(3`ABf$la~FN*WW0vdd&ToT0J*N4Hu`s+g%6k~zk^V@JJWC6nU)`uF+TZA}U+d)j2 zY${|Y4539vV2}`uHVmna(9_n_grE>e1RRNiBXqQo2<%QBECLBx`al755D1P<@x(gd zO_$68D}AUJm&?M!;eLL8Fh4Ym$)>@PdU|?r1PYEqX#of=P5^^T^4DT;wk|4JQiG>* z$ZR@`OJ_15^J+;ROdeMs3V6I2iZ5$fH-odp7r-3cpTvSAVTk$A7Jw`-CYQQ9IR@C9KO)`U$ZahYr)lj-v<+jif$ftWb% zgdri;Br=^b&(^%TB?&5?#HH#(f!u3rA$DpZ(L|&!b|(_MQ(FU}i$x$7q1He(QAk|U zcflwuLhs+eObXpI;D^xV)L>1RK1{YXlLGjGhC=?{2mXC6{rS>|avaQzAr=G^3{nq+ z(L%wHPzZ&L^<=VrNdVt;UlNT9Kg^=i7W}og##%5qToQv!wZQ8`fnZ^DIt7a$;1L)C z(g;sLAuzf~q%J}iZHm{^M(;#v>!I<+-(>MjGH<>RzR6PNWlerg)|O2NTA1YXU+Gxr zviX+7{Y?Uq>d&-L>sN7=s!ilA@P3@ z1O7*)^$#(uY`*_4hD9l|7l}cm0*G%3hHj7KsfM8W*TjeW)j!=?fvT zSUz+zX+D*3K7+D!hA$Tlgv*4iY}=nPN};mpE67}Fa@ilq|CR9{=kbTf%l~5@7aMqG z-{IijZ_%aB#V>MgI-kmg*An)-{r3~K3%sMSl>h2TU9`*m-yEsS#k@$sim_wi09xDy zW*T4x5b|xHnqMssWmE>x7HnYT>hhH%fU;=+MfbIcgl;^Kc^7OZG-zkV zYmrb)x#{}6cc@;BfS;3VVybo@=1D(L{6(O8B*M@TGZmI0GYrxTqq>~>GeD;7ZC0x% zTH%q(2BUYCx+1s6BL);|j<+J?w)UC67&>ZjUEBJhScG8GeJV=AYLAMPPqFl3W3Tk^9I?so>g^%8LcvLv&<90&~ytZ9-@_skDuOh-z w2?a4gC{AtGjSN4S6Z8^yO-}Ni5;$1!tJm3M#WUk4=4WaPf(^dR_|Wlx0cA+;3IG5A literal 0 HcmV?d00001 diff --git a/clusterAdminLibrary/src/main/resources/icons/tumblerOn.png b/clusterAdminLibrary/src/main/resources/icons/tumblerOn.png new file mode 100644 index 0000000000000000000000000000000000000000..e7fb1e76350fe90444b847ad373939a2b7629ff6 GIT binary patch literal 5681 zcmc&%2{@E%`yaA|vR1Y*rid^rgUOQ2Sh6z-*~ZKmQ_M^=V=qJtm9j<3k}X2E4kh8V z&QY=@sgx)k$}&+R%J*7weAmD4)OG&XcYSkR@4WLo@9*Az_kBO_J#qH7=4*xJgh3$C zT1yM8BXF0Qzg7zX->-rVr+^zD#l*%01gboBV8$UCSc8ccjy53BF)8!n z>p#?3E1TbmEsqsJ)n;f)^h#Em9fzOM=-2J<#*3m>f!102OEX;JAZQ6hoRZ`lNdExn zm4%Sk{+`{MuSgn{`F@KkLBZYP73se$&=QA-@*e&jn7tZ$rusB|m>+zNQot;x9(rzOqr9X;&wL8|B zQ{F(?Y&3d$yv;-ZgEirJ6tqlULrcZxk3vd5%5~%QzU*UDN`l`46$MN(LPWD~OW_X3 zT|D`~O1%0!=dJKHssSeLbN0C@vD@GB@78XJ>zIS zOuYq4qqG=&wBO~YV#LLToL6nI;JXwhR<&KRn@`vT(JeF?wbx!y&IIMh&oSAe$KMiT z^-As<4=rZKd!2O@#e2gI0TFRNf-(|&=#BDv3#pD{&0qnNSglEez4$tzyE}x$#Uyux zw)qyxY>g?-2`iHQqKFa7JXW?nrp?1|&AFoy$6nrCZ5@57Lb8-!{`MNc-XYUhyBNGT z1X_-Wyi#DO^njF(YqM#rsug!d7n>=V1zreq&~+ddxptas%U+J{ zGJk%dzD;6~kGA@Z0iX+`yhaHAphsA?*pQ7r9r$?pm`GjFc# zQ{68TqJBg5rNG!}%4-(4V9M-(?l(*XZ{zj^RX?fW)yjuA-%{P7l5>WU$c^GAS!^zr zxEyx~3*En|GAZO_NV=Zc0jnhCp+t9!_RY#v!6EUXjYH5Om2~Sa$hM@sKX}JQnW$;r zX^H80KHM#fTUOCpl_t4nxu!lA{k5At9i2KXnbo8+(vdepP4AOXjv?w=>eA{LJHsx? zT}pP`zuUK5$B!TY~?T3@5%k`4poTK zG^ujg>S${71FbWxl-GZ(Z>ny3ks7|mE-g6OF11&sSAEW&r{F@Ncu_(@g;!tht!Bq} zj?W893vgDaVfBTpHQuQUsF&?BDC#cPE6gu_lao@0FJPNc&C)Lp7iHwTmmM$*bvu&l zQ+{ig`fmM_@f4_4aBg9n#!&r7*Il?>cDr)+*1wB-7k#eAt;nsx?ff&-z-WxAp=Z5& zz4<|BQ`~L4O?G*>*IBBb$vNpowY#s_u{^EzXt?hyaW3pismZ8G3n~jbF}X^i>QqdN zT&6(gp6fCmM`=}~Mla;UDzc7v=6c4z3_R%4>zG~AXcyTA3h)m29pwj?L2Q=A$ok6F z$efaGKY1X2JRTFDCBIL`Ty_jOiu&f~LrC)J@MHGk?{z-c?)~lg$6%BpD%CaqsTQlM zwr*Nr0y-i6;A7hU)Df>BPP9)SrSfqur$46Pj7o3SW9GA+x3_i`ckMlFLgs_-lu5hX z-qq42Uux&tSY7#>MEAz4(+|7a&`&30M>?4!0~rJH4>%*8!)Jp&1?5e$XIy4hP3DOf zi&`HOIL0~k?vy`Am1DWZqi}O!o^5NUO~!P~NXrBi4Snz4QVS_lEW?$pq9JKHw8ym5 zJ&${&diL~C3^fh9!ZIeX;a@^V$2Wd(9QO&;34a*2C$xNG^po;5-wb}nVDjLSG@f>q(*3RSLU0@dEr-V3gxr#fZ9eJ}oJ zLPx?(4kqVTTNb>jVzAo(1(=!ylh{EL`H`oP8?sB;j60ERJ)OqZoIv^&QidW(3hbjLwWoByM|p+4?g$llDEs2Ag}Y`+gtIC_U6}cda2ZG z*W_tc4bAu18a5hMXKW6mgtw5&!bh*}bJ*v)FMJ$7fgXsz%yQe^sOYA2wSf}zhv%AmV)(w_cTko$a)7xKJP+*^%;H6jfIB4GsbSHYW=FrI7 z=Os0fnm*DVT4?n$wFs|UTWi0>59yxiJ@8DTk$9oAialrBZ2PjM&qK6MG|e(?AT@q$ z^7#t~TNrF>Wc3!`)-%V+>jT4u!jFWTYaG<5E7mR!a;`78Ep704?f%HQ#HFr2C_*W` zw=IJ6^>X0Oz`KECq71Q~OP`Cz{Mz;w>BZ`w4dq%AU5LF`PtwnyUw7{Kd83W}3UY=U z+1IW&M|I75e>h(&iIEOh|5lS;(x%;zU8*Y)= z;uhI9n^Tk7;n~R(_=epaq#AT82p6!Z=rM*+`Ye9LP;ea!Y!Rj-AUY#R-aGHr4*v<(odGDcHN@t5fl?+gC;OuV~-#@gvdV}UsSKmMRiZRH| zOdL#X-!{C>DcEVW;aXZKz3HjfV|YaLXJD*o zcTu^qy2ll|DILc7#24CUGGvBHwYg;CiB3QGRBhfxV z{rq!x3wy0R?>8EJ-21d7t2V0EyxhqP)+}A07|EK_dL7VP#|=&vaUH81(=Z;482mOk z@!@7+r(O0p{#9ouX6dRuz*q?qVpzDcKp+vx`HQFHMZ_$y*FeR)uw87dF+_R*lt7~U zkf9*~3;+$xoyH*y0&yRi4fY{Zs5C>!SY0CoOeGmYcI(){Z5XCxKdMC-lk5~`izkNd zBkGeN#zt#}4MH%0h5#~~01gT8r?D_0hL8ot7~uE(HVgt@fUx%&LQLi@f?aIv!KQR3 z8LR_^YZ2jS1Q@LiMQFqIwe>Z@NH_uxLm**rT`dG0qoa#~Bfv`^2w)BjHeix`F^*WX zC3C>a5aP#XGcYh%aBwg*7zL#>DKLb-zCH|&gdvey078ouN@Ej3v}mkNi%OQ%V96{Z zlgeOI=``@XT7nNfkZlM7JYEbXfU&Hb##-VFU=9{SV89Si__t@CZGO4g#a2tpV4=z~PHf8=#s<1UBJ^ zU?c{v|8HPAiRv5rQ|NMPFs5{WI@5+u0{lQhz<=!n|Gt*~d>KMmj^;bSmN-*1LLZIR zLP8M`Fo}rqr85Hv0N>OA0)-6Q%OF!0{I#*cSkhQ*0*y$v#2P|?V4+kh2?NJr;b^dWwCT(;Cvx`mnF^1n*N%s9g_;QFv0&H=~(Ep z`Ia;Iiv&D5gl$a-B{NyePnTL~2Z6F;YiZM;x`Mz3Ia@*iKrEh4q4<-*K7njDowkzX z1o3R8@(my&<7wyvjKS%0vF)tFZV(eHrfEIUw znFd$^gnS>U=2y!@8JPyO1rr##Is;_!AP`TkCDsIQVKtKSPy_2Ab1xf}ZQZ%fryzm< zO68|dg0U%Q;`v2H()075x+JbuC;MxfIc%7$qTG-0&-W!%!5!otsx|jKnRsbsra2lv zF#9gFwRS9HA|it&*ID#|(##o5NTEF=6lWF}9%jbeQ+K@DDci4FVtdyzAq74npkqb# z-aV!EAXnYV?YNo9EB!aOZTVd;-LY|fq9)kMJAes^s*))%=H0k!2%{lm$%NJvZ=6RkMT{HN^(s&(zoKy@xOW_M5N5PMGjBAnV8XCwbsJ-bO zm#LQOZ6 Date: Mon, 18 Mar 2024 18:16:19 +0300 Subject: [PATCH 30/70] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA?= =?UTF-8?q?=D0=B8=20=D0=B7=D0=B0=D0=BF=D1=83=D1=81=D0=BA=D0=B0=20=D0=BB?= =?UTF-8?q?=D0=BE=D0=BA=D0=B0=D0=BB=D1=8C=D0=BD=D0=BE=D0=B3=D0=BE=20RAS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yanygin/clusterAdminLibrary/Helper.java | 5 +++ .../yanygin/clusterAdminLibrary/Server.java | 35 ++++++++++--------- .../clusterAdminLibrary/messages.properties | 1 + .../messages_ru_RU.properties | 3 +- 4 files changed, 27 insertions(+), 17 deletions(-) diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java index 454eb5c..b6a7ba5 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java @@ -178,6 +178,11 @@ public static String pathToRas(String version, String bitness) { String pathToVersion = getInstalledV8Versions(bitness).get(version); String osPart; + if (pathToVersion == null) { + // указанная версия не обнаружена среди установленных + return null; + } + if (Config.currentConfig.isWindows()) { osPart = "bin"; } else if (Config.currentConfig.isLinux()) { diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java index 1b2de36..7b4d656 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java @@ -735,9 +735,9 @@ private void refreshAgentVersion() { if (newAgentVersion.version().size() == 3) { v8versionIsActual = - savedV8version.feature() != newAgentVersion.feature() - || savedV8version.interim() != newAgentVersion.interim() - || savedV8version.update() != newAgentVersion.update(); + savedV8version.feature() == newAgentVersion.feature() + && savedV8version.interim() == newAgentVersion.interim() + && savedV8version.update() == newAgentVersion.update(); } else { v8versionIsActual = savedV8version.equals(newAgentVersion); @@ -910,13 +910,21 @@ private boolean checkAndRunLocalRas() { } if (v8version.isBlank() || localRasPort == 0) { - var message = + connectionError = String.format( - Messages.getString("Server.LocalRasParamsIsEmpty"), //$NON-NLS-1$ + Messages.getString("Server.LocalRasParamsIsEmpty"), // $NON-NLS-1$ this.getServerKey()); - LOGGER.error(message); - Helper.showMessageBox(message); + LOGGER.error(connectionError); + return false; + } + Version savedV8version = Version.parse(v8version); + if (savedV8version.version().size() == 3) { + connectionError = + String.format( + Messages.getString("Server.LocalRasParamsIsInvalid"), // $NON-NLS-1$ + v8version); + LOGGER.error(connectionError); return false; } @@ -925,12 +933,10 @@ private boolean checkAndRunLocalRas() { var processOutput = ""; //$NON-NLS-1$ var localRasPath = Helper.pathToRas(v8version, "x64"); if (localRasPath == null) { - var message = + connectionError = String.format( - Messages.getString("Server.LocalRasNotFound"), this.getServerKey()); //$NON-NLS-1$ - LOGGER.error(message); - Helper.showMessageBox(message); - + Messages.getString("Server.LocalRasNotFound"), this.getServerKey()); // $NON-NLS-1$ + LOGGER.error(connectionError); return false; } @@ -956,8 +962,7 @@ private boolean checkAndRunLocalRas() { } catch (Exception excp) { LOGGER.error("Error launch local RAS for server <{}>", this.getServerKey()); //$NON-NLS-1$ LOGGER.error("Error: <{}>", processOutput, excp); //$NON-NLS-1$ - Helper.showMessageBox(excp.getLocalizedMessage()); - + connectionError = excp.getLocalizedMessage(); return false; } @@ -984,8 +989,6 @@ private boolean checkAndRunLocalRas() { connectionError = String.format("Local RAS <%s> is shutdown", this.getServerKey()); //$NON-NLS-1$ LOGGER.error(connectionError); - Helper.showMessageBox(connectionError); - return false; } } diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/messages.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/messages.properties index 7a59c68..ca3b5eb 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/messages.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/messages.properties @@ -23,6 +23,7 @@ Server.Designer = Designer Server.JobScheduler = Job scheduler Server.LocalRasNotFound = Local RAS not found Server.LocalRasParamsIsEmpty = Local RAS path or port for Server %s is empty +Server.LocalRasParamsIsInvalid = To run RAS, you need to specify the platform version in the server connection settings.\r\nThe full version must be specified with the completed assembly number (the fourth block of digits).\r\nFor example, 8.3.13 is incorrect, 8.3.13.1690 is correct.\r\nThe current specified version is %s Server.NotConnect = not connect Server.TerminateSessionMessage = Your session was interrupted by the administrator Server.TheClusterAuthenticationError = The cluster autentication error. diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/messages_ru_RU.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/messages_ru_RU.properties index 4da4f24..8aee912 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/messages_ru_RU.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/messages_ru_RU.properties @@ -20,7 +20,8 @@ Server.ClusterConsole = \u041A\u043E\u043D\u0441\u04 Server.Designer = \u041A\u043E\u043D\u0444\u0438\u0433\u0443\u0440\u0430\u0442\u043E\u0440 Server.JobScheduler = \u041F\u043B\u0430\u043D\u0438\u0440\u043E\u0432\u0449\u0438\u043A \u0437\u0430\u0434\u0430\u043D\u0438\u0439 Server.LocalRasNotFound = \u041D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D \u0438\u0441\u043F\u043E\u043B\u043D\u044F\u0435\u043C\u044B\u0439 \u0444\u0430\u0439\u043B \u043B\u043E\u043A\u0430\u043B\u044C\u043D\u043E\u0433\u043E RAS -Server.LocalRasParamsIsEmpty = \u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u044B \u043B\u043E\u043A\u0430\u043B\u044C\u043D\u043E\u0433\u043E RAS \u043D\u0435 \u0437\u0430\u043F\u043E\u043B\u043D\u0435\u043D\u044B +Server.LocalRasParamsIsEmpty = \u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u044B \u043B\u043E\u043A\u0430\u043B\u044C\u043D\u043E\u0433\u043E RAS \u0434\u043B\u044F \u0441\u0435\u0440\u0432\u0435\u0440\u0430 %s \u043D\u0435 \u0437\u0430\u043F\u043E\u043B\u043D\u0435\u043D\u044B +Server.LocalRasParamsIsInvalid = \u0414\u043B\u044F \u0437\u0430\u043F\u0443\u0441\u043A\u0430 RAS \u043D\u0435\u043E\u0431\u0445\u043E\u0434\u0438\u043C\u043E \u0443\u0442\u043E\u0447\u043D\u0438\u0442\u044C \u0432\u0435\u0440\u0441\u0438\u044E \u043F\u043B\u0430\u0442\u0444\u043E\u0440\u043C\u044B \u0432 \u043D\u0430\u0441\u0442\u0440\u043E\u0439\u043A\u0430\u0445 \u043F\u043E\u0434\u043A\u043B\u044E\u0447\u0435\u043D\u0438\u044F \u043A \u0441\u0435\u0440\u0432\u0435\u0440\u0443.\r\n\u0414\u043E\u043B\u0436\u043D\u0430 \u0431\u044B\u0442\u044C \u0443\u043A\u0430\u0437\u0430\u043D\u0430 \u043F\u043E\u043B\u043D\u0430\u044F \u0432\u0435\u0440\u0441\u0438\u044F \u0441 \u0437\u0430\u043F\u043E\u043B\u043D\u0435\u043D\u043D\u044B\u043C \u043D\u043E\u043C\u0435\u0440\u043E\u043C \u0441\u0431\u043E\u0440\u043A\u0438 (\u0447\u0435\u0442\u0432\u0435\u0440\u0442\u044B\u0439 \u0431\u043B\u043E\u043A \u0446\u044B\u0444\u0440).\r\n\u041D\u0430\u043F\u0440\u0438\u043C\u0435\u0440, 8.3.13 - \u043D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u043E, 8.3.13.1690 - \u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u043E.\r\n\u0422\u0435\u043A\u0443\u0449\u0430\u044F \u0443\u043A\u0430\u0437\u0430\u043D\u043D\u0430\u044F \u0432\u0435\u0440\u0441\u0438\u044F - %s Server.NotConnect = \u043D\u0435 \u043F\u043E\u0434\u043A\u043B\u044E\u0447\u0435\u043D Server.TerminateSessionMessage = \u0412\u0430\u0448 \u0441\u0435\u0430\u043D\u0441 \u0431\u044B\u043B \u043F\u0440\u0435\u0440\u0432\u0430\u043D \u0430\u0434\u043C\u0438\u043D\u0438\u0441\u0442\u0440\u0430\u0442\u043E\u0440\u043E\u043C Server.TheClusterAuthenticationError = \u041E\u0448\u0438\u0431\u043A\u0430 \u0430\u0443\u0442\u0435\u043D\u0442\u0438\u0444\u0438\u043A\u0430\u0446\u0438\u0438 \u043A\u043B\u0430\u0441\u0442\u0435\u0440\u0430. From 335008c48186a18949ce15c0457acb6e1086224f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Wed, 20 Mar 2024 08:10:08 +0300 Subject: [PATCH 31/70] =?UTF-8?q?=D0=A1=D1=80=D0=B0=D0=B2=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D1=81=20=D1=82=D0=B5=D0=BA=D1=83=D1=89?= =?UTF-8?q?=D0=B8=D0=BC=20=D0=B4=D0=BD=D0=B5=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/ru/yanygin/clusterAdminLibrary/Helper.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java index 1c5efa7..71eeadb 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java @@ -6,7 +6,9 @@ import java.nio.file.Paths; import java.text.DateFormat; import java.text.SimpleDateFormat; +import java.util.Calendar; import java.util.Date; +import java.util.GregorianCalendar; import java.util.HashMap; import java.util.Map; import java.util.UUID; @@ -286,8 +288,12 @@ public static String dateToString(Date date) { if (date == null || date.equals(emptyDate)) { return ""; } + Calendar calendar = new GregorianCalendar(); + calendar.set(Calendar.HOUR, 0); + calendar.set(Calendar.MINUTE, 0); + calendar.set(Calendar.SECOND, 0); - if (Config.currentConfig.showCurrentDateAsTime()) { + if (Config.currentConfig.showCurrentDateAsTime() && date.after(calendar.getTime())) { return currentDayDateFormat.format(date); } else { return normalDateFormat.format(date); From e7e5be02192dcca39299123e0a366ec93750651d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Sun, 31 Mar 2024 17:34:28 +0300 Subject: [PATCH 32/70] =?UTF-8?q?=D0=9A=D0=BB=D0=B0=D1=81=D1=81=20=D0=B4?= =?UTF-8?q?=D0=BB=D1=8F=20=D1=83=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=20=D0=BF=D0=BE=D0=BB=D1=8F=D0=BC=D0=B8=20=D0=B4?= =?UTF-8?q?=D0=B0=D1=82=D0=B0-=D0=B2=D1=80=D0=B5=D0=BC=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../clusterAdminLibraryUI/InfobaseDialog.java | 485 +++++++++--------- .../clusterAdminLibraryUI/messages.properties | 1 + .../messages_ru_RU.properties | 1 + 3 files changed, 236 insertions(+), 251 deletions(-) diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/InfobaseDialog.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/InfobaseDialog.java index e60bb08..ccf579a 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/InfobaseDialog.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/InfobaseDialog.java @@ -54,8 +54,6 @@ public class InfobaseDialog extends Dialog { private UUID infoBaseId; private boolean creationMode = false; private boolean deniedFriendlyEditMode = false; - private boolean deniedFromIsEmpty = true; - private boolean deniedToIsEmpty = true; private final Image tumblerOn = Helper.getImage("tumblerOn.png"); private final Image tumblerOff = Helper.getImage("tumblerOff.png"); @@ -82,18 +80,10 @@ public class InfobaseDialog extends Dialog { private Button btnExternalSessionManagerRequired; private Text txtDeniedMessage; - private Text txtDeniedFromDate; - private DateTime deniedFromDate; - private DateTime deniedFromTime; - private Text txtDeniedToDate; private Button btnDeniedSwitchMode; - private Button btnDeniedFromClear; - private DateTime deniedToDate; - private DateTime deniedToTime; - private Button btnDeniedToClear; - private Combo comboDeniedFrom; - private Combo comboDeniedTo; - private Button btnPutDeniedMessage; + + private DateTimeCombo deniedFromCombined; + private DateTimeCombo deniedToCombined; /** * Create the dialog. @@ -110,7 +100,9 @@ public InfobaseDialog(Shell parentShell, Server server, UUID clusterId, UUID inf this.server = server; this.clusterId = clusterId; this.infoBaseId = infoBaseId; - + + dateFormat.setLenient(false); + // три варианта открытия окна: // - существующая база // - новая база @@ -220,36 +212,29 @@ protected Control createDialogArea(Composite parent) { lblDeniedFrom.setText(Strings.SESSIONS_DENIED_FROM); Composite compositeDeniedFrom = new Composite(container, SWT.NONE); + compositeDeniedFrom.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1)); compositeDeniedFrom.setLayout(null); - txtDeniedFromDate = new Text(compositeDeniedFrom, SWT.BORDER); + Text txtDeniedFromDate = new Text(compositeDeniedFrom, SWT.BORDER); txtDeniedFromDate.setBounds(0, 1, 185, 21); - txtDeniedFromDate.addModifyListener( - new ModifyListener() { - public void modifyText(ModifyEvent e) { - Date deniedFrom = convertStringToDate(txtDeniedFromDate.getText()); - setValueOnDateTimeFields(deniedFrom, deniedFromDate, deniedFromTime); - comboDeniedFrom.select(deniedFromTime.getHours() * 4); - } - }); - deniedFromDate = new DateTime(compositeDeniedFrom, SWT.BORDER | SWT.DROP_DOWN); - deniedFromDate.setBounds(0, 1, 91, 21); - deniedFromDate.addSelectionListener( - new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - convertDeniedFromDateToClassicTextField(); - } - }); + DateTime deniedFromDate = new DateTime(compositeDeniedFrom, SWT.BORDER | SWT.DROP_DOWN); + deniedFromDate.setBounds(0, 0, 91, 23); + + DateTime deniedFromTime = new DateTime(compositeDeniedFrom, SWT.BORDER | SWT.TIME); + deniedFromTime.setBounds(96, 0, 70, 23); - deniedFromTime = new DateTime(compositeDeniedFrom, SWT.BORDER | SWT.TIME); - deniedFromTime.setBounds(96, 1, 70, 21); - deniedFromTime.addSelectionListener( + Combo comboDeniedFrom = new Combo(compositeDeniedFrom, SWT.READ_ONLY); + comboDeniedFrom.setBounds(96, 0, 90, 21); + + Button btnDeniedFromClear = new Button(compositeDeniedFrom, SWT.NONE); + btnDeniedFromClear.setText("X"); + btnDeniedFromClear.setBounds(184, -1, 23, 25); + btnDeniedFromClear.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - convertDeniedFromDateToClassicTextField(); + deniedFromCombined.clear(); } }); @@ -261,42 +246,7 @@ public void widgetSelected(SelectionEvent e) { new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - deniedFriendlyEditMode = !deniedFriendlyEditMode; - Config.currentConfig.setInfobaseDeniedFriendlyEditMode(deniedFriendlyEditMode); - setDeniedFieldsState(); - setImageOnDeniedSwitchButton(); - } - }); - - btnDeniedFromClear = new Button(compositeDeniedFrom, SWT.NONE); - btnDeniedFromClear.setText("x"); - btnDeniedFromClear.setBounds(190, 1, 21, 21); - btnDeniedFromClear.addSelectionListener( - new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - deniedFromIsEmpty = true; - setDeniedFieldsState(); - txtDeniedFromDate.setText(""); - } - }); - - comboDeniedFrom = new Combo(compositeDeniedFrom, SWT.READ_ONLY); - comboDeniedFrom.setBounds(95, 0, 90, 21); - comboDeniedFrom.addSelectionListener( - new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - - int curTimeIndex = comboDeniedFrom.getSelectionIndex(); - int curHourIndex = curTimeIndex - (curTimeIndex % 4); - String curHour = comboDeniedFrom.getItem(curHourIndex).substring(0, 2); - - deniedFromTime.setHours(Integer.parseInt(curHour)); - deniedFromTime.setMinutes(15 * (curTimeIndex % 4)); - deniedFromTime.setSeconds(0); - - convertDeniedFromDateToClassicTextField(); + switchDeniedEditMode(); } }); @@ -308,82 +258,40 @@ public void widgetSelected(SelectionEvent e) { compositeDeniedTo.setLayout(null); compositeDeniedTo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); - txtDeniedToDate = new Text(compositeDeniedTo, SWT.BORDER); + Text txtDeniedToDate = new Text(compositeDeniedTo, SWT.BORDER); txtDeniedToDate.setBounds(0, 1, 185, 21); - txtDeniedToDate.addModifyListener( - new ModifyListener() { - public void modifyText(ModifyEvent e) { - Date deniedTo = convertStringToDate(txtDeniedToDate.getText()); - setValueOnDateTimeFields(deniedTo, deniedToDate, deniedToTime); - comboDeniedTo.select(deniedToTime.getHours() * 4); - } - }); - - deniedToDate = new DateTime(compositeDeniedTo, SWT.BORDER | SWT.DROP_DOWN); - deniedToDate.setBounds(0, 1, 91, 21); - deniedToDate.addSelectionListener( - new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - convertDeniedToToClassicTextField(); - } - }); - deniedToTime = new DateTime(compositeDeniedTo, SWT.BORDER | SWT.TIME); - deniedToTime.setBounds(95, 1, 70, 21); - deniedToTime.addSelectionListener( - new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - convertDeniedToToClassicTextField(); - } - }); + DateTime deniedToDate = new DateTime(compositeDeniedTo, SWT.BORDER | SWT.DROP_DOWN); + deniedToDate.setBounds(0, 0, 91, 23); - comboDeniedTo = new Combo(compositeDeniedTo, SWT.READ_ONLY); - comboDeniedTo.setBounds(95, 0, 90, 23); - // comboDeniedTo.select(0); - comboDeniedTo.addSelectionListener( - new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - - int curTimeIndex = comboDeniedTo.getSelectionIndex(); - int curHourIndex = curTimeIndex - (curTimeIndex % 4); - String curHour = comboDeniedTo.getItem(curHourIndex).substring(0, 2); - - deniedToTime.setHours(Integer.parseInt(curHour)); - deniedToTime.setMinutes(15 * (curTimeIndex % 4)); - deniedToTime.setSeconds(0); + DateTime deniedToTime = new DateTime(compositeDeniedTo, SWT.BORDER | SWT.TIME); + deniedToTime.setBounds(96, 0, 70, 23); - convertDeniedToToClassicTextField(); - } - }); + Combo comboDeniedTo = new Combo(compositeDeniedTo, SWT.READ_ONLY); + comboDeniedTo.setBounds(96, 0, 90, 23); - btnDeniedToClear = new Button(compositeDeniedTo, SWT.NONE); - btnDeniedToClear.setText("x"); - btnDeniedToClear.setBounds(190, 1, 21, 21); + Button btnDeniedToClear = new Button(compositeDeniedTo, SWT.NONE); + btnDeniedToClear.setText("X"); + btnDeniedToClear.setBounds(184, -1, 23, 25); btnDeniedToClear.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - deniedToIsEmpty = true; - setDeniedFieldsState(); - txtDeniedToDate.setText(""); + deniedToCombined.clear(); } }); Label lblDeniedMessage = new Label(container, SWT.NONE); lblDeniedMessage.setText(Strings.SESSIONS_DENIED_MESSAGE); - btnPutDeniedMessage = new Button(container, SWT.READ_ONLY); + Button btnPutDeniedMessage = new Button(container, SWT.READ_ONLY); btnPutDeniedMessage.setText(Strings.PUT_SESSIONS_DENIED_MESSAGE); btnPutDeniedMessage.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - - Date deniedFrom = getDeniedDate(deniedFromDate, deniedFromTime); - Date deniedTo = getDeniedDate(deniedToDate, deniedToTime); + Date deniedFrom = deniedFromCombined.getDate(); // надо учесть пустую дату + Date deniedTo = deniedToCombined.getDate(); String deniedMessage = String.format( @@ -454,19 +362,10 @@ public void widgetSelected(SelectionEvent e) { getParentShell().getDisplay(), fontData.getName(), fontData.getHeight(), SWT.NORMAL); fontMicro = new Font(getParentShell().getDisplay(), fontData.getName(), 1, SWT.NORMAL); - for (int i = 0; i < 24; i++) { - comboDeniedFrom.add(String.format("%02d:00:00", i)); - comboDeniedFrom.add(" 15:00"); - comboDeniedFrom.add(" 30:00"); - comboDeniedFrom.add(" 45:00"); - - comboDeniedTo.add(String.format("%02d:00:00", i)); - comboDeniedTo.add(" 15:00"); - comboDeniedTo.add(" 30:00"); - comboDeniedTo.add(" 45:00"); - } - comboDeniedFrom.select(0); - comboDeniedTo.select(0); + deniedFromCombined = + new DateTimeCombo(txtDeniedFromDate, deniedFromDate, deniedFromTime, comboDeniedFrom); + deniedToCombined = + new DateTimeCombo(txtDeniedToDate, deniedToDate, deniedToTime, comboDeniedTo); initProperties(); @@ -500,35 +399,11 @@ private void initProperties() { btnSessionsDenied.setSelection(infoBaseInfo.isSessionsDenied()); deniedFriendlyEditMode = Config.currentConfig.getInfobaseDeniedFriendlyEditMode(); - setImageOnDeniedSwitchButton(); - - // Дата запрета входа Начальная - Date deniedFrom = infoBaseInfo.getDeniedFrom(); - deniedFromIsEmpty = deniedFrom.equals(emptyDate); - - if (deniedFromIsEmpty) { - deniedFromTime.setTime(deniedFromTime.getHours(), 0, 0); - } else { - txtDeniedFromDate.setText(convertDateToString(deniedFrom)); - setValueOnDateTimeFields(deniedFrom, deniedFromDate, deniedFromTime); - } - comboDeniedFrom.select(deniedFromTime.getHours() * 4); - // Дата запрета входа начальная - - // Дата запрета входа Конечная - Date deniedTo = infoBaseInfo.getDeniedTo(); - deniedToIsEmpty = deniedTo.equals(emptyDate); - - if (deniedToIsEmpty) { - deniedToTime.setTime(deniedToTime.getHours() + 1, 0, 0); - } else { - txtDeniedToDate.setText(convertDateToString(deniedTo)); - setValueOnDateTimeFields(deniedTo, deniedToDate, deniedToTime); - } - comboDeniedTo.select(deniedToTime.getHours() * 4); - // Дата запрета входа Конечная + setActiveDeniedFields(); - setDeniedFieldsState(); + // Даты запрета входа + deniedFromCombined.setDate(infoBaseInfo.getDeniedFrom(), true); + deniedToCombined.setDate(infoBaseInfo.getDeniedTo(), true); txtDeniedMessage.setText(infoBaseInfo.getDeniedMessage()); txtPermissionCode.setText(infoBaseInfo.getPermissionCode()); @@ -567,18 +442,13 @@ private boolean checkVariablesFromControls() { } } - List checksDateControls = new ArrayList<>(); - checksDateControls.add(txtDeniedFromDate); - checksDateControls.add(txtDeniedToDate); + List checksDateControls = new ArrayList<>(); + checksDateControls.add(deniedFromCombined); + checksDateControls.add(deniedToCombined); - for (Text control : checksDateControls) { - if (control.getText().isBlank()) { - control.setBackground(Helper.getWhiteColor()); - } else { - if (convertStringToDate(control.getText()).equals(emptyDate)) { - control.setBackground(Helper.getPinkColor()); - existsError = true; - } + for (DateTimeCombo control : checksDateControls) { + if (!control.valueIsValid()) { + existsError = true; } } @@ -588,6 +458,7 @@ private boolean checkVariablesFromControls() { private boolean saveInfobaseProperties() { if (checkVariablesFromControls()) { + Helper.showMessageBox(Strings.SAVE_ERROR); return false; } @@ -611,8 +482,8 @@ private boolean saveInfobaseProperties() { // Lock properties infoBaseInfo.setSessionsDenied(btnSessionsDenied.getSelection()); - infoBaseInfo.setDeniedFrom(convertStringToDate(txtDeniedFromDate.getText())); - infoBaseInfo.setDeniedTo(convertStringToDate(txtDeniedToDate.getText())); + infoBaseInfo.setDeniedFrom(deniedFromCombined.getDate()); + infoBaseInfo.setDeniedTo(deniedToCombined.getDate()); infoBaseInfo.setDeniedMessage(txtDeniedMessage.getText()); infoBaseInfo.setPermissionCode(txtPermissionCode.getText()); @@ -638,87 +509,27 @@ private Date convertStringToDate(String date) { } Date convertDate; - + try { convertDate = dateFormat.parse(date); } catch (ParseException excp) { - excp.printStackTrace(); - convertDate = emptyDate; + convertDate = null; } return convertDate; } - private String convertDateToString(Date date) { - - return date.equals(emptyDate) ? EMPTY_STRING : dateFormat.format(date); - } + private void switchDeniedEditMode() { + deniedFriendlyEditMode = !deniedFriendlyEditMode; + Config.currentConfig.setInfobaseDeniedFriendlyEditMode(deniedFriendlyEditMode); - private void setValueOnDateTimeFields(Date date, DateTime dateField, DateTime timeField) { - dateField.setDate(date.getYear() + 1900, date.getMonth(), date.getDate()); - timeField.setTime(date.getHours(), date.getMinutes(), date.getSeconds()); + setActiveDeniedFields(); } - private void setDeniedFieldsState() { + private void setActiveDeniedFields() { + deniedFromCombined.setEditMode(); + deniedToCombined.setEditMode(); - if (deniedFromIsEmpty) { - deniedFromDate.setFont(fontMicro); - deniedFromTime.setFont(fontMicro); - } else { - deniedFromDate.setFont(fontNormal); - deniedFromTime.setFont(fontNormal); - } - - if (deniedToIsEmpty) { - deniedToDate.setFont(fontMicro); - deniedToTime.setFont(fontMicro); - } else { - deniedToDate.setFont(fontNormal); - deniedToTime.setFont(fontNormal); - } - - deniedFromDate.setVisible(deniedFriendlyEditMode); - deniedFromTime.setVisible(deniedFriendlyEditMode); - comboDeniedFrom.setVisible(deniedFriendlyEditMode); - txtDeniedFromDate.setVisible(!deniedFriendlyEditMode); - - deniedToDate.setVisible(deniedFriendlyEditMode); - deniedToTime.setVisible(deniedFriendlyEditMode); - comboDeniedTo.setVisible(deniedFriendlyEditMode); - txtDeniedToDate.setVisible(!deniedFriendlyEditMode); - } - - private void convertDeniedFromDateToClassicTextField() { - - deniedFromIsEmpty = false; - setDeniedFieldsState(); - - Date deniedDate = getDeniedDate(deniedFromDate, deniedFromTime); - txtDeniedFromDate.setText(Helper.dateToStringReverse(deniedDate)); - } - - private void convertDeniedToToClassicTextField() { - - deniedToIsEmpty = false; - setDeniedFieldsState(); - - Date deniedDate = getDeniedDate(deniedToDate, deniedToTime); - txtDeniedToDate.setText(Helper.dateToStringReverse(deniedDate)); - } - - private Date getDeniedDate(DateTime date, DateTime time) { - Calendar calendar = - new GregorianCalendar( - date.getYear(), - date.getMonth(), - date.getDay(), - time.getHours(), - time.getMinutes(), - time.getSeconds()); - return calendar.getTime(); - } - - private void setImageOnDeniedSwitchButton() { btnDeniedSwitchMode.setImage(deniedFriendlyEditMode ? tumblerOn : tumblerOff); } @@ -753,6 +564,177 @@ public void widgetSelected(SelectionEvent e) { }); } + private class DateTimeCombo { + Text textField; + DateTime dateField; + DateTime timeField; + Combo comboField; + + boolean dateIsEmpty = false; + boolean deniedModifyEventOff = false; + + public DateTimeCombo(Text textField, DateTime dateField, DateTime timeField, Combo comboField) { + this.textField = textField; + this.dateField = dateField; + this.timeField = timeField; + this.comboField = comboField; + + for (int i = 0; i < 24; i++) { + this.comboField.add(String.format("%02d:00:00", i)); + this.comboField.add(" 15:00"); + this.comboField.add(" 30:00"); + this.comboField.add(" 45:00"); + } + + // установка обработчиков + this.textField.addModifyListener( + new ModifyListener() { + public void modifyText(ModifyEvent e) { + if (deniedModifyEventOff) { + deniedModifyEventOff = false; + return; + } + parseTextDate(); + } + }); + this.dateField.addSelectionListener( + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + update(); + } + }); + this.timeField.addSelectionListener( + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + update(); + } + }); + this.comboField.addSelectionListener( + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + updateTime(); + } + }); + } + + private void parseTextDate() { + Date date = convertStringToDate(textField.getText()); + if (date != null) { + setDate(date, false); + } + } + + private void setDate(Date dateValue, boolean modifyTextField) { + dateIsEmpty = dateValue.equals(emptyDate); + updateEmptyState(); + + if (dateIsEmpty) { + timeField.setTime(timeField.getHours(), 0, 0); + comboField.select(timeField.getHours() * 4); + } else { + if (modifyTextField) { + deniedModifyEventOff = true; + textField.setText(convertDateToString(dateValue)); + } + + dateField.setDate(dateValue.getYear() + 1900, dateValue.getMonth(), dateValue.getDate()); + timeField.setTime(dateValue.getHours(), dateValue.getMinutes(), dateValue.getSeconds()); + comboField.select(timeField.getHours() * 4); + } + } + + private void update() { + comboField.select(timeField.getHours() * 4); + + dateIsEmpty = false; + updateEmptyState(); + + Date deniedDate = getDate(); + deniedModifyEventOff = true; + textField.setText(Helper.dateToStringReverse(deniedDate)); // TODO = convertDateToString??? + } + + private void updateTime() { + int newMinutesIndex = comboField.getSelectionIndex(); + int newHourIndex = newMinutesIndex - (newMinutesIndex % 4); + String newHour = comboField.getItem(newHourIndex).substring(0, 2); + + timeField.setHours(Integer.parseInt(newHour)); + timeField.setMinutes(15 * (newMinutesIndex % 4)); + timeField.setSeconds(0); + + update(); + } + + private void updateEmptyState() { + if (dateIsEmpty) { + dateField.setFont(fontMicro); + timeField.setFont(fontMicro); + } else { + dateField.setFont(fontNormal); + timeField.setFont(fontNormal); + } + } + + private void clear() { + dateIsEmpty = true; + updateEmptyState(); + deniedModifyEventOff = true; + textField.setText(""); + + Date curDate = Calendar.getInstance().getTime(); + + dateField.setDate(curDate.getYear() + 1900, curDate.getMonth(), curDate.getDate()); + timeField.setTime(curDate.getHours(), 0, 0); + comboField.select(curDate.getHours() * 4); + } + + private Date getDate() { + if (dateIsEmpty) { + return emptyDate; + } + Calendar calendar = + new GregorianCalendar( + dateField.getYear(), + dateField.getMonth(), + dateField.getDay(), + timeField.getHours(), + timeField.getMinutes(), + timeField.getSeconds()); + return calendar.getTime(); + } + + private String convertDateToString(Date date) { + + return date.equals(emptyDate) ? EMPTY_STRING : dateFormat.format(date); + } + + private boolean valueIsValid() { + if (deniedFriendlyEditMode) { + return true; + } + if (textField.getText().isBlank()) { + textField.setBackground(Helper.getWhiteColor()); + } else if (convertStringToDate(textField.getText()) == null) { + textField.setBackground(Helper.getPinkColor()); + return false; + } else { + textField.setBackground(Helper.getWhiteColor()); + } + return true; + } + + private void setEditMode() { + textField.setVisible(!deniedFriendlyEditMode); + dateField.setVisible(deniedFriendlyEditMode); + timeField.setVisible(deniedFriendlyEditMode); + comboField.setVisible(deniedFriendlyEditMode); + } + } + private static class Strings { static final String TITLE_WINDOW = getString("TitleDialog"); @@ -783,6 +765,7 @@ private static class Strings { getString("RequiredUseOfExternalManagement"); static final String SECURITY_PROFILE = getString("SecurityProfile"); static final String SAFE_MODE_SECURITY_PROFILE = getString("SafeModeSecurityProfile"); + static final String SAVE_ERROR = getString("SaveError"); static final String APPLY = Messages.getString("Dialogs.Apply"); diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties index c8c1e6d..c3aa4dc 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties @@ -67,6 +67,7 @@ InfobaseDialog.Locale = Locale InfobaseDialog.PutSessionsDeniedMessage = Fill on the template InfobaseDialog.RequiredUseOfExternalManagement = Required use of external management InfobaseDialog.SafeModeSecurityProfile = Safe mode security profile +InfobaseDialog.SaveError = The parameters of the infobase are not saved - there are errors! InfobaseDialog.SecurityProfile = Security profile InfobaseDialog.ServerDBName = Server DB name InfobaseDialog.SessionsDenied = Sessions denied diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties index 9fbf6d5..1ecfb37 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties @@ -67,6 +67,7 @@ InfobaseDialog.Locale = \u042F\u0437\u044B\u043A (\u042 InfobaseDialog.PutSessionsDeniedMessage = \u0417\u0430\u043F\u043E\u043B\u043D\u0438\u0442\u044C \u043F\u043E \u0448\u0430\u0431\u043B\u043E\u043D\u0443 InfobaseDialog.RequiredUseOfExternalManagement = \u041E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u043E\u0435 \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u043D\u0438\u0435 \u0432\u043D\u0435\u0448\u043D\u0435\u0433\u043E \u0443\u043F\u0440\u0430\u0432\u043B\u0435\u043D\u0438\u044F InfobaseDialog.SafeModeSecurityProfile = \u041F\u0440\u043E\u0444\u0438\u043B\u044C \u0431\u0435\u0437\u043E\u043F\u0430\u0441\u043D\u043E\u0441\u0442\u0438\r\n\u0431\u0435\u0437\u043E\u043F\u0430\u0441\u043D\u043E\u0433\u043E \u0440\u0435\u0436\u0438\u043C\u0430 +InfobaseDialog.SaveError = \u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u044B \u0438\u043D\u0444\u043E\u0431\u0430\u0437\u044B \u043D\u0435 \u0441\u043E\u0445\u0440\u0430\u043D\u0435\u043D\u044B - \u0441\u043E\u0434\u0435\u0440\u0436\u0430\u0442\u0441\u044F \u043E\u0448\u0438\u0431\u043A\u0438! InfobaseDialog.SecurityProfile = \u041F\u0440\u043E\u0444\u0438\u043B\u044C \u0431\u0435\u0437\u043E\u043F\u0430\u0441\u043D\u043E\u0441\u0442\u0438 InfobaseDialog.ServerDBName = \u0421\u0435\u0440\u0432\u0435\u0440 \u0431\u0430\u0437 \u0434\u0430\u043D\u043D\u044B\u0445 InfobaseDialog.SessionsDenied = \u0411\u043B\u043E\u043A\u0438\u0440\u043E\u0432\u043A\u0430 \u043D\u0430\u0447\u0430\u043B\u0430 \u0441\u0435\u0430\u043D\u0441\u043E\u0432 \u0432\u043A\u043B\u044E\u0447\u0435\u043D\u0430 From 839281ca3ddf81a460abfa4b3145b5381760b15e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Wed, 3 Apr 2024 08:32:33 +0300 Subject: [PATCH 33/70] =?UTF-8?q?=D0=9F=D1=80=D0=BE=D0=B2=D0=B5=D1=80?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=BD=D0=B0=20=D0=BF=D1=83=D1=81=D1=82=D0=BE?= =?UTF-8?q?=D1=82=D1=83=20=D1=83=20=D0=B2=D1=80=D0=B5=D0=BC=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=20=D0=B1=D0=BB=D0=BE=D0=BA=D0=B8=D1=80=D0=BE=D0=B2=D0=BA?= =?UTF-8?q?=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../clusterAdminLibraryUI/InfobaseDialog.java | 13 +++++++++---- .../clusterAdminLibraryUI/messages.properties | 2 +- .../clusterAdminLibraryUI/messages_ru_RU.properties | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/InfobaseDialog.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/InfobaseDialog.java index ccf579a..3e75e08 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/InfobaseDialog.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/InfobaseDialog.java @@ -290,14 +290,12 @@ public void widgetSelected(SelectionEvent e) { new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - Date deniedFrom = deniedFromCombined.getDate(); // надо учесть пустую дату - Date deniedTo = deniedToCombined.getDate(); String deniedMessage = String.format( Config.currentConfig.getInfobaseDeniedMessagePattern(), - dateDeniedFormat.format(deniedFrom), - dateDeniedFormat.format(deniedTo)); + deniedFromCombined.getDeniedTime(), + deniedToCombined.getDeniedTime()); txtDeniedMessage.setText(deniedMessage); } @@ -707,6 +705,13 @@ private Date getDate() { return calendar.getTime(); } + private String getDeniedTime() { + if (dateIsEmpty) { + return "-"; + } + return dateDeniedFormat.format(getDate()); + } + private String convertDateToString(Date date) { return date.equals(emptyDate) ? EMPTY_STRING : dateFormat.format(date); diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties index c3aa4dc..14b33a6 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties @@ -123,7 +123,7 @@ SettingsDialog.HighlightNewItems = Highlight new items SettingsDialog.HighlightTitle = Highlight SettingsDialog.InfobaseDeniedEditMode = Infobase denied editing mode: SettingsDialog.InfobaseDeniedFriendlyEditMode = User-friendly -SettingsDialog.InfobaseDeniedMessagePattern = Infobase denied message pattern: +SettingsDialog.InfobaseDeniedMessagePattern = Infobase denied message pattern:\r\n(start time - %1$s, end time - %2$s) SettingsDialog.InfobaseDeniedStandardEditMode = Standard SettingsDialog.LocaleEnglish = English SettingsDialog.LocaleRussian = Russian diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties index 1ecfb37..3b2b9a5 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties @@ -123,7 +123,7 @@ SettingsDialog.HighlightNewItems = \u041F\u043E\u0434\u0441\u0432\u SettingsDialog.HighlightTitle = \u041F\u043E\u0434\u0441\u0432\u0435\u0447\u0438\u0432\u0430\u043D\u0438\u0435 SettingsDialog.InfobaseDeniedEditMode = \u0412\u0430\u0440\u0438\u0430\u043D\u0442 \u0440\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u044F \u0434\u0430\u0442\u044B \u0437\u0430\u043F\u0440\u0435\u0442\u0430 \u0432\u0445\u043E\u0434\u0430 \u0432 \u0438\u043D\u0444\u043E\u0431\u0430\u0437\u044B: SettingsDialog.InfobaseDeniedFriendlyEditMode = \u0423\u043B\u0443\u0447\u0448\u0435\u043D\u043D\u044B\u0439 -SettingsDialog.InfobaseDeniedMessagePattern = \u0428\u0430\u0431\u043B\u043E\u043D \u0441\u043E\u043E\u0431\u0449\u0435\u043D\u0438\u044F \u0431\u043B\u043E\u043A\u0438\u0440\u043E\u0432\u043A\u0438 \u0438\u043D\u0444\u043E\u0431\u0430\u0437\u044B: +SettingsDialog.InfobaseDeniedMessagePattern = \u0428\u0430\u0431\u043B\u043E\u043D \u0441\u043E\u043E\u0431\u0449\u0435\u043D\u0438\u044F \u0431\u043B\u043E\u043A\u0438\u0440\u043E\u0432\u043A\u0438 \u0438\u043D\u0444\u043E\u0431\u0430\u0437\u044B:\r\n(\u0432\u0440\u0435\u043C\u044F \u043D\u0430\u0447\u0430\u043B\u0430 - %1$s, \u0432\u0440\u0435\u043C\u044F \u043E\u043A\u043E\u043D\u0447\u0430\u043D\u0438\u044F - %2$s) SettingsDialog.InfobaseDeniedStandardEditMode = \u0421\u0442\u0430\u043D\u0434\u0430\u0440\u0442\u043D\u044B\u0439 SettingsDialog.LocaleEnglish = \u0410\u043D\u0433\u043B\u0438\u0439\u0441\u043A\u0438\u0439 SettingsDialog.LocaleRussian = \u0420\u0443\u0441\u0441\u043A\u0438\u0439 From 792ce8dd76302de6fccc59fb9af67d5f18fc12b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Thu, 4 Apr 2024 13:46:44 +0300 Subject: [PATCH 34/70] Up checkout@v4 and Sonar - JDKv17 --- .github/workflows/SonarCloud.yml | 6 +++--- .github/workflows/build-linux.yml | 2 +- .github/workflows/build-macOS.yml | 2 +- .github/workflows/build-windows.yml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/SonarCloud.yml b/.github/workflows/SonarCloud.yml index 244d517..22c626f 100644 --- a/.github/workflows/SonarCloud.yml +++ b/.github/workflows/SonarCloud.yml @@ -14,16 +14,16 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: fetch-depth: '' - run: | git fetch --prune --unshallow - - name: Set up JDK 11 + - name: Set up JDK 17 uses: actions/setup-java@v1 with: - java-version: 11 + java-version: 17 - name: Download and install Libs env: diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index 1b41e8a..a522c27 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -14,7 +14,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set up JDK 11 uses: actions/setup-java@v1 diff --git a/.github/workflows/build-macOS.yml b/.github/workflows/build-macOS.yml index e514b97..7170aad 100644 --- a/.github/workflows/build-macOS.yml +++ b/.github/workflows/build-macOS.yml @@ -14,7 +14,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set up JDK 11 uses: actions/setup-java@v1 diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml index d48c70a..38cb664 100644 --- a/.github/workflows/build-windows.yml +++ b/.github/workflows/build-windows.yml @@ -14,7 +14,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set up JDK 11 uses: actions/setup-java@v1 From 46632992002d6167b474e762c602e7dc6ed55b41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Thu, 4 Apr 2024 18:37:19 +0300 Subject: [PATCH 35/70] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B1=D0=B8=D0=B1=D0=BB=D0=B8=D0=BE?= =?UTF-8?q?=D1=82=D0=B5=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- clusterAdminLibrary/pom.xml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/clusterAdminLibrary/pom.xml b/clusterAdminLibrary/pom.xml index b8eef33..9f3d2ed 100644 --- a/clusterAdminLibrary/pom.xml +++ b/clusterAdminLibrary/pom.xml @@ -87,21 +87,21 @@ org.eclipse.platform ${swt.artifactId} - 3.116.0 + 3.125.0 org.eclipse.platform org.eclipse.swt - 3.116.0 + 3.125.0 org.junit.jupiter junit-jupiter-api - 5.8.2 + 5.10.2 test @@ -109,7 +109,7 @@ org.slf4j slf4j-api - 1.7.30 + 1.7.36 @@ -117,27 +117,27 @@ ch.qos.logback logback-classic - 1.2.3 + 1.2.13 ch.qos.logback logback-core - 1.2.3 + 1.2.13 org.eclipse.platform org.eclipse.core.commands - 3.9.800 + 3.12.0 org.eclipse.platform org.eclipse.equinox.common - 3.14.100 + 3.19.0 @@ -162,14 +162,14 @@ org.eclipse.platform org.eclipse.jface - 3.22.100 + 3.33.0 com.google.code.gson gson - 2.8.2 + 2.10.1 @@ -215,14 +215,14 @@ org.apache.maven maven-model - 3.8.5 + 3.9.6 org.json json - 20220320 + 20240303 From fb1ba5251d6b35d8b5b7149c873bc14986c8d01f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Thu, 4 Apr 2024 18:38:26 +0300 Subject: [PATCH 36/70] =?UTF-8?q?=D0=9D=D0=BE=D0=B2=D1=8B=D0=B5=20=D0=B8?= =?UTF-8?q?=D0=BA=D0=BE=D0=BD=D0=BA=D0=B8=20=D0=BF=D0=BE=D0=B4=D0=BA=D0=BB?= =?UTF-8?q?-=D0=BE=D1=82=D0=BA=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/resources/icons/connect_action_24.png | Bin 671 -> 488 bytes .../resources/icons/disconnect_action_24.png | Bin 766 -> 485 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/clusterAdminLibrary/src/main/resources/icons/connect_action_24.png b/clusterAdminLibrary/src/main/resources/icons/connect_action_24.png index 4dcd867efb1da8385818f864217ea3b0029911cb..b9684970fbab36cd6b6c94ba58c9520aad716619 100644 GIT binary patch delta 425 zcmV;a0apH>1?U5iNq-;!04^W_)f^rh0004fNklYU6vj^zqoiWRsf&Xk zIEspkgTz6Ki{L8y5{|{8=nMD~x+*F<2n92^i!Ls14i<-E1cfHCp6{G{n?%#aAKdod z@4M&Z+ zg3<3SQ))Tz#(#KDj*5tW`Y_lBqFrtww?IZ2R?~~+r(KSjcPV_1Xk&)g@2-ncO;#y( zp12qCn(x?uq_x>Dj|29O*c+F5etJmz?Q4Atr~;P*=WD@k+YLk6@1A}D)Z%-dyNONB z9#dJ8GIGHfx*`HBWo7P)Z`doj{bfoV-#7}^jIuwxrXmdn<f)=$>KG(Tf?cNMe# zSxEMtq}Se?NpgT{FSV~#OwoNgdj&B15!p{sTwN+NWqeuY^tnHR{>Hdtd|xKy*@~e;FeeNW z-UR$+3NOFB0#jk&Iv|_WE;YAZ-agQ<%g^YrIlkHSwiaYWYsQ*=liNh0T0p&ChiA`o z;$^+dN?J|H_72mCD?U;-o5kYd;vLZ`&WR3jN`(sR59=1uB3`6YDK?o*YR%udQqWH( vlR>FeGODVI!^6X$>2w;wU=aTbt~(J;kr<%~KngjOAzrbDaa`5|#3i!7D3*)xu-|VUg0JZn1 zZDj*U*^n~w&5R3wBZu&Y@sjwv;o+INZQR%+-%Lt>XCMy35~Wc_oNr7q<{KL9ve=BM RC{O?Z002ovPDHLkV1i(|%CrCg delta 706 zcmV;z0zLiZ1O5e&NPiB(000ic0Tn1pfB*mjlSxEDR5(w?lFv`mU>L{0@7u0rUAu0& z4Wg(_L*F5JfR6_9EfqcKBQ-M zLl;5ceW+GUS8`^YMWX5SwLtEtbXSy? zW)D=&)=@`oaevA*24vH`hjbe1N)lSF2AvS-nuc1b1oh(zNIs7sArHfK?W!v~G?<^C zCjrWg20Uzl)9diwAA!);1{8}h3I%Y3gWzK^G}V41=wVxALPu=P+}zwz2O`6C3oHxa zQafntIbovRUj-On|+41K#Ecd<+B0%C#hvSbrTl2E)U{reT^)UR9A{IVc+& z$mA6Kn3=`S@-niUoA|Z6i*3pxS5=`II-@9xJxJQN1Q3otg4gnwdwX$aYz)<@ zDbTewFn<)kY8*E{zP-I^>ly|RL@DR5*RRMN*FnF01!GOWsjCaT;Di2V0mkAYc&llZ zVP^B9_-tBL4_xUHFQd`ZTRi`|Kxm~1VmgOV=i~`3rWkfQAqNFF-QmPjUh)bpk$U}( z&oD+krrBYI42_WW5~a@-mVMu^Rttxjhnz4-COebXb_mri?C-w5zQ1w%cgorL!~cU3CjbBd07*qoM6N<$f)h(klmGw# From a5fe6cbcf0789bf4e818bcb805edf6bc864d826f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Sun, 7 Apr 2024 15:09:53 +0300 Subject: [PATCH 37/70] =?UTF-8?q?=D0=98=D0=BA=D0=BE=D0=BD=D0=BA=D0=B0=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20=D0=BF=D1=83=D0=BD=D0=BA=D1=82=D0=B0=20?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yanygin/clusterAdminLibraryUI/ViewerArea.java | 6 +++++- .../src/main/resources/icons/watch.png | Bin 0 -> 254 bytes 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 clusterAdminLibrary/src/main/resources/icons/watch.png diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java index 9851e10..481489c 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java @@ -121,6 +121,7 @@ public class ViewerArea extends Composite { Image sortIcon; Image moveUpIcon; Image moveDownIcon; + Image watchSession; Tree serversTree; TreeItem currentTreeItem; @@ -349,6 +350,8 @@ private void initIcon() { moveUpIcon = Helper.getImage("move_up.png"); //$NON-NLS-1$ moveDownIcon = Helper.getImage("move_down.png"); //$NON-NLS-1$ + watchSession = Helper.getImage("watch.png"); // $NON-NLS-1$ + LOGGER.debug("Icon init succesfully"); //$NON-NLS-1$ } @@ -674,7 +677,8 @@ private void initTableContextMenu( addItemInMenu(tableMenu, title, editIcon16, editItemInTablesListener); } - addItemInMenu(tableMenu, Strings.CONTEXT_MENU_WATCH_SESSION, null, switchWatchingMenuListener); + addItemInMenu( + tableMenu, Strings.CONTEXT_MENU_WATCH_SESSION, watchSession, switchWatchingMenuListener); addItemInMenu( tableMenu, Strings.CONTEXT_MENU_COPY_CELL_VALUE, null, copyCellValueInTablesListener); diff --git a/clusterAdminLibrary/src/main/resources/icons/watch.png b/clusterAdminLibrary/src/main/resources/icons/watch.png new file mode 100644 index 0000000000000000000000000000000000000000..ec508f8bab736e8945fb4b6a9ce2494da3f020ba GIT binary patch literal 254 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G|&0G|+7V`Jlg|Ni~||NqgWN1mRZJ9g~w@bJja&i?l8+t;sOw{PDLRQR#H zARI{Xlmz(&169HRgV6nR=YZmz1s;*b3=DjSK$uZf!>a)(= Date: Sun, 7 Apr 2024 18:46:43 +0300 Subject: [PATCH 38/70] =?UTF-8?q?=D0=A0=D0=B5=D1=84=D0=B0=D0=BA=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ru/yanygin/clusterAdminLibrary/Helper.java | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java index 71eeadb..3592caa 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java @@ -26,10 +26,8 @@ public class Helper { private static final Logger LOGGER = LoggerFactory.getLogger("ClusterProvider"); //$NON-NLS-1$ - private static final DateFormat normalDateFormat = - new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"); // $NON-NLS-1$ - private static final DateFormat currentDayDateFormat = - new SimpleDateFormat("HH:mm:ss"); // $NON-NLS-1$ + private static final DateFormat simpleDateFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"); + private static final DateFormat currentDayDateFormat = new SimpleDateFormat("HH:mm:ss"); /** Пустой UUID. */ public static final UUID EMPTY_UUID = @@ -288,15 +286,15 @@ public static String dateToString(Date date) { if (date == null || date.equals(emptyDate)) { return ""; } - Calendar calendar = new GregorianCalendar(); - calendar.set(Calendar.HOUR, 0); - calendar.set(Calendar.MINUTE, 0); - calendar.set(Calendar.SECOND, 0); + Calendar startCurrentDay = new GregorianCalendar(); + startCurrentDay.set(Calendar.HOUR, 0); + startCurrentDay.set(Calendar.MINUTE, 0); + startCurrentDay.set(Calendar.SECOND, 0); - if (Config.currentConfig.showCurrentDateAsTime() && date.after(calendar.getTime())) { + if (Config.currentConfig.showCurrentDateAsTime() && date.after(startCurrentDay.getTime())) { return currentDayDateFormat.format(date); } else { - return normalDateFormat.format(date); + return simpleDateFormat.format(date); } } } From 70d937ecc08ce22e87626555159fe29f5a7ed084 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Tue, 9 Apr 2024 18:29:40 +0300 Subject: [PATCH 39/70] =?UTF-8?q?dateToStringReverse=20=D0=BF=D0=B5=D1=80?= =?UTF-8?q?=D0=B5=D0=BD=D0=B5=D1=81=20=D0=B2=20InfobaseDialog?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yanygin/clusterAdminLibrary/Helper.java | 14 ------------ .../clusterAdminLibraryUI/InfobaseDialog.java | 22 ++++++++++++------- 2 files changed, 14 insertions(+), 22 deletions(-) diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java index f95a769..458c78a 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java @@ -24,7 +24,6 @@ public class Helper { private static final Logger LOGGER = LoggerFactory.getLogger("ClusterProvider"); //$NON-NLS-1$ private static final DateFormat simpleDateFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"); - private static final DateFormat reverseDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); /** Пустой UUID. */ public static final UUID EMPTY_UUID = @@ -286,17 +285,4 @@ public static String dateToString(Date date) { return simpleDateFormat.format(date); } - /** - * Преобразует дату к строке ("yyyy-MM-dd hh:MM:ss"). - * - * @param date - Дата - * @return Дата строкой - */ - public static String dateToStringReverse(Date date) { - Date emptyDate = new Date(0); - if (date == null || date.equals(emptyDate)) { - return ""; - } - return reverseDateFormat.format(date); - } } diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/InfobaseDialog.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/InfobaseDialog.java index 3e75e08..1446e13 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/InfobaseDialog.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/InfobaseDialog.java @@ -43,8 +43,8 @@ public class InfobaseDialog extends Dialog { private static final String DBMS_TYPE_ORACLEDATABASE = "OracleDatabase"; //$NON-NLS-1$ private static final String EMPTY_STRING = ""; //$NON-NLS-1$ - private final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); //$NON-NLS-1$ - private final DateFormat dateDeniedFormat = new SimpleDateFormat("H:mm"); // $NON-NLS-1$ + private final DateFormat dateReverseFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + private final DateFormat dateDeniedFormat = new SimpleDateFormat("H:mm"); private final Date emptyDate = new Date(0); private Font fontNormal; private Font fontMicro; @@ -101,7 +101,7 @@ public InfobaseDialog(Shell parentShell, Server server, UUID clusterId, UUID inf this.clusterId = clusterId; this.infoBaseId = infoBaseId; - dateFormat.setLenient(false); + dateReverseFormat.setLenient(false); // три варианта открытия окна: // - существующая база @@ -509,7 +509,7 @@ private Date convertStringToDate(String date) { Date convertDate; try { - convertDate = dateFormat.parse(date); + convertDate = dateReverseFormat.parse(date); } catch (ParseException excp) { convertDate = null; } @@ -635,7 +635,7 @@ private void setDate(Date dateValue, boolean modifyTextField) { } else { if (modifyTextField) { deniedModifyEventOff = true; - textField.setText(convertDateToString(dateValue)); + textField.setText(convertDateToReverseString(dateValue)); } dateField.setDate(dateValue.getYear() + 1900, dateValue.getMonth(), dateValue.getDate()); @@ -652,7 +652,7 @@ private void update() { Date deniedDate = getDate(); deniedModifyEventOff = true; - textField.setText(Helper.dateToStringReverse(deniedDate)); // TODO = convertDateToString??? + textField.setText(convertDateToReverseString(deniedDate)); } private void updateTime() { @@ -712,9 +712,15 @@ private String getDeniedTime() { return dateDeniedFormat.format(getDate()); } - private String convertDateToString(Date date) { + /** + * Преобразует дату к строке ("yyyy-MM-dd hh:MM:ss"). + * + * @param date - Дата + * @return Дата строкой + */ + private String convertDateToReverseString(Date date) { - return date.equals(emptyDate) ? EMPTY_STRING : dateFormat.format(date); + return date.equals(emptyDate) ? EMPTY_STRING : dateReverseFormat.format(date); } private boolean valueIsValid() { From 19d9f574c42b9d9231f3b977abec0fbf869d9a12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Wed, 10 Apr 2024 13:30:22 +0300 Subject: [PATCH 40/70] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BF=D1=83=D1=82=D0=B8=20=D0=BA=20ibases?= =?UTF-8?q?.v8i=20=D1=87=D0=B5=D1=80=D0=B5=D0=B7=20=D0=BD=D0=B0=D1=81?= =?UTF-8?q?=D1=82=D1=80=D0=BE=D0=B9=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yanygin/clusterAdminLibrary/Config.java | 22 +++++++++++++++++++ .../yanygin/clusterAdminLibrary/Helper.java | 4 ++-- .../clusterAdminLibraryUI/SettingsDialog.java | 13 +++++++++++ .../clusterAdminLibraryUI/messages.properties | 1 + .../messages_ru_RU.properties | 1 + 5 files changed, 39 insertions(+), 2 deletions(-) diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java index 40befc2..14a26ec 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java @@ -930,6 +930,28 @@ public Path getIbasesPath() { } } + /** + * Получить установленный пользователем путь к файлу со списком информационных баз. + * + * @return Путь к списку информационных баз в виде строки + */ + public String getIbasesStringPath() { + if (ibasesPath.isBlank()) { + return ""; + } else { + return ibasesPath; + } + } + + /** + * Установить путь к файлу со списком информационных баз. + * + * @param ibasesPath - путь к файлу со списком информационных баз + */ + public void setIbasesPath(String ibasesPath) { + this.ibasesPath = ibasesPath; + } + /** * Получение свойства колонок списков. * diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java index 5e538b4..c3588cc 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java @@ -343,7 +343,7 @@ public static Map findNewServers() { } } } - + if (foundServers.isEmpty()) { return new HashMap<>(); } @@ -367,7 +367,7 @@ private static String readTextFile(Path textFile) { return ""; } } - + return ""; } } diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/SettingsDialog.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/SettingsDialog.java index d5e974a..e393b56 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/SettingsDialog.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/SettingsDialog.java @@ -54,6 +54,7 @@ public class SettingsDialog extends Dialog { private Button btnLoggerLevelDebug; private static final String LOCALE_RU = "ru-RU"; //$NON-NLS-1$ + private Text txtIbasesFilePath; /** * Создание диалога настроек сервера. @@ -235,6 +236,12 @@ protected Control createDialogArea(Composite parent) { btnCheckUpdate = new Button(grpOther, SWT.CHECK); btnCheckUpdate.setText(Strings.CHECK_UPDATE); + + Label lblIbasesFilePath = new Label(grpOther, SWT.NONE); + lblIbasesFilePath.setText(Strings.IBASES_PATH_TITLE); + + txtIbasesFilePath = new Text(grpOther, SWT.BORDER); + txtIbasesFilePath.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); new Label(container, SWT.NONE); initProperties(); @@ -283,6 +290,8 @@ private void initProperties() { btnLoggerLevelWarning.setSelection(loggerLevel.equals(btnLoggerLevelWarning.getText())); btnLoggerLevelInfo.setSelection(loggerLevel.equals(btnLoggerLevelInfo.getText())); btnLoggerLevelDebug.setSelection(loggerLevel.equals(btnLoggerLevelDebug.getText())); + + txtIbasesFilePath.setText(config.getIbasesStringPath()); } private void saveProperties() { @@ -340,6 +349,8 @@ private void saveProperties() { loggerLevel = btnLoggerLevelOff.getText(); } config.setLoggerLevel(loggerLevel); + + config.setIbasesPath(txtIbasesFilePath.getText()); } /** @@ -405,6 +416,8 @@ private static class Strings { static final String LOGGER_LEVEL_TITLE = getString("LoggerLevelTitle"); + static final String IBASES_PATH_TITLE = getString("IbasesFilePathTitle"); + static String getString(String key) { return Messages.getString("SettingsDialog." + key); //$NON-NLS-1$ } diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties index a1703d3..8da18f5 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties @@ -118,6 +118,7 @@ SettingsDialog.ExpandWorkingServers = Working servers SettingsDialog.HighlightDuration = Highlight duration (sec) SettingsDialog.HighlightNewItems = Highlight new items SettingsDialog.HighlightTitle = Highlight +SettingsDialog.IbasesFilePathTitle = The path to the "ibases.v8i" file: SettingsDialog.LocaleEnglish = English SettingsDialog.LocaleRussian = Russian SettingsDialog.LocaleSystem = System diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties index 27dcab1..c68c1db 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties @@ -118,6 +118,7 @@ SettingsDialog.ExpandWorkingServers = \u0420\u0430\u0431\u043E\u0447\u0438 SettingsDialog.HighlightDuration = \u0414\u043B\u0438\u0442\u0435\u043B\u044C\u043D\u043E\u0441\u0442\u044C \u043F\u043E\u0434\u0441\u0432\u0435\u0442\u043A\u0438 (\u0441\u0435\u043A) SettingsDialog.HighlightNewItems = \u041F\u043E\u0434\u0441\u0432\u0435\u0447\u0438\u0432\u0430\u0442\u044C \u043D\u043E\u0432\u044B\u0435 \u0441\u0442\u0440\u043E\u043A\u0438 SettingsDialog.HighlightTitle = \u041F\u043E\u0434\u0441\u0432\u0435\u0447\u0438\u0432\u0430\u043D\u0438\u0435 +SettingsDialog.IbasesFilePathTitle = \u041F\u0443\u0442\u044C \u043A \u0444\u0430\u0439\u043B\u0443 "ibases.v8i": SettingsDialog.LocaleEnglish = \u0410\u043D\u0433\u043B\u0438\u0439\u0441\u043A\u0438\u0439 SettingsDialog.LocaleRussian = \u0420\u0443\u0441\u0441\u043A\u0438\u0439 SettingsDialog.LocaleSystem = \u0421\u0438\u0441\u0442\u0435\u043C\u043D\u044B\u0439 From 7af64d6d813c2489cefe902a705fb66b0dc28874 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Fri, 12 Apr 2024 13:14:32 +0300 Subject: [PATCH 41/70] =?UTF-8?q?=D0=9F=D0=BE=D0=BC=D0=B5=D0=BD=D1=8F?= =?UTF-8?q?=D0=BB=20=D0=BF=D0=BE=D1=80=D1=8F=D0=B4=D0=BE=D0=BA=20=D0=BF?= =?UTF-8?q?=D1=83=D0=BD=D0=BA=D1=82=D0=BE=D0=B2=20=D0=BC=D0=B5=D0=BD=D1=8E?= =?UTF-8?q?=20=D0=BA=D0=BB=D0=B0=D1=81=D1=82=D0=B5=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java index 916c3e7..101fbda 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java @@ -510,15 +510,14 @@ private void initClusterMenu() { addItemInMenu( clusterMenu, Strings.CONTEXT_MENU_CREATE_CLUSTER, addIcon16, createClusterListener); addItemInMenu(clusterMenu, Strings.CONTEXT_MENU_EDIT_CLUSTER, editIcon16, editClusterListener); - addItemInMenu(clusterMenu, Strings.CONTEXT_MENU_ADMINS, null, editAdminsListener); + addItemInMenu(clusterMenu, Strings.CONTEXT_MENU_UPDATE, updateIcon16, updateClusterListener); addMenuSeparator(clusterMenu); - addItemInMenu(clusterMenu, Strings.CONTEXT_MENU_UPDATE, updateIcon16, updateClusterListener); - + addItemInMenu(clusterMenu, Strings.CONTEXT_MENU_ADMINS, null, editAdminsListener); + addMenuSeparator(clusterMenu); addItemInMenu( clusterMenu, Strings.CONTEXT_MENU_DELETE_CLUSTER, deleteIcon16, deleteClusterListener); - } private void initWorkingServerMenu() { From 4e7632373996f51e407c06c303bdecc17924c971 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Fri, 12 Apr 2024 13:15:45 +0300 Subject: [PATCH 42/70] =?UTF-8?q?=D0=A3=D0=B1=D1=80=D0=B0=D0=BB=20=D0=BF?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D1=83=20=D0=B7=D0=B0=D0=BF?= =?UTF-8?q?=D0=BE=D0=BB=D0=BD=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B8=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=20=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0?= =?UTF-8?q?=D1=82=D0=B5=D0=BB=D1=8F=20=D0=94=D0=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/ru/yanygin/clusterAdminLibraryUI/InfobaseDialog.java | 1 - 1 file changed, 1 deletion(-) diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/InfobaseDialog.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/InfobaseDialog.java index 1446e13..7d45902 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/InfobaseDialog.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/InfobaseDialog.java @@ -429,7 +429,6 @@ private boolean checkVariablesFromControls() { checksTextControls.add(txtInfobaseName); checksTextControls.add(txtServerDbName); checksTextControls.add(txtDatabaseDbName); - checksTextControls.add(txtDatabaseDbUser); for (Text control : checksTextControls) { if (control.getText().isBlank()) { From 8f19ca9db8fe147a65f348032e542fb25be8148e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Sun, 14 Apr 2024 10:35:30 +0300 Subject: [PATCH 43/70] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BD=D0=B5=D0=B2=D0=B5=D1=80?= =?UTF-8?q?=D0=BD=D0=BE=D0=B9=20=D1=83=D1=81=D1=82=D0=B0=D0=BD=D0=BE=D0=B2?= =?UTF-8?q?=D0=BA=D0=B8=20=D0=BD=D0=B0=D1=87=D0=B0=D0=BB=D0=B0=20=D0=B4?= =?UTF-8?q?=D0=BD=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java index 3592caa..f892222 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java @@ -287,7 +287,7 @@ public static String dateToString(Date date) { return ""; } Calendar startCurrentDay = new GregorianCalendar(); - startCurrentDay.set(Calendar.HOUR, 0); + startCurrentDay.set(Calendar.HOUR_OF_DAY, 0); startCurrentDay.set(Calendar.MINUTE, 0); startCurrentDay.set(Calendar.SECOND, 0); From 69522cfecf470b8dd5aa107142fdaf934a34c8c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Sun, 14 Apr 2024 14:58:57 +0300 Subject: [PATCH 44/70] =?UTF-8?q?=D0=9A=D0=BE=D0=BD=D1=82=D0=B5=D0=BA?= =?UTF-8?q?=D1=81=D1=82=D0=BD=D0=BE=D0=B5=20=D0=BC=D0=B5=D0=BD=D1=8E=20?= =?UTF-8?q?=D0=B8=20=D0=BE=D0=B1=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D1=87=D0=B8?= =?UTF-8?q?=D0=BA=D0=B8=20=D0=BA=D0=BB=D0=B0=D0=B2=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../clusterAdminLibraryUI/AdminsDialog.java | 93 ++++++++++++++----- 1 file changed, 68 insertions(+), 25 deletions(-) diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/AdminsDialog.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/AdminsDialog.java index 35cb0fb..cf66619 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/AdminsDialog.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/AdminsDialog.java @@ -17,6 +17,8 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Menu; +import org.eclipse.swt.widgets.MenuItem; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableColumn; @@ -31,7 +33,7 @@ public class AdminsDialog extends Dialog { private Server server; private UUID clusterId; - + private Table tableAdmins; final Image addIcon16 = Helper.getImage("add_16.png"); // $NON-NLS-1$ @@ -74,35 +76,17 @@ protected Control createDialogArea(Composite parent) { ToolItem toolBarAdd = new ToolItem(toolBar, SWT.NONE); toolBarAdd.setImage(addIcon16); toolBarAdd.setText(Strings.TOOLBAR_ADD); - toolBarAdd.addSelectionListener( - new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - addAdmin(); - } - }); + toolBarAdd.addSelectionListener(addAdminListener); ToolItem toolBarEdit = new ToolItem(toolBar, SWT.NONE); toolBarEdit.setImage(editIcon16); toolBarEdit.setText(Strings.TOOLBAR_EDIT); - toolBarEdit.addSelectionListener( - new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - editAdmin(); - } - }); + toolBarEdit.addSelectionListener(editAdminListener); ToolItem toolBarDelete = new ToolItem(toolBar, SWT.NONE); toolBarDelete.setImage(deleteIcon16); toolBarDelete.setText(Strings.TOOLBAR_DELETE); - toolBarDelete.addSelectionListener( - new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - delAdmin(); - } - }); + toolBarDelete.addSelectionListener(delAdminListener); tableAdmins = new Table(container, SWT.BORDER | SWT.CHECK | SWT.FULL_SELECTION | SWT.MULTI); tableAdmins.setHeaderVisible(true); @@ -130,6 +114,7 @@ public void widgetSelected(SelectionEvent e) { tcSysUsername.setWidth(120); tcSysUsername.setText(Strings.SYS_USERNAME); + initContextMenu(); initProperties(); parent.pack(); @@ -137,6 +122,27 @@ public void widgetSelected(SelectionEvent e) { return container; } + private void initContextMenu() { + Menu tableMenu = new Menu(tableAdmins); + tableAdmins.setMenu(tableMenu); + // установить активность контекстного меню + + MenuItem addMenuItem = new MenuItem(tableMenu, SWT.NONE); + addMenuItem.setText(Strings.TOOLBAR_ADD); + addMenuItem.setImage(addIcon16); + addMenuItem.addSelectionListener(addAdminListener); + + MenuItem editMenuItem = new MenuItem(tableMenu, SWT.NONE); + editMenuItem.setText(Strings.TOOLBAR_EDIT); + editMenuItem.setImage(editIcon16); + editMenuItem.addSelectionListener(editAdminListener); + + MenuItem delMenuItem = new MenuItem(tableMenu, SWT.NONE); + delMenuItem.setText(Strings.TOOLBAR_DELETE); + delMenuItem.setImage(deleteIcon16); + delMenuItem.addSelectionListener(delAdminListener); + } + private void initProperties() { if (server != null) { fillTableAdmins(); @@ -167,7 +173,7 @@ private String[] getTableAdminsItemText(IRegUserInfo userInfo) { userInfo.getSysUserName() }; } - + /** * Create contents of the button bar. * @@ -190,8 +196,21 @@ public void widgetSelected(SelectionEvent e) { new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { - if (e.keyCode == SWT.DEL) { - delAdmin(); + switch (e.keyCode) { + case SWT.INSERT: + addAdmin(); + break; + + case SWT.F2: + editAdmin(); + break; + + case SWT.DEL: + delAdmin(); + break; + + default: + break; } } }; @@ -204,6 +223,30 @@ public void mouseDoubleClick(MouseEvent e) { } }; + private SelectionAdapter addAdminListener = + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + addAdmin(); + } + }; + + private SelectionAdapter editAdminListener = + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + editAdmin(); + } + }; + + private SelectionAdapter delAdminListener = + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + delAdmin(); + } + }; + private void addAdmin() { AdminEditDialog adminEditDialog = From 4a86c9cd611d64028d24b5020a670a6d576f9760 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Sun, 14 Apr 2024 18:12:02 +0300 Subject: [PATCH 45/70] =?UTF-8?q?=D0=9F=D0=BE=D0=B4=D1=81=D0=BA=D0=B0?= =?UTF-8?q?=D0=B7=D0=BA=D0=B8=20=D0=BA=20=D0=B3=D0=BE=D1=80=D1=8F=D1=87?= =?UTF-8?q?=D0=B8=D0=BC=20=D0=BA=D0=BB=D0=B0=D0=B2=D0=B8=D1=88=D0=B0=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ru/yanygin/clusterAdminLibraryUI/AdminsDialog.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/AdminsDialog.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/AdminsDialog.java index cf66619..fb5770c 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/AdminsDialog.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/AdminsDialog.java @@ -128,17 +128,17 @@ private void initContextMenu() { // установить активность контекстного меню MenuItem addMenuItem = new MenuItem(tableMenu, SWT.NONE); - addMenuItem.setText(Strings.TOOLBAR_ADD); + addMenuItem.setText(Strings.CONTEXT_MENU_ADD); addMenuItem.setImage(addIcon16); addMenuItem.addSelectionListener(addAdminListener); MenuItem editMenuItem = new MenuItem(tableMenu, SWT.NONE); - editMenuItem.setText(Strings.TOOLBAR_EDIT); + editMenuItem.setText(Strings.CONTEXT_MENU_EDIT); editMenuItem.setImage(editIcon16); editMenuItem.addSelectionListener(editAdminListener); MenuItem delMenuItem = new MenuItem(tableMenu, SWT.NONE); - delMenuItem.setText(Strings.TOOLBAR_DELETE); + delMenuItem.setText(Strings.CONTEXT_MENU_DELETE); delMenuItem.setImage(deleteIcon16); delMenuItem.addSelectionListener(delAdminListener); } @@ -320,6 +320,9 @@ private static class Strings { static final String TOOLBAR_ADD = Messages.getString("ViewerArea.ContextMenu.Create"); static final String TOOLBAR_EDIT = Messages.getString("ViewerArea.ContextMenu.Edit"); static final String TOOLBAR_DELETE = Messages.getString("ViewerArea.ContextMenu.Delete"); + static final String CONTEXT_MENU_ADD = TOOLBAR_ADD.concat("\tIns"); + static final String CONTEXT_MENU_EDIT = TOOLBAR_EDIT.concat("\tF2"); + static final String CONTEXT_MENU_DELETE = TOOLBAR_DELETE.concat("\tDel"); static String getString(String key) { return Messages.getString("AdminDialog." + key); From 45d2cf1e209bec85e22e1e49101cc4a3f54f731c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Tue, 16 Apr 2024 19:01:11 +0300 Subject: [PATCH 46/70] =?UTF-8?q?=D0=A4=D0=BE=D1=80=D0=BC=D0=B0=20=D0=B4?= =?UTF-8?q?=D0=BB=D1=8F=20=D0=B2=D1=8B=D0=B1=D0=BE=D1=80=D0=B0=20=D0=B4?= =?UTF-8?q?=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D1=8F=D0=B5=D0=BC=D1=8B=D1=85=20?= =?UTF-8?q?=D1=81=D0=B5=D1=80=D0=B2=D0=B5=D1=80=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yanygin/clusterAdminLibrary/Helper.java | 9 +- .../NewServersChoiseDialog.java | 125 ++++++++++++++++++ .../clusterAdminLibraryUI/ViewerArea.java | 27 +++- .../clusterAdminLibraryUI/messages.properties | 3 + .../messages_ru_RU.properties | 3 + 5 files changed, 154 insertions(+), 13 deletions(-) create mode 100644 clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/NewServersChoiseDialog.java diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java index c3588cc..bf806cf 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java @@ -294,7 +294,7 @@ public static String dateToString(Date date) { } /** Ищет новые сервера в файле списка инфобаз v8i. */ - public static Map findNewServers() { + public static List findNewServers() { List foundServers = new ArrayList<>(); // Читаем файл со списком инфобаз стартера @@ -343,12 +343,7 @@ public static Map findNewServers() { } } } - - if (foundServers.isEmpty()) { - return new HashMap<>(); - } - - return Config.currentConfig.addNewServers(foundServers); + return foundServers; } private static String readTextFile(Path textFile) { diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/NewServersChoiseDialog.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/NewServersChoiseDialog.java new file mode 100644 index 0000000..55adbab --- /dev/null +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/NewServersChoiseDialog.java @@ -0,0 +1,125 @@ +package ru.yanygin.clusterAdminLibraryUI; + +import java.util.List; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.swt.widgets.TableItem; +import ru.yanygin.clusterAdminLibrary.Helper; + +/** Форма для выбора, какие найденные сервера добавлять в список. */ +public class NewServersChoiseDialog extends Dialog { + private Table table; + private List newServers; + + /** + * Create the dialog. + * + * @param parentShell - parent shell + */ + public NewServersChoiseDialog(Shell parentShell) { + super(parentShell); + setShellStyle(SWT.DIALOG_TRIM | SWT.RESIZE | SWT.APPLICATION_MODAL); + } + + @Override + protected void configureShell(Shell newShell) { + super.configureShell(newShell); + newShell.setText(Strings.TITLE_WINDOW); + } + + /** + * Create contents of the dialog. + * + * @param parent - parent composite + */ + @Override + protected Control createDialogArea(Composite parent) { + + Composite container = (Composite) super.createDialogArea(parent); + GridLayout gridLayout = (GridLayout) container.getLayout(); + gridLayout.marginHeight = 0; + gridLayout.marginWidth = 0; + + table = new Table(container, SWT.BORDER | SWT.CHECK | SWT.FULL_SELECTION); + table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); + table.setHeaderVisible(true); + table.setLinesVisible(true); + + TableColumn tblcolumn = new TableColumn(table, SWT.LEFT); + tblcolumn.setResizable(false); + tblcolumn.setWidth(200); + tblcolumn.setText(Strings.SERVER_ADDRESS); + + newServers = Helper.findNewServers(); + + table.removeAll(); + newServers.forEach( + (serv) -> { + TableItem item = new TableItem(table, SWT.NONE); + item.setText(serv); + }); + + tblcolumn.pack(); + + return container; + } + + private void saveNewServers() { + TableItem[] items = table.getItems(); + + for (TableItem tableItem : items) { + if (!tableItem.getChecked()) { + newServers.remove(tableItem.getText()); + } + } + } + + /** + * Получение списка серверов, выбранных пользователем. + * + * @return список новых серверов + */ + public List getNewServers() { + return newServers; + } + + /** + * Create contents of the button bar. + * + * @param parent - parent composite + */ + @Override + protected void createButtonsForButtonBar(Composite parent) { + Button button = + createButton(parent, IDialogConstants.FINISH_ID, IDialogConstants.OK_LABEL, true); + button.addSelectionListener( + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + saveNewServers(); + close(); + } + }); + createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); + } + + private static class Strings { + static final String TITLE_WINDOW = getString("TitleDialog"); + static final String SERVER_ADDRESS = getString("ServerAddress"); + + static String getString(String key) { + return Messages.getString("NewServersDialog." + key); // $NON-NLS-1$ + } + } +} diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java index 96a4d41..f3c483d 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java @@ -1625,12 +1625,27 @@ public void widgetSelected(SelectionEvent e) { new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - Map newServers = Helper.findNewServers(); - if (!newServers.isEmpty()) { - newServers.forEach( - (serverKey, server) -> { - addServerItemInServersTree(server); - }); + NewServersChoiseDialog dialog; + try { + dialog = new NewServersChoiseDialog(getParent().getDisplay().getActiveShell()); + } catch (Exception excp) { + LOGGER.error("Error init NewServersChoiseDialog", excp); // $NON-NLS-1$ + return; + } + + if (dialog.open() == 0) { + List s = dialog.getNewServers(); + if (s.isEmpty()) { + return; + } + + Map newServers = Config.currentConfig.addNewServers(s); + if (!newServers.isEmpty()) { + newServers.forEach( + (serverKey, server) -> { + addServerItemInServersTree(server); + }); + } } } }; diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties index 8da18f5..e834ea8 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties @@ -79,6 +79,9 @@ InfobaseDialog.TitleDialog = Infobase parameters InfobaseDialog.TitleDropInfobaseParameters = Delete infobase InfobaseDialog.YouNeedToEnter = you need to enter +NewServersDialog.ServerAddress = Server address +NewServersDialog.TitleDialog = Selecting servers to add + ServerDialog.AgentParameters = Server agent parameters ServerDialog.AutoconnectAtStartup = Autoconnect to the server at startup ServerDialog.CentralServerAdminstrator = Central server adminstrator diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties index c68c1db..64b1124 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties @@ -79,6 +79,9 @@ InfobaseDialog.TitleDialog = \u041F\u0430\u0440\u0430\u043C\ InfobaseDialog.TitleDropInfobaseParameters = \u0423\u0434\u0430\u043B\u0435\u043D\u0438\u0435 \u0438\u043D\u0444\u043E\u0431\u0430\u0437\u044B InfobaseDialog.YouNeedToEnter = \u043D\u0443\u0436\u043D\u043E \u0437\u0430\u043F\u043E\u043B\u043D\u0438\u0442\u044C +NewServersDialog.ServerAddress = \u0410\u0434\u0440\u0435\u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 +NewServersDialog.TitleDialog = \u0412\u044B\u0431\u043E\u0440 \u0441\u0435\u0440\u0432\u0435\u0440\u043E\u0432 \u0434\u043B\u044F \u0434\u043E\u0431\u0430\u0432\u043B\u0435\u043D\u0438\u044F + ServerDialog.AgentParameters = \u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u044B \u0430\u0433\u0435\u043D\u0442\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 ServerDialog.AutoconnectAtStartup = \u0410\u0432\u0442\u043E\u043C\u0430\u0442\u0438\u0447\u0435\u0441\u043A\u0438 \u043F\u043E\u0434\u043A\u043B\u044E\u0447\u0430\u0442\u044C\u0441\u044F \u043F\u0440\u0438 \u0441\u0442\u0430\u0440\u0442\u0435 ServerDialog.CentralServerAdminstrator = \u0410\u0434\u043C\u0438\u043D\u0438\u0441\u0442\u0440\u0430\u0442\u043E\u0440 \u0446\u0435\u043D\u0442\u0440\u0430\u043B\u044C\u043D\u043E\u0433\u043E \u0441\u0435\u0440\u0432\u0435\u0440\u0430 From e847d4398adc3802a4f5337755647d26a8903a9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Sat, 20 Apr 2024 20:04:34 +0300 Subject: [PATCH 47/70] =?UTF-8?q?=D0=A0=D0=B5=D1=84=D0=B0=D0=BA=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=B8=D0=BD=D0=B3=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20=D1=81=D0=B5=D1=80=D0=B2=D0=B5?= =?UTF-8?q?=D1=80=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yanygin/clusterAdminLibrary/Config.java | 42 +++-------------- .../yanygin/clusterAdminLibrary/Helper.java | 31 +++++++----- .../yanygin/clusterAdminLibrary/Server.java | 47 ++++++++++++------- .../NewServersChoiseDialog.java | 34 +++++++++----- .../clusterAdminLibraryUI/ViewerArea.java | 11 ++--- .../clusterAdminLibraryUI/messages.properties | 3 +- .../messages_ru_RU.properties | 3 +- 7 files changed, 82 insertions(+), 89 deletions(-) diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java index 14a26ec..dda9c07 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java @@ -428,7 +428,6 @@ private void showDownloadedFile(String fname) { * @return новый сервер */ public Server createNewServer() { - Server newServer = null; if (isReadClipboard()) { Clipboard clipboard = new Clipboard(Display.getDefault()); @@ -438,16 +437,11 @@ public Server createNewServer() { if (clip != null && clip.startsWith("Srvr=")) { //$NON-NLS-1$ String[] srvrPart = clip.split(";"); //$NON-NLS-1$ String srvr = srvrPart[0].substring(6, srvrPart[0].length() - 1); - newServer = new Server(srvr); - } else { - newServer = new Server("Server:1541"); //$NON-NLS-1$ + return new Server(srvr); } - } else { - newServer = new Server("Server:1541"); //$NON-NLS-1$ } - // servers.put(newServer.getServerKey(), newServer); - // TODO по идее еще рано добавлять в список серверов эту заготовку - return newServer; + + return new Server(); } public void addNewServer(Server server) { @@ -476,34 +470,12 @@ public void close() { * Добавление новых серверов в конфиг. * * @param newServers - список новых серверов - * @return список серверов, которые были реально добавлены */ - public Map addNewServers(List newServers) { - // Пакетное добавление серверов в список, предполагается для механизма импорта из списка - // информационных баз - - Map addedServers = new HashMap<>(); - - // Имя сервера, которое приходит сюда не равно Представлению сервера, выводимому в списке - // Имя сервера. оно же Key в map и json, строка вида Server:1541, с обязательным указанием порта - // менеджера, к которому подключаемся - // если порт менеджера не задан - ставим стандартный 1541 - // переделать - for (String serverName : newServers) { - String[] adr = serverName.split(":"); // $NON-NLS-1$ - String agentHost = adr[0]; - int agentPort = Integer.parseInt(adr[1]) - 1; - String serverNameAgentPort = agentHost.concat(":").concat(Integer.toString(agentPort)); - - if (!servers.containsKey(serverNameAgentPort)) { - Server serverConfig = new Server(serverName); - servers.put(serverNameAgentPort, serverConfig); - - addedServers.put(serverNameAgentPort, serverConfig); - } + public void addNewServers(List newServers) { + // Пакетное добавление серверов в список + for (Server server : newServers) { + servers.put(server.getServerKey(), server); } - - return addedServers; } /** Подключиться ко всем серверам в тихом режиме. */ diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java index bf806cf..e56eb67 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java @@ -294,8 +294,10 @@ public static String dateToString(Date date) { } /** Ищет новые сервера в файле списка инфобаз v8i. */ - public static List findNewServers() { - List foundServers = new ArrayList<>(); + public static List findNewServers() { + List foundServersKey = new ArrayList<>(); + List foundServers = new ArrayList<>(); + Map currentServers = Config.currentConfig.getServers(); // Читаем файл со списком инфобаз стартера Path ibasesPath = Config.currentConfig.getIbasesPath(); @@ -310,15 +312,14 @@ public static List findNewServers() { String[] adr = serverAddress.split(":"); // $NON-NLS-1$ String agentHost = adr[0]; + int agentPort = (adr.length == 1) ? 1540 : Integer.valueOf(adr[1]) - 1; - int agentPort; - if (adr.length == 1) { - agentPort = 1541; - serverAddress = agentHost.concat(":").concat(Integer.toString(agentPort)); - } + Server server = new Server(agentHost, agentPort); + String serverKey = server.getServerKey(); - if (!foundServers.contains(serverAddress)) { - foundServers.add(serverAddress); + if (!foundServersKey.contains(serverKey) && currentServers.get(serverKey) == null) { + foundServersKey.add(serverKey); + foundServers.add(server); } } } @@ -335,14 +336,18 @@ public static List findNewServers() { String[] adr = serverAddress.split(","); // $NON-NLS-1$ String agentHost = adr[0].replace("\"", ""); - int agentPort = Integer.parseInt(adr[1]) + 1; - serverAddress = agentHost.concat(":").concat(Integer.toString(agentPort)); + int agentPort = Integer.parseInt(adr[1]); + + Server server = new Server(agentHost, agentPort); + String serverKey = server.getServerKey(); - if (!foundServers.contains(serverAddress)) { - foundServers.add(serverAddress); + if (!foundServersKey.contains(serverKey) && currentServers.get(serverKey) == null) { + foundServersKey.add(serverKey); + foundServers.add(server); } } } + return foundServers; } diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java index 1b2de36..62bd48d 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java @@ -58,19 +58,19 @@ public class Server implements Comparable { @SerializedName("AgentHost") @Expose - private String agentHost = ""; //$NON-NLS-1$ + private String agentHost = "Server1c"; //$NON-NLS-1$ @SerializedName("AgentPort") @Expose - private int agentPort = 0; + private int agentPort = 1540; @SerializedName("RasHost") @Expose - private String rasHost = ""; //$NON-NLS-1$ + private String rasHost = "Server1c"; //$NON-NLS-1$ @SerializedName("RasPort") @Expose - private int rasPort = 0; + private int rasPort = 1545; @SerializedName("UseLocalRas") @Expose @@ -613,8 +613,12 @@ public Server() { * @param serverName - имя сервера в виде "Server" или с указанием порта менеджера "Server:2541". */ public Server(String serverName) { + serverName = serverName.strip(); + if (serverName.isBlank()) { + return; + } - computeServerParams(serverName); + computeHostAndPort(serverName); // this.useLocalRas = false; // this.localRasPort = 0; @@ -627,6 +631,20 @@ public Server(String serverName) { // init(); } + /** + * Создание нового экземпляра. + * + * @param serverHost - имя хоста сервера в виде "Server" (без номера порта) + * @param agentPort - порт агента сервера (1540, 2540 и т.п.) + */ + public Server(String serverHost, int agentPort) { + + this.agentHost = serverHost; + this.rasHost = serverHost; + this.agentPort = agentPort; + this.rasPort = agentPort + 5; + } + /** Initializes some server parameters. */ // public void init() { // @@ -779,21 +797,16 @@ public boolean isFifteenOrMoreAgentVersion() { * @param serverAddress - Имя сервера из списка баз. Может содержать номер порта менеджера * кластера (Если не указан, то по-умолчанию 1541). Примеры: Server1c, Server1c:2541 */ - private void computeServerParams(String serverAddress) { - - String host; - int newAgentPort; - int newRasPort; + private void computeHostAndPort(String serverAddress) { - serverAddress = serverAddress.strip(); - if (serverAddress.isBlank()) { - serverAddress = "localhost"; //$NON-NLS-1$ - } + String[] adr = serverAddress.split(":"); // $NON-NLS-1$ - String[] adr = serverAddress.split(":"); //$NON-NLS-1$ - host = adr[0]; + final String host = adr[0]; + final int newAgentPort; + final int newRasPort; if (adr.length == 1) { + // адрес не содержит двоеточие и номер порта, значит используется порт по-умолчанию 1541 newAgentPort = 1540; newRasPort = 1545; } else { @@ -807,7 +820,7 @@ private void computeServerParams(String serverAddress) { this.agentPort = newAgentPort; this.rasPort = newRasPort; - LOGGER.info("Compute params for Server <{}> ", this.getServerKey()); //$NON-NLS-1$ + LOGGER.info("Compute host and port for Server <{}> ", this.getServerKey()); //$NON-NLS-1$ } /** diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/NewServersChoiseDialog.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/NewServersChoiseDialog.java index 55adbab..a5e8041 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/NewServersChoiseDialog.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/NewServersChoiseDialog.java @@ -16,11 +16,12 @@ import org.eclipse.swt.widgets.TableColumn; import org.eclipse.swt.widgets.TableItem; import ru.yanygin.clusterAdminLibrary.Helper; +import ru.yanygin.clusterAdminLibrary.Server; /** Форма для выбора, какие найденные сервера добавлять в список. */ public class NewServersChoiseDialog extends Dialog { private Table table; - private List newServers; + private List newServers; /** * Create the dialog. @@ -56,10 +57,15 @@ protected Control createDialogArea(Composite parent) { table.setHeaderVisible(true); table.setLinesVisible(true); - TableColumn tblcolumn = new TableColumn(table, SWT.LEFT); - tblcolumn.setResizable(false); - tblcolumn.setWidth(200); - tblcolumn.setText(Strings.SERVER_ADDRESS); + TableColumn columnHost = new TableColumn(table, SWT.LEFT); + columnHost.setResizable(false); + columnHost.setWidth(200); + columnHost.setText(Strings.HOST); + + TableColumn columnAgentPort = new TableColumn(table, SWT.LEFT); + columnAgentPort.setResizable(false); + columnAgentPort.setWidth(100); + columnAgentPort.setText(Strings.PORT); newServers = Helper.findNewServers(); @@ -67,10 +73,13 @@ protected Control createDialogArea(Composite parent) { newServers.forEach( (serv) -> { TableItem item = new TableItem(table, SWT.NONE); - item.setText(serv); + item.setText(0, serv.getAgentHost()); + item.setText(1, serv.getAgentPortAsString()); + item.setData(serv); }); - tblcolumn.pack(); + columnHost.pack(); + columnAgentPort.pack(); return container; } @@ -80,7 +89,7 @@ private void saveNewServers() { for (TableItem tableItem : items) { if (!tableItem.getChecked()) { - newServers.remove(tableItem.getText()); + newServers.remove(tableItem.getData()); } } } @@ -90,7 +99,7 @@ private void saveNewServers() { * * @return список новых серверов */ - public List getNewServers() { + public List getNewServers() { return newServers; } @@ -115,11 +124,12 @@ public void widgetSelected(SelectionEvent e) { } private static class Strings { - static final String TITLE_WINDOW = getString("TitleDialog"); - static final String SERVER_ADDRESS = getString("ServerAddress"); + static final String TITLE_WINDOW = Messages.getString("NewServersDialog.TitleDialog"); + static final String HOST = getString("Host"); + static final String PORT = getString("Port"); static String getString(String key) { - return Messages.getString("NewServersDialog." + key); // $NON-NLS-1$ + return Messages.getString("ServerDialog." + key); // $NON-NLS-1$ } } } diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java index f3c483d..0de6a2d 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java @@ -1634,18 +1634,13 @@ public void widgetSelected(SelectionEvent e) { } if (dialog.open() == 0) { - List s = dialog.getNewServers(); + List s = dialog.getNewServers(); if (s.isEmpty()) { return; } - Map newServers = Config.currentConfig.addNewServers(s); - if (!newServers.isEmpty()) { - newServers.forEach( - (serverKey, server) -> { - addServerItemInServersTree(server); - }); - } + Config.currentConfig.addNewServers(s); + s.forEach((server) -> addServerItemInServersTree(server)); } } }; diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties index e834ea8..ae915aa 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties @@ -79,8 +79,7 @@ InfobaseDialog.TitleDialog = Infobase parameters InfobaseDialog.TitleDropInfobaseParameters = Delete infobase InfobaseDialog.YouNeedToEnter = you need to enter -NewServersDialog.ServerAddress = Server address -NewServersDialog.TitleDialog = Selecting servers to add +NewServersDialog.TitleDialog = Selecting servers to add ServerDialog.AgentParameters = Server agent parameters ServerDialog.AutoconnectAtStartup = Autoconnect to the server at startup diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties index 64b1124..2e73b98 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties @@ -79,8 +79,7 @@ InfobaseDialog.TitleDialog = \u041F\u0430\u0440\u0430\u043C\ InfobaseDialog.TitleDropInfobaseParameters = \u0423\u0434\u0430\u043B\u0435\u043D\u0438\u0435 \u0438\u043D\u0444\u043E\u0431\u0430\u0437\u044B InfobaseDialog.YouNeedToEnter = \u043D\u0443\u0436\u043D\u043E \u0437\u0430\u043F\u043E\u043B\u043D\u0438\u0442\u044C -NewServersDialog.ServerAddress = \u0410\u0434\u0440\u0435\u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 -NewServersDialog.TitleDialog = \u0412\u044B\u0431\u043E\u0440 \u0441\u0435\u0440\u0432\u0435\u0440\u043E\u0432 \u0434\u043B\u044F \u0434\u043E\u0431\u0430\u0432\u043B\u0435\u043D\u0438\u044F +NewServersDialog.TitleDialog = \u0412\u044B\u0431\u043E\u0440 \u0441\u0435\u0440\u0432\u0435\u0440\u043E\u0432 \u0434\u043B\u044F \u0434\u043E\u0431\u0430\u0432\u043B\u0435\u043D\u0438\u044F ServerDialog.AgentParameters = \u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u044B \u0430\u0433\u0435\u043D\u0442\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 ServerDialog.AutoconnectAtStartup = \u0410\u0432\u0442\u043E\u043C\u0430\u0442\u0438\u0447\u0435\u0441\u043A\u0438 \u043F\u043E\u0434\u043A\u043B\u044E\u0447\u0430\u0442\u044C\u0441\u044F \u043F\u0440\u0438 \u0441\u0442\u0430\u0440\u0442\u0435 From 51865fdd0082534588da9a3ddcb334fcb5811331 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Sun, 21 Apr 2024 11:35:31 +0300 Subject: [PATCH 48/70] =?UTF-8?q?=D0=A1=D0=BE=D1=85=D1=80=D0=B0=D0=BD?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BA=D0=BE=D0=BD=D1=84=D0=B8=D0=B3?= =?UTF-8?q?=D0=B0=20=D0=BF=D0=BE=D1=81=D0=BB=D0=B5=20=D0=B4=D0=BE=D0=B1?= =?UTF-8?q?=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20=D1=81=D0=B5=D1=80?= =?UTF-8?q?=D0=B2=D0=B5=D1=80=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/ru/yanygin/clusterAdminLibrary/Config.java | 1 + 1 file changed, 1 insertion(+) diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java index dda9c07..cd7a108 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java @@ -476,6 +476,7 @@ public void addNewServers(List newServers) { for (Server server : newServers) { servers.put(server.getServerKey(), server); } + saveConfig(); } /** Подключиться ко всем серверам в тихом режиме. */ From f998b595673301d092739aa3fd65cf2434390904 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Sun, 21 Apr 2024 12:29:12 +0300 Subject: [PATCH 49/70] =?UTF-8?q?=D0=98=D0=BC=D1=8F=20=D1=85=D0=BE=D1=81?= =?UTF-8?q?=D1=82=D0=B0=20=D0=B2=20=D0=BA=D0=BB=D1=8E=D1=87=D0=B5=20=D1=81?= =?UTF-8?q?=D0=B5=D1=80=D0=B2=D0=B5=D1=80=D0=B0=20=D0=BA=20=D0=BD=D0=B8?= =?UTF-8?q?=D0=B6=D0=BD=D0=B5=D0=BC=D1=83=20=D1=80=D0=B5=D0=B3=D0=B8=D1=81?= =?UTF-8?q?=D1=82=D1=80=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/ru/yanygin/clusterAdminLibrary/Server.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java index 62bd48d..710e03e 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java @@ -380,7 +380,7 @@ public boolean needShowConnectionError() { * @return ключ сервера */ public String getServerKey() { - return agentHost.concat(":").concat(Integer.toString(agentPort)); //$NON-NLS-1$ + return agentHost.toLowerCase().concat(":").concat(Integer.toString(agentPort)); // $NON-NLS-1$ } /** From a602578adfe099e43cfc601a8a2b36892be2228b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Mon, 22 Apr 2024 18:23:16 +0300 Subject: [PATCH 50/70] =?UTF-8?q?=D0=9F=D1=80=D0=BE=D0=B2=D0=B5=D1=80?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=B0=D1=83=D1=82=D0=B5=D0=BD=D1=82=D0=B8=D1=84?= =?UTF-8?q?=D0=B8=D0=BA=D0=B0=D1=86=D0=B8=D0=B8=20=D0=B0=D0=B3=D0=B5=D0=BD?= =?UTF-8?q?=D1=82=D0=B0=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B4=20=D0=BF=D0=B5?= =?UTF-8?q?=D1=80=D0=B5=D0=B7=D0=B0=D0=BF=D1=83=D1=81=D0=BA=D0=BE=D0=BC=20?= =?UTF-8?q?=D0=A0=D0=9F=D0=A5=D0=BE=D1=81=D1=82=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/ru/yanygin/clusterAdminLibrary/Server.java | 2 +- .../java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java index 1b2de36..43ee805 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java @@ -997,7 +997,7 @@ private boolean checkAndRunLocalRas() { * @param clusterId - ID кластера * @return boolean истекла/не истекла */ - private boolean checkAutenticateAgent() { + public boolean checkAutenticateAgent() { var needAuthenticate = false; try { diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java index cbcbe95..e59f5ad 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java @@ -2113,6 +2113,8 @@ public void widgetSelected(SelectionEvent event) { return; } + server.checkAutenticateAgent(); + Thread thread = new Thread( () -> { @@ -2128,7 +2130,8 @@ public void widgetSelected(SelectionEvent event) { clusterInfo.setExpirationTimeout(20); if (!server.regCluster(clusterInfo)) { - Helper.showMessageBox("Error edit cluster"); + Helper.showMessageBox("Error setting temporary properties for the cluster"); + return; } // подождать 10 секунд и вернуть все назад @@ -2139,12 +2142,11 @@ public void widgetSelected(SelectionEvent event) { } clusterInfo.setLifeTimeLimit(oldLifeTimeLimit); - clusterInfo.setClusterRecyclingKillProblemProcesses(oldRecyclingKillProcesses); clusterInfo.setExpirationTimeout(oldExpirationTimeout); if (!server.regCluster(clusterInfo)) { - Helper.showMessageBox("Error edit cluster"); + Helper.showMessageBox("Error returning cluster properties"); } }); From d66fedb2f168021753265b704eb31248cd20bc7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Tue, 23 Apr 2024 07:56:13 +0300 Subject: [PATCH 51/70] =?UTF-8?q?=D0=A1=D1=81=D1=8B=D0=BB=D0=BA=D0=B0=20?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=B1=D1=83=D1=81=D1=82=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ru/yanygin/clusterAdminLibraryUI/AboutDialog.java | 9 ++++++++- .../ru/yanygin/clusterAdminLibraryUI/messages.properties | 1 + .../clusterAdminLibraryUI/messages_ru_RU.properties | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/AboutDialog.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/AboutDialog.java index ab0af08..f58253c 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/AboutDialog.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/AboutDialog.java @@ -26,6 +26,7 @@ public class AboutDialog extends Dialog { "https://github.com/YanSergey/OneS_ClusterAdmin"; //$NON-NLS-1$ private static final String TELEGRAM_LINK = "https://t.me/YanSergey"; //$NON-NLS-1$ private static final String EMAIL_LINK = "mailto:yanyginsa@gmail.com"; //$NON-NLS-1$ + private static final String BOOSTY_LINK = "https://boosty.to/YanSergeyCoder"; // $NON-NLS-1$ Config config = Config.currentConfig; @@ -91,6 +92,10 @@ protected Control createDialogArea(Composite parent) { linkEmail.setText(Strings.EMAIL_DESCRIPTION); linkEmail.addSelectionListener(goToLinkListener); + Link linkBoosty = new Link(container, 0); + linkBoosty.setText(Strings.BOOSTY_DESCRIPTION); + linkBoosty.addSelectionListener(goToLinkListener); + return container; } @@ -166,6 +171,8 @@ private static class Strings { String.format(getString("Telegram_Description"), TELEGRAM_LINK); static final String EMAIL_DESCRIPTION = String.format(getString("Email_Description"), EMAIL_LINK); + static final String BOOSTY_DESCRIPTION = + String.format(getString("Boosty_Description"), BOOSTY_LINK); static String getString(String key) { return Messages.getString("AboutDialog." + key); //$NON-NLS-1$ @@ -174,6 +181,6 @@ static String getString(String key) { @Override protected Point getInitialSize() { - return new Point(500, 380); + return new Point(500, 418); } } diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties index a1703d3..9c98e6d 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties @@ -3,6 +3,7 @@ #Sun Apr 17 15:13:55 MSK 2022 AboutDialog.Autor = Autor:\r\nYanygin Sergey (Tula) +AboutDialog.Boosty_Description = Support the project on Boosty:\r\n%s AboutDialog.CurrentVersion = version %s AboutDialog.CurrentVersionIsLatest = (the latest version is installed) AboutDialog.CurrentVersionIsOld = (latest version is %s, download) diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties index 27dcab1..fb44054 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties @@ -3,6 +3,7 @@ #Thu Sep 09 18:06:08 MSK 2021 AboutDialog.Autor = \u0410\u0432\u0442\u043E\u0440:\r\n\u042F\u043D\u044B\u0433\u0438\u043D \u0421\u0435\u0440\u0433\u0435\u0439 (\u0433. \u0422\u0443\u043B\u0430) +AboutDialog.Boosty_Description = \u041F\u043E\u0434\u0434\u0435\u0440\u0436\u0430\u0442\u044C \u043F\u0440\u043E\u0435\u043A\u0442 \u043D\u0430 Boosty:\r\n%s AboutDialog.CurrentVersion = \u0432\u0435\u0440\u0441\u0438\u044F %s AboutDialog.CurrentVersionIsLatest = (\u0443\u0441\u0442\u0430\u043D\u043E\u0432\u043B\u0435\u043D\u0430 \u043F\u043E\u0441\u043B\u0435\u0434\u043D\u044F\u044F \u0432\u0435\u0440\u0441\u0438\u044F) AboutDialog.CurrentVersionIsOld = (\u043F\u043E\u0441\u043B\u0435\u0434\u043D\u044F\u044F \u0432\u0435\u0440\u0441\u0438\u044F %s, \u0441\u043A\u0430\u0447\u0430\u0442\u044C) From c5841e8a14bcd325cd6155ff153ce6069c2937b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Tue, 23 Apr 2024 13:23:25 +0300 Subject: [PATCH 52/70] =?UTF-8?q?=D0=9F=D1=83=D0=BD=D0=BA=D1=82=20=D0=BC?= =?UTF-8?q?=D0=B5=D0=BD=D1=8E=20Create->Add=20=D0=BA=20=D1=81=D0=BB=D0=B8?= =?UTF-8?q?=D1=8F=D0=BD=D0=B8=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/ru/yanygin/clusterAdminLibraryUI/AdminsDialog.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/AdminsDialog.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/AdminsDialog.java index fb5770c..923d411 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/AdminsDialog.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/AdminsDialog.java @@ -317,7 +317,7 @@ private static class Strings { static final String ANSWER_DELETE = getString("AnswerDelete"); - static final String TOOLBAR_ADD = Messages.getString("ViewerArea.ContextMenu.Create"); + static final String TOOLBAR_ADD = Messages.getString("ViewerArea.ContextMenu.Add"); static final String TOOLBAR_EDIT = Messages.getString("ViewerArea.ContextMenu.Edit"); static final String TOOLBAR_DELETE = Messages.getString("ViewerArea.ContextMenu.Delete"); static final String CONTEXT_MENU_ADD = TOOLBAR_ADD.concat("\tIns"); From 1ef934c8407c3eca3d7d924b407b9c76998a2c38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Tue, 23 Apr 2024 13:25:00 +0300 Subject: [PATCH 53/70] =?UTF-8?q?=D0=94=D0=BE=D1=80=D0=B0=D0=B1=D0=BE?= =?UTF-8?q?=D1=82=D0=BA=D0=B0=20=D1=82=D0=B5=D1=81=D1=82=D0=B0=20=D0=BA=20?= =?UTF-8?q?=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=B8=D1=8E=20create?= =?UTF-8?q?NewServer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../test/java/ru/yanygin/clusterAdminLibrary/ConfigTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clusterAdminLibrary/src/test/java/ru/yanygin/clusterAdminLibrary/ConfigTest.java b/clusterAdminLibrary/src/test/java/ru/yanygin/clusterAdminLibrary/ConfigTest.java index d6682d3..f7cc1e9 100644 --- a/clusterAdminLibrary/src/test/java/ru/yanygin/clusterAdminLibrary/ConfigTest.java +++ b/clusterAdminLibrary/src/test/java/ru/yanygin/clusterAdminLibrary/ConfigTest.java @@ -73,9 +73,9 @@ void testCreateNewServer() { Server server = emptyConfig.createNewServer(); - assertEquals("Server", server.getAgentHost()); + assertEquals("Server1c", server.getAgentHost()); assertEquals("1540", server.getAgentPortAsString()); - assertEquals("Server", server.getRasHost()); + assertEquals("Server1c", server.getRasHost()); assertEquals("1545", server.getRasPortAsString()); } } From 6366633cf9698879ea6d5f540322590096463d9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Wed, 24 Apr 2024 19:10:16 +0300 Subject: [PATCH 54/70] =?UTF-8?q?=D0=A4=D1=83=D0=BD=D0=BA=D1=86=D0=B8?= =?UTF-8?q?=D0=BE=D0=BD=D0=B0=D0=BB=20=D0=A2=D0=9D=D0=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AssignmentRuleContentProvider.java | 34 + .../AssignmentRuleLabelProvider.java | 188 +++ .../clusterAdminLibrary/BaseInfoExtended.java | 1 + .../yanygin/clusterAdminLibrary/Config.java | 23 +- .../yanygin/clusterAdminLibrary/Server.java | 193 ++- .../clusterAdminLibrary/messages.properties | 39 + .../messages_ru_RU.properties | 39 + .../AssignmentRuleDialog.java | 264 ++++ .../clusterAdminLibraryUI/ViewerArea.java | 1110 ++++++++++++----- .../clusterAdminLibraryUI/messages.properties | 9 +- .../messages_ru_RU.properties | 9 +- .../src/main/resources/icons/view_16.png | Bin 0 -> 677 bytes 12 files changed, 1532 insertions(+), 377 deletions(-) create mode 100644 clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/AssignmentRuleContentProvider.java create mode 100644 clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/AssignmentRuleLabelProvider.java create mode 100644 clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/AssignmentRuleDialog.java create mode 100644 clusterAdminLibrary/src/main/resources/icons/view_16.png diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/AssignmentRuleContentProvider.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/AssignmentRuleContentProvider.java new file mode 100644 index 0000000..9aaa7f7 --- /dev/null +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/AssignmentRuleContentProvider.java @@ -0,0 +1,34 @@ +package ru.yanygin.clusterAdminLibrary; + +import com._1c.v8.ibis.admin.IAssignmentRuleInfo; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.eclipse.jface.viewers.IStructuredContentProvider; + +/** Контент-провайдер для заполнения таблицы с ТНФ. */ +public class AssignmentRuleContentProvider implements IStructuredContentProvider { + + static Map ruleNumbers = new HashMap<>(); + + /** + * Returns the elements in the input, which must be either an array or a Collection . + */ + @Override + public Object[] getElements(Object inputElement) { + List listTnf = (List) inputElement; + setRuleNumbers(listTnf); + return listTnf.toArray(); + } + + private static void setRuleNumbers(List rules) { + ruleNumbers.clear(); + for (int i = 0; i < rules.size(); i++) { + ruleNumbers.put(rules.get(i), i + 1); + } + } + + public static int getRuleNumber(IAssignmentRuleInfo rule) { + return ruleNumbers.getOrDefault(rule, 0); + } +} diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/AssignmentRuleLabelProvider.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/AssignmentRuleLabelProvider.java new file mode 100644 index 0000000..86d0d35 --- /dev/null +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/AssignmentRuleLabelProvider.java @@ -0,0 +1,188 @@ +package ru.yanygin.clusterAdminLibrary; + +import com._1c.v8.ibis.admin.IAssignmentRuleInfo; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import org.eclipse.jface.viewers.ColumnLabelProvider; + +/** Провайдер требований назначения функциональности. */ +public class AssignmentRuleLabelProvider extends ColumnLabelProvider { + + private static final String NUMBER = "AssignmentRule.Number"; + private static final String OBJECT_TYPE = "AssignmentRule.ObjectType"; + private static final String RULE_TYPE = "AssignmentRule.RuleType"; + private static final String INFOBASE_NAME = "AssignmentRule.InfoBaseName"; + private static final String APPLICATION_EXT = "AssignmentRule.ApplicationExt"; + private static final String PRIORITY = "AssignmentRule.Priority"; + + private static Config commonConfig = Config.currentConfig; + private static ColumnProperties columnProperties = + commonConfig.getColumnsProperties(IAssignmentRuleInfo.class); + + private String columnName; + + public static final String RULE_TYPE_DO_NOT_ASSIGN = + Messages.getString("AssignmentRule.RuleType.DoNotAssign"); // "Не назначать" = 0 + public static final String RULE_TYPE_AUTO = + Messages.getString("AssignmentRule.RuleType.Auto"); // "Авто" = 1 + public static final String RULE_TYPE_ASSIGN = + Messages.getString("AssignmentRule.RuleType.Assign"); // "Назначать" = 2 + + static final String[] ruleType = {RULE_TYPE_DO_NOT_ASSIGN, RULE_TYPE_AUTO, RULE_TYPE_ASSIGN}; + static final Map objectTypes = fillObjectType(); + + public AssignmentRuleLabelProvider(String columnName) { + this.columnName = columnName; + } + + private static Map fillObjectType() { + + Map objectTypes = new HashMap<>(); + objectTypes.put("", Messages.getString("AssignmentRule.ObjectType.ForAll")); + + String[] ruleKeys = { + "Connection", + "ClientTestingService", + "SessionDataService", + "DataEditLockService", + "JobService", + "ExternalDataSourceXMLAService", + "ExternalSessionManagerService", + "EventLogService", + "TimestampService", + "AuxiliaryService", + "ExternalDataSourceODBCService", + "OpenID2ProviderContextService", + "SessionReuseService", + "TransactionLockService", + "LicenseService", + "FulltextSearchService", + "SettingsService", + "NumerationService", + "DataBaseConfigurationUpdateService", + "DatabaseTableNumberingService", + "CounterService", + + // доступны с версии платформы, где добавлен дата акселератор (?) + "DbCopiesTimeService", + "GetSessionsService", + "IntegrationDataService", + "DbCopiesService", + "DataAcceleratorService" + }; + Arrays.sort(ruleKeys); + + for (String ruleKey : ruleKeys) { + objectTypes.put(ruleKey, Messages.getString("AssignmentRule.ObjectType." + ruleKey)); + } + return objectTypes; + } + + /** Возвращает возможные значения доп. параметров. */ + public static String[] getApplicationExtValues() { + String[] appExtValues = { + "Designer", + "1CV8", + "1CV8C", + "1CV8CDirect", + "WebClient", + "COMConnection", + "WSConnection", + "HTTPServiceConnection", + "ODataConnection", + "BotConnection", + "WebServerExtension", + "MobileClient", + "AnalyticsSystemClient", + "AnalyticsSystemQuery", + "BackgroundJob.ScheduledJob.<Имя объекта конфигурации>", + "BackgroundJob.CommonModule", + "BackgroundJob.CommonModule.<Имя модуля>.<Имя метода>", + "BackgroundJob.FullTextSearchIndexUpdate", + "BackgroundJob.GenerateReport.<Полное имя объекта конфигурации>", + "BackgroundJob.InputByString.<Полное имя объекта конфигурации>", + "BackgroundJob.DynamicListSearch.<Полное имя формы>.<Имя таблицы формы связанной со списком>", + "BackgroundJob.DBCopiesFilling", + "BackgroundJob.DBCopiesNotification", + "BackgroundJob.UpdateDataHistoryImmediatelyAfterWrite", + "BackgroundJob.AfterWriteDataHistoryVersionsProcessing", + "BackgroundJob.GlobalSearchFunctionsMenu", + "BackgroundJob.GlobalSearchFullTextSearch", + "BackgroundJob.GlobalSearchHelp", + "BackgroundJob.GlobalSearchAllFunctions", + "BackgroundJob.GlobalSearch.<имя модуля>.<имя метода>", + "BackgroundJob.IntegrationServiceReceivedMessagesProcessing.<Полное имя канала сервиса интеграции>", + "SystemBackgroundJob.DBConfigUpdate", + "SystemBackgroundJob.RecalcTotals", + "BackgroundJob.SendIntegrationSystemMessagesQueueProcessing.<полное имя сервиса интеграции>", + "BackgroundJob.ReceiveIntegrationSystemMessagesQueueProcessing.<полное имя сервиса интеграции>", + "BackgroundJob.ReceivingIntegrationSystemMessages.<полное имя сервиса интеграции>", + "BackgroundJob.ReceivedIntegrationSystemMessagesProcessing.<полное имя канала сервиса интеграции>", + "BackgroundJob.StandaloneExchange" + }; + return appExtValues; + } + + private static void putObjectType(Map objectTypes, String key) { + objectTypes.put(key, Messages.getString("AssignmentRule.ObjectType." + key)); + } + + public static Map getObjectTypes() { + return objectTypes; + } + + public static String getObjectType(String key) { + return objectTypes.getOrDefault(key, "unknown"); + } + + @Override + public String getText(Object element) { + if (!(element instanceof IAssignmentRuleInfo)) { + return null; + } + return String.valueOf(getValue(element)); + } + + /** + * Возвращает наименование правила ТНФ. + * + * @param element - элемент, для которого нужно вернуть наименование ТНФ + */ + public Object getValue(Object element) { + if (!(element instanceof IAssignmentRuleInfo)) { + return null; + } + IAssignmentRuleInfo rule = (IAssignmentRuleInfo) element; + + switch (columnName) { + case NUMBER: + return AssignmentRuleContentProvider.getRuleNumber(rule); + case OBJECT_TYPE: + return objectTypes.getOrDefault(rule.getObjectType(), "unknown"); + case RULE_TYPE: + return ruleType[rule.getRuleType()]; + case INFOBASE_NAME: + return rule.getInfoBaseName(); + case APPLICATION_EXT: + return rule.getApplicationExt(); + case PRIORITY: + return rule.getPriority(); + default: + return "UnknownColumn"; + } + } + + /** Инициализация имен колонок. */ + protected static void initColumnsName() { + columnProperties.addColumnsInMap( + OBJECT_TYPE, RULE_TYPE, INFOBASE_NAME, APPLICATION_EXT, NUMBER, PRIORITY); + } + + private static class Strings { + + static String getString(String key) { + return Messages.getString("AssignmentRule." + key); // $NON-NLS-1$ + } + } +} diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BaseInfoExtended.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BaseInfoExtended.java index 64ed60e..7461690 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BaseInfoExtended.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BaseInfoExtended.java @@ -242,6 +242,7 @@ public static void init() { LockInfoExtended.initColumnsName(); WorkingProcessInfoExtended.initColumnsName(); WorkingServerInfoExtended.initColumnsName(); + AssignmentRuleLabelProvider.initColumnsName(); } /** diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java index 2d692c4..31e4067 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java @@ -1,5 +1,6 @@ package ru.yanygin.clusterAdminLibrary; +import com._1c.v8.ibis.admin.IAssignmentRuleInfo; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonIOException; @@ -155,6 +156,10 @@ public class Config { @Expose private ColumnProperties wsColumnProperties = new ColumnProperties(0); + @SerializedName("AssignmentRuleColumnProperties") + @Expose + private ColumnProperties asRuleColumnProperties = new ColumnProperties(0); + private static final Logger LOGGER = (Logger) LoggerFactory.getLogger(Config.class.getSimpleName()); @@ -208,8 +213,8 @@ public Config(String configPath) { // } // } - /** Init config. */ - public void init() { + /** Действия, которые нужно выполнить после чтения или создания конфига. */ + public void postInit() { runReadUpstreamVersion(); } @@ -910,10 +915,10 @@ public void setListRrefreshRate(int refreshRate) { /** * Получение свойства колонок списков. * - * @param clazz - имя класса, идентифицирующее список-кладелец колонок + * @param clazz - имя класса, идентифицирующее список-владелец колонок * @return ColumnProperties - свойства колонок списка */ - public ColumnProperties getColumnsProperties(Class clazz) { + public ColumnProperties getColumnsProperties(Class clazz) { if (clazz == SessionInfoExtended.class) { return sessionColumnProperties; } else if (clazz == ConnectionInfoExtended.class) { @@ -924,6 +929,8 @@ public ColumnProperties getColumnsProperties(Class c return wpColumnProperties; } else if (clazz == WorkingServerInfoExtended.class) { return wsColumnProperties; + } else if (clazz == IAssignmentRuleInfo.class) { + return asRuleColumnProperties; } else { return null; } @@ -935,7 +942,7 @@ public ColumnProperties getColumnsProperties(Class c * @param clazz - имя класса, идентифицирующее список-кладелец колонок * @param columnOrder - новый порядок колонок */ - public void setColumnsOrder(Class clazz, int[] columnOrder) { + public void setColumnsOrder(Class clazz, int[] columnOrder) { getColumnsProperties(clazz).setOrder(columnOrder); } @@ -946,7 +953,7 @@ public void setColumnsOrder(Class clazz, int[] colum * @param index - индекс колонки * @param width - ширина колонки */ - public void setColumnsWidth(Class clazz, int index, int width) { + public void setColumnsWidth(Class clazz, int index, int width) { getColumnsProperties(clazz).setWidth(index, width); } @@ -1075,7 +1082,7 @@ public static Config readConfig(String configPath) { config.setConfigPath(configPath); config.migrateProps(); - config.init(); + // config.init(); if (config.getLocale() != null) { LOGGER.debug("Set locale is <{}>", config.getLocale()); //$NON-NLS-1$ Locale locale = Locale.forLanguageTag(config.getLocale()); @@ -1085,6 +1092,8 @@ public static Config readConfig(String configPath) { config.applyLoggerLevel(); } + config.postInit(); + LOGGER.info("Config file read successfully"); //$NON-NLS-1$ return config; } diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java index 1b2de36..e271874 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java @@ -3195,77 +3195,206 @@ public List getClusterServices(UUID clusterId) { } /** - * Applies assignment rules. + * Получает список описаний ТНФ рабочего сервера. * *

Требует аутентификации в кластере * * @param clusterId - ID кластера - * @param full - assigment rule application mode: 0 - partial 1 - full + * @param serverId - ID рабочего сервера + * @return список ТНФ */ - public void applyAssignmentRules(UUID clusterId, int full) { - // TODO - agentConnection.applyAssignmentRules(clusterId, full); + public List getAssignmentRules(UUID clusterId, UUID serverId) { + LOGGER.debug( + "Getting a list of descriptions of assignment rules, cluster <{}>, ws <{}>", //$NON-NLS-1$ + clusterId, + serverId); + + if (!isConnected()) { + return new ArrayList<>(); + } + if (!checkAutenticateCluster(clusterId)) { + return new ArrayList<>(); + } + + List assignmentRules; + try { + assignmentRules = agentConnection.getAssignmentRules(clusterId, serverId); + } catch (Exception excp) { + LOGGER.error( + "Error in getting a list of descriptions of assignment rules", excp); // $NON-NLS-1$ + return new ArrayList<>(); + } + + assignmentRules.forEach( + rule -> + LOGGER.debug( + "\tRule: ObjectType=<{}>, RuleId=<{}>", //$NON-NLS-1$ + rule.getObjectType(), + rule.getAssignmentRuleId())); + + LOGGER.debug("Getting the list of assignment rule descriptions was successful"); // $NON-NLS-1$ + return assignmentRules; } /** - * Gets the list of descriptions of working server assignment rules. + * Получает описание правила ТНФ. * *

Требует аутентификации в кластере * * @param clusterId - ID кластера - * @param serverId - server ID - * @return infobase full infobase description + * @param serverId - ID рабочего сервера + * @param ruleId - ID правила ТНФ + * @return описание правила ТНФ */ - public List getAssignmentRules(UUID clusterId, UUID serverId) { - // TODO - return agentConnection.getAssignmentRules(clusterId, serverId); + public IAssignmentRuleInfo getAssignmentRuleInfo(UUID clusterId, UUID serverId, UUID ruleId) { + LOGGER.debug( + "Getting a description of the assignment rule, cluster <{}>, ws <{}>, rule <{}>", //$NON-NLS-1$ + clusterId, + serverId, + ruleId); + + if (!isConnected()) { + return null; + } + if (!checkAutenticateCluster(clusterId)) { + return null; + } + + IAssignmentRuleInfo assignmentRule; + try { + assignmentRule = agentConnection.getAssignmentRuleInfo(clusterId, serverId, ruleId); + } catch (Exception excp) { + LOGGER.error( + "Error in getting a list of descriptions of assignment rules", excp); // $NON-NLS-1$ + return null; + } + + LOGGER.debug( + "\tAssignment rule: ObjectType=<{}>", //$NON-NLS-1$ + assignmentRule.getObjectType()); + + LOGGER.debug("Getting the list of assignment rule descriptions was successful"); // $NON-NLS-1$ + return assignmentRule; } /** - * Creates an assignment rule, changes an existing one, or moves an existing rule to a new - * position. + * Создает правило ТНФ, изменяет существующее или переносит существующее правило в новую позицию. * *

Требует аутентификации в кластере * * @param clusterId - ID кластера - * @param serverId - server ID - * @param info - assignment rule description - * @param position - position in the rule list (starts from 0) - * @return ID of the created rule, or null if an existing assignment rule was changed + * @param serverId - ID рабочего сервера + * @param info - правило ТНФ + * @param position - позиция в списке правил (начинается с 0) + * @return ID созданного правила или null, если существующее правило было изменено */ - public UUID regAssignmentRule( + public boolean regAssignmentRule( UUID clusterId, UUID serverId, IAssignmentRuleInfo info, int position) { + + LOGGER.debug( + "Registration assignment rule <{}>", //$NON-NLS-1$ + info.getObjectType()); + + if (!isConnected()) { + return false; + } + if (!checkAutenticateCluster(clusterId)) { + return false; + } + + UUID newRuleId; + try { + newRuleId = agentConnection.regAssignmentRule(clusterId, serverId, info, position); + } catch (Exception excp) { + LOGGER.error( + "Error registraion assignment rule", //$NON-NLS-1$ + excp); + return false; + } + + if (newRuleId.equals(Helper.EMPTY_UUID)) { + LOGGER.debug( + "Registration new assignment rule <{}> succesful", //$NON-NLS-1$ + newRuleId); + } else { + LOGGER.debug( + "Registration changes a assignment rule <{}> was succesful", //$NON-NLS-1$ + info.getAssignmentRuleId()); + } + // TODO - return agentConnection.regAssignmentRule(clusterId, serverId, info, position); + return true; } /** - * Deletes an assignment rule from the list of working server rules. + * Удаляет правило ТНФ из списка правил рабочего сервера. * *

Требует аутентификации в кластере * * @param clusterId - ID кластера - * @param serverId - working server ID - * @param ruleId - assignment rule ID + * @param serverId - ID рабочего сервера + * @param ruleId - ID правила ТНФ */ - public void unregAssignmentRule(UUID clusterId, UUID serverId, UUID ruleId) { - // TODO - agentConnection.unregAssignmentRule(clusterId, serverId, ruleId); + public boolean unregAssignmentRule(UUID clusterId, UUID serverId, UUID ruleId) { + + LOGGER.debug( + "Unregistration assignment rule <{}>", //$NON-NLS-1$ + ruleId); + + if (!isConnected()) { + return false; + } + if (!checkAutenticateCluster(clusterId)) { + return false; + } + + try { + agentConnection.unregAssignmentRule(clusterId, serverId, ruleId); + } catch (Exception excp) { + LOGGER.error( + "Error unregistraion assignment rule", //$NON-NLS-1$ + excp); + return false; + } + + LOGGER.debug("Unregistration assignment rule <{}> succesful"); // $NON-NLS-1$ + + return true; } /** - * Gets an assignment rule description. + * Применяет ТНФ. * *

Требует аутентификации в кластере * * @param clusterId - ID кластера - * @param serverId - server ID - * @param ruleId - assignment rule ID - * @return assignment rule description + * @param mode - Режим применения ТНФ: 0 - частичное 1 - полное */ - public IAssignmentRuleInfo getAssignmentRuleInfo(UUID clusterId, UUID serverId, UUID ruleId) { - // TODO - return agentConnection.getAssignmentRuleInfo(clusterId, serverId, ruleId); + public boolean applyAssignmentRules(UUID clusterId, int mode) { + + LOGGER.debug( + "Apply assignment rules for cluster <{}>", //$NON-NLS-1$ + clusterId); + + if (!isConnected()) { + return false; + } + if (!checkAutenticateCluster(clusterId)) { + return false; + } + + try { + agentConnection.applyAssignmentRules(clusterId, mode); + } catch (Exception excp) { + LOGGER.error( + "Error apply assignment rules", //$NON-NLS-1$ + excp); + return false; + } + + LOGGER.debug("Apply assignment rules was succesful"); // $NON-NLS-1$ + + return true; } /** diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/messages.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/messages.properties index 7a59c68..74d5676 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/messages.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/messages.properties @@ -2,6 +2,45 @@ #Eclipse messages class #Fri Oct 01 13:58:03 MSK 2021 +AssignmentRule.ApplicationExt = Value of additional parameter +AssignmentRule.InfoBaseName = Infobase name +AssignmentRule.Number = Number +AssignmentRule.ObjectType = Requirement object +AssignmentRule.ObjectType.AuxiliaryService = Utility cluster service +AssignmentRule.ObjectType.ClientTestingService = Testing service +AssignmentRule.ObjectType.Connection = Client infobase connection +AssignmentRule.ObjectType.CounterService = Service of resource consumption counters monitoring +AssignmentRule.ObjectType.DataAcceleratorService = Data accelerator service +AssignmentRule.ObjectType.DataBaseConfigurationUpdateService = Database configuration update service +AssignmentRule.ObjectType.DataEditLockService = Object locking service +AssignmentRule.ObjectType.DatabaseTableNumberingService = Table name and database field numbering service +AssignmentRule.ObjectType.DbCopiesService = Database copy service +AssignmentRule.ObjectType.DbCopiesTimeService = Database copy time service +AssignmentRule.ObjectType.EventLogService = Event logging service +AssignmentRule.ObjectType.ExternalDataSourceODBCService = ODBC external data source access service +AssignmentRule.ObjectType.ExternalDataSourceXMLAService = XMLA external data source access service +AssignmentRule.ObjectType.ExternalSessionManagerService = External session management service +AssignmentRule.ObjectType.ForAll = For all +AssignmentRule.ObjectType.FulltextSearchService = Full-text search service +AssignmentRule.ObjectType.GetSessionsService = Service for getting a session list +AssignmentRule.ObjectType.IntegrationDataService = Integration data service +AssignmentRule.ObjectType.JobService = Job service +AssignmentRule.ObjectType.LicenseService = Licensing service +AssignmentRule.ObjectType.NumerationService = Numbering service +AssignmentRule.ObjectType.OpenID2ProviderContextService = OpenID2 service provider +AssignmentRule.ObjectType.SessionDataService = Session data service +AssignmentRule.ObjectType.SessionReuseService = Session reuse service +AssignmentRule.ObjectType.SettingsService = User-defined settings service +AssignmentRule.ObjectType.TimestampService = Time service +AssignmentRule.ObjectType.TransactionLockService = Transaction lock service +AssignmentRule.Priority = Priority +AssignmentRule.RuleType = Requirement type +AssignmentRule.RuleType.Assign = Assign +AssignmentRule.RuleType.Auto = Auto +AssignmentRule.RuleType.DoNotAssign = Do not assign +AssignmentRule.TitleEditRule = Assignment rule +AssignmentRule.TitleNewRule = New assignment rule + ConnectionInfo.ConnectedAt = Connected at ConnectionInfo.Connection = Connection ConnectionInfo.Hostname = Hostname diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/messages_ru_RU.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/messages_ru_RU.properties index 4da4f24..fd3b861 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/messages_ru_RU.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/messages_ru_RU.properties @@ -1,5 +1,44 @@ #Generated by ResourceBundle Editor (http://essiembre.github.io/eclipse-rbe/) +AssignmentRule.ApplicationExt = \u0417\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0434\u043E\u043F. \u043F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u0430 +AssignmentRule.InfoBaseName = \u0418\u043C\u044F \u0418\u0411 +AssignmentRule.Number = \u041D\u043E\u043C\u0435\u0440 +AssignmentRule.ObjectType = \u041E\u0431\u044A\u0435\u043A\u0442 \u0442\u0440\u0435\u0431\u043E\u0432\u0430\u043D\u0438\u044F +AssignmentRule.ObjectType.AuxiliaryService = \u0421\u0435\u0440\u0432\u0438\u0441 \u0432\u0441\u043F\u043E\u043C\u043E\u0433\u0430\u0442\u0435\u043B\u044C\u043D\u044B\u0445 \u0444\u0443\u043D\u043A\u0446\u0438\u0439 \u043A\u043B\u0430\u0441\u0442\u0435\u0440\u0430 +AssignmentRule.ObjectType.ClientTestingService = \u0421\u0435\u0440\u0432\u0438\u0441 \u0442\u0435\u0441\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u044F +AssignmentRule.ObjectType.Connection = \u041A\u043B\u0438\u0435\u043D\u0442\u0441\u043A\u043E\u0435 \u0441\u043E\u0435\u0434\u0438\u043D\u0435\u043D\u0438\u0435 \u0441 \u0418\u0411 +AssignmentRule.ObjectType.CounterService = \u0421\u0435\u0440\u0432\u0438\u0441 \u043C\u043E\u043D\u0438\u0442\u043E\u0440\u0438\u043D\u0433\u0430 \u0441\u0447\u0435\u0442\u0447\u0438\u043A\u043E\u0432 \u043F\u043E\u0442\u0440\u0435\u0431\u043B\u0435\u043D\u0438\u044F \u0440\u0435\u0441\u0443\u0440\u0441\u043E\u0432 +AssignmentRule.ObjectType.DataAcceleratorService = \u0421\u0435\u0440\u0432\u0438\u0441 \u0414\u0430\u0442\u0430 a\u043A\u0441\u0435\u043B\u0435\u0440\u0430\u0442\u043E\u0440\u0430 +AssignmentRule.ObjectType.DataBaseConfigurationUpdateService = \u0421\u0435\u0440\u0432\u0438\u0441 \u043E\u0431\u043D\u043E\u0432\u043B\u0435\u043D\u0438\u044F \u043A\u043E\u043D\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0431\u0430\u0437\u044B \u0434\u0430\u043D\u043D\u044B\u0445 +AssignmentRule.ObjectType.DataEditLockService = \u0421\u0435\u0440\u0432\u0438\u0441 \u0431\u043B\u043E\u043A\u0438\u0440\u043E\u0432\u043A\u0438 \u043E\u0431\u044A\u0435\u043A\u0442\u043E\u0432 +AssignmentRule.ObjectType.DatabaseTableNumberingService = \u0421\u0435\u0440\u0432\u0438\u0441 \u043D\u043E\u043C\u0435\u0440\u043E\u0432 \u0438\u043C\u0435\u043D \u0442\u0430\u0431\u043B\u0438\u0446 \u0438 \u043F\u043E\u043B\u0435\u0439 \u0431\u0430\u0437\u044B \u0434\u0430\u043D\u043D\u044B\u0445 +AssignmentRule.ObjectType.DbCopiesService = \u0421\u0435\u0440\u0432\u0438\u0441 \u043A\u043E\u043F\u0438\u0439 \u0431\u0430\u0437\u044B \u0434\u0430\u043D\u043D\u044B\u0445 +AssignmentRule.ObjectType.DbCopiesTimeService = \u0421\u0435\u0440\u0432\u0438\u0441 \u0432\u0440\u0435\u043C\u0435\u043D\u0438 \u043A\u043E\u043F\u0438\u0439 \u0431\u0430\u0437\u044B \u0434\u0430\u043D\u043D\u044B\u0445 +AssignmentRule.ObjectType.EventLogService = \u0421\u0435\u0440\u0432\u0438\u0441 \u0436\u0443\u0440\u043D\u0430\u043B\u043E\u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 +AssignmentRule.ObjectType.ExternalDataSourceODBCService = \u0421\u0435\u0440\u0432\u0438\u0441 \u0440\u0430\u0431\u043E\u0442\u044B \u0441 \u0432\u043D\u0435\u0448\u043D\u0438\u043C\u0438 \u0438\u0441\u0442\u043E\u0447\u043D\u0438\u043A\u0430\u043C\u0438 \u0434\u0430\u043D\u043D\u044B\u0445 \u0447\u0435\u0440\u0435\u0437 ODBC +AssignmentRule.ObjectType.ExternalDataSourceXMLAService = \u0421\u0435\u0440\u0432\u0438\u0441 \u0440\u0430\u0431\u043E\u0442\u044B \u0441 \u0432\u043D\u0435\u0448\u043D\u0438\u043C\u0438 \u0438\u0441\u0442\u043E\u0447\u043D\u0438\u043A\u0430\u043C\u0438 \u0434\u0430\u043D\u043D\u044B\u0445 \u0447\u0435\u0440\u0435\u0437 XMLA +AssignmentRule.ObjectType.ExternalSessionManagerService = \u0421\u0435\u0440\u0432\u0438\u0441 \u0432\u043D\u0435\u0448\u043D\u0435\u0433\u043E \u0443\u043F\u0440\u0430\u0432\u043B\u0435\u043D\u0438\u044F \u0441\u0435\u0430\u043D\u0441\u0430\u043C\u0438 +AssignmentRule.ObjectType.ForAll = \u0414\u043B\u044F \u0432\u0441\u0435\u0445 +AssignmentRule.ObjectType.FulltextSearchService = \u0421\u0435\u0440\u0432\u0438\u0441 \u043F\u043E\u043B\u043D\u043E\u0442\u0435\u043A\u0441\u0442\u043E\u0432\u043E\u0433\u043E \u043F\u043E\u0438\u0441\u043A\u0430 +AssignmentRule.ObjectType.GetSessionsService = \u0421\u0435\u0440\u0432\u0438\u0441 \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u0438\u044F \u0441\u043F\u0438\u0441\u043A\u0430 \u0441\u0435\u0430\u043D\u0441\u043E\u0432 +AssignmentRule.ObjectType.IntegrationDataService = \u0421\u0435\u0440\u0432\u0438\u0441 \u0438\u043D\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043E\u043D\u043D\u044B\u0445 \u0434\u0430\u043D\u043D\u044B\u0445 +AssignmentRule.ObjectType.JobService = \u0421\u0435\u0440\u0432\u0438\u0441 \u0437\u0430\u0434\u0430\u043D\u0438\u0439 +AssignmentRule.ObjectType.LicenseService = \u0421\u0435\u0440\u0432\u0438\u0441 \u043B\u0438\u0446\u0435\u043D\u0437\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u044F +AssignmentRule.ObjectType.NumerationService = \u0421\u0435\u0440\u0432\u0438\u0441 \u043D\u0443\u043C\u0435\u0440\u0430\u0446\u0438\u0438 +AssignmentRule.ObjectType.OpenID2ProviderContextService = \u0421\u0435\u0440\u0432\u0438\u0441 \u043F\u0440\u043E\u0432\u0430\u0439\u0434\u0435\u0440\u0430 OpenID2 +AssignmentRule.ObjectType.SessionDataService = \u0421\u0435\u0440\u0432\u0438\u0441 \u0441\u0435\u0430\u043D\u0441\u043E\u0432\u044B\u0445 \u0434\u0430\u043D\u043D\u044B\u0445 +AssignmentRule.ObjectType.SessionReuseService = \u0421\u0435\u0440\u0432\u0438\u0441 \u043F\u043E\u0432\u0442\u043E\u0440\u043D\u043E\u0433\u043E \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u043D\u0438\u044F \u0441\u0435\u0430\u043D\u0441\u043E\u0432 +AssignmentRule.ObjectType.SettingsService = \u0421\u0435\u0440\u0432\u0438\u0441 \u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u0442\u0435\u043B\u044C\u0441\u043A\u0438\u0445 \u043D\u0430\u0441\u0442\u0440\u043E\u0435\u043A +AssignmentRule.ObjectType.TimestampService = \u0421\u0435\u0440\u0432\u0438\u0441 \u0432\u0440\u0435\u043C\u0435\u043D\u0438 +AssignmentRule.ObjectType.TransactionLockService = \u0421\u0435\u0440\u0432\u0438\u0441 \u0442\u0440\u0430\u043D\u0437\u0430\u043A\u0446\u0438\u043E\u043D\u043D\u044B\u0445 \u0431\u043B\u043E\u043A\u0438\u0440\u043E\u0432\u043E\u043A +AssignmentRule.Priority = \u041F\u0440\u0438\u043E\u0440\u0438\u0442\u0435\u0442 +AssignmentRule.RuleType = \u0422\u0438\u043F \u0442\u0440\u0435\u0431\u043E\u0432\u0430\u043D\u0438\u044F +AssignmentRule.RuleType.Assign = \u041D\u0430\u0437\u043D\u0430\u0447\u0430\u0442\u044C +AssignmentRule.RuleType.Auto = \u0410\u0432\u0442\u043E +AssignmentRule.RuleType.DoNotAssign = \u041D\u0435 \u043D\u0430\u0437\u043D\u0430\u0447\u0430\u0442\u044C +AssignmentRule.TitleEditRule = \u0422\u0440\u0435\u0431\u043E\u0432\u0430\u043D\u0438\u0435 \u043D\u0430\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u044F \u0444\u0443\u043D\u043A\u0446\u0438\u043E\u043D\u0430\u043B\u044C\u043D\u043E\u0441\u0442\u0438 +AssignmentRule.TitleNewRule = \u041D\u043E\u0432\u043E\u0435 \u0442\u0440\u0435\u0431\u043E\u0432\u0430\u043D\u0438\u0435 \u043D\u0430\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u044F \u0444\u0443\u043D\u043A\u0446\u0438\u043E\u043D\u0430\u043B\u044C\u043D\u043E\u0441\u0442\u0438 + ConnectionInfo.ConnectedAt = \u041F\u043E\u0434\u043A\u043B\u044E\u0447\u0435\u043D\u043E \u0441 ConnectionInfo.Connection = \u0421\u043E\u0435\u0434\u0438\u043D\u0435\u043D\u0438\u0435 ConnectionInfo.Hostname = \u0418\u043C\u044F \u0445\u043E\u0441\u0442\u0430 diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/AssignmentRuleDialog.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/AssignmentRuleDialog.java new file mode 100644 index 0000000..570f068 --- /dev/null +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/AssignmentRuleDialog.java @@ -0,0 +1,264 @@ +package ru.yanygin.clusterAdminLibraryUI; + +import com._1c.v8.ibis.admin.AssignmentRuleInfo; +import com._1c.v8.ibis.admin.IAssignmentRuleInfo; +import java.util.UUID; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.layout.RowLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Spinner; +import ru.yanygin.clusterAdminLibrary.AssignmentRuleContentProvider; +import ru.yanygin.clusterAdminLibrary.AssignmentRuleLabelProvider; +import ru.yanygin.clusterAdminLibrary.Messages; +import ru.yanygin.clusterAdminLibrary.Server; + +/** Диалог редактирования ТНФ. */ +public class AssignmentRuleDialog extends Dialog { + + private Server server; + private UUID clusterId; + private UUID wsId; + private IAssignmentRuleInfo ruleInfo; + + private Combo txtObjectType; + private Combo txtInfoBaseName; + private Combo txtApplicationExt; + + private Button btnRuleTypeAuto; + private Button btnRuleTypeAssign; + private Button btnRuleTypeDoNotAssign; + private Spinner spinnerPriority; + private Spinner spinnerNumber; + + /** + * Создание диалога редактирования ТНФ. + * + * @param parentShell - parent shell + * @param server - Сервер + * @param clusterId - ID кластера + * @param ruleInfo - IAssignmentRuleInfo правило ТНФ + * @wbp.parser.constructor + */ + public AssignmentRuleDialog( + Shell parentShell, Server server, UUID clusterId, UUID wsId, IAssignmentRuleInfo ruleInfo) { + super(parentShell); + setShellStyle(SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); + + this.server = server; + this.clusterId = clusterId; + this.wsId = wsId; + this.ruleInfo = ruleInfo; + } + + @Override + protected void configureShell(Shell newShell) { + newShell.setMinimumSize(new Point(300, 39)); + super.configureShell(newShell); + + if (ruleInfo == null) { + newShell.setText(Strings.TITLE_NEW_RULE); + } else { + newShell.setText(Strings.TITLE_EDIT_RULE); + } + } + + /** + * Create contents of the dialog. + * + * @param parent - parent composite + */ + @Override + protected Control createDialogArea(Composite parent) { + + Composite container = (Composite) super.createDialogArea(parent); + GridLayout gridLayout = (GridLayout) container.getLayout(); + gridLayout.numColumns = 2; + + Label lblObjectType = new Label(container, SWT.NONE); + lblObjectType.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); + lblObjectType.setText(Strings.OBJECT_TYPE); + + txtObjectType = new Combo(container, SWT.READ_ONLY); + txtObjectType.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); + + Label lblRuleType = new Label(container, SWT.NONE); + lblRuleType.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); + lblRuleType.setText(Strings.RULE_TYPE); + + Composite composite = new Composite(container, SWT.NONE); + composite.setLayout(new RowLayout(SWT.HORIZONTAL)); + + btnRuleTypeAuto = new Button(composite, SWT.RADIO); + btnRuleTypeAuto.setText(AssignmentRuleLabelProvider.RULE_TYPE_AUTO); + + btnRuleTypeAssign = new Button(composite, SWT.RADIO); + btnRuleTypeAssign.setText(AssignmentRuleLabelProvider.RULE_TYPE_ASSIGN); + + btnRuleTypeDoNotAssign = new Button(composite, SWT.RADIO); + btnRuleTypeDoNotAssign.setText(AssignmentRuleLabelProvider.RULE_TYPE_DO_NOT_ASSIGN); + + Label lblInfoBaseName = new Label(container, SWT.NONE); + lblInfoBaseName.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); + lblInfoBaseName.setText(Strings.INFOBASE_NAME); + + txtInfoBaseName = new Combo(container, SWT.BORDER); + txtInfoBaseName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); + + Label lblApplicationExt = new Label(container, SWT.NONE); + lblApplicationExt.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); + lblApplicationExt.setText(Strings.APPLICATION_EXT); + + txtApplicationExt = new Combo(container, SWT.BORDER); + GridData gdTxtApplicationExt = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1); + gdTxtApplicationExt.widthHint = 100; + txtApplicationExt.setLayoutData(gdTxtApplicationExt); + + Label lblNumber = new Label(container, SWT.NONE); + lblNumber.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); + lblNumber.setText(Strings.NUMBER); + + spinnerNumber = new Spinner(container, SWT.BORDER); + spinnerNumber.setMinimum(1); + spinnerNumber.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); + + Label lblPriority = new Label(container, SWT.NONE); + lblPriority.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); + lblPriority.setText(Strings.PRIORITY); + + spinnerPriority = new Spinner(container, SWT.BORDER); + spinnerPriority.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); + + fillComboFields(); + initValueFields(); + + parent.pack(); + + return container; + } + + private void fillComboFields() { + // Заполнение выпадающих списков значениями для выбора + AssignmentRuleLabelProvider.getObjectTypes() + .forEach( + (k, v) -> { + txtObjectType.add(v); + txtObjectType.setData(v, k); + }); + + server.getInfoBasesShort(clusterId).forEach(ib -> txtInfoBaseName.add(ib.getName())); + + String[] appExtValues = AssignmentRuleLabelProvider.getApplicationExtValues(); + for (String v : appExtValues) { + txtApplicationExt.add(v); + txtApplicationExt.setData(v); + } + } + + private void initValueFields() { + if (ruleInfo != null) { + this.txtObjectType.setText( + AssignmentRuleLabelProvider.getObjectType(ruleInfo.getObjectType())); + + final int ruleType = ruleInfo.getRuleType(); + this.btnRuleTypeAuto.setSelection(ruleType == 1); + this.btnRuleTypeAssign.setSelection(ruleType == 2); + this.btnRuleTypeDoNotAssign.setSelection(ruleType == 0); + + this.txtInfoBaseName.setText(ruleInfo.getInfoBaseName()); + this.txtApplicationExt.setText(ruleInfo.getApplicationExt()); + + this.spinnerPriority.setSelection(ruleInfo.getPriority()); + this.spinnerNumber.setSelection(AssignmentRuleContentProvider.getRuleNumber(ruleInfo)); + } else { + this.txtObjectType.setText(AssignmentRuleLabelProvider.getObjectType("")); + this.btnRuleTypeAuto.setSelection(true); + } + } + + private boolean regRule() { + + if (ruleInfo == null) { + ruleInfo = new AssignmentRuleInfo(); + } + + String objectType = (String) txtObjectType.getData(txtObjectType.getText()); + ruleInfo.setObjectType(objectType); + + final int ruleType; + if (btnRuleTypeAuto.getSelection()) { + ruleType = 1; + } else if (btnRuleTypeAssign.getSelection()) { + ruleType = 2; + } else { + ruleType = 0; + } + ruleInfo.setRuleType(ruleType); + + ruleInfo.setInfoBaseName(txtInfoBaseName.getText()); + ruleInfo.setApplicationExt(txtApplicationExt.getText()); + + ruleInfo.setPriority(spinnerPriority.getSelection()); + + return server.regAssignmentRule(clusterId, wsId, ruleInfo, spinnerNumber.getSelection() - 1); + } + + /** + * Получает итоговую информацию о правиле ТНФ. + * + * @return IAssignmentRuleInfo правило ТНФ + */ + public IAssignmentRuleInfo getRuleInfo() { + return ruleInfo; + } + + /** + * Create contents of the button bar. + * + * @param parent - parent composite + */ + @Override + protected void createButtonsForButtonBar(Composite parent) { + Button button = + createButton(parent, IDialogConstants.FINISH_ID, IDialogConstants.OK_LABEL, true); + button.addSelectionListener( + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + if (regRule()) { + close(); + } + } + }); + + createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); + } + + private static class Strings { + + static final String TITLE_EDIT_RULE = getString("TitleEditRule"); + static final String TITLE_NEW_RULE = getString("TitleNewRule"); + + static final String NUMBER = getString("Number"); + static final String OBJECT_TYPE = getString("ObjectType"); + static final String RULE_TYPE = getString("RuleType"); + static final String INFOBASE_NAME = getString("InfoBaseName"); + static final String APPLICATION_EXT = getString("ApplicationExt"); + static final String PRIORITY = getString("Priority"); + + static String getString(String key) { + return Messages.getString("AssignmentRule." + key); // $NON-NLS-1$ + } + } +} diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java index 8e03274..318b51b 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java @@ -1,5 +1,6 @@ package ru.yanygin.clusterAdminLibraryUI; +import com._1c.v8.ibis.admin.IAssignmentRuleInfo; import com._1c.v8.ibis.admin.IClusterInfo; import com._1c.v8.ibis.admin.IInfoBaseInfo; import com._1c.v8.ibis.admin.IWorkingProcessInfo; @@ -22,11 +23,17 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.TableViewerColumn; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.ViewerComparator; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.SashForm; import org.eclipse.swt.dnd.Clipboard; import org.eclipse.swt.dnd.TextTransfer; import org.eclipse.swt.dnd.Transfer; +import org.eclipse.swt.events.FocusAdapter; +import org.eclipse.swt.events.FocusEvent; import org.eclipse.swt.events.KeyAdapter; import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.MouseAdapter; @@ -41,6 +48,7 @@ import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; @@ -60,6 +68,8 @@ import org.eclipse.swt.widgets.Widget; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import ru.yanygin.clusterAdminLibrary.AssignmentRuleContentProvider; +import ru.yanygin.clusterAdminLibrary.AssignmentRuleLabelProvider; import ru.yanygin.clusterAdminLibrary.BackgroundTask; import ru.yanygin.clusterAdminLibrary.BaseInfoExtended; import ru.yanygin.clusterAdminLibrary.ClusterProvider; @@ -109,6 +119,7 @@ public class ViewerArea extends Composite { Image addIcon16; Image editIcon16; Image deleteIcon16; + Image viewIcon16; Image updateIcon16; Image addIcon24; @@ -133,13 +144,13 @@ public class ViewerArea extends Composite { Menu infobaseNodeMenu; Menu infobaseMenu; - TabItem tabSessions; - TabItem tabConnections; - TabItem tabLocks; - TabItem tabWorkingProcesses; - TabItem tabWorkingServers; - TabItem currentTab; - + Table tableSessions; + Table tableConnections; + Table tableLocks; + Table tableWorkingProcesses; + Table tableWorkingServers; + Table currentTable; + Table tableTasks; TabItem tabTask; Text tableTaskLog; @@ -147,6 +158,7 @@ public class ViewerArea extends Composite { ToolItem addToolbarItem; ToolItem editToolbarItem; ToolItem deleteToolbarItem; + TableViewer tnfTableViewer; TreeColumn columnServer; @@ -178,10 +190,7 @@ public enum TreeItemType { Map toolbarCreateListeners = new EnumMap<>(TreeItemType.class); Map toolbarEditListeners = new EnumMap<>(TreeItemType.class); Map toolbarDeleteListeners = new EnumMap<>(TreeItemType.class); - Map tableContextItemEdit = new HashMap<>(); - Map tableContextItemDelete = new HashMap<>(); Map serversTreeContextMenus = new EnumMap<>(TreeItemType.class); - Map> linksTablesToExtendedClass = new HashMap<>(); // List userScripts = new ArrayList<>(); Timer taskTimer; @@ -243,35 +252,59 @@ private void initServersTab(TabFolder mainTabFolder) { initServersTree(sashServers); - TabFolder tabFolderLists = new TabFolder(sashServers, SWT.NONE); - - tabFolderLists.addSelectionListener( + TabFolder tabFolder = new TabFolder(sashServers, SWT.NONE); + tabFolder.addSelectionListener( new SelectionAdapter() { - @Override public void widgetSelected(SelectionEvent evt) { - currentTab = tabFolderLists.getSelection()[0]; + TabItem currentTab = tabFolder.getSelection()[0]; + currentTable = getTable(currentTab); refreshCurrentList(); } }); - tabSessions = initListTable(tabFolderLists, SessionInfoExtended.class, true); - tabConnections = initListTable(tabFolderLists, ConnectionInfoExtended.class, false); - tabLocks = initListTable(tabFolderLists, LockInfoExtended.class, false); - tabWorkingProcesses = initListTable(tabFolderLists, WorkingProcessInfoExtended.class, false); - tabWorkingServers = initListTable(tabFolderLists, WorkingServerInfoExtended.class, false); - //////////////////////////////////////////// + // Таблица сеансов + TabItem tabSessions = new TabItem(tabFolder, SWT.NONE); + tableSessions = initTable(tabFolder, SessionInfoExtended.class); + tabSessions.setControl(tableSessions); + BaseInfoExtended.linkTabItem(SessionInfoExtended.class, tabSessions); + tableSessions.setFocus(); + + // Таблица соединений + TabItem tabConnections = new TabItem(tabFolder, SWT.NONE); + tableConnections = initTable(tabFolder, ConnectionInfoExtended.class); + tabConnections.setControl(tableConnections); + BaseInfoExtended.linkTabItem(ConnectionInfoExtended.class, tabConnections); + + // Таблица блокировок + TabItem tabLocks = new TabItem(tabFolder, SWT.NONE); + tableLocks = initTable(tabFolder, LockInfoExtended.class); + tabLocks.setControl(tableLocks); + BaseInfoExtended.linkTabItem(LockInfoExtended.class, tabLocks); + + // Таблица рабочих процессов + TabItem tabWorkingProcesses = new TabItem(tabFolder, SWT.NONE); + tableWorkingProcesses = initTable(tabFolder, WorkingProcessInfoExtended.class); + tabWorkingProcesses.setControl(tableWorkingProcesses); + BaseInfoExtended.linkTabItem(WorkingProcessInfoExtended.class, tabWorkingProcesses); - initMaps(); + // Таблица рабочих серверов + TabItem tabWorkingServers = new TabItem(tabFolder, SWT.NONE); - initTableContextMenu(tabSessions, true, false, true, true); - initTableContextMenu(tabConnections, true, false, false, true); - initTableContextMenu(tabLocks, true, false, false, false); - initTableContextMenu(tabWorkingProcesses, true, false, false, false); - initTableContextMenu(tabWorkingServers, true, true, true, true); - ////////////////////////////////////////////// + SashForm sashWorkingServers = new SashForm(tabFolder, SWT.VERTICAL); - clearTabs(); + tableWorkingServers = initTable(sashWorkingServers, WorkingServerInfoExtended.class); + + initAssRuleTable(sashWorkingServers); + BaseInfoExtended.linkTabItem(WorkingServerInfoExtended.class, tabWorkingServers); + + tabWorkingServers.setControl(sashWorkingServers); + sashWorkingServers.setWeights(5, 10); // Пропорции областей + + initTableContextMenu(tnfTableViewer.getTable(), IAssignmentRuleInfo.class); + + initToolbarListeners(); + clearTabs(false); // TODO тут вроде не нужно BaseInfoExtended.resetTabsTextCount(); setEnableToolbarItems(); @@ -336,6 +369,7 @@ private void initIcon() { editIcon16 = Helper.getImage("edit_16.png"); // $NON-NLS-1$ addIcon16 = Helper.getImage("add_16.png"); // $NON-NLS-1$ deleteIcon16 = Helper.getImage("delete_16.png"); // $NON-NLS-1$ + viewIcon16 = Helper.getImage("view_16.png"); // $NON-NLS-1$ updateIcon16 = Helper.getImage("update_16.png"); // $NON-NLS-1$ editIcon24 = Helper.getImage("edit_24.png"); // $NON-NLS-1$ @@ -361,7 +395,7 @@ private void initToolbar(ToolBar toolBar) { toolBar.setSize(-1, 48); addToolbarItem = - addItemInToolbar(toolBar, Strings.CONTEXT_MENU_CREATE, addIcon24, toolbarListener); + addItemInToolbar(toolBar, Strings.CONTEXT_MENU_ADD, addIcon24, toolbarListener); editToolbarItem = addItemInToolbar(toolBar, Strings.CONTEXT_MENU_EDIT, editIcon24, toolbarListener); deleteToolbarItem = @@ -431,21 +465,27 @@ public void handleEvent(Event event) { private void initServersTreeContextMenu() { - // Server Menu - serverMenu = new Menu(serversTree); - initServerMenu(); initClusterMenu(); initWorkingServerMenu(); initInfobaseNodeMenu(); initInfobaseMenu(); + // соответствие контекстных меню дерева серверов + serversTreeContextMenus.put(TreeItemType.SERVER, serverMenu); + serversTreeContextMenus.put(TreeItemType.CLUSTER, clusterMenu); + serversTreeContextMenus.put(TreeItemType.INFOBASE_NODE, infobaseNodeMenu); + serversTreeContextMenus.put(TreeItemType.INFOBASE, infobaseMenu); + serversTreeContextMenus.put(TreeItemType.WORKINGSERVER, workingServerMenu); + // set active menu serversTree.setMenu(serverMenu); } private void initServerMenu() { + serverMenu = new Menu(serversTree); + // установка активности элементов контекстного меню serverMenu.addListener(SWT.Show, setActiveConnectActionListener); @@ -478,8 +518,8 @@ private void initServerMenu() { addMenuSeparator(serverMenu); - addItemInMenu(serverMenu, Strings.CONTEXT_MENU_ADD_SERVER, addIcon16, addServerListener); - addItemInMenu(serverMenu, Strings.CONTEXT_MENU_EDIT_SERVER, editIcon16, editServerListener); + addItemInMenu(serverMenu, Strings.CONTEXT_MENU_ADD, addIcon16, addServerListener); + addItemInMenu(serverMenu, Strings.CONTEXT_MENU_EDIT, editIcon16, editServerListener); addItemInMenu(serverMenu, Strings.CONTEXT_MENU_UPDATE, updateIcon16, updateServerListener); addMenuSeparator(serverMenu); @@ -491,8 +531,7 @@ private void initServerMenu() { addMenuSeparator(serverMenu); - addItemInMenu( - serverMenu, Strings.CONTEXT_MENU_REMOVE_SERVER, deleteIcon16, deleteServerListener); + addItemInMenu(serverMenu, Strings.CONTEXT_MENU_DELETE, deleteIcon16, deleteServerListener); // TODO это для отладки без запуска сервера - удалить new UserScriptRunner(serverMenu); @@ -509,6 +548,12 @@ private void initClusterMenu() { addMenuSeparator(clusterMenu); addItemInMenu( clusterMenu, Strings.CONTEXT_MENU_DELETE_CLUSTER, deleteIcon16, deleteClusterListener); + + addMenuSeparator(clusterMenu); + addItemInMenu( + clusterMenu, Strings.CONTEXT_MENU_APPLY_PARTIAL_RULE, null, applyAssignmentRuleListener, 0); + addItemInMenu( + clusterMenu, Strings.CONTEXT_MENU_APPLY_FULL_RULE, null, applyAssignmentRuleListener, 1); } private void initWorkingServerMenu() { @@ -614,28 +659,35 @@ private void initInfobaseMenu() { new UserScriptRunner(infobaseMenu); } - private TabItem initListTable( - TabFolder tabFolder, Class clazz, boolean checkable) { - - TabItem newTab = new TabItem(tabFolder, SWT.NONE); + private Table initTable(Composite composite, Class clazz) { int style = - checkable + clazz == SessionInfoExtended.class ? SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.CHECK : SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI; - Table table = new Table(tabFolder, style); - newTab.setControl(table); + Table table = new Table(composite, style); + // tabItem.setControl(table); + table.setData(clazz); table.setHeaderVisible(true); table.setLinesVisible(true); table.addKeyListener(tableKeyPressedListener); table.addMouseListener(tablesMouseClickListener); - if (checkable) { + if (clazz == SessionInfoExtended.class) { table.addListener(SWT.Selection, switchWatchingListener); } + table.addFocusListener( + new FocusAdapter() { + @Override + public void focusGained(FocusEvent e) { + currentTable = table; + // currentTable = (Table) e.widget; + LOGGER.debug("currentTable = {}", currentTable.getData().toString()); + } + }); - ColumnProperties columnProperties = getColumnProperties(clazz); + final ColumnProperties columnProperties = getColumnProperties(clazz); String[] columnNameList = columnProperties.getColumnsDescription(); for (String columnName : columnNameList) { @@ -647,43 +699,243 @@ private TabItem initListTable( table.setColumnOrder(columnOrder); } - BaseInfoExtended.linkTabItem(clazz, newTab); - return newTab; + if (clazz != IAssignmentRuleInfo.class) { + initTableContextMenu(table, clazz); + } + + // BaseInfoExtended.linkTabItem(clazz, tabItem); + return table; } - private void initTableContextMenu( - TabItem tab, boolean updatable, boolean creatable, boolean editable, boolean killable) { - Table table = getTable(tab); - Menu tableMenu = new Menu(table); - table.setMenu(tableMenu); + private void initAssRuleTable(SashForm sashWorkingServers) { // таблица с ТНФ + tnfTableViewer = + new TableViewer(sashWorkingServers, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI); + tnfTableViewer.setContentProvider(new AssignmentRuleContentProvider()); + + tnfTableViewer.setComparator( + new ViewerComparator() { + public int compare(Viewer viewer, Object e1, Object e2) { + + Table table = ((TableViewer) viewer).getTable(); + TableColumn sortColumn = table.getSortColumn(); + if (sortColumn == null) { + return 0; + } + int numColumn = (int) sortColumn.getData(); + TableViewerColumn tableViewerColumn = + (TableViewerColumn) sortColumn.getData("org.eclipse.jface.columnViewer"); + //TableViewerColumn.class.toString() + + AssignmentRuleLabelProvider labelProvider = + (AssignmentRuleLabelProvider) + tableViewerColumn.getViewer().getLabelProvider(numColumn); + + final Object first; + final Object second; + switch (table.getSortDirection()) { + case SWT.UP: + first = labelProvider.getValue(e1); + second = labelProvider.getValue(e2); + break; + + case SWT.DOWN: + first = labelProvider.getValue(e2); + second = labelProvider.getValue(e1); + break; + + case SWT.NONE: + default: + return 0; + } + if (first instanceof Integer) { + return Integer.compare((int) first, (int) second); + } + if (first instanceof String) { + return ((String) first).compareTo((String) second); + } + return 0; + } + }); + + Table table = tnfTableViewer.getTable(); + + table.setData(IAssignmentRuleInfo.class); + table.setHeaderVisible(true); + table.setLinesVisible(true); + + // tableTnf.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); + table.addKeyListener(tableKeyPressedListener); + table.addMouseListener(tablesMouseClickListener); + table.addFocusListener( + new FocusAdapter() { + @Override + public void focusGained(FocusEvent e) { + currentTable = table; + // currentTable = (Table) e.widget; + LOGGER.debug("currentTable = {}", currentTable.getData().toString()); + } + }); - if (updatable) { - addItemInMenu(tableMenu, Strings.CONTEXT_MENU_UPDATE_F5, updateIcon16, refreshTablesListener); + final ColumnProperties columnProperties = getColumnProperties(IAssignmentRuleInfo.class); + + String[] columnNameList = columnProperties.getColumnsName(); // TODO + String[] columnDescList = columnProperties.getColumnsDescription(); + + for (int i = 0; i < columnNameList.length; i++) { + addTableViewerColumn(tnfTableViewer, columnNameList[i], columnDescList[i], columnProperties); } - if (creatable) { - addItemInMenu( - tableMenu, - Strings.CONTEXT_MENU_CREATE_WORKING_SERVER, - addIcon16, - createWorkingServerListener); + int[] columnOrder = columnProperties.getOrder(); + if (columnOrder != null && table.getColumnCount() == columnOrder.length) { + table.setColumnOrder(columnOrder); } - if (editable) { - String title = tableContextItemEdit.get(tab); - addItemInMenu(tableMenu, title, editIcon16, editItemInTablesListener); + } + + private void initTableContextMenu(Table table, Class clazz) { + + // Table table = getTable(tab); + + Menu tableMenu = new Menu(table); + table.setMenu(tableMenu); + + // установка активности элементов контекстного меню + + Listener setActiveContextMenuListener = + new Listener() { + @Override + public void handleEvent(Event event) { + + TableItem[] items = currentTable.getSelection(); + boolean selected = (items.length != 0); + + MenuItem[] menuItems = ((Menu) event.widget).getItems(); + + for (MenuItem menuItem : menuItems) { + if (!menuItem.getText().equals(Strings.CONTEXT_MENU_UPDATE_F5) + && !menuItem.getText().equals(Strings.CONTEXT_MENU_ADD_HOTKEY)) { + menuItem.setEnabled(selected); + } + } + } + }; + tableMenu.addListener(SWT.Show, setActiveContextMenuListener); + + final SelectionAdapter refreshListener = + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + currentTable = table; + refreshCurrentList(); + } + }; + addItemInMenu(tableMenu, Strings.CONTEXT_MENU_UPDATE_F5, updateIcon16, refreshListener); + + addItemInMenu(tableMenu, Strings.CONTEXT_MENU_COPY_CELL, null, copyCellValueInTablesListener); + + // у соединений еще есть прерывание серверного вызова (с какой то версии платформы) + if (clazz == WorkingServerInfoExtended.class || clazz == IAssignmentRuleInfo.class) { + + final SelectionAdapter addListener = + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + addItemInTable(table); + } + }; + final SelectionAdapter editListener = + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + TableItem[] items = table.getSelection(); + if (items.length == 0) { + return; + } + editItemInTable(items[0]); + } + }; + final SelectionAdapter deleteListener = + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + TableItem[] items = table.getSelection(); + if (items.length == 0) { + return; + } + deleteItemsFromTable(items); + } + }; + + addMenuSeparator(tableMenu); + addItemInMenu(tableMenu, Strings.CONTEXT_MENU_ADD_HOTKEY, addIcon16, addListener); + addItemInMenu(tableMenu, Strings.CONTEXT_MENU_EDIT_HOTKEY, editIcon16, editListener); + addItemInMenu(tableMenu, Strings.CONTEXT_MENU_DELETE_HOTKEY, deleteIcon16, deleteListener); + + } else if (clazz == SessionInfoExtended.class) { + // просмотр + final SelectionAdapter viewListener = + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + TableItem[] items = table.getSelection(); + if (items.length == 0) { + return; + } + viewItemInTable(items[0]); + } + }; + // TODO для сеансов есть форма, для соединений и раб.процессов - ее нет + // попробовать сделать генерируюмую форму со списком полей + addMenuSeparator(tableMenu); + addItemInMenu(tableMenu, Strings.CONTEXT_MENU_VIEW_HOTKEY, viewIcon16, viewListener); } - addItemInMenu( - tableMenu, Strings.CONTEXT_MENU_COPY_CELL_VALUE, null, copyCellValueInTablesListener); + if (clazz == SessionInfoExtended.class || clazz == ConnectionInfoExtended.class) { + final SelectionAdapter deleteListener = + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + TableItem[] items = table.getSelection(); + if (items.length == 0) { + return; + } + deleteItemsFromTable(items); + } + }; + addItemInMenu(tableMenu, Strings.CONTEXT_MENU_DELETE_HOTKEY, deleteIcon16, deleteListener); + } - if (killable) { - String title = tableContextItemDelete.get(tab); - addItemInMenu(tableMenu, title, deleteIcon16, deleteItemInTablesListener); + if (clazz == IAssignmentRuleInfo.class) { + // пункты увеличения и уменьшения порядка правила ТНФ + final SelectionAdapter increaseListener = + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + TableItem[] items = table.getSelection(); + if (items.length == 0) { + return; + } + changeAssignmentRuleNumber(items[0], true); + } + }; + final SelectionAdapter reduseListener = + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + TableItem[] items = table.getSelection(); + if (items.length == 0) { + return; + } + changeAssignmentRuleNumber(items[0], false); + } + }; + addMenuSeparator(tableMenu); + addItemInMenu(tableMenu, Strings.CONTEXT_MENU_MOVE_UP, moveUpIcon, increaseListener); + addItemInMenu(tableMenu, Strings.CONTEXT_MENU_MOVE_DOWN, moveDownIcon, reduseListener); } } - private void initMaps() { + private void initToolbarListeners() { // обработчики кнопки тулбара "Добавить" toolbarCreateListeners.put(TreeItemType.SERVER, addServerListener); @@ -704,26 +956,6 @@ private void initMaps() { toolbarDeleteListeners.put(TreeItemType.CLUSTER, deleteClusterListener); toolbarDeleteListeners.put(TreeItemType.INFOBASE, deleteInfobaseListener); - // контекстные меню дерева серверов - serversTreeContextMenus.put(TreeItemType.SERVER, serverMenu); - serversTreeContextMenus.put(TreeItemType.CLUSTER, clusterMenu); - serversTreeContextMenus.put(TreeItemType.INFOBASE_NODE, infobaseNodeMenu); - serversTreeContextMenus.put(TreeItemType.INFOBASE, infobaseMenu); - serversTreeContextMenus.put(TreeItemType.WORKINGSERVER, workingServerMenu); - - // тексты пунктов контекстного меню списков - tableContextItemEdit.put(tabSessions, Strings.CONTEXT_MENU_VIEW_SESSION_F2); - tableContextItemEdit.put(tabWorkingServers, Strings.CONTEXT_MENU_EDIT_WORKING_SERVER_F2); - tableContextItemDelete.put(tabSessions, Strings.CONTEXT_MENU_KILL_SESSION_DEL); - tableContextItemDelete.put(tabConnections, Strings.CONTEXT_MENU_KILL_CONNECTION_DEL); - tableContextItemDelete.put(tabWorkingServers, Strings.CONTEXT_MENU_DELETE_WORKING_SERVER_DEL); - - // соответствие таблиц списков - linksTablesToExtendedClass.put(tabSessions, SessionInfoExtended.class); - linksTablesToExtendedClass.put(tabConnections, ConnectionInfoExtended.class); - linksTablesToExtendedClass.put(tabLocks, LockInfoExtended.class); - linksTablesToExtendedClass.put(tabWorkingServers, WorkingServerInfoExtended.class); - linksTablesToExtendedClass.put(tabWorkingProcesses, WorkingProcessInfoExtended.class); } private ToolItem addItemInToolbar( @@ -979,14 +1211,19 @@ private void setItemProperties( private void addTableColumn(Table table, String text, ColumnProperties columnProperties) { - final int[] columnWidth = columnProperties.getWidth(); - final boolean[] columnVisible = columnProperties.getVisible(); - var newColumn = new TableColumn(table, SWT.NONE); newColumn.setText(text); newColumn.setMoveable(true); newColumn.setAlignment(SWT.RIGHT); + if (columnProperties == null) { + newColumn.setWidth(100); + return; + } + + final int[] columnWidth = columnProperties.getWidth(); + final boolean[] columnVisible = columnProperties.getVisible(); + int numOfColumn = table.getColumnCount() - 1; newColumn.setData(numOfColumn); if (numOfColumn == columnProperties.getSortColumn()) { @@ -1399,7 +1636,6 @@ private void updateNode( private void refreshCurrentList() { - Table currentTable = getCurrentTable(); if (currentTable == null) { return; } @@ -1414,37 +1650,46 @@ private void refreshCurrentList() { UUID workingProcessId = getCurrentWorkingProcessId(); // TreeItemType treeItemType = getTreeItemType(currentTreeItem); // TODO currentHighlightingType - clearTabs(); + final Class clazz = (Class) currentTable.getData(); + clearTabs(clazz == IAssignmentRuleInfo.class); List list = null; + + // TODO getSessionsExtendedInfo, getConnectionsExtendedInfo и др. // заменить на одну?, определяемую через map - if (currentTab.equals(tabSessions)) { + if (clazz == SessionInfoExtended.class) { list = server.getSessionsExtendedInfo( currentHighlightingType, clusterId, workingProcessId, infobaseId); - } else if (currentTab.equals(tabConnections)) { + } else if (clazz == ConnectionInfoExtended.class) { list = server.getConnectionsExtendedInfo( currentHighlightingType, clusterId, workingProcessId, infobaseId); - } else if (currentTab.equals(tabLocks)) { + } else if (clazz == LockInfoExtended.class) { list = server.getLocksExtendedInfo(currentHighlightingType, clusterId, infobaseId); - } else if (currentTab.equals(tabWorkingProcesses)) { + } else if (clazz == WorkingProcessInfoExtended.class) { list = server.getWorkingProcessesExtendedInfo( currentHighlightingType, clusterId, workingProcessId); - } else if (currentTab.equals(tabWorkingServers)) { + } else if (clazz == WorkingServerInfoExtended.class) { list = server.getWorkingServersExtendedInfo(currentHighlightingType, clusterId); + // очистка таблицы с ТНФ + tnfTableViewer.getTable().clearAll(); + + } else if (clazz == IAssignmentRuleInfo.class) { + fillAssignmentRulesTable(); + return; } else { return; } - BaseInfoExtended.updateTabText(linksTablesToExtendedClass.get(currentTab), list.size()); + BaseInfoExtended.updateTabText((Class) clazz, list.size()); list.forEach(item -> item.addToTable(currentTable)); } @@ -1459,15 +1704,17 @@ private void setActiveContextMenuInTree(TreeItem treeItem) { serversTree.setMenu(serversTreeContextMenus.get(currentContextMenuItem)); } - private void clearTabs() { + private void clearTabs(boolean isAssignmentRule) { // BaseInfoExtended.resetTabsTextCount(); - getTable(tabSessions).removeAll(); - getTable(tabConnections).removeAll(); - getTable(tabLocks).removeAll(); - getTable(tabWorkingProcesses).removeAll(); - getTable(tabWorkingServers).removeAll(); + tableSessions.removeAll(); + tableConnections.removeAll(); + tableLocks.removeAll(); + tableWorkingProcesses.removeAll(); + if (!isAssignmentRule) { + tableWorkingServers.removeAll(); + } } private void clickItemInServerTree(int mouseButton) { @@ -1498,22 +1745,25 @@ private void clickItemInServerTree(int mouseButton) { } private Table getCurrentTable() { - // return linksTabToTables.get(currentTab); - return ((Table) currentTab.getControl()); + return currentTable; } private Table getTable(TabItem tab) { - return ((Table) tab.getControl()); + Control control = tab.getControl(); + if (control instanceof Table) { + return (Table) control; + } + if (control instanceof SashForm) { + return (Table) (((SashForm) control).getChildren())[0]; + } + // return ((Table) tab.getControl()); + return null; } - private ColumnProperties getColumnProperties(Class clazz) { + private ColumnProperties getColumnProperties(Class clazz) { return config.getColumnsProperties(clazz); } - private ColumnProperties getColumnProperties(TabItem tab) { - return config.getColumnsProperties(linksTablesToExtendedClass.get(tab)); - } - private void saveCurrentSelectedData(TreeItem treeItem) { if (currentTreeItem != null && !currentTreeItem.isDisposed()) { @@ -1564,6 +1814,305 @@ private void setEnableToolbarItems() { deleteToolbarItem.setEnabled(toolbarDeleteListeners.get(currentHighlightingType) != null); } + private void fillAssignmentRulesTable() { + Object wsInfo = tnfTableViewer.getTable().getData(ID_DATA_KEY); + fillAssignmentRulesTable((WorkingServerInfoExtended) wsInfo); + } + + private void fillAssignmentRulesTable(WorkingServerInfoExtended wsInfo) { + + TableItem[] item = tableWorkingServers.getSelection(); + if (item.length == 0) { + return; + } + Server server = getCurrentServer(); + UUID clusterId = getCurrentClusterId(); + UUID workingServerId = wsInfo.getWorkingServerId(); + if (server == null || clusterId == null) { + return; + } + + // Заполнение таблицы с ТНФ + List listTnf = server.getAssignmentRules(clusterId, workingServerId); + tnfTableViewer.setInput(listTnf); + tnfTableViewer.getTable().setData(ID_DATA_KEY, wsInfo); + } + + private void addTableViewerColumn( + TableViewer tableViewer, String name, String desc, ColumnProperties columnProperties) { + + var tableViewerColumnParamKey = new TableViewerColumn(tableViewer, SWT.NONE); + TableColumn newColumn = tableViewerColumnParamKey.getColumn(); + newColumn.setText(desc); + newColumn.setMoveable(true); + newColumn.setAlignment(SWT.RIGHT); + tableViewerColumnParamKey.setLabelProvider(new AssignmentRuleLabelProvider(name)); + + if (columnProperties == null) { + newColumn.setWidth(100); + return; + } + + final int[] columnWidth = columnProperties.getWidth(); + final boolean[] columnVisible = columnProperties.getVisible(); + + Table table = tableViewer.getTable(); + int numOfColumn = table.getColumnCount() - 1; + newColumn.setData(numOfColumn); + if (numOfColumn == columnProperties.getSortColumn()) { + table.setSortColumn(newColumn); + table.setSortDirection(columnProperties.getSortDirectionSwt()); + } + + if (columnVisible != null && columnVisible[numOfColumn]) { + newColumn.setResizable(true); + newColumn.setWidth(columnWidth[numOfColumn] == 0 ? 100 : columnWidth[numOfColumn]); + } else { + newColumn.setResizable(false); + newColumn.setWidth(0); + } + + newColumn.addListener(SWT.Move, columnMoveListener); + newColumn.addListener(SWT.Resize, columnResizeListener); + newColumn.addListener(SWT.Selection, columnSortListener); + } + + private void addItemInTable(Table table) { + Class clazz = (Class) table.getData(); + + if (clazz == WorkingServerInfoExtended.class) { + + Server server = getCurrentServer(); + UUID clusterId = getCurrentClusterId(); + + if (server == null || clusterId == null) { + return; + } + + WorkingServerDialog dialog; + try { + dialog = + new WorkingServerDialog( + getParent().getDisplay().getActiveShell(), server, clusterId, null); + } catch (Exception excp) { + LOGGER.error( + "Error init WorkingServerDialog for cluster id {}", //$NON-NLS-1$ + clusterId, + excp); + return; + } + + if (dialog.open() == 0) { + refreshCurrentList(); + } + } + + if (clazz == IAssignmentRuleInfo.class) { + + WorkingServerInfoExtended wsInfo = (WorkingServerInfoExtended) table.getData(ID_DATA_KEY); + + Server server = getCurrentServer(); + UUID clusterId = getCurrentClusterId(); + UUID wsId = wsInfo.getWorkingServerId(); + if (server == null || clusterId == null || wsId == null) { + return; + } + + AssignmentRuleDialog dialog; + try { + dialog = + new AssignmentRuleDialog( + getParent().getDisplay().getActiveShell(), server, clusterId, wsId, null); + } catch (Exception excp) { + excp.printStackTrace(); + LOGGER.error( + "Error init AssignmentRuleEditDialog for new rule", //$NON-NLS-1$ + excp); + return; + } + + if (dialog.open() == 0) { + fillAssignmentRulesTable(); + } + } + + } + + private void viewItemInTable(TableItem item) { + BaseInfoExtended extInfo = (BaseInfoExtended) item.getData(EXTENDED_INFO); + + if (extInfo instanceof SessionInfoExtended) { + + SessionInfoExtended sessionExtInfo = (SessionInfoExtended) extInfo; + + SessionInfoDialog dialog; + try { + dialog = new SessionInfoDialog(getParent().getDisplay().getActiveShell(), sessionExtInfo); + } catch (Exception excp) { + excp.printStackTrace(); + LOGGER.error( + "Error init SessionInfoDialog for session id {}", //$NON-NLS-1$ + sessionExtInfo.getSessionInfo().getSid(), + excp); + return; + } + + dialog.open(); + } + } + + private void editItemInTable(TableItem item) { + BaseInfoExtended extInfo = (BaseInfoExtended) item.getData(EXTENDED_INFO); + if (extInfo instanceof WorkingServerInfoExtended) { + + WorkingServerInfoExtended workingServerExtInfo = (WorkingServerInfoExtended) extInfo; + + WorkingServerDialog dialog; + try { + dialog = + new WorkingServerDialog( + getParent().getDisplay().getActiveShell(), workingServerExtInfo); + } catch (Exception excp) { + excp.printStackTrace(); + LOGGER.error( + "Error init WorkingServerDialog for cluster id {}", //$NON-NLS-1$ + workingServerExtInfo.getWorkingServerId(), + excp); + return; + } + + if (dialog.open() == 0) { + // clickItemInServerTree(0); // TODO что здесь должно делаться??? + refreshCurrentList(); + } + } else if (extInfo == null && item.getData() instanceof IAssignmentRuleInfo) { + IAssignmentRuleInfo ruleInfo = (IAssignmentRuleInfo) item.getData(); + + WorkingServerInfoExtended wsInfo = + (WorkingServerInfoExtended) item.getParent().getData(ID_DATA_KEY); + + Server server = getCurrentServer(); + UUID clusterId = getCurrentClusterId(); + UUID wsId = wsInfo.getWorkingServerId(); + if (server == null || clusterId == null || wsId == null) { + return; + } + + AssignmentRuleDialog dialog; + try { + dialog = + new AssignmentRuleDialog( + getParent().getDisplay().getActiveShell(), server, clusterId, wsId, ruleInfo); + } catch (Exception excp) { + excp.printStackTrace(); + LOGGER.error( + "Error init AssignmentRuleEditDialog for rule {}", //$NON-NLS-1$ + ruleInfo.getObjectType(), + excp); + return; + } + + if (dialog.open() == 0) { + refreshCurrentList(); + } + + } else { + return; + } + } + + private void deleteItemsFromTable(TableItem[] selectedItems) { + + for (TableItem item : selectedItems) { + + Object extInfo = item.getData(EXTENDED_INFO); + item.setForeground(deletedItemColor); // TODO успевает ли окраситься в красный цвет + + if (extInfo instanceof SessionInfoExtended) { + SessionInfoExtended sessionExtInfo = (SessionInfoExtended) extInfo; + + Server server = sessionExtInfo.getServer(); + UUID clusterId = sessionExtInfo.getClusterId(); + UUID sessionId = sessionExtInfo.getSessionInfo().getSid(); + + if (server.terminateSession(clusterId, sessionId)) { + item.dispose(); + } + + } else if (extInfo instanceof ConnectionInfoExtended) { + ConnectionInfoExtended connExtInfo = (ConnectionInfoExtended) extInfo; + + Server server = connExtInfo.getServer(); + UUID clusterId = connExtInfo.getClusterId(); + UUID processId = connExtInfo.getConnectionInfo().getWorkingProcessId(); + UUID connectionId = connExtInfo.getConnectionInfo().getInfoBaseConnectionId(); + UUID infobaseId = connExtInfo.getConnectionInfo().getInfoBaseId(); + + if (server.disconnectConnection(clusterId, processId, connectionId, infobaseId)) { + item.dispose(); // update tableConnections + } + + } else if (extInfo instanceof WorkingServerInfoExtended) { + WorkingServerInfoExtended wsExtInfo = (WorkingServerInfoExtended) extInfo; + + Server server = wsExtInfo.getServer(); + UUID clusterId = wsExtInfo.getClusterId(); + UUID workingServerId = wsExtInfo.getWorkingServerId(); + + int answer = + Helper.showQuestionBox( + Messages.getString("ViewerArea.DeleteServerQuestion")); // $NON-NLS-1$ + + if (answer == SWT.YES && server.unregWorkingServer(clusterId, workingServerId)) { + item.dispose(); // update tableWorkingServers + } + } else if (extInfo == null && item.getData() instanceof IAssignmentRuleInfo) { + IAssignmentRuleInfo ruleInfo = (IAssignmentRuleInfo) item.getData(); + + WorkingServerInfoExtended wsInfo = + (WorkingServerInfoExtended) item.getParent().getData(ID_DATA_KEY); + + Server server = getCurrentServer(); + UUID clusterId = getCurrentClusterId(); + UUID wsId = wsInfo.getWorkingServerId(); + if (server == null || clusterId == null || wsId == null) { + return; + } + + int answer = + Helper.showQuestionBox( + Messages.getString("ViewerArea.DeleteAssignmentRule")); // $NON-NLS-1$ + + if (answer == SWT.YES + && server.unregAssignmentRule(clusterId, wsId, ruleInfo.getAssignmentRuleId())) { + item.dispose(); + } + + } else { + break; + } + } + } + + private void changeAssignmentRuleNumber(TableItem item, boolean increase) { + IAssignmentRuleInfo rule = (IAssignmentRuleInfo) item.getData(); + + int newRuleNumber = AssignmentRuleContentProvider.getRuleNumber(rule) + (increase ? -1 : 1); + + WorkingServerInfoExtended wsInfo = + (WorkingServerInfoExtended) item.getParent().getData(ID_DATA_KEY); + + Server server = getCurrentServer(); + UUID clusterId = getCurrentClusterId(); + UUID wsId = wsInfo.getWorkingServerId(); + if (server == null || clusterId == null || wsId == null) { + return; + } + + server.regAssignmentRule(clusterId, wsId, rule, newRuleNumber - 1); + refreshCurrentList(); + } + ////////////////////////////////////////////////////////////////////////// // LISTENERS @@ -1754,7 +2303,7 @@ public void widgetSelected(SelectionEvent event) { String buttonName = ((ToolItem) event.widget).getText(); if (serversTree.getSelection().length == 0 - && Strings.CONTEXT_MENU_CREATE.equals(buttonName)) { + && Strings.CONTEXT_MENU_ADD.equals(buttonName)) { addServerListener.widgetSelected(event); return; } @@ -1764,7 +2313,7 @@ public void widgetSelected(SelectionEvent event) { } Map currListener = null; - if (Strings.CONTEXT_MENU_CREATE.equals(buttonName)) { + if (Strings.CONTEXT_MENU_ADD.equals(buttonName)) { currListener = toolbarCreateListeners; } else if (Strings.CONTEXT_MENU_EDIT.equals(buttonName)) { currListener = toolbarEditListeners; @@ -2093,6 +2642,29 @@ public void widgetSelected(SelectionEvent event) { } }; + SelectionAdapter applyAssignmentRuleListener = + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent event) { + TreeItem[] item = serversTree.getSelection(); + if (item.length == 0) { + return; + } + + Server server = getServer(item[0]); + UUID clusterId = getClusterId(item[0]); + + if (server == null || clusterId == null) { + return; + } + + Object data = ((MenuItem) event.widget).getData(); + if (data instanceof Integer) { + server.applyAssignmentRules(clusterId, (int) data); + } + } + }; + SelectionAdapter createInfobaseListener = // TODO вызывается из контекстного меню и из тулбара // нет ли ошибки serversTree.getSelection() при вызове из тулбара @@ -2400,46 +2972,6 @@ public void widgetSelected(SelectionEvent event) { } }; - SelectionAdapter createWorkingServerListener = - new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - Table tableWorkingServers = getCurrentTable(); - Server server = getCurrentServer(); - UUID clusterId = getCurrentClusterId(); - - if (server == null || clusterId == null) { - return; - } - - WorkingServerDialog dialog; - try { - dialog = - new WorkingServerDialog( - getParent().getDisplay().getActiveShell(), server, clusterId, null); - } catch (Exception excp) { - LOGGER.error( - "Error init WorkingServerDialog for cluster id {}", //$NON-NLS-1$ - clusterId, - excp); - return; - } - - int dialogResult = dialog.open(); - if (dialogResult == 0) { - var newWorkingServerUuid = dialog.getNewWorkingServerId(); - if (newWorkingServerUuid != null) { - WorkingServerInfoExtended workingServerInfo = - new WorkingServerInfoExtended( - server, - clusterId, - server.getWorkingServerInfo(clusterId, newWorkingServerUuid)); - workingServerInfo.addToTable(tableWorkingServers); - } - } - } - }; - SelectionAdapter createWorkingServerListenerInTree = new SelectionAdapter() { @Override @@ -2522,8 +3054,7 @@ public void handleEvent(Event e) { TableColumn column = (TableColumn) e.widget; Table currentTable = column.getParent(); - final Class clazz = - linksTablesToExtendedClass.get(currentTab); + final Class clazz = (Class) currentTable.getData(); if (clazz != null) { config.setColumnsOrder(clazz, currentTable.getColumnOrder()); } @@ -2538,13 +3069,15 @@ public void handleEvent(Event e) { public void handleEvent(Event e) { TableColumn column = (TableColumn) e.widget; - int newWidth = column.getWidth(); Table currentTable = column.getParent(); + + int newWidth = column.getWidth(); TableColumn[] columns = currentTable.getColumns(); + final Class clazz = (Class) currentTable.getData(); for (int i = 0; i < columns.length; i++) { if (columns[i].getText().equals(column.getText())) { - config.setColumnsWidth(linksTablesToExtendedClass.get(currentTab), i, newWidth); + config.setColumnsWidth(clazz, i, newWidth); break; } } @@ -2555,17 +3088,16 @@ public void handleEvent(Event e) { Listener columnSortListener = new Listener() { public void handleEvent(Event e) { - Table currentTable = getCurrentTable(); - if (currentTable == null) { - return; - } + TableColumn column = (TableColumn) e.widget; + Table currentTable = column.getParent(); + + int numColumn = (int) column.getData(); - ColumnProperties columnProperties = getColumnProperties(currentTab); + final Class clazz = (Class) currentTable.getData(); + ColumnProperties columnProperties = getColumnProperties(clazz); if (columnProperties == null) { return; } - TableColumn column = (TableColumn) e.widget; - int numColumn = (int) column.getData(); columnProperties.setSortColumn(numColumn); currentTable.setSortColumn(column); @@ -2574,17 +3106,22 @@ public void handleEvent(Event e) { // сортировка того что уже есть в списке TableItem[] items = currentTable.getItems(); - for (int i = 1; i < items.length; i++) { - BaseInfoExtended secondString = (BaseInfoExtended) items[i].getData(EXTENDED_INFO); + if (clazz == IAssignmentRuleInfo.class) { + tnfTableViewer.refresh(); + } + if (clazz != IAssignmentRuleInfo.class) { + for (int i = 1; i < items.length; i++) { + BaseInfoExtended secondString = (BaseInfoExtended) items[i].getData(EXTENDED_INFO); - for (int j = 0; j < i; j++) { - BaseInfoExtended firstString = (BaseInfoExtended) items[j].getData(EXTENDED_INFO); + for (int j = 0; j < i; j++) { + BaseInfoExtended firstString = (BaseInfoExtended) items[j].getData(EXTENDED_INFO); - if (firstString.compareTo(secondString) > 0) { - items[i].dispose(); - secondString.addToTable(currentTable, j); - items = currentTable.getItems(); - break; + if (firstString.compareTo(secondString) > 0) { + items[i].dispose(); + secondString.addToTable(currentTable, j); + items = currentTable.getItems(); + break; + } } } } @@ -2608,131 +3145,6 @@ public void handleEvent(Event e) { // } // }; - SelectionAdapter editItemInTablesListener = - new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - - TableItem[] item = getCurrentTable().getSelection(); - if (item.length == 0) { - return; - } - - if (currentTab.equals(tabSessions)) { - - SessionInfoExtended sessionExtInfo = - (SessionInfoExtended) item[0].getData(EXTENDED_INFO); - - SessionInfoDialog dialog; - try { - dialog = - new SessionInfoDialog(getParent().getDisplay().getActiveShell(), sessionExtInfo); - } catch (Exception excp) { - excp.printStackTrace(); - LOGGER.error( - "Error init SessionInfoDialog for session id {}", //$NON-NLS-1$ - sessionExtInfo.getSessionInfo().getSid(), - excp); - return; - } - - dialog.open(); - - } else if (currentTab.equals(tabWorkingServers)) { - - WorkingServerInfoExtended workingServerExtInfo = - (WorkingServerInfoExtended) item[0].getData(EXTENDED_INFO); - - WorkingServerDialog dialog; - try { - dialog = - new WorkingServerDialog( - getParent().getDisplay().getActiveShell(), workingServerExtInfo); - } catch (Exception excp) { - excp.printStackTrace(); - LOGGER.error( - "Error init WorkingServerDialog for cluster id {}", //$NON-NLS-1$ - workingServerExtInfo.getWorkingServerId(), - excp); - return; - } - - int dialogResult = dialog.open(); - if (dialogResult == 0) { - // clickItemInServerTree(0); // TODO что здесь должно делаться??? - refreshCurrentList(); - } - } else { - return; - } - } - }; - - SelectionAdapter deleteItemInTablesListener = - new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - - TableItem[] selectedItems = getCurrentTable().getSelection(); - if (selectedItems.length == 0) { - return; - } - - for (TableItem item : selectedItems) { - item.setForeground(deletedItemColor); // TODO успевает ли окраситься в красный цвет - - // BaseInfoExtended extInfo = (BaseInfoExtended) item.getData("ExtendedInfo"); - // //$NON-NLS-1$ - // Server server = extInfo.getServer(); - // UUID clusterId = extInfo.getClusterId(); - - if (currentTab.equals(tabSessions)) { - SessionInfoExtended extInfo = (SessionInfoExtended) item.getData(EXTENDED_INFO); - - Server server = extInfo.getServer(); - UUID clusterId = extInfo.getClusterId(); - UUID sessionId = extInfo.getSessionInfo().getSid(); - - if (server.terminateSession(clusterId, sessionId)) { - item.dispose(); - } - - } else if (currentTab.equals(tabConnections)) { - ConnectionInfoExtended extInfo = (ConnectionInfoExtended) item.getData(EXTENDED_INFO); - - Server server = extInfo.getServer(); - UUID clusterId = extInfo.getClusterId(); - UUID pricessId = extInfo.getConnectionInfo().getWorkingProcessId(); - UUID connectionId = extInfo.getConnectionInfo().getInfoBaseConnectionId(); - UUID infobaseId = extInfo.getConnectionInfo().getInfoBaseId(); - - if (server.disconnectConnection(clusterId, pricessId, connectionId, infobaseId)) { - item.dispose(); // update tableConnections - } - - } else if (currentTab.equals(tabWorkingServers)) { - WorkingServerInfoExtended extInfo = - (WorkingServerInfoExtended) item.getData(EXTENDED_INFO); - - Server server = extInfo.getServer(); - UUID clusterId = extInfo.getClusterId(); - UUID workingServerId = extInfo.getWorkingServerId(); - - int answer = - Helper.showQuestionBox( - Messages.getString("ViewerArea.DeleteServerQuestion")); //$NON-NLS-1$ - - if (answer == SWT.YES && server.unregWorkingServer(clusterId, workingServerId)) { - item.dispose(); // update tableWorkingServers - } - - } else { - break; - } - } - } - }; - SelectionAdapter copyCellValueInTablesListener = new SelectionAdapter() { @Override @@ -2795,31 +3207,48 @@ public void mouseDown(MouseEvent event) { if (event.button != 1 && event.button != 3) { return; } - Table currentTable = (Table) event.widget; + currentTable = (Table) event.widget; Point pt = new Point(event.x, event.y); TableItem item = currentTable.getItem(pt); - if (item != null) { - for (int col = 0; col < currentTable.getColumnCount(); col++) { - Rectangle rect = item.getBounds(col); - if (rect.contains(pt)) { - if (lastSelectItem != null && !lastSelectItem.isDisposed()) { - lastSelectItem.setForeground(lastSelectColumn, null); - } - item.setForeground(col, Helper.getOrangeColor()); + if (item == null) { + currentTable.deselectAll(); + return; + } - lastSelectItem = item; - lastSelectColumn = col; - break; + for (int col = 0; col < currentTable.getColumnCount(); col++) { + Rectangle rect = item.getBounds(col); + if (rect.contains(pt)) { + + if (lastSelectItem != null && !lastSelectItem.isDisposed()) { + lastSelectItem.setForeground(lastSelectColumn, null); } + item.setForeground(col, Helper.getOrangeColor()); + + // заполнение таблицы с ТНФ + if (currentTable.equals(tableWorkingServers) && !item.equals(lastSelectItem)) { + WorkingServerInfoExtended ws = + (WorkingServerInfoExtended) item.getData(EXTENDED_INFO); + fillAssignmentRulesTable(ws); + } + + lastSelectItem = item; + lastSelectColumn = col; + break; } } } @Override - public void mouseDoubleClick(MouseEvent e) { - editItemInTablesListener.widgetSelected(null); + public void mouseDoubleClick(MouseEvent event) { + currentTable = (Table) event.widget; + TableItem[] item = currentTable.getSelection(); + if (item.length == 0) { + return; + } + editItemInTable(item[0]); + } }; @@ -2829,18 +3258,30 @@ public void mouseDoubleClick(MouseEvent e) { public void keyPressed(KeyEvent e) { final int keyC = 99; + currentTable = (Table) e.widget; + TableItem[] items = currentTable.getSelection(); switch (e.keyCode) { - case SWT.F2: - editItemInTablesListener.widgetSelected(null); - break; - case SWT.F5: refreshCurrentList(); break; + case SWT.INSERT: + addItemInTable(currentTable); + break; + + case SWT.F2: + if (items.length == 0) { + return; + } + editItemInTable(items[0]); + break; + case SWT.DEL: - deleteItemInTablesListener.widgetSelected(null); + if (items.length == 0) { + return; + } + deleteItemsFromTable(items); break; case keyC: @@ -3174,7 +3615,7 @@ public void addToTasksQueue(BackgroundTask task) { } } - class RefreshTablesSelectionListener extends SelectionAdapter { + class RefreshTablesSelectionListener implements Listener { private ToolItem mainButton; private Menu dropdownMenu; @@ -3182,7 +3623,7 @@ class RefreshTablesSelectionListener extends SelectionAdapter { public RefreshTablesSelectionListener(ToolItem mainButton) { this.mainButton = mainButton; - this.mainButton.addSelectionListener(this); + this.mainButton.addListener(SWT.Selection, this); dropdownMenu = new Menu(mainButton.getParent().getShell()); @@ -3254,7 +3695,7 @@ public void widgetSelected(SelectionEvent event) { }; @Override - public void widgetSelected(SelectionEvent event) { + public void handleEvent(Event event) { if (event.detail == SWT.ARROW) { ToolItem item = (ToolItem) event.widget; Rectangle rect = item.getBounds(); @@ -3287,21 +3728,27 @@ private static class Strings { getString("ContextMenu.DisconnectOfServer"); static final String CONTEXT_MENU_SHOW_CONNECTION_ERROR = getString("ContextMenu.ShowConnectionError"); - static final String CONTEXT_MENU_CREATE = getString("ContextMenu.Create"); + + static final String CONTEXT_MENU_ADD = getString("ContextMenu.Add"); static final String CONTEXT_MENU_EDIT = getString("ContextMenu.Edit"); static final String CONTEXT_MENU_DELETE = getString("ContextMenu.Delete"); - static final String CONTEXT_MENU_COPY_CELL_VALUE = - getString("ContextMenu.CopyCellValue").concat("\tCtrl+C"); - static final String CONTEXT_MENU_ADD_SERVER = getString("ContextMenu.AddServer"); - static final String CONTEXT_MENU_EDIT_SERVER = getString("ContextMenu.EditServer"); + + static final String CONTEXT_MENU_ADD_HOTKEY = CONTEXT_MENU_ADD.concat("\tIns"); + static final String CONTEXT_MENU_EDIT_HOTKEY = CONTEXT_MENU_EDIT.concat("\tF2"); + static final String CONTEXT_MENU_DELETE_HOTKEY = CONTEXT_MENU_DELETE.concat("\tDEL"); + + static final String CONTEXT_MENU_COPY_CELL = + getString("ContextMenu.CopyCell").concat("\tCtrl+C"); + static final String CONTEXT_MENU_MOVE_UP = getString("ContextMenu.MoveUp"); static final String CONTEXT_MENU_MOVE_DOWN = getString("ContextMenu.MoveDown"); static final String CONTEXT_MENU_ORGANIZE_SERVERS = getString("ContextMenu.OrganizeServers"); - static final String CONTEXT_MENU_REMOVE_SERVER = getString("ContextMenu.RemoveServer"); static final String CONTEXT_MENU_CREATE_CLUSTER = getString("ContextMenu.CreateCluster"); static final String CONTEXT_MENU_EDIT_CLUSTER = getString("ContextMenu.EditCluster"); static final String CONTEXT_MENU_DELETE_CLUSTER = getString("ContextMenu.DeleteCluster"); + static final String CONTEXT_MENU_APPLY_PARTIAL_RULE = getString("ContextMenu.ApplyPartialRule"); + static final String CONTEXT_MENU_APPLY_FULL_RULE = getString("ContextMenu.ApplyFullRule"); static final String CONTEXT_MENU_CREATE_WORKING_SERVER = getString("ContextMenu.CreateWorkingServer"); @@ -3337,8 +3784,7 @@ private static class Strings { static final String CONTEXT_MENU_TERMINATE_USERS_SESSIONS = getString("ContextMenu.TerminateUsersSessions"); - static final String CONTEXT_MENU_VIEW_SESSION_F2 = - getString("ContextMenu.ViewSession").concat("\tF2"); + static final String CONTEXT_MENU_VIEW_HOTKEY = getString("ContextMenu.View").concat("\tF2"); static final String CONTEXT_MENU_KILL_SESSION_DEL = getString("ContextMenu.KillSession").concat("\tDEL"); static final String CONTEXT_MENU_KILL_CONNECTION_DEL = diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties index a1703d3..cbe3487 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties @@ -143,12 +143,14 @@ SettingsDialog.WatchSessions = Watch sessions color ViewerArea.Active = Active ViewerArea.ColumnServer = Server ViewerArea.ConnPerProcessLimit = Conn per process limit +ViewerArea.ContextMenu.Add = Add ViewerArea.ContextMenu.AddInFavorites = Add to favorites ViewerArea.ContextMenu.AddServer = Add server +ViewerArea.ContextMenu.ApplyFullRule = Apply rule (full) +ViewerArea.ContextMenu.ApplyPartialRule = Apply rule (partial) ViewerArea.ContextMenu.ConnectToServer = Connect to server -ViewerArea.ContextMenu.CopyCellValue = Copy cell value +ViewerArea.ContextMenu.CopyCell = Copy cell ViewerArea.ContextMenu.CopyInfobase = Copy infobase -ViewerArea.ContextMenu.Create = Create ViewerArea.ContextMenu.CreateCluster = Create cluster ViewerArea.ContextMenu.CreateInfobase = Create infobase ViewerArea.ContextMenu.CreateWorkingServer = Create working server @@ -180,8 +182,9 @@ ViewerArea.ContextMenu.TerminateAllSessions = Terminate all sessions ViewerArea.ContextMenu.TerminateUsersSessions = Terminate users sessions ViewerArea.ContextMenu.Update = Update ViewerArea.ContextMenu.UpdateInfobases = Update infobases -ViewerArea.ContextMenu.ViewSession = Session info +ViewerArea.ContextMenu.View = View ViewerArea.DedicatedManagers = Dedicated managers +ViewerArea.DeleteAssignmentRule = Do you really want to remove the assignment rule? ViewerArea.DeleteClusterQuestion = Deleting a cluster will delete its settings and the list of registered information databases. Do you really want to delete the cluster? ViewerArea.DeleteServerQuestion = Do you really want to remove the server from the list? ViewerArea.Description = Description diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties index 27dcab1..8339f8e 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties @@ -143,12 +143,14 @@ SettingsDialog.WatchSessions = \u0426\u0432\u0435\u0442 \u043E\u044 ViewerArea.Active = \u0410\u043A\u0442\u0438\u0432\u043D\u044B\u0439 ViewerArea.ColumnServer = \u0421\u0435\u0440\u0432\u0435\u0440 ViewerArea.ConnPerProcessLimit = \u041A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E \u0441\u043E\u0435\u0434\u0438\u043D\u0435\u043D\u0438\u0439 \u043D\u0430 \u0440\u0430\u0431\u043E\u0447\u0438\u0439 \u043F\u0440\u043E\u0446\u0435\u0441\u0441 +ViewerArea.ContextMenu.Add = \u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C ViewerArea.ContextMenu.AddInFavorites = \u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u0432 \u0438\u0437\u0431\u0440\u0430\u043D\u043D\u043E\u0435 ViewerArea.ContextMenu.AddServer = \u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u0441\u0435\u0440\u0432\u0435\u0440 +ViewerArea.ContextMenu.ApplyFullRule = \u041F\u0440\u0438\u043C\u0435\u043D\u0438\u0442\u044C \u0422\u041D\u0424 (\u043F\u043E\u043B\u043D\u043E\u0435) +ViewerArea.ContextMenu.ApplyPartialRule = \u041F\u0440\u0438\u043C\u0435\u043D\u0438\u0442\u044C \u0422\u041D\u0424 (\u0447\u0430\u0441\u0442\u0438\u0447\u043D\u043E\u0435) ViewerArea.ContextMenu.ConnectToServer = \u041F\u043E\u0434\u043A\u043B\u044E\u0447\u0438\u0442\u044C\u0441\u044F \u043A \u0441\u0435\u0440\u0432\u0435\u0440\u0443 -ViewerArea.ContextMenu.CopyCellValue = \u041A\u043E\u043F\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u044F\u0447\u0435\u0439\u043A\u0438 +ViewerArea.ContextMenu.CopyCell = \u041A\u043E\u043F\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u044F\u0447\u0435\u0439\u043A\u0443 ViewerArea.ContextMenu.CopyInfobase = \u0421\u043A\u043E\u043F\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u0438\u043D\u0444\u043E\u0431\u0430\u0437\u0443 -ViewerArea.ContextMenu.Create = \u0421\u043E\u0437\u0434\u0430\u0442\u044C ViewerArea.ContextMenu.CreateCluster = \u0421\u043E\u0437\u0434\u0430\u0442\u044C \u043A\u043B\u0430\u0441\u0442\u0435\u0440 ViewerArea.ContextMenu.CreateInfobase = \u0421\u043E\u0437\u0434\u0430\u0442\u044C \u0438\u043D\u0444\u043E\u0431\u0430\u0437\u0443 ViewerArea.ContextMenu.CreateWorkingServer = \u0421\u043E\u0437\u0434\u0430\u0442\u044C \u0440\u0430\u0431\u043E\u0447\u0438\u0439 \u0441\u0435\u0440\u0432\u0435\u0440 @@ -180,8 +182,9 @@ ViewerArea.ContextMenu.TerminateAllSessions = \u0417\u0430\u0432\u04 ViewerArea.ContextMenu.TerminateUsersSessions = \u0417\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u044C \u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u0442\u0435\u043B\u044C\u0441\u043A\u0438\u0435 \u0441\u0435\u0430\u043D\u0441\u044B ViewerArea.ContextMenu.Update = \u041E\u0431\u043D\u043E\u0432\u0438\u0442\u044C ViewerArea.ContextMenu.UpdateInfobases = \u041E\u0431\u043D\u043E\u0432\u0438\u0442\u044C \u0438\u043D\u0444\u043E\u0431\u0430\u0437\u044B -ViewerArea.ContextMenu.ViewSession = \u0418\u043D\u0444\u043E\u0440\u043C\u0430\u0446\u0438\u044F \u043E \u0441\u0435\u0441\u0441\u0438\u0438 +ViewerArea.ContextMenu.View = \u041F\u0440\u043E\u0441\u043C\u043E\u0442\u0440 ViewerArea.DedicatedManagers = \u041C\u0435\u043D\u0435\u0434\u0436\u0435\u0440 \u043F\u043E\u0434 \u043A\u0430\u0436\u0434\u044B\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 +ViewerArea.DeleteAssignmentRule = \u0412\u044B \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043B\u044C\u043D\u043E \u0445\u043E\u0442\u0438\u0442\u0435 \u0443\u0434\u0430\u043B\u0438\u0442\u044C \u043F\u0440\u0430\u0432\u0438\u043B\u043E \u0422\u041D\u0424? ViewerArea.DeleteClusterQuestion = \u0423\u0434\u0430\u043B\u0435\u043D\u0438\u0435 \u043A\u043B\u0430\u0441\u0442\u0435\u0440\u0430 \u043F\u0440\u0438\u0432\u0435\u0434\u0435\u0442 \u043A \u0443\u0434\u0430\u043B\u0435\u043D\u0438\u044E \u0435\u0433\u043E \u043D\u0430\u0441\u0442\u0440\u043E\u0435\u043A \u0438 \u0441\u043F\u0438\u0441\u043A\u0430 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043E\u0432\u0430\u043D\u043D\u044B\u0445 \u0438\u043D\u0444\u043E\u0440\u043C\u0430\u0446\u0438\u043E\u043D\u043D\u044B\u0445 \u0431\u0430\u0437. \u0412\u044B \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043B\u044C\u043D\u043E \u0445\u043E\u0442\u0438\u0442\u0435 \u0443\u0434\u0430\u043B\u0438\u0442\u044C \u043A\u043B\u0430\u0441\u0442\u0435\u0440? ViewerArea.DeleteServerQuestion = \u0412\u044B \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043B\u044C\u043D\u043E \u0445\u043E\u0442\u0438\u0442\u0435 \u0443\u0434\u0430\u043B\u0438\u0442\u044C \u0441\u0435\u0440\u0432\u0435\u0440 \u0438\u0437 \u0441\u043F\u0438\u0441\u043A\u0430? ViewerArea.Description = \u041E\u043F\u0438\u0441\u0430\u043D\u0438\u0435 diff --git a/clusterAdminLibrary/src/main/resources/icons/view_16.png b/clusterAdminLibrary/src/main/resources/icons/view_16.png new file mode 100644 index 0000000000000000000000000000000000000000..6bde4ee4de6a0a59ec9a88a801e06f6686a443d9 GIT binary patch literal 677 zcmV;W0$TlvP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGdzW@LUzXAB|doKV00y;@VK~y+Tm6J_q z(_kFNpM131c3-WO6=YO&TcsPDAYx~$9Sk->(6M|7cept7+u_a(j6OMxP?QVs<7c2Iof(AFBreG^S%ZZq|)^Y?7tmw{c zBu+lgF5IHLl%{N%Xjvj!Sk>t3VuI2iM=1LN7p&-Cm@ANGBT*gQ)4cySTn&4mXoS4V zP*4atRfH(bU~hJ4-QjHOZtRVx&87ukJrR>fbw@vR+h$o~1jdZlA_B)$qE#4dyj)%CvYD^J6mU#_X)nG-xm+*=oFS-6$dt&s0H>Zo1HLFkjWM%TgDGfg zJ~XvUzxTd*Z4yPL1W6N-*97wrwKW9r6b^3oe$(OnyxFQ@>pPI=PWhF>tH~la5y{yH zq4I9*Mg|@>ji1RENY1rPox3qVY{hqmmd@KY;uv3#;mNNU-bkPDaOGXw=;bpV$^D{@ zPIMl;V@2zvBO35|TQlu0Ck+IHSFCA$9FIhzKDS%x@_OlPG&*99>mwWvk9nOA>S^_r zx(*D4tZ{wxh5D`=dryz9`d8`mY5%t0`G2^1Df~RtzC?q={bRoYv^EFtL&Av*00000 LNkvXXu0mjfElM$( literal 0 HcmV?d00001 From 7df896f34468ec49f5bef014668370d9d70cb130 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Sun, 28 Apr 2024 12:38:35 +0300 Subject: [PATCH 55/70] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D1=80=D0=B0?= =?UTF-8?q?=D0=B1=D0=BE=D1=82=D0=BA=D0=B0=20=D0=B4=D0=B8=D0=B0=D0=BB=D0=BE?= =?UTF-8?q?=D0=B3=D0=B0=20=D0=B2=D1=8B=D0=B1=D0=BE=D1=80=D0=B0=20=D1=84?= =?UTF-8?q?=D0=B0=D0=B9=D0=BB=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../clusterAdminLibrary/BackgroundTask.java | 48 ++++++++++++++++--- .../BackgroundTaskParams.java | 26 +++++----- .../clusterAdminLibraryUI/ViewerArea.java | 5 +- 3 files changed, 58 insertions(+), 21 deletions(-) diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java index 9f486f7..c8744d2 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java @@ -27,6 +27,7 @@ public class BackgroundTask { static final String enterpriseCommand = "ENTERPRISE"; static final String logonCommand = "/S%v8serverName%:%v8managerPort%\\%v8infobase% /N%v8username% /P%v8password%"; + static final String FILEPATH_PARAM_KEY = "%v8FilePath%"; static int countOfRunning = 0; static int countOfCompleted = 0; @@ -39,6 +40,8 @@ public class BackgroundTask { File script; String scriptText; + String v8Command; + String fileExtension; String scriptName; @@ -53,6 +56,7 @@ public class BackgroundTask { TaskState stateLast; TaskVariant taskVariant; + V8ActionVariant v8ActionVariant; enum TaskState { RUNNUNG, @@ -108,31 +112,46 @@ public BackgroundTask(File script) { */ public BackgroundTask(V8ActionVariant v8ActionVariant) { this.taskVariant = TaskVariant.V8ACTION; + this.v8ActionVariant = v8ActionVariant; + final String launchMode; if (v8ActionVariant == V8ActionVariant.RUN_ENTERPRISE) { - this.scriptText = String.join(" ", starterPath, enterpriseCommand, logonCommand); + launchMode = enterpriseCommand; } else { - this.scriptText = String.join(" ", starterPath, designerCommand, logonCommand); + launchMode = designerCommand; } + final String v8Command; switch (v8ActionVariant) { case SAVE_CF: - this.scriptText = String.join(" ", this.scriptText, "/DumpCfg %v8FilePath.cf%"); + this.fileExtension = ".cf"; + v8Command = String.join(" ", "/DumpCfg", FILEPATH_PARAM_KEY); break; case LOAD_CF: - this.scriptText = String.join(" ", this.scriptText, "/LoadCfg %v8FilePath.cf%"); + this.fileExtension = ".cf"; + v8Command = String.join(" ", "/LoadCfg", FILEPATH_PARAM_KEY); break; case SAVE_DT: - this.scriptText = String.join(" ", this.scriptText, "/DumpIB %v8FilePath.dt%"); + this.fileExtension = ".dt"; + v8Command = String.join(" ", "/DumpIB", FILEPATH_PARAM_KEY); break; case LOAD_DT: - this.scriptText = String.join(" ", this.scriptText, "/RestoreIB %v8FilePath.dt%"); + this.fileExtension = ".dt"; + v8Command = String.join(" ", "/RestoreIB", FILEPATH_PARAM_KEY); break; - default: + v8Command = ""; break; } + this.scriptText = + String.join( + " ", + starterPath, + launchMode, + logonCommand, + v8Command); + this.scriptName = v8ActionVariant.toString(); } @@ -166,6 +185,21 @@ public String getScriptName() { return this.scriptName; } + /** Определяет, я вляется ли параметр путем к файлу. */ + public boolean isFilepathParam(String paramName) { + return FILEPATH_PARAM_KEY.contains(paramName); + } + + /** Получить строку для фильтра выбора файла. */ + public String getFilenameFilterExt() { + return "*".concat(fileExtension); + } + + /** Получить строку для фильтра выбора файла. */ + public boolean isSaveCommand() { + return v8ActionVariant == V8ActionVariant.SAVE_CF || v8ActionVariant == V8ActionVariant.SAVE_DT; + } + /** * Установка параметров задачи. * diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/BackgroundTaskParams.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/BackgroundTaskParams.java index 2e8432f..e2b2a47 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/BackgroundTaskParams.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/BackgroundTaskParams.java @@ -29,6 +29,7 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableColumn; +import ru.yanygin.clusterAdminLibrary.BackgroundTask; import ru.yanygin.clusterAdminLibrary.UserPassPair; /** Диалог параметров фоновой задачи. */ @@ -38,6 +39,7 @@ public class BackgroundTaskParams extends Dialog { private static final String PASSWORD_TITLE = "v8password"; private Map params; + private BackgroundTask task; private String title; private Table tableParams; private Map infobasesCredentials = new HashMap<>(); @@ -51,19 +53,20 @@ public class BackgroundTaskParams extends Dialog { * * @param parentShell - parent shell * @param params - текущие имя пользователя и пароль - * @param title - заголовок окна аутентификации + * @param task - ссылка на объект задачи * @param infobasesCredentials - данные доступа к инфобазам */ public BackgroundTaskParams( Shell parentShell, Map params, - String title, + BackgroundTask task, List infobasesCredentials) { super(parentShell); setShellStyle(SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); this.params = params; - this.title = title; + this.task = task; + this.title = task.getScriptName(); infobasesCredentials.forEach( up -> { @@ -180,18 +183,11 @@ protected boolean isPasswordParam(String e) { } protected boolean isFilepathParam(String[] e) { - - if (e[0].toLowerCase().contains("filepath.cf")) { - currentFilenameExt = "*.cf"; - currentFilepath = e[1]; - return true; - } - if (e[0].toLowerCase().contains("filepath.dt")) { - currentFilenameExt = "*.dt"; + if (task.isFilepathParam(e[0])) { + currentFilenameExt = task.getFilenameFilterExt(); currentFilepath = e[1]; return true; } - return false; } @@ -218,7 +214,11 @@ protected Object openDialogBox(Control cellEditorWindow) { final String[] filterNames = {String.format(Strings.FILTER_NAME, currentFilenameExt)}; final String[] filterExt = {currentFilenameExt}; - FileDialog dialog = new FileDialog(cellEditorWindow.getShell(), SWT.OPEN); + // При варианте SWT.SAVE автоматически дописывается расширение, в отличие от OPEN + FileDialog dialog = new FileDialog(cellEditorWindow.getShell(), SWT.SAVE); + // поэтому вопрос о перезаписи регулируем через setOverwrite + dialog.setOverwrite(task.isSaveCommand()); + if (currentFilepath.isBlank()) { dialog.setFileName(currentFilenameExt); } else { diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java index 94aecc4..67f9513 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java @@ -1657,7 +1657,10 @@ private Map fillParams(BackgroundTask backgroundTask, TreeItem i if (foundEmptyParams) { BackgroundTaskParams taskParamsDialog = new BackgroundTaskParams( - getShell(), params, backgroundTask.getScriptName(), server.getInfobasesCredentials()); + getShell(), + params, + backgroundTask, + server.getInfobasesCredentials()); int dialogResult = taskParamsDialog.open(); if (dialogResult != 0) { return new HashMap<>(); From 0421d6368802511f26ec72cd9c34292e29b2e62d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Sun, 28 Apr 2024 12:52:03 +0300 Subject: [PATCH 56/70] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=84=D0=BE=D1=80=D0=BC=D0=B8?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F=20=D0=B8=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=20=D0=B7=D0=B0=D0=B4=D0=B0=D1=87=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java index c8744d2..712b420 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java @@ -168,9 +168,9 @@ private void generateTaskName() { String.format( "%s %s:%s/%s (#%d)", scriptName, - params.get("serverName"), - params.get("managerPort"), - params.get("infobase"), + params.get("v8serverName"), + params.get("v8managerPort"), + params.get("v8infobase"), taskNumber); } } From 075be0fa898b7e2cca88f66a652256143265490a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Mon, 29 Apr 2024 13:17:16 +0300 Subject: [PATCH 57/70] =?UTF-8?q?=D0=94=D0=BE=D0=BD=D0=B0=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ru/yanygin/clusterAdminLibrary/Helper.java | 2 ++ .../clusterAdminLibraryUI/AboutDialog.java | 4 ++-- .../yanygin/clusterAdminLibraryUI/ViewerArea.java | 14 ++++++++++++++ .../clusterAdminLibraryUI/messages.properties | 3 ++- .../messages_ru_RU.properties | 1 + .../src/main/resources/icons/Rouble.png | Bin 0 -> 711 bytes 6 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 clusterAdminLibrary/src/main/resources/icons/Rouble.png diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java index b6a7ba5..e04908b 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Helper.java @@ -28,6 +28,8 @@ public class Helper { public static final UUID EMPTY_UUID = UUID.fromString("00000000-0000-0000-0000-000000000000"); //$NON-NLS-1$ + public static final String BOOSTY_LINK = "https://boosty.to/YanSergeyCoder"; + private Helper() {} /** diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/AboutDialog.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/AboutDialog.java index f58253c..b744585 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/AboutDialog.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/AboutDialog.java @@ -17,6 +17,7 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.wb.swt.SWTResourceManager; import ru.yanygin.clusterAdminLibrary.Config; +import ru.yanygin.clusterAdminLibrary.Helper; /** Диалог "О программе". */ public class AboutDialog extends Dialog { @@ -26,7 +27,6 @@ public class AboutDialog extends Dialog { "https://github.com/YanSergey/OneS_ClusterAdmin"; //$NON-NLS-1$ private static final String TELEGRAM_LINK = "https://t.me/YanSergey"; //$NON-NLS-1$ private static final String EMAIL_LINK = "mailto:yanyginsa@gmail.com"; //$NON-NLS-1$ - private static final String BOOSTY_LINK = "https://boosty.to/YanSergeyCoder"; // $NON-NLS-1$ Config config = Config.currentConfig; @@ -172,7 +172,7 @@ private static class Strings { static final String EMAIL_DESCRIPTION = String.format(getString("Email_Description"), EMAIL_LINK); static final String BOOSTY_DESCRIPTION = - String.format(getString("Boosty_Description"), BOOSTY_LINK); + String.format(getString("Boosty_Description"), Helper.BOOSTY_LINK); static String getString(String key) { return Messages.getString("AboutDialog." + key); //$NON-NLS-1$ diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java index 8e03274..332fb72 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java @@ -40,6 +40,7 @@ import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.program.Program; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; @@ -121,6 +122,7 @@ public class ViewerArea extends Composite { Image sortIcon; Image moveUpIcon; Image moveDownIcon; + Image roubleIcon; Tree serversTree; TreeItem currentTreeItem; @@ -349,6 +351,8 @@ private void initIcon() { moveUpIcon = Helper.getImage("move_up.png"); //$NON-NLS-1$ moveDownIcon = Helper.getImage("move_down.png"); //$NON-NLS-1$ + roubleIcon = Helper.getImage("Rouble.png"); // $NON-NLS-1$ + LOGGER.debug("Icon init succesfully"); //$NON-NLS-1$ } @@ -396,6 +400,15 @@ private void initMainMenu(Menu mainMenu) { Menu serviceGroup = addItemGroupInMenu(mainMenu, Strings.MENU_SERVICE, null); addItemInMenu(serviceGroup, Strings.MENU_OPEN_SETTINGS, null, openSettingsListener); addItemInMenu(serviceGroup, Strings.MENU_ABOUT, null, showAboutDialogListener); + + SelectionAdapter goToLinkListener = + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + Program.launch(Helper.BOOSTY_LINK); + } + }; + addItemInMenu(serviceGroup, Strings.MENU_DONATE, roubleIcon, goToLinkListener); } private void initServersTree(SashForm sashForm) { @@ -3276,6 +3289,7 @@ private static class Strings { static final String MENU_SERVICE = getString("MainMenu.Service"); static final String MENU_OPEN_SETTINGS = getString("MainMenu.OpenSettings"); static final String MENU_ABOUT = getString("MainMenu.About"); + static final String MENU_DONATE = getString("MainMenu.Donate"); static final String COLUMN_SERVER = getString("ColumnServer"); static final String TREE_INFOBASES_COUNT = getString("InfobasesCount"); diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties index 9c98e6d..25fd1e8 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties @@ -3,7 +3,7 @@ #Sun Apr 17 15:13:55 MSK 2022 AboutDialog.Autor = Autor:\r\nYanygin Sergey (Tula) -AboutDialog.Boosty_Description = Support the project on Boosty:\r\n%s +AboutDialog.Boosty_Description = Donate to the project on Boosty:\r\n%s AboutDialog.CurrentVersion = version %s AboutDialog.CurrentVersionIsLatest = (the latest version is installed) AboutDialog.CurrentVersionIsOld = (latest version is %s, download) @@ -193,6 +193,7 @@ ViewerArea.InfobasesCount = Infobases (%s) ViewerArea.MainMenu.About = About ViewerArea.MainMenu.ConnectAllServers = Connect to all servers ViewerArea.MainMenu.DisonnectAllServers = Disconnect from all servers +ViewerArea.MainMenu.Donate = Donate to the project ViewerArea.MainMenu.FindServers = Find Servers ViewerArea.MainMenu.OpenSettings = Settings ViewerArea.MainMenu.Servers = Servers diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties index fb44054..64c55a9 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties @@ -193,6 +193,7 @@ ViewerArea.InfobasesCount = \u0418\u043D\u0444\u04 ViewerArea.MainMenu.About = \u041E \u043F\u0440\u043E\u0433\u0440\u0430\u043C\u043C\u0435 ViewerArea.MainMenu.ConnectAllServers = \u041F\u043E\u0434\u043A\u043B\u044E\u0447\u0438\u0442\u044C\u0441\u044F \u043A\u043E \u0432\u0441\u0435\u043C \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u043C ViewerArea.MainMenu.DisonnectAllServers = \u041E\u0442\u043A\u043B\u044E\u0447\u0438\u0442\u044C\u0441\u044F \u043E\u0442 \u0432\u0441\u0435\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u043E\u0432 +ViewerArea.MainMenu.Donate = \u041F\u043E\u0434\u0434\u0435\u0440\u0436\u0430\u0442\u044C \u043F\u0440\u043E\u0435\u043A\u0442 ViewerArea.MainMenu.FindServers = \u041D\u0430\u0439\u0442\u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 ViewerArea.MainMenu.OpenSettings = \u041D\u0430\u0441\u0442\u0440\u043E\u0439\u043A\u0438 ViewerArea.MainMenu.Servers = \u0421\u0435\u0440\u0432\u0435\u0440\u0430 diff --git a/clusterAdminLibrary/src/main/resources/icons/Rouble.png b/clusterAdminLibrary/src/main/resources/icons/Rouble.png new file mode 100644 index 0000000000000000000000000000000000000000..39fb4200c562482edf310a4f6c69f7b3f62272ae GIT binary patch literal 711 zcmV;&0yzDNP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!~g&e!~vBn4jTXf0$fQ%K~y+TZIew% zRACf`pL=I&bY{vaC(AMtD^SG#C?qOcWHbdq%i1V}tCnq|pfHFaH!gzOxUgs=L~Y6n zglZAhCWL4aQ3Qin{!ofCHI9D0=iWQkgfDz>zw@2<{JiH}k7eM7NE2r>K6Qa%k#S1o zy%Wp^_kU0kz&#1u@5u;77HQ@u(EbyKp13HhqW zKpDPT3Vg*eZny_UhIRT?QZcJW_V3W@{ zNxBR3WM;JORz=J*mSLHV{G03EF@Bio|DUN^0Xj6_E}cEWsDcL(7u2)0s?7SCH0%%+ t0m{&ZRcle|HD_rrNNoie3-qc0`~gBlz_H=C$rb Date: Mon, 29 Apr 2024 13:38:03 +0300 Subject: [PATCH 58/70] =?UTF-8?q?=D0=A3=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BF=D1=83=D0=BD=D0=BA=D1=82=D0=B0=20=D0=B8?= =?UTF-8?q?=D0=B7=20=D0=BC=D0=B5=D0=BD=D1=8E=20=D1=81=D0=B5=D1=80=D0=B2?= =?UTF-8?q?=D0=B5=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java index 67f9513..b8d4bdb 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java @@ -495,8 +495,6 @@ private void initServerMenu() { addItemInMenu( serverMenu, Strings.CONTEXT_MENU_REMOVE_SERVER, deleteIcon16, deleteServerListener); - // TODO это для отладки без запуска сервера - удалить - new UserScriptRunner(serverMenu); } private void initClusterMenu() { From 4cbfb537d30ef80e76f31f51eeef48b573adee3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Mon, 29 Apr 2024 14:11:19 +0300 Subject: [PATCH 59/70] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20SAVE=20=D0=BD=D0=B0=20DUMP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yanygin/clusterAdminLibrary/BackgroundTask.java | 12 ++++++------ .../ru/yanygin/clusterAdminLibraryUI/ViewerArea.java | 8 ++++---- .../clusterAdminLibraryUI/messages.properties | 4 ++-- .../clusterAdminLibraryUI/messages_ru_RU.properties | 4 ++-- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java index 712b420..cb39f81 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java @@ -73,9 +73,9 @@ public enum V8ActionVariant { RUN_DESIGNER, RUN_ENTERPRISE, LOAD_CF, - SAVE_CF, + DUMP_CF, LOAD_DT, - SAVE_DT + DUMP_DT } Thread thread; @@ -123,7 +123,7 @@ public BackgroundTask(V8ActionVariant v8ActionVariant) { final String v8Command; switch (v8ActionVariant) { - case SAVE_CF: + case DUMP_CF: this.fileExtension = ".cf"; v8Command = String.join(" ", "/DumpCfg", FILEPATH_PARAM_KEY); break; @@ -131,7 +131,7 @@ public BackgroundTask(V8ActionVariant v8ActionVariant) { this.fileExtension = ".cf"; v8Command = String.join(" ", "/LoadCfg", FILEPATH_PARAM_KEY); break; - case SAVE_DT: + case DUMP_DT: this.fileExtension = ".dt"; v8Command = String.join(" ", "/DumpIB", FILEPATH_PARAM_KEY); break; @@ -195,9 +195,9 @@ public String getFilenameFilterExt() { return "*".concat(fileExtension); } - /** Получить строку для фильтра выбора файла. */ + /** Определяет поведение диалога выбора файла (сохранение или открытие). */ public boolean isSaveCommand() { - return v8ActionVariant == V8ActionVariant.SAVE_CF || v8ActionVariant == V8ActionVariant.SAVE_DT; + return v8ActionVariant == V8ActionVariant.DUMP_CF || v8ActionVariant == V8ActionVariant.DUMP_DT; } /** diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java index b8d4bdb..007db37 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java @@ -621,11 +621,11 @@ private void initInfobaseMenu() { addItemInMenu(subMenuInfobaseActions, Strings.CONTEXT_MENU_RUN_DESIGNER, null, launchV8ActionListener, V8ActionVariant.RUN_DESIGNER); addMenuSeparator(subMenuInfobaseActions); - addItemInMenu(subMenuInfobaseActions, Strings.CONTEXT_MENU_SAVE_CF, null, launchV8ActionListener, V8ActionVariant.SAVE_CF); + addItemInMenu(subMenuInfobaseActions, Strings.CONTEXT_MENU_DUMP_CF, null, launchV8ActionListener, V8ActionVariant.DUMP_CF); addItemInMenu(subMenuInfobaseActions, Strings.CONTEXT_MENU_LOAD_CF, null, launchV8ActionListener, V8ActionVariant.LOAD_CF); addMenuSeparator(subMenuInfobaseActions); - addItemInMenu(subMenuInfobaseActions, Strings.CONTEXT_MENU_SAVE_DT, null, launchV8ActionListener, V8ActionVariant.SAVE_DT); + addItemInMenu(subMenuInfobaseActions, Strings.CONTEXT_MENU_DUMP_DT, null, launchV8ActionListener, V8ActionVariant.DUMP_DT); addItemInMenu(subMenuInfobaseActions, Strings.CONTEXT_MENU_LOAD_DT, null, launchV8ActionListener, V8ActionVariant.LOAD_DT); } @@ -3377,9 +3377,9 @@ private static class Strings { static final String CONTEXT_MENU_INFOBASE_ACTIONS = getString("ContextMenu.InfobaseActions.Group"); static final String CONTEXT_MENU_RUN_DESIGNER = getString("ContextMenu.InfobaseActions.RunDesigner"); static final String CONTEXT_MENU_RUN_ENTERPRISE = getString("ContextMenu.InfobaseActions.RunEnterprise"); - static final String CONTEXT_MENU_SAVE_CF = getString("ContextMenu.InfobaseActions.SaveCf"); + static final String CONTEXT_MENU_DUMP_CF = getString("ContextMenu.InfobaseActions.DumpCf"); static final String CONTEXT_MENU_LOAD_CF = getString("ContextMenu.InfobaseActions.LoadCf"); - static final String CONTEXT_MENU_SAVE_DT = getString("ContextMenu.InfobaseActions.SaveDt"); + static final String CONTEXT_MENU_DUMP_DT = getString("ContextMenu.InfobaseActions.DumpDt"); static final String CONTEXT_MENU_LOAD_DT = getString("ContextMenu.InfobaseActions.LoadDt"); static String getString(String key) { diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties index 7a6372d..a3b554e 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties @@ -165,13 +165,13 @@ ViewerArea.ContextMenu.EditCluster = Edit cluster ViewerArea.ContextMenu.EditInfobase = Edit infobase ViewerArea.ContextMenu.EditServer = Edit server ViewerArea.ContextMenu.EditWorkingServer = Edit working server +ViewerArea.ContextMenu.InfobaseActions.DumpCf = Dump CF +ViewerArea.ContextMenu.InfobaseActions.DumpDt = Dump DT ViewerArea.ContextMenu.InfobaseActions.Group = Actions with the infobase ViewerArea.ContextMenu.InfobaseActions.LoadCf = Load CF ViewerArea.ContextMenu.InfobaseActions.LoadDt = Load DT ViewerArea.ContextMenu.InfobaseActions.RunDesigner = Designer ViewerArea.ContextMenu.InfobaseActions.RunEnterprise = Enterprise -ViewerArea.ContextMenu.InfobaseActions.SaveCf = Save CF -ViewerArea.ContextMenu.InfobaseActions.SaveDt = Save DT ViewerArea.ContextMenu.KillConnection = Kill connection ViewerArea.ContextMenu.KillSession = Kill session ViewerArea.ContextMenu.LockSessionsNow = Lock sessions now diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties index fb1a02e..b244351 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties @@ -165,13 +165,13 @@ ViewerArea.ContextMenu.EditCluster = \u0420\u0435\u0434\u04 ViewerArea.ContextMenu.EditInfobase = \u0420\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u0438\u043D\u0444\u043E\u0431\u0430\u0437\u0443 ViewerArea.ContextMenu.EditServer = \u0420\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u0441\u0435\u0440\u0432\u0435\u0440 ViewerArea.ContextMenu.EditWorkingServer = \u0420\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u0440\u0430\u0431\u043E\u0447\u0438\u0439 \u0441\u0435\u0440\u0432\u0435\u0440 +ViewerArea.ContextMenu.InfobaseActions.DumpCf = \u0412\u044B\u0433\u0440\u0443\u0437\u0438\u0442\u044C CF +ViewerArea.ContextMenu.InfobaseActions.DumpDt = \u0412\u044B\u0433\u0440\u0443\u0437\u0438\u0442\u044C DT ViewerArea.ContextMenu.InfobaseActions.Group = \u0414\u0435\u0439\u0441\u0442\u0432\u0438\u044F \u0441 \u0431\u0430\u0437\u043E\u0439 ViewerArea.ContextMenu.InfobaseActions.LoadCf = \u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C CF ViewerArea.ContextMenu.InfobaseActions.LoadDt = \u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C DT ViewerArea.ContextMenu.InfobaseActions.RunDesigner = \u041A\u043E\u043D\u0444\u0438\u0433\u0443\u0440\u0430\u0442\u043E\u0440 ViewerArea.ContextMenu.InfobaseActions.RunEnterprise = \u041F\u0440\u0435\u0434\u043F\u0440\u0438\u044F\u0442\u0438\u0435 -ViewerArea.ContextMenu.InfobaseActions.SaveCf = \u0421\u043E\u0445\u0440\u0430\u043D\u0438\u0442\u044C CF -ViewerArea.ContextMenu.InfobaseActions.SaveDt = \u0421\u043E\u0445\u0440\u0430\u043D\u0438\u0442\u044C DT ViewerArea.ContextMenu.KillConnection = \u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0441\u043E\u0435\u0434\u0438\u043D\u0435\u043D\u0438\u0435 ViewerArea.ContextMenu.KillSession = \u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0441\u0435\u0430\u043D\u0441 ViewerArea.ContextMenu.LockSessionsNow = \u041D\u0435\u043C\u0435\u0434\u043B\u0435\u043D\u043D\u043E \u0437\u0430\u0431\u043B\u043E\u043A\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u0441\u0435\u0430\u043D\u0441\u044B From 286d72f91d96b4ad1eb5d338cad886a6b577c801 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Mon, 29 Apr 2024 19:38:09 +0300 Subject: [PATCH 60/70] =?UTF-8?q?=D0=97=D0=B0=D0=BF=D1=83=D1=81=D0=BA=20?= =?UTF-8?q?=D1=8F=D0=B2=D0=BD=D1=8B=D0=BC=20=D1=83=D0=BA=D0=B0=D0=B7=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=D0=BC=20=D0=B2=D0=B5=D1=80=D1=81=D0=B8=D0=B8?= =?UTF-8?q?=20=D0=B2=D0=BC=D0=B5=D1=81=D1=82=D0=BE=20=D1=81=D1=82=D0=B0?= =?UTF-8?q?=D1=80=D1=82=D0=B5=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java index cb39f81..93c79e2 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java @@ -22,7 +22,7 @@ public class BackgroundTask { static final Logger LOGGER = LoggerFactory.getLogger(BackgroundTask.class.getSimpleName()); - static final String starterPath = "\"C:\\Program Files\\1cv8\\common\\1cestart.exe\""; + static final String starterPath = "\"C:\\Program Files\\1cv8\\%v8version%\\bin\\1cv8.exe\""; static final String designerCommand = "DESIGNER"; static final String enterpriseCommand = "ENTERPRISE"; static final String logonCommand = From 83d572ea62faf99c4c359dca5b34c5ebc09e4aa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Tue, 30 Apr 2024 20:32:25 +0300 Subject: [PATCH 61/70] =?UTF-8?q?=D0=97=D0=B0=D0=BF=D1=80=D0=BE=D1=81=20?= =?UTF-8?q?=D0=BB=D0=BE=D0=B3=D0=B8=D0=BD=D0=B0=20=D0=B2=20=D0=BD=D0=B0?= =?UTF-8?q?=D1=81=D1=82=D1=80=D0=BE=D0=B9=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../clusterAdminLibrary/BackgroundTask.java | 9 +++++--- .../yanygin/clusterAdminLibrary/Config.java | 22 +++++++++++++++++++ .../clusterAdminLibraryUI/SettingsDialog.java | 10 +++++++++ .../clusterAdminLibraryUI/messages.properties | 1 + .../messages_ru_RU.properties | 1 + 5 files changed, 40 insertions(+), 3 deletions(-) diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java index 93c79e2..8ae2316 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BackgroundTask.java @@ -25,8 +25,8 @@ public class BackgroundTask { static final String starterPath = "\"C:\\Program Files\\1cv8\\%v8version%\\bin\\1cv8.exe\""; static final String designerCommand = "DESIGNER"; static final String enterpriseCommand = "ENTERPRISE"; - static final String logonCommand = - "/S%v8serverName%:%v8managerPort%\\%v8infobase% /N%v8username% /P%v8password%"; + static final String infobasePath = "/S%v8serverName%:%v8managerPort%\\%v8infobase%"; + static final String logonCommand = "/N%v8username% /P%v8password%"; static final String FILEPATH_PARAM_KEY = "%v8FilePath%"; static int countOfRunning = 0; @@ -144,12 +144,15 @@ public BackgroundTask(V8ActionVariant v8ActionVariant) { break; } + boolean logonEnabled = Config.currentConfig.getRequestLogon(); + this.scriptText = String.join( " ", starterPath, launchMode, - logonCommand, + infobasePath, + logonEnabled ? logonCommand : "", v8Command); this.scriptName = v8ActionVariant.toString(); diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java index 2d692c4..2061777 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java @@ -131,6 +131,10 @@ public class Config { @Expose private String loggerLevel = "error"; + @SerializedName("RequestLogon") + @Expose + private boolean requestLogon = false; + @SerializedName("Servers") @Expose private Map servers = new HashMap<>(); @@ -907,6 +911,24 @@ public void setListRrefreshRate(int refreshRate) { this.listRefreshRate = refreshRate; } + /** + * Запрашивать логин/пароль при действиях с базой. + * + * @return запрашивать или нет + */ + public boolean getRequestLogon() { + return requestLogon; + } + + /** + * Установка запроса логин/пароля при действиях с базой. + * + * @param requestLogon - запрашивать логин/пароль + */ + public void setRequestLogon(boolean requestLogon) { + this.requestLogon = requestLogon; + } + /** * Получение свойства колонок списков. * diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/SettingsDialog.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/SettingsDialog.java index d5e974a..237e41f 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/SettingsDialog.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/SettingsDialog.java @@ -52,6 +52,7 @@ public class SettingsDialog extends Dialog { private Button btnLoggerLevelWarning; private Button btnLoggerLevelInfo; private Button btnLoggerLevelDebug; + private Button btnRequestLogon; private static final String LOCALE_RU = "ru-RU"; //$NON-NLS-1$ @@ -235,6 +236,9 @@ protected Control createDialogArea(Composite parent) { btnCheckUpdate = new Button(grpOther, SWT.CHECK); btnCheckUpdate.setText(Strings.CHECK_UPDATE); + + btnRequestLogon = new Button(grpOther, SWT.CHECK); + btnRequestLogon.setText(Strings.REQUEST_LOGON); new Label(container, SWT.NONE); initProperties(); @@ -283,6 +287,8 @@ private void initProperties() { btnLoggerLevelWarning.setSelection(loggerLevel.equals(btnLoggerLevelWarning.getText())); btnLoggerLevelInfo.setSelection(loggerLevel.equals(btnLoggerLevelInfo.getText())); btnLoggerLevelDebug.setSelection(loggerLevel.equals(btnLoggerLevelDebug.getText())); + + btnRequestLogon.setSelection(config.getRequestLogon()); } private void saveProperties() { @@ -340,6 +346,8 @@ private void saveProperties() { loggerLevel = btnLoggerLevelOff.getText(); } config.setLoggerLevel(loggerLevel); + + config.setRequestLogon(btnRequestLogon.getSelection()); } /** @@ -405,6 +413,8 @@ private static class Strings { static final String LOGGER_LEVEL_TITLE = getString("LoggerLevelTitle"); + static final String REQUEST_LOGON = getString("RequestLogon"); + static String getString(String key) { return Messages.getString("SettingsDialog." + key); //$NON-NLS-1$ } diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties index a3b554e..bc0f5be 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties @@ -126,6 +126,7 @@ SettingsDialog.LocaleSystem = System SettingsDialog.LocaleTitle = Locale (need restart) SettingsDialog.LoggerLevelTitle = Logger level SettingsDialog.ReadClipboard = Read clipboard (when adding server) +SettingsDialog.RequestLogon = Request a username when working with the infobase SettingsDialog.RowSortDirectionAsPrevious = As previous SettingsDialog.RowSortDirectionAscending = Descending SettingsDialog.RowSortDirectionDescending = Ascending diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties index b244351..3b3c1fb 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties @@ -126,6 +126,7 @@ SettingsDialog.LocaleSystem = \u0421\u0438\u0441\u0442\u0435\u043C SettingsDialog.LocaleTitle = \u042F\u0437\u044B\u043A \u0438\u043D\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 (\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044F \u043F\u0435\u0440\u0435\u0437\u0430\u043F\u0443\u0441\u043A) SettingsDialog.LoggerLevelTitle = \u0423\u0440\u043E\u0432\u0435\u043D\u044C \u043B\u043E\u0433\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u044F SettingsDialog.ReadClipboard = \u0427\u0438\u0442\u0430\u0442\u044C \u0431\u0443\u0444\u0435\u0440 \u043E\u0431\u043C\u0435\u043D\u0430 (\u043F\u0440\u0438 \u0434\u043E\u0431\u0430\u0432\u043B\u0435\u043D\u0438\u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430) +SettingsDialog.RequestLogon = \u0417\u0430\u043F\u0440\u0430\u0448\u0438\u0432\u0430\u0442\u044C \u043B\u043E\u0433\u0438\u043D \u043F\u0440\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044F\u0445 \u0441 \u0438\u043D\u0444\u043E\u0431\u0430\u0437\u043E\u0439 SettingsDialog.RowSortDirectionAsPrevious = \u041A\u0430\u043A \u043F\u0440\u0435\u0434\u044B\u0434\u0443\u0449\u0430\u044F SettingsDialog.RowSortDirectionAscending = \u041F\u043E \u0443\u0431\u044B\u0432\u0430\u043D\u0438\u044E SettingsDialog.RowSortDirectionDescending = \u041F\u043E \u0432\u043E\u0437\u0440\u0430\u0441\u0442\u0430\u043D\u0438\u044E From 05f6c4f49926a3e6f29b202c5688380c4461dfa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Wed, 1 May 2024 14:29:27 +0300 Subject: [PATCH 62/70] =?UTF-8?q?=D0=94=D0=BE=D0=BD=D0=B0=D1=82=20=D0=BD?= =?UTF-8?q?=D0=B0=20=D0=B3=D0=BB=D0=B0=D0=B2=D0=BD=D0=BE=D0=B9=20=D1=81?= =?UTF-8?q?=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=86=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index e33fbdd..505f878 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,9 @@ ## Утилита для интерактивного администрирования серверов 1С +![Donate](/clusterAdminLibrary/src/main/resources/icons/Rouble.png) +Поддержать проект https://boosty.to/YanSergeyCoder + Статья с описанием возможностей утилиты на Infostart https://infostart.ru/public/1489055/ Разработка ведется в `Eclipse IDE for Java Developers` From c4989ff321335960710d13d506b3d55d26521bf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Sun, 5 May 2024 11:24:12 +0300 Subject: [PATCH 63/70] =?UTF-8?q?=D0=91=D0=B5=D0=BA=D0=B0=D0=BF=20=D0=BA?= =?UTF-8?q?=D0=BE=D0=BD=D1=84=D0=B8=D0=B3=D0=B0=20=D0=BF=D1=80=D0=B8=20?= =?UTF-8?q?=D0=BC=D0=B8=D0=B3=D1=80=D0=B0=D1=86=D0=B8=D0=B8=20=D1=81=D0=BE?= =?UTF-8?q?=20=D1=81=D1=82=D0=B0=D1=80=D0=BE=D0=B9=20=D0=B2=D0=B5=D1=80?= =?UTF-8?q?=D1=81=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ru/yanygin/clusterAdminLibrary/Config.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java index 2d692c4..aaf4cf8 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java @@ -20,6 +20,9 @@ import java.net.HttpURLConnection; import java.net.URL; import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardCopyOption; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -216,6 +219,20 @@ public void init() { /** Миграция настроек из конфига предыдущей версии. */ public void migrateProps() { + if (!currentVersion.toString().equals(configVersion)) { + // делаем бекап конфига + String configCopy = configPath + "_bak"; + File configFile = new File(configPath); + if (configFile.exists()) { + try { + Files.copy(Path.of(configPath), Path.of(configCopy), StandardCopyOption.REPLACE_EXISTING); + } catch (IOException e) { + LOGGER.error("Config file backup error:", e); + } + } + configVersion = currentVersion.toString(); + } + if (configVersion == null) { configVersion = "0.2.0"; servers.forEach((key, server) -> server.migrateProps(configVersion)); From f1df48f6ff382d0092b5a086b80cef3b96929019 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Sun, 5 May 2024 17:03:08 +0300 Subject: [PATCH 64/70] =?UTF-8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=BA=D0=B0=20?= =?UTF-8?q?=D0=B2=D0=B5=D1=80=D1=81=D0=B8=D0=B9=20=D0=B1=D0=B8=D0=B1=D0=BB?= =?UTF-8?q?=D0=B8=D0=BE=D1=82=D0=B5=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- clusterAdminApplication/pom.xml | 12 ++++++------ clusterAdminLibrary/pom.xml | 19 ++++++++++--------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/clusterAdminApplication/pom.xml b/clusterAdminApplication/pom.xml index 2e57bbf..e531fa4 100644 --- a/clusterAdminApplication/pom.xml +++ b/clusterAdminApplication/pom.xml @@ -86,20 +86,20 @@ org.slf4j slf4j-api - 1.7.30 + 2.0.13 ch.qos.logback logback-classic - 1.2.3 + 1.5.6 ch.qos.logback logback-core - 1.2.3 + 1.5.6 @@ -107,21 +107,21 @@ org.eclipse.platform ${swt.artifactId} - 3.116.0 + 3.120.0 org.eclipse.platform org.eclipse.jface - 3.22.0 + 3.22.100 com.google.code.gson gson - 2.8.6 + 2.10.1 diff --git a/clusterAdminLibrary/pom.xml b/clusterAdminLibrary/pom.xml index 9f3d2ed..06da5e9 100644 --- a/clusterAdminLibrary/pom.xml +++ b/clusterAdminLibrary/pom.xml @@ -87,14 +87,14 @@ org.eclipse.platform ${swt.artifactId} - 3.125.0 + 3.120.0 org.eclipse.platform org.eclipse.swt - 3.125.0 + 3.120.0 @@ -109,35 +109,36 @@ org.slf4j slf4j-api - 1.7.36 + 2.0.13 - + ch.qos.logback logback-classic - 1.2.13 + 1.5.6 + ch.qos.logback logback-core - 1.2.13 + 1.5.6 org.eclipse.platform org.eclipse.core.commands - 3.12.0 + 3.10.400 org.eclipse.platform org.eclipse.equinox.common - 3.19.0 + 3.18.200 @@ -162,7 +163,7 @@ org.eclipse.platform org.eclipse.jface - 3.33.0 + 3.22.100 From 8e0f58f10c51b9758ab0a48803a8353c031feacb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Thu, 9 May 2024 13:22:17 +0300 Subject: [PATCH 65/70] =?UTF-8?q?=D0=BE=D1=82=D0=BA=D0=B0=D1=82=20equinox?= =?UTF-8?q?=20=D0=BA=203.14.100?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- clusterAdminLibrary/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clusterAdminLibrary/pom.xml b/clusterAdminLibrary/pom.xml index 06da5e9..1d9cfe6 100644 --- a/clusterAdminLibrary/pom.xml +++ b/clusterAdminLibrary/pom.xml @@ -138,7 +138,7 @@ org.eclipse.platform org.eclipse.equinox.common - 3.18.200 + 3.14.100 From 816e1d587c91fd9add4ffeba5bb5295b160fde60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Thu, 9 May 2024 13:23:31 +0300 Subject: [PATCH 66/70] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA?= =?UTF-8?q?=D0=B8=20=D0=B2=20=D0=BC=D0=B8=D0=B3=D1=80=D0=B0=D1=86=D0=B8?= =?UTF-8?q?=D0=B8=20=D0=BA=D0=BE=D0=BD=D1=84=D0=B8=D0=B3=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/ru/yanygin/clusterAdminLibrary/Config.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java index aaf4cf8..700b0c6 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java @@ -219,6 +219,11 @@ public void init() { /** Миграция настроек из конфига предыдущей версии. */ public void migrateProps() { + if (configVersion == null) { + configVersion = "0.2.0"; + servers.forEach((key, server) -> server.migrateProps(configVersion)); + } + if (!currentVersion.toString().equals(configVersion)) { // делаем бекап конфига String configCopy = configPath + "_bak"; @@ -230,14 +235,9 @@ public void migrateProps() { LOGGER.error("Config file backup error:", e); } } - configVersion = currentVersion.toString(); } - if (configVersion == null) { - configVersion = "0.2.0"; - servers.forEach((key, server) -> server.migrateProps(configVersion)); - configVersion = currentVersion.toString(); - } + configVersion = currentVersion.toString(); } private OsType getOperatingSystemType() { From a26d9b497edc5e5b11cfec1a618b31cdbb11d270 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Fri, 10 May 2024 10:29:27 +0300 Subject: [PATCH 67/70] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA?= =?UTF-8?q?=D0=B8=20=D1=81=D1=80=D0=B0=D0=B2=D0=BD=D0=B5=D0=BD=D0=B8=D1=8F?= =?UTF-8?q?=20=D0=B4=D0=B0=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/ru/yanygin/clusterAdminLibrary/BaseInfoExtended.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BaseInfoExtended.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BaseInfoExtended.java index 64ed60e..d168ffb 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BaseInfoExtended.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/BaseInfoExtended.java @@ -174,6 +174,9 @@ public int compareTo(BaseInfoExtended o) { break; case DATE: + compareResult = ((Date) left).compareTo((Date) right); + break; + case TEXT: default: compareResult = From 541e45484fc826e887451d91d746cce1c0abbf00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Fri, 10 May 2024 11:03:08 +0300 Subject: [PATCH 68/70] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA?= =?UTF-8?q?=D0=B8=20=D0=BE=D1=82=D0=BA=D0=BB=D1=8E=D1=87=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=20=D0=BE=D1=82=20=D1=81=D0=B5=D1=80=D0=B2=D0=B5=D1=80?= =?UTF-8?q?=D0=B0=20=D0=BF=D1=80=D0=B8=20=D1=81=D0=BC=D0=B5=D0=BD=D0=B5=20?= =?UTF-8?q?=D0=B2=D0=B0=D1=80=D0=B8=D0=B0=D0=BD=D1=82=D0=B0=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=B4=D0=BA=D0=BB=D1=8E=D1=87=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/ru/yanygin/clusterAdminLibrary/Server.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java index dd82211..1946e0a 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Server.java @@ -1099,10 +1099,11 @@ public void disconnectFromAgent() { } private void disconnectLocalRas() { - if (useLocalRas && localRasProcess.isAlive()) { + if (localRasProcess != null && localRasProcess.isAlive()) { Stream ch = localRasProcess.children(); ch.forEach(ProcessHandle::destroy); localRasProcess.destroy(); + localRasProcess = null; LOGGER.info( "Local RAS of Server <{}> is shutdown now", //$NON-NLS-1$ this.getServerKey()); From 9cbb96d6ac58ef86315bdda71e152ca5bbcb4d0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Sat, 18 May 2024 19:53:23 +0300 Subject: [PATCH 69/70] =?UTF-8?q?=D0=9E=D1=82=D0=BC=D0=B5=D0=BD=D0=B0=20?= =?UTF-8?q?=D0=BF=D0=B5=D1=80=D0=B5=D0=B7=D0=B0=D0=BF=D1=83=D1=81=D0=BA?= =?UTF-8?q?=D0=B0=20=D0=BF=D1=80=D0=B8=20=D0=BD=D0=B5=D1=83=D0=B4=D0=B0?= =?UTF-8?q?=D1=87=D0=BD=D0=BE=D0=B9=20=D0=B0=D1=83=D1=82=D0=B5=D0=BD=D1=82?= =?UTF-8?q?=D0=B8=D1=84=D0=B8=D0=BA=D0=B0=D1=86=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java | 7 ++++++- .../ru/yanygin/clusterAdminLibraryUI/messages.properties | 1 + .../clusterAdminLibraryUI/messages_ru_RU.properties | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java index e59f5ad..f8f4f6d 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/ViewerArea.java @@ -2113,7 +2113,10 @@ public void widgetSelected(SelectionEvent event) { return; } - server.checkAutenticateAgent(); + if (!server.checkAutenticateAgent()) { + Helper.showMessageBox(Strings.ERROR_AUTH_FOR_RESTART_WP); + return; + } Thread thread = new Thread( @@ -3406,6 +3409,8 @@ private static class Strings { static final String CONTEXT_MENU_KILL_CONNECTION_DEL = getString("ContextMenu.KillConnection").concat("\tDEL"); + static final String ERROR_AUTH_FOR_RESTART_WP = getString("ErrorAuthForRestartWp"); + static String getString(String key) { return Messages.getString("ViewerArea." + key); //$NON-NLS-1$ } diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties index c3cd2fd..f4484b1 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages.properties @@ -186,6 +186,7 @@ ViewerArea.DedicatedManagers = Dedicated managers ViewerArea.DeleteClusterQuestion = Deleting a cluster will delete its settings and the list of registered information databases. Do you really want to delete the cluster? ViewerArea.DeleteServerQuestion = Do you really want to remove the server from the list? ViewerArea.Description = Description +ViewerArea.ErrorAuthForRestartWp = To restart the working processes, you need to authenticate to the main server ViewerArea.IBPerProcessLimit = IB per process limit ViewerArea.IPPort = IP Port ViewerArea.IPPortMainManager = IP Port main manager diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties index 857c1f0..58e14e0 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibraryUI/messages_ru_RU.properties @@ -186,6 +186,7 @@ ViewerArea.DedicatedManagers = \u041C\u0435\u043D\u04 ViewerArea.DeleteClusterQuestion = \u0423\u0434\u0430\u043B\u0435\u043D\u0438\u0435 \u043A\u043B\u0430\u0441\u0442\u0435\u0440\u0430 \u043F\u0440\u0438\u0432\u0435\u0434\u0435\u0442 \u043A \u0443\u0434\u0430\u043B\u0435\u043D\u0438\u044E \u0435\u0433\u043E \u043D\u0430\u0441\u0442\u0440\u043E\u0435\u043A \u0438 \u0441\u043F\u0438\u0441\u043A\u0430 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043E\u0432\u0430\u043D\u043D\u044B\u0445 \u0438\u043D\u0444\u043E\u0440\u043C\u0430\u0446\u0438\u043E\u043D\u043D\u044B\u0445 \u0431\u0430\u0437. \u0412\u044B \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043B\u044C\u043D\u043E \u0445\u043E\u0442\u0438\u0442\u0435 \u0443\u0434\u0430\u043B\u0438\u0442\u044C \u043A\u043B\u0430\u0441\u0442\u0435\u0440? ViewerArea.DeleteServerQuestion = \u0412\u044B \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043B\u044C\u043D\u043E \u0445\u043E\u0442\u0438\u0442\u0435 \u0443\u0434\u0430\u043B\u0438\u0442\u044C \u0441\u0435\u0440\u0432\u0435\u0440 \u0438\u0437 \u0441\u043F\u0438\u0441\u043A\u0430? ViewerArea.Description = \u041E\u043F\u0438\u0441\u0430\u043D\u0438\u0435 +ViewerArea.ErrorAuthForRestartWp = \u0414\u043B\u044F \u043F\u0435\u0440\u0435\u0437\u0430\u043F\u0443\u0441\u043A\u0430 \u0440\u0430\u0431\u043E\u0447\u0438\u0445 \u043F\u0440\u043E\u0446\u0435\u0441\u0441\u043E\u0432 \u043D\u0435\u043E\u0431\u0445\u043E\u0434\u0438\u043C\u043E \u0432\u044B\u043F\u043E\u043B\u043D\u0438\u0442\u044C \u0430\u0443\u0442\u0435\u043D\u0442\u0438\u0444\u0438\u043A\u0430\u0446\u0438\u044E \u043D\u0430 \u0446\u0435\u043D\u0442\u0440\u0430\u043B\u044C\u043D\u043E\u043C \u0441\u0435\u0440\u0432\u0435\u0440\u0435 ViewerArea.IBPerProcessLimit = \u041A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E \u0418\u0411 \u043D\u0430 \u043F\u0440\u043E\u0446\u0435\u0441\u0441 ViewerArea.IPPort = IP \u043F\u043E\u0440\u0442 ViewerArea.IPPortMainManager = IP \u043F\u043E\u0440\u0442 \u0446\u0435\u043D\u0442\u0440\u0430\u043B\u044C\u043D\u043E\u0433\u043E \u0441\u0435\u0440\u0432\u0435\u0440\u0430 From 7a4e52bbe9f707d86c854f886db3076fefbcdc85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=AF=D0=BD=D1=8B?= =?UTF-8?q?=D0=B3=D0=B8=D0=BD?= Date: Wed, 22 May 2024 11:06:46 +0300 Subject: [PATCH 70/70] =?UTF-8?q?=D0=A3=D1=81=D1=82=D0=B0=D0=BD=D0=BE?= =?UTF-8?q?=D0=B2=D0=BA=D0=B0=20=D0=B2=D0=B5=D1=80=D1=81=D0=B8=D0=B8=200.4?= =?UTF-8?q?.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- clusterAdminApplication/pom.xml | 2 +- clusterAdminLibrary/pom.xml | 2 +- .../src/main/java/ru/yanygin/clusterAdminLibrary/Config.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/clusterAdminApplication/pom.xml b/clusterAdminApplication/pom.xml index e531fa4..36546db 100644 --- a/clusterAdminApplication/pom.xml +++ b/clusterAdminApplication/pom.xml @@ -6,7 +6,7 @@ ru.yanygin ru.yanygin.clusterAdminApplication - 0.4.0.beta1 + 0.4.0 jar diff --git a/clusterAdminLibrary/pom.xml b/clusterAdminLibrary/pom.xml index 1d9cfe6..11a9b87 100644 --- a/clusterAdminLibrary/pom.xml +++ b/clusterAdminLibrary/pom.xml @@ -6,7 +6,7 @@ ru.yanygin ${artifactId} - 0.4.0.beta1-SNAPSHOT + 0.4.0-SNAPSHOT jar diff --git a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java index 3778596..bf248e8 100644 --- a/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java +++ b/clusterAdminLibrary/src/main/java/ru/yanygin/clusterAdminLibrary/Config.java @@ -304,7 +304,7 @@ private Version readCurrentVersion() { // return Version.parse(v); // } - return Version.parse("0.4.0.beta1"); + return Version.parse("0.4.0"); } private void runReadUpstreamVersion() {