Skip to content

Commit

Permalink
Added project name to project specific context menu actions
Browse files Browse the repository at this point in the history
  • Loading branch information
funfried committed Sep 24, 2024
1 parent b6d7869 commit 2efec03
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.8.0</version>
<version>3.10.0</version>
<configuration>
<quiet>true</quiet>
<doclint>all,-missing</doclint>
Expand Down Expand Up @@ -325,7 +325,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jdepend-maven-plugin</artifactId>
<version>2.0</version>
<version>2.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
9 changes: 9 additions & 0 deletions src/changes/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
</properties>

<body>
<release version="1.0.7-SNAPSHOT" date="n/a" description="n/a">
<action dev="bahlef" type="change">
Added project names to project specific context menu actions
</action>
<action dev="bahlef" type="change" issue="35">
Separated the version specific VCS actions into plugin extensions.
</action>
</release>

<release version="1.0.6" date="2024-03-19" description="Hotfix release">
<action dev="bahlef" type="fix" issue="32">
Fixed close left action which closed all tabs instead of only the left tabs of the selected tab.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@
import java.awt.event.ActionEvent;
import java.util.Objects;

import javax.swing.Action;

import org.apache.commons.lang3.ArrayUtils;
import org.netbeans.api.project.Project;
import org.netbeans.api.project.ProjectInformation;
import org.netbeans.api.project.ProjectUtils;
import org.netbeans.api.project.ui.OpenProjects;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil;
Expand All @@ -35,6 +39,8 @@
abstract class AbstractProjectBaseAction extends AbstractInitialCloseBaseAction {
private static final long serialVersionUID = 5322225046091709258L;

private final String actionNamePrefix;

/**
* Constructor of abstract class {@link ActionBase}.
*
Expand All @@ -43,6 +49,8 @@ abstract class AbstractProjectBaseAction extends AbstractInitialCloseBaseAction
*/
public AbstractProjectBaseAction(String name, TopComponent topComponent, boolean initialClose) {
super(name, topComponent, initialClose);

actionNamePrefix = name;
}

/**
Expand Down Expand Up @@ -70,9 +78,24 @@ public void actionPerformed(ActionEvent event) {
}
}

/**
* {@inheritDoc}
*/
@Override
public boolean isEnabled() {
return getProjectByTopComponent(OpenProjects.getDefault().getOpenProjects(), topComponent) != null;
Project project = getProjectByTopComponent(OpenProjects.getDefault().getOpenProjects(), topComponent);
if (project != null) {
ProjectInformation projectInfo = ProjectUtils.getInformation(project);
if (projectInfo != null) {
putValue(Action.NAME, actionNamePrefix + " (" + projectInfo.getDisplayName() + ")");
}

return true;
} else {
putValue(Action.NAME, actionNamePrefix);

return false;
}
}

private Project getProjectByTopComponent(Project[] openProjects, TopComponent topComponent) {
Expand Down
Binary file modified src/site/resources/imgs/editor_tab_contextmenu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2efec03

Please sign in to comment.