mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 10:16:03 +02:00
Terminals: Bug 460064 - The Ctrl+Alt+T shortcut should pick up the
directory of the editor in focus
This commit is contained in:
parent
3c24c4231f
commit
cf87ee533b
10 changed files with 82 additions and 9 deletions
|
@ -3,4 +3,15 @@
|
|||
<plugin>
|
||||
<extension-point id="contextPropertiesProviders" name="%contextPropertiesProviders" schema="schema/contextPropertiesProviders.exsd"/>
|
||||
|
||||
<!-- Property tester contributions -->
|
||||
<extension point="org.eclipse.core.expressions.propertyTesters">
|
||||
<propertyTester
|
||||
class="org.eclipse.tcf.te.core.terminals.internal.PropertyTester"
|
||||
id="org.eclipse.tcf.te.core.terminals.PropertyTester"
|
||||
namespace="org.eclipse.tcf.te.core.terminals"
|
||||
properties="hasContextPropertiesProvider"
|
||||
type="java.lang.Object">
|
||||
</propertyTester>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2011, 2014 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 v1.0 which accompanies this distribution, and is
|
||||
* available at http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Wind River Systems - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.tcf.te.core.terminals.internal;
|
||||
|
||||
import org.eclipse.tcf.te.core.terminals.TerminalContextPropertiesProviderFactory;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Property tester implementation.
|
||||
*/
|
||||
public class PropertyTester extends org.eclipse.core.expressions.PropertyTester {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
|
||||
|
||||
// "hasContextPropertiesProvider": Checks if a context properties provider is available for the given receiver.
|
||||
if ("hasContextPropertiesProvider".equals(property)) { //$NON-NLS-1$
|
||||
boolean hasProvider = TerminalContextPropertiesProviderFactory.getProvider(receiver) != null;
|
||||
return expectedValue instanceof Boolean ? ((Boolean)expectedValue).equals(Boolean.valueOf(hasProvider)) : hasProvider;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -173,6 +173,14 @@ public class LocalLauncherDelegate extends AbstractLauncherDelegate {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (element instanceof IPath || element instanceof File) {
|
||||
File f = element instanceof IPath ? ((IPath)element).toFile() : (File)element;
|
||||
if (f.isDirectory() && f.canRead()) {
|
||||
dir = f.getAbsolutePath();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (dir != null) {
|
||||
|
|
|
@ -15,10 +15,15 @@ import java.util.Map;
|
|||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.jface.viewers.StructuredSelection;
|
||||
import org.eclipse.tcf.te.core.terminals.interfaces.constants.ITerminalsConnectorConstants;
|
||||
import org.eclipse.tcf.te.ui.terminals.interfaces.ILauncherDelegate;
|
||||
import org.eclipse.tcf.te.ui.terminals.launcher.LauncherDelegateManager;
|
||||
import org.eclipse.ui.IEditorInput;
|
||||
import org.eclipse.ui.IPathEditorInput;
|
||||
import org.eclipse.ui.handlers.HandlerUtil;
|
||||
|
||||
/**
|
||||
|
@ -34,6 +39,19 @@ public class LocalLauncherHandler extends AbstractHandler {
|
|||
// Get the current selection
|
||||
ISelection selection = HandlerUtil.getCurrentSelection(event);
|
||||
|
||||
// If the selection is not a structured selection, check if there is an active
|
||||
// editor and get the path from the editor input
|
||||
if (!(selection instanceof IStructuredSelection)) {
|
||||
IEditorInput input = HandlerUtil.getActiveEditorInput(event);
|
||||
if (input instanceof IPathEditorInput) {
|
||||
IPath path = ((IPathEditorInput)input).getPath();
|
||||
if (path != null) {
|
||||
if (path.toFile().isFile()) path = path.removeLastSegments(1);
|
||||
if (path.toFile().isDirectory() && path.toFile().canRead()) selection = new StructuredSelection(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get all applicable launcher delegates for the current selection
|
||||
ILauncherDelegate[] delegates = LauncherDelegateManager.getInstance().getApplicableLauncherDelegates(selection);
|
||||
// Find the local terminal launcher delegate
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
<iterate operator="and" ifEmpty="false">
|
||||
<test
|
||||
forcePluginActivation="true"
|
||||
property="org.eclipse.tcf.te.runtime.services.hasService"
|
||||
value="org.eclipse.tcf.te.runtime.services.interfaces.IPropertiesAccessService"/>
|
||||
property="org.eclipse.tcf.te.core.terminals.hasContextPropertiesProvider"
|
||||
value="true"/>
|
||||
</iterate>
|
||||
</with>
|
||||
</enablement>
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
<iterate operator="and" ifEmpty="false">
|
||||
<test
|
||||
forcePluginActivation="true"
|
||||
property="org.eclipse.tcf.te.runtime.services.hasService"
|
||||
value="org.eclipse.tcf.te.runtime.services.interfaces.IPropertiesAccessService"/>
|
||||
property="org.eclipse.tcf.te.core.terminals.hasContextPropertiesProvider"
|
||||
value="true"/>
|
||||
</iterate>
|
||||
</with>
|
||||
</enablement>
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
<iterate operator="and" ifEmpty="false">
|
||||
<test
|
||||
forcePluginActivation="true"
|
||||
property="org.eclipse.tcf.te.runtime.services.hasService"
|
||||
value="org.eclipse.tcf.te.runtime.services.interfaces.IPropertiesAccessService"/>
|
||||
property="org.eclipse.tcf.te.core.terminals.hasContextPropertiesProvider"
|
||||
value="true"/>
|
||||
</iterate>
|
||||
</with>
|
||||
</enablement>
|
||||
|
|
|
@ -151,7 +151,7 @@ public class InputStreamMonitor extends OutputStream implements IDisposable {
|
|||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.tcf.te.runtime.interfaces.IDisposable#dispose()
|
||||
* @see org.eclipse.ui.services.IDisposable#dispose()
|
||||
*/
|
||||
@Override
|
||||
public void dispose() {
|
||||
|
|
|
@ -125,7 +125,7 @@ public class OutputStreamMonitor implements IDisposable {
|
|||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.tcf.te.runtime.interfaces.IDisposable#dispose()
|
||||
* @see org.eclipse.ui.services.IDisposable#dispose()
|
||||
*/
|
||||
@Override
|
||||
public void dispose() {
|
||||
|
|
|
@ -70,7 +70,7 @@ public class StreamsConnector extends AbstractStreamsConnector implements IDispo
|
|||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.tcf.te.runtime.interfaces.IDisposable#dispose()
|
||||
* @see org.eclipse.ui.services.IDisposable#dispose()
|
||||
*/
|
||||
@Override
|
||||
public void dispose() {
|
||||
|
|
Loading…
Add table
Reference in a new issue