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 @@ -154,4 +154,9 @@ public static String getString(String key) {
public static String RenameTerminalAction_inputdialog_title;
public static String RenameTerminalAction_tooltip;
public static String RenameTerminalAction_menu;

public static String MaximizeViewHandler_maximize;
public static String MaximizeViewHandler_maximizeTooltip;
public static String MaximizeViewHandler_minimize;
public static String MaximizeViewHandler_minimizeTooltip;
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,8 @@ PreferencePage_command_invalid=Selected shell command is not a file or is not re
PreferencePage_command_note_label=Note:
PreferencePage_command_note_text=Leave the shell command empty to fallback to the SHELL environment variable or if not set, to /bin/sh.
PreferencePage_command_arguments_label=Arguments:

MaximizeViewHandler_maximize=Maximize View
MaximizeViewHandler_maximizeTooltip=Maximize the Terminal view
MaximizeViewHandler_minimize=Minimize View
MaximizeViewHandler_minimizeTooltip=Restore the Terminal view to its normal size
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2014, 2018 Wind River Systems, Inc. and others. All rights reserved.
* Copyright (c) 2014, 2026 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 2.0 which accompanies this distribution, and is
* available at https://www.eclipse.org/legal/epl-2.0/
Expand All @@ -8,21 +8,62 @@
*
* Contributors:
* Wind River Systems - initial API and implementation
* IBM Corporation - Update label for window state
*******************************************************************************/
package org.eclipse.terminal.view.ui.internal.handler;

import java.util.Map;

import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.terminal.view.ui.internal.Messages;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPartReference;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.IElementUpdater;
import org.eclipse.ui.menus.UIElement;

/**
* Maximize view handler implementation.
*/
public class MaximizeViewHandler extends AbstractTriggerCommandHandler {
public class MaximizeViewHandler extends AbstractTriggerCommandHandler implements IElementUpdater {

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
triggerCommand("org.eclipse.ui.window.maximizePart", null); //$NON-NLS-1$
return null;
}

@SuppressWarnings("rawtypes")
@Override
public void updateElement(UIElement element, Map parameters) {
if (isActivePartMaximized()) {
element.setText(Messages.MaximizeViewHandler_minimize);
element.setTooltip(Messages.MaximizeViewHandler_minimizeTooltip);
} else {
element.setText(Messages.MaximizeViewHandler_maximize);
element.setTooltip(Messages.MaximizeViewHandler_maximizeTooltip);
}
}

/**
* Returns {@code true} when the currently active part in the active workbench
* page is in the {@link IWorkbenchPage#STATE_MAXIMIZED} state.
*/
private static boolean isActivePartMaximized() {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return false;
}
IWorkbenchPage page = window.getActivePage();
if (page == null) {
return false;
}
IWorkbenchPartReference partRef = page.getActivePartReference();
if (partRef == null) {
return false;
}
return page.getPartState(partRef) == IWorkbenchPage.STATE_MAXIMIZED;
}
}
Loading