This is an automated email from the ASF dual-hosted git repository. nadment pushed a commit to branch 3956 in repository https://gitbox.apache.org/repos/asf/hop.git
commit 15fea8de52e80a37c23c8ace86a5cae3ae2eabf6 Author: Nicolas Adment <[email protected]> AuthorDate: Tue May 21 22:19:36 2024 +0200 Add more file types #3956 --- .../perspective/explorer/file/ParquetFileType.java | 128 +++++++++++++++++++++ .../perspective/explorer/file/ExcelFileType.java | 128 +++++++++++++++++++++ .../transforms/excel/src/main/resources/excel.svg | 2 + .../transforms/types/CsvExplorerFileType.java | 4 +- .../textfile/src/main/resources/textfile.svg | 21 ++-- .../explorer/file/types/ArchiveFileType.java | 128 +++++++++++++++++++++ ui/src/main/resources/ui/images/file.svg | 30 ++--- ui/src/main/resources/ui/images/zipfile.svg | 24 ++++ 8 files changed, 430 insertions(+), 35 deletions(-) diff --git a/plugins/tech/parquet/src/main/java/org/apache/hop/ui/hopgui/perspective/explorer/file/ParquetFileType.java b/plugins/tech/parquet/src/main/java/org/apache/hop/ui/hopgui/perspective/explorer/file/ParquetFileType.java new file mode 100644 index 0000000000..d56ee868c7 --- /dev/null +++ b/plugins/tech/parquet/src/main/java/org/apache/hop/ui/hopgui/perspective/explorer/file/ParquetFileType.java @@ -0,0 +1,128 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.hop.ui.hopgui.perspective.explorer.file; + +import java.util.Collections; +import java.util.List; +import java.util.Properties; +import org.apache.commons.vfs2.FileName; +import org.apache.commons.vfs2.FileObject; +import org.apache.hop.core.exception.HopException; +import org.apache.hop.core.file.IHasFilename; +import org.apache.hop.core.util.Utils; +import org.apache.hop.core.variables.IVariables; +import org.apache.hop.core.vfs.HopVfs; +import org.apache.hop.ui.hopgui.HopGui; +import org.apache.hop.ui.hopgui.context.IGuiContextHandler; +import org.apache.hop.ui.hopgui.file.HopFileTypePlugin; +import org.apache.hop.ui.hopgui.file.IHopFileType; +import org.apache.hop.ui.hopgui.file.IHopFileTypeHandler; +import org.apache.hop.ui.hopgui.file.empty.EmptyHopFileTypeHandler; + +@HopFileTypePlugin( + id = "ParquetFileType", + name = "Parquet File Type", + description = "Apache Parquet file handling in the explorer perspective", + image = "parquet.svg") +public class ParquetFileType implements IHopFileType { + + private static final String[] EXTENSIONS = new String[] {"*.parquet"}; + private static final String[] FILTER_EXTENSIONS = new String[] {"*.parquet"}; + private static final String[] FILTER_NAMES = new String[] {"Parquet files"}; + + @Override + public String getName() { + return "Parquet"; + } + + @Override + public String getDefaultFileExtension() { + return "parquet"; + } + + @Override + public String[] getFilterExtensions() { + return FILTER_EXTENSIONS; + } + + @Override + public String[] getFilterNames() { + return FILTER_NAMES; + } + + @Override + public Properties getCapabilities() { + return new Properties(); + } + + @Override + public boolean hasCapability(String capability) { + return false; + } + + @Override + public IHopFileTypeHandler openFile(HopGui hopGui, String filename, IVariables variables) + throws HopException { + return new EmptyHopFileTypeHandler(); + } + + @Override + public IHopFileTypeHandler newFile(HopGui hopGui, IVariables variables) throws HopException { + return new EmptyHopFileTypeHandler(); + } + + @Override + public boolean isHandledBy(String filename, boolean checkContent) throws HopException { + try { + FileObject fileObject = HopVfs.getFileObject(filename); + FileName fileName = fileObject.getName(); + String fileExtension = fileName.getExtension().toLowerCase(); + + // No extension + if (Utils.isEmpty(fileExtension)) return false; + + // Verify the extension + // + for (String typeExtension : EXTENSIONS) { + if (typeExtension.toLowerCase().endsWith(fileExtension)) { + return true; + } + } + return false; + } catch (Exception e) { + throw new HopException( + "Unable to verify file handling of file '" + filename + "' by extension", e); + } + } + + @Override + public boolean supportsFile(IHasFilename metaObject) { + return false; + } + + @Override + public List<IGuiContextHandler> getContextHandlers() { + return Collections.emptyList(); + } + + @Override + public String getFileTypeImage() { + return getClass().getAnnotation(HopFileTypePlugin.class).image(); + } +} diff --git a/plugins/transforms/excel/src/main/java/org/apache/hop/ui/hopgui/perspective/explorer/file/ExcelFileType.java b/plugins/transforms/excel/src/main/java/org/apache/hop/ui/hopgui/perspective/explorer/file/ExcelFileType.java new file mode 100644 index 0000000000..ddca3764cb --- /dev/null +++ b/plugins/transforms/excel/src/main/java/org/apache/hop/ui/hopgui/perspective/explorer/file/ExcelFileType.java @@ -0,0 +1,128 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.hop.ui.hopgui.perspective.explorer.file; + +import java.util.Collections; +import java.util.List; +import java.util.Properties; +import org.apache.commons.vfs2.FileName; +import org.apache.commons.vfs2.FileObject; +import org.apache.hop.core.exception.HopException; +import org.apache.hop.core.file.IHasFilename; +import org.apache.hop.core.util.Utils; +import org.apache.hop.core.variables.IVariables; +import org.apache.hop.core.vfs.HopVfs; +import org.apache.hop.ui.hopgui.HopGui; +import org.apache.hop.ui.hopgui.context.IGuiContextHandler; +import org.apache.hop.ui.hopgui.file.HopFileTypePlugin; +import org.apache.hop.ui.hopgui.file.IHopFileType; +import org.apache.hop.ui.hopgui.file.IHopFileTypeHandler; +import org.apache.hop.ui.hopgui.file.empty.EmptyHopFileTypeHandler; + +@HopFileTypePlugin( + id = "ExcelFileType", + name = "Excel File Type", + description = "Excel file handling in the explorer perspective", + image = "excel.svg") +public class ExcelFileType implements IHopFileType { + + private static final String[] EXTENSIONS = new String[] {"*.xls", "*.xlsx"}; + private static final String[] FILTER_EXTENSIONS = new String[] {"*.xls;*.xlsx"}; + private static final String[] FILTER_NAMES = new String[] {"Excel files"}; + + @Override + public String getName() { + return "Excel"; + } + + @Override + public String getDefaultFileExtension() { + return "xlsx"; + } + + @Override + public String[] getFilterExtensions() { + return FILTER_EXTENSIONS; + } + + @Override + public String[] getFilterNames() { + return FILTER_NAMES; + } + + @Override + public Properties getCapabilities() { + return new Properties(); + } + + @Override + public boolean hasCapability(String capability) { + return false; + } + + @Override + public IHopFileTypeHandler openFile(HopGui hopGui, String filename, IVariables variables) + throws HopException { + return new EmptyHopFileTypeHandler(); + } + + @Override + public IHopFileTypeHandler newFile(HopGui hopGui, IVariables variables) throws HopException { + return new EmptyHopFileTypeHandler(); + } + + @Override + public boolean isHandledBy(String filename, boolean checkContent) throws HopException { + try { + FileObject fileObject = HopVfs.getFileObject(filename); + FileName fileName = fileObject.getName(); + String fileExtension = fileName.getExtension().toLowerCase(); + + // No extension + if (Utils.isEmpty(fileExtension)) return false; + + // Verify the extension + // + for (String typeExtension : EXTENSIONS) { + if (typeExtension.toLowerCase().endsWith(fileExtension)) { + return true; + } + } + return false; + } catch (Exception e) { + throw new HopException( + "Unable to verify file handling of file '" + filename + "' by extension", e); + } + } + + @Override + public boolean supportsFile(IHasFilename metaObject) { + return false; + } + + @Override + public List<IGuiContextHandler> getContextHandlers() { + return Collections.emptyList(); + } + + @Override + public String getFileTypeImage() { + return getClass().getAnnotation(HopFileTypePlugin.class).image(); + } +} diff --git a/plugins/transforms/excel/src/main/resources/excel.svg b/plugins/transforms/excel/src/main/resources/excel.svg new file mode 100644 index 0000000000..359b1992de --- /dev/null +++ b/plugins/transforms/excel/src/main/resources/excel.svg @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="utf-8"?> +<svg width="800px" height="800px" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><defs><linearGradient id="a" x1="4.494" y1="-2092.086" x2="13.832" y2="-2075.914" gradientTransform="translate(0 2100)" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#18884f"/><stop offset="0.5" stop-color="#117e43"/><stop offset="1" stop-color="#0b6631"/></linearGradient></defs><title>file_type_excel</title><path d="M19.581,15.35,8.512,13.4V27 [...] \ No newline at end of file diff --git a/plugins/transforms/textfile/src/main/java/org/apache/hop/pipeline/transforms/types/CsvExplorerFileType.java b/plugins/transforms/textfile/src/main/java/org/apache/hop/pipeline/transforms/types/CsvExplorerFileType.java index f94708faea..15470398be 100644 --- a/plugins/transforms/textfile/src/main/java/org/apache/hop/pipeline/transforms/types/CsvExplorerFileType.java +++ b/plugins/transforms/textfile/src/main/java/org/apache/hop/pipeline/transforms/types/CsvExplorerFileType.java @@ -32,8 +32,8 @@ import org.apache.hop.ui.hopgui.perspective.explorer.file.types.text.BaseTextExp @HopFileTypePlugin( id = "CsvExplorerFileType", - name = "JSON File Type", - description = "JSON file handling in the explorer perspective", + name = "CSV File Type", + description = "CSV file handling in the explorer perspective", image = "textfile.svg") public class CsvExplorerFileType extends BaseTextExplorerFileType<TextExplorerFileTypeHandler> implements IExplorerFileType<TextExplorerFileTypeHandler> { diff --git a/plugins/transforms/textfile/src/main/resources/textfile.svg b/plugins/transforms/textfile/src/main/resources/textfile.svg index 98d3b7dcc6..92853272ec 100644 --- a/plugins/transforms/textfile/src/main/resources/textfile.svg +++ b/plugins/transforms/textfile/src/main/resources/textfile.svg @@ -1,15 +1,12 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- Generator: Adobe Illustrator 17.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> +<!-- Generator: Adobe Illustrator 14.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 43363) --> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> -<svg version="1.1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" - width="42px" height="42px" viewBox="0 0 42 42" enable-background="new 0 0 42 42"> - <g> - <path fill="#C9E8FB" d="M24.932,13.053V8.795H11.553v24.411l11.515,0l6.162-6.162l-0.04-13.991H24.932z M17.652,24.783H14.45 - v-0.801h3.201V24.783z M26.353,21.4H14.45V20.6h11.902V21.4z M26.353,18.018H14.45v-0.801h11.902V18.018z"/> - <polygon fill="#0E3A5A" points="30.89,13.063 29.181,11.354 26.633,11.354 26.633,8.806 24.922,7.096 9.853,7.096 9.853,34.905 - 21.369,34.905 23.068,33.206 11.553,33.206 11.553,8.795 24.932,8.795 24.932,13.053 29.19,13.053 29.23,27.044 30.925,25.348 "/> - <rect x="14.45" y="17.217" fill="#0E3A5A" width="11.902" height="0.801"/> - <rect x="14.45" y="20.6" fill="#0E3A5A" width="11.902" height="0.801"/> - <rect x="14.45" y="23.982" fill="#0E3A5A" width="3.201" height="0.801"/> - </g> +<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" + width="42px" height="42px" viewBox="0 0 42 42" enable-background="new 0 0 42 42" xml:space="preserve"> +<path fill="#C9E8FB" d="M7.652,2.564v36.868h26.632V8.997h-6.426V2.564"/> +<path fill="#0E3A5A" d="M34.271,6.429h-3.847V2.583L27.843,0H5.085v42h31.767V9.008L34.271,6.429z M12.894,2.565h14.964v6.431h6.426 + v30.436H7.652V2.565h3.43"/> +<rect x="11.98" y="17.551" fill="#0E3A5A" width="17.975" height="1.21"/> +<rect x="11.98" y="22.662" fill="#0E3A5A" width="17.975" height="1.209"/> +<rect x="11.98" y="27.769" fill="#0E3A5A" width="4.836" height="1.21"/> </svg> diff --git a/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/explorer/file/types/ArchiveFileType.java b/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/explorer/file/types/ArchiveFileType.java new file mode 100644 index 0000000000..a9dcc0d560 --- /dev/null +++ b/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/explorer/file/types/ArchiveFileType.java @@ -0,0 +1,128 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.hop.ui.hopgui.perspective.explorer.file.types; + +import java.util.Collections; +import java.util.List; +import java.util.Properties; +import org.apache.commons.vfs2.FileName; +import org.apache.commons.vfs2.FileObject; +import org.apache.hop.core.exception.HopException; +import org.apache.hop.core.file.IHasFilename; +import org.apache.hop.core.util.Utils; +import org.apache.hop.core.variables.IVariables; +import org.apache.hop.core.vfs.HopVfs; +import org.apache.hop.ui.hopgui.HopGui; +import org.apache.hop.ui.hopgui.context.IGuiContextHandler; +import org.apache.hop.ui.hopgui.file.HopFileTypePlugin; +import org.apache.hop.ui.hopgui.file.IHopFileType; +import org.apache.hop.ui.hopgui.file.IHopFileTypeHandler; +import org.apache.hop.ui.hopgui.file.empty.EmptyHopFileTypeHandler; + +@HopFileTypePlugin( + id = "ArchiveExplorerFileType", + name = "Archive File Type", + description = "Archive file handling in the explorer perspective", + image = "ui/images/zipfile.svg") +public class ArchiveFileType implements IHopFileType { + + private static final String[] EXTENSIONS = new String[] {"*.zip", "*.7z", "*.gz", "*.rar"}; + private static final String[] FILTER_EXTENSIONS = new String[] {"*.zip;*.7z;*.gz;*.rar"}; + private static final String[] FILTER_NAMES = new String[] {"Archive files"}; + + @Override + public String getName() { + return "archive"; + } + + @Override + public String getDefaultFileExtension() { + return "zip"; + } + + @Override + public String[] getFilterExtensions() { + return FILTER_EXTENSIONS; + } + + @Override + public String[] getFilterNames() { + return FILTER_NAMES; + } + + @Override + public Properties getCapabilities() { + return new Properties(); + } + + @Override + public boolean hasCapability(String capability) { + return false; + } + + @Override + public IHopFileTypeHandler openFile(HopGui hopGui, String filename, IVariables variables) + throws HopException { + return new EmptyHopFileTypeHandler(); + } + + @Override + public IHopFileTypeHandler newFile(HopGui hopGui, IVariables variables) throws HopException { + return new EmptyHopFileTypeHandler(); + } + + @Override + public boolean isHandledBy(String filename, boolean checkContent) throws HopException { + try { + FileObject fileObject = HopVfs.getFileObject(filename); + FileName fileName = fileObject.getName(); + String fileExtension = fileName.getExtension().toLowerCase(); + + // No extension + if (Utils.isEmpty(fileExtension)) return false; + + // Verify the extension + // + for (String typeExtension : EXTENSIONS) { + if (typeExtension.toLowerCase().endsWith(fileExtension)) { + return true; + } + } + return false; + } catch (Exception e) { + throw new HopException( + "Unable to verify file handling of file '" + filename + "' by extension", e); + } + } + + @Override + public boolean supportsFile(IHasFilename metaObject) { + return false; + } + + @Override + public List<IGuiContextHandler> getContextHandlers() { + return Collections.emptyList(); + } + + @Override + public String getFileTypeImage() { + return getClass().getAnnotation(HopFileTypePlugin.class).image(); + } +} diff --git a/ui/src/main/resources/ui/images/file.svg b/ui/src/main/resources/ui/images/file.svg index 060e92c87b..9f4133d269 100644 --- a/ui/src/main/resources/ui/images/file.svg +++ b/ui/src/main/resources/ui/images/file.svg @@ -1,21 +1,9 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!-- Generator: Adobe Illustrator 17.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> -<svg - xmlns="http://www.w3.org/2000/svg" - version="1.1" - x="0px" - y="0px" - width="42px" - height="42px" - viewBox="0 0 42 42" - enable-background="new 0 0 42 42" -> - <path - style="fill:#c9e8fb" - d="m 12.151394,8.7320242 0,24.5025848 17.663853,0 -0.05849,-20.228308 -4.250242,0 0,-4.2742768 -13.355121,0 z" - /> - <path - fill="#0E3A5A" - d="M29.778,11.352h-2.547V8.805L25.52,7.094H10.452v27.811h21.099l-0.063-21.842L29.778,11.352z M29.788,13.052 l0.058,20.152H12.152V8.794h13.379v4.258H29.788z" - /> -</svg> \ No newline at end of file +<?xml version="1.0" encoding="utf-8"?> +<!-- Generator: Adobe Illustrator 14.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 43363) --> +<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> +<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" + width="42px" height="42px" viewBox="0 0 42 42" enable-background="new 0 0 42 42" xml:space="preserve"> +<path fill="#C9E8FB" d="M6.608,2.564v36.867H34.49V8.996h-6.729V2.564"/> +<path fill="#0E3A5A" d="M34.477,6.429h-4.029V2.583L27.745,0H3.921v42h33.257V9.008L34.477,6.429z M12.097,2.565h15.665v6.432h6.729 + v30.436H6.608V2.565h3.591"/> +</svg> diff --git a/ui/src/main/resources/ui/images/zipfile.svg b/ui/src/main/resources/ui/images/zipfile.svg new file mode 100644 index 0000000000..f632ff773e --- /dev/null +++ b/ui/src/main/resources/ui/images/zipfile.svg @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Generator: Adobe Illustrator 14.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 43363) --> +<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> +<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" + width="42px" height="42px" viewBox="0 0 42 42" enable-background="new 0 0 42 42" xml:space="preserve"> +<g> + <path fill="#FFECCE" d="M27.858,2.565H12.894v2.252h-1.813V2.565h-3.43v36.867h26.632V8.997h-6.426V2.565z M11.08,8.479h1.813 + v3.548H11.08V8.479z M11.08,15.689h1.813v3.548H11.08V15.689z M11.08,22.879h1.813v3.546H11.08V22.879z M14.871,35.685h-3.933 + v-8.365h3.933V35.685z M14.98,22.842h-1.812v-3.547h1.812V22.842z M14.98,15.632h-1.812v-3.548h1.812V15.632z M14.98,8.422h-1.812 + V4.875h1.812V8.422z"/> + <path fill="#FFECCE" d="M12.058,34.907h1.694c0.275,0,0.495-0.22,0.495-0.494v-0.764c0-0.274-0.22-0.495-0.495-0.495h-1.694 + c-0.273,0-0.495,0.221-0.495,0.495v0.764C11.563,34.685,11.786,34.907,12.058,34.907z"/> + <path fill="#FF9C04" d="M34.271,6.429h-3.847V2.583L27.843,0H5.085v42h31.767V9.008L34.271,6.429z M34.284,39.433H7.652V2.565h3.43 + v2.252h1.813V2.565h14.964v6.431h6.426V39.433z"/> + <rect x="11.08" y="8.479" fill="#FF9C04" width="1.813" height="3.548"/> + <rect x="11.08" y="15.689" fill="#FF9C04" width="1.813" height="3.548"/> + <rect x="13.168" y="4.875" fill="#FF9C04" width="1.812" height="3.547"/> + <rect x="13.168" y="12.085" fill="#FF9C04" width="1.812" height="3.549"/> + <rect x="13.168" y="19.294" fill="#FF9C04" width="1.812" height="3.547"/> + <rect x="11.08" y="22.879" fill="#FF9C04" width="1.813" height="3.546"/> + <path fill="#FF9C04" d="M10.938,35.685h3.933v-8.365h-3.933V35.685z M11.563,33.649c0-0.274,0.222-0.495,0.495-0.495h1.694 + c0.275,0,0.495,0.221,0.495,0.495v0.764c0,0.274-0.22,0.494-0.495,0.494h-1.694c-0.273,0-0.495-0.22-0.495-0.494V33.649z"/> +</g> +</svg>
