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 autoPinEditor = new BooleanFieldEditor(IConsoleConstants.AUTO_PIN_ENABLED_PREF_NAME,
DebugPreferencesMessages.ConsolePreferencePage_ConsoleAutoPinEnable, SWT.NONE, getFieldEditorParent());
autoPinEditor.setPreferenceStore(ConsolePlugin.getDefault().getPreferenceStore());
addField(autoPinEditor);
Label comboLabel = new Label(getFieldEditorParent(), SWT.NONE);
comboLabel.setText(DebugPreferencesMessages.ConsoleElapsedTimeLabel);
fElapsedFormat = new ComboViewer(getFieldEditorParent(), SWT.DROP_DOWN | SWT.BORDER);
Expand Down Expand Up @@ -324,6 +328,9 @@ protected void performDefaults() {
updateBufferSizeEditor();
updateInterpretCrAsControlCharacterEditor();
updateElapsedTimePreferences();

IPreferenceStore prefStore = ConsolePlugin.getDefault().getPreferenceStore();
prefStore.setValue(IConsoleConstants.REMEMBER_AUTO_PIN_DECISION_PREF_NAME, false);
}

protected boolean canClearErrorMessage() {
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=Pin current and the new Console views when a new Console view 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,22 @@ 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 automatically pinning current Console view when
* opening a new Console view.
*
* @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 @@ -33,6 +33,10 @@ public class ConsoleMessages extends NLS {
public static String PinConsoleAction_0;
public static String PinConsoleAction_1;

public static String TurnOnAutoPinDialogMessage;
public static String TurnOnAutoPinDialogTitle;
public static String TurnOnAutoPinRememberDecision;

public static String ClearOutputAction_title;
public static String ClearOutputAction_toolTipText;

Expand Down Expand Up @@ -63,6 +67,7 @@ public class ConsoleMessages extends NLS {
public static String TextConsolePage_PasteText;
public static String TextConsolePage_PasteDescrip;


static {
// load message values from bundle file
NLS.initializeMessages(BUNDLE_NAME, ConsoleMessages.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,7 @@ TextConsolePage_PasteDescrip=Paste
PatternMatchListenerExtension_3=Console Pattern Match Listener
PatternMatchListenerExtension_4=contributed by
PatternMatchListenerExtension_5=is missing required enablement expression and will be removed
UpdatingConsoleState=Updating console state
UpdatingConsoleState=Updating console state
TurnOnAutoPinDialogMessage=If a new Console view is opened, it's possible to auto pin the old Console view and new Console view to keep its content. Should we pin the old and new Console views (so different console pages could be updated independently)?
TurnOnAutoPinDialogTitle=Enable auto pin
TurnOnAutoPinRememberDecision=Remember my decision
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public void initializeDefaultPreferences() {
IPreferenceStore prefs = ConsolePlugin.getDefault().getPreferenceStore();
prefs.setDefault(IConsoleConstants.P_CONSOLE_AUTO_SCROLL_LOCK, true);
prefs.setDefault(IConsoleConstants.P_CONSOLE_WORD_WRAP, false);
prefs.setDefault(IConsoleConstants.AUTO_PIN_ENABLED_PREF_NAME, false);
prefs.setDefault(IConsoleConstants.REMEMBER_AUTO_PIN_DECISION_PREF_NAME, false);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ protected void createActions() {
fDisplayConsoleAction = new ConsoleDropDownAction(this);
ConsoleFactoryExtension[] extensions = ((ConsoleManager)ConsolePlugin.getDefault().getConsoleManager()).getConsoleFactoryExtensions();
if (extensions.length > 0) {
fOpenConsoleAction = new OpenConsoleAction();
fOpenConsoleAction = new OpenConsoleAction(this);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
*******************************************************************************/
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.IViewPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
Expand All @@ -24,22 +30,70 @@
public class ConsoleViewConsoleFactory implements IConsoleFactory {

int counter = 1;
private ConsoleView currentConsoleView;

@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;
}
boolean shouldPin = handleAutoPin();
try {
String secondaryId = "Console View #" + counter; //$NON-NLS-1$
IViewPart view = page.showView(IConsoleConstants.ID_CONSOLE_VIEW, secondaryId, 1);
if (view instanceof ConsoleView newConsoleView) {
newConsoleView.setPinned(shouldPin);
}
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.
*/
private boolean handleAutoPin() {
if (currentConsoleView == null) {
return false;
}
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,
ConsoleMessages.TurnOnAutoPinDialogTitle, ConsoleMessages.TurnOnAutoPinDialogMessage,
ConsoleMessages.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)) {
// To avoid if pinned manually and unpin due to preference..
currentConsoleView.setPinned(true);
return true;
}
return false;
}

/**
* Sets the console view, on which the open new console action was called.
*/
void setConsoleView(ConsoleView consoleView) {
this.currentConsoleView = consoleView;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,14 @@ public class OpenConsoleAction extends Action implements IMenuCreator {

private ConsoleFactoryExtension[] fFactoryExtensions;
private Menu fMenu;
private ConsoleView consoleView;

public OpenConsoleAction() {
/**
* @param consoleView the view which this action belongs to.
*/
public OpenConsoleAction(ConsoleView consoleView) {
super(ConsoleMessages.OpenConsoleAction_0, AS_DROP_DOWN_MENU);
this.consoleView = consoleView;
fFactoryExtensions = getSortedFactories();
setToolTipText(ConsoleMessages.OpenConsoleAction_1);
setImageDescriptor(ConsolePluginImages.getImageDescriptor(IInternalConsoleConstants.IMG_ELCL_NEW_CON));
Expand All @@ -66,6 +71,7 @@ private ConsoleFactoryExtension[] getSortedFactories() {

@Override
public void dispose() {
consoleView = null;
fFactoryExtensions = null;
if (fMenu != null) {
fMenu.dispose();
Expand Down Expand Up @@ -98,7 +104,7 @@ public Menu getMenu(Control parent) {
if (!WorkbenchActivityHelper.filterItem(extension) && extension.isEnabled()) {
String label = extension.getLabel();
ImageDescriptor image = extension.getImageDescriptor();
addActionToMenu(fMenu, new ConsoleFactoryAction(label, image, extension), accel);
addActionToMenu(fMenu, new ConsoleFactoryAction(label, image, extension, consoleView), accel);
accel++;
if (extension.isNewConsoleExtenson()) {
new Separator("new").fill(fMenu, -1); //$NON-NLS-1$
Expand Down Expand Up @@ -128,17 +134,20 @@ public Menu getMenu(Menu parent) {
return null;
}

private class ConsoleFactoryAction extends Action {
private static class ConsoleFactoryAction extends Action {

private final ConsoleView fConsoleView;
private final ConsoleFactoryExtension fConfig;
private IConsoleFactory fFactory;

public ConsoleFactoryAction(String label, ImageDescriptor image, ConsoleFactoryExtension extension) {
public ConsoleFactoryAction(String label, ImageDescriptor image, ConsoleFactoryExtension extension,
ConsoleView consoleView) {
setText(label);
if (image != null) {
setImageDescriptor(image);
}
fConfig = extension;
this.fConsoleView = consoleView;
}

@Override
Expand All @@ -147,7 +156,9 @@ public void run() {
if (fFactory == null) {
fFactory = fConfig.createFactory();
}

if (fFactory instanceof ConsoleViewConsoleFactory consViewConsFactory) {
consViewConsFactory.setConsoleView(fConsoleView);
}
fFactory.openConsole();
} catch (CoreException e) {
ConsolePlugin.log(e);
Expand Down
Loading