Skip to content
Merged
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 @@ -8,7 +8,6 @@ Bundle-Activator: com.tlcsdm.eclipse.fullscreen.Activator
Bundle-Vendor: %providerName
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime
Eclipse-LazyStart: true
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: JavaSE-17
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
Expand Down Expand Up @@ -96,7 +94,7 @@ public void setFullScreen(Shell mainShell, boolean fullScreen) {
controlLists.remove(mainShell);
Menu menuBar = mainShell.getMenuBar();
if (menuBar == null) {
menuBar = (Menu) menuBars.get(mainShell);
menuBar = menuBars.get(mainShell);
mainShell.setMenuBar(menuBar);
menuBars.remove(mainShell);
}
Expand All @@ -109,8 +107,7 @@ public void setFullScreen(Shell mainShell, boolean fullScreen) {
private void showTrimControls(Shell mainShell) {
List<Control> controls = controlLists.get(mainShell);
if (controls != null) {
for (int i = 0; i < controls.size(); i++) {
Control control = (Control) controls.get(i);
for (Control control : controls) {
control.setVisible(true);
}
}
Expand All @@ -119,8 +116,7 @@ private void showTrimControls(Shell mainShell) {
private List<Control> hideTrimControls(Shell mainShell) {
List<Control> controls = new ArrayList<>();
Control[] children = mainShell.getChildren();
for (int i = 0; i < children.length; i++) {
Control child = children[i];
for (Control child : children) {
if (child.isDisposed() || !child.isVisible()) {
continue;
}
Expand Down Expand Up @@ -174,23 +170,19 @@ private boolean getDisableEclipseFullscreen() {
}

private Preferences preferences() {
Preferences preferences = Platform.getPreferencesService().getRootNode().node(InstanceScope.SCOPE).node(ID);
return preferences;
return Platform.getPreferencesService().getRootNode().node(InstanceScope.SCOPE).node(ID);
}

public void earlyStartup() {
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
store.addPropertyChangeListener(new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
String changedProperty = event.getProperty();
if (DISABLE_ECLIPSE_FULLSCREEN.equals(changedProperty)) {
boolean disabled = store.getBoolean(DISABLE_ECLIPSE_FULLSCREEN);
if (disabled) {
FullscreenHandlerService.disableFullscreenHandler();
} else {
FullscreenHandlerService.enableFullscreenHandler();
}
store.addPropertyChangeListener(event -> {
String changedProperty = event.getProperty();
if (DISABLE_ECLIPSE_FULLSCREEN.equals(changedProperty)) {
boolean disabled = store.getBoolean(DISABLE_ECLIPSE_FULLSCREEN);
if (disabled) {
FullscreenHandlerService.disableFullscreenHandler();
} else {
FullscreenHandlerService.enableFullscreenHandler();
}
}
});
Expand All @@ -203,13 +195,11 @@ public void propertyChange(PropertyChangeEvent event) {
}

final IWorkbench workbench = PlatformUI.getWorkbench();
workbench.getDisplay().asyncExec(new Runnable() {
public void run() {
IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
if (window != null) {
Shell mainShell = window.getShell();
getDefault().setFullScreen(mainShell, true);
}
workbench.getDisplay().asyncExec(() -> {
IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
if (window != null) {
Shell mainShell = window.getShell();
getDefault().setFullScreen(mainShell, true);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void selectionChanged(IAction action, ISelection selection) {
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
Shell mainShell = Display.getDefault().getActiveShell();
if (mainShell.getFullScreen()) {
if (mainShell != null && mainShell.getFullScreen()) {
Activator.getDefault().setFullScreen(mainShell, false);
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ public void selectionChanged(IAction action, ISelection selection) {
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
Shell mainShell = Display.getDefault().getActiveShell();
if (mainShell == null) {
return null;
}
Activator.getDefault().setFullScreen(mainShell, !mainShell.getFullScreen());
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

import java.io.IOException;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
Expand Down Expand Up @@ -65,6 +67,8 @@ public boolean performOk() {
try {
preferences.save();
} catch (IOException e) {
Activator.getDefault().getLog()
.log(new Status(IStatus.ERROR, Activator.ID, "Failed to save preferences", e));
}
return super.performOk();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,31 @@
import org.eclipse.ui.commands.ICommandService;
import org.eclipse.ui.internal.handlers.FullScreenHandler;

@SuppressWarnings("restriction")
public class FullscreenHandlerService {

@SuppressWarnings("restriction")
private static final String FULLSCREEN_COMMAND_ID = "org.eclipse.ui.window.fullscreenmode";

public static void enableFullscreenHandler() {
ICommandService commandService = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
if (commandService == null) {
return;
Command command = getFullscreenCommand();
if (command != null) {
command.setHandler(new FullScreenHandler());
}
Command command = commandService.getCommand("org.eclipse.ui.window.fullscreenmode");
command.setHandler(new FullScreenHandler());
}

public static void disableFullscreenHandler() {
ICommandService commandService = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
Command command = getFullscreenCommand();
if (command != null) {
command.setHandler(null);
}
}

private static Command getFullscreenCommand() {
ICommandService commandService = PlatformUI.getWorkbench().getService(ICommandService.class);
if (commandService == null) {
return;
return null;
}
Command command = commandService.getCommand("org.eclipse.ui.window.fullscreenmode");
command.setHandler(null);
return commandService.getCommand(FULLSCREEN_COMMAND_ID);
}

}