Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/plugin.xml7
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/activator/UIPlugin.java18
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/launcher/LocalLauncherDelegate.java41
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/nls/Messages.java9
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/nls/Messages.properties9
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/showin/interfaces/IPreferenceKeys.java40
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/showin/preferences/PreferencePage.java129
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/showin/preferences/PreferencesInitializer.java37
8 files changed, 280 insertions, 10 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/plugin.xml
index fc7fbbbd0..3d7e2f3ff 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/plugin.xml
@@ -117,6 +117,13 @@
</page>
</extension>
+<!-- Preferences contributions -->
+ <extension point="org.eclipse.core.runtime.preferences">
+ <initializer
+ class="org.eclipse.tcf.te.ui.terminals.local.showin.preferences.PreferencesInitializer">
+ </initializer>
+ </extension>
+
<!-- Startup contributions -->
<extension point="org.eclipse.ui.startup">
<startup class="org.eclipse.tcf.te.ui.terminals.local.showin.ExternalExecutablesInitializer"/>
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/activator/UIPlugin.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/activator/UIPlugin.java
index f1c1d8016..9013e8f32 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/activator/UIPlugin.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/activator/UIPlugin.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2013 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2012 - 2015 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
@@ -12,6 +12,7 @@ package org.eclipse.tcf.te.ui.terminals.local.activator;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.tcf.te.runtime.preferences.ScopedEclipsePreferences;
import org.eclipse.tcf.te.runtime.tracing.TraceHandler;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
@@ -22,7 +23,8 @@ import org.osgi.framework.BundleContext;
public class UIPlugin extends AbstractUIPlugin {
// The shared instance
private static UIPlugin plugin;
-
+ // The scoped preferences instance
+ private static volatile ScopedEclipsePreferences scopedPreferences;
// The trace handler instance
private static volatile TraceHandler traceHandler;
@@ -52,6 +54,16 @@ public class UIPlugin extends AbstractUIPlugin {
}
/**
+ * Return the scoped preferences for this plugin.
+ */
+ public static ScopedEclipsePreferences getScopedPreferences() {
+ if (scopedPreferences == null) {
+ scopedPreferences = new ScopedEclipsePreferences(getUniqueIdentifier());
+ }
+ return scopedPreferences;
+ }
+
+ /**
* Returns the bundles trace handler.
*
* @return The bundles trace handler.
@@ -78,6 +90,8 @@ public class UIPlugin extends AbstractUIPlugin {
@Override
public void stop(BundleContext context) throws Exception {
plugin = null;
+ scopedPreferences = null;
+ traceHandler = null;
super.stop(context);
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/launcher/LocalLauncherDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/launcher/LocalLauncherDelegate.java
index b5250fc0b..fb64f5a17 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/launcher/LocalLauncherDelegate.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/launcher/LocalLauncherDelegate.java
@@ -9,14 +9,19 @@
*******************************************************************************/
package org.eclipse.tcf.te.ui.terminals.local.launcher;
+import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.util.Iterator;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.URIUtil;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
@@ -29,7 +34,9 @@ import org.eclipse.tcf.te.ui.controls.BaseDialogPageControl;
import org.eclipse.tcf.te.ui.terminals.interfaces.IConfigurationPanel;
import org.eclipse.tcf.te.ui.terminals.interfaces.IMementoHandler;
import org.eclipse.tcf.te.ui.terminals.launcher.AbstractLauncherDelegate;
+import org.eclipse.tcf.te.ui.terminals.local.activator.UIPlugin;
import org.eclipse.tcf.te.ui.terminals.local.controls.LocalWizardConfigurationPanel;
+import org.eclipse.tcf.te.ui.terminals.local.showin.interfaces.IPreferenceKeys;
import org.eclipse.ui.ISelectionService;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.WorkbenchEncoding;
@@ -89,10 +96,36 @@ public class LocalLauncherDelegate extends AbstractLauncherDelegate {
properties.setProperty(ITerminalsConnectorConstants.PROP_FORCE_NEW, true);
}
- // Start the local terminal in the users home directory
- String home = System.getProperty("user.home"); //$NON-NLS-1$
- if (home != null && !"".equals(home)) { //$NON-NLS-1$
- properties.setProperty(ITerminalsConnectorConstants.PROP_PROCESS_WORKING_DIR, home);
+ // Initialize the local terminal working directory.
+ // By default, start the local terminal in the users home directory
+ String initialCwd = UIPlugin.getScopedPreferences().getString(IPreferenceKeys.PREF_LOCAL_TERMINAL_INITIAL_CWD);
+ String cwd = null;
+ if (initialCwd == null || IPreferenceKeys.PREF_INITIAL_CWD_USER_HOME.equals(initialCwd) || "".equals(initialCwd.trim())) { //$NON-NLS-1$
+ cwd = System.getProperty("user.home"); //$NON-NLS-1$
+ } else if (IPreferenceKeys.PREF_INITIAL_CWD_ECLIPSE_HOME.equals(initialCwd)) {
+ String eclipseHomeLocation = System.getProperty("eclipse.home.location"); //$NON-NLS-1$
+ if (eclipseHomeLocation != null) {
+ try {
+ URI uri = URIUtil.fromString(eclipseHomeLocation);
+ File f = URIUtil.toFile(uri);
+ cwd = f.getAbsolutePath();
+ } catch (URISyntaxException ex) { /* ignored on purpose */ }
+ }
+ } else if (IPreferenceKeys.PREF_INITIAL_CWD_ECLIPSE_WS.equals(initialCwd)) {
+ if (ResourcesPlugin.getWorkspace() != null
+ && ResourcesPlugin.getWorkspace().getRoot() != null
+ && ResourcesPlugin.getWorkspace().getRoot().getLocation() != null) {
+ cwd = ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString();
+ }
+ } else {
+ IPath p = new Path(initialCwd);
+ if (p.toFile().canRead() && p.toFile().isDirectory()) {
+ cwd = p.toOSString();
+ }
+ }
+
+ if (cwd != null && !"".equals(cwd)) { //$NON-NLS-1$
+ properties.setProperty(ITerminalsConnectorConstants.PROP_PROCESS_WORKING_DIR, cwd);
}
// If the current selection resolved to an folder, default the working directory
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/nls/Messages.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/nls/Messages.java
index 0461adb24..b86b7c04d 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/nls/Messages.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/nls/Messages.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2013 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011 - 2015 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
@@ -38,6 +38,13 @@ public class Messages extends NLS {
public static String PreferencePage_executables_button_add_label;
public static String PreferencePage_executables_button_edit_label;
public static String PreferencePage_executables_button_remove_label;
+ public static String PreferencePage_workingDir_label;
+ public static String PreferencePage_workingDir_userhome_label;
+ public static String PreferencePage_workingDir_eclipsehome_label;
+ public static String PreferencePage_workingDir_eclipsews_label;
+ public static String PreferencePage_workingDir_button_browse;
+ public static String PreferencePage_workingDir_note_label;
+ public static String PreferencePage_workingDir_note_text;
public static String ExternalExecutablesDialog_title_add;
public static String ExternalExecutablesDialog_title_edit;
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/nls/Messages.properties
index 93fab6d34..a48a0977c 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/nls/Messages.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/nls/Messages.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2012 - 2014 Wind River Systems, Inc. and others. All rights reserved.
+# Copyright (c) 2012 - 2015 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
@@ -37,3 +37,10 @@ PreferencePage_executables_column_path_label=Path
PreferencePage_executables_button_add_label=Add...
PreferencePage_executables_button_edit_label=Edit...
PreferencePage_executables_button_remove_label=Remove
+PreferencePage_workingDir_label=Local Terminal Initial Working Directory
+PreferencePage_workingDir_userhome_label=User home
+PreferencePage_workingDir_eclipsehome_label=Eclipse home
+PreferencePage_workingDir_eclipsews_label=Eclipse workspace
+PreferencePage_workingDir_button_browse=Browse...
+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.
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/showin/interfaces/IPreferenceKeys.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/showin/interfaces/IPreferenceKeys.java
new file mode 100644
index 000000000..6bf6c3444
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/showin/interfaces/IPreferenceKeys.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.ui.terminals.local.showin.interfaces;
+
+/**
+ * Terminals plug-in preference key definitions.
+ */
+public interface IPreferenceKeys {
+ /**
+ * Preference keys family prefix.
+ */
+ public final String PREF_TERMINAL = "terminals"; //$NON-NLS-1$
+
+ /**
+ * Preference key: Remove terminated terminals when a new terminal is created.
+ */
+ public final String PREF_LOCAL_TERMINAL_INITIAL_CWD = PREF_TERMINAL + ".localTerminalInitialCwd"; //$NON-NLS-1$
+
+ /**
+ * Preference value: Local terminal initial working directory is "User home"
+ */
+ public final String PREF_INITIAL_CWD_USER_HOME = "userhome"; //$NON-NLS-1$
+
+ /**
+ * Preference value: Local terminal initial working directory is "Eclipse home"
+ */
+ public final String PREF_INITIAL_CWD_ECLIPSE_HOME = "eclipsehome"; //$NON-NLS-1$
+
+ /**
+ * Preference value: Local terminal initial working directory is "Eclipse workspace"
+ */
+ public final String PREF_INITIAL_CWD_ECLIPSE_WS = "eclipsews"; //$NON-NLS-1$
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/showin/preferences/PreferencePage.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/showin/preferences/PreferencePage.java
index 6bb6e99b4..bc4e2f0d8 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/showin/preferences/PreferencePage.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/showin/preferences/PreferencePage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2014 - 2015 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
@@ -9,12 +9,19 @@
*******************************************************************************/
package org.eclipse.tcf.te.ui.terminals.local.showin.preferences;
+import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.URIUtil;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ColumnViewerToolTipSupport;
import org.eclipse.jface.viewers.ColumnWeightData;
@@ -37,17 +44,22 @@ import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.tcf.te.ui.swt.SWTControlUtil;
+import org.eclipse.tcf.te.ui.swt.widgets.NoteCompositeHelper;
+import org.eclipse.tcf.te.ui.terminals.local.activator.UIPlugin;
import org.eclipse.tcf.te.ui.terminals.local.nls.Messages;
import org.eclipse.tcf.te.ui.terminals.local.showin.ExternalExecutablesDialog;
import org.eclipse.tcf.te.ui.terminals.local.showin.ExternalExecutablesManager;
import org.eclipse.tcf.te.ui.terminals.local.showin.interfaces.IExternalExecutablesProperties;
+import org.eclipse.tcf.te.ui.terminals.local.showin.interfaces.IPreferenceKeys;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
@@ -59,6 +71,8 @@ public class PreferencePage extends org.eclipse.jface.preference.PreferencePage
private Button addButton;
private Button editButton;
private Button removeButton;
+ /* default */ Combo workingDir;
+ private Button browseButton;
/* default */ final List<Map<String, Object>> executables = new ArrayList<Map<String, Object>>();
/* default */ final Map<String, Image> images = new HashMap<String, Image>();
@@ -76,7 +90,7 @@ public class PreferencePage extends org.eclipse.jface.preference.PreferencePage
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
*/
@Override
- protected Control createContents(Composite parent) {
+ protected Control createContents(final Composite parent) {
Composite panel = new Composite(parent, SWT.NONE);
panel.setLayout(new GridLayout());
GridData layoutData = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
@@ -87,6 +101,93 @@ public class PreferencePage extends org.eclipse.jface.preference.PreferencePage
label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
Group group = new Group(panel, SWT.NONE);
+ group.setText(Messages.PreferencePage_workingDir_label);
+ group.setLayout(new GridLayout(2, false));
+ group.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
+
+ workingDir = new Combo(group, SWT.DROP_DOWN);
+ workingDir.setItems(new String[] { Messages.PreferencePage_workingDir_userhome_label, Messages.PreferencePage_workingDir_eclipsehome_label, Messages.PreferencePage_workingDir_eclipsews_label });
+ workingDir.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ workingDir.select(0);
+
+ browseButton = new Button(group, SWT.PUSH);
+ browseButton.setText(Messages.PreferencePage_workingDir_button_browse);
+ layoutData = new GridData(SWT.FILL, SWT.CENTER, false, false);
+ layoutData.widthHint = SWTControlUtil.convertWidthInCharsToPixels(browseButton, 10);
+ browseButton.setLayoutData(layoutData);
+ browseButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ IPath uh = null;
+ IPath eh = null;
+ IPath ew = null;
+
+ // HOME
+ String home = System.getProperty("user.home"); //$NON-NLS-1$
+ if (home != null && !"".equals(home)) uh = new Path(home); //$NON-NLS-1$
+
+ // ECLIPSE_HOME
+ String eclipseHomeLocation = System.getProperty("eclipse.home.location"); //$NON-NLS-1$
+ if (eclipseHomeLocation != null) {
+ try {
+ URI uri = URIUtil.fromString(eclipseHomeLocation);
+ File f = URIUtil.toFile(uri);
+ eh = new Path(f.getAbsolutePath());
+ } catch (URISyntaxException ex) { /* ignored on purpose */ }
+ }
+
+ // ECLIPSE_WORKSPACE
+ if (ResourcesPlugin.getWorkspace() != null
+ && ResourcesPlugin.getWorkspace().getRoot() != null
+ && ResourcesPlugin.getWorkspace().getRoot().getLocation() != null) {
+ ew = ResourcesPlugin.getWorkspace().getRoot().getLocation();
+ }
+
+ DirectoryDialog dialog = new DirectoryDialog(parent.getShell(), SWT.OPEN);
+
+ // Determine the filter path
+ String text = workingDir.getText();
+ if (Messages.PreferencePage_workingDir_userhome_label.equals(text)) {
+ dialog.setFilterPath(uh.toOSString());
+ } else if (Messages.PreferencePage_workingDir_eclipsehome_label.equals(text)) {
+ dialog.setFilterPath(eh.toOSString());
+ } else if (Messages.PreferencePage_workingDir_eclipsews_label.equals(text)) {
+ dialog.setFilterPath(ew.toOSString());
+ } else if (text != null && !"".equals(text.trim())) { //$NON-NLS-1$
+ dialog.setFilterPath(text.trim());
+ }
+
+ String selected = dialog.open();
+ if (selected != null) {
+ IPath sp = new Path(selected);
+
+ if (uh.equals(sp)) {
+ workingDir.select(0);
+ } else if (eh.equals(sp)) {
+ workingDir.select(1);
+ } else if (ew.equals(sp)) {
+ workingDir.select(2);
+ } else {
+ workingDir.setText(sp.toOSString());
+ }
+ }
+ }
+ });
+
+ 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$
+ workingDir.select(0);
+ } else if (IPreferenceKeys.PREF_INITIAL_CWD_ECLIPSE_HOME.equals(initialCwd)) {
+ workingDir.select(1);
+ } else if (IPreferenceKeys.PREF_INITIAL_CWD_ECLIPSE_WS.equals(initialCwd)) {
+ workingDir.select(2);
+ } else {
+ workingDir.setText(new Path(initialCwd).toOSString());
+ }
+
+ NoteCompositeHelper.createNoteComposite(group.getFont(), group, Messages.PreferencePage_workingDir_note_label, Messages.PreferencePage_workingDir_note_text);
+
+ group = new Group(panel, SWT.NONE);
group.setText(Messages.PreferencePage_executables_label);
group.setLayout(new GridLayout(2, false));
group.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
@@ -318,6 +419,17 @@ public class PreferencePage extends org.eclipse.jface.preference.PreferencePage
*/
@Override
protected void performDefaults() {
+ 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$
+ workingDir.select(0);
+ } else if (IPreferenceKeys.PREF_INITIAL_CWD_ECLIPSE_HOME.equals(initialCwd)) {
+ workingDir.select(1);
+ } else if (IPreferenceKeys.PREF_INITIAL_CWD_ECLIPSE_WS.equals(initialCwd)) {
+ workingDir.select(2);
+ } else {
+ workingDir.setText(new Path(initialCwd).toOSString());
+ }
+
executables.clear();
List<Map<String, Object>> l = ExternalExecutablesManager.load();
if (l != null) executables.addAll(l);
@@ -331,7 +443,20 @@ public class PreferencePage extends org.eclipse.jface.preference.PreferencePage
*/
@Override
public boolean performOk() {
+ String text = workingDir.getText();
+ if (text == null || Messages.PreferencePage_workingDir_userhome_label.equals(text) || "".equals(text.trim())) { //$NON-NLS-1$
+ UIPlugin.getScopedPreferences().putString(IPreferenceKeys.PREF_LOCAL_TERMINAL_INITIAL_CWD, null);
+ } else if (Messages.PreferencePage_workingDir_eclipsehome_label.equals(text)) {
+ UIPlugin.getScopedPreferences().putString(IPreferenceKeys.PREF_LOCAL_TERMINAL_INITIAL_CWD, IPreferenceKeys.PREF_INITIAL_CWD_ECLIPSE_HOME);
+ } else if (Messages.PreferencePage_workingDir_eclipsews_label.equals(text)) {
+ UIPlugin.getScopedPreferences().putString(IPreferenceKeys.PREF_LOCAL_TERMINAL_INITIAL_CWD, IPreferenceKeys.PREF_INITIAL_CWD_ECLIPSE_WS);
+ } else {
+ IPath p = new Path(text.trim());
+ UIPlugin.getScopedPreferences().putString(IPreferenceKeys.PREF_LOCAL_TERMINAL_INITIAL_CWD, p.toFile().canRead() && p.toFile().isDirectory() ? p.toString() : null);
+ }
+
ExternalExecutablesManager.save(executables);
+
return super.performOk();
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/showin/preferences/PreferencesInitializer.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/showin/preferences/PreferencesInitializer.java
new file mode 100644
index 000000000..b5729bc4e
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/showin/preferences/PreferencesInitializer.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.ui.terminals.local.showin.preferences;
+
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.tcf.te.runtime.preferences.ScopedEclipsePreferences;
+import org.eclipse.tcf.te.ui.terminals.local.activator.UIPlugin;
+import org.eclipse.tcf.te.ui.terminals.local.showin.interfaces.IPreferenceKeys;
+
+/**
+ * Terminals default preferences initializer.
+ */
+public class PreferencesInitializer extends AbstractPreferenceInitializer {
+
+ /**
+ * Constructor.
+ */
+ public PreferencesInitializer() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
+ */
+ @Override
+ public void initializeDefaultPreferences() {
+ ScopedEclipsePreferences prefs = UIPlugin.getScopedPreferences();
+
+ prefs.putDefaultString(IPreferenceKeys.PREF_LOCAL_TERMINAL_INITIAL_CWD, IPreferenceKeys.PREF_INITIAL_CWD_USER_HOME);
+ }
+}

Back to the top