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 @@ -23,6 +23,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;

import org.eclipse.cdt.utils.pty.PTY;
import org.eclipse.core.runtime.Assert;
Expand All @@ -44,7 +45,6 @@
import org.eclipse.terminal.connector.local.controls.LocalWizardConfigurationPanel;
import org.eclipse.terminal.connector.process.ProcessSettings;
import org.eclipse.terminal.view.core.ILineSeparatorConstants;
import org.eclipse.terminal.view.core.ITerminalService;
import org.eclipse.terminal.view.core.ITerminalServiceOutputStreamMonitorListener;
import org.eclipse.terminal.view.core.ITerminalsConnectorConstants;
import org.eclipse.terminal.view.ui.IMementoHandler;
Expand Down Expand Up @@ -75,7 +75,7 @@ public IConfigurationPanel getPanel(IConfigurationPanelContainer container) {
}

@Override
public void execute(Map<String, Object> properties, ITerminalService.Done done) {
public CompletableFuture<?> execute(Map<String, Object> properties) {
Assert.isNotNull(properties);

// Set the terminal tab title
Expand Down Expand Up @@ -221,12 +221,10 @@ public void execute(Map<String, Object> properties, ITerminalService.Done done)
}
}
}

// Get the terminal service
ITerminalService terminal = getTerminalService();
// If not available, we cannot fulfill this request
if (terminal != null) {
terminal.openConsole(properties, done);
try {
return getTerminalService().openConsole(properties);
} catch (RuntimeException e) {
return CompletableFuture.failedFuture(e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
Expand All @@ -37,9 +38,12 @@ public class LocalLauncherHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection selection = selection(event);
UIPlugin.getLaunchDelegateManager().getApplicableLauncherDelegates(selection)
.filter(d -> "org.eclipse.terminal.connector.local.launcher.local".equals(d.getId())).findFirst() //$NON-NLS-1$
.ifPresent(d -> executeDelegate(selection, d));
Optional<ILauncherDelegate> delegate = UIPlugin.getLaunchDelegateManager()
.getApplicableLauncherDelegates(selection)
.filter(d -> "org.eclipse.terminal.connector.local.launcher.local".equals(d.getId())).findFirst(); //$NON-NLS-1$
if (delegate.isPresent()) {
executeDelegate(selection, delegate.get());
}
return null;
}

Expand All @@ -64,11 +68,15 @@ private ISelection selection(ExecutionEvent event) {
return selection;
}

private void executeDelegate(ISelection selection, ILauncherDelegate delegate) {
private void executeDelegate(ISelection selection, ILauncherDelegate delegate) throws ExecutionException {
Map<String, Object> properties = new HashMap<>();
properties.put(ITerminalsConnectorConstants.PROP_DELEGATE_ID, delegate.getId());
properties.put(ITerminalsConnectorConstants.PROP_SELECTION, selection);
delegate.execute(properties, null);
try {
delegate.execute(properties);
} catch (Exception e) {
throw new ExecutionException(e.getMessage(), e);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
package org.eclipse.terminal.connector.process.internal;

import java.util.Map;
import java.util.concurrent.CompletableFuture;

import org.eclipse.cdt.utils.pty.PTY;
import org.eclipse.core.runtime.Assert;
Expand All @@ -22,7 +23,6 @@
import org.eclipse.terminal.connector.InMemorySettingsStore;
import org.eclipse.terminal.connector.TerminalConnectorExtension;
import org.eclipse.terminal.connector.process.ProcessSettings;
import org.eclipse.terminal.view.core.ITerminalService;
import org.eclipse.terminal.view.core.ITerminalServiceOutputStreamMonitorListener;
import org.eclipse.terminal.view.core.ITerminalsConnectorConstants;
import org.eclipse.terminal.view.ui.launcher.AbstractLauncherDelegate;
Expand All @@ -45,14 +45,12 @@ public IConfigurationPanel getPanel(IConfigurationPanelContainer container) {
}

@Override
public void execute(Map<String, Object> properties, ITerminalService.Done done) {
public CompletableFuture<?> execute(Map<String, Object> properties) {
Assert.isNotNull(properties);

// Get the terminal service
ITerminalService terminal = getTerminalService();
// If not available, we cannot fulfill this request
if (terminal != null) {
terminal.openConsole(properties, done);
try {
return getTerminalService().openConsole(properties);
} catch (RuntimeException e) {
return CompletableFuture.failedFuture(e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.text.DateFormat;
import java.util.Date;
import java.util.Map;
import java.util.concurrent.CompletableFuture;

import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
Expand All @@ -28,7 +29,6 @@
import org.eclipse.terminal.connector.ssh.connector.SshSettings;
import org.eclipse.terminal.connector.ssh.controls.SshWizardConfigurationPanel;
import org.eclipse.terminal.connector.ssh.nls.Messages;
import org.eclipse.terminal.view.core.ITerminalService;
import org.eclipse.terminal.view.core.ITerminalsConnectorConstants;
import org.eclipse.terminal.view.ui.IMementoHandler;
import org.eclipse.terminal.view.ui.launcher.AbstractLauncherDelegate;
Expand All @@ -53,7 +53,7 @@ public IConfigurationPanel getPanel(IConfigurationPanelContainer container) {
}

@Override
public void execute(Map<String, Object> properties, ITerminalService.Done done) {
public CompletableFuture<?> execute(Map<String, Object> properties) {
Assert.isNotNull(properties);

// Set the terminal tab title
Expand All @@ -67,12 +67,10 @@ public void execute(Map<String, Object> properties, ITerminalService.Done done)
if (!properties.containsKey(ITerminalsConnectorConstants.PROP_FORCE_NEW)) {
properties.put(ITerminalsConnectorConstants.PROP_FORCE_NEW, Boolean.TRUE);
}

// Get the terminal service
ITerminalService terminal = getTerminalService();
// If not available, we cannot fulfill this request
if (terminal != null) {
terminal.openConsole(properties, done);
try {
return getTerminalService().openConsole(properties);
} catch (RuntimeException e) {
return CompletableFuture.failedFuture(e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.text.DateFormat;
import java.util.Date;
import java.util.Map;
import java.util.concurrent.CompletableFuture;

import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
Expand All @@ -27,7 +28,6 @@
import org.eclipse.terminal.connector.telnet.connector.TelnetSettings;
import org.eclipse.terminal.connector.telnet.controls.TelnetWizardConfigurationPanel;
import org.eclipse.terminal.connector.telnet.nls.Messages;
import org.eclipse.terminal.view.core.ITerminalService;
import org.eclipse.terminal.view.core.ITerminalsConnectorConstants;
import org.eclipse.terminal.view.ui.IMementoHandler;
import org.eclipse.terminal.view.ui.launcher.AbstractLauncherDelegate;
Expand All @@ -52,7 +52,7 @@ public IConfigurationPanel getPanel(IConfigurationPanelContainer container) {
}

@Override
public void execute(Map<String, Object> properties, ITerminalService.Done done) {
public CompletableFuture<?> execute(Map<String, Object> properties) {
Assert.isNotNull(properties);

// Set the terminal tab title
Expand All @@ -66,12 +66,10 @@ public void execute(Map<String, Object> properties, ITerminalService.Done done)
if (!properties.containsKey(ITerminalsConnectorConstants.PROP_FORCE_NEW)) {
properties.put(ITerminalsConnectorConstants.PROP_FORCE_NEW, Boolean.TRUE);
}

// Get the terminal service
ITerminalService terminal = getTerminalService();
// If not available, we cannot fulfill this request
if (terminal != null) {
terminal.openConsole(properties, done);
try {
return getTerminalService().openConsole(properties);
} catch (RuntimeException e) {
return CompletableFuture.failedFuture(e);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011 - 2018 Wind River Systems, Inc. and others. All rights reserved.
* Copyright (c) 2011 - 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/
Expand All @@ -8,53 +8,41 @@
*
* Contributors:
* Wind River Systems - initial API and implementation
* Alexander Fedorov (ArSysOp) - further evolution
*******************************************************************************/
package org.eclipse.terminal.view.core;

import java.util.Map;

import org.eclipse.core.runtime.IStatus;
import java.util.concurrent.CompletableFuture;

/**
* Terminal service.
*/
public interface ITerminalService {

/**
* Client call back interface.
*/
public interface Done {
/**
* Called when the terminal service operation is done.
*
* @param status The status of the terminal service operation.
*/
public void done(IStatus status);
}

/**
* Opens a terminal asynchronously and invokes the given callback if done.
*
* @param properties The terminal properties. Must not be <code>null</code>.
* @param done The callback to invoke if finished or <code>null</code>.
* @return the {@link CompletableFuture}
*/
public void openConsole(Map<String, Object> properties, Done done);
public CompletableFuture<?> openConsole(Map<String, Object> properties);

/**
* Close the terminal asynchronously and invokes the given callback if done.
* Close the terminal asynchronously.
*
* @param properties The terminal properties. Must not be <code>null</code>.
* @param done The callback to invoke if finished or <code>null</code>.
* @return the {@link CompletableFuture}
*/
public void closeConsole(Map<String, Object> properties, Done done);
public CompletableFuture<?> closeConsole(Map<String, Object> properties);

/**
* Terminate (disconnect) the terminal asynchronously and invokes the given callback if done.
*
* @param properties The terminal properties. Must not be <code>null</code>.
* @param done The callback to invoke if finished or <code>null</code>.
* @return the {@link CompletableFuture}
*/
public void terminateConsole(Map<String, Object> properties, Done done);
public CompletableFuture<?> terminateConsole(Map<String, Object> properties);

/**
* Register the given listener to receive notifications about terminal events.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public static String getString(String key) {
public static String AbstractConfigurationPanel_encoding_custom_title;
public static String AbstractConfigurationPanel_encoding_custom_message;
public static String AbstractConfigurationPanel_encoding_custom_error;
public static String AbstractLauncherDelegate_e_no_terminal_service;

public static String ConsoleManager_e_cannot_create_console;
public static String ConsoleManager_e_no_active_page;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ AbstractConfigurationPanel_encoding_custom=Other...
AbstractConfigurationPanel_encoding_custom_title=Other...
AbstractConfigurationPanel_encoding_custom_message=Please enter the name of the encoding to use for the terminal.
AbstractConfigurationPanel_encoding_custom_error=Unsupported encoding. Please enter the name of a supported encoding.
AbstractLauncherDelegate_e_no_terminal_service=Terminal service is not available
ConsoleManager_e_cannot_create_console=Cannot create console
ConsoleManager_e_no_active_page=No active workbench page

Expand Down
Loading
Loading