3

I've created a small project in NetBeans 8 (it's not Java, in fact it's config-file to launch a tool), and I wrote several targets for it (these are shell-scripts, invoking the tool). I've mapped some of these scripts to default ant targets (clean, jar, run). But I need more targets (e.g. stop) and I would like to have these additional targets in project context menu (not in the menu on the top). But i haven't found way to do it. Does anyone know how to do this?

Alissa
  • 686
  • 1
  • 8
  • 21
  • You are saying the project is not Java, but mentioning the ant - what kind of NetBeans project is that? Do you have the `build.xml`? – HEKTO Jul 16 '14 at 18:06
  • Yes, I have build.xml where I put my targets. I can provide examples if you need. Each target is one or two shell commands, calling external tool. Actually I needed this to be a NetBeans project because we (team I'm working in) want to run this tool with just one button, like other code. Also not all team-members feel comfortable with CLI, and the tool doesn't have any GUI. – Alissa Jul 17 '14 at 07:54

3 Answers3

1

For NetBeans Java Free-Form projects - you can open the Project Properties pop-up window, go to Build and Run and hit the Add button. Then you can enter Ant target name (right column) and corresponding GUI name (left column) - please see below:

Project Properties

(I hope I've got your question correctly)

HEKTO
  • 3,876
  • 2
  • 24
  • 45
  • 1
    I think you've got question correctly, but in NetBeans 8 this window looks different (e.g. now there are separate section Build with subsections and separate section Run). And this "mapping of custom context menu items" doesn't exist. – Alissa Jul 18 '14 at 12:13
  • 1
    It's NetBeans 8. You probably have chosen the `Java Application` project when you have created it. I'm using the `Java Free-Form Project`. I'll edit my answer – HEKTO Jul 18 '14 at 14:03
  • Yes. And now I know it was wrong. But I can't find way to convert project to free-form. – Alissa Jul 18 '14 at 16:02
  • You can delete your project (make sure you DON'T check the sources deletion checkmark) - then the NetBeans will delete all its mechanics but not your sources. Then you can create a Java free-form project in the same directory - it needs actually only the `build.xml` file. – HEKTO Jul 18 '14 at 17:06
  • I know. Then, what will happen from the git point of view? Will it consider deletion and creation of a project, or will it think tat it's a change? – Alissa Jul 21 '14 at 08:13
  • All the same files in the same directory - why would git care? The only subdirectory which will change is the `nbproject` - but you can add it to the `.gitignore` file – HEKTO Jul 21 '14 at 14:06
0

We've found that it's impossible to vary project's context menu except by a plugin. Also adding target shortcuts to main menu is still available and easy to make.

Alissa
  • 686
  • 1
  • 8
  • 21
  • 1
    Right-clicking the `build.xml` file and then "Run Target" would also probably work. – predi Jul 17 '14 at 13:14
  • 1
    Yeah. But we want to keep action really simple. And to use thisRun target you need first to switch to Files tab, expand project, right-click build.xml. Not a perfect solution actually. – Alissa Jul 18 '14 at 12:15
0

Creating a netbeans plugin is not very hard. It is easy to attach your own actions to the context menu of the file node, project node or of the editor.

Add your actions to

  • Projects/org-netbeans-modules-j2ee-clientproject/Actions
  • Projects/org-netbeans-modules-j2ee-earproject/Actions
  • Projects/org-netbeans-modules-j2ee-ejbjarproject/Actions
  • Projects/org-netbeans-modules-java-j2seproject/Actions

and this should cover all ant-based-project nodes.

More resources

Ben
  • 2,235
  • 18
  • 17
  • Yeah, I know. In first place our idea was, that others won't need to do anything but open project and call some action from context menu. And you cannot deliver a plugin through git. You need to come to each person and remind about plugin installation... – Alissa Jul 22 '14 at 11:39