Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion debug/org.eclipse.ui.console/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 <b>not true</b>
* 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 <b>true</b> 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);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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() {
}
}
Original file line number Diff line number Diff line change
@@ -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