feat(TUP-35957): Merge branch 'maintenance/8.0' into bhe/feat/TUP-35957_80
This commit is contained in:
@@ -16,8 +16,14 @@ import java.io.BufferedOutputStream;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.swt.SWT;
|
||||
@@ -158,8 +164,35 @@ public class ImageUtils {
|
||||
return imageDes;
|
||||
}
|
||||
|
||||
private static Map<byte[], ImageDataProvider> imageFromDataCachedImages = new HashMap<byte[], ImageDataProvider>();
|
||||
private static Map<byte[], ImageDataProvider> imageFromDataCachedImages = Collections.synchronizedMap(new HashMap<byte[], ImageDataProvider>());
|
||||
private static Map<Long, byte[]> cachedImagesTimeKeeping = Collections.synchronizedMap(new HashMap<Long, byte[]>());
|
||||
|
||||
private static Thread clearImageFromDataCachedImages = new Thread() {
|
||||
@SuppressWarnings("static-access")
|
||||
public void run() {
|
||||
long timeout = 5 * 60 * 1000;
|
||||
while(true) {//remove older than 5 mins
|
||||
Set<Entry<Long, byte[]>> collect = cachedImagesTimeKeeping.entrySet().stream()
|
||||
.filter(entry -> (System.currentTimeMillis() - entry.getKey()) > timeout).collect(Collectors.toSet());
|
||||
for(Entry<Long, byte[]> entry: collect) {
|
||||
Long key = entry.getKey();
|
||||
cachedImagesTimeKeeping.remove(key);
|
||||
imageFromDataCachedImages.remove(entry.getValue());
|
||||
}
|
||||
|
||||
try {
|
||||
sleep(timeout);
|
||||
} catch (InterruptedException e) {//
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
static {
|
||||
clearImageFromDataCachedImages.setDaemon(true);
|
||||
clearImageFromDataCachedImages.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, keep in memory the .
|
||||
*
|
||||
@@ -169,12 +202,17 @@ public class ImageUtils {
|
||||
*/
|
||||
public static ImageDescriptor createImageFromData(byte[] data, boolean... keepInMemory) {
|
||||
if (data != null) {
|
||||
ImageDataProvider imageProvider = imageFromDataCachedImages.get(data);
|
||||
ImageDataProvider imageProvider = null;
|
||||
Optional<byte[]> findKey = imageFromDataCachedImages.keySet().stream().filter(key->Arrays.equals(key, data)).findAny();
|
||||
if(findKey.isPresent()) {
|
||||
imageProvider = imageFromDataCachedImages.get(findKey.get());
|
||||
}
|
||||
if (imageProvider == null) {
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(data);
|
||||
ImageData img = new ImageData(bais);
|
||||
imageProvider = new TalendImageProvider(img);
|
||||
imageFromDataCachedImages.put(data, imageProvider);
|
||||
cachedImagesTimeKeeping.put(System.currentTimeMillis(), data);
|
||||
}
|
||||
return ImageDescriptor.createFromImageDataProvider(imageProvider);
|
||||
}
|
||||
@@ -183,8 +221,9 @@ public class ImageUtils {
|
||||
|
||||
public static void disposeImages(byte[] data) {
|
||||
if (data != null) {
|
||||
if (imageFromDataCachedImages.get(data) != null) {
|
||||
imageFromDataCachedImages.remove(data);
|
||||
Optional<byte[]> findKey = imageFromDataCachedImages.keySet().stream().filter(key->Arrays.equals(key, data)).findAny();
|
||||
if(findKey.isPresent()) {
|
||||
imageFromDataCachedImages.remove(findKey.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,10 @@ public class SparkBatchMetadataTalendTypeFilter extends SparkMetadataTalendTypeF
|
||||
"tFileInputParquet",
|
||||
"tFileOutputParquet",
|
||||
"tJDBCInput",
|
||||
"tJDBCOutput", "tLogRow", "tSqlRow"
|
||||
"tJDBCOutput",
|
||||
"tLogRow",
|
||||
"tSqlRow",
|
||||
"tFileInputDelimited"
|
||||
);
|
||||
|
||||
public SparkBatchMetadataTalendTypeFilter(INode node) {
|
||||
|
||||
@@ -552,6 +552,8 @@ BusinessAppearanceComposite.textAlignment.vertical.centre=\u4E2D\u5FC3
|
||||
ConnectionBean.Local=\u30ED\u30FC\u30AB\u30EB
|
||||
ConnectionBean.Remote=\u30EA\u30E2\u30FC\u30C8
|
||||
ConnectionBean.DefaultConnection=\u30C7\u30D5\u30A9\u30EB\u30C8\u63A5\u7D9A
|
||||
ConnectionBean.Cloud.name=\u30B5\u30A4\u30F3\u30A4\u30F3\u6E08\u307F: \u30AF\u30E9\u30A6\u30C9({0})
|
||||
ConnectionBean.CloudConnection.description=\u30AF\u30E9\u30A6\u30C9\u3078\u306E\u30EA\u30E2\u30FC\u30C8\u63A5\u7D9A - \u30B5\u30A4\u30F3\u30A4\u30F3\u6E08\u307F: \u30AF\u30E9\u30A6\u30C9({0})
|
||||
InegerCellEditorListener.NegativeNumberMessage={0}\u306B\u306F\u8CA0\u306E\u5024\u3092\u8A2D\u5B9A\u3067\u304D\u307E\u305B\u3093\u3002
|
||||
InegerCellEditorListener.NumeralMessage={0}\u306B\u306F\u6570\u5024\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044\u3002
|
||||
OpenXSDFileDialog.cancel=\u30AD\u30E3\u30F3\u30BB\u30EB
|
||||
|
||||
@@ -552,6 +552,8 @@ BusinessAppearanceComposite.textAlignment.vertical.centre=\u4E2D\u592E
|
||||
ConnectionBean.Local=\u672C\u5730
|
||||
ConnectionBean.Remote=\u8FDC\u7A0B
|
||||
ConnectionBean.DefaultConnection=\u9ED8\u8BA4\u8FDE\u63A5
|
||||
ConnectionBean.Cloud.name=\u5DF2\u767B\u5F55: \u4E91\u7AEF ({0})
|
||||
ConnectionBean.CloudConnection.description=\u4E91\u7AEF\u8FDC\u7A0B\u8FDE\u63A5 - \u5DF2\u767B\u5F55: \u4E91\u7AEF ({0})
|
||||
InegerCellEditorListener.NegativeNumberMessage={0} \u7684\u503C\u4E0D\u80FD\u8BBE\u5B9A\u4E3A\u8D1F\u6570\u3002
|
||||
InegerCellEditorListener.NumeralMessage={0} \u7684\u503C\u5E94\u8BE5\u4E3A\u6570\u5B57\u3002
|
||||
OpenXSDFileDialog.cancel=\u53D6\u6D88
|
||||
|
||||
@@ -135,6 +135,8 @@ public class FastDateParser {
|
||||
calendar.clear();
|
||||
calendar.set(year, month, day);
|
||||
return calendar.getTime();
|
||||
} catch (NumberFormatException numberFormatException){
|
||||
throw new RuntimeException("Unparseable date: \"" + source + "\""); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
} catch (Exception e) {
|
||||
pos.setErrorIndex(index);
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
SSOClientExec.error.timeout=\u30ED\u30B0\u30A4\u30F3\u5F85\u3061\u306E\u30BF\u30A4\u30E0\u30A2\u30A6\u30C8
|
||||
@@ -0,0 +1 @@
|
||||
SSOClientExec.error.timeout=\u7B49\u5F85\u767B\u5F55\u8D85\u65F6
|
||||
@@ -12,8 +12,16 @@
|
||||
// ============================================================================
|
||||
package org.talend.signon.util;
|
||||
|
||||
public class TMCRepositoryUtil {
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.eclipse.core.runtime.preferences.ConfigurationScope;
|
||||
import org.osgi.service.prefs.BackingStoreException;
|
||||
import org.osgi.service.prefs.Preferences;
|
||||
|
||||
|
||||
public class TMCRepositoryUtil {
|
||||
private static Logger LOGGER = Logger.getLogger(TMCRepositoryUtil.class);
|
||||
|
||||
public static final String REPOSITORY_CLOUD_US_ID = "cloud_us"; //$NON-NLS-1$
|
||||
|
||||
public static final String REPOSITORY_CLOUD_EU_ID = "cloud_eu"; //$NON-NLS-1$
|
||||
@@ -45,6 +53,10 @@ public class TMCRepositoryUtil {
|
||||
public static final String SUCCESS_REDIRECT_URL = "https://iam.%s.cloud.talend.com/idp/login-sso-success"; //$NON-NLS-1$
|
||||
|
||||
public static final String ONLINE_HELP_URL = "https://document-link.us.cloud.talend.com/ts_ug_launch-studio?version=%s&lang=%s&env=prd";
|
||||
|
||||
public static final String ORG_TALEND_WORKSPACE_PREF_NODE = "org.eclipse.ui.ide"; //$NON-NLS-1$
|
||||
|
||||
public static final String ORG_TALEND_RECENT_DATA_CENTERR = "org.talend.recent.datacenter";
|
||||
|
||||
public static String getBaseLoginURL(String dataCenter) {
|
||||
if (dataCenter == null) {
|
||||
@@ -55,11 +67,29 @@ public class TMCRepositoryUtil {
|
||||
|
||||
public static String getDefaultDataCenter() {
|
||||
String defaultDataCenter = "us";
|
||||
if (getRecentDataCenter() != null) {
|
||||
defaultDataCenter = getRecentDataCenter();
|
||||
}
|
||||
if (System.getProperty(SSOClientUtil.DATA_CENTER_KEY) != null) {
|
||||
defaultDataCenter = System.getProperty(SSOClientUtil.DATA_CENTER_KEY);
|
||||
}
|
||||
return defaultDataCenter;
|
||||
}
|
||||
|
||||
public static void saveRecentDataCenter(String dataCenter) {
|
||||
Preferences node = new ConfigurationScope().getNode(ORG_TALEND_WORKSPACE_PREF_NODE);
|
||||
node.put(ORG_TALEND_RECENT_DATA_CENTERR, dataCenter);
|
||||
try {
|
||||
node.flush();
|
||||
} catch (BackingStoreException e) {
|
||||
LOGGER.error("failed to store workspace location in preferences :", e); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
public static String getRecentDataCenter() {
|
||||
Preferences node = new ConfigurationScope().getNode(ORG_TALEND_WORKSPACE_PREF_NODE);
|
||||
return node.get(ORG_TALEND_RECENT_DATA_CENTERR, null);
|
||||
}
|
||||
|
||||
public static String getCloudAdminURL(String dataCenter) {
|
||||
return String.format(ADMIN_URL, dataCenter);
|
||||
|
||||
1
pom.xml
1
pom.xml
@@ -121,6 +121,7 @@
|
||||
<module>main/plugins/org.talend.libraries.persist.lookup</module>
|
||||
<module>main/plugins/org.talend.designer.maven.aether</module>
|
||||
<!--<module>test/features/org.talend.test.tos.feature</module>-->
|
||||
<module>test/plugins/org.talend.common.ui.runtime.test</module>
|
||||
<module>test/plugins/org.talend.commons.runtime.test</module>
|
||||
<module>test/plugins/org.talend.commons.ui.test</module>
|
||||
<module>test/plugins/org.talend.core.repository.test</module>
|
||||
|
||||
11
test/plugins/org.talend.common.ui.runtime.test/.classpath
Normal file
11
test/plugins/org.talend.common.ui.runtime.test/.classpath
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="test" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
28
test/plugins/org.talend.common.ui.runtime.test/.project
Normal file
28
test/plugins/org.talend.common.ui.runtime.test/.project
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>org.talend.common.ui.runtime.test</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,11 @@
|
||||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: org.talend.common.ui.runtime.test
|
||||
Bundle-SymbolicName: org.talend.common.ui.runtime.test
|
||||
Bundle-Version: 8.0.1.qualifier
|
||||
Fragment-Host: org.talend.common.ui.runtime
|
||||
Automatic-Module-Name: org.talend.common.ui.runtime.test
|
||||
Require-Bundle: org.junit;bundle-version="[4.0.0,5.0.0)",
|
||||
org.talend.utils,
|
||||
org.talend.testutils
|
||||
Bundle-ClassPath: .
|
||||
@@ -0,0 +1,4 @@
|
||||
source.. = src/main/java/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.
|
||||
12
test/plugins/org.talend.common.ui.runtime.test/pom.xml
Normal file
12
test/plugins/org.talend.common.ui.runtime.test/pom.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.talend.studio</groupId>
|
||||
<artifactId>tcommon-studio-se</artifactId>
|
||||
<version>8.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../../</relativePath>
|
||||
</parent>
|
||||
<artifactId>org.talend.common.ui.runtime.test</artifactId>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
</project>
|
||||
@@ -0,0 +1,56 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2022 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.commons.ui.runtime.image;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ImageUtilsTest {
|
||||
|
||||
@Test
|
||||
public void testCreateImageFromData() {
|
||||
IImage icon = ECoreImage.PROCESS_ICON;
|
||||
ImageDescriptor imgDesc = ImageDescriptor.createFromFile(icon.getLocation(), icon.getPath());
|
||||
|
||||
byte[] data1 = ImageUtils.saveImageToData(imgDesc);
|
||||
byte[] data2 = new byte[data1.length];
|
||||
System.arraycopy(data1, 0, data2, 0, data1.length);
|
||||
assertTrue(Arrays.equals(data1, data2));
|
||||
|
||||
ImageDescriptor createdImageFromData1 = ImageUtils.createImageFromData(data1);
|
||||
ImageDescriptor createdImageFromData2 = ImageUtils.createImageFromData(data2);
|
||||
assertEquals(createdImageFromData2, createdImageFromData1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDisposeImages() {
|
||||
IImage icon = ECoreImage.PROCESS_ICON;
|
||||
ImageDescriptor imgDesc = ImageDescriptor.createFromFile(icon.getLocation(), icon.getPath());
|
||||
|
||||
byte[] data1 = ImageUtils.saveImageToData(imgDesc);
|
||||
byte[] data2 = new byte[data1.length];
|
||||
System.arraycopy(data1, 0, data2, 0, data1.length);
|
||||
assertTrue(Arrays.equals(data1, data2));
|
||||
|
||||
ImageDescriptor createdImageFromData1 = ImageUtils.createImageFromData(data1);
|
||||
ImageUtils.disposeImages(data2);
|
||||
ImageDescriptor createdImageFromData2 = ImageUtils.createImageFromData(data1);
|
||||
assertNotSame(createdImageFromData1, createdImageFromData2);
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,8 @@
|
||||
// ============================================================================
|
||||
package org.talend.designer.core.image;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.graphics.ImageData;
|
||||
@@ -225,15 +227,11 @@ public class CoreImageProviderTest {
|
||||
|
||||
byte[] data1 = ImageUtils.saveImageToData(imgDesc);
|
||||
byte[] data2 = ImageUtils.saveImageToData(imgDesc);
|
||||
Assert.assertNotEquals(data2, data1);
|
||||
Assert.assertTrue(Arrays.equals(data2, data1));
|
||||
|
||||
ImageDescriptor newImgDesc1 = ImageUtils.createImageFromData(data1);
|
||||
ImageDescriptor newImgDesc2 = ImageUtils.createImageFromData(data2);
|
||||
Assert.assertNotEquals(newImgDesc2, newImgDesc1);
|
||||
|
||||
Image img1 = newImgDesc1.createImage();
|
||||
Image img2 = newImgDesc2.createImage();
|
||||
Assert.assertNotEquals(img2, img1);
|
||||
Assert.assertEquals(newImgDesc2, newImgDesc1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user