Passing an object as a parameter to a command - eclipse

I Have two commands in my eclipse plugin. (Upload and Run). They can be invoked by the user one after another. So it only makes sense to invoke Run after the upload command is done.
Since the upload command possibly takes some time it will schedule a WorkspaceJob for actual execution. And returns right after it scheduled the job.
What i like to do know is to add another command called "Upload and Run" which (suprisingly) is supposed to first upload and then run the selection. Therefore it must be notified when the WorkspaceJob started in the Upload command has finished.
So i'd like to parameterize the command with an additional IJobChangeListener which it will add when the WorkspaceJob is scheduled.
Unfortunately it seems to me like it's only possible to pass Strings as parameters to a command or Objects that can be converted to Strings easily. However a Listener like this cannot be passed as a String.
How can i provide the command with such an Listener Object?
Is there maybe an other way of providing the Listener Object to the Command (other than passing it as a prameter) that i didn't think of?

Since your "Upload and Run" action is going to start the upload, you could then just schedule another job for the Run-action which simply calls join() on the workspace job-reference you have before doing anything else.
Update:
I think you're running into a limitation of the framework there. The commands are intended as an abstraction on the user-interface, not as an abstraction of getting things done. I'd simply go with reusing the Java code that you have, and directly invoke the code for both actions from the button for the joint functionality.

Related

Launch on event with python

here I write my first question as programming beginner starting with python.
I have a small script that executes a loop, which function is to download a list from the server, compare it with other lists and see if something has happened. Usually the answer is NO, but sometimes something happens. When the answer becomes YES, I would like this script at this point to be able to "launch the second program", a similar script that from here takes care of the instructions to handle the specific event signaled while the " main program "continues to interrogate the server and compare the answers (that's the only thing he has to do).
considering that you can run it with two clicks from the desktop specifying only one variable (that comes from the first script), I thought it was easy to "trigger" the execution of a python file in a new window or something like that ...can anybody tell me how I can make it start at the request of the first script avoiding that the first script remains blocked waiting for answers and continues to execute its cycle?

Run each hotkey in a script file in a separate thread (with max threads per hotkey = 1)

I have a .ahk script file with 3 hotkeys.
Each hotkey takes a few seconds to complete.
What happens when I run hotkey a and then hotkey b before a is finished is that a is interrupted and the script continues with b.
Basically I want a and b to run concurrently.
Can I achieve this ?
True Multi-Threading in a single script does not exist (yet) in AutoHotkey.
While there are some ways to try and create "fake" multithreading, the best solution at the present is to have each hotkey run their own separate ahk script files using the Run command.
Hope this was helpful; if you would like an example of what this kind of code would look like, lmk and I can go ahead and create one.
When I need two functions to operate simultaneously I make multiple scripts that interact with each other. Unfortunately Autohotkey doesn't support multi-threading so that's the only way to do it.
Some ideas:
You can pass variables between scripts using msgbox and/or GUIs.
You can also use msgbox as a "wait until" if you need one function to
wait for the other to complete a part of automation.
I sometimes use that to make two scripts "play tag" to utilize all
the down time that exists during load times on websites. In other
words, I make two bots that interact with separate websites...
automating one while the other one is waiting for its page to load.
I have also utilized a "control panel" type of setup where I make a
master script that controls subroutines (other scripts) via GUIs. You
can then use the buttons to trigger Run commands and provide kill
buttons for each subroutine. This will give it the feeling of a full
application if you do it all through controlsend to a hidden gui. The
master script can then keep track of all the variables that need to
be exchanged between subroutines with msgbox like I mentioned before.
But I think at that point you might want to just incorporate another
more powerful language like python or Java.

Automated Updating of a Program via powershell

I am trying to updating a software that is company wide. When the update is applied to the server, the client machines recognize they need an update and ask if you wish to update or not. To update, the user would need to run as admin, which is'nt an option in this case.
We would like to automate this process using powershell, using the Invoke-Command feature. For the most part, the only thing that the update does is copy new files to the programs folder, which we have achieved with robocopy. However, there is one registry key that needs to be added in multiple locations. There is a setup file that does this, but requires a user (with admin privileges) click a couple buttons, and we want this to be completely automated.
So I guess the short version of my question is, what is the best way to handle the registry changes that setup.exe does? It would be nice if there was a way to invoke the script that the executable does.
As for my question, I solved the problem with a slightly diferent approach. (One that should have been tried initially)
When (ProgramName).exe is run, if it sees that it needs updated, it runs a program called (ProgramName).setup.exe with the parameters :
Client="Local folder" server="server location"
These parameters did NOT work from the command line, however, and so I ended up using a powershell script to make a scheduled task that ran (ProgramName).setup.exe with said parameters.
Another huge advantage to this was the fact that I could create an icon that allowed a regular user to run the scheduled task with admin privileges. I couldn't setup a shortcut directly, however, I wrote an AUTO-it Executable that would run the task as admin.
I hope someone can get some level of help out of this post!

Changing Code At Runtime While Debugging

I am using Eclipse Kepler Service Release 2 , EPIC 0.5.46 and Strawberry Perl 5 version 18 for perl programming. For debugging I am using Eclipse debugger and PadWalker .
I have an interactive perl program that writes to files based on answers provided by the users to multiple prompts. While debugging , every time i change a single line of code I have to rerun the whole program again and provide inputs to every prompt , which is really time consuming.
Is there a way to make changes to the code in a sub routine , in the middle of debugging session such that the instruction pointer resets itself to the first line of that sub routine. This way i do not have to restart the session to recompile the new code.
Appreciate your inputs and suggestions. Thank You!!!
What you want to do can be done, and I've done it many times in Perl myself. For example, see this.
However although what you describe may work (and is a bit dangerous), the way it is generally done a bit different and safer.
First one has to assume a regular kind of command structure like a command processor, or say a web server.
In a command processor or web server, you read a command (or get a web request), perform an action, then read another command, perform another action and so on. From your description, it sounds like you have such a structure.
In my case, I have each debugger command stored as in Perl file. This is helpful not only for facilitating this task, but also for understanding, testing and changing the code.
Given this kind of program structure, instead of trying to change the program counter, you complete the command and at the level where you are about to read a new command, you make the change and then reload the file which changes the code.
The specific Perl construct to do this is called do. Don't use require or use which will load in a Perl file only if that file or module hasn't been previously loaded. In your situation, you want to reload even if it has been loaded before.
So now how do you get to be able to issue a do command? As you suggest, you could do it through a debugger. Assuming you have this overall program stucture as described above, you put the breakpoint somewhere a common point in the caller which loops over things to process, rather than try to change things in indvidual commands.
And you don't even need a debugger to do this! Many web frameworks like Ruby on Rails, have a "development" mode where they save timestamps on files that implement functionality. If the file has changed they issue the "do" command before running the request.

Is it possible to have windows autocomplete custom commands?

I'm running Console2, which I believe is just an interface to windows cmd
I have a custom batch file that does most of my dirty work for me, but there are lot of commands in it now. Is there a way I can get a tap autocomplete working for it in the windows command prompt?
For example: my script is called rob.bat and it takes in a various number of arguments
It'd like to type rob set{Tab} and then have it cycle through
setup_envvars
setup_userprefs
setup_whateverothersetupscriptsIhave
Is there a way to do this?
Console2 has no special provisions for tab completion and instead relies on the program running within it to provide such features. Picture Console2 as little more than something that runs a console program hidden somewhere, regularly polls that hidden window for changes, and forwards all input to that window; this is, in essence, what's happening.
Note that Console2 does nothing special with cmd. You can run any shell within it. As for customizing tab completion, cmd offers nothing of that sort. You may be able to change this by installing clink, which has extension points for Lua code. Another option would be PowerShell, which has customizable tab completion out of the box, either by wrapping your program in a function that provides the necessary parameters, or by writing a custom TabExpansion or TabExpansion2 function.