Skip to main content
1-Visitor
January 19, 2018
Solved

How do I install a custom toolbar in the Epic editor 5.4?

  • January 19, 2018
  • 1 reply
  • 11546 views

Hi Everyone,

I built a custom toolbar by editing the editwindow.xml file in Arbortext (C:\Program Files (x86)\PTC\Arbortext Editor\lib\dialogs) however, I understand that it is not the correct way to add a custom toolbar. I've read a great part of the customization guide and also the programmers guide, but I just cannot find the information I need, in the form of a code sample,  that will help me do this all correctly.

 

I have removed the toolbar XML code from the editwindow.xml file and put it into a new file called "my-custom-toolbar.xml". I have also created a new file called "my-custom-toolbar.acl" that hopefully can be used to load the toolbar when a document is opened up in the Arbortext editor. Both of these files are in a following location on my PC:

 

C:\Program Files (x86)\PTC\Arbortext Editor\custom\editinit

 

I think I am close to succeeding because when I put a response("HELLO") message within the above ACL file, it showed up as expected. Unfortunately, my custom toolbar didn't show up, and worse, I don't know why.

 

Here is some information:

  • The window_load_component_file(win, "my-custom-toolbar.xml") command returns 0 - I assume that return value means it failed as it does in C.
  • I have two files, one ACL and one XML that are both in the above editinit directory.
  • Below is the code found in the my-custom-toolbar.acl file that is suppose to load and display my custom toolbar in the Editor.

 

#BEGINNING OF CODE SAMPLE [Not part of the file]

 

function \
init(win = current_window())
{
  if (window_state(win) < 0) {
    response("Invalid window $win")     
    return
  }
 
  local doc = window_doc(win) 
  if (!doc_valid(doc)) {
    response("Invalid document")   
    return
  }  

  #===> Load my custom toolbar on Windows.
  window_load_component_file(win, "my-custom-toolbar.xml") 
  return win
}

# Calls the above function
init()

 

#END OF CODE SAMPLE [Not part of the file]

 

Could someone please lend me a hand and have a look and please tell me where I went wrong? Thank you in advance for your help and input everyone.

 

- George

 

Best answer by ggrosso0321

Hi Everyone,

I think I may have the solution for my issue. I wanted to load a custom toolbar when Arbortext is first started but I just couldn't do it. Thanks to Clay, and some information that I found on this site I was able to get it to work as I want. Now the question is ... did I do it properly?

 

Here's my ACL code:

 

------------------------------------------------
package my_custom_toolbar;

# Forward references
function reload_Toolbar(){}#<==I don't know if I really need this?

function init_toolbar(win = current_window())
{
  # Use a window callback to load the toolbar on callback.
  window_add_callback(0,'create','reload_Toolbar');

  return win;
}

 

# Function to actually load the toolbar.
function reload_Toolbar(win)
{
  # Load my custom toolbar on Windows.
  local XUI_file = get_custom_dir() . "\\dialogs\\my-custom-toolbar.xml";

 

  if(win && XUI_file)

  {
    window_load_component_file(win, XUI_file);

  }

  else

  {

    response("An unknown error has occurred while loading the window.");

  }
}

# Call the above function
init_toolbar();

-------------------------------------------------

 

And that's what I have. Clay please provide your input so I don't inadvertently give a bad example here.

Thanks,

Giorgio

 

1 reply

18-Opal
January 22, 2018

Hi Giorgio--

I guess the first thing I would check is that your XUI file is correct. Try opening the XUI XML file in Editor. From there you should be able to do a completeness check to see if any required content is missing. For a XUI document to be loaded using window_load_component_file(), it must be a complete XUI document, i.e. have a top-level <window> element. Also remember that it needs the appropriate doctype declaration so Arbortext knows it's a XUI document.

If that checks out, you can test the XUI dialog by opening the XUI document in Editor and selecting Tools->View Dialog from the menus. This should show the XUI dialog, and allow you to edit it and see the changes reflected in the dialog view in real time.

Hopefully this will help you troubleshoot your toolbar. You are on the right path, I think, it's just a matter of figuring out what is preventing your toolbar from displaying.

--Clay

1-Visitor
January 23, 2018

Hi Clay,

Thank you for your suggestions, they were very helpful. I loaded the xml file into the editor and the toolbar DID show up. I guess my problem actually is that it is NOT showing up when I open a specific type of document. In my case that's a docbook (actually docbook 4.5) document for editing. How do I get the toolbar to show in either of these two situations:

  • When the editor is first started and nothing is loaded into it
  • When I open a docbook document for editing.

Either one of these above cases would be good for me, but the first case (where the toolbar displays when I first start the editor) would be the most useful case for me.

I've attached a screenshot of the toolbar so you can see that it just sits in the UI with the other toolbars.

Thanks in advance,

- Giorgio

 

18-Opal
January 23, 2018

Hi Giorgio--

In that case, your script might be having trouble finding the XUI file. Your code only uses the filename, with no path info. You might need to be explicit with the location. The get_custom_dir() function can be helpful for this. Try modifying your editinit code along these lines:

 

#===> Load my custom toolbar on Windows.
  window_load_component_file(win, get_custom_dir() . "/editinit/my-custom-toolbar.xml")
  return win

 

Hopefully that will get it to find your toolbar. (FWIW, the return code of window_load_component_file() is just the opposite of what you thought; 0 means it was not able to load the document, 1 means success.)

 

Also, just as a tip, it is conventional to put XUI files into custom/dialogs, to keep it encapsulated from code in editinit or other custom dirs. If you move the XUI, of course you'll need to make the corresponding change in the code above.

 

--Clay