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 @@ -38,7 +38,7 @@ public String getDefaultExtension() {
@Nonnull
@Override
public Image getIcon() {
return ImagesIconGroup.imagesfiletype();
return ImagesIconGroup.filetypeImage();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,20 @@ public interface ImageZoomModel {

void setZoomFactor(double zoomFactor);

void fitZoomToWindow();

void zoomOut();
void zoomFitToWindow();

void zoomIn();

void zoomOut();

void setZoomLevelChanged(boolean value);

boolean canZoomOut();
boolean canZoomFitToWindow();

boolean canZoomIn();

boolean canZoomOut();

boolean isZoomLevelChanged();

ImageZoomModel STUB = new ImageZoomModel() {
Expand All @@ -56,23 +58,23 @@ public void setZoomFactor(double zoomFactor) {
}

@Override
public void zoomOut() {
public void zoomFitToWindow() {
}

@Override
public void zoomIn() {
}

@Override
public void setZoomLevelChanged(boolean value) {
public void zoomOut() {
}

@Override
public void fitZoomToWindow() {
public void setZoomLevelChanged(boolean value) {
}

@Override
public boolean canZoomOut() {
public boolean canZoomFitToWindow() {
return false;
}

Expand All @@ -81,6 +83,11 @@ public boolean canZoomIn() {
return false;
}

@Override
public boolean canZoomOut() {
return false;
}

@Override
public boolean isZoomLevelChanged() {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,56 @@
package org.intellij.images.editor.actionSystem;

import consulo.ui.ex.action.AnActionEvent;
import org.intellij.images.editor.ImageZoomModel;
import org.intellij.images.ui.ImageComponentDecorator;

import jakarta.annotation.Nullable;
import java.util.function.Consumer;
import java.util.function.Predicate;

/**
* Editor actions utility.
*
* @author <a href="mailto:aefimov.box@gmail.com">Alexey Efimov</a>
* @author UNV
*/
public final class ImageEditorActionUtil {
private ImageEditorActionUtil() {
public static void acceptImageDecorator(AnActionEvent e, Consumer<ImageComponentDecorator> consumer) {
ImageComponentDecorator decorator = getValidDecorator(e);
if (decorator != null) {
consumer.accept(decorator);
}
}

public static void acceptZoomModel(AnActionEvent e, Consumer<ImageZoomModel> consumer) {
ImageComponentDecorator decorator = getValidDecorator(e);
if (decorator != null) {
consumer.accept(decorator.getZoomModel());
}
}

@Nullable
public static ImageComponentDecorator getImageComponentDecorator(AnActionEvent e) {
return e.getData(ImageComponentDecorator.DATA_KEY);
public static boolean testImageDecorator(AnActionEvent e, Predicate<ImageComponentDecorator> predicate) {
return testImageDecorator(e, predicate, false);
}

public static boolean testImageDecorator(AnActionEvent e, Predicate<ImageComponentDecorator> predicate, boolean defaultValue) {
ImageComponentDecorator decorator = getValidDecorator(e);
return decorator != null ? predicate.test(decorator) : defaultValue;
}

public static boolean testZoomModel(AnActionEvent e, Predicate<ImageZoomModel> predicate) {
return testZoomModel(e, predicate, false);
}

public static boolean testZoomModel(AnActionEvent e, Predicate<ImageZoomModel> predicate, boolean defaultValue) {
ImageComponentDecorator decorator = getValidDecorator(e);
return decorator != null ? predicate.test(decorator.getZoomModel()) : defaultValue;
}

private static ImageComponentDecorator getValidDecorator(AnActionEvent e) {
ImageComponentDecorator decorator = e.getData(ImageComponentDecorator.DATA_KEY);
return decorator != null && decorator.isEnabledForActionPlace(e.getPlace()) ? decorator : null;
}

private ImageEditorActionUtil() {
}
}

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ action.Images.Editor.Toggle.Transparency.Chessboard.show.text:
text: Show Chessboard
action.Images.Editor.Zoom.Actual.text:
text: Zoom to Actual Size
action.Images.Editor.Zoom.Fit.To.Window.text:
text: Fit to Window
action.Images.Editor.Zoom.In.text:
text: Zoom In
action.Images.Editor.Zoom.Out.text:
Expand Down
Loading
Loading