Skip to content

Commit

Permalink
Updated for Swordfish 4.10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rmraya committed Oct 29, 2021
1 parent d9ba6db commit f61252d
Show file tree
Hide file tree
Showing 10 changed files with 483 additions and 224 deletions.
27 changes: 27 additions & 0 deletions html/spaceAnalysis.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<html lang="en">

<head>
<title id="version">Space Analysis</title>
<link id="theme" rel="stylesheet" type="text/css" href="../css/light.css">
<link rel="stylesheet" type="text/css" href="../css/fonts.css">
</head>

<body id="body">
<div class="divContainer bordered" style="height:250px;">
<table class="fill_width discover stripes" id="table">
<tr>

</tr>
</table>
</div>

<div class="buttonArea">
<button id="goTo">Open Selected Segment</button>
<button id="refresh">Refresh List</button>
</div>
<script src="../js/keyboardHandler.js"></script>
<script src="../js/spaceAnalysis.js"></script>
</body>

</html>
27 changes: 27 additions & 0 deletions html/tagsAnalysis.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<html lang="en">

<head>
<title id="version">Tags Analysis</title>
<link id="theme" rel="stylesheet" type="text/css" href="../css/light.css">
<link rel="stylesheet" type="text/css" href="../css/fonts.css">
</head>

<body id="body">
<div class="divContainer bordered" style="height:250px;">
<table class="fill_width discover stripes" id="table">
<tr>

</tr>
</table>
</div>

<div class="buttonArea">
<button id="goTo">Open Selected Segment</button>
<button id="refresh">Refresh List</button>
</div>
<script src="../js/keyboardHandler.js"></script>
<script src="../js/tagsAnalysis.js"></script>
</body>

</html>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "swordfish",
"productName": "Swordfish",
"version": "4.9.0",
"version": "4.10.0",
"description": "Swordfish Translation Editor",
"main": "js/App.js",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions src/com/maxprograms/swordfish/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ private Constants() {
}

public static final String APPNAME = "Swordfish";
public static final String VERSION = "4.9.0";
public static final String BUILD = "20211022_1011";
public static final String VERSION = "4.10.0";
public static final String BUILD = "20211029_1338";

public static final String REASON = "reason";
public static final String STATUS = "status";
Expand Down
288 changes: 146 additions & 142 deletions src/com/maxprograms/swordfish/mt/MTUtils.java

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions src/com/maxprograms/swordfish/xliff/XliffStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -2961,8 +2961,7 @@ public JSONObject analyzeSpaces() throws SQLException, IOException {
idx++;
boolean segTranslate = rs.getString(8).equals("Y");
String segState = rs.getString(7);
if (!segTranslate || Constants.INITIAL.equals(segState)
|| (Constants.TRANSLATED.equals(segState) && !acceptUnconfirmed)) {
if (!segTranslate || Constants.INITIAL.equals(segState)) {
continue;
}
String sourceText = TMUtils.getString(rs.getNCharacterStream(5));
Expand Down
Binary file modified swordfish.pdf
Binary file not shown.
162 changes: 85 additions & 77 deletions ts/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ class Swordfish {
static addXmlConfigurationWindow: BrowserWindow;
static editXmlFilterWindow: BrowserWindow;
static configElementWindow: BrowserWindow;
static tagsAnalysisWindow: BrowserWindow;
static spaceAnalysisWindow: BrowserWindow;

javapath: string = Swordfish.path.join(app.getAppPath(), 'bin', 'java');

Expand Down Expand Up @@ -130,6 +132,7 @@ class Swordfish {
static typeParam: string;
static xmlFilter: string;
static filterElement: any;
static activeProject: string;

static htmlContent: string;
static htmlTitle: string;
Expand Down Expand Up @@ -342,6 +345,7 @@ class Swordfish {
Swordfish.destroyWindow(Swordfish.goToWindow);
});
ipcMain.on('go-to-segment', (event: IpcMainEvent, arg: any) => {
Swordfish.mainWindow.focus();
Swordfish.mainWindow.webContents.send('open-segment', arg);
});
ipcMain.on('get-project-param', (event: IpcMainEvent) => {
Expand Down Expand Up @@ -931,6 +935,24 @@ class Swordfish {
ipcMain.on('add-xmlConfigurationFile', (event: IpcMainEvent, arg: any) => {
Swordfish.addXmlConfiguration(event, arg);
});
ipcMain.on('tagsAnalysis-height', (event: IpcMainEvent, arg: any) => {
Swordfish.setHeight(Swordfish.tagsAnalysisWindow, arg);
});
ipcMain.on('close-tagsAnalysis', () => {
Swordfish.destroyWindow(Swordfish.tagsAnalysisWindow);
});
ipcMain.on('get-tagsErrors', (event: IpcMainEvent) => {
Swordfish.getTagErrors(event);
});
ipcMain.on('spaceAnalysis-height', (event: IpcMainEvent, arg: any) => {
Swordfish.setHeight(Swordfish.spaceAnalysisWindow, arg);
});
ipcMain.on('close-spaceAnalysis', () => {
Swordfish.destroyWindow(Swordfish.spaceAnalysisWindow);
});
ipcMain.on('get-spaceErrors', (event: IpcMainEvent) => {
Swordfish.getSpaceErrors(event);
});
} // end constructor

static createWindow(): void {
Expand Down Expand Up @@ -3213,6 +3235,10 @@ class Swordfish {
break;
case 'elementConfig': parent = Swordfish.configElementWindow;
break;
case 'tagsAnalysis': parent = Swordfish.tagsAnalysisWindow;
break;
case 'spaceAnalysis': parent = Swordfish.spaceAnalysisWindow;
break;
default: parent = Swordfish.mainWindow;
}
}
Expand Down Expand Up @@ -4453,100 +4479,82 @@ class Swordfish {
}

static analyzeSpaces(arg: any): void {
Swordfish.sendRequest('/projects/analyzeSpaces', arg,
Swordfish.activeProject = arg.project;
Swordfish.spaceAnalysisWindow = new BrowserWindow({
parent: this.mainWindow,
width: 400,
minimizable: false,
maximizable: false,
resizable: false,
show: false,
icon: this.iconPath,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
nativeWindowOpen: true
}
});
Swordfish.spaceAnalysisWindow.setMenu(null);
Swordfish.spaceAnalysisWindow.loadURL('file://' + this.path.join(app.getAppPath(), 'html', 'spaceAnalysis.html'));
Swordfish.spaceAnalysisWindow.once('ready-to-show', () => {
Swordfish.spaceAnalysisWindow.show();
});
Swordfish.spaceAnalysisWindow.on('close', () => {
this.mainWindow.focus();
});
Swordfish.setLocation(Swordfish.spaceAnalysisWindow, 'spaceAnalysis.html');
}

static analyzeTags(arg: any): void {
Swordfish.activeProject = arg.project;
Swordfish.tagsAnalysisWindow = new BrowserWindow({
parent: this.mainWindow,
width: 400,
minimizable: false,
maximizable: false,
resizable: false,
show: false,
icon: this.iconPath,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
nativeWindowOpen: true
}
});
Swordfish.tagsAnalysisWindow.setMenu(null);
Swordfish.tagsAnalysisWindow.loadURL('file://' + this.path.join(app.getAppPath(), 'html', 'tagsAnalysis.html'));
Swordfish.tagsAnalysisWindow.once('ready-to-show', () => {
Swordfish.tagsAnalysisWindow.show();
});
Swordfish.tagsAnalysisWindow.on('close', () => {
this.mainWindow.focus();
});
Swordfish.setLocation(Swordfish.tagsAnalysisWindow, 'tagsAnalysis.html');
}

static getTagErrors(event: IpcMainEvent): void {
Swordfish.sendRequest('/projects/analyzeTags', { project: Swordfish.activeProject },
(data: any) => {
if (data.status !== Swordfish.SUCCESS) {
Swordfish.showMessage({ type: 'error', message: data.reason });
return;
}
if (data.errors.length === 0) {
Swordfish.showMessage({ type: 'info', message: 'There are no errors in initial/trailing spaces' });
return;
}
let table: string = '<div class="divContainer"><table class="stripes fill_width">';
let length = data.errors.length;
for (let i = 0; i < length; i++) {
let line: any = data.errors[i];
table = table + '<tr><td class="center initial">' + line.index + '</td><td class="center fill_width">' + line.type + '</td></tr>';
}
table = table + '</table></div>';
let htmlViewerWindow: BrowserWindow = new BrowserWindow({
parent: this.mainWindow,
width: 250,
height: 350,
minimizable: false,
maximizable: false,
resizable: true,
show: false,
icon: this.iconPath,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
nativeWindowOpen: true
}
});
Swordfish.htmlContent = table;
Swordfish.htmlTitle = 'Space Analysis';
Swordfish.htmlId = htmlViewerWindow.id;
htmlViewerWindow.setMenu(null);
htmlViewerWindow.loadURL('file://' + this.path.join(app.getAppPath(), 'html', 'htmlViewer.html'));
htmlViewerWindow.once('ready-to-show', () => {
htmlViewerWindow.show();
});
htmlViewerWindow.on('close', () => {
this.mainWindow.focus();
});
event.sender.send('set-tagsErrors', data);
},
(reason: string) => {
Swordfish.showMessage({ type: 'error', message: reason });
}
);
}

static analyzeTags(arg: any): void {
Swordfish.sendRequest('/projects/analyzeTags', arg,
static getSpaceErrors(event: IpcMainEvent): void {
Swordfish.sendRequest('/projects/analyzeSpaces', { project: Swordfish.activeProject },
(data: any) => {
if (data.status !== Swordfish.SUCCESS) {
Swordfish.showMessage({ type: 'error', message: data.reason });
return;
}
if (data.errors.length === 0) {
Swordfish.showMessage({ type: 'info', message: 'There are no tag errors' });
return;
}
let table: string = '<div class="divContainer"><table class="stripes fill_width">';
let length = data.errors.length;
for (let i = 0; i < length; i++) {
let line: any = data.errors[i];
table = table + '<tr><td class="center initial">' + line.index + '</td><td class="center fill_width">' + line.type + '</td></tr>';
}
table = table + '</table></div>';
let htmlViewerWindow: BrowserWindow = new BrowserWindow({
parent: this.mainWindow,
width: 250,
height: 350,
minimizable: false,
maximizable: false,
resizable: true,
show: false,
icon: this.iconPath,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
nativeWindowOpen: true
}
});
Swordfish.htmlContent = table;
Swordfish.htmlTitle = 'Tags Analysis';
Swordfish.htmlId = htmlViewerWindow.id;
htmlViewerWindow.setMenu(null);
htmlViewerWindow.loadURL('file://' + this.path.join(app.getAppPath(), 'html', 'htmlViewer.html'));
htmlViewerWindow.once('ready-to-show', () => {
htmlViewerWindow.show();
});
htmlViewerWindow.on('close', () => {
this.mainWindow.focus();
});
event.sender.send('set-spaceErrors', data);
},
(reason: string) => {
Swordfish.showMessage({ type: 'error', message: reason });
Expand Down
Loading

0 comments on commit f61252d

Please sign in to comment.