-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Proposal: Opening/Closing Mechanism for Zip Files
The Eclipse IDE has no built in functionality to open Zip Files and read or manipulate their content. Because of this, other operations like searching inside of Zip Files or comparing two Zip Files were also not possible. This PR introduces UI support for accesing the opening/closing mechanism for Zip Files over the UI-menu. It is accessed by right-clicking the Zip File that should be opened and then clicking on "Open Zip File". Closing is accessed the same way but when right-clicking an opened Zip File. Please see #1408 for the PR on the repository **eclipse.platform** for the platform implementation and further information. Co-Authored-By: David Erdös <[email protected]> remove javadoc
- Loading branch information
1 parent
e5c00ef
commit bb2d2c2
Showing
6 changed files
with
191 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
...es/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/ZipFileSystemContributor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 IBM Corporation and others. | ||
* | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* IBM Corporation - initial API and implementation | ||
*******************************************************************************/ | ||
|
||
package org.eclipse.ui.ide.fileSystem.zip; | ||
|
||
import java.io.File; | ||
import java.net.URI; | ||
import java.net.URISyntaxException; | ||
|
||
import org.eclipse.swt.widgets.FileDialog; | ||
import org.eclipse.swt.widgets.Shell; | ||
import org.eclipse.ui.ide.fileSystem.FileSystemContributor; | ||
|
||
/** | ||
* ZipFileSystemContributor is the zip example of a file system contributor. | ||
* | ||
* @since 3.23 | ||
*/ | ||
public class ZipFileSystemContributor extends FileSystemContributor { | ||
|
||
public ZipFileSystemContributor() { | ||
super(); | ||
} | ||
|
||
@Override | ||
public URI getURI(String pathString) { | ||
try { | ||
if (pathString.startsWith("zip")) //$NON-NLS-1$ | ||
return new URI(pathString); | ||
} catch (URISyntaxException e1) { | ||
return null; | ||
} | ||
if (File.separatorChar != '/') | ||
pathString = pathString.replace(File.separatorChar, '/'); | ||
final int length = pathString.length(); | ||
StringBuffer pathBuf = new StringBuffer(length + 1); | ||
pathBuf.append("file:"); //$NON-NLS-1$ | ||
// There must be a leading slash in a hierarchical URI | ||
if (length > 0 && (pathString.charAt(0) != '/')) | ||
pathBuf.append('/'); | ||
// additional double-slash for UNC paths to distinguish from host | ||
// separator | ||
if (pathString.startsWith("//")) //$NON-NLS-1$ | ||
pathBuf.append('/').append('/'); | ||
pathBuf.append(pathString); | ||
try { | ||
//scheme, host, path, query, fragment | ||
return new URI("zip", null, "/", pathBuf.toString(), null); //$NON-NLS-1$ //$NON-NLS-2$ | ||
} catch (URISyntaxException e) { | ||
return null; | ||
} | ||
} | ||
|
||
@Override | ||
public URI browseFileSystem(String initialPath, Shell shell) { | ||
|
||
FileDialog dialog = new FileDialog(shell); | ||
|
||
if (initialPath.length() > 0) | ||
dialog.setFilterPath(initialPath); | ||
|
||
dialog.setFilterExtensions(new String[] {"*.zip"});//$NON-NLS-1$ | ||
|
||
String selectedFile = dialog.open(); | ||
if (selectedFile == null) | ||
return null; | ||
return getURI(selectedFile); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters