Skip to content

Commit

Permalink
Merge pull request #15 from YanSergey/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
YanSergey committed Oct 7, 2021
2 parents cca97dd + 57d5e6d commit 32d0dcd
Show file tree
Hide file tree
Showing 25 changed files with 2,474 additions and 867 deletions.
4 changes: 2 additions & 2 deletions clusterAdminApplication/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>ru.yanygin</groupId>
<artifactId>ru.yanygin.clusterAdminApplication</artifactId>
<version>0.1.1</version>
<version>0.2.0</version>
<packaging>jar</packaging>

<properties>
Expand Down Expand Up @@ -88,7 +88,7 @@
<groupId>ru.yanygin</groupId>
<!-- <artifactId>ru.yanygin.clusterAdminLibrary</artifactId> -->
<artifactId>${clusterAdminLibrary.artifactId}</artifactId>
<version>0.1.1-SNAPSHOT</version>
<version>0.2.0-SNAPSHOT</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
package ru.yanygin.clusterAdminApplication;

import org.eclipse.swt.widgets.Display;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ClusterAdmin {

public static void main (String[] args) {
Logger LOGGER = LoggerFactory.getLogger("ClusterProvider"); //$NON-NLS-1$

try {
ClusterViewer window = new ClusterViewer();
window.setBlockOnOpen(true);
window.open();
Display.getCurrent().dispose();

} catch (Exception e) {
e.printStackTrace();
} catch (Exception excp) {
excp.printStackTrace();
LOGGER.error("Error:", excp); //$NON-NLS-1$
}

}
Expand Down
2 changes: 1 addition & 1 deletion clusterAdminLibrary/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>ru.yanygin</groupId>
<artifactId>${artifactId}</artifactId>
<version>0.1.1-SNAPSHOT</version>
<version>0.2.0-SNAPSHOT</version>
<packaging>jar</packaging>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.UUID;

import org.eclipse.swt.dnd.Clipboard;
import org.eclipse.swt.dnd.TextTransfer;
import org.eclipse.swt.widgets.Display;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -28,8 +30,6 @@
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;

import ru.yanygin.clusterAdminLibrary.Server;

public class ClusterProvider {

File configFile;
Expand Down Expand Up @@ -142,11 +142,27 @@ public void saveConfig() {//String configPath) {
}

public Server createNewServer() {
return getCommonConfig().createNewServer();
Server newServer = null;

if (commonConfig.readClipboard) {
Clipboard clipboard = new Clipboard(Display.getDefault());
String clip = (String)clipboard.getContents(TextTransfer.getInstance());
clipboard.dispose();

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 newServer;
}

public void addNewServer(Server server) {
getCommonConfig().servers.put(server.getServerKey(), server);
commonConfig.servers.put(server.getServerKey(), server);
saveConfig();
}

Expand Down Expand Up @@ -208,7 +224,9 @@ public List<IInfoBaseInfo> getInfobases(Server server){ // not used?
}

public void close() {


saveConfig();

getServers().forEach((server, config) -> {
if (config.isConnected())
config.disconnectFromAgent();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package ru.yanygin.clusterAdminLibrary;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

public class ColumnProperties {

@SerializedName("Order")
@Expose
public int[] order = null;

@SerializedName("Width")
@Expose
public int[] width = null;

@SerializedName("Visible")
@Expose
public boolean[] visible = null;

public ColumnProperties(int size) {

// Порядок столбцов
this.order = new int[size];
for (int i = 0; i < this.order.length; i++)
this.order[i] = i;

// Ширина столбцов
this.width = new int[size];

// Видимость столбцов
this.visible = new boolean[size];
for (int i = 0; i < this.visible.length; i++)
this.visible[i] = true;
}

public void updateColumnProperties(int arraySize) {

// если после десериализации количество не равно текущему
// (например, поменялся состав колонок),
// нужно переложить в новый массив без потерь

// Порядок столбцов
if (order.length != arraySize) {
int[] columnOrderTemp = order;
order = new int[arraySize];
System.arraycopy(columnOrderTemp, 0, order, 0,
Math.min(arraySize, columnOrderTemp.length));

if (arraySize > columnOrderTemp.length)
for (int i = columnOrderTemp.length; i < arraySize; i++)
order[i] = i;
}

// Ширина столбцов
if (width.length != arraySize) {
int[] columnWidthTemp = width;
width = new int[arraySize];
System.arraycopy(columnWidthTemp, 0, width, 0,
Math.min(arraySize, columnWidthTemp.length));
}

// Видимость столбцов
if (visible.length != arraySize) {
boolean[] columnVisibleTemp = visible;
visible = new boolean[arraySize];
System.arraycopy(columnVisibleTemp, 0, visible, 0,
Math.min(arraySize, columnVisibleTemp.length));
if (arraySize > columnVisibleTemp.length)
for (int i = columnVisibleTemp.length; i < arraySize; i++)
visible[i] = true;
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,43 @@ public class Config {
@SerializedName("Locale")
@Expose
public String locale;

@SerializedName("SessionColumnProperties")
@Expose
public ColumnProperties sessionColumnProperties;

@SerializedName("ConnectionColumnProperties")
@Expose
public ColumnProperties connectionColumnProperties;

@SerializedName("LockColumnProperties")
@Expose
public ColumnProperties lockColumnProperties;

@SerializedName("WPColumnProperties")
@Expose
public ColumnProperties wpColumnProperties;

@SerializedName("WSColumnProperties")
@Expose
public ColumnProperties wsColumnProperties;

@SerializedName("ShadowSleepSessions")
@Expose
public boolean shadowSleepSessions;

@SerializedName("HighlightNewItems")
@Expose
public boolean highlightNewItems;

@SerializedName("HighlightNewItemsDuration")
@Expose
public int highlightNewItemsDuration;
@SerializedName("ReadClipboard")
@Expose
public boolean readClipboard;


private static Logger LOGGER = LoggerFactory.getLogger("clusterAdminLibrary"); //$NON-NLS-1$

private OSType currrentOS;
Expand Down Expand Up @@ -102,10 +138,6 @@ private void getOperatingSystemType() {
}
}

public Server createNewServer() {
return new Server("newServerAddress:1541"); //$NON-NLS-1$
}

public List<String> addNewServers(List<String> servers) {
// Пакетное добавление серверов в список, предполагается для механизма импорта из списка информационных баз

Expand All @@ -128,15 +160,11 @@ public List<String> addNewServers(List<String> servers) {
}

public void connectAllServers() {
servers.forEach((server, config) -> {
config.connectAndAuthenticate(false);
});
servers.forEach((serverKey, server) -> server.connectToServer(false, true));
}

public void checkConnectionAllServers() {
servers.forEach((server, config) -> {
config.connectAndAuthenticate(true);
});
servers.forEach((serverKey, server) -> server.connectToServer(true, true));
}

public boolean isWindows() {
Expand All @@ -151,6 +179,85 @@ public boolean isMacOS() {
return currrentOS == OSType.MACOS;
}

public void setSessionsColumnOrder(int[] columnOrder) {
sessionColumnProperties.order = columnOrder;
}

public void setConnectionsColumnOrder(int[] columnOrder) {
connectionColumnProperties.order = columnOrder;
}

public void setLocksColumnOrder(int[] columnOrder) {
lockColumnProperties.order = columnOrder;
}

public void setWorkingProcessesColumnOrder(int[] columnOrder) {
wpColumnProperties.order = columnOrder;
}

public void setWorkingServersColumnOrder(int[] columnOrder) {
wsColumnProperties.order = columnOrder;
}

public void initSessionsColumnCount(int columnCount) {

if (sessionColumnProperties == null)
sessionColumnProperties = new ColumnProperties(columnCount);
else
sessionColumnProperties.updateColumnProperties(columnCount);
}

public void initConnectionsColumnCount(int columnCount) {

if (connectionColumnProperties == null)
connectionColumnProperties = new ColumnProperties(columnCount);
else
connectionColumnProperties.updateColumnProperties(columnCount);
}

public void initLocksColumnCount(int columnCount) {

if (lockColumnProperties == null)
lockColumnProperties = new ColumnProperties(columnCount);
else
lockColumnProperties.updateColumnProperties(columnCount);
}

public void initWorkingProcessesColumnCount(int columnCount) {

if (wpColumnProperties == null)
wpColumnProperties = new ColumnProperties(columnCount);
else
wpColumnProperties.updateColumnProperties(columnCount);
}

public void initWorkingServersColumnCount(int columnCount) {

if (wsColumnProperties == null)
wsColumnProperties = new ColumnProperties(columnCount);
else
wsColumnProperties.updateColumnProperties(columnCount);
}

public void setSessionsColumnWidth(int index, int width) {
sessionColumnProperties.width[index] = width;
}

public void setConnectionsColumnWidth(int index, int width) {
connectionColumnProperties.width[index] = width;
}

public void setLocksColumnWidth(int index, int width) {
lockColumnProperties.width[index] = width;
}

public void setWorkingProcessesColumnWidth(int index, int width) {
wpColumnProperties.width[index] = width;
}

public void setWorkingServersColumnWidth(int index, int width) {
wsColumnProperties.width[index] = width;
}

}

Expand Down

0 comments on commit 32d0dcd

Please sign in to comment.