Merge remote-tracking branch

'origin/GP-4962-dragonmacher-font-end-dispose-exception--SQUASHED'
(Closes #6937)
This commit is contained in:
Ryan Kurtz 2024-09-26 06:04:39 -04:00
commit a1c6452798
2 changed files with 33 additions and 15 deletions

View File

@ -4,9 +4,9 @@
* Licensed 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.
@ -44,6 +44,20 @@ public class DomainFolderChangesDisplayPlugin extends Plugin
provider = new DomainFolderChangesDisplayComponentProvider(tool, getName());
}
@Override
public void serviceRemoved(Class<?> interfaceClass, Object service) {
if (interfaceClass == FrontEndService.class) {
((FrontEndService) service).removeProjectListener(this);
}
}
@Override
public void serviceAdded(Class<?> interfaceClass, Object service) {
if (interfaceClass == FrontEndService.class) {
((FrontEndService) service).addProjectListener(this);
}
}
@Override
protected void init() {
@ -52,15 +66,19 @@ public class DomainFolderChangesDisplayPlugin extends Plugin
projectOpened(activeProject);
}
FrontEndService frontEnd = tool.getService(FrontEndService.class);
frontEnd.addProjectListener(this);
super.init();
}
@Override
protected void dispose() {
// Normal shutdown will have removed the FrontEndService at the point dispose() is called.
// In this case, the listener is removed in a call to serviceRemoved(). If this plugin is
// removed by the user, then dispose() is called and we need to remove the listener.
FrontEndService frontEnd = tool.getService(FrontEndService.class);
frontEnd.addProjectListener(this);
if (frontEnd != null) {
frontEnd.removeProjectListener(this);
}
Project activeProject = tool.getProjectManager().getActiveProject();
if (activeProject != null) {
@ -89,14 +107,15 @@ public class DomainFolderChangesDisplayPlugin extends Plugin
}
@Override
public void domainFolderRemoved(DomainFolder parent, String name) {
provider.addText("domainFolderRemoved: parent=" + parent.getPathname() + ", name=" + name);
public void domainFolderRemoved(DomainFolder parent, String folderName) {
provider.addText(
"domainFolderRemoved: parent=" + parent.getPathname() + ", name=" + folderName);
}
@Override
public void domainFileRemoved(DomainFolder parent, String name, String fileID) {
provider.addText("domainFileRemoved: parent=" + parent.getPathname() + ", name=" + name +
", fileID=" + fileID);
public void domainFileRemoved(DomainFolder parent, String folderName, String fileID) {
provider.addText("domainFileRemoved: parent=" + parent.getPathname() + ", name=" +
folderName + ", fileID=" + fileID);
}
@Override

View File

@ -4,9 +4,9 @@
* Licensed 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.
@ -84,9 +84,8 @@ public class ServiceManager {
}
private void notifyServiceAdded(Class<?> interfaceClass, Object service) {
Iterator<?> it = serviceListeners.iterator();
while (it.hasNext()) {
((ServiceListener) it.next()).serviceAdded(interfaceClass, service);
for (ServiceListener serviceListener : serviceListeners) {
serviceListener.serviceAdded(interfaceClass, service);
}
}