images plugin now part of a CE
[fedora-idea.git] / images / src / org / intellij / images / editor / actions / ActualSizeAction.java
blob556e26f846b1a61f3f436f8b59f3cf2ecf01b520
1 /*
2 * Copyright 2004-2005 Alexey Efimov
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.intellij.images.editor.actions;
18 import com.intellij.openapi.actionSystem.AnAction;
19 import com.intellij.openapi.actionSystem.AnActionEvent;
20 import org.intellij.images.editor.ImageEditor;
21 import org.intellij.images.editor.ImageZoomModel;
22 import org.intellij.images.editor.actionSystem.ImageEditorActionUtil;
24 /**
25 * Resize image to actual size.
27 * @author <a href="mailto:aefimov.box@gmail.com">Alexey Efimov</a>
28 * @see ImageEditor#getZoomModel()
29 * @see ImageZoomModel#setZoomFactor
31 public final class ActualSizeAction extends AnAction {
32 public void actionPerformed(AnActionEvent e) {
33 ImageEditor editor = ImageEditorActionUtil.getValidEditor(e);
34 if (editor != null) {
35 ImageZoomModel zoomModel = editor.getZoomModel();
36 zoomModel.setZoomFactor(1.0d);
40 public void update(AnActionEvent e) {
41 super.update(e);
42 if (ImageEditorActionUtil.setEnabled(e)) {
43 ImageEditor editor = ImageEditorActionUtil.getValidEditor(e);
44 ImageZoomModel zoomModel = editor.getZoomModel();
45 e.getPresentation().setEnabled(zoomModel.getZoomFactor() != 1.0d);