Skip to content

Commit

Permalink
Merge pull request #60 from picimako/v131
Browse files Browse the repository at this point in the history
v1.3.1
  • Loading branch information
picimako authored Jun 19, 2023
2 parents 2f3f38d + e74feff commit 3e2f8f2
Show file tree
Hide file tree
Showing 18 changed files with 70 additions and 134 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## [Unreleased]

## [1.3.1]

### Changed
- Removed support for 2021.3, and added support for 2023.2

## [1.3.0]

### Changed
Expand Down
8 changes: 5 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ plugins {
// Kotlin support
id("org.jetbrains.kotlin.jvm") version "1.8.0"
// Gradle IntelliJ Plugin
id("org.jetbrains.intellij") version "1.12.0"
id("org.jetbrains.intellij") version "1.13.3"
// Gradle Changelog Plugin
id("org.jetbrains.changelog") version "2.0.0"
//Lombok
id("io.freefair.lombok") version "6.5.0.3"
}

group = properties("pluginGroup")
Expand Down Expand Up @@ -103,10 +105,10 @@ tasks {
//See https://app.slack.com/client/T5P9YATH9/C5U8BM1MK/thread/C5U8BM1MK-1639934273.054400
isScanForTestClasses = false
include("**/*Test.class")
// systemProperty('idea.home.path', '<absolute path to locally cloned intellij-community GitHub repository>')
// systemProperty("idea.home.path", "<absolute path to locally cloned intellij-community GitHub repository>")
}

// runPluginVerifier {
// ideVersions.set(listOf('IU-2021.3', 'IU-2022.1', 'IU-2022.2', 'IU-2022.3', 'IU-2023.1'))
// ideVersions.set(listOf(//"IU-2022.1", "IU-2022.2", "IU-2022.3", "IU-2023.1", "IU-2023.2"))
// }
}
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ pluginGroup = com.picimako.terra
pluginName = Terra Support
pluginRepositoryUrl = https://github.com/picimako/terra-support
# SemVer format -> https://semver.org
pluginVersion = 1.3.0
pluginVersion = 1.3.1

# See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
# for insight into build numbers and IntelliJ Platform versions.
pluginSinceBuild = 213
pluginUntilBuild = 231.*
pluginSinceBuild = 221
pluginUntilBuild = 232.*

# IntelliJ Platform Properties -> https://github.com/JetBrains/gradle-intellij-plugin#intellij-platform-properties
platformType = IU
platformVersion = 2021.3
platformVersion = 2022.1

# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
# Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22
Expand All @@ -24,7 +24,7 @@ platformPlugins = java,JavaScript
javaVersion = 11

# Gradle Releases -> https://github.com/gradle/gradle/releases
gradleVersion = 7.4
gradleVersion = 8.1.1

# Opt-out flag for bundling Kotlin standard library.
# See https://plugins.jetbrains.com/docs/intellij/kotlin.html#kotlin-standard-library for details.
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
10 changes: 5 additions & 5 deletions gradlew
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

#
# Copyright © 2015-2021 the original authors.
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -32,10 +32,10 @@
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.vfs.VirtualFile;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import org.intellij.images.editor.impl.ImageEditorImpl;
import org.jetbrains.annotations.NotNull;

/**
* Abstract UI content provider implementation for providing common methods for UI component creation.
*/
@RequiredArgsConstructor(access = AccessLevel.PROTECTED)
public abstract class AbstractScreenshotDiffUIContentProvider implements ScreenshotDiffUIContentProvider {

@NotNull
private final Project project;

protected AbstractScreenshotDiffUIContentProvider(@NotNull Project project) {
this.project = project;
}

protected JPanel createImageEditorFor(@NotNull VirtualFile file) {
var imageEditor = new ImageEditorImpl(project, file);
Disposer.register(ImageEditorCache.getInstance(project), imageEditor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.SmartList;
import lombok.Getter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import com.picimako.terra.wdio.SpecFolderCollector;
import com.picimako.terra.wdio.TerraResourceManager;
import com.picimako.terra.wdio.TerraWdioFolders;

Expand All @@ -34,19 +34,20 @@
*
* @since 0.1.0
*/
@Getter
public abstract class AbstractScreenshotsPreview implements FileEditor {

protected final List<ScreenshotDiff> screenshotDiffs = new SmartList<>();
protected final Project project;

protected AbstractScreenshotsPreview(@NotNull Project project, @NotNull VirtualFile file, @NotNull String sourceFolderName,
@NotNull Function<VirtualFile, ScreenshotDiff> screenshotToDiffMapper) {
VirtualFile wdioFolder = TerraWdioFolders.projectWdioRoot(project);
var wdioFolder = TerraWdioFolders.projectWdioRoot(project);
//There should never be a case when the wdio root is null here. Since previews can only be initiated
// from/via screenshots. Having at least one screenshot means that there is a wdio root.
if (wdioFolder != null) {
wdioFolder.refresh(false, true);
SpecFolderCollector specFolderCollector = TerraResourceManager.getInstance(project).specFolderCollector();
var specFolderCollector = TerraResourceManager.getInstance(project).specFolderCollector();
this.screenshotDiffs.addAll(specFolderCollector.collectSpecFoldersForTypeInside(sourceFolderName, VfsUtil.collectChildrenRecursively(wdioFolder))
.flatMap(spec -> Arrays.stream(VfsUtil.getChildren(spec))) //individual screenshot files
.filter(screenshot -> file.getName().equals(screenshot.getName()))
Expand All @@ -56,14 +57,6 @@ protected AbstractScreenshotsPreview(@NotNull Project project, @NotNull VirtualF
this.project = project;
}

public List<ScreenshotDiff> getScreenshotDiffs() {
return screenshotDiffs;
}

public Project getProject() {
return project;
}

/**
* Overriding and implementing this method is required. Since 2021.1
* {@code com.intellij.openapi.fileEditor.impl.IdeDocumentHistoryImpl#createPlaceInfo(FileEditor, FileEditorProvider)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,59 +2,37 @@

package com.picimako.terra.wdio.imagepreview;

import java.util.Objects;

import com.intellij.openapi.vfs.VirtualFile;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/**
* Represents a screenshot diff, meaning either an actual diff image, or a pair of a reference and a latest image.
*/
@Getter
@EqualsAndHashCode
@AllArgsConstructor
public final class ScreenshotDiff {

/**
* Can be a reference or diff image. If it is a diff, then {@link #latest} will be null.
*/
@NotNull
private final VirtualFile original;
@Nullable
private VirtualFile latest;

public ScreenshotDiff(@NotNull VirtualFile original) {
this.original = original;
}

public ScreenshotDiff(@NotNull VirtualFile original, @Nullable VirtualFile latest) {
this.original = original;
this.latest = latest;
}

public VirtualFile getOriginal() {
return original;
}

@Nullable
public VirtualFile getLatest() {
return latest;
}

/**
* Gets whether this diff object has a latest image set.
*/
public boolean hasLatest() {
return latest != null;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ScreenshotDiff that = (ScreenshotDiff) o;
return Objects.equals(original, that.original) &&
Objects.equals(latest, that.latest);
}

@Override
public int hashCode() {
return Objects.hash(original, latest);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

import lombok.RequiredArgsConstructor;

/**
* Listens for the Microsoft Context menu keyboard button to invoke popup menus.
*/
@RequiredArgsConstructor
public final class KeyboardListeningPopupMenuInvoker extends KeyAdapter {
private final ToolWindowPopupMenuInvoker menuInvoker;

public KeyboardListeningPopupMenuInvoker(ToolWindowPopupMenuInvoker menuInvoker) {
this.menuInvoker = menuInvoker;
}

@Override
public void keyReleased(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_CONTEXT_MENU) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.awt.*;

import com.intellij.ui.PopupHandler;
import lombok.RequiredArgsConstructor;
import org.jetbrains.annotations.NotNull;

/**
Expand All @@ -26,13 +27,11 @@
* <li><a href="https://docs.oracle.com/javase/tutorial/uiswing/components/menu.html#popup">Oracle popup menu tutorial</a></li>
* </ul>
*/
@RequiredArgsConstructor
public final class MouseListeningPopupMenuInvoker extends PopupHandler {
@NotNull
private final ToolWindowPopupMenuInvoker menuInvoker;

public MouseListeningPopupMenuInvoker(@NotNull ToolWindowPopupMenuInvoker menuInvoker) {
this.menuInvoker = menuInvoker;
}

@Override
public void invokePopup(Component comp, int x, int y) {
menuInvoker.invokePopup(comp, x, y);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import javax.swing.*;

import com.intellij.openapi.project.Project;
import lombok.RequiredArgsConstructor;

import com.picimako.terra.wdio.toolwindow.node.TerraWdioTree;
import com.picimako.terra.wdio.toolwindow.action.CompareLatestWithReferenceScreenshotsAction;
Expand All @@ -15,15 +16,11 @@
* Adds support for the Screenshot nodes in the Terra wdio tree to be able to open the Reference/Latest Preview
* by double-clicking on screenshot nodes.
*/
@RequiredArgsConstructor
public class MouseListeningScreenshotNodeActionInvoker extends MouseAdapter {
private final Project project;
private final TerraWdioTree tree;

public MouseListeningScreenshotNodeActionInvoker(Project project, TerraWdioTree tree) {
this.project = project;
this.tree = tree;
}

@Override
public void mouseClicked(MouseEvent e) {
if (SwingUtilities.isLeftMouseButton(e) && e.getClickCount() == 2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.function.Predicate;

import com.intellij.openapi.project.Project;
import lombok.RequiredArgsConstructor;
import org.jetbrains.annotations.NotNull;

import com.picimako.terra.wdio.toolwindow.node.TerraWdioTree;
Expand All @@ -26,6 +27,7 @@
* Validates that the used shortcut keys correspond to one of the available action's shortcut,
* and if they do, it invokes that particular action.
*/
@RequiredArgsConstructor
public final class ShortcutKeyListeningScreenshotNodeActionInvoker extends KeyAdapter {
private static final Map<ShortcutKeyChecker, ActionProvider> ACTIONS = Map.of(
RenameScreenshotsAction::isRenameScreenshotsShortcutKey, RenameScreenshotsAction::new,
Expand All @@ -36,14 +38,11 @@ public final class ShortcutKeyListeningScreenshotNodeActionInvoker extends KeyAd
ShowDiffScreenshotsAction::isShowDiffsShortcutKey, ShowDiffScreenshotsAction::new
);

@NotNull
private final Project project;
@NotNull
private final TerraWdioTree tree;

public ShortcutKeyListeningScreenshotNodeActionInvoker(@NotNull Project project, @NotNull TerraWdioTree tree) {
this.project = project;
this.tree = tree;
}

@Override
public void keyPressed(KeyEvent e) {
ACTIONS.keySet().stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.util.Map;

import com.intellij.openapi.actionSystem.ActionPopupMenu;
import lombok.RequiredArgsConstructor;
import org.jetbrains.annotations.NotNull;

import com.picimako.terra.wdio.toolwindow.node.TerraWdioTree;
Expand All @@ -18,15 +19,13 @@
* <p>
* The logic for what mouse or shortcut keys to display the popups is handled in separate listener implementations.
*/
@RequiredArgsConstructor
public final class ToolWindowPopupMenuInvoker {
@NotNull
private final TerraWdioTree tree;
@NotNull
private final Map<String, ActionPopupMenu> actionPopupMenus;

public ToolWindowPopupMenuInvoker(@NotNull TerraWdioTree tree, @NotNull Map<String, ActionPopupMenu> actionPopupMenus) {
this.tree = tree;
this.actionPopupMenus = actionPopupMenus;
}

//Invokes the context menu only when it is initiated on the proper node type
public void invokePopup(Component comp, int x, int y) {
String nodeTypeToSelect = identifyTreeNodeTypeForClickLocation(tree, x, y);
Expand Down
Loading

0 comments on commit 3e2f8f2

Please sign in to comment.