package com.intellij.ide.actions;

import com.intellij.ide.ui.UISettings;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.wm.impl.IdeFrameImpl;

import java.awt.*;

/**
 * @author Konstantin Bulenkov
 */
public class TogglePresentationModeAction extends AnAction implements DumbAware {
  @Override
  public void update(AnActionEvent e) {
    boolean selected = UISettings.getInstance().PRESENTATION_MODE;
    e.getPresentation().setText(selected ? "Exit Presentation Mode" : "Enter Presentation Mode");
  }

  @Override
  public void actionPerformed(AnActionEvent e){
    UISettings settings = UISettings.getInstance();
    Project project = e.getProject();

    if (project != null) {
      HideAllToolWindowsAction.performAction(project);
    }

    settings.PRESENTATION_MODE = !settings.PRESENTATION_MODE;
    settings.fireUISettingsChanged();

    if (project != null) {
      Window frame = IdeFrameImpl.getActiveFrame();
      if (frame instanceof IdeFrameImpl) {
        ((IdeFrameImpl)frame).toggleFullScreen(true);
      }
    }
  }
}

@@ -1,8 +1,609 @@
+/*%0A * Copyright 2000-2013 JetBrains s.r.o.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A * http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A
 package 
@@ -668,16 +668,66 @@
 ttings;%0A
+import com.intellij.ide.util.PropertiesComponent;%0A
 import c
@@ -821,24 +821,79 @@
 ctionEvent;%0A
+import com.intellij.openapi.editor.ex.util.EditorUtil;%0A
 import com.i
@@ -1861,67 +1861,589 @@
     
-((IdeFrameImpl)frame).toggleFullScreen(true);%0A      %7D%0A    %7D
+final PropertiesComponent propertiesComponent = PropertiesComponent.getInstance(project);%0A        if (settings.PRESENTATION_MODE) %7B%0A          propertiesComponent.setValue(%22full.screen.before.presentation.mode%22, String.valueOf(((IdeFrameImpl)frame).isInFullScreen()));%0A          ((IdeFrameImpl)frame).toggleFullScreen(true);%0A        %7D else %7B%0A          final String value = propertiesComponent.getValue(%22full.screen.before.presentation.mode%22);%0A          ((IdeFrameImpl)frame).toggleFullScreen(%22true%22.equalsIgnoreCase(value));%0A        %7D%0A      %7D%0A    %7D%0A%0A    EditorUtil.reinitSettings();
 %0A  %7D

save full screen state and reinit editor properly