mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-01 22:25:25 +02:00
Remove workaround for egit not providing path information for show in terminal (#1208)
To fix https://bugs.eclipse.org/bugs/show_bug.cgi?id=460277 many years
ago some workarounds were added to the terminal to allow adapting
git inputs to locations to open a terminal with.
Since that workaround was added it is no longer necessary because egit
now adapts objects and provides selections in a way that means we don't
need it anymore. In particular 316d0971ad
adapts inputs to Files that we know how to open with.
Fixes https://github.com/eclipse-cdt/cdt/issues/1202
This commit is contained in:
parent
f591672014
commit
a1cd8a948f
5 changed files with 1 additions and 123 deletions
|
@ -243,8 +243,6 @@
|
|||
includeBinaryEquivalents="false">
|
||||
<requirement
|
||||
name="org.eclipse.license.feature.group"/>
|
||||
<requirement
|
||||
name="org.eclipse.egit.feature.group"/>
|
||||
<requirement
|
||||
name="org.eclipse.equinox.executable.feature.group"/>
|
||||
<requirement
|
||||
|
@ -274,8 +272,6 @@
|
|||
<repositoryList>
|
||||
<repository
|
||||
url="https://download.eclipse.org/cbi/updates/license"/>
|
||||
<repository
|
||||
url="https://download.eclipse.org/egit/updates-nightly"/>
|
||||
<repository
|
||||
url="https://download.eclipse.org/linuxtools/updates-docker-nightly"/>
|
||||
<repository
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
|
||||
<repository location="https://download.eclipse.org/mylyn/updates/release/latest/" />
|
||||
</location>
|
||||
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
|
||||
<repository location="https://download.eclipse.org/egit/updates-stable-nightly/" />
|
||||
<unit id="org.eclipse.egit.feature.group" version="0.0.0" />
|
||||
</location>
|
||||
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
|
||||
<repository location="https://download.eclipse.org/linuxtools/updates-docker-nightly/" />
|
||||
<unit id="org.eclipse.linuxtools.docker.feature.feature.group" version="0.0.0" />
|
||||
|
|
|
@ -10,7 +10,6 @@ Require-Bundle: org.eclipse.core.expressions;bundle-version="[3.9.400,4)",
|
|||
org.eclipse.core.resources;bundle-version="[3.22.200,4)";resolution:=optional,
|
||||
org.eclipse.core.variables;bundle-version="[3.6.500,4)",
|
||||
org.eclipse.debug.ui;bundle-version="[3.18.800,4)";resolution:=optional,
|
||||
org.eclipse.egit.ui;bundle-version="[7.3.0,8)";resolution:=optional,
|
||||
org.eclipse.tm.terminal.view.core;bundle-version="[4.10.0,5.0.0)",
|
||||
org.eclipse.tm.terminal.control;bundle-version="[5.6.0,6.0.0)",
|
||||
org.eclipse.ui;bundle-version="[3.207.200,4)",
|
||||
|
@ -40,6 +39,5 @@ Export-Package: org.eclipse.tm.terminal.view.ui.actions,
|
|||
org.eclipse.tm.terminal.view.ui.services,
|
||||
org.eclipse.tm.terminal.view.ui.streams,
|
||||
org.eclipse.tm.terminal.view.ui.tabs,
|
||||
org.eclipse.tm.terminal.view.ui.view,
|
||||
org.eclipse.tm.terminal.view.ui.view.showin;x-internal:=true
|
||||
org.eclipse.tm.terminal.view.ui.view
|
||||
Automatic-Module-Name: org.eclipse.tm.terminal.view.ui
|
||||
|
|
|
@ -60,7 +60,6 @@ import org.eclipse.tm.terminal.view.ui.nls.Messages;
|
|||
import org.eclipse.tm.terminal.view.ui.tabs.TabFolderManager;
|
||||
import org.eclipse.tm.terminal.view.ui.tabs.TabFolderMenuHandler;
|
||||
import org.eclipse.tm.terminal.view.ui.tabs.TabFolderToolbarHandler;
|
||||
import org.eclipse.tm.terminal.view.ui.view.showin.GitShowInContextHandler;
|
||||
import org.eclipse.ui.IMemento;
|
||||
import org.eclipse.ui.ISources;
|
||||
import org.eclipse.ui.IViewSite;
|
||||
|
@ -622,21 +621,6 @@ public class TerminalsView extends ViewPart implements ITerminalsView, IShowInTa
|
|||
// Get the selection from the context
|
||||
ISelection selection = context.getSelection();
|
||||
|
||||
// If the selection is not set or empty, look at the input element of
|
||||
// the show in context.
|
||||
if (!(selection instanceof IStructuredSelection) || selection.isEmpty()) {
|
||||
Object input = context.getInput();
|
||||
// If coming from the EGit repository viewer, the input element is
|
||||
// org.eclipse.egit.ui.internal.history.HistoryPageInput
|
||||
if ("org.eclipse.egit.ui.internal.history.HistoryPageInput".equals(input.getClass().getName())) { //$NON-NLS-1$
|
||||
Bundle bundle = Platform.getBundle("org.eclipse.egit.ui"); //$NON-NLS-1$
|
||||
if (bundle != null && bundle.getState() != Bundle.UNINSTALLED
|
||||
&& bundle.getState() != Bundle.STOPPING) {
|
||||
selection = GitShowInContextHandler.getSelection(input);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The selection must contain elements that can be adapted to IResource, File or IPath
|
||||
if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
|
||||
boolean isValid = true;
|
||||
|
@ -706,15 +690,6 @@ public class TerminalsView extends ViewPart implements ITerminalsView, IShowInTa
|
|||
continue;
|
||||
}
|
||||
|
||||
// The EGit repository view can also set a RepositoryTreeNode (and subclasses)
|
||||
// "org.eclipse.egit.ui.internal.repository.tree...."
|
||||
if (element.getClass().getName().startsWith("org.eclipse.egit.ui.internal.repository.tree")) { //$NON-NLS-1$
|
||||
bundle = Platform.getBundle("org.eclipse.egit.ui"); //$NON-NLS-1$
|
||||
if (bundle != null && bundle.getState() != Bundle.UNINSTALLED
|
||||
&& bundle.getState() != Bundle.STOPPING) {
|
||||
adapted = GitShowInContextHandler.getPath(element);
|
||||
}
|
||||
}
|
||||
if (adapted != null) {
|
||||
if (!elements.contains(adapted))
|
||||
elements.add(adapted);
|
||||
|
|
|
@ -1,87 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015, 2018 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/
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*
|
||||
* Contributors:
|
||||
* Wind River Systems - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.tm.terminal.view.ui.view.showin;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.Assert;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.StructuredSelection;
|
||||
|
||||
/**
|
||||
* Git show in context handler implementation.
|
||||
*/
|
||||
@SuppressWarnings("restriction")
|
||||
public class GitShowInContextHandler {
|
||||
|
||||
/**
|
||||
* Converts the data from the input object into a selection.
|
||||
*
|
||||
* @param input The input element. Must not be <code>null</code>.
|
||||
* @return The selection or <code>null</code>.
|
||||
*/
|
||||
public static ISelection getSelection(Object input) {
|
||||
Assert.isNotNull(input);
|
||||
|
||||
List<Object> elements = new ArrayList<>();
|
||||
|
||||
if (input instanceof org.eclipse.egit.ui.internal.history.HistoryPageInput) {
|
||||
org.eclipse.egit.ui.internal.history.HistoryPageInput inp = (org.eclipse.egit.ui.internal.history.HistoryPageInput) input;
|
||||
|
||||
if (inp.isSingleFile()) {
|
||||
elements.add(inp.getSingleFile());
|
||||
} else {
|
||||
File[] fl = inp.getFileList();
|
||||
if (fl != null && fl.length > 0) {
|
||||
for (File f : fl) {
|
||||
if (f.canRead() && !elements.contains(f)) {
|
||||
elements.add(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IResource[] rl = inp.getItems();
|
||||
if (rl != null && rl.length > 0) {
|
||||
for (IResource r : rl) {
|
||||
if (r.isAccessible() && !elements.contains(r)) {
|
||||
elements.add(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return elements.isEmpty() ? null : new StructuredSelection(elements);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the path of the given element.
|
||||
*
|
||||
* @param element The element. Must not be <code>null</code>.
|
||||
* @return The path or <code>null</code>.
|
||||
*/
|
||||
public static IPath getPath(Object element) {
|
||||
Assert.isNotNull(element);
|
||||
|
||||
IPath path = null;
|
||||
|
||||
if (element instanceof org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode) {
|
||||
path = ((org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode<?>) element).getPath();
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue