Preview not available
diff --git a/html/convertExcel.html b/html/convertExcel.html
index 420ae43..26ea717 100644
--- a/html/convertExcel.html
+++ b/html/convertExcel.html
@@ -30,7 +30,7 @@
-
+
Preview not available
diff --git a/html/fileInfo.html b/html/fileInfo.html
index a253458..c2aa08f 100644
--- a/html/fileInfo.html
+++ b/html/fileInfo.html
@@ -7,81 +7,78 @@
-
-
-
-
+
+
+
+
-
-
-
-
-
-
- Creation Tool |
- |
-
-
- Creation Tool Version |
- |
-
-
- Segmentation Type |
- |
-
-
- Original Translation Memory Format |
- |
-
-
- Administrative Language |
- |
-
-
- Source Language |
- |
-
-
- Data Type |
- |
-
-
-
+
+
+
+
+
+ Creation Tool |
+ |
+
+
+ Creation Tool Version |
+ |
+
+
+ Segmentation Type |
+ |
+
+
+ Original Translation Memory Format |
+ |
+
+
+ Administrative Language |
+ |
+
+
+ Source Language |
+ |
+
+
+ Data Type |
+ |
+
+
+
-
-
+
-
+
diff --git a/html/removeSameAsSource.html b/html/removeSameAsSource.html
new file mode 100644
index 0000000..b492112
--- /dev/null
+++ b/html/removeSameAsSource.html
@@ -0,0 +1,26 @@
+
+
+
+
+
Remove Translation Same as Source
+
+
+
+
+
+
+
+ |
+
+
+ |
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/jars/openxliff.jar b/jars/openxliff.jar
index 5e597b4..6cc3aec 100644
Binary files a/jars/openxliff.jar and b/jars/openxliff.jar differ
diff --git a/package.json b/package.json
index f9b973d..0c5c1e3 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "tmxeditor",
"productName": "TMXEditor",
- "version": "2.5.1",
+ "version": "2.6.0",
"description": "TMX Editor",
"main": "js/app.js",
"scripts": {
@@ -19,7 +19,11 @@
"url": "https://github.com/rmraya/TMXEditor.git"
},
"devDependencies": {
- "electron": "^13.1.1",
- "typescript": "^4.3.2"
+ "@types/node-fetch": "^2.5.12",
+ "electron": "^13.1.7",
+ "typescript": "^4.3.5"
+ },
+ "dependencies": {
+ "node-fetch": "^2.6.1"
}
}
diff --git a/src/com/maxprograms/tmxserver/Constants.java b/src/com/maxprograms/tmxserver/Constants.java
index eca3d10..8dd0a6d 100644
--- a/src/com/maxprograms/tmxserver/Constants.java
+++ b/src/com/maxprograms/tmxserver/Constants.java
@@ -19,8 +19,8 @@ private Constants() {
}
public static final String APPNAME = "TMXEditor";
- public static final String VERSION = "2.5.1";
- public static final String BUILD = "20210615_0900";
+ public static final String VERSION = "2.6.0";
+ public static final String BUILD = "20210705_1108";
public static final String REASON = "reason";
public static final String STATUS = "status";
diff --git a/src/com/maxprograms/tmxserver/TMXServer.java b/src/com/maxprograms/tmxserver/TMXServer.java
index ab0e179..090b774 100644
--- a/src/com/maxprograms/tmxserver/TMXServer.java
+++ b/src/com/maxprograms/tmxserver/TMXServer.java
@@ -171,6 +171,9 @@ public void handle(HttpExchange t) throws IOException {
case "removeUntranslated":
response = removeUntranslated(json.getString("srcLang"));
break;
+ case "removeSameAsSource":
+ response = removeSameAsSource(json.getString("srcLang"));
+ break;
case "replaceText":
response = replaceText(json);
break;
@@ -564,6 +567,19 @@ private String removeUntranslated(String srcLang) {
}
}
+ private String removeSameAsSource(String srcLang) {
+ try {
+ Language lang = service.getLanguage(srcLang);
+ return service.removeSameAsSource(lang).toString();
+ } catch (IOException e) {
+ logger.log(Level.ERROR, e);
+ JSONObject result = new JSONObject();
+ result.put(Constants.STATUS, Constants.ERROR);
+ result.put(Constants.REASON, e.getMessage());
+ return result.toString();
+ }
+ }
+
private String validateFile(String file) {
return service.validateFile(file).toString();
}
diff --git a/src/com/maxprograms/tmxserver/TMXService.java b/src/com/maxprograms/tmxserver/TMXService.java
index 6ba18a9..f89c96b 100644
--- a/src/com/maxprograms/tmxserver/TMXService.java
+++ b/src/com/maxprograms/tmxserver/TMXService.java
@@ -621,6 +621,34 @@ public void run() {
return result;
}
+ public JSONObject removeSameAsSource(Language lang) {
+ JSONObject result = new JSONObject();
+ processing = true;
+ processingError = "";
+ try {
+ new Thread() {
+
+ @Override
+ public void run() {
+ try {
+ store.removeSameAsSource(lang);
+ } catch (Exception e) {
+ logger.log(Level.SEVERE, e.getMessage(), e);
+ processingError = e.getMessage();
+ }
+ processing = false;
+ }
+ }.start();
+ result.put(Constants.STATUS, Constants.SUCCESS);
+ } catch (Exception e) {
+ logger.log(Level.SEVERE, e.getMessage(), e);
+ processing = false;
+ result.put(Constants.STATUS, Constants.ERROR);
+ result.put(Constants.REASON, e.getMessage());
+ }
+ return result;
+ }
+
public JSONObject addLanguage(Language lang) {
JSONObject result = new JSONObject();
try {
diff --git a/src/com/maxprograms/tmxserver/tmx/CountStore.java b/src/com/maxprograms/tmxserver/tmx/CountStore.java
index c3c7869..aeb2029 100644
--- a/src/com/maxprograms/tmxserver/tmx/CountStore.java
+++ b/src/com/maxprograms/tmxserver/tmx/CountStore.java
@@ -118,6 +118,11 @@ public long removeUntranslated(Language lang) {
return 0;
}
+ @Override
+ public void removeSameAsSource(Language lang) {
+ // do nothing
+ }
+
@Override
public void addLanguage(Language lang) {
// do nothing
diff --git a/src/com/maxprograms/tmxserver/tmx/H2Store.java b/src/com/maxprograms/tmxserver/tmx/H2Store.java
index 70d001b..b7be68c 100644
--- a/src/com/maxprograms/tmxserver/tmx/H2Store.java
+++ b/src/com/maxprograms/tmxserver/tmx/H2Store.java
@@ -688,6 +688,50 @@ public long removeUntranslated(Language language) throws IOException, SQLExcepti
return result;
}
+ @Override
+ public void removeSameAsSource(Language language)
+ throws SQLException, SAXException, IOException, ParserConfigurationException {
+ processed = 0l;
+ List
selected = new ArrayList<>();
+ String srclang = language.getCode();
+ String query = "SELECT tuid, tu FROM tu";
+ try (ResultSet rs = stmt.executeQuery(query)) {
+ while (rs.next()) {
+ String tuid = rs.getString(1);
+ String tuv = getTuvString(tuid, srclang);
+ if (!tuv.isEmpty()) {
+ Element srcTuv = toElement(tuv);
+ Element src = srcTuv.getChild("seg");
+ Iterator langIt = languages.iterator();
+ int count = 0;
+ while (langIt.hasNext()) {
+ String lang = langIt.next();
+ if (!lang.equals(srclang)) {
+ tuv = getTuvString(tuid, lang);
+ if (!tuv.isEmpty()) {
+ Element tgt = toElement(tuv).getChild("seg");
+ if (src.equals(tgt)) {
+ deleteTuv(tuid, lang);
+ } else {
+ count++;
+ }
+ }
+ }
+ }
+ if (count == 0) {
+ selected.add(tuid);
+ }
+ }
+ processed++;
+ }
+ }
+ Iterator it = selected.iterator();
+ while (it.hasNext()) {
+ delete(it.next());
+ }
+ selected.clear();
+ }
+
@Override
public void addLanguage(Language language) throws IOException, SQLException {
String lang = language.getCode();
diff --git a/src/com/maxprograms/tmxserver/tmx/LanguagesStore.java b/src/com/maxprograms/tmxserver/tmx/LanguagesStore.java
index 5956d56..6d5ad92 100644
--- a/src/com/maxprograms/tmxserver/tmx/LanguagesStore.java
+++ b/src/com/maxprograms/tmxserver/tmx/LanguagesStore.java
@@ -133,6 +133,11 @@ public long removeUntranslated(Language lang) {
return 0;
}
+ @Override
+ public void removeSameAsSource(Language lang) {
+ // do nothing
+ }
+
@Override
public void addLanguage(Language lang) {
// do nothing
diff --git a/src/com/maxprograms/tmxserver/tmx/MergeStore.java b/src/com/maxprograms/tmxserver/tmx/MergeStore.java
index 06d757a..2c4ca1d 100644
--- a/src/com/maxprograms/tmxserver/tmx/MergeStore.java
+++ b/src/com/maxprograms/tmxserver/tmx/MergeStore.java
@@ -135,6 +135,11 @@ public long removeUntranslated(Language lang) {
return 0l;
}
+ @Override
+ public void removeSameAsSource(Language lang) {
+ // do nothing
+ }
+
@Override
public void addLanguage(Language lang) {
// do nothing
diff --git a/src/com/maxprograms/tmxserver/tmx/SimpleStore.java b/src/com/maxprograms/tmxserver/tmx/SimpleStore.java
index 8986f8d..f41aeaa 100644
--- a/src/com/maxprograms/tmxserver/tmx/SimpleStore.java
+++ b/src/com/maxprograms/tmxserver/tmx/SimpleStore.java
@@ -410,6 +410,46 @@ public long removeUntranslated(Language language) throws IOException {
return result;
}
+ @Override
+ public void removeSameAsSource(Language language) throws IOException {
+ processed = 0l;
+ List selected = new ArrayList<>();
+ String srclang = language.getCode();
+ Iterator ut = order.iterator();
+ while (ut.hasNext()) {
+ String tuid = ut.next();
+ Element srcTuv = maps.get(srclang).get(tuid);
+ if (srcTuv != null) {
+ Element src = srcTuv.getChild("seg");
+ Iterator langIt = languages.iterator();
+ int count = 0;
+ while (langIt.hasNext()) {
+ String lang = langIt.next();
+ if (!lang.equals(srclang)) {
+ Element tuv = maps.get(lang).get(tuid);
+ if (tuv != null) {
+ Element tgt = tuv.getChild("seg");
+ if (src.equals(tgt)) {
+ maps.get(lang).remove(tuid);
+ } else {
+ count++;
+ }
+ }
+ }
+ }
+ if (count == 0) {
+ selected.add(tuid);
+ }
+ }
+ processed++;
+ }
+ Iterator it = selected.iterator();
+ while (it.hasNext()) {
+ delete(it.next());
+ }
+ selected.clear();
+ }
+
@Override
public void addLanguage(Language language) {
String lang = language.getCode();
diff --git a/src/com/maxprograms/tmxserver/tmx/SplitStore.java b/src/com/maxprograms/tmxserver/tmx/SplitStore.java
index a67cfda..c03d17f 100644
--- a/src/com/maxprograms/tmxserver/tmx/SplitStore.java
+++ b/src/com/maxprograms/tmxserver/tmx/SplitStore.java
@@ -179,6 +179,11 @@ public long removeUntranslated(Language lang) {
return 0;
}
+ @Override
+ public void removeSameAsSource(Language lang) {
+ // do nothing
+ }
+
@Override
public void addLanguage(Language lang) {
// do nothing
diff --git a/src/com/maxprograms/tmxserver/tmx/StoreInterface.java b/src/com/maxprograms/tmxserver/tmx/StoreInterface.java
index 27ddcb0..a296de0 100644
--- a/src/com/maxprograms/tmxserver/tmx/StoreInterface.java
+++ b/src/com/maxprograms/tmxserver/tmx/StoreInterface.java
@@ -68,6 +68,8 @@ void replaceText(String search, String replace, Language language, boolean regEx
long removeUntranslated(Language lang) throws IOException, SQLException;
+ void removeSameAsSource(Language lang) throws IOException, SQLException, SAXException, ParserConfigurationException;
+
void addLanguage(Language lang) throws IOException, SQLException;
void removeLanguage(Language lang) throws IOException, SQLException;
diff --git a/tmxeditor.pdf b/tmxeditor.pdf
index f89817c..f17ce73 100644
Binary files a/tmxeditor.pdf and b/tmxeditor.pdf differ
diff --git a/ts/app.ts b/ts/app.ts
index f40aa04..807b2af 100644
--- a/ts/app.ts
+++ b/ts/app.ts
@@ -10,11 +10,10 @@
* Maxprograms - initial API and implementation
*******************************************************************************/
-import { Buffer } from "buffer";
-import { execFileSync, spawn, ChildProcessWithoutNullStreams } from "child_process";
-import { app, BrowserWindow, dialog, ipcMain, Menu, MenuItem, shell, Rectangle, nativeTheme, IpcMainEvent, OpenDialogReturnValue, SaveDialogReturnValue } from "electron";
+import { ChildProcessWithoutNullStreams, execFileSync, spawn } from "child_process";
+import { app, BrowserWindow, dialog, ipcMain, IpcMainEvent, Menu, MenuItem, nativeTheme, OpenDialogReturnValue, Rectangle, SaveDialogReturnValue, shell } from "electron";
import { existsSync, mkdirSync, readFile, readFileSync, writeFile, writeFileSync } from "fs";
-import { ClientRequest, request, IncomingMessage } from "http";
+import fetch from "node-fetch";
const SUCCESS: string = 'Success';
const LOADING: string = 'Loading';
@@ -27,7 +26,6 @@ const PROCESSING: string = 'Processing';
class App {
static path = require('path');
- static https = require('https');
static mainWindow: BrowserWindow;
static newFileWindow: BrowserWindow;
@@ -53,6 +51,7 @@ class App {
static removeLanguageWindow: BrowserWindow;
static srcLanguageWindow: BrowserWindow;
static removeUntranslatedWindow: BrowserWindow;
+ static removeSameAsSourceWindow: BrowserWindow;
static consolidateWindow: BrowserWindow;
static updatesWindow: BrowserWindow;
static maintenanceWindow: BrowserWindow;
@@ -158,41 +157,17 @@ class App {
console.error(`stderr: ${data}`);
});
- App.ls.on('close', (code) => {
+ App.ls.on('close', (code: number) => {
if (code === 0) {
- var postData: string = JSON.stringify({ command: 'stop' });
- var options = {
- hostname: '127.0.0.1',
- port: 8060,
- path: '/TMXServer',
- headers: {
- 'Content-Type': 'application/json',
- 'Content-Length': Buffer.byteLength(postData)
- }
- };
- // Make a request
- var req: ClientRequest = request(options);
- req.on('response',
- (res: any) => {
- res.setEncoding('utf-8');
- if (res.statusCode !== 200) {
- console.log('sendRequest() error: ' + res.statusMessage);
- }
- var rawData: string = '';
- res.on('data', (chunk: string) => {
- rawData += chunk;
- });
- res.on('end', () => {
- try {
- console.log(rawData);
- } catch (e) {
- console.log(e.message);
- }
- });
+ App.sendRequest({ command: 'stop' },
+ () => {
+ console.log('Restarting server');
+ App.ls = spawn(App.javapath, ['-cp', 'lib/h2-1.4.200.jar', '--module-path', 'lib', '-m', 'tmxserver/com.maxprograms.tmxserver.TMXServer', '-port', '8060'], { cwd: app.getAppPath() });
+ },
+ (reason: string) => {
+ console.log('Error restarting server: ' + reason);
}
);
- req.write(postData);
- req.end();
}
});
@@ -468,6 +443,9 @@ class App {
ipcMain.on('remove-untranslated', (event: IpcMainEvent, arg: any) => {
this.removeUntranslated(arg);
});
+ ipcMain.on('remove-sameAsSource', (event: IpcMainEvent, arg: any) => {
+ this.removeSameAsSource(arg);
+ });
ipcMain.on('consolidate-units', (event: IpcMainEvent, arg: any) => {
this.consolidateUnits(arg);
});
@@ -621,6 +599,12 @@ class App {
ipcMain.on('removeUntranslated-height', (event: IpcMainEvent, arg: any) => {
App.setHeight(App.removeUntranslatedWindow, arg);
});
+ ipcMain.on('removeSameAsSource-height', (event: IpcMainEvent, arg: any) => {
+ App.setHeight(App.removeSameAsSourceWindow, arg);
+ });
+ ipcMain.on('close-removeSameAsSource', () => {
+ App.destroyWindow(App.removeSameAsSourceWindow);
+ });
ipcMain.on('close-removeUntranslated', () => {
App.destroyWindow(App.removeUntranslatedWindow);
});
@@ -856,6 +840,7 @@ class App {
{ label: 'Remove All Tags', click: () => { App.removeTags(); } },
{ label: 'Remove Duplicates', click: () => { App.removeDuplicates(); } },
{ label: 'Remove Untranslated...', click: () => { App.showRemoveUntranslated(); } },
+ { label: 'Remove Translation Same as Source...', click: () => { App.showRemoveSameAsSource(); } },
{ label: 'Remove Initial/Trailing Spaces', click: () => { App.removeSpaces(); } },
{ label: 'Consolidate Units...', click: () => { App.showConsolidateUnits(); } }
]);
@@ -997,49 +982,20 @@ class App {
});
}
- static sendRequest(json: any, success: any, error: any): void {
- var postData: string = JSON.stringify(json);
- var options = {
- hostname: '127.0.0.1',
- port: 8060,
- path: '/TMXServer',
- headers: {
- 'Content-Type': 'application/json',
- 'Content-Length': Buffer.byteLength(postData)
- }
- };
- // Make a request
- var req: ClientRequest = request(options);
- req.on('response',
- (res: any) => {
- res.setEncoding('utf-8');
- if (res.statusCode !== 200) {
- error('sendRequest() error: ' + res.statusMessage);
- }
- var rawData: string = '';
- res.on('data', (chunk: string) => {
- rawData += chunk;
- });
- res.on('end', () => {
- try {
- success(JSON.parse(rawData));
- } catch (e) {
- error(e.message);
- }
- });
- }
- );
- req.write(postData, (err: Error) => {
- if (err) {
- console.log('Write error: ' + err.message);
- }
- });
- req.on('error', (err: Error) => {
- error(err.message);
- console.log('Error: ' + err.message);
- console.log('Params: ' + JSON.stringify(json));
+ static sendRequest(params: any, success: Function, error: Function): void {
+ fetch('http://127.0.0.1:8060/TMXServer', {
+ method: 'POST',
+ headers: [
+ ['Content-Type', 'application/json'],
+ ['Accept', 'application/json']
+ ],
+ body: JSON.stringify(params)
+ }).then(async (response) => {
+ let json: any = await response.json();
+ success(json);
+ }).catch((reason: any) => {
+ error(JSON.stringify(reason));
});
- req.end();
}
static showLicenses(arg: any): void {
@@ -3154,6 +3110,32 @@ class App {
});
}
+ static showRemoveSameAsSource(): void {
+ if (App.currentFile === '') {
+ App.showMessage({ type: 'warning', message: 'Open a TMX file' });
+ return;
+ }
+ App.removeSameAsSourceWindow = new BrowserWindow({
+ parent: App.mainWindow,
+ width: 470,
+ useContentSize: true,
+ minimizable: false,
+ maximizable: false,
+ resizable: false,
+ show: false,
+ icon: App.iconPath,
+ webPreferences: {
+ nodeIntegration: true,
+ contextIsolation: false
+ }
+ });
+ App.removeSameAsSourceWindow.setMenu(null);
+ App.removeSameAsSourceWindow.loadURL('file://' + App.path.join(app.getAppPath(), 'html', 'removeSameAsSource.html'));
+ App.removeSameAsSourceWindow.once('ready-to-show', () => {
+ App.removeSameAsSourceWindow.show();
+ });
+ }
+
removeUntranslated(arg: any): void {
App.destroyWindow(App.removeUntranslatedWindow);
App.mainWindow.webContents.send('start-waiting');
@@ -3199,6 +3181,51 @@ class App {
);
}
+ removeSameAsSource(arg: any): void {
+ App.destroyWindow(App.removeSameAsSourceWindow);
+ App.mainWindow.webContents.send('start-waiting');
+ arg.command = 'removeSameAsSource';
+ App.sendRequest(arg,
+ (data: any) => {
+ App.currentStatus = data;
+ App.mainWindow.webContents.send('set-status', 'Removing entries...');
+ var intervalObject = setInterval(() => {
+ if (App.currentStatus.status === COMPLETED) {
+ App.mainWindow.webContents.send('end-waiting');
+ App.mainWindow.webContents.send('set-status', '');
+ clearInterval(intervalObject);
+ App.loadSegments();
+ App.getCount();
+ App.saved = false;
+ App.mainWindow.setDocumentEdited(true);
+ return;
+ } else if (App.currentStatus.status === PROCESSING) {
+ // it's OK, keep waiting
+ } else if (App.currentStatus.status === ERROR) {
+ App.mainWindow.webContents.send('end-waiting');
+ App.mainWindow.webContents.send('set-status', '');
+ clearInterval(intervalObject);
+ App.showMessage({ type: 'error', message: App.currentStatus.reason });
+ return;
+ } else if (App.currentStatus.status === SUCCESS) {
+ // ignore status from 'removeSameAsSource'
+ } else {
+ App.mainWindow.webContents.send('end-waiting');
+ App.mainWindow.webContents.send('set-status', '');
+ clearInterval(intervalObject);
+ dialog.showErrorBox('Error', 'Unknown error removing entries with translation same as source');
+ return;
+ }
+ App.getProcessingProgress();
+ }, 500);
+ },
+ (reason: string) => {
+ App.mainWindow.webContents.send('end-waiting');
+ App.showMessage({ type: 'error', message: reason });
+ }
+ );
+ }
+
static removeSpaces(): void {
if (App.currentFile === '') {
App.showMessage({ type: 'warning', message: 'Open a TMX file' });
@@ -3409,72 +3436,60 @@ class App {
}
static checkUpdates(silent: boolean): void {
- this.https.get('https://maxprograms.com/tmxeditor.json', (res: IncomingMessage) => {
- if (res.statusCode === 200) {
- let rawData = '';
- res.on('data', (chunk: string) => {
- rawData += chunk;
- });
- res.on('end', () => {
- try {
- const parsedData = JSON.parse(rawData);
- if (app.getVersion() !== parsedData.version) {
- App.latestVersion = parsedData.version;
- switch (process.platform) {
- case 'darwin':
- App.downloadLink = process.arch === 'arm64' ? parsedData.arm64 : parsedData.darwin;
- break;
- case 'win32':
- App.downloadLink = parsedData.win32;
- break;
- case 'linux':
- App.downloadLink = parsedData.linux;
- break;
- }
- App.updatesWindow = new BrowserWindow({
- parent: this.mainWindow,
- width: 600,
- useContentSize: true,
- minimizable: false,
- maximizable: false,
- resizable: false,
- show: false,
- icon: App.iconPath,
- webPreferences: {
- nodeIntegration: true,
- contextIsolation: false
- }
- });
- App.updatesWindow.setMenu(null);
- App.updatesWindow.loadURL('file://' + this.path.join(app.getAppPath(), 'html', 'updates.html'));
- App.updatesWindow.once('ready-to-show', () => {
- App.updatesWindow.show();
- });
- } else {
- if (!silent) {
- App.showMessage({
- type: 'info',
- message: 'There are currently no updates available'
- });
- }
- }
- } catch (e: any) {
- console.log(e);
- App.showMessage({ type: 'error', message: e.message });
+ fetch('https://maxprograms.com/tmxeditor.json', {
+ method: 'GET'
+ }).then(async (response) => {
+ let parsedData: any = await response.json();
+ if (app.getVersion() !== parsedData.version) {
+ App.latestVersion = parsedData.version;
+ switch (process.platform) {
+ case 'darwin':
+ App.downloadLink = process.arch === 'arm64' ? parsedData.arm64 : parsedData.darwin;
+ break;
+ case 'win32':
+ App.downloadLink = parsedData.win32;
+ break;
+ case 'linux':
+ App.downloadLink = parsedData.linux;
+ break;
+ }
+ App.updatesWindow = new BrowserWindow({
+ parent: this.mainWindow,
+ width: 600,
+ useContentSize: true,
+ minimizable: false,
+ maximizable: false,
+ resizable: false,
+ show: false,
+ icon: this.iconPath,
+ webPreferences: {
+ nodeIntegration: true,
+ contextIsolation: false
}
});
+ App.updatesWindow.setMenu(null);
+ App.updatesWindow.loadURL('file://' + this.path.join(app.getAppPath(), 'html', 'updates.html'));
+ App.updatesWindow.once('ready-to-show', () => {
+ App.updatesWindow.show();
+ });
} else {
if (!silent) {
- App.showMessage({ type: 'error', message: 'Updates Request Failed.\nStatus code: ' + res.statusCode });
+ App.showMessage({
+ type: 'info',
+ message: 'There are currently no updates available'
+ });
}
}
- }).on('error', (e: any) => {
+ }).catch((reason: any) => {
if (!silent) {
- App.showMessage({ type: 'error', message: e.message });
+ App.showMessage({
+ type: 'error',
+ message: reason.message
+ });
}
});
}
-}
+}
new App(process.argv);
\ No newline at end of file
diff --git a/ts/fileInfo.ts b/ts/fileInfo.ts
index 9792406..e213fd0 100644
--- a/ts/fileInfo.ts
+++ b/ts/fileInfo.ts
@@ -41,7 +41,6 @@ class FileInfo {
}
setFileProperties(arg: any): void {
- document.getElementById('file').innerHTML = arg.file;
document.getElementById('creationtool').innerHTML = arg.attributes.creationtool;
document.getElementById('creationtoolversion').innerHTML = arg.attributes.creationtoolversion;
document.getElementById('segtype').innerHTML = arg.attributes.segtype;
@@ -68,45 +67,45 @@ class FileInfo {
}
showAttributes(): void {
- document.getElementById('atributesTab').classList.add('selected');
- document.getElementById('attributes').classList.remove('hiddenTab');
+ document.getElementById('atributesTab').classList.add('selectedTab');
+ document.getElementById('attributes').classList.remove('hidden');
document.getElementById('attributes').classList.add('tabContent');
- document.getElementById('propertiesTab').classList.remove('selected');
+ document.getElementById('propertiesTab').classList.remove('selectedTab');
document.getElementById('properties').classList.remove('tabContent');
- document.getElementById('properties').classList.add('hiddenTab');
+ document.getElementById('properties').classList.add('hidden');
- document.getElementById('notesTab').classList.remove('selected');
+ document.getElementById('notesTab').classList.remove('selectedTab');
document.getElementById('notes').classList.remove('tabContent');
- document.getElementById('notes').classList.add('hiddenTab');
+ document.getElementById('notes').classList.add('hidden');
}
showProperties(): void {
- document.getElementById('propertiesTab').classList.add('selected');
- document.getElementById('properties').classList.remove('hiddenTab');
+ document.getElementById('propertiesTab').classList.add('selectedTab');
+ document.getElementById('properties').classList.remove('hidden');
document.getElementById('properties').classList.add('tabContent');
- document.getElementById('atributesTab').classList.remove('selected');
+ document.getElementById('atributesTab').classList.remove('selectedTab');
document.getElementById('attributes').classList.remove('tabContent');
- document.getElementById('attributes').classList.add('hiddenTab');
+ document.getElementById('attributes').classList.add('hidden');
- document.getElementById('notesTab').classList.remove('selected');
+ document.getElementById('notesTab').classList.remove('selectedTab');
document.getElementById('notes').classList.remove('tabContent');
- document.getElementById('notes').classList.add('hiddenTab');
+ document.getElementById('notes').classList.add('hidden');
}
showNotes(): void {
- document.getElementById('notesTab').classList.add('selected');
+ document.getElementById('notesTab').classList.add('selectedTab');
document.getElementById('notes').classList.add('tabContent');
- document.getElementById('notes').classList.remove('hiddenTab');
+ document.getElementById('notes').classList.remove('hidden');
- document.getElementById('propertiesTab').classList.remove('selected');
+ document.getElementById('propertiesTab').classList.remove('selectedTab');
document.getElementById('properties').classList.remove('tabContent');
- document.getElementById('properties').classList.add('hiddenTab');
+ document.getElementById('properties').classList.add('hidden');
- document.getElementById('atributesTab').classList.remove('selected');
+ document.getElementById('atributesTab').classList.remove('selectedTab');
document.getElementById('attributes').classList.remove('tabContent');
- document.getElementById('attributes').classList.add('hiddenTab');
+ document.getElementById('attributes').classList.add('hidden');
}
}
diff --git a/ts/main.ts b/ts/main.ts
index ff79908..f22bf9f 100644
--- a/ts/main.ts
+++ b/ts/main.ts
@@ -318,6 +318,7 @@ class Main {
createCenterPanel(): void {
this.mainPanel = document.getElementById('mainPanel') as HTMLDivElement;
+ this.mainPanel.classList.add('lighter');
let split: VerticalSplit = new VerticalSplit(this.mainPanel);
split.setWeights([80, 20]);
@@ -983,7 +984,6 @@ class Main {
}
var x: string = element.tagName;
var id: string;
- var lang: string;
if ('TD' === x || 'INPUT' === x) {
var composed = event.composedPath();
if ('TR' === (composed[0] as Element).tagName) {
@@ -993,7 +993,6 @@ class Main {
} else if ('TR' === (composed[2] as Element).tagName) {
id = (composed[2] as Element).id;
}
- lang = (event.target as Element).getAttribute('lang');
}
if (id) {
this.currentId = id;
diff --git a/ts/removeSameAsSource.ts b/ts/removeSameAsSource.ts
new file mode 100644
index 0000000..5698910
--- /dev/null
+++ b/ts/removeSameAsSource.ts
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2018-2021 Maxprograms.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 1.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/org/documents/epl-v10.html
+ *
+ * Contributors:
+ * Maxprograms - initial API and implementation
+ *******************************************************************************/
+
+class removeSameAsSource {
+
+ electron = require("electron");
+
+ constructor() {
+ this.electron.ipcRenderer.send('get-theme');
+ this.electron.ipcRenderer.on('set-theme', (event: Electron.IpcRendererEvent, arg: any) => {
+ (document.getElementById('theme') as HTMLLinkElement).href = arg;
+ });
+ this.electron.ipcRenderer.send('get-filter-languages');
+ this.electron.ipcRenderer.on('filter-languages', (event: Electron.IpcRendererEvent, arg: any) => {
+ this.filterLanguages(arg);
+ });
+ this.electron.ipcRenderer.on('set-source-language', (event: Electron.IpcRendererEvent, arg: any) => {
+ if (arg.srcLang !== '*all*') {
+ (document.getElementById('sourceLanguage') as HTMLSelectElement).value = arg.srcLang;
+ }
+ });
+ document.getElementById('removeSameAsSource').addEventListener('click', () => {
+ this.removeSameAsSource();
+ });
+ document.addEventListener('keydown', (event: KeyboardEvent) => {
+ if (event.code === 'Enter' || event.code === 'NumpadEnter') {
+ this.removeSameAsSource();
+ }
+ if (event.code === 'Escape') {
+ this.electron.ipcRenderer.send('close-removeSameAsSource');
+ }
+ });
+ document.getElementById('sourceLanguage').focus();
+ let body: HTMLBodyElement = document.getElementById('body') as HTMLBodyElement;
+ this.electron.ipcRenderer.send('removeSameAsSource-height', { width: body.clientWidth, height: body.clientHeight });
+ }
+
+ filterLanguages(arg: any): void {
+ var sourceLanguage: HTMLSelectElement = document.getElementById('sourceLanguage') as HTMLSelectElement;
+ var options: string = '';
+ for (let i: number = 0; i < arg.length; i++) {
+ let lang: any = arg[i];
+ options = options + ''
+ }
+ sourceLanguage.innerHTML = options;
+ this.electron.ipcRenderer.send('get-source-language');
+ }
+
+ removeSameAsSource(): void {
+ var srcLang: string = (document.getElementById('sourceLanguage') as HTMLSelectElement).value;
+ this.electron.ipcRenderer.send('remove-sameAsSource', { srcLang: srcLang });
+ }
+}
+
+new removeSameAsSource();
\ No newline at end of file