mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-26 18:35:32 +02:00
Terminals: Allow the use of Eclipse variables to specify the initial
local terminal working directory within the Terminals View preferences
This commit is contained in:
parent
5d84a80a39
commit
49592b0d05
11 changed files with 128 additions and 26 deletions
|
@ -41,6 +41,7 @@
|
||||||
<import feature="org.eclipse.tm.terminal.serial" version="2.1.300" match="greaterOrEqual"/>
|
<import feature="org.eclipse.tm.terminal.serial" version="2.1.300" match="greaterOrEqual"/>
|
||||||
<import feature="org.eclipse.tm.terminal.ssh" version="2.1.300" match="greaterOrEqual"/>
|
<import feature="org.eclipse.tm.terminal.ssh" version="2.1.300" match="greaterOrEqual"/>
|
||||||
<import feature="org.eclipse.tm.terminal.telnet" version="2.1.300" match="greaterOrEqual"/>
|
<import feature="org.eclipse.tm.terminal.telnet" version="2.1.300" match="greaterOrEqual"/>
|
||||||
|
<import plugin="org.eclipse.core.variables" version="3.2.800" match="greaterOrEqual"/>
|
||||||
</requires>
|
</requires>
|
||||||
|
|
||||||
<plugin
|
<plugin
|
||||||
|
|
|
@ -10,6 +10,8 @@ Require-Bundle: org.eclipse.cdt.core;bundle-version="5.6";resolution:=optional,
|
||||||
org.eclipse.core.expressions;bundle-version="3.4.400",
|
org.eclipse.core.expressions;bundle-version="3.4.400",
|
||||||
org.eclipse.core.resources;bundle-version="3.8.1";resolution:=optional,
|
org.eclipse.core.resources;bundle-version="3.8.1";resolution:=optional,
|
||||||
org.eclipse.core.runtime;bundle-version="3.8.0",
|
org.eclipse.core.runtime;bundle-version="3.8.0",
|
||||||
|
org.eclipse.core.variables;bundle-version="3.2.800",
|
||||||
|
org.eclipse.debug.ui;bundle-version="3.8.1";resolution:=optional,
|
||||||
org.eclipse.tcf.te.core.terminals;bundle-version="1.3.0",
|
org.eclipse.tcf.te.core.terminals;bundle-version="1.3.0",
|
||||||
org.eclipse.tcf.te.ui.terminals;bundle-version="1.3.0",
|
org.eclipse.tcf.te.ui.terminals;bundle-version="1.3.0",
|
||||||
org.eclipse.tcf.te.ui.terminals.process;bundle-version="1.3.0",
|
org.eclipse.tcf.te.ui.terminals.process;bundle-version="1.3.0",
|
||||||
|
|
|
@ -77,7 +77,7 @@ public class LocalWizardConfigurationPanel extends AbstractExtendedConfiguration
|
||||||
label.setLayoutData(layoutData);
|
label.setLayoutData(layoutData);
|
||||||
|
|
||||||
Bundle bundle = Platform.getBundle("org.eclipse.core.resources"); //$NON-NLS-1$
|
Bundle bundle = Platform.getBundle("org.eclipse.core.resources"); //$NON-NLS-1$
|
||||||
if (bundle != null && (bundle.getState() == Bundle.RESOLVED || bundle.getState() == Bundle.ACTIVE)) {
|
if (bundle != null && bundle.getState() != Bundle.UNINSTALLED && bundle.getState() != Bundle.STOPPING) {
|
||||||
resource = getSelectionResource();
|
resource = getSelectionResource();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ public class LocalWizardConfigurationPanel extends AbstractExtendedConfiguration
|
||||||
data.put(ITerminalsConnectorConstants.PROP_ENCODING, getEncoding());
|
data.put(ITerminalsConnectorConstants.PROP_ENCODING, getEncoding());
|
||||||
|
|
||||||
Bundle bundle = Platform.getBundle("org.eclipse.core.resources"); //$NON-NLS-1$
|
Bundle bundle = Platform.getBundle("org.eclipse.core.resources"); //$NON-NLS-1$
|
||||||
if (bundle != null && (bundle.getState() == Bundle.RESOLVED || bundle.getState() == Bundle.ACTIVE)) {
|
if (bundle != null && bundle.getState() != Bundle.UNINSTALLED && bundle.getState() != Bundle.STOPPING) {
|
||||||
// if we have a IResource selection use the location for working directory
|
// if we have a IResource selection use the location for working directory
|
||||||
if (resource instanceof org.eclipse.core.resources.IResource){
|
if (resource instanceof org.eclipse.core.resources.IResource){
|
||||||
String dir = ((org.eclipse.core.resources.IResource)resource).getProject().getLocation().toString();
|
String dir = ((org.eclipse.core.resources.IResource)resource).getProject().getLocation().toString();
|
||||||
|
|
|
@ -22,11 +22,14 @@ import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.utils.pty.PTY;
|
import org.eclipse.cdt.utils.pty.PTY;
|
||||||
import org.eclipse.core.runtime.Assert;
|
import org.eclipse.core.runtime.Assert;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IAdaptable;
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
import org.eclipse.core.runtime.Platform;
|
import org.eclipse.core.runtime.Platform;
|
||||||
import org.eclipse.core.runtime.URIUtil;
|
import org.eclipse.core.runtime.URIUtil;
|
||||||
|
import org.eclipse.core.variables.IStringVariableManager;
|
||||||
|
import org.eclipse.core.variables.VariablesPlugin;
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
import org.eclipse.tcf.te.core.terminals.TerminalServiceFactory;
|
import org.eclipse.tcf.te.core.terminals.TerminalServiceFactory;
|
||||||
|
@ -125,7 +128,7 @@ public class LocalLauncherDelegate extends AbstractLauncherDelegate {
|
||||||
}
|
}
|
||||||
} else if (IPreferenceKeys.PREF_INITIAL_CWD_ECLIPSE_WS.equals(initialCwd)) {
|
} else if (IPreferenceKeys.PREF_INITIAL_CWD_ECLIPSE_WS.equals(initialCwd)) {
|
||||||
Bundle bundle = Platform.getBundle("org.eclipse.core.resources"); //$NON-NLS-1$
|
Bundle bundle = Platform.getBundle("org.eclipse.core.resources"); //$NON-NLS-1$
|
||||||
if (bundle != null && (bundle.getState() == Bundle.RESOLVED || bundle.getState() == Bundle.ACTIVE)) {
|
if (bundle != null && bundle.getState() != Bundle.UNINSTALLED && bundle.getState() != Bundle.STOPPING) {
|
||||||
if (org.eclipse.core.resources.ResourcesPlugin.getWorkspace() != null
|
if (org.eclipse.core.resources.ResourcesPlugin.getWorkspace() != null
|
||||||
&& org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot() != null
|
&& org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot() != null
|
||||||
&& org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot().getLocation() != null) {
|
&& org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot().getLocation() != null) {
|
||||||
|
@ -133,9 +136,19 @@ public class LocalLauncherDelegate extends AbstractLauncherDelegate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
IPath p = new Path(initialCwd);
|
try {
|
||||||
if (p.toFile().canRead() && p.toFile().isDirectory()) {
|
// Resolve possible dynamic variables
|
||||||
cwd = p.toOSString();
|
IStringVariableManager vm = VariablesPlugin.getDefault().getStringVariableManager();
|
||||||
|
String resolved = vm.performStringSubstitution(initialCwd);
|
||||||
|
|
||||||
|
IPath p = new Path(resolved);
|
||||||
|
if (p.toFile().canRead() && p.toFile().isDirectory()) {
|
||||||
|
cwd = p.toOSString();
|
||||||
|
}
|
||||||
|
} catch (CoreException ex) {
|
||||||
|
if (Platform.inDebugMode()) {
|
||||||
|
UIPlugin.getDefault().getLog().log(ex.getStatus());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,7 +169,7 @@ public class LocalLauncherDelegate extends AbstractLauncherDelegate {
|
||||||
Object element = iter.next();
|
Object element = iter.next();
|
||||||
|
|
||||||
Bundle bundle = Platform.getBundle("org.eclipse.core.resources"); //$NON-NLS-1$
|
Bundle bundle = Platform.getBundle("org.eclipse.core.resources"); //$NON-NLS-1$
|
||||||
if (bundle != null && (bundle.getState() == Bundle.RESOLVED || bundle.getState() == Bundle.ACTIVE)) {
|
if (bundle != null && bundle.getState() != Bundle.UNINSTALLED && bundle.getState() != Bundle.STOPPING) {
|
||||||
// If the element is not an IResource, try to adapt to IResource
|
// If the element is not an IResource, try to adapt to IResource
|
||||||
if (!(element instanceof org.eclipse.core.resources.IResource)) {
|
if (!(element instanceof org.eclipse.core.resources.IResource)) {
|
||||||
Object adapted = element instanceof IAdaptable ? ((IAdaptable)element).getAdapter(org.eclipse.core.resources.IResource.class) : null;
|
Object adapted = element instanceof IAdaptable ? ((IAdaptable)element).getAdapter(org.eclipse.core.resources.IResource.class) : null;
|
||||||
|
@ -331,7 +344,7 @@ public class LocalLauncherDelegate extends AbstractLauncherDelegate {
|
||||||
|
|
||||||
// ECLIPSE_WORKSPACE
|
// ECLIPSE_WORKSPACE
|
||||||
Bundle bundle = Platform.getBundle("org.eclipse.core.resources"); //$NON-NLS-1$
|
Bundle bundle = Platform.getBundle("org.eclipse.core.resources"); //$NON-NLS-1$
|
||||||
if (bundle != null && (bundle.getState() == Bundle.RESOLVED || bundle.getState() == Bundle.ACTIVE)) {
|
if (bundle != null && bundle.getState() != Bundle.UNINSTALLED && bundle.getState() != Bundle.STOPPING) {
|
||||||
if (org.eclipse.core.resources.ResourcesPlugin.getWorkspace() != null
|
if (org.eclipse.core.resources.ResourcesPlugin.getWorkspace() != null
|
||||||
&& org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot() != null
|
&& org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot() != null
|
||||||
&& org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot().getLocation() != null) {
|
&& org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot().getLocation() != null) {
|
||||||
|
|
|
@ -45,6 +45,7 @@ public class Messages extends NLS {
|
||||||
public static String PreferencePage_workingDir_button_browse;
|
public static String PreferencePage_workingDir_button_browse;
|
||||||
public static String PreferencePage_workingDir_note_label;
|
public static String PreferencePage_workingDir_note_label;
|
||||||
public static String PreferencePage_workingDir_note_text;
|
public static String PreferencePage_workingDir_note_text;
|
||||||
|
public static String PreferencePage_workingDir_button_variables;
|
||||||
|
|
||||||
public static String ExternalExecutablesDialog_title_add;
|
public static String ExternalExecutablesDialog_title_add;
|
||||||
public static String ExternalExecutablesDialog_title_edit;
|
public static String ExternalExecutablesDialog_title_edit;
|
||||||
|
|
|
@ -33,6 +33,7 @@ PreferencePage_workingDir_label=Local Terminal Initial Working Directory
|
||||||
PreferencePage_workingDir_userhome_label=User home
|
PreferencePage_workingDir_userhome_label=User home
|
||||||
PreferencePage_workingDir_eclipsehome_label=Eclipse home
|
PreferencePage_workingDir_eclipsehome_label=Eclipse home
|
||||||
PreferencePage_workingDir_eclipsews_label=Eclipse workspace
|
PreferencePage_workingDir_eclipsews_label=Eclipse workspace
|
||||||
PreferencePage_workingDir_button_browse=Browse...
|
PreferencePage_workingDir_button_browse=&Browse...
|
||||||
PreferencePage_workingDir_note_label=Note:
|
PreferencePage_workingDir_note_label=Note:
|
||||||
PreferencePage_workingDir_note_text=The chosen initial working directory might be overwritten by the current selection of the active view.
|
PreferencePage_workingDir_note_text=The chosen initial working directory might be overwritten by the current selection of the active view.
|
||||||
|
PreferencePage_workingDir_button_variables=&Variables...
|
||||||
|
|
|
@ -194,7 +194,7 @@ public class ExternalExecutablesDialog extends TrayDialog {
|
||||||
} else {
|
} else {
|
||||||
String workspace = null;
|
String workspace = null;
|
||||||
Bundle bundle = Platform.getBundle("org.eclipse.core.resources"); //$NON-NLS-1$
|
Bundle bundle = Platform.getBundle("org.eclipse.core.resources"); //$NON-NLS-1$
|
||||||
if (bundle != null && (bundle.getState() == Bundle.RESOLVED || bundle.getState() == Bundle.ACTIVE)) {
|
if (bundle != null && bundle.getState() != Bundle.UNINSTALLED && bundle.getState() != Bundle.STOPPING) {
|
||||||
workspace = org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString();
|
workspace = org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,7 +274,7 @@ public class ExternalExecutablesDialog extends TrayDialog {
|
||||||
} else {
|
} else {
|
||||||
String workspace = null;
|
String workspace = null;
|
||||||
Bundle bundle = Platform.getBundle("org.eclipse.core.resources"); //$NON-NLS-1$
|
Bundle bundle = Platform.getBundle("org.eclipse.core.resources"); //$NON-NLS-1$
|
||||||
if (bundle != null && (bundle.getState() == Bundle.RESOLVED || bundle.getState() == Bundle.ACTIVE)) {
|
if (bundle != null && bundle.getState() != Bundle.UNINSTALLED && bundle.getState() != Bundle.STOPPING) {
|
||||||
workspace = org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString();
|
workspace = org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,10 +18,13 @@ import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
import org.eclipse.core.runtime.Platform;
|
import org.eclipse.core.runtime.Platform;
|
||||||
import org.eclipse.core.runtime.URIUtil;
|
import org.eclipse.core.runtime.URIUtil;
|
||||||
|
import org.eclipse.core.variables.IStringVariableManager;
|
||||||
|
import org.eclipse.core.variables.VariablesPlugin;
|
||||||
import org.eclipse.jface.dialogs.Dialog;
|
import org.eclipse.jface.dialogs.Dialog;
|
||||||
import org.eclipse.jface.resource.ImageDescriptor;
|
import org.eclipse.jface.resource.ImageDescriptor;
|
||||||
import org.eclipse.jface.resource.JFaceResources;
|
import org.eclipse.jface.resource.JFaceResources;
|
||||||
|
@ -39,6 +42,8 @@ import org.eclipse.jface.viewers.TableViewer;
|
||||||
import org.eclipse.jface.viewers.Viewer;
|
import org.eclipse.jface.viewers.Viewer;
|
||||||
import org.eclipse.jface.window.Window;
|
import org.eclipse.jface.window.Window;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.events.ModifyEvent;
|
||||||
|
import org.eclipse.swt.events.ModifyListener;
|
||||||
import org.eclipse.swt.events.SelectionAdapter;
|
import org.eclipse.swt.events.SelectionAdapter;
|
||||||
import org.eclipse.swt.events.SelectionEvent;
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
import org.eclipse.swt.graphics.GC;
|
import org.eclipse.swt.graphics.GC;
|
||||||
|
@ -77,6 +82,9 @@ public class PreferencePage extends org.eclipse.jface.preference.PreferencePage
|
||||||
/* default */ Combo workingDir;
|
/* default */ Combo workingDir;
|
||||||
private Button browseButton;
|
private Button browseButton;
|
||||||
|
|
||||||
|
private Button variablesButton;
|
||||||
|
private boolean hasVariablesButton = false;
|
||||||
|
|
||||||
/* default */ final List<Map<String, String>> executables = new ArrayList<Map<String, String>>();
|
/* default */ final List<Map<String, String>> executables = new ArrayList<Map<String, String>>();
|
||||||
/* default */ final Map<String, Image> images = new HashMap<String, Image>();
|
/* default */ final Map<String, Image> images = new HashMap<String, Image>();
|
||||||
|
|
||||||
|
@ -87,6 +95,10 @@ public class PreferencePage extends org.eclipse.jface.preference.PreferencePage
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void init(IWorkbench workbench) {
|
public void init(IWorkbench workbench) {
|
||||||
|
Bundle bundle = Platform.getBundle("org.eclipse.debug.ui"); //$NON-NLS-1$
|
||||||
|
if (bundle != null && bundle.getState() != Bundle.UNINSTALLED && bundle.getState() != Bundle.STOPPING) {
|
||||||
|
hasVariablesButton = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -108,23 +120,51 @@ public class PreferencePage extends org.eclipse.jface.preference.PreferencePage
|
||||||
|
|
||||||
Group group = new Group(panel, SWT.NONE);
|
Group group = new Group(panel, SWT.NONE);
|
||||||
group.setText(Messages.PreferencePage_workingDir_label);
|
group.setText(Messages.PreferencePage_workingDir_label);
|
||||||
group.setLayout(new GridLayout(2, false));
|
group.setLayout(new GridLayout(hasVariablesButton ? 3 : 2, false));
|
||||||
group.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
|
group.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
|
||||||
|
|
||||||
workingDir = new Combo(group, SWT.DROP_DOWN);
|
workingDir = new Combo(group, SWT.DROP_DOWN);
|
||||||
Bundle bundle = Platform.getBundle("org.eclipse.core.resources"); //$NON-NLS-1$
|
Bundle bundle = Platform.getBundle("org.eclipse.core.resources"); //$NON-NLS-1$
|
||||||
if (bundle != null && (bundle.getState() == Bundle.RESOLVED || bundle.getState() == Bundle.ACTIVE)) {
|
if (bundle != null && bundle.getState() != Bundle.UNINSTALLED && bundle.getState() != Bundle.STOPPING) {
|
||||||
workingDir.setItems(new String[] { Messages.PreferencePage_workingDir_userhome_label, Messages.PreferencePage_workingDir_eclipsehome_label, Messages.PreferencePage_workingDir_eclipsews_label });
|
workingDir.setItems(new String[] { Messages.PreferencePage_workingDir_userhome_label, Messages.PreferencePage_workingDir_eclipsehome_label, Messages.PreferencePage_workingDir_eclipsews_label });
|
||||||
} else {
|
} else {
|
||||||
workingDir.setItems(new String[] { Messages.PreferencePage_workingDir_userhome_label, Messages.PreferencePage_workingDir_eclipsehome_label });
|
workingDir.setItems(new String[] { Messages.PreferencePage_workingDir_userhome_label, Messages.PreferencePage_workingDir_eclipsehome_label });
|
||||||
}
|
}
|
||||||
workingDir.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
|
workingDir.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
|
||||||
workingDir.select(0);
|
workingDir.select(0);
|
||||||
|
workingDir.addModifyListener(new ModifyListener() {
|
||||||
|
@Override
|
||||||
|
public void modifyText(ModifyEvent e) {
|
||||||
|
boolean valid = true;
|
||||||
|
String message = null;
|
||||||
|
|
||||||
|
String text = workingDir.getText();
|
||||||
|
if (text != null && !"".equals(text.trim()) //$NON-NLS-1$
|
||||||
|
&& !Messages.PreferencePage_workingDir_userhome_label.equals(text)
|
||||||
|
&& !Messages.PreferencePage_workingDir_eclipsehome_label.equals(text)
|
||||||
|
&& !Messages.PreferencePage_workingDir_eclipsews_label.equals(text)) {
|
||||||
|
try {
|
||||||
|
// Resolve possible dynamic variables
|
||||||
|
IStringVariableManager vm = VariablesPlugin.getDefault().getStringVariableManager();
|
||||||
|
String resolved = vm.performStringSubstitution(text.trim());
|
||||||
|
|
||||||
|
IPath p = new Path(resolved);
|
||||||
|
valid = p.toFile().canRead() && p.toFile().isDirectory();
|
||||||
|
} catch (CoreException ex) {
|
||||||
|
valid = false;
|
||||||
|
message = ex.getLocalizedMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setValid(valid);
|
||||||
|
setErrorMessage(message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
browseButton = new Button(group, SWT.PUSH);
|
browseButton = new Button(group, SWT.PUSH);
|
||||||
browseButton.setText(Messages.PreferencePage_workingDir_button_browse);
|
browseButton.setText(Messages.PreferencePage_workingDir_button_browse);
|
||||||
layoutData = new GridData(SWT.FILL, SWT.CENTER, false, false);
|
layoutData = new GridData(SWT.FILL, SWT.CENTER, false, false);
|
||||||
layoutData.widthHint = Dialog.convertWidthInCharsToPixels(gc.getFontMetrics(), 10);
|
layoutData.widthHint = Dialog.convertWidthInCharsToPixels(gc.getFontMetrics(), 14);
|
||||||
browseButton.setLayoutData(layoutData);
|
browseButton.setLayoutData(layoutData);
|
||||||
browseButton.addSelectionListener(new SelectionAdapter() {
|
browseButton.addSelectionListener(new SelectionAdapter() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -149,7 +189,7 @@ public class PreferencePage extends org.eclipse.jface.preference.PreferencePage
|
||||||
|
|
||||||
// ECLIPSE_WORKSPACE
|
// ECLIPSE_WORKSPACE
|
||||||
Bundle bundle = Platform.getBundle("org.eclipse.core.resources"); //$NON-NLS-1$
|
Bundle bundle = Platform.getBundle("org.eclipse.core.resources"); //$NON-NLS-1$
|
||||||
if (bundle != null && (bundle.getState() == Bundle.RESOLVED || bundle.getState() == Bundle.ACTIVE)) {
|
if (bundle != null && bundle.getState() != Bundle.UNINSTALLED && bundle.getState() != Bundle.STOPPING) {
|
||||||
if (org.eclipse.core.resources.ResourcesPlugin.getWorkspace() != null
|
if (org.eclipse.core.resources.ResourcesPlugin.getWorkspace() != null
|
||||||
&& org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot() != null
|
&& org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot() != null
|
||||||
&& org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot().getLocation() != null) {
|
&& org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot().getLocation() != null) {
|
||||||
|
@ -168,7 +208,16 @@ public class PreferencePage extends org.eclipse.jface.preference.PreferencePage
|
||||||
} else if (Messages.PreferencePage_workingDir_eclipsews_label.equals(text)) {
|
} else if (Messages.PreferencePage_workingDir_eclipsews_label.equals(text)) {
|
||||||
dialog.setFilterPath(ew.toOSString());
|
dialog.setFilterPath(ew.toOSString());
|
||||||
} else if (text != null && !"".equals(text.trim())) { //$NON-NLS-1$
|
} else if (text != null && !"".equals(text.trim())) { //$NON-NLS-1$
|
||||||
dialog.setFilterPath(text.trim());
|
try {
|
||||||
|
// Resolve possible dynamic variables
|
||||||
|
IStringVariableManager vm = VariablesPlugin.getDefault().getStringVariableManager();
|
||||||
|
String resolved = vm.performStringSubstitution(text.trim());
|
||||||
|
dialog.setFilterPath(resolved);
|
||||||
|
} catch (CoreException ex) {
|
||||||
|
if (Platform.inDebugMode()) {
|
||||||
|
UIPlugin.getDefault().getLog().log(ex.getStatus());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String selected = dialog.open();
|
String selected = dialog.open();
|
||||||
|
@ -188,12 +237,37 @@ public class PreferencePage extends org.eclipse.jface.preference.PreferencePage
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (hasVariablesButton) {
|
||||||
|
variablesButton = new Button(group, SWT.PUSH);
|
||||||
|
variablesButton.setText(Messages.PreferencePage_workingDir_button_variables);
|
||||||
|
layoutData = new GridData(SWT.FILL, SWT.CENTER, false, false);
|
||||||
|
layoutData.widthHint = Dialog.convertWidthInCharsToPixels(gc.getFontMetrics(), 14);
|
||||||
|
variablesButton.setLayoutData(layoutData);
|
||||||
|
variablesButton.addSelectionListener(new SelectionAdapter() {
|
||||||
|
@Override
|
||||||
|
public void widgetSelected(SelectionEvent e) {
|
||||||
|
org.eclipse.debug.ui.StringVariableSelectionDialog dialog = new org.eclipse.debug.ui.StringVariableSelectionDialog(getShell());
|
||||||
|
dialog.open();
|
||||||
|
String expression = dialog.getVariableExpression();
|
||||||
|
if (expression != null) {
|
||||||
|
if ("${eclipse_home}".equals(expression)) { //$NON-NLS-1$
|
||||||
|
workingDir.select(1);
|
||||||
|
} else if ("${workspace_loc}".equals(expression)) { //$NON-NLS-1$
|
||||||
|
workingDir.select(2);
|
||||||
|
} else {
|
||||||
|
workingDir.setText(expression);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
String initialCwd = UIPlugin.getScopedPreferences().getString(IPreferenceKeys.PREF_LOCAL_TERMINAL_INITIAL_CWD);
|
String initialCwd = UIPlugin.getScopedPreferences().getString(IPreferenceKeys.PREF_LOCAL_TERMINAL_INITIAL_CWD);
|
||||||
if (initialCwd == null || IPreferenceKeys.PREF_INITIAL_CWD_USER_HOME.equals(initialCwd) || "".equals(initialCwd.trim())) { //$NON-NLS-1$
|
if (initialCwd == null || IPreferenceKeys.PREF_INITIAL_CWD_USER_HOME.equals(initialCwd) || "".equals(initialCwd.trim())) { //$NON-NLS-1$
|
||||||
workingDir.select(0);
|
workingDir.select(0);
|
||||||
} else if (IPreferenceKeys.PREF_INITIAL_CWD_ECLIPSE_HOME.equals(initialCwd)) {
|
} else if (IPreferenceKeys.PREF_INITIAL_CWD_ECLIPSE_HOME.equals(initialCwd) || "${eclipse_home}".equals(initialCwd)) { //$NON-NLS-1$
|
||||||
workingDir.select(1);
|
workingDir.select(1);
|
||||||
} else if (IPreferenceKeys.PREF_INITIAL_CWD_ECLIPSE_WS.equals(initialCwd)) {
|
} else if (IPreferenceKeys.PREF_INITIAL_CWD_ECLIPSE_WS.equals(initialCwd) || "${workspace_loc}".equals(initialCwd)) { //$NON-NLS-1$
|
||||||
workingDir.select(2);
|
workingDir.select(2);
|
||||||
} else {
|
} else {
|
||||||
workingDir.setText(new Path(initialCwd).toOSString());
|
workingDir.setText(new Path(initialCwd).toOSString());
|
||||||
|
@ -438,9 +512,9 @@ public class PreferencePage extends org.eclipse.jface.preference.PreferencePage
|
||||||
String initialCwd = UIPlugin.getScopedPreferences().getDefaultString(IPreferenceKeys.PREF_LOCAL_TERMINAL_INITIAL_CWD);
|
String initialCwd = UIPlugin.getScopedPreferences().getDefaultString(IPreferenceKeys.PREF_LOCAL_TERMINAL_INITIAL_CWD);
|
||||||
if (initialCwd == null || IPreferenceKeys.PREF_INITIAL_CWD_USER_HOME.equals(initialCwd) || "".equals(initialCwd.trim())) { //$NON-NLS-1$
|
if (initialCwd == null || IPreferenceKeys.PREF_INITIAL_CWD_USER_HOME.equals(initialCwd) || "".equals(initialCwd.trim())) { //$NON-NLS-1$
|
||||||
workingDir.select(0);
|
workingDir.select(0);
|
||||||
} else if (IPreferenceKeys.PREF_INITIAL_CWD_ECLIPSE_HOME.equals(initialCwd)) {
|
} else if (IPreferenceKeys.PREF_INITIAL_CWD_ECLIPSE_HOME.equals(initialCwd) || "${eclipse_home}".equals(initialCwd)) { //$NON-NLS-1$
|
||||||
workingDir.select(1);
|
workingDir.select(1);
|
||||||
} else if (IPreferenceKeys.PREF_INITIAL_CWD_ECLIPSE_WS.equals(initialCwd)) {
|
} else if (IPreferenceKeys.PREF_INITIAL_CWD_ECLIPSE_WS.equals(initialCwd) || "${workspace_loc}".equals(initialCwd)) { //$NON-NLS-1$
|
||||||
workingDir.select(2);
|
workingDir.select(2);
|
||||||
} else {
|
} else {
|
||||||
workingDir.setText(new Path(initialCwd).toOSString());
|
workingDir.setText(new Path(initialCwd).toOSString());
|
||||||
|
@ -467,8 +541,18 @@ public class PreferencePage extends org.eclipse.jface.preference.PreferencePage
|
||||||
} else if (Messages.PreferencePage_workingDir_eclipsews_label.equals(text)) {
|
} else if (Messages.PreferencePage_workingDir_eclipsews_label.equals(text)) {
|
||||||
UIPlugin.getScopedPreferences().putString(IPreferenceKeys.PREF_LOCAL_TERMINAL_INITIAL_CWD, IPreferenceKeys.PREF_INITIAL_CWD_ECLIPSE_WS);
|
UIPlugin.getScopedPreferences().putString(IPreferenceKeys.PREF_LOCAL_TERMINAL_INITIAL_CWD, IPreferenceKeys.PREF_INITIAL_CWD_ECLIPSE_WS);
|
||||||
} else {
|
} else {
|
||||||
IPath p = new Path(text.trim());
|
try {
|
||||||
UIPlugin.getScopedPreferences().putString(IPreferenceKeys.PREF_LOCAL_TERMINAL_INITIAL_CWD, p.toFile().canRead() && p.toFile().isDirectory() ? p.toString() : null);
|
// Resolve possible dynamic variables
|
||||||
|
IStringVariableManager vm = VariablesPlugin.getDefault().getStringVariableManager();
|
||||||
|
String resolved = vm.performStringSubstitution(text.trim());
|
||||||
|
|
||||||
|
IPath p = new Path(resolved);
|
||||||
|
UIPlugin.getScopedPreferences().putString(IPreferenceKeys.PREF_LOCAL_TERMINAL_INITIAL_CWD, p.toFile().canRead() && p.toFile().isDirectory() ? text.trim() : null);
|
||||||
|
} catch (CoreException e) {
|
||||||
|
if (Platform.inDebugMode()) {
|
||||||
|
UIPlugin.getDefault().getLog().log(e.getStatus());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ExternalExecutablesManager.save(executables);
|
ExternalExecutablesManager.save(executables);
|
||||||
|
|
|
@ -149,7 +149,7 @@ public class ProcessSettingsPage extends AbstractSettingsPage {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Bundle bundle = Platform.getBundle("org.eclipse.core.resources"); //$NON-NLS-1$
|
Bundle bundle = Platform.getBundle("org.eclipse.core.resources"); //$NON-NLS-1$
|
||||||
if (bundle != null && (bundle.getState() == Bundle.RESOLVED || bundle.getState() == Bundle.ACTIVE)) {
|
if (bundle != null && bundle.getState() != Bundle.UNINSTALLED && bundle.getState() != Bundle.STOPPING) {
|
||||||
dialog.setFilterPath(org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString());
|
dialog.setFilterPath(org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -562,7 +562,7 @@ public abstract class AbstractExtendedConfigurationPanel extends AbstractConfigu
|
||||||
private String getResourceEncoding() {
|
private String getResourceEncoding() {
|
||||||
String preference = null;
|
String preference = null;
|
||||||
Bundle bundle = Platform.getBundle("org.eclipse.core.resources"); //$NON-NLS-1$
|
Bundle bundle = Platform.getBundle("org.eclipse.core.resources"); //$NON-NLS-1$
|
||||||
if (bundle != null && (bundle.getState() == Bundle.RESOLVED || bundle.getState() == Bundle.ACTIVE)) {
|
if (bundle != null && bundle.getState() != Bundle.UNINSTALLED && bundle.getState() != Bundle.STOPPING) {
|
||||||
preference = org.eclipse.core.resources.ResourcesPlugin.getPlugin().getPluginPreferences().getString(org.eclipse.core.resources.ResourcesPlugin.PREF_ENCODING);
|
preference = org.eclipse.core.resources.ResourcesPlugin.getPlugin().getPluginPreferences().getString(org.eclipse.core.resources.ResourcesPlugin.PREF_ENCODING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -662,7 +662,7 @@ public class TerminalsView extends ViewPart implements ITerminalsView, IShowInTa
|
||||||
Object adapted = null;
|
Object adapted = null;
|
||||||
|
|
||||||
Bundle bundle = Platform.getBundle("org.eclipse.core.resources"); //$NON-NLS-1$
|
Bundle bundle = Platform.getBundle("org.eclipse.core.resources"); //$NON-NLS-1$
|
||||||
if (bundle != null && (bundle.getState() == Bundle.RESOLVED || bundle.getState() == Bundle.ACTIVE)) {
|
if (bundle != null && bundle.getState() != Bundle.UNINSTALLED && bundle.getState() != Bundle.STOPPING) {
|
||||||
if (element instanceof org.eclipse.core.resources.IResource) continue;
|
if (element instanceof org.eclipse.core.resources.IResource) continue;
|
||||||
|
|
||||||
adapted = element instanceof IAdaptable ? ((IAdaptable)element).getAdapter(org.eclipse.core.resources.IResource.class) : null;
|
adapted = element instanceof IAdaptable ? ((IAdaptable)element).getAdapter(org.eclipse.core.resources.IResource.class) : null;
|
||||||
|
|
Loading…
Add table
Reference in a new issue