diff --git a/terminal/bundles/org.eclipse.terminal.connector.local/src/org/eclipse/terminal/connector/local/activator/UIPlugin.java b/terminal/bundles/org.eclipse.terminal.connector.local/src/org/eclipse/terminal/connector/local/activator/UIPlugin.java index 497fe8b8b31..eea9a952836 100644 --- a/terminal/bundles/org.eclipse.terminal.connector.local/src/org/eclipse/terminal/connector/local/activator/UIPlugin.java +++ b/terminal/bundles/org.eclipse.terminal.connector.local/src/org/eclipse/terminal/connector/local/activator/UIPlugin.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012 - 2018 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2012 - 2025 Wind River Systems, Inc. and others. All rights reserved. * 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/ @@ -8,19 +8,17 @@ * * Contributors: * Wind River Systems - initial API and implementation + * Alexander Fedorov (ArSysOp) - further evolution *******************************************************************************/ package org.eclipse.terminal.connector.local.activator; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.ImageRegistry; import org.eclipse.swt.graphics.Image; -import org.eclipse.terminal.view.core.ITerminalService; import org.eclipse.terminal.view.core.utils.ScopedEclipsePreferences; import org.eclipse.terminal.view.core.utils.TraceHandler; -import org.eclipse.terminal.view.ui.launcher.ILaunchDelegateManager; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; -import org.osgi.util.tracker.ServiceTracker; /** * The activator class controls the plug-in life cycle @@ -121,25 +119,4 @@ public static ImageDescriptor getImageDescriptor(String key) { return getDefault().getImageRegistry().getDescriptor(key); } - private static ServiceTracker terminalServiceTracker; - - public static synchronized ITerminalService getTerminalService() { - if (terminalServiceTracker == null) { - terminalServiceTracker = new ServiceTracker<>(getDefault().getBundle().getBundleContext(), - ITerminalService.class, null); - terminalServiceTracker.open(); - } - return terminalServiceTracker.getService(); - } - - private static ServiceTracker launchDelegateServiceTracker; - - public static synchronized ILaunchDelegateManager getLaunchDelegateManager() { - if (launchDelegateServiceTracker == null) { - launchDelegateServiceTracker = new ServiceTracker<>(getDefault().getBundle().getBundleContext(), - ILaunchDelegateManager.class, null); - launchDelegateServiceTracker.open(); - } - return launchDelegateServiceTracker.getService(); - } } diff --git a/terminal/bundles/org.eclipse.terminal.connector.local/src/org/eclipse/terminal/connector/local/launcher/LocalLauncherDelegate.java b/terminal/bundles/org.eclipse.terminal.connector.local/src/org/eclipse/terminal/connector/local/launcher/LocalLauncherDelegate.java index 40accd31ecf..7a5b3f360dc 100644 --- a/terminal/bundles/org.eclipse.terminal.connector.local/src/org/eclipse/terminal/connector/local/launcher/LocalLauncherDelegate.java +++ b/terminal/bundles/org.eclipse.terminal.connector.local/src/org/eclipse/terminal/connector/local/launcher/LocalLauncherDelegate.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012, 2018 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2012, 2025 Wind River Systems, Inc. and others. All rights reserved. * 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/ @@ -9,6 +9,7 @@ * Contributors: * Wind River Systems - initial API and implementation * Dirk Fauth - Bug 460496 + * Alexander Fedorov (ArSysOp) - further evolution *******************************************************************************/ package org.eclipse.terminal.connector.local.launcher; @@ -22,6 +23,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Optional; import org.eclipse.cdt.utils.pty.PTY; import org.eclipse.core.runtime.Assert; @@ -220,13 +222,8 @@ public void execute(Map properties, ITerminalService.Done done) } } } - - // Get the terminal service - ITerminalService terminal = UIPlugin.getTerminalService(); - // If not available, we cannot fulfill this request - if (terminal != null) { - terminal.openConsole(properties, done); - } + Optional.ofNullable(PlatformUI.getWorkbench().getService(ITerminalService.class)) + .ifPresent(s -> s.openConsole(properties, done)); } /** diff --git a/terminal/bundles/org.eclipse.terminal.connector.local/src/org/eclipse/terminal/connector/local/launcher/LocalLauncherHandler.java b/terminal/bundles/org.eclipse.terminal.connector.local/src/org/eclipse/terminal/connector/local/launcher/LocalLauncherHandler.java index 7074bb54eec..a0ad35cccea 100644 --- a/terminal/bundles/org.eclipse.terminal.connector.local/src/org/eclipse/terminal/connector/local/launcher/LocalLauncherHandler.java +++ b/terminal/bundles/org.eclipse.terminal.connector.local/src/org/eclipse/terminal/connector/local/launcher/LocalLauncherHandler.java @@ -23,11 +23,12 @@ import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.terminal.connector.local.activator.UIPlugin; import org.eclipse.terminal.view.core.ITerminalsConnectorConstants; +import org.eclipse.terminal.view.ui.launcher.ILaunchDelegateManager; import org.eclipse.terminal.view.ui.launcher.ILauncherDelegate; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IPathEditorInput; +import org.eclipse.ui.PlatformUI; import org.eclipse.ui.handlers.HandlerUtil; /** @@ -58,7 +59,7 @@ public Object execute(ExecutionEvent event) throws ExecutionException { } // Get all applicable launcher delegates for the current selection - List delegates = UIPlugin.getLaunchDelegateManager() + List delegates = PlatformUI.getWorkbench().getService(ILaunchDelegateManager.class) .getApplicableLauncherDelegates(selection); // Find the local terminal launcher delegate ILauncherDelegate delegate = null;