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
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2014, 2018 Wind River Systems, Inc. and others. All rights reserved.
* Copyright (c) 2014, 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,10 +8,12 @@
*
* Contributors:
* Wind River Systems - initial API and implementation
* Alexander Fedorov (ArSysOp) - further evolution
*******************************************************************************/
package org.eclipse.terminal.connector.local.launcher;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.eclipse.core.commands.AbstractHandler;
Expand Down Expand Up @@ -56,7 +58,8 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
}

// Get all applicable launcher delegates for the current selection
ILauncherDelegate[] delegates = UIPlugin.getLaunchDelegateManager().getApplicableLauncherDelegates(selection);
List<ILauncherDelegate> delegates = UIPlugin.getLaunchDelegateManager()
.getApplicableLauncherDelegates(selection);
// Find the local terminal launcher delegate
ILauncherDelegate delegate = null;
for (ILauncherDelegate candidate : delegates) {
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,6 +8,7 @@
*
* Contributors:
* Wind River Systems - initial API and implementation
* Alexander Fedorov (ArSysOp) - further evolution
*******************************************************************************/
package org.eclipse.terminal.view.ui.internal;

Expand Down Expand Up @@ -227,19 +228,18 @@ public int compare(IExtension o1, IExtension o2) {
* @param unique If <code>true</code>, the method returns new instances for each
* contributed terminal launcher delegate.
*
* @return The list of contributed terminal launcher delegates, or an empty array.
* @return The list of contributed terminal launcher delegates, or an empty list.
*/
@Override
public ILauncherDelegate[] getLauncherDelegates(boolean unique) {
public List<ILauncherDelegate> getLauncherDelegates(boolean unique) {
List<ILauncherDelegate> contributions = new ArrayList<>();
for (Proxy launcherDelegate : getExtensions().values()) {
ILauncherDelegate instance = unique ? launcherDelegate.newInstance() : launcherDelegate.getInstance();
if (instance != null && !contributions.contains(instance)) {
contributions.add(instance);
}
}

return contributions.toArray(new ILauncherDelegate[contributions.size()]);
return contributions;
}

/**
Expand Down Expand Up @@ -268,10 +268,10 @@ public ILauncherDelegate getLauncherDelegate(String id, boolean unique) {
* Returns the applicable terminal launcher delegates for the given selection.
*
* @param selection The selection or <code>null</code>.
* @return The list of applicable terminal launcher delegates or an empty array.
* @return The list of applicable terminal launcher delegates or an empty list.
*/
@Override
public ILauncherDelegate[] getApplicableLauncherDelegates(ISelection selection) {
public List<ILauncherDelegate> getApplicableLauncherDelegates(ISelection selection) {
List<ILauncherDelegate> applicable = new ArrayList<>();

for (ILauncherDelegate delegate : getLauncherDelegates(false)) {
Expand Down Expand Up @@ -312,7 +312,7 @@ public ILauncherDelegate[] getApplicableLauncherDelegates(ISelection selection)
}
}

return applicable.toArray(new ILauncherDelegate[applicable.size()]);
return applicable;
}

/**
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,6 +8,7 @@
*
* Contributors:
* Wind River Systems - initial API and implementation
* Alexander Fedorov (ArSysOp) - further evolution
*******************************************************************************/
package org.eclipse.terminal.view.ui.internal;

Expand All @@ -30,7 +31,7 @@ public boolean test(Object receiver, String property, Object[] args, Object expe
if ("hasApplicableLauncherDelegates".equals(property)) { //$NON-NLS-1$
ISelection selection = receiver instanceof ISelection i ? i : new StructuredSelection(receiver);
return expectedValue.equals(Boolean
.valueOf(UIPlugin.getLaunchDelegateManager().getApplicableLauncherDelegates(selection).length > 0));
.valueOf(!UIPlugin.getLaunchDelegateManager().getApplicableLauncherDelegates(selection).isEmpty()));
}

if ("canDisconnect".equals(property) && receiver instanceof ITerminalsView) { //$NON-NLS-1$
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 @@ -10,6 +10,7 @@
* Wind River Systems - initial API and implementation
* Max Weninger (Wind River) - [361352] [TERMINALS][SSH] Add SSH terminal support
* Dirk Fauth <dirk.fauth@googlemail.com> - Bug 460496
* Alexander Fedorov (ArSysOp) - further evolution
*******************************************************************************/
package org.eclipse.terminal.view.ui.internal.dialogs;

Expand Down Expand Up @@ -420,7 +421,7 @@ protected List<String> getTerminals() {
ITraceIds.TRACE_LAUNCH_TERMINAL_COMMAND_HANDLER, LaunchTerminalSettingsDialog.this);
}

ILauncherDelegate[] delegates = UIPlugin.getLaunchDelegateManager().getLauncherDelegates(false);
List<ILauncherDelegate> delegates = UIPlugin.getLaunchDelegateManager().getLauncherDelegates(false);

if (UIPlugin.getTraceHandler().isSlotEnabled(0, ITraceIds.TRACE_LAUNCH_TERMINAL_COMMAND_HANDLER)) {
UIPlugin.getTraceHandler().trace(
Expand Down Expand Up @@ -450,7 +451,7 @@ protected List<String> getTerminals() {
ITraceIds.TRACE_LAUNCH_TERMINAL_COMMAND_HANDLER, LaunchTerminalSettingsDialog.this);
}

ILauncherDelegate[] delegates = UIPlugin.getLaunchDelegateManager()
List<ILauncherDelegate> delegates = UIPlugin.getLaunchDelegateManager()
.getApplicableLauncherDelegates(selection);

if (UIPlugin.getTraceHandler().isSlotEnabled(0, ITraceIds.TRACE_LAUNCH_TERMINAL_COMMAND_HANDLER)) {
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,12 +8,14 @@
*
* Contributors:
* Wind River Systems - initial API and implementation
* Alexander Fedorov (ArSysOp) - further evolution
*******************************************************************************/
package org.eclipse.terminal.view.ui.internal.handler;

import java.text.DateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.eclipse.core.commands.AbstractHandler;
Expand Down Expand Up @@ -104,7 +106,7 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
}

// Check if the dialog needs to be shown at all
ILauncherDelegate[] delegates = UIPlugin.getLaunchDelegateManager()
List<ILauncherDelegate> delegates = UIPlugin.getLaunchDelegateManager()
.getApplicableLauncherDelegates(selection);

if (UIPlugin.getTraceHandler().isSlotEnabled(0, ITraceIds.TRACE_LAUNCH_TERMINAL_COMMAND_HANDLER)) {
Expand All @@ -113,7 +115,7 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
ITraceIds.TRACE_LAUNCH_TERMINAL_COMMAND_HANDLER, LaunchTerminalCommandHandler.this);
}

if (delegates.length > 1 || (delegates.length == 1 && delegates[0].needsUserConfiguration())) {
if (delegates.size() > 1 || (delegates.size() == 1 && delegates.get(0).needsUserConfiguration())) {
if (UIPlugin.getTraceHandler().isSlotEnabled(0, ITraceIds.TRACE_LAUNCH_TERMINAL_COMMAND_HANDLER)) {
UIPlugin.getTraceHandler().trace("(b) Attempt to open launch terminal settings dialog after " //$NON-NLS-1$
+ (System.currentTimeMillis() - start) + " ms.", //$NON-NLS-1$
Expand All @@ -137,8 +139,8 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
delegate.execute(properties, null);
}
}
} else if (delegates.length == 1) {
ILauncherDelegate delegate = delegates[0];
} else if (delegates.size() == 1) {
ILauncherDelegate delegate = delegates.get(0);
Map<String, Object> properties = new HashMap<>();

// Store the id of the selected delegate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@
* Contributors:
* Wind River Systems - initial API and implementation
* Christoph Läubrich - extract to interface
* Alexander Fedorov (ArSysOp) - further evolution
*******************************************************************************/
package org.eclipse.terminal.view.ui.launcher;

import java.util.List;

import org.eclipse.jface.viewers.ISelection;

public interface ILaunchDelegateManager {
Expand All @@ -22,9 +25,9 @@ public interface ILaunchDelegateManager {
* @param unique If <code>true</code>, the method returns new instances for each
* contributed terminal launcher delegate.
*
* @return The list of contributed terminal launcher delegates, or an empty array.
* @return The list of contributed terminal launcher delegates, or an empty list.
*/
ILauncherDelegate[] getLauncherDelegates(boolean unique);
List<ILauncherDelegate> getLauncherDelegates(boolean unique);

/**
* Returns the terminal launcher delegate identified by its unique id. If no terminal
Expand All @@ -41,8 +44,8 @@ public interface ILaunchDelegateManager {
* Returns the applicable terminal launcher delegates for the given selection.
*
* @param selection The selection or <code>null</code>.
* @return The list of applicable terminal launcher delegates or an empty array.
* @return The list of applicable terminal launcher delegates or an empty list.
*/
ILauncherDelegate[] getApplicableLauncherDelegates(ISelection selection);
List<ILauncherDelegate> getApplicableLauncherDelegates(ISelection selection);

}
Loading