Modify label of command programmatically in Eclipse RCP - eclipse-plugin

Is it possible in Eclipse RCP to modify programmatically the label of a command defined in plugin.xml?

I can't see any way to programmatically change the name of a command defined using the org.eclipse.ui.commands extension point.
Note that the UI often doesn't use the command name anyway. For example the command element of the org.eclipse.ui.menus extension point has a label attribute which overrides the command name.

You can do that if you do have a handler for the respective command.Ask your handler to implement IElementUpdater and in method
updateElement(UIElement element, Map parameters)
you can just set the label of menu item as
element.setText("any_name");

Related

Intellij plugin/action - how to add caret listener to editor automatically on load?

How to add a caret listener to the active editor during "on load", such as when the intellij application starts or when an editor is opened?
I know how to do so in actionPerformed but apparently it is not the right place to do so, and the constructor has no AnActionEvent being passed in so I couldn't get an Editor instance.
I'm not sure what you mean by 'active' editor here. Editor which is active when a particular action is invoked can be retrieved from DataContext passed to actionPerformed.
If you want to add a listener to any editor, when it's created, you can do it in EditorFactoryListener.editorCreated. It can be also simpler to register a listener which will get events from all editors (see EditorFactory.getEventMulticaster()).

Add additional behaviour to existing Eclipse button?

I would like to add additional behaviour to an existing button in the Eclipse ide with a plugin.
To have an example, I would like to print to standard out each time the "Remove Launch" button in the console view gets pressed (see image).
Should I find and override/extend the corresponding, existing Handler with my logic?
Should I work with the these extensions?
ConsoleView extension locationURI="toolbar:org.eclipse.ui.console.ConsoleView"
Commands extension: "org.eclipse.ui.commands"
There isn't a general way to hook in to existing actions.
For Remove Launch you can set up a listener to be notified of removed launches by using the ILaunchManager:
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
launchManager.addLaunchListener(listener);
The listener is an ILaunchesListener which has a launchesRemoved method that will be called when a launch is removed.

How to use the GtkHeaderBar in glade 3.20?

I tried to do a GtkHeaderBar application with glade 3.20, but I have the oldschool bar on top every time, when creating my python app.
In glade 3.19, checking the client-side decoration property created a line on top, in which I could put the GtkHeaderBar. This is not the case in the latest version.
I tried to check/uncheck every property, I could not find the way to do this. That is very surprising, since this should be the default way to do a Gnome application.
I looked on the internet, but there is dramatically no documentation on gladeā€¦
After searching, it seems that I must add a GtkHeaderBar as child in the main window. But how, that is the mystery.
Create the window, set the "Client side window decorations" property to True. Next, get the HeaderBar widget from the toolbox and drop it on the top part of the window that just appeared:
And here you are, the header bar:
Ok, I found by myself a workaround:
We need to create the GtkHeaderBar apart, and after activating the client side decoration property, we close the project. Then, by editing the XML file, we put the header bar section into the titlebar section, instead of the placeholder xml tag. When we reopen the glade project, that's ok, the header bar is in the window.

How to run custom IntelliJ inspections from terminal

so I'm currently trying to run IntelliJ's code inspector from the command line, but I can find where to put in a custom scope. There is an option for custom directories to scan, but nothing for plugging into their custom scope language. Has anyone else dealt with this before? IntelliJ's Documentation
Add the idea.analyze.scope=SCOPE_NAME[1] to your custom properties using the Help | Edit Custom Properties... menu item. Replace SCOPE_NAME with the name of the scope you want to use. This scope you will have to define inside your IDE. If the scope cannot be found, the entire project is inspected. [2]

xcode4 obtaining value of textbox

I am creating an applescript application in xcode 4 and am asking for some guidance. I have done a great deal of reading and scouring the internet but cannot find the answer I am looking for. I have a main window with a textbox and a button. I would like to be able to substitute hostname123 for the text in the textbox so that the command is: do shell script "sudo scutil --set HostName" & [Value of Textbox]. I have the button event set up so that the command will be executed on click. Can someone assist in obtaining the value of the textbox so that it can be used in the command?
on ButtonHandlerVolumeSetting0_(sender)
do shell script "sudo scutil --set HostName hostname123"
end ButtonHandlerVolumeSetting0_
First of all, I'm assuming this is in AppleScriptObjC, and not the older AppleScript Studio.
First, you need to make the AppleScript equivalent of an IBOutlet, which is an instance variable (or property) which references the text field and allows the Objective-C code (or AppleScript) to communicate with it. Toward the top of your AppleScript script, add a line like the following:
script MDAppDelegate
property parent : class "NSObject"
property hostNameTextField : missing value -- add this line
You'll then want to Control-drag from the instance of your script in the nib file to the text field in the window to "hook up" this outlet.
[UPDATE]: from the error message you're getting, it sounds like you haven't got this hostNameTextField connection set up properly in the nib file.
The MDAppDelegate blue cube icon in the nib file shown in the image below represents an instance of your AppleScript script that will be created at runtime when that nib file is loaded. You likely have already properly made the "connection" from your button to the blue AppleScript cube, which specifies that when you click the button, it should call the ButtonHandlerVolumeSetting0_() function (aka AppleScript handler). You now need to select your blue AppleScript cube instance like in the image below, and then right-click (or control-click) and drag from the blue cube to your input text field like I've shown.
When you let up on the mouse button, it should show a black popup panel with possible properties you can "hook up" to the text field. Select hostNameTextField.
Afterwards, when you select the blue AppleScript cube, in the Connections inspector in the right utility area, you can see the connections for the AppleScript script. Under Outlets, you'll see the hostNameTextField outlet and under Received Actions, you'll see ButtonHandlerVolumeSetting0_().
While the hostNameTextField property is set to an initial value of missing value in the AppleScript, (the AppleScript equivalent of Objective-C's nil), by making this connection in the nib file, at runtime, the value of hostNameTextField will be set to the NSTextField you specified. This will allow communication between the script and the object hierarchy that was archived into the nib file.
[END OF UPDATE]
An NSTextField inherits a method named stringValue from its superclass NSControl. This method returns the contents of the text field as an NSString (which equates to an AppleScript string). So inside the button click handler, you can get the string value as follows:
on ButtonHandlerVolumeSetting0_(sender)
set hostName to hostNameTextField's stringValue()
do shell script ("/usr/sbin/scutil --set HostName " & hostName) with administrator privileges
end ButtonHandlerVolumeSetting0_
When using do shell script, it's usually best to omit any inclusion of sudo from the script itself and to instead tack on the with administrator privileges qualifier. That signifies to AppleScript that you need to run the script with elevated privileges and it will handle showing the standard authentication dialog.