Login  Register

Re: Non-modal dialog with Yes No Cancel

Posted by Stein Rørvik on Oct 13, 2020; 9:33pm
URL: http://imagej.273.s1.nabble.com/Non-modal-dialog-with-Yes-No-Cancel-tp5024006p5024046.html

Edit:

I re-read the documentation for the command line and see this:
  -port
     Specifies the port ImageJ uses to determine if another instance is running
     Example 1: -port1 (use default port address + 1)
     Example 2: -port2 (use default port address + 2)
     Example 3: -port0 (don't check for another instance)

So what I described only works when the instance listener is enabled. This means that if ImageJ was launched on with option -port2, that instance will grab new commands who were also launched using -port2 option.

Stein

-----Original Message-----
Sent: 13. oktober 2020 23:26
Subject: Re: Non-modal dialog with Yes No Cancel

Yes, the -p option will make the port number refer to a specific ImageJ instance, so you can chain several commands to that. And no port specified means new instance every time, or same instance every time (and not the same as the one specified with -p) if you have instance listener enabled in Options. This behaviour is extremely useful in a pipelined multi-tasking scenario as the one I described.

The reason I have a separate compile-and-run macro is a Windows issue: The program I am using passes the filepath to the command line using single backslashes that are lost (interpreted as escape characters) when using the -eval command. But the -macro command handles this correctly, so I can use getArgument() to retrieve the filename. If I type the command manually on the command line I can use forward slashes with -eval command and then run("Compile and Run..." works without a macro, but that is not an option in the editor I am using. On a Linux or Mac system the intermediate macro is probably not needed.

Stein

-----Original Message-----
Sent: 13. oktober 2020 18:43
Subject: Re: Non-modal dialog with Yes No Cancel

Greetings Stein,

Thanks.  I didn't realize that the -p option will open a new imagej panel and assign it the specified port number; obvious now.

As I am able to run the "Compile and Run..." menu item directly from the command line, I am curious as to why you use a middle man approach?
The GVim.rc setting(imagej commandline) I use is:
map <silent> <F9> :silent w<bar>!imagej -o -e 'run("Compile and Run...","compile=%:p");'<CR> which does the equivalent of Ctrl-R inside imagej, albeit using F9 instead.

You can get a handle to the Log window using WindowManager.getAllNonImageWindows(); and change its title.

Thanks,

Fred

On Mon, October 12, 2020 5:45 pm, Stein Rørvik wrote:

> I do this today from the command line via a small wrapper macro. I
> have the "multiple instances listener" on.
> The command line options I use from my external editor (EditPlus) is
>
> -macro "C:/Users/steinr/ImageJ/Generic/Macro Compile Plugin.ijm"
> "$(FilePath)"
>
> And the content of "Macro Compile Plugin.ijm" is
>
> file = getArgument();
> print("compile=" + file);
> run("Compile and Run...", "compile=" + file);
>
> The use of an extra macro causes a delay of a second or two but it is
> still much faster than doing it via the GUI. Multiple compiles do not
> launch a separate instance. I still need to activate ImageJ though as
> it is not brought to the foreground (and it should not).
>
> I am doing this on Windows but it should work on any system.
>
> Regarding ports, I usually have three instances of ImageJ running when
> working at the lab. I launch these using the -port option from my
> Windows scripts that controls the workflow. So I have a dedicated port
> number for batch jobs that may take hours to execute, a second one for
> medium long import-and-export jobs that may take a couple of minutes,
> and a third "normal" one with the default port number and multiple
> instance listener active for everything else that was launched without
> specifying a port number. This works great and there are zero conflicts.
>
> I use a small JavaScript snippet to change the title of each ImageJ
> main window to be able to separate these, to avoid closing the long
> job instance by mistake. The two dedicated batch instances have batch
> mode always on, so that no windows pop up from these. I can inspect
> their progress in the Log window. I do nearly everything from the
> command line or registry connected scripts, so that I can just right
> click a file or folder and specify what to do. The only drawback from
> this is that there is no easy way to identify which ImageJ instance
> each of the three Log window belongs to. So I always have something
> verbose written there, so I can see which job the window is running.
>
> Stein
>
> -----Original Message-----
> Sent: 12. oktober 2020 21:54
> Subject: Re: Non-modal dialog with Yes No Cancel
>
> Greetings,
>
> I would like to compile and run a plugin in the currently running
> imagej instance from the commandline.  The -o options tends not to
> work, i.e., left over lockfile(s) or lockfile pointing to imagej
> instance on another workspace (linux).  Is there a ways to find an
> imagej instance's port number from within imagej? The -p option seems
> to work if you guess the port number correctly.
>
> Thanks,
>
> Fred
>
> gvim:
> map <silent> <F9> :silent w<bar>!imagej -o -e 'run("Compile and
> Run...","compile=%:p");'<CR>
>
> On Mon, October 12, 2020 11:27 am, Stein Rørvik wrote:
> ...
>> use an external editor which launches ImageJ via the command line
>> when writing or testing new macros.
> ...
>
> ---
>
> --
> ImageJ mailing list:
> https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fimage
> j.nih.gov%2Fij%2Flist.html&amp;data=02%7C01%7Cstein.rorvik%40sintef.no
> %7C26163f642c534eea4aca08d86f977183%7Ce1f00f39604145b0b309e0210d8b32af
> %7C1%7C0%7C637382043540302398&amp;sdata=wFA5refdQClMPjs8k6AnQjOxGzmtd6
> PP2uTPlnkiVnM%3D&amp;reserved=0
>

--
ImageJ mailing list: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fimagej.nih.gov%2Fij%2Flist.html&amp;data=02%7C01%7Cstein.rorvik%40sintef.no%7C70c81f4a8ffb431acb8008d86fbefaf2%7Ce1f00f39604145b0b309e0210d8b32af%7C1%7C0%7C637382213339037376&amp;sdata=deB%2BfYYZL17qS%2FuFbvXMQ0RUqLBht4mcUyroEXtMsu4%3D&amp;reserved=0

--
ImageJ mailing list: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fimagej.nih.gov%2Fij%2Flist.html&amp;data=02%7C01%7Cstein.rorvik%40sintef.no%7C70c81f4a8ffb431acb8008d86fbefaf2%7Ce1f00f39604145b0b309e0210d8b32af%7C1%7C0%7C637382213339037376&amp;sdata=deB%2BfYYZL17qS%2FuFbvXMQ0RUqLBht4mcUyroEXtMsu4%3D&amp;reserved=0

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html