diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/ConsolePreferencePage.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/ConsolePreferencePage.java
index 91ac6956fc5..0c70b990cf5 100644
--- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/ConsolePreferencePage.java
+++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/ConsolePreferencePage.java
@@ -177,6 +177,10 @@ public void widgetSelected(SelectionEvent e) {
addField(new BooleanFieldEditor(IDebugPreferenceConstants.CONSOLE_OPEN_ON_OUT, DebugPreferencesMessages.ConsolePreferencePage_Show__Console_View_when_there_is_program_output_3, SWT.NONE, getFieldEditorParent()));
addField(new BooleanFieldEditor(IDebugPreferenceConstants.CONSOLE_OPEN_ON_ERR, DebugPreferencesMessages.ConsolePreferencePage_Show__Console_View_when_there_is_program_error_3, SWT.NONE, getFieldEditorParent()));
+ BooleanFieldEditor editor = new BooleanFieldEditor(IConsoleConstants.AUTO_PIN_ENABLED_PREF_NAME,
+ DebugPreferencesMessages.ConsolePreferencePage_ConsoleAutoPinEnable, SWT.NONE, getFieldEditorParent());
+ editor.setPreferenceStore(ConsolePlugin.getDefault().getPreferenceStore());
+ addField(editor);
Label comboLabel = new Label(getFieldEditorParent(), SWT.NONE);
comboLabel.setText(DebugPreferencesMessages.ConsoleElapsedTimeLabel);
fElapsedFormat = new ComboViewer(getFieldEditorParent(), SWT.DROP_DOWN | SWT.BORDER);
diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.java
index d1213fa11cb..cf401c4152e 100644
--- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.java
+++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.java
@@ -31,6 +31,8 @@ public class DebugPreferencesMessages extends NLS {
public static String ConsolePreferencePage_Console_width;
public static String ConsolePreferencePage_Limit_console_output_1;
public static String ConsolePreferencePage_Console_buffer_size__characters___2;
+
+ public static String ConsolePreferencePage_ConsoleAutoPinEnable;
public static String ConsolePreferencePage_The_console_buffer_size_must_be_at_least_1000_characters__1;
public static String ConsolePreferencePage_console_width;
public static String ConsolePreferencePage_12;
diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.properties b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.properties
index 78819ff3c93..b59d20bbbab 100644
--- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.properties
+++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.properties
@@ -23,6 +23,7 @@ ConsolePreferencePage_Wrap_text_1=Fixed &width console
ConsolePreferencePage_Console_width=&Maximum character width:
ConsolePreferencePage_Limit_console_output_1=&Limit console output
ConsolePreferencePage_Console_buffer_size__characters___2=Console &buffer size (characters):
+ConsolePreferencePage_ConsoleAutoPinEnable=Auto pin current console view, if new console is opened
ConsolePreferencePage_The_console_buffer_size_must_be_at_least_1000_characters__1=Buffer size must be between 1000 and {0} inclusive.
ConsolePreferencePage_console_width=Character width must be between 80 and 1000 inclusive.
ConsolePreferencePage_12=Displayed &tab width:
diff --git a/debug/org.eclipse.ui.console/META-INF/MANIFEST.MF b/debug/org.eclipse.ui.console/META-INF/MANIFEST.MF
index 77a7668e488..532662eaff8 100644
--- a/debug/org.eclipse.ui.console/META-INF/MANIFEST.MF
+++ b/debug/org.eclipse.ui.console/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.ui.console; singleton:=true
-Bundle-Version: 3.14.400.qualifier
+Bundle-Version: 3.15.0.qualifier
Bundle-Activator: org.eclipse.ui.console.ConsolePlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
diff --git a/debug/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleConstants.java b/debug/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleConstants.java
index 8c0a61a59cd..1bddaf6d6a6 100644
--- a/debug/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleConstants.java
+++ b/debug/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleConstants.java
@@ -163,6 +163,21 @@ public interface IConsoleConstants {
*/
String P_CONSOLE_WORD_WRAP = ConsolePlugin.getUniqueIdentifier() + ".P_CONSOLE_WORD_WRAP"; //$NON-NLS-1$
+ /**
+ * The preference name for the auto pin question to avoid that opening for every
+ * new console opening.
+ *
+ * @since 3.15
+ */
+ String REMEMBER_AUTO_PIN_DECISION_PREF_NAME = ConsolePlugin.getUniqueIdentifier() + ".AUTO_PIN_ASKED"; //$NON-NLS-1$
+
+ /**
+ * The preference name for the auto pin.
+ *
+ * @since 3.15
+ */
+ String AUTO_PIN_ENABLED_PREF_NAME = ConsolePlugin.getUniqueIdentifier() + ".AUTO_PIN_ENABLED"; //$NON-NLS-1$
+
/**
* The default tab size for text consoles.
*
diff --git a/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleViewConsoleFactory.java b/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleViewConsoleFactory.java
index 6330831e19d..96a46f1c1f9 100644
--- a/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleViewConsoleFactory.java
+++ b/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleViewConsoleFactory.java
@@ -13,6 +13,11 @@
*******************************************************************************/
package org.eclipse.ui.internal.console;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialogWithToggle;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
@@ -28,17 +33,54 @@ public class ConsoleViewConsoleFactory implements IConsoleFactory {
@Override
public void openConsole() {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (window != null) {
- IWorkbenchPage page = window.getActivePage();
- if (page != null) {
- try {
- String secondaryId = "Console View #" + counter; //$NON-NLS-1$
- page.showView(IConsoleConstants.ID_CONSOLE_VIEW, secondaryId, 1);
- counter++;
- } catch (PartInitException e) {
- ConsolePlugin.log(e);
- }
- }
+ if (window == null) {
+ return;
+ }
+ IWorkbenchPage page = window.getActivePage();
+ if (page == null) {
+ return;
+ }
+ handleAutoPin(page);
+ try {
+ String secondaryId = "Console View #" + counter; //$NON-NLS-1$
+ page.showView(IConsoleConstants.ID_CONSOLE_VIEW, secondaryId, 1);
+ counter++;
+ } catch (PartInitException e) {
+ ConsolePlugin.log(e);
+ }
+ }
+
+ /**
+ * This handler checks if the remember auto-pin decision state not true
+ * and asks the user if auto pin of the view content should be enabled.
+ * Afterwards it checks if remember auto-pin decision was checked and sets the
+ * preference according to that
+ *
+ * If the remember auto-pin decision state is true it gathers the auto
+ * pin preference value and sets this to the current view.
+ *
+ * @param page the active page
+ * @since 3.14
+ */
+ private void handleAutoPin(IWorkbenchPage page) {
+ IPreferenceStore store = ConsolePlugin.getDefault().getPreferenceStore();
+ if (!store.getBoolean(IConsoleConstants.REMEMBER_AUTO_PIN_DECISION_PREF_NAME)) {
+ Shell shell = Display.getDefault().getActiveShell();
+ MessageDialogWithToggle toggleDialog = MessageDialogWithToggle.openYesNoQuestion(shell,
+ Messages.ConsoleViewConsoleFactory_TurnOnAutoPinDialogTitle,
+ Messages.ConsoleViewConsoleFactory_TurnOnAutoPinDialogMessage,
+ Messages.ConsoleViewConsoleFactory_TurnOnAutoPinRememberDecision, false, null, null);
+
+ store.setValue(IConsoleConstants.AUTO_PIN_ENABLED_PREF_NAME,
+ toggleDialog.getReturnCode() == IDialogConstants.YES_ID);
+
+ store.setValue(IConsoleConstants.REMEMBER_AUTO_PIN_DECISION_PREF_NAME, toggleDialog.getToggleState());
+ }
+
+ if (store.getBoolean(IConsoleConstants.AUTO_PIN_ENABLED_PREF_NAME)
+ && page.getActivePart() instanceof ConsoleView currentConsoleView) {
+ // To avoid if pinned manually and unpin due to preference..
+ currentConsoleView.setPinned(true);
}
}
diff --git a/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/Messages.java b/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/Messages.java
new file mode 100644
index 00000000000..01d04679877
--- /dev/null
+++ b/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/Messages.java
@@ -0,0 +1,37 @@
+package org.eclipse.ui.internal.console;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * @since 3.14
+ */
+public class Messages extends NLS {
+
+ /**
+ * @since 3.14
+ */
+ private static final String BUNDLE_NAME = Messages.class.getPackageName() + ".messages"; //$NON-NLS-1$
+
+ /**
+ * @since 3.14
+ */
+ public static String ConsoleViewConsoleFactory_TurnOnAutoPinDialogMessage;
+
+ /**
+ * @since 3.14
+ */
+ public static String ConsoleViewConsoleFactory_TurnOnAutoPinDialogTitle;
+
+ /**
+ * @since 3.14
+ */
+ public static String ConsoleViewConsoleFactory_TurnOnAutoPinRememberDecision;
+
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/messages.properties b/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/messages.properties
new file mode 100644
index 00000000000..7d7a80b46a4
--- /dev/null
+++ b/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/messages.properties
@@ -0,0 +1,3 @@
+ConsoleViewConsoleFactory_TurnOnAutoPinDialogMessage=If a new console is opened, it's possible to auto pin the old console view to keep its content. Would you like to turn on the auto pin?
+ConsoleViewConsoleFactory_TurnOnAutoPinDialogTitle=Enable auto pin
+ConsoleViewConsoleFactory_TurnOnAutoPinRememberDecision=Remember my decision