Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
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;
Expand All @@ -27,17 +26,13 @@
*/
public class UIPlugin extends AbstractUIPlugin {
// The shared instance
private static UIPlugin plugin;
private static volatile UIPlugin plugin;
// The scoped preferences instance
private static volatile ScopedEclipsePreferences scopedPreferences;
// The trace handler instance
private static volatile TraceHandler traceHandler;

/**
* The constructor
*/
public UIPlugin() {
}
private ServiceTracker<ILaunchDelegateManager, ILaunchDelegateManager> launchDelegateServiceTracker;

/**
* Returns the shared instance
Expand Down Expand Up @@ -83,6 +78,8 @@ public static TraceHandler getTraceHandler() {
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
launchDelegateServiceTracker = new ServiceTracker<>(context, ILaunchDelegateManager.class, null);
launchDelegateServiceTracker.open();
plugin = this;
}

Expand Down Expand Up @@ -121,25 +118,11 @@ public static ImageDescriptor getImageDescriptor(String key) {
return getDefault().getImageRegistry().getDescriptor(key);
}

private static ServiceTracker<ITerminalService, ITerminalService> 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<ILaunchDelegateManager, ILaunchDelegateManager> launchDelegateServiceTracker;

public static synchronized ILaunchDelegateManager getLaunchDelegateManager() {
if (launchDelegateServiceTracker == null) {
launchDelegateServiceTracker = new ServiceTracker<>(getDefault().getBundle().getBundleContext(),
ILaunchDelegateManager.class, null);
launchDelegateServiceTracker.open();
UIPlugin plugin = getDefault();
if (plugin == null) {
return null;
}
return launchDelegateServiceTracker.getService();
return plugin.launchDelegateServiceTracker.getService();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public void execute(Map<String, Object> properties, ITerminalService.Done done)
}

// Get the terminal service
ITerminalService terminal = UIPlugin.getTerminalService();
ITerminalService terminal = getTerminalService();
// If not available, we cannot fulfill this request
if (terminal != null) {
terminal.openConsole(properties, done);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public void connect(ITerminalControl control) {
// Save the shell so the error message can have somewhere to display
Shell shell = control.getShell();
// Lookup the tab item
UIPlugin.getConsoleManager().findConsole(control).ifPresent(Widget::dispose);
getConsoleViewManager().findConsole(control).ifPresent(Widget::dispose);
// Get the error message from the exception
String msg = e.getLocalizedMessage() != null ? e.getLocalizedMessage() : ""; //$NON-NLS-1$
Assert.isNotNull(msg);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void execute(Map<String, Object> properties, ITerminalService.Done done)
Assert.isNotNull(properties);

// Get the terminal service
ITerminalService terminal = UIPlugin.getTerminalService();
ITerminalService terminal = getTerminalService();
// If not available, we cannot fulfill this request
if (terminal != null) {
terminal.openConsole(properties, done);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,9 @@
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.TraceHandler;
import org.eclipse.terminal.view.ui.launcher.ITerminalConsoleViewManager;
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
Expand Down Expand Up @@ -117,26 +114,4 @@ public static void log(IStatus status) {
getDefault().getLog().log(status);
}

private static ServiceTracker<ITerminalService, ITerminalService> serviceTracker;

public static synchronized ITerminalService getTerminalService() {
if (serviceTracker == null) {
serviceTracker = new ServiceTracker<>(getDefault().getBundle().getBundleContext(), ITerminalService.class,
null);
serviceTracker.open();
}
return serviceTracker.getService();
}

private static ServiceTracker<ITerminalConsoleViewManager, ITerminalConsoleViewManager> consoleManagerTracker;

public static synchronized ITerminalConsoleViewManager getConsoleManager() {
if (consoleManagerTracker == null) {
consoleManagerTracker = new ServiceTracker<>(getDefault().getBundle().getBundleContext(),
ITerminalConsoleViewManager.class, null);
consoleManagerTracker.open();
}
return consoleManagerTracker.getService();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import org.eclipse.jsch.core.IJSchService;
import org.eclipse.swt.graphics.Image;
import org.eclipse.terminal.connector.ssh.connector.SshConnection;
import org.eclipse.terminal.view.core.ITerminalService;
import org.eclipse.terminal.view.core.utils.TraceHandler;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
Expand Down Expand Up @@ -143,14 +142,4 @@ public static ImageDescriptor getImageDescriptor(String key) {
return getDefault().getImageRegistry().getDescriptor(key);
}

private static ServiceTracker<ITerminalService, ITerminalService> serviceTracker;

public static synchronized ITerminalService getTerminalService() {
if (serviceTracker == null) {
serviceTracker = new ServiceTracker<>(getDefault().getBundle().getBundleContext(), ITerminalService.class,
null);
serviceTracker.open();
}
return serviceTracker.getService();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
import org.eclipse.terminal.connector.ITerminalControl;
import org.eclipse.terminal.connector.Logger;
import org.eclipse.terminal.connector.NullSettingsStore;
import org.eclipse.terminal.connector.provider.TerminalConnectorImpl;
import org.eclipse.terminal.connector.provider.AbstractTerminalConnector;

import com.jcraft.jsch.ChannelShell;
import com.jcraft.jsch.JSch;

public class SshConnector extends TerminalConnectorImpl {
public class SshConnector extends AbstractTerminalConnector {
private OutputStream fOutputStream;
private InputStream fInputStream;
private JSch fJsch;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.eclipse.terminal.connector.ITerminalConnector;
import org.eclipse.terminal.connector.InMemorySettingsStore;
import org.eclipse.terminal.connector.TerminalConnectorExtension;
import org.eclipse.terminal.connector.ssh.activator.UIPlugin;
import org.eclipse.terminal.connector.ssh.connector.ISshSettings;
import org.eclipse.terminal.connector.ssh.connector.SshSettings;
import org.eclipse.terminal.connector.ssh.controls.SshWizardConfigurationPanel;
Expand Down Expand Up @@ -68,7 +67,7 @@ public void execute(Map<String, Object> properties, ITerminalService.Done done)
}

// Get the terminal service
ITerminalService terminal = UIPlugin.getTerminalService();
ITerminalService terminal = getTerminalService();
// If not available, we cannot fulfill this request
if (terminal != null) {
terminal.openConsole(properties, done);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@
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.TraceHandler;
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
Expand Down Expand Up @@ -105,14 +103,4 @@ public static ImageDescriptor getImageDescriptor(String key) {
return getDefault().getImageRegistry().getDescriptor(key);
}

private static ServiceTracker<ITerminalService, ITerminalService> serviceTracker;

public static synchronized ITerminalService getTerminalService() {
if (serviceTracker == null) {
serviceTracker = new ServiceTracker<>(getDefault().getBundle().getBundleContext(), ITerminalService.class,
null);
serviceTracker.open();
}
return serviceTracker.getService();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
import org.eclipse.terminal.connector.Logger;
import org.eclipse.terminal.connector.NullSettingsStore;
import org.eclipse.terminal.connector.TerminalState;
import org.eclipse.terminal.connector.provider.TerminalConnectorImpl;
import org.eclipse.terminal.connector.provider.AbstractTerminalConnector;

public class TelnetConnector extends TerminalConnectorImpl {
public class TelnetConnector extends AbstractTerminalConnector {

static final class TelnetOutputStream extends FilterOutputStream {
final static byte CR = 13;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.eclipse.terminal.connector.ITerminalConnector;
import org.eclipse.terminal.connector.InMemorySettingsStore;
import org.eclipse.terminal.connector.TerminalConnectorExtension;
import org.eclipse.terminal.connector.telnet.activator.UIPlugin;
import org.eclipse.terminal.connector.telnet.connector.TelnetSettings;
import org.eclipse.terminal.connector.telnet.controls.TelnetWizardConfigurationPanel;
import org.eclipse.terminal.connector.telnet.nls.Messages;
Expand Down Expand Up @@ -67,7 +66,7 @@ public void execute(Map<String, Object> properties, ITerminalService.Done done)
}

// Get the terminal service
ITerminalService terminal = UIPlugin.getTerminalService();
ITerminalService terminal = getTerminalService();
// If not available, we cannot fulfill this request
if (terminal != null) {
terminal.openConsole(properties, done);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@
<attribute name="class" type="string" use="required">
<annotation>
<documentation>
A class extending TerminalConnectorImpl
A class extending AbstractTerminalConnector
</documentation>
<appInfo>
<meta.attribute kind="java" basedOn="org.eclipse.terminal.connector.provider.TerminalConnectorImpl:"/>
<meta.attribute kind="java" basedOn="org.eclipse.terminal.connector.provider.AbstractTerminalConnector:"/>
</appInfo>
</annotation>
</attribute>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import java.util.Optional;

import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.terminal.connector.provider.TerminalConnectorImpl;
import org.eclipse.terminal.connector.provider.AbstractTerminalConnector;
import org.eclipse.terminal.control.ITerminalViewControl;

/**
Expand All @@ -29,9 +29,9 @@
* <code>org.eclipse.terminal.control.connectors</code> extension point. This
* class gives access to the static markup of a terminal connector extension as
* well as providing the lifecycle management for the dynamically loaded
* {@link TerminalConnectorImpl} instance, which performs the actual
* {@link AbstractTerminalConnector} instance, which performs the actual
* communications. This pattern allows for lazy initialization, bundle
* activation and class loading of the actual {@link TerminalConnectorImpl}
* activation and class loading of the actual {@link AbstractTerminalConnector}
* instance.
*
* Clients can get terminal connector instances from the
Expand Down Expand Up @@ -61,7 +61,7 @@ public interface ITerminalConnector extends IAdaptable {
boolean isHidden();

/**
* @return true if the {@link TerminalConnectorImpl} has been initialized.
* @return true if the {@link AbstractTerminalConnector} has been initialized.
* If there was an initialization error, {@link #getInitializationErrorMessage()}
* returns the error message.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.RegistryFactory;
import org.eclipse.terminal.connector.provider.TerminalConnectorImpl;
import org.eclipse.terminal.connector.provider.AbstractTerminalConnector;
import org.eclipse.terminal.internal.connector.TerminalConnector;

/**
Expand All @@ -40,7 +40,7 @@ static private ITerminalConnector makeConnector(final IConfigurationElement conf
}
String hidden = config.getAttribute("hidden"); //$NON-NLS-1$
boolean isHidden = hidden != null ? Boolean.parseBoolean(hidden) : false;
TerminalConnector.Factory factory = () -> (TerminalConnectorImpl) config.createExecutableExtension("class"); //$NON-NLS-1$
TerminalConnector.Factory factory = () -> (AbstractTerminalConnector) config.createExecutableExtension("class"); //$NON-NLS-1$
return new TerminalConnector(factory, id, name, isHidden);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* extension point.
*
*/
public abstract class TerminalConnectorImpl {
public abstract class AbstractTerminalConnector {

/**
* The TerminalControl associated with this connector.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import org.eclipse.terminal.connector.Logger;
import org.eclipse.terminal.connector.TerminalConnectorExtension;
import org.eclipse.terminal.connector.TerminalState;
import org.eclipse.terminal.connector.provider.TerminalConnectorImpl;
import org.eclipse.terminal.connector.provider.AbstractTerminalConnector;
import org.eclipse.terminal.internal.control.impl.TerminalMessages;

/**
Expand All @@ -35,7 +35,7 @@
*
* It provides all terminal connector functions that can be provided by static
* markup without loading the actual implementation class. The actual
* {@link TerminalConnectorImpl} implementation class is lazily loaded by the
* {@link AbstractTerminalConnector} implementation class is lazily loaded by the
* provided {@link TerminalConnector.Factory} interface when needed. class, and
* delegates to the actual implementation when needed. The following methods can
* be called without initializing the contributed implementation class:
Expand All @@ -50,7 +50,7 @@
*/
public class TerminalConnector implements ITerminalConnector {
/**
* Creates an instance of TerminalConnectorImpl. This is used to lazily load
* Creates an instance of {@link AbstractTerminalConnector}. This is used to lazily load
* classed defined in extensions.
*
*/
Expand All @@ -62,7 +62,7 @@ public interface Factory {
* @return a Connector
* @throws Exception
*/
TerminalConnectorImpl makeConnector() throws Exception;
AbstractTerminalConnector makeConnector() throws Exception;
}

/**
Expand All @@ -84,7 +84,7 @@ public interface Factory {
/**
* The connector
*/
private TerminalConnectorImpl fConnector;
private AbstractTerminalConnector fConnector;
/**
* If the initialization of the class specified in the extension fails,
* this variable contains the error
Expand All @@ -100,7 +100,7 @@ public interface Factory {
* Constructor for the terminal connector.
*
* @param terminalConnectorFactory Factory for lazily instantiating the
* TerminalConnectorImpl when needed.
* {@link AbstractTerminalConnector} when needed.
* @param id terminal connector ID. The connector is publicly known under
* this ID.
* @param name translatable name to display the connector in the UI.
Expand Down Expand Up @@ -137,14 +137,14 @@ public boolean isHidden() {
return fHidden;
}

private TerminalConnectorImpl getConnectorImpl() {
private AbstractTerminalConnector getConnectorImpl() {
if (!isInitialized()) {
try {
fConnector = fTerminalConnectorFactory.makeConnector();
fConnector.initialize();
} catch (Exception e) {
fException = e;
fConnector = new TerminalConnectorImpl() {
fConnector = new AbstractTerminalConnector() {
@Override
public void connect(ITerminalControl control) {
// super.connect(control);
Expand Down Expand Up @@ -241,7 +241,7 @@ public void setTerminalSize(int newWidth, int newHeight) {

@Override
public <T> T getAdapter(Class<T> adapter) {
TerminalConnectorImpl connector = null;
AbstractTerminalConnector connector = null;
if (isInitialized()) {
connector = getConnectorImpl();
}
Expand Down
Loading
Loading