Skip to content

Commit

Permalink
Merge pull request #19 from unv-unv/unv/maven-refactoring
Browse files Browse the repository at this point in the history
Maven refactoring
  • Loading branch information
VISTALL authored Oct 10, 2024
2 parents 0df720f + a0c352f commit a6daa0a
Show file tree
Hide file tree
Showing 49 changed files with 3,720 additions and 4,197 deletions.
27 changes: 13 additions & 14 deletions plugin/src/main/java/org/jetbrains/idea/maven/MavenIcons.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,17 @@

@Deprecated
@DeprecationInfo("Use MavenIconGroup")
public class MavenIcons
{
public static final Image ChildrenProjects = MavenIconGroup.childrenprojects();
public static final Image MavenLogo = MavenIconGroup.mavenlogo();
public static final Image MavenPlugin = MavenIconGroup.mavenplugin();
// TODO [VISTALL] use file icon
public static final Image MavenProject = MavenLogo; // 16x16
public static final Image ModulesClosed = MavenIconGroup.modulesclosed();
public static final Image ParentProject = MavenIconGroup.parentproject();
public static final Image PhasesClosed = AllIcons.Nodes.ConfigFolder; // 16x16
public static final Image PluginGoal = MavenIconGroup.plugingoal();
public static final Image ProfilesClosed = MavenIconGroup.profilesclosed();
public static final Image ToolWindowMaven = MavenIconGroup.toolwindowmaven();
public static final Image UpdateFolders = MavenIconGroup.updatefolders();
public class MavenIcons {
public static final Image ChildrenProjects = MavenIconGroup.childrenprojects();
public static final Image MavenLogo = MavenIconGroup.mavenlogo();
public static final Image MavenPlugin = MavenIconGroup.mavenplugin();
// TODO [VISTALL] use file icon
public static final Image MavenProject = MavenLogo; // 16x16
public static final Image ModulesClosed = MavenIconGroup.modulesclosed();
public static final Image ParentProject = MavenIconGroup.parentproject();
public static final Image PhasesClosed = AllIcons.Nodes.ConfigFolder; // 16x16
public static final Image PluginGoal = MavenIconGroup.plugingoal();
public static final Image ProfilesClosed = MavenIconGroup.profilesclosed();
public static final Image ToolWindowMaven = MavenIconGroup.toolwindowmaven();
public static final Image UpdateFolders = MavenIconGroup.updatefolders();
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

/**
* @author VISTALL
* @since 21/01/2023
* @since 2023-01-21
*/
@ExtensionImpl
public class MavenDomGutterAnnotatorFactory implements AnnotatorFactory {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@
*/
package org.jetbrains.idea.maven.dom.refactorings.extract;

import consulo.language.editor.refactoring.RefactoringBundle;
import consulo.language.editor.refactoring.localize.RefactoringLocalize;
import consulo.project.Project;
import consulo.ui.annotation.RequiredUIAccess;
import consulo.ui.ex.awt.DialogWrapper;
import consulo.util.lang.Pair;
import consulo.util.lang.StringUtil;
import org.jetbrains.idea.maven.dom.MavenDomBundle;
import org.jetbrains.idea.maven.dom.MavenDomUtil;
import org.jetbrains.idea.maven.dom.model.MavenDomDependency;
import org.jetbrains.idea.maven.dom.model.MavenDomProjectModel;
import org.jetbrains.idea.maven.localize.MavenDomLocalize;
import org.jetbrains.idea.maven.project.MavenProject;
import org.jetbrains.idea.maven.utils.ComboBoxUtil;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.swing.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.Set;
import java.util.function.Function;
Expand Down Expand Up @@ -58,7 +58,7 @@ public SelectMavenProjectDialog(
myMavenDomProjectModels = mavenDomProjectModels;
myHasExclusions = hasExclusions;

setTitle(MavenDomBundle.message("choose.project"));
setTitle(MavenDomLocalize.chooseProject());

myOccurrencesCountFunction = funOccurrences;
for (MavenDomProjectModel model : myMavenDomProjectModels) {
Expand All @@ -72,13 +72,15 @@ public SelectMavenProjectDialog(
}

@Nonnull
@Override
protected Action[] createActions() {
return new Action[]{
getOKAction(),
getCancelAction()
};
}

@Override
protected void init() {
super.init();

Expand Down Expand Up @@ -106,6 +108,7 @@ public boolean isExtractExclusions() {
return myExtractExclusions.isSelected();
}

@Override
protected JComponent createCenterPanel() {
ComboBoxUtil.setModel(myMavenProjectsComboBox, new DefaultComboBoxModel(), myMavenDomProjectModels,
model -> {
Expand All @@ -121,11 +124,7 @@ protected JComponent createCenterPanel() {
}
);

myReplaceAllListener = new ItemListener() {
public void itemStateChanged(ItemEvent e) {
updateControls();
}
};
myReplaceAllListener = e -> updateControls();

myMavenProjectsComboBox.addItemListener(myReplaceAllListener);
myMavenProjectsComboBox.setSelectedItem(0);
Expand All @@ -140,7 +139,7 @@ public void itemStateChanged(ItemEvent e) {
private void updateControls() {
MavenDomProjectModel project = getSelectedProject();
Integer count = myOccurrencesCountFunction.apply(project).size();
myReplaceAllCheckBox.setText(RefactoringBundle.message("replace.all.occurences", count));
myReplaceAllCheckBox.setText(RefactoringLocalize.replaceAllOccurences(count).get());

myReplaceAllCheckBox.setEnabled(count != 0);
}
Expand All @@ -149,6 +148,8 @@ private void updateOkStatus() {
setOKActionEnabled(getSelectedProject() != null);
}

@Override
@RequiredUIAccess
public JComponent getPreferredFocusedComponent() {
return myMavenProjectsComboBox;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*/

/*
* User: anna
* Date: 13-May-2010
* @author anna
* @since 2010-05-13
*/
package org.jetbrains.idea.maven.execution;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,46 +19,52 @@

/**
* @author Eugene Zhuravlev
* Date: 10/27/12
* @since 2012-10-27
*/
public class MavenIdBean {
@Tag("groupId")
public String groupId;
@Tag("groupId")
public String groupId;

@Tag("artifactId")
public String artifactId;
@Tag("artifactId")
public String artifactId;

@Tag("version")
public String version;
@Tag("version")
public String version;

public MavenIdBean() {
}
public MavenIdBean() {
}

public MavenIdBean(String groupId, String artifactId, String version) {
this.groupId = groupId;
this.artifactId = artifactId;
this.version = version;
}
public MavenIdBean(String groupId, String artifactId, String version) {
this.groupId = groupId;
this.artifactId = artifactId;
this.version = version;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}

MavenIdBean bean = (MavenIdBean)o;
MavenIdBean bean = (MavenIdBean)o;

if (artifactId != null ? !artifactId.equals(bean.artifactId) : bean.artifactId != null) return false;
if (groupId != null ? !groupId.equals(bean.groupId) : bean.groupId != null) return false;
if (version != null ? !version.equals(bean.version) : bean.version != null) return false;
if (artifactId != null ? !artifactId.equals(bean.artifactId) : bean.artifactId != null) {
return false;
}
if (groupId != null ? !groupId.equals(bean.groupId) : bean.groupId != null) {
return false;
}
return version != null ? version.equals(bean.version) : bean.version == null;
}

return true;
}

@Override
public int hashCode() {
int result = groupId != null ? groupId.hashCode() : 0;
result = 31 * result + (artifactId != null ? artifactId.hashCode() : 0);
result = 31 * result + (version != null ? version.hashCode() : 0);
return result;
}
@Override
public int hashCode() {
int result = groupId != null ? groupId.hashCode() : 0;
result = 31 * result + (artifactId != null ? artifactId.hashCode() : 0);
result = 31 * result + (version != null ? version.hashCode() : 0);
return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,81 +28,79 @@

/**
* @author Eugene Zhuravlev
* Date: 10/20/12
* @since 2012-10-20
*/
public class MavenModuleResourceConfiguration {
@Nonnull
@Tag("id")
public MavenIdBean id;

@Nullable
@Tag("parentId")
public MavenIdBean parentId;

@Nonnull
@Tag("directory")
public String directory;

@Nonnull
@Tag("delimiters-pattern")
public String delimitersPattern;

@Tag("model-map")
@MapAnnotation(surroundWithTag = false, surroundKeyWithTag = false, surroundValueWithTag = false)
public Map<String, String> modelMap = new HashMap<String, String>();

@Tag("properties")
@MapAnnotation(surroundWithTag = false, surroundKeyWithTag = false, surroundValueWithTag = false)
public Map<String, String> properties = new HashMap<String, String>();

@Tag("filtering-excluded-extensions")
@AbstractCollection(surroundWithTag = false, elementTag = "extension")
public Set<String> filteringExclusions = Sets.newHashSet(FileUtil.PATH_HASHING_STRATEGY);

@OptionTag
public String escapeString = MavenProjectConfiguration.DEFAULT_ESCAPE_STRING;

@OptionTag
public boolean escapeWindowsPaths = true;

@Tag("resources")
@AbstractCollection(surroundWithTag = false, elementTag = "resource")
public List<ResourceRootConfiguration> resources = new ArrayList<ResourceRootConfiguration>();

@Tag("test-resources")
@AbstractCollection(surroundWithTag = false, elementTag = "resource")
public List<ResourceRootConfiguration> testResources = new ArrayList<ResourceRootConfiguration>();


public Set<String> getFilteringExcludedExtensions() {
if (filteringExclusions.isEmpty()) {
return MavenProjectConfiguration.DEFAULT_FILTERING_EXCLUDED_EXTENSIONS;
}
final Set<String> result = Sets.newHashSet(FileUtil.PATH_HASHING_STRATEGY);
result.addAll(MavenProjectConfiguration.DEFAULT_FILTERING_EXCLUDED_EXTENSIONS);
result.addAll(filteringExclusions);
return Collections.unmodifiableSet(result);
}

public int computeConfigurationHash(boolean forTestResources) {
int result = id.hashCode();
result = 31 * result + (parentId != null ? parentId.hashCode() : 0);
result = 31 * result + directory.hashCode();
result = 31 * result + delimitersPattern.hashCode();
result = 31 * result + modelMap.hashCode();
result = 31 * result + properties.hashCode();
result = 31 * result + filteringExclusions.hashCode();
result = 31 * result + (escapeString != null ? escapeString.hashCode() : 0);
result = 31 * result + (escapeWindowsPaths ? 1 : 0);

final List<ResourceRootConfiguration> _resources = forTestResources? testResources : resources;
result = 31 * result;
for (ResourceRootConfiguration resource : _resources) {
result += resource.computeConfigurationHash();
@Nonnull
@Tag("id")
public MavenIdBean id;

@Nullable
@Tag("parentId")
public MavenIdBean parentId;

@Nonnull
@Tag("directory")
public String directory;

@Nonnull
@Tag("delimiters-pattern")
public String delimitersPattern;

@Tag("model-map")
@MapAnnotation(surroundWithTag = false, surroundKeyWithTag = false, surroundValueWithTag = false)
public Map<String, String> modelMap = new HashMap<>();

@Tag("properties")
@MapAnnotation(surroundWithTag = false, surroundKeyWithTag = false, surroundValueWithTag = false)
public Map<String, String> properties = new HashMap<>();

@Tag("filtering-excluded-extensions")
@AbstractCollection(surroundWithTag = false, elementTag = "extension")
public Set<String> filteringExclusions = Sets.newHashSet(FileUtil.PATH_HASHING_STRATEGY);

@OptionTag
public String escapeString = MavenProjectConfiguration.DEFAULT_ESCAPE_STRING;

@OptionTag
public boolean escapeWindowsPaths = true;

@Tag("resources")
@AbstractCollection(surroundWithTag = false, elementTag = "resource")
public List<ResourceRootConfiguration> resources = new ArrayList<>();

@Tag("test-resources")
@AbstractCollection(surroundWithTag = false, elementTag = "resource")
public List<ResourceRootConfiguration> testResources = new ArrayList<>();

public Set<String> getFilteringExcludedExtensions() {
if (filteringExclusions.isEmpty()) {
return MavenProjectConfiguration.DEFAULT_FILTERING_EXCLUDED_EXTENSIONS;
}
final Set<String> result = Sets.newHashSet(FileUtil.PATH_HASHING_STRATEGY);
result.addAll(MavenProjectConfiguration.DEFAULT_FILTERING_EXCLUDED_EXTENSIONS);
result.addAll(filteringExclusions);
return Collections.unmodifiableSet(result);
}
return result;
}

public int computeConfigurationHash(boolean forTestResources) {
int result = id.hashCode();
result = 31 * result + (parentId != null ? parentId.hashCode() : 0);
result = 31 * result + directory.hashCode();
result = 31 * result + delimitersPattern.hashCode();
result = 31 * result + modelMap.hashCode();
result = 31 * result + properties.hashCode();
result = 31 * result + filteringExclusions.hashCode();
result = 31 * result + (escapeString != null ? escapeString.hashCode() : 0);
result = 31 * result + (escapeWindowsPaths ? 1 : 0);

final List<ResourceRootConfiguration> _resources = forTestResources ? testResources : resources;
result = 31 * result;
for (ResourceRootConfiguration resource : _resources) {
result += resource.computeConfigurationHash();
}
return result;
}
}


Expand Down
Loading

0 comments on commit a6daa0a

Please sign in to comment.