From 0d7c517195c1b20c7e7232a4b9b2ff537404fd25 Mon Sep 17 00:00:00 2001 From: Michael Bangas Date: Tue, 11 Jun 2024 13:43:42 +0200 Subject: [PATCH 01/20] Proposal: Opening/Closing Mechanism for Zip Files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- bundles/org.eclipse.ui.ide/plugin.properties | 4 +- bundles/org.eclipse.ui.ide/plugin.xml | 70 +++++++++++++++- .../fileSystem/zip/CloseZipFileHandler.java | 59 ++++++++++++++ .../fileSystem/zip/OpenZipFileHandler.java | 79 ++++++++++++++++++ .../zip/ZipFileSystemContributor.java | 81 +++++++++++++++++++ .../wizards/datatransfer/ImportOperation.java | 9 +++ 6 files changed, 299 insertions(+), 3 deletions(-) create mode 100644 bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/CloseZipFileHandler.java create mode 100644 bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/OpenZipFileHandler.java create mode 100644 bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/ZipFileSystemContributor.java diff --git a/bundles/org.eclipse.ui.ide/plugin.properties b/bundles/org.eclipse.ui.ide/plugin.properties index 6256c252eff..a5db42dad8c 100644 --- a/bundles/org.eclipse.ui.ide/plugin.properties +++ b/bundles/org.eclipse.ui.ide/plugin.properties @@ -201,7 +201,9 @@ command.copyMarkerResourceQualifiedName.name=Copy Resource Qualified Name To Cli command.copyMarkerResourceQualifiedName.label=Resource Qualified Name command.copyMarkerResourceQualifiedName.description=Copies markers resource qualified name to the clipboard command.copyMarkerResourceQualifiedName.mnemonic=Q - +command.name.openZipFile=Open Zip File +command.name.closeZipFile=Close Zip File +filesystem.file.zip=Zip file command.showInQuickMenu.name= Show In... command.showInQuickMenu.description = Open the Show In menu diff --git a/bundles/org.eclipse.ui.ide/plugin.xml b/bundles/org.eclipse.ui.ide/plugin.xml index b170640a475..7a3514ae3fd 100644 --- a/bundles/org.eclipse.ui.ide/plugin.xml +++ b/bundles/org.eclipse.ui.ide/plugin.xml @@ -1089,7 +1089,17 @@ id="org.eclipse.ui.ide.markers.copyMarkerResourceQualifiedName" name="%command.copyMarkerResourceQualifiedName.name" defaultHandler="org.eclipse.ui.internal.views.markers.CopyMarkerResourceQualifiedNameHandler"> - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2718,5 +2778,11 @@ markerType="org.eclipse.core.resources.noExplicitEncoding"> - + + + diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/CloseZipFileHandler.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/CloseZipFileHandler.java new file mode 100644 index 00000000000..d56596c9afe --- /dev/null +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/CloseZipFileHandler.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright (c) 2024 Vector Informatik GmbH 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: Vector Informatik GmbH - initial API and implementation + *******************************************************************************/ + +package org.eclipse.ui.ide.fileSystem.zip; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.ZipFileTransformer; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.handlers.HandlerUtil; + +/** + * This class represents a handler for closing an opened zip file. + * + * @since 3.132 + */ +public class CloseZipFileHandler extends AbstractHandler { + + /** + * Executes the handler action, which involves closing an opened zip file. + * + * @param event The event triggering the execution of this handler. + */ + @Override + public Object execute(ExecutionEvent event) { + Shell shell = HandlerUtil.getActiveShell(event); + ISelection selection = HandlerUtil.getCurrentSelection(event); + + if (!(selection instanceof IStructuredSelection)) { + return null; + } + + Object element = ((IStructuredSelection) selection).getFirstElement(); + + if (!(element instanceof IFolder)) { + return null; + } + try { + ZipFileTransformer.closeZipFile((IFolder) element); + } catch (Exception e) { + MessageDialog.openError(shell, "Error", "Error opening zip file"); //$NON-NLS-1$ //$NON-NLS-2$ + e.printStackTrace(); + } + return null; + } +} diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/OpenZipFileHandler.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/OpenZipFileHandler.java new file mode 100644 index 00000000000..d0218b39c6b --- /dev/null +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/OpenZipFileHandler.java @@ -0,0 +1,79 @@ +/******************************************************************************* + * Copyright (c) 2024 Vector Informatik GmbH 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: Vector Informatik GmbH - initial API and implementation + *******************************************************************************/ + +package org.eclipse.ui.ide.fileSystem.zip; + +import java.lang.reflect.InvocationTargetException; +import java.net.URISyntaxException; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.ZipFileTransformer; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.dialogs.ProgressMonitorDialog; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.handlers.HandlerUtil; + +/** + * This class represents a handler for opening zip files. + * + * @since 3.132 + */ +public class OpenZipFileHandler extends AbstractHandler { + + /** + * Executes the handler action, which involves opening a zip file selected by + * the user. + * + * @param event The event triggering the execution of this handler. + */ + @Override + public Object execute(ExecutionEvent event) { + Shell shell = HandlerUtil.getActiveShell(event); + ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell); + ISelection selection = HandlerUtil.getCurrentSelection(event); + if (!(selection instanceof IStructuredSelection)) { + return null; + } + + Object element = ((IStructuredSelection) selection).getFirstElement(); + + if (!(element instanceof IFile)) { + return null; + } + try { + dialog.run(true, false, new IRunnableWithProgress() { + @Override + public void run(IProgressMonitor monitor) throws InterruptedException { + monitor.beginTask("Opening Zip File", 5); //$NON-NLS-1$ + try { + ZipFileTransformer.openZipFile((IFile) element, monitor, true); + } catch (URISyntaxException | CoreException e) { + throw new InterruptedException(e.getMessage()); + } + monitor.worked(1); + } + }); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } catch (InterruptedException e) { + MessageDialog.openError(shell, "Error opening zip file", e.getMessage()); //$NON-NLS-1$ + } + return null; + } +} diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/ZipFileSystemContributor.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/ZipFileSystemContributor.java new file mode 100644 index 00000000000..a7d2ace2d40 --- /dev/null +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/ZipFileSystemContributor.java @@ -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); + } + +} diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/wizards/datatransfer/ImportOperation.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/wizards/datatransfer/ImportOperation.java index 7eb4b7bf43a..e90b19d6a82 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/wizards/datatransfer/ImportOperation.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/wizards/datatransfer/ImportOperation.java @@ -25,6 +25,7 @@ import java.util.zip.ZipEntry; import org.eclipse.core.filesystem.URIUtil; +import org.eclipse.core.filesystem.ZipFileUtil; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; @@ -544,6 +545,14 @@ void importFile(Object fileObject, int policy, IProgressMonitor mon) { targetResource.createLink( createRelativePath(IPath.fromOSString(provider.getFullPath(fileObject)), targetResource), 0, subMonitor.split(50)); + } else if (ZipFileUtil.isOpenZipFile(targetResource.getLocationURI())) {// $NON-NLS-1$ + // When overwriting an opened Zip File with a new Zip File that has the same + // name, the opened zip file needs to be deleted first. + IFolder openedZipFile = targetResource.getProject().getFolder(targetResource.getName()); + if (openedZipFile.exists()) { + openedZipFile.delete(true, subMonitor.split(50)); + } + targetResource.create(contentStream, false, subMonitor.split(50)); } else if (targetResource.exists()) { if (targetResource.isLinked()) { targetResource.delete(true, subMonitor.split(50)); From 826ab83147bef61fc0c8f38581927d415e55c79d Mon Sep 17 00:00:00 2001 From: Michael Bangas Date: Tue, 18 Jun 2024 13:57:06 +0200 Subject: [PATCH 02/20] change Open/Close Zip error handling This change removes the ProgressDialog in the OpenZipHandler because the operation is so fast that it is not needed. Errors are logged instead of being printed. --- .../fileSystem/zip/CloseZipFileHandler.java | 12 ++++---- .../fileSystem/zip/OpenZipFileHandler.java | 30 ++++--------------- 2 files changed, 12 insertions(+), 30 deletions(-) diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/CloseZipFileHandler.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/CloseZipFileHandler.java index d56596c9afe..66f6e3b9d8e 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/CloseZipFileHandler.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/CloseZipFileHandler.java @@ -12,15 +12,17 @@ package org.eclipse.ui.ide.fileSystem.zip; +import java.net.URISyntaxException; + import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.ZipFileTransformer; -import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.handlers.HandlerUtil; +import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; /** * This class represents a handler for closing an opened zip file. @@ -36,7 +38,6 @@ public class CloseZipFileHandler extends AbstractHandler { */ @Override public Object execute(ExecutionEvent event) { - Shell shell = HandlerUtil.getActiveShell(event); ISelection selection = HandlerUtil.getCurrentSelection(event); if (!(selection instanceof IStructuredSelection)) { @@ -50,9 +51,8 @@ public Object execute(ExecutionEvent event) { } try { ZipFileTransformer.closeZipFile((IFolder) element); - } catch (Exception e) { - MessageDialog.openError(shell, "Error", "Error opening zip file"); //$NON-NLS-1$ //$NON-NLS-2$ - e.printStackTrace(); + } catch (CoreException | URISyntaxException e) { + IDEWorkbenchPlugin.log(e.getMessage(), e); } return null; } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/OpenZipFileHandler.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/OpenZipFileHandler.java index d0218b39c6b..dd9cc51bd90 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/OpenZipFileHandler.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/OpenZipFileHandler.java @@ -12,7 +12,6 @@ package org.eclipse.ui.ide.fileSystem.zip; -import java.lang.reflect.InvocationTargetException; import java.net.URISyntaxException; import org.eclipse.core.commands.AbstractHandler; @@ -20,10 +19,7 @@ import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.ZipFileTransformer; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.dialogs.ProgressMonitorDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.swt.widgets.Shell; @@ -45,35 +41,21 @@ public class OpenZipFileHandler extends AbstractHandler { @Override public Object execute(ExecutionEvent event) { Shell shell = HandlerUtil.getActiveShell(event); - ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell); ISelection selection = HandlerUtil.getCurrentSelection(event); if (!(selection instanceof IStructuredSelection)) { return null; } Object element = ((IStructuredSelection) selection).getFirstElement(); - if (!(element instanceof IFile)) { return null; } - try { - dialog.run(true, false, new IRunnableWithProgress() { - @Override - public void run(IProgressMonitor monitor) throws InterruptedException { - monitor.beginTask("Opening Zip File", 5); //$NON-NLS-1$ - try { - ZipFileTransformer.openZipFile((IFile) element, monitor, true); - } catch (URISyntaxException | CoreException e) { - throw new InterruptedException(e.getMessage()); - } - monitor.worked(1); - } - }); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } catch (InterruptedException e) { - MessageDialog.openError(shell, "Error opening zip file", e.getMessage()); //$NON-NLS-1$ - } + + try { + ZipFileTransformer.openZipFile((IFile) element, true); + } catch (URISyntaxException | CoreException e) { + MessageDialog.openError(shell, "Error opening zip file", e.getMessage()); //$NON-NLS-1$ + } return null; } } From e8b1b9dc610d591c447b4c19045d4ffc202b3c45 Mon Sep 17 00:00:00 2001 From: Michael Bangas Date: Tue, 18 Jun 2024 14:02:06 +0200 Subject: [PATCH 03/20] log exception so that stack trace does not get lost --- .../org/eclipse/ui/ide/fileSystem/zip/OpenZipFileHandler.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/OpenZipFileHandler.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/OpenZipFileHandler.java index dd9cc51bd90..9d34bc13f4c 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/OpenZipFileHandler.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/OpenZipFileHandler.java @@ -24,6 +24,7 @@ import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.handlers.HandlerUtil; +import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; /** * This class represents a handler for opening zip files. @@ -54,6 +55,7 @@ public Object execute(ExecutionEvent event) { try { ZipFileTransformer.openZipFile((IFile) element, true); } catch (URISyntaxException | CoreException e) { + IDEWorkbenchPlugin.log(e.getMessage(), e); MessageDialog.openError(shell, "Error opening zip file", e.getMessage()); //$NON-NLS-1$ } return null; From d7695891ce9292830aa1330df216e43be37734bc Mon Sep 17 00:00:00 2001 From: Michael Bangas Date: Mon, 29 Jul 2024 13:22:45 +0200 Subject: [PATCH 04/20] Failed attempt to include open behaviour to "Open" button Please mind that the "Open Zip File" and "Close Zip File" Buttons are still implemented in the menu --- bundles/org.eclipse.ui.ide/plugin.xml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/bundles/org.eclipse.ui.ide/plugin.xml b/bundles/org.eclipse.ui.ide/plugin.xml index 7a3514ae3fd..a678667e178 100644 --- a/bundles/org.eclipse.ui.ide/plugin.xml +++ b/bundles/org.eclipse.ui.ide/plugin.xml @@ -2449,6 +2449,19 @@ + + + + + + + + From 52d2cf30f919c378c9e146407a7d137e2c3929de Mon Sep 17 00:00:00 2001 From: Michael Bangas Date: Wed, 31 Jul 2024 09:11:13 +0200 Subject: [PATCH 05/20] allow JAR and WAR files to be opened --- bundles/org.eclipse.ui.ide/plugin.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bundles/org.eclipse.ui.ide/plugin.xml b/bundles/org.eclipse.ui.ide/plugin.xml index a678667e178..6ab2b5b489d 100644 --- a/bundles/org.eclipse.ui.ide/plugin.xml +++ b/bundles/org.eclipse.ui.ide/plugin.xml @@ -2243,6 +2243,14 @@ property="org.eclipse.core.resources.extension" value="zip"> + + + + From f9fe1aa720294bb344950df59ee6beb1dcd7ce61 Mon Sep 17 00:00:00 2001 From: Michael Bangas Date: Mon, 5 Aug 2024 09:43:51 +0200 Subject: [PATCH 06/20] Revert "Failed attempt to include open behaviour to "Open" button" This reverts commit 4a87a0c2a4c687fa8b4702be716becaed0118ef2. --- bundles/org.eclipse.ui.ide/plugin.xml | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/bundles/org.eclipse.ui.ide/plugin.xml b/bundles/org.eclipse.ui.ide/plugin.xml index 6ab2b5b489d..cf80867e144 100644 --- a/bundles/org.eclipse.ui.ide/plugin.xml +++ b/bundles/org.eclipse.ui.ide/plugin.xml @@ -2457,19 +2457,6 @@ - - - - - - - - From 34a046dc3e55bb185b1f9ff0959b0f6030d2952c Mon Sep 17 00:00:00 2001 From: Michael Bangas Date: Mon, 5 Aug 2024 14:12:04 +0200 Subject: [PATCH 07/20] Implement new Decorator for zip files --- .../icons/full/ovr16/zipfile_ovr.png | Bin 0 -> 289 bytes bundles/org.eclipse.ui.ide/plugin.properties | 2 + bundles/org.eclipse.ui.ide/plugin.xml | 17 ++++ .../ui/internal/ide/ZipFileDecorator.java | 89 ++++++++++++++++++ 4 files changed, 108 insertions(+) create mode 100644 bundles/org.eclipse.ui.ide/icons/full/ovr16/zipfile_ovr.png create mode 100644 bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/ZipFileDecorator.java diff --git a/bundles/org.eclipse.ui.ide/icons/full/ovr16/zipfile_ovr.png b/bundles/org.eclipse.ui.ide/icons/full/ovr16/zipfile_ovr.png new file mode 100644 index 0000000000000000000000000000000000000000..636a8ade9cb838cdb7751e743f68fa43d4eb93a1 GIT binary patch literal 289 zcmeAS@N?(olHy`uVBq!ia0vp^>_E)H!3HEvS)PI@#^NA%Cx&(BWL^R}Ea{HEjtmSN z`?>!lvI6;>1s;*b3=DjSK$uZf!>a)(xXshWF+?KVw`cz;_XLL4`@0K;Po?f)_^UQs zXWaqY6Q&)#ol_1fD6$!9ss{ONvWZ{+vU=I)<;6!n+oVLg&3i85>L}t`65H-_=lfZU zzWEb9-dD<<-t<9t>5ucJv0rNYGj59=HYku`KfUS4-#Qk@1H0C7XoiFy{a$;>z~y>r z&h2Lwd@eG_GiH5bU6#2>gKOREP4BHA+4xUValCiE^sE6-&h29+z8&9dHBV1kwQAp{ hOsPvIsq@nRF&r=0%Fvc?`y1#322WQ%mvv4FO#l^FaZUgL literal 0 HcmV?d00001 diff --git a/bundles/org.eclipse.ui.ide/plugin.properties b/bundles/org.eclipse.ui.ide/plugin.properties index a5db42dad8c..93829bedd16 100644 --- a/bundles/org.eclipse.ui.ide/plugin.properties +++ b/bundles/org.eclipse.ui.ide/plugin.properties @@ -115,6 +115,8 @@ DecoratorSpecificContentType.label = File Icons Based On Content Analysis DecoratorSpecificContentType.description = Displays an icon based on the examination of the contents of a file. This yields a more precise answer than one derived simply from the file name. DecoratorSpecificResourceFilterType.label = Containers with Resource Filters DecoratorSpecificResourceFilterType.description = Displays an icon based on the presence of resource filters on a container. +DecoratorZipFile.label = Zip Files +DecoratorZipFile.description = Adds an icon decoration to linked zip files. OpenWorkspaceFileAction.label = Open Reso&urce... SelectWorkingSetsAction.label = &Working Sets SelectWorkingSetsAction.tooltip = Modify window working set diff --git a/bundles/org.eclipse.ui.ide/plugin.xml b/bundles/org.eclipse.ui.ide/plugin.xml index cf80867e144..6a738588620 100644 --- a/bundles/org.eclipse.ui.ide/plugin.xml +++ b/bundles/org.eclipse.ui.ide/plugin.xml @@ -358,6 +358,23 @@ + + + %DecoratorZipFile.description + + + + + + ZIP_FILE; + + private static final Optional ZIP_FILE_WARNING; + + static { + ZIP_FILE = ResourceLocator.imageDescriptorFromBundle(IDEWorkbenchPlugin.IDE_WORKBENCH, + "$nl$/icons/full/ovr16/zipfile_ovr.png"); //$NON-NLS-1$ + ZIP_FILE_WARNING = ResourceLocator.imageDescriptorFromBundle(IDEWorkbenchPlugin.IDE_WORKBENCH, + "$nl$/icons/full/ovr16/zipfile_ovr.png"); //$NON-NLS-1$ + } + + /** + * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(ILabelProviderListener) + */ + @Override + public void addListener(ILabelProviderListener listener) { + } + + /** + * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose() + */ + @Override + public void dispose() { + // no resources to dispose + } + + /** + * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, + * java.lang.String) + */ + @Override + public boolean isLabelProperty(Object element, String property) { + return false; + } + + /** + * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(ILabelProviderListener) + */ + @Override + public void removeListener(ILabelProviderListener listener) { + } + + /** + * Adds the linked resource overlay if the given element is a linked resource. + * + * @param element element to decorate + * @param decoration The decoration we are adding to + * @see org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate(Object, + * IDecoration) + */ + @Override + public void decorate(Object element, IDecoration decoration) { + if (element instanceof VirtualZipFolder folder) { + URI location = folder.getLocationURI(); + if (ZipFileUtil.isOpenZipFile(location)) { + IFileInfo fileInfo = null; + if (location != null) { + fileInfo = IDEResourceInfoUtils.getFileInfo(location); + } + if (fileInfo != null && fileInfo.exists()) { + ZIP_FILE.ifPresent(decoration::addOverlay); + } else { + ZIP_FILE_WARNING.ifPresent(decoration::addOverlay); + } + } + } + } +} From 7f18acf696b0332fab2f175aebdc66088d7dda94 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 8 Aug 2024 14:14:05 +0200 Subject: [PATCH 08/20] use jar icon for VirtualZipFolders --- .../icons/full/obj16/zip_file_open.png | Bin 0 -> 599 bytes .../icons/full/obj16/zip_file_open@2x.png | Bin 0 -> 1474 bytes bundles/org.eclipse.ui.ide/plugin.xml | 4 +- .../ui/internal/ide/ZipFileDecorator.java | 97 ++++++------------ 4 files changed, 31 insertions(+), 70 deletions(-) create mode 100644 bundles/org.eclipse.ui.ide/icons/full/obj16/zip_file_open.png create mode 100644 bundles/org.eclipse.ui.ide/icons/full/obj16/zip_file_open@2x.png diff --git a/bundles/org.eclipse.ui.ide/icons/full/obj16/zip_file_open.png b/bundles/org.eclipse.ui.ide/icons/full/obj16/zip_file_open.png new file mode 100644 index 0000000000000000000000000000000000000000..9af044391eacb2d7df41c28107674c351a8c5cca GIT binary patch literal 599 zcmV-d0;v6oP)dZPFxN|0ZeDw9NMLCewG>UhTreJ)C>;yXQPfhK7!Nr58rVnD8*mgsu`@ zVVQTAS!Vtc(FK+Xo-HuJbB-ectHBX*&~IVTD`B9g(U+6x*B0)k9-S-iiW+G0a@!p)_VkGAXk#{EI=2>r>PUR0B>Y1 zl*&lh;uMssI_gRny3w=LP`lu29Z>7szBjz~z!u<-elMq48983Hiff7i?H{178dh$L zbm5O}WNiViw_l~rqCz@Q$p|_s|3}bz#D^|ek~7a<%&oAt0H=4!0%S`Hc0~>4hGF?& zs$B12ml(TQlrjD)VGp?bJSLe1nWAd>keAw|ZQYU?=XeF?1-B;`?Ew$pP@)MieK2>^ zi(g_JJ3<@VB+e8M0M6Hmk}bd;OeJ##o*31%3axI)IHt_l%+Xl^uDLJkwt$)F>TrVI zka-~wRuHkn*O23y_ZpV6VYT#fn|6^Em z2Vm*@5SHE#VCmV5Y3xoCqr3eY*{)X~Y9$<& z>#DwQ=#SJk8w9H>4reG0?`j5tXa=EJ7U6hNbnS~|VDrXt;-X&op`kx`xUp~dLj{+q zxShwEZqC&<>o+DGVJrnxaId6Uu(TL7lFTByRy?niAiS$-OwNaKLN%0^DFPuJ!dqA{J1p;hi?tbp_G_?kY&D_$ReJ~A(_r0!Ol?z5n>R&NE*&?8m5^5PN@w- zt%}pjWZYv99Q^E`!~5&ohB0`@1*6t8u091kU9AHb(w>by0;vAs<(>ca~XeIa=0D)4)2%HjV z>74|5N(QJ?4{^$Cw?F`-8Mgk*tH8sSSx{_4Rt!pWfvQ2}r+q;vkQadPMSvE2Ag!r7_22LU`@{|m4Trt2kUN*9T(YuVw5R@SW zqLxrlYdP??zHe85yY|_`&V{}d$KJmCI+^-!^%Yx z1eee=JW)_<%}Mfnpr2&Lm9agFE@NKHnF`^+6cVdeL{{t~j4$AXhXGL#m)|R%36Smw zLrYiRa`>Up3smhx;yMAC@vj-|3nrow-J-b4yZ_Zc3)mT{x=LRXzF# c_y3N602P>Bqnxx2F#rGn07*qoM6N<$g5`p}F#rGn literal 0 HcmV?d00001 diff --git a/bundles/org.eclipse.ui.ide/plugin.xml b/bundles/org.eclipse.ui.ide/plugin.xml index 6a738588620..0a637145876 100644 --- a/bundles/org.eclipse.ui.ide/plugin.xml +++ b/bundles/org.eclipse.ui.ide/plugin.xml @@ -359,12 +359,10 @@ %DecoratorZipFile.description diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/ZipFileDecorator.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/ZipFileDecorator.java index e21aa18924f..c59803b532d 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/ZipFileDecorator.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/ZipFileDecorator.java @@ -1,89 +1,52 @@ package org.eclipse.ui.internal.ide; -import java.net.URI; -import java.util.Optional; - -import org.eclipse.core.filesystem.IFileInfo; -import org.eclipse.core.filesystem.ZipFileUtil; import org.eclipse.core.internal.resources.VirtualZipFolder; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.resource.ResourceLocator; -import org.eclipse.jface.viewers.IDecoration; -import org.eclipse.jface.viewers.ILabelProviderListener; -import org.eclipse.jface.viewers.ILightweightLabelDecorator; -import org.eclipse.ui.internal.ide.dialogs.IDEResourceInfoUtils; +import org.eclipse.jface.viewers.ILabelDecorator; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.swt.graphics.Image; +import org.eclipse.ui.plugin.AbstractUIPlugin; /** - * @since 3.4 + * A label decorator that adds a custom icon to virtual ZIP folders. + *

+ * This decorator provides a specific icon for objects of type + * {@link VirtualZipFolder} to visually differentiate them from other folder + * types in the UI. The icon is the same as for a ZIP when its closed and + * therefore a file. + *

* + * @since 3.4 */ -public class ZipFileDecorator implements ILightweightLabelDecorator { - - private static final Optional ZIP_FILE; +public class ZipFileDecorator extends LabelProvider implements ILabelDecorator { - private static final Optional ZIP_FILE_WARNING; + private static final String PLUGIN_ID = IDEWorkbenchPlugin.IDE_WORKBENCH; // $NON-NLS-1$ + private static final Image CUSTOM_ZIP_FOLDER_ICON = AbstractUIPlugin + .imageDescriptorFromPlugin(PLUGIN_ID, "icons/full/obj16/zip_file_open.png").createImage(); //$NON-NLS-1$ - static { - ZIP_FILE = ResourceLocator.imageDescriptorFromBundle(IDEWorkbenchPlugin.IDE_WORKBENCH, - "$nl$/icons/full/ovr16/zipfile_ovr.png"); //$NON-NLS-1$ - ZIP_FILE_WARNING = ResourceLocator.imageDescriptorFromBundle(IDEWorkbenchPlugin.IDE_WORKBENCH, - "$nl$/icons/full/ovr16/zipfile_ovr.png"); //$NON-NLS-1$ - } - - /** - * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(ILabelProviderListener) - */ @Override - public void addListener(ILabelProviderListener listener) { + public Image getImage(Object element) { + if (element instanceof VirtualZipFolder) { + return CUSTOM_ZIP_FOLDER_ICON; + } + return super.getImage(element); } - /** - * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose() - */ @Override public void dispose() { - // no resources to dispose + CUSTOM_ZIP_FOLDER_ICON.dispose(); + super.dispose(); } - /** - * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, - * java.lang.String) - */ @Override - public boolean isLabelProperty(Object element, String property) { - return false; - } - - /** - * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(ILabelProviderListener) - */ - @Override - public void removeListener(ILabelProviderListener listener) { + public Image decorateImage(Image image, Object element) { + if (element instanceof VirtualZipFolder) { + return CUSTOM_ZIP_FOLDER_ICON; + } + return image; } - /** - * Adds the linked resource overlay if the given element is a linked resource. - * - * @param element element to decorate - * @param decoration The decoration we are adding to - * @see org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate(Object, - * IDecoration) - */ @Override - public void decorate(Object element, IDecoration decoration) { - if (element instanceof VirtualZipFolder folder) { - URI location = folder.getLocationURI(); - if (ZipFileUtil.isOpenZipFile(location)) { - IFileInfo fileInfo = null; - if (location != null) { - fileInfo = IDEResourceInfoUtils.getFileInfo(location); - } - if (fileInfo != null && fileInfo.exists()) { - ZIP_FILE.ifPresent(decoration::addOverlay); - } else { - ZIP_FILE_WARNING.ifPresent(decoration::addOverlay); - } - } - } + public String decorateText(String text, Object element) { + return text; } } From ad71086664c94485f13e30fe03d832ba5e3fde56 Mon Sep 17 00:00:00 2001 From: Michael Bangas Date: Mon, 12 Aug 2024 11:38:46 +0200 Subject: [PATCH 09/20] refreshing of all viewers after opening/closing zip file --- .../fileSystem/zip/CloseZipFileHandler.java | 42 +++++++++++++++++ .../fileSystem/zip/OpenZipFileHandler.java | 46 +++++++++++++++++-- 2 files changed, 85 insertions(+), 3 deletions(-) diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/CloseZipFileHandler.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/CloseZipFileHandler.java index 66f6e3b9d8e..2aaf183c741 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/CloseZipFileHandler.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/CloseZipFileHandler.java @@ -20,7 +20,15 @@ import org.eclipse.core.resources.ZipFileTransformer; import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.StructuredViewer; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IViewReference; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; import org.eclipse.ui.handlers.HandlerUtil; import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; @@ -38,6 +46,7 @@ public class CloseZipFileHandler extends AbstractHandler { */ @Override public Object execute(ExecutionEvent event) { + Shell shell = HandlerUtil.getActiveShell(event); ISelection selection = HandlerUtil.getCurrentSelection(event); if (!(selection instanceof IStructuredSelection)) { @@ -51,9 +60,42 @@ public Object execute(ExecutionEvent event) { } try { ZipFileTransformer.closeZipFile((IFolder) element); + if (shell != null && !shell.isDisposed()) { + shell.getDisplay().asyncExec(() -> { + // for all viewers + refreshAllViewers(); + + // only for active viewer +// StructuredViewer viewer = (StructuredViewer) HandlerUtil.getActivePart(event).getSite() +// .getSelectionProvider(); +// if (viewer != null && viewer.getControl() != null && !viewer.getControl().isDisposed()) { +// viewer.refresh(); +// } + }); + } } catch (CoreException | URISyntaxException e) { IDEWorkbenchPlugin.log(e.getMessage(), e); } return null; } + + public static void refreshAllViewers() { + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (window != null) { + IWorkbenchPage page = window.getActivePage(); + if (page != null) { + for (IViewReference viewReference : page.getViewReferences()) { + IWorkbenchPart part = viewReference.getPart(false); + if (part != null) { + ISelectionProvider selectionProvider = part.getSite().getSelectionProvider(); + if(selectionProvider instanceof StructuredViewer viewer) { + if (viewer != null && viewer.getControl() != null && !viewer.getControl().isDisposed()) { + viewer.refresh(); + } + } + } + } + } + } + } } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/OpenZipFileHandler.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/OpenZipFileHandler.java index 9d34bc13f4c..bd7ce8f93a5 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/OpenZipFileHandler.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/OpenZipFileHandler.java @@ -12,8 +12,6 @@ package org.eclipse.ui.ide.fileSystem.zip; -import java.net.URISyntaxException; - import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.resources.IFile; @@ -21,8 +19,15 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.StructuredViewer; import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IViewReference; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; import org.eclipse.ui.handlers.HandlerUtil; import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; @@ -54,10 +59,45 @@ public Object execute(ExecutionEvent event) { try { ZipFileTransformer.openZipFile((IFile) element, true); - } catch (URISyntaxException | CoreException e) { + // Update View + if (shell != null && !shell.isDisposed()) { + shell.getDisplay().asyncExec(() -> { + // for all viewers + refreshAllViewers(); + + // only for active viewer +// StructuredViewer viewer = (StructuredViewer) HandlerUtil.getActivePart(event).getSite() +// .getSelectionProvider(); +// if (viewer != null && viewer.getControl() != null && !viewer.getControl().isDisposed()) { +// viewer.refresh(); +// } + }); + } + } catch (CoreException e) { IDEWorkbenchPlugin.log(e.getMessage(), e); MessageDialog.openError(shell, "Error opening zip file", e.getMessage()); //$NON-NLS-1$ } return null; } + + public static void refreshAllViewers() { + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (window != null) { + IWorkbenchPage page = window.getActivePage(); + if (page != null) { + // Iterate over all views + for (IViewReference viewReference : page.getViewReferences()) { + IWorkbenchPart part = viewReference.getPart(false); + if (part != null) { + ISelectionProvider selectionProvider = part.getSite().getSelectionProvider(); + if (selectionProvider instanceof StructuredViewer viewer) { + if (viewer != null && viewer.getControl() != null && !viewer.getControl().isDisposed()) { + viewer.refresh(); + } + } + } + } + } + } + } } From 786ed43be28f8f39ababbd9062a7a978c50498e3 Mon Sep 17 00:00:00 2001 From: Michael Bangas Date: Tue, 13 Aug 2024 13:09:42 +0200 Subject: [PATCH 10/20] Shown In System Explorer: Workaround for proper error handling This commit introduces as special case check when performing the Show In System Explorer Operation on files inside of a zip file. An investigation of better solutions will follow. --- .../org/eclipse/ui/internal/ide/IDEWorkbenchMessages.java | 1 + .../ide/handlers/ShowInSystemExplorerHandler.java | 8 ++++++++ .../src/org/eclipse/ui/internal/ide/messages.properties | 1 + 3 files changed, 10 insertions(+) diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/IDEWorkbenchMessages.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/IDEWorkbenchMessages.java index 78700035350..111dd9ae53f 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/IDEWorkbenchMessages.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/IDEWorkbenchMessages.java @@ -973,6 +973,7 @@ public class IDEWorkbenchMessages extends NLS { public static String ShowInSystemExplorerHandler_commandUnavailable; public static String ShowInSystemExplorerHandler_notDetermineLocation; public static String ShowInSystemExplorerHandler_jobTitle; + public static String ShowInSystemExplorerHandler_insideOfZipFile; public static String TextAction_selectAll; public static String Cut; diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/handlers/ShowInSystemExplorerHandler.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/handlers/ShowInSystemExplorerHandler.java index 87b7b1c5ff7..68725f2f801 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/handlers/ShowInSystemExplorerHandler.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/handlers/ShowInSystemExplorerHandler.java @@ -22,6 +22,8 @@ import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.common.NotDefinedException; +import org.eclipse.core.filesystem.ZipFileUtil; +import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.Adapters; @@ -84,6 +86,12 @@ public Object execute(final ExecutionEvent event) { try { File canonicalPath = getSystemExplorerPath(item); + + if (item instanceof IFile file && ZipFileUtil.isInsideOpenZipFile(file.getLocationURI())) { + return statusReporter.newStatus(IStatus.ERROR, + logMsgPrefix + IDEWorkbenchMessages.ShowInSystemExplorerHandler_insideOfZipFile, null); + } + if (canonicalPath == null) { return statusReporter.newStatus(IStatus.ERROR, logMsgPrefix + IDEWorkbenchMessages.ShowInSystemExplorerHandler_notDetermineLocation, null); diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/messages.properties b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/messages.properties index 3f9b127093c..8fc4423e234 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/messages.properties +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/messages.properties @@ -992,6 +992,7 @@ ScrubLocalAction_problemsTitle = Content Removal Problems ScrubLocalAction_progress = Discarding content... ShowInSystemExplorerHandler_commandUnavailable=System Explorer command unavailable. Please set the System Explorer command in the workspace preferences. ShowInSystemExplorerHandler_notDetermineLocation=Could not determine resource's location. +ShowInSystemExplorerHandler_insideOfZipFile=Resources inside of Zip Files cannot be shown in System Explorer. ShowInSystemExplorerHandler_jobTitle="Opening System Explorer..." TextAction_selectAll = Select All From 299404208ff78e55e7f5b6a541fe8d96c6a7d7bc Mon Sep 17 00:00:00 2001 From: Michael Bangas Date: Tue, 13 Aug 2024 13:55:12 +0200 Subject: [PATCH 11/20] adjust MessageDialog for deleting zip files Deleting an opened zip file also deletes the resource in the local file system. An opened zip file is represented as a linked folder which shows a specific Messagedialog when being deleted indicating that only the link will be deleted. In this case the delete operation of zip files also deletes the resource in the local file system. Please mind that one dialog exists in JDT which should also be adjusted similarily. --- .../ltk/ui/refactoring/resource/DeleteResourcesWizard.java | 4 +++- .../org/eclipse/ui/actions/DeleteResourceAction.java | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/bundles/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/ui/refactoring/resource/DeleteResourcesWizard.java b/bundles/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/ui/refactoring/resource/DeleteResourcesWizard.java index 79a0fb69ebb..49cd14dbf21 100644 --- a/bundles/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/ui/refactoring/resource/DeleteResourcesWizard.java +++ b/bundles/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/ui/refactoring/resource/DeleteResourcesWizard.java @@ -38,6 +38,8 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; +import org.eclipse.core.filesystem.ZipFileUtil; + import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.OperationCanceledException; @@ -270,7 +272,7 @@ private static String getLocation(IResource resource) { private boolean containsLinkedResource(IResource[] resources) { for (IResource resource : resources) { - if (resource != null && resource.isLinked()) { // paranoia code, can not be null + if (resource != null && resource.isLinked() && !ZipFileUtil.isOpenZipFile(resource.getLocationURI())) { // paranoia code, can not be null return true; } } diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/DeleteResourceAction.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/DeleteResourceAction.java index 585d44d6873..f0278f93496 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/DeleteResourceAction.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/DeleteResourceAction.java @@ -20,6 +20,7 @@ import java.util.List; import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.filesystem.ZipFileUtil; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.Assert; @@ -319,7 +320,7 @@ private boolean canDelete(List resources) { private boolean containsLinkedResource(List resources) { for (int i = 0; i < resources.size(); i++) { IResource resource = resources.get(i); - if (resource.isLinked()) { + if (resource.isLinked() && !ZipFileUtil.isOpenZipFile(resource.getLocationURI())) { return true; } } @@ -389,7 +390,7 @@ private boolean confirmDeleteNonProjects(List resources) { if (resources.size() == 1) { title = IDEWorkbenchMessages.DeleteResourceAction_title1; IResource resource = resources.get(0); - if (resource.isLinked()) { + if (resource.isLinked() && !ZipFileUtil.isOpenZipFile(resource.getLocationURI())) { msg = NLS .bind( IDEWorkbenchMessages.DeleteResourceAction_confirmLinkedResource1, From 5965f2e399411af7cd3ed6d86589d7284c93405f Mon Sep 17 00:00:00 2001 From: Michael Bangas Date: Tue, 13 Aug 2024 10:26:55 +0200 Subject: [PATCH 12/20] delete added icon --- .../icons/full/ovr16/zipfile_ovr.png | Bin 289 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 bundles/org.eclipse.ui.ide/icons/full/ovr16/zipfile_ovr.png diff --git a/bundles/org.eclipse.ui.ide/icons/full/ovr16/zipfile_ovr.png b/bundles/org.eclipse.ui.ide/icons/full/ovr16/zipfile_ovr.png deleted file mode 100644 index 636a8ade9cb838cdb7751e743f68fa43d4eb93a1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 289 zcmeAS@N?(olHy`uVBq!ia0vp^>_E)H!3HEvS)PI@#^NA%Cx&(BWL^R}Ea{HEjtmSN z`?>!lvI6;>1s;*b3=DjSK$uZf!>a)(xXshWF+?KVw`cz;_XLL4`@0K;Po?f)_^UQs zXWaqY6Q&)#ol_1fD6$!9ss{ONvWZ{+vU=I)<;6!n+oVLg&3i85>L}t`65H-_=lfZU zzWEb9-dD<<-t<9t>5ucJv0rNYGj59=HYku`KfUS4-#Qk@1H0C7XoiFy{a$;>z~y>r z&h2Lwd@eG_GiH5bU6#2>gKOREP4BHA+4xUValCiE^sE6-&h29+z8&9dHBV1kwQAp{ hOsPvIsq@nRF&r=0%Fvc?`y1#322WQ%mvv4FO#l^FaZUgL From 9a3aed7a065214ac080514cf9aa2a70d484ecec0 Mon Sep 17 00:00:00 2001 From: Michael Bangas Date: Tue, 13 Aug 2024 13:06:48 +0200 Subject: [PATCH 13/20] implement double click open for zip files This implementation is not yet finished as a proper editor handling needs to be added. --- .../META-INF/MANIFEST.MF | 3 +- .../icons/full/obj16/zip_file_open.png | Bin 0 -> 599 bytes .../icons/full/obj16/zip_file_open@2x.png | Bin 0 -> 1474 bytes .../org.eclipse.ui.editors/plugin.properties | 1 + bundles/org.eclipse.ui.editors/plugin.xml | 13 +++ .../eclipse/ui/editors/zip/ZipFileEditor.java | 88 ++++++++++++++++++ .../fileSystem/zip/OpenZipFileHandler.java | 8 +- 7 files changed, 107 insertions(+), 6 deletions(-) create mode 100644 bundles/org.eclipse.ui.editors/icons/full/obj16/zip_file_open.png create mode 100644 bundles/org.eclipse.ui.editors/icons/full/obj16/zip_file_open@2x.png create mode 100644 bundles/org.eclipse.ui.editors/src/org/eclipse/ui/editors/zip/ZipFileEditor.java diff --git a/bundles/org.eclipse.ui.editors/META-INF/MANIFEST.MF b/bundles/org.eclipse.ui.editors/META-INF/MANIFEST.MF index e3cf47afb07..79d70d2f676 100644 --- a/bundles/org.eclipse.ui.editors/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.ui.editors/META-INF/MANIFEST.MF @@ -15,7 +15,8 @@ Export-Package: org.eclipse.ui.internal.editors.text.codemining.annotation;x-internal:=true, org.eclipse.ui.internal.texteditor;x-internal:=true, org.eclipse.ui.internal.texteditor.stickyscroll;x-internal:=true, - org.eclipse.ui.texteditor + org.eclipse.ui.texteditor, + org.eclipse.ui.editors.zip Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)", org.eclipse.core.expressions;bundle-version="[3.9.0,4.0.0)", diff --git a/bundles/org.eclipse.ui.editors/icons/full/obj16/zip_file_open.png b/bundles/org.eclipse.ui.editors/icons/full/obj16/zip_file_open.png new file mode 100644 index 0000000000000000000000000000000000000000..9af044391eacb2d7df41c28107674c351a8c5cca GIT binary patch literal 599 zcmV-d0;v6oP)dZPFxN|0ZeDw9NMLCewG>UhTreJ)C>;yXQPfhK7!Nr58rVnD8*mgsu`@ zVVQTAS!Vtc(FK+Xo-HuJbB-ectHBX*&~IVTD`B9g(U+6x*B0)k9-S-iiW+G0a@!p)_VkGAXk#{EI=2>r>PUR0B>Y1 zl*&lh;uMssI_gRny3w=LP`lu29Z>7szBjz~z!u<-elMq48983Hiff7i?H{178dh$L zbm5O}WNiViw_l~rqCz@Q$p|_s|3}bz#D^|ek~7a<%&oAt0H=4!0%S`Hc0~>4hGF?& zs$B12ml(TQlrjD)VGp?bJSLe1nWAd>keAw|ZQYU?=XeF?1-B;`?Ew$pP@)MieK2>^ zi(g_JJ3<@VB+e8M0M6Hmk}bd;OeJ##o*31%3axI)IHt_l%+Xl^uDLJkwt$)F>TrVI zka-~wRuHkn*O23y_ZpV6VYT#fn|6^Em z2Vm*@5SHE#VCmV5Y3xoCqr3eY*{)X~Y9$<& z>#DwQ=#SJk8w9H>4reG0?`j5tXa=EJ7U6hNbnS~|VDrXt;-X&op`kx`xUp~dLj{+q zxShwEZqC&<>o+DGVJrnxaId6Uu(TL7lFTByRy?niAiS$-OwNaKLN%0^DFPuJ!dqA{J1p;hi?tbp_G_?kY&D_$ReJ~A(_r0!Ol?z5n>R&NE*&?8m5^5PN@w- zt%}pjWZYv99Q^E`!~5&ohB0`@1*6t8u091kU9AHb(w>by0;vAs<(>ca~XeIa=0D)4)2%HjV z>74|5N(QJ?4{^$Cw?F`-8Mgk*tH8sSSx{_4Rt!pWfvQ2}r+q;vkQadPMSvE2Ag!r7_22LU`@{|m4Trt2kUN*9T(YuVw5R@SW zqLxrlYdP??zHe85yY|_`&V{}d$KJmCI+^-!^%Yx z1eee=JW)_<%}Mfnpr2&Lm9agFE@NKHnF`^+6cVdeL{{t~j4$AXhXGL#m)|R%36Smw zLrYiRa`>Up3smhx;yMAC@vj-|3nrow-J-b4yZ_Zc3)mT{x=LRXzF# c_y3N602P>Bqnxx2F#rGn07*qoM6N<$g5`p}F#rGn literal 0 HcmV?d00001 diff --git a/bundles/org.eclipse.ui.editors/plugin.properties b/bundles/org.eclipse.ui.editors/plugin.properties index 5a246191f2b..4f2eae332a4 100644 --- a/bundles/org.eclipse.ui.editors/plugin.properties +++ b/bundles/org.eclipse.ui.editors/plugin.properties @@ -53,6 +53,7 @@ PreferencePages.Annotations= Annotations PreferencePages.QuickDiff= Quick Diff PreferencePages.Accessibility= Accessibility PreferencePages.Spelling= Spelling +Editors.ZipFileEditor = Open Zip File lastSaveReferenceProvider.label= Version on &Disk diff --git a/bundles/org.eclipse.ui.editors/plugin.xml b/bundles/org.eclipse.ui.editors/plugin.xml index e69aca3a288..aa1a5fc7646 100644 --- a/bundles/org.eclipse.ui.editors/plugin.xml +++ b/bundles/org.eclipse.ui.editors/plugin.xml @@ -275,6 +275,19 @@ />
+ + + + + + + { + refreshAllViewers(); + }); + } + } catch (CoreException e) { + MessageDialog.openError(shell, "Error opening zip file", e.getMessage()); //$NON-NLS-1$ + } + } + + private static void refreshAllViewers() { + IWorkbenchWindow window= PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (window != null) { + IWorkbenchPage page= window.getActivePage(); + if (page != null) { + for (IViewReference viewReference : page.getViewReferences()) { + IWorkbenchPart part= viewReference.getPart(false); + if (part != null) { + ISelectionProvider selectionProvider= part.getSite().getSelectionProvider(); + if (selectionProvider instanceof StructuredViewer viewer) { + if (viewer.getControl() != null && !viewer.getControl().isDisposed()) { + viewer.refresh(); + } + } + } + } + } + } + } +} \ No newline at end of file diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/OpenZipFileHandler.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/OpenZipFileHandler.java index bd7ce8f93a5..c0803bd2603 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/OpenZipFileHandler.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/OpenZipFileHandler.java @@ -59,10 +59,9 @@ public Object execute(ExecutionEvent event) { try { ZipFileTransformer.openZipFile((IFile) element, true); - // Update View + if (shell != null && !shell.isDisposed()) { shell.getDisplay().asyncExec(() -> { - // for all viewers refreshAllViewers(); // only for active viewer @@ -80,18 +79,17 @@ public Object execute(ExecutionEvent event) { return null; } - public static void refreshAllViewers() { + private static void refreshAllViewers() { IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (window != null) { IWorkbenchPage page = window.getActivePage(); if (page != null) { - // Iterate over all views for (IViewReference viewReference : page.getViewReferences()) { IWorkbenchPart part = viewReference.getPart(false); if (part != null) { ISelectionProvider selectionProvider = part.getSite().getSelectionProvider(); if (selectionProvider instanceof StructuredViewer viewer) { - if (viewer != null && viewer.getControl() != null && !viewer.getControl().isDisposed()) { + if (viewer.getControl() != null && !viewer.getControl().isDisposed()) { viewer.refresh(); } } From 1e6f278be411c4e5dccba71ef24bd226d29b8b0c Mon Sep 17 00:00:00 2001 From: Michael Bangas Date: Wed, 14 Aug 2024 12:33:58 +0200 Subject: [PATCH 14/20] additional editor close --- .../eclipse/ui/editors/zip/ZipFileEditor.java | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/bundles/org.eclipse.ui.editors/src/org/eclipse/ui/editors/zip/ZipFileEditor.java b/bundles/org.eclipse.ui.editors/src/org/eclipse/ui/editors/zip/ZipFileEditor.java index b77834a67da..dbf929bbdcc 100644 --- a/bundles/org.eclipse.ui.editors/src/org/eclipse/ui/editors/zip/ZipFileEditor.java +++ b/bundles/org.eclipse.ui.editors/src/org/eclipse/ui/editors/zip/ZipFileEditor.java @@ -11,10 +11,10 @@ *******************************************************************************/ package org.eclipse.ui.editors.zip; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; -import org.eclipse.core.filesystem.EFS; - import org.eclipse.core.runtime.CoreException; import org.eclipse.core.resources.IFile; @@ -28,9 +28,9 @@ import org.eclipse.ui.IViewReference; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchPartSite; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.ide.FileStoreEditorInput; import org.eclipse.ui.part.FileEditorInput; import org.eclipse.ui.editors.text.TextEditor; @@ -42,20 +42,27 @@ public class ZipFileEditor extends TextEditor { @Override protected void doSetInput(IEditorInput input) throws CoreException { - + super.doSetInput(input); + IWorkbenchPartSite site= getSite(); + Shell shell= site.getShell(); if (input instanceof FileEditorInput fileEditorInput) { - IFile file = fileEditorInput.getFile(); - input= new FileStoreEditorInput(EFS.getStore(file.getLocationURI())); - super.doSetInput(input); - Shell shell= getSite().getShell(); + IFile file= fileEditorInput.getFile(); openAndRefresh(file, shell); } + Display display= shell.getDisplay(); + display.asyncExec(() -> { + site.getPage().closeEditor(this, false); + }); + } + + @Override + public void createPartControl(Composite parent) { + return; } public static void openAndRefresh(IFile file, Shell shell) { try { ZipFileTransformer.openZipFile(file, true); - if (shell != null && !shell.isDisposed()) { shell.getDisplay().asyncExec(() -> { refreshAllViewers(); From 6065c7b0f6879881e7c1913c9078850fa9bed2e0 Mon Sep 17 00:00:00 2001 From: Michael Bangas Date: Mon, 12 Aug 2024 11:38:46 +0200 Subject: [PATCH 15/20] remove refreshViewers --- .../fileSystem/zip/CloseZipFileHandler.java | 43 +------------------ .../fileSystem/zip/OpenZipFileHandler.java | 40 ----------------- 2 files changed, 1 insertion(+), 82 deletions(-) diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/CloseZipFileHandler.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/CloseZipFileHandler.java index 2aaf183c741..e2012cee5c9 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/CloseZipFileHandler.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/CloseZipFileHandler.java @@ -20,15 +20,7 @@ import org.eclipse.core.resources.ZipFileTransformer; import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.StructuredViewer; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IViewReference; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; import org.eclipse.ui.handlers.HandlerUtil; import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; @@ -46,7 +38,6 @@ public class CloseZipFileHandler extends AbstractHandler { */ @Override public Object execute(ExecutionEvent event) { - Shell shell = HandlerUtil.getActiveShell(event); ISelection selection = HandlerUtil.getCurrentSelection(event); if (!(selection instanceof IStructuredSelection)) { @@ -58,44 +49,12 @@ public Object execute(ExecutionEvent event) { if (!(element instanceof IFolder)) { return null; } + try { ZipFileTransformer.closeZipFile((IFolder) element); - if (shell != null && !shell.isDisposed()) { - shell.getDisplay().asyncExec(() -> { - // for all viewers - refreshAllViewers(); - - // only for active viewer -// StructuredViewer viewer = (StructuredViewer) HandlerUtil.getActivePart(event).getSite() -// .getSelectionProvider(); -// if (viewer != null && viewer.getControl() != null && !viewer.getControl().isDisposed()) { -// viewer.refresh(); -// } - }); - } } catch (CoreException | URISyntaxException e) { IDEWorkbenchPlugin.log(e.getMessage(), e); } return null; } - - public static void refreshAllViewers() { - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if (window != null) { - IWorkbenchPage page = window.getActivePage(); - if (page != null) { - for (IViewReference viewReference : page.getViewReferences()) { - IWorkbenchPart part = viewReference.getPart(false); - if (part != null) { - ISelectionProvider selectionProvider = part.getSite().getSelectionProvider(); - if(selectionProvider instanceof StructuredViewer viewer) { - if (viewer != null && viewer.getControl() != null && !viewer.getControl().isDisposed()) { - viewer.refresh(); - } - } - } - } - } - } - } } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/OpenZipFileHandler.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/OpenZipFileHandler.java index c0803bd2603..8d4c3265e69 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/OpenZipFileHandler.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/OpenZipFileHandler.java @@ -19,15 +19,8 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.StructuredViewer; import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IViewReference; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; import org.eclipse.ui.handlers.HandlerUtil; import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; @@ -59,43 +52,10 @@ public Object execute(ExecutionEvent event) { try { ZipFileTransformer.openZipFile((IFile) element, true); - - if (shell != null && !shell.isDisposed()) { - shell.getDisplay().asyncExec(() -> { - refreshAllViewers(); - - // only for active viewer -// StructuredViewer viewer = (StructuredViewer) HandlerUtil.getActivePart(event).getSite() -// .getSelectionProvider(); -// if (viewer != null && viewer.getControl() != null && !viewer.getControl().isDisposed()) { -// viewer.refresh(); -// } - }); - } } catch (CoreException e) { IDEWorkbenchPlugin.log(e.getMessage(), e); MessageDialog.openError(shell, "Error opening zip file", e.getMessage()); //$NON-NLS-1$ } return null; } - - private static void refreshAllViewers() { - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if (window != null) { - IWorkbenchPage page = window.getActivePage(); - if (page != null) { - for (IViewReference viewReference : page.getViewReferences()) { - IWorkbenchPart part = viewReference.getPart(false); - if (part != null) { - ISelectionProvider selectionProvider = part.getSite().getSelectionProvider(); - if (selectionProvider instanceof StructuredViewer viewer) { - if (viewer.getControl() != null && !viewer.getControl().isDisposed()) { - viewer.refresh(); - } - } - } - } - } - } - } } From 5805be46659e560818e8e288c2f0693025525f3b Mon Sep 17 00:00:00 2001 From: Michael Bangas Date: Tue, 20 Aug 2024 15:39:21 +0200 Subject: [PATCH 16/20] Revert "remove refreshViewers" This reverts commit 6a3216ea21bcb11388e750657f89dedf3b4e0dd8. --- .../fileSystem/zip/CloseZipFileHandler.java | 43 ++++++++++++++++++- .../fileSystem/zip/OpenZipFileHandler.java | 40 +++++++++++++++++ 2 files changed, 82 insertions(+), 1 deletion(-) diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/CloseZipFileHandler.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/CloseZipFileHandler.java index e2012cee5c9..2aaf183c741 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/CloseZipFileHandler.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/CloseZipFileHandler.java @@ -20,7 +20,15 @@ import org.eclipse.core.resources.ZipFileTransformer; import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.StructuredViewer; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IViewReference; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; import org.eclipse.ui.handlers.HandlerUtil; import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; @@ -38,6 +46,7 @@ public class CloseZipFileHandler extends AbstractHandler { */ @Override public Object execute(ExecutionEvent event) { + Shell shell = HandlerUtil.getActiveShell(event); ISelection selection = HandlerUtil.getCurrentSelection(event); if (!(selection instanceof IStructuredSelection)) { @@ -49,12 +58,44 @@ public Object execute(ExecutionEvent event) { if (!(element instanceof IFolder)) { return null; } - try { ZipFileTransformer.closeZipFile((IFolder) element); + if (shell != null && !shell.isDisposed()) { + shell.getDisplay().asyncExec(() -> { + // for all viewers + refreshAllViewers(); + + // only for active viewer +// StructuredViewer viewer = (StructuredViewer) HandlerUtil.getActivePart(event).getSite() +// .getSelectionProvider(); +// if (viewer != null && viewer.getControl() != null && !viewer.getControl().isDisposed()) { +// viewer.refresh(); +// } + }); + } } catch (CoreException | URISyntaxException e) { IDEWorkbenchPlugin.log(e.getMessage(), e); } return null; } + + public static void refreshAllViewers() { + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (window != null) { + IWorkbenchPage page = window.getActivePage(); + if (page != null) { + for (IViewReference viewReference : page.getViewReferences()) { + IWorkbenchPart part = viewReference.getPart(false); + if (part != null) { + ISelectionProvider selectionProvider = part.getSite().getSelectionProvider(); + if(selectionProvider instanceof StructuredViewer viewer) { + if (viewer != null && viewer.getControl() != null && !viewer.getControl().isDisposed()) { + viewer.refresh(); + } + } + } + } + } + } + } } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/OpenZipFileHandler.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/OpenZipFileHandler.java index 8d4c3265e69..c0803bd2603 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/OpenZipFileHandler.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/OpenZipFileHandler.java @@ -19,8 +19,15 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.StructuredViewer; import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IViewReference; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; import org.eclipse.ui.handlers.HandlerUtil; import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; @@ -52,10 +59,43 @@ public Object execute(ExecutionEvent event) { try { ZipFileTransformer.openZipFile((IFile) element, true); + + if (shell != null && !shell.isDisposed()) { + shell.getDisplay().asyncExec(() -> { + refreshAllViewers(); + + // only for active viewer +// StructuredViewer viewer = (StructuredViewer) HandlerUtil.getActivePart(event).getSite() +// .getSelectionProvider(); +// if (viewer != null && viewer.getControl() != null && !viewer.getControl().isDisposed()) { +// viewer.refresh(); +// } + }); + } } catch (CoreException e) { IDEWorkbenchPlugin.log(e.getMessage(), e); MessageDialog.openError(shell, "Error opening zip file", e.getMessage()); //$NON-NLS-1$ } return null; } + + private static void refreshAllViewers() { + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (window != null) { + IWorkbenchPage page = window.getActivePage(); + if (page != null) { + for (IViewReference viewReference : page.getViewReferences()) { + IWorkbenchPart part = viewReference.getPart(false); + if (part != null) { + ISelectionProvider selectionProvider = part.getSite().getSelectionProvider(); + if (selectionProvider instanceof StructuredViewer viewer) { + if (viewer.getControl() != null && !viewer.getControl().isDisposed()) { + viewer.refresh(); + } + } + } + } + } + } + } } From 55d29c7e8add33af47da66b15ef7296b5f3615c1 Mon Sep 17 00:00:00 2001 From: Michael Bangas Date: Tue, 20 Aug 2024 17:04:16 +0200 Subject: [PATCH 17/20] refactor refreshViewers --- .../eclipse/ui/editors/zip/ZipFileEditor.java | 34 +----------- .../fileSystem/zip/CloseZipFileHandler.java | 54 +++---------------- .../fileSystem/zip/OpenZipFileHandler.java | 52 ++---------------- .../fileSystem/zip/ZipFileHandlerUtil.java | 35 ++++++++++++ 4 files changed, 49 insertions(+), 126 deletions(-) create mode 100644 bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/ZipFileHandlerUtil.java diff --git a/bundles/org.eclipse.ui.editors/src/org/eclipse/ui/editors/zip/ZipFileEditor.java b/bundles/org.eclipse.ui.editors/src/org/eclipse/ui/editors/zip/ZipFileEditor.java index dbf929bbdcc..b5ac26f4dda 100644 --- a/bundles/org.eclipse.ui.editors/src/org/eclipse/ui/editors/zip/ZipFileEditor.java +++ b/bundles/org.eclipse.ui.editors/src/org/eclipse/ui/editors/zip/ZipFileEditor.java @@ -21,16 +21,10 @@ import org.eclipse.core.resources.ZipFileTransformer; import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.StructuredViewer; import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IViewReference; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkbenchPartSite; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.ide.fileSystem.zip.ZipFileHandlerUtil; import org.eclipse.ui.part.FileEditorInput; import org.eclipse.ui.editors.text.TextEditor; @@ -63,33 +57,9 @@ public void createPartControl(Composite parent) { public static void openAndRefresh(IFile file, Shell shell) { try { ZipFileTransformer.openZipFile(file, true); - if (shell != null && !shell.isDisposed()) { - shell.getDisplay().asyncExec(() -> { - refreshAllViewers(); - }); - } + ZipFileHandlerUtil.refreshAllViewers(); } catch (CoreException e) { MessageDialog.openError(shell, "Error opening zip file", e.getMessage()); //$NON-NLS-1$ } } - - private static void refreshAllViewers() { - IWorkbenchWindow window= PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if (window != null) { - IWorkbenchPage page= window.getActivePage(); - if (page != null) { - for (IViewReference viewReference : page.getViewReferences()) { - IWorkbenchPart part= viewReference.getPart(false); - if (part != null) { - ISelectionProvider selectionProvider= part.getSite().getSelectionProvider(); - if (selectionProvider instanceof StructuredViewer viewer) { - if (viewer.getControl() != null && !viewer.getControl().isDisposed()) { - viewer.refresh(); - } - } - } - } - } - } - } } \ No newline at end of file diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/CloseZipFileHandler.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/CloseZipFileHandler.java index 2aaf183c741..ddc2ea976d1 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/CloseZipFileHandler.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/CloseZipFileHandler.java @@ -19,23 +19,17 @@ import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.ZipFileTransformer; import org.eclipse.core.runtime.CoreException; +import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.StructuredViewer; import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IViewReference; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; import org.eclipse.ui.handlers.HandlerUtil; import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; /** * This class represents a handler for closing an opened zip file. * - * @since 3.132 + * @since 3.23 */ public class CloseZipFileHandler extends AbstractHandler { @@ -49,53 +43,19 @@ public Object execute(ExecutionEvent event) { Shell shell = HandlerUtil.getActiveShell(event); ISelection selection = HandlerUtil.getCurrentSelection(event); - if (!(selection instanceof IStructuredSelection)) { + if (!(selection instanceof IStructuredSelection structuredSelection)) { return null; } - - Object element = ((IStructuredSelection) selection).getFirstElement(); - - if (!(element instanceof IFolder)) { + if (!(structuredSelection.getFirstElement() instanceof IFolder folder)) { return null; } try { - ZipFileTransformer.closeZipFile((IFolder) element); - if (shell != null && !shell.isDisposed()) { - shell.getDisplay().asyncExec(() -> { - // for all viewers - refreshAllViewers(); - - // only for active viewer -// StructuredViewer viewer = (StructuredViewer) HandlerUtil.getActivePart(event).getSite() -// .getSelectionProvider(); -// if (viewer != null && viewer.getControl() != null && !viewer.getControl().isDisposed()) { -// viewer.refresh(); -// } - }); - } + ZipFileTransformer.closeZipFile(folder); + ZipFileHandlerUtil.refreshAllViewers(); } catch (CoreException | URISyntaxException e) { IDEWorkbenchPlugin.log(e.getMessage(), e); + MessageDialog.openError(shell, "Error closing zip file", e.getMessage()); //$NON-NLS-1$ } return null; } - - public static void refreshAllViewers() { - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if (window != null) { - IWorkbenchPage page = window.getActivePage(); - if (page != null) { - for (IViewReference viewReference : page.getViewReferences()) { - IWorkbenchPart part = viewReference.getPart(false); - if (part != null) { - ISelectionProvider selectionProvider = part.getSite().getSelectionProvider(); - if(selectionProvider instanceof StructuredViewer viewer) { - if (viewer != null && viewer.getControl() != null && !viewer.getControl().isDisposed()) { - viewer.refresh(); - } - } - } - } - } - } - } } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/OpenZipFileHandler.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/OpenZipFileHandler.java index c0803bd2603..6ae35d0af58 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/OpenZipFileHandler.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/OpenZipFileHandler.java @@ -19,22 +19,15 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.StructuredViewer; import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IViewReference; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; import org.eclipse.ui.handlers.HandlerUtil; import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; /** * This class represents a handler for opening zip files. * - * @since 3.132 + * @since 3.23 */ public class OpenZipFileHandler extends AbstractHandler { @@ -48,54 +41,19 @@ public class OpenZipFileHandler extends AbstractHandler { public Object execute(ExecutionEvent event) { Shell shell = HandlerUtil.getActiveShell(event); ISelection selection = HandlerUtil.getCurrentSelection(event); - if (!(selection instanceof IStructuredSelection)) { + if (!(selection instanceof IStructuredSelection structuredSelection)) { return null; } - - Object element = ((IStructuredSelection) selection).getFirstElement(); - if (!(element instanceof IFile)) { + if (!(structuredSelection.getFirstElement() instanceof IFile file)) { return null; } - try { - ZipFileTransformer.openZipFile((IFile) element, true); - - if (shell != null && !shell.isDisposed()) { - shell.getDisplay().asyncExec(() -> { - refreshAllViewers(); - - // only for active viewer -// StructuredViewer viewer = (StructuredViewer) HandlerUtil.getActivePart(event).getSite() -// .getSelectionProvider(); -// if (viewer != null && viewer.getControl() != null && !viewer.getControl().isDisposed()) { -// viewer.refresh(); -// } - }); - } + ZipFileTransformer.openZipFile(file, true); + ZipFileHandlerUtil.refreshAllViewers(); } catch (CoreException e) { IDEWorkbenchPlugin.log(e.getMessage(), e); MessageDialog.openError(shell, "Error opening zip file", e.getMessage()); //$NON-NLS-1$ } return null; } - - private static void refreshAllViewers() { - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if (window != null) { - IWorkbenchPage page = window.getActivePage(); - if (page != null) { - for (IViewReference viewReference : page.getViewReferences()) { - IWorkbenchPart part = viewReference.getPart(false); - if (part != null) { - ISelectionProvider selectionProvider = part.getSite().getSelectionProvider(); - if (selectionProvider instanceof StructuredViewer viewer) { - if (viewer.getControl() != null && !viewer.getControl().isDisposed()) { - viewer.refresh(); - } - } - } - } - } - } - } } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/ZipFileHandlerUtil.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/ZipFileHandlerUtil.java new file mode 100644 index 00000000000..f18be525b45 --- /dev/null +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/ZipFileHandlerUtil.java @@ -0,0 +1,35 @@ +package org.eclipse.ui.ide.fileSystem.zip; + +import org.eclipse.jface.viewers.ISelectionProvider; +import org.eclipse.jface.viewers.StructuredViewer; +import org.eclipse.ui.IViewReference; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; + +/** + * @since 3.23 + * + */ +public class ZipFileHandlerUtil { + public static void refreshAllViewers() { + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (window != null) { + IWorkbenchPage page = window.getActivePage(); + if (page != null) { + for (IViewReference viewReference : page.getViewReferences()) { + IWorkbenchPart part = viewReference.getPart(false); + if (part != null) { + ISelectionProvider selectionProvider = part.getSite().getSelectionProvider(); + if (selectionProvider instanceof StructuredViewer viewer) { + if (viewer.getControl() != null && !viewer.getControl().isDisposed()) { + viewer.refresh(); + } + } + } + } + } + } + } +} From 8b38dafb9a05ef23534a9d121894a9f3f5365255 Mon Sep 17 00:00:00 2001 From: Michael Bangas Date: Fri, 23 Aug 2024 13:37:52 +0200 Subject: [PATCH 18/20] allow close Zip File always if folder is VirtualZipFolder --- bundles/org.eclipse.ui.ide/plugin.xml | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/bundles/org.eclipse.ui.ide/plugin.xml b/bundles/org.eclipse.ui.ide/plugin.xml index 0a637145876..f11def5cdc4 100644 --- a/bundles/org.eclipse.ui.ide/plugin.xml +++ b/bundles/org.eclipse.ui.ide/plugin.xml @@ -2252,21 +2252,7 @@ - - - - - - - - + type="org.eclipse.core.internal.resources.VirtualZipFolder"> From 32f9f5982332c900a602b0c336a6e442cc0e9c23 Mon Sep 17 00:00:00 2001 From: Michael Bangas Date: Wed, 28 Aug 2024 14:48:26 +0200 Subject: [PATCH 19/20] remove explicit refresh --- .../eclipse/ui/editors/zip/ZipFileEditor.java | 2 -- .../fileSystem/zip/CloseZipFileHandler.java | 1 - .../fileSystem/zip/OpenZipFileHandler.java | 1 - .../fileSystem/zip/ZipFileHandlerUtil.java | 35 ------------------- 4 files changed, 39 deletions(-) delete mode 100644 bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/ZipFileHandlerUtil.java diff --git a/bundles/org.eclipse.ui.editors/src/org/eclipse/ui/editors/zip/ZipFileEditor.java b/bundles/org.eclipse.ui.editors/src/org/eclipse/ui/editors/zip/ZipFileEditor.java index b5ac26f4dda..cf3f94272f0 100644 --- a/bundles/org.eclipse.ui.editors/src/org/eclipse/ui/editors/zip/ZipFileEditor.java +++ b/bundles/org.eclipse.ui.editors/src/org/eclipse/ui/editors/zip/ZipFileEditor.java @@ -24,7 +24,6 @@ import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IWorkbenchPartSite; -import org.eclipse.ui.ide.fileSystem.zip.ZipFileHandlerUtil; import org.eclipse.ui.part.FileEditorInput; import org.eclipse.ui.editors.text.TextEditor; @@ -57,7 +56,6 @@ public void createPartControl(Composite parent) { public static void openAndRefresh(IFile file, Shell shell) { try { ZipFileTransformer.openZipFile(file, true); - ZipFileHandlerUtil.refreshAllViewers(); } catch (CoreException e) { MessageDialog.openError(shell, "Error opening zip file", e.getMessage()); //$NON-NLS-1$ } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/CloseZipFileHandler.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/CloseZipFileHandler.java index ddc2ea976d1..480cc20a9e3 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/CloseZipFileHandler.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/CloseZipFileHandler.java @@ -51,7 +51,6 @@ public Object execute(ExecutionEvent event) { } try { ZipFileTransformer.closeZipFile(folder); - ZipFileHandlerUtil.refreshAllViewers(); } catch (CoreException | URISyntaxException e) { IDEWorkbenchPlugin.log(e.getMessage(), e); MessageDialog.openError(shell, "Error closing zip file", e.getMessage()); //$NON-NLS-1$ diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/OpenZipFileHandler.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/OpenZipFileHandler.java index 6ae35d0af58..09d372529cb 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/OpenZipFileHandler.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/OpenZipFileHandler.java @@ -49,7 +49,6 @@ public Object execute(ExecutionEvent event) { } try { ZipFileTransformer.openZipFile(file, true); - ZipFileHandlerUtil.refreshAllViewers(); } catch (CoreException e) { IDEWorkbenchPlugin.log(e.getMessage(), e); MessageDialog.openError(shell, "Error opening zip file", e.getMessage()); //$NON-NLS-1$ diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/ZipFileHandlerUtil.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/ZipFileHandlerUtil.java deleted file mode 100644 index f18be525b45..00000000000 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/fileSystem/zip/ZipFileHandlerUtil.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.eclipse.ui.ide.fileSystem.zip; - -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.StructuredViewer; -import org.eclipse.ui.IViewReference; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; - -/** - * @since 3.23 - * - */ -public class ZipFileHandlerUtil { - public static void refreshAllViewers() { - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if (window != null) { - IWorkbenchPage page = window.getActivePage(); - if (page != null) { - for (IViewReference viewReference : page.getViewReferences()) { - IWorkbenchPart part = viewReference.getPart(false); - if (part != null) { - ISelectionProvider selectionProvider = part.getSite().getSelectionProvider(); - if (selectionProvider instanceof StructuredViewer viewer) { - if (viewer.getControl() != null && !viewer.getControl().isDisposed()) { - viewer.refresh(); - } - } - } - } - } - } - } -} From c78a687aa16656120bdbb4d797f93235e05466ac Mon Sep 17 00:00:00 2001 From: Michael Bangas Date: Wed, 28 Aug 2024 14:49:24 +0200 Subject: [PATCH 20/20] refresh workaround --- .../src/org/eclipse/jface/viewers/AbstractTreeViewer.java | 1 + 1 file changed, 1 insertion(+) diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/AbstractTreeViewer.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/AbstractTreeViewer.java index 0bdc435dea4..e08959d4309 100644 --- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/AbstractTreeViewer.java +++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/AbstractTreeViewer.java @@ -332,6 +332,7 @@ protected void internalAdd(Widget widget, Object parentElementOrTreePath, } assertElementsNotNull(parent, elements); } + internalRefresh(parent); } }