Pages: 1
Print
Author Topic: XMetaL 9 tab customizations  (Read 9215 times)
tahnee_m
Member

Posts: 10


« on: January 08, 2015, 04:16:00 PM »

We are currently upgrading to SDL LCA 2014 (with SP1 installed) and testing XMetaL Author Enterprise 9.0.0.053. In our previous version (XM6) document tabs were a fixed length no matter how many were open (about 10-12 characters). Now with XM9 tabs are as long as the file name with GUID and extension. This makes working with more than two or three files very difficult -- even knowing how many files are open is more difficult.

We would like it if tabs got narrower as the number of open tabs increased, to a minimum width of n characters. Alternately, a fixed width of n (still TBD) characters where n is more than we had in XM6 would be fine too. However, our best option would be if the tab showed up to the first = sign, giving us just the CMS title and not the GUID and extension. Is this possible?

After installing LCA SP1, the CMS title is shown alone until you save and then at that point the full file name appears with the GUID. SDL says that this is a change JustSystems made and it is outside of their control so I am curious if this has been addressed yet. Keeping just the CMS title in the tab after saving is our ultimate goal so any help would be greatly appreciated.
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2621



WWW
« Reply #1 on: January 08, 2015, 05:36:10 PM »

There are no plans at this time to alter the behaviour but let me try to explain the reasoning behind that.

The software displays the full file name (now) in order to provide you all the information you might need to identify it. If a file name is in a non-human-readable form, or mostly in a non-human-readable form (in your case containing a GUID) there is no way for XMetaL Author to know what portion of the file name to display (the start, the end, the middle, something else). Though the old logic may have been good enough for your needs it does cause issues for other clients as file naming conventions vary widely. There is no logical way for our software to guess what portion of a long file name will be meaningful to a particular person.

In your case, because you have no control over the file naming convention used by SDL, you cannot give shorter meaningful names to your files. That would be the general recommendation for anyone not using a CMS, or where the CMS allows you to name the file.

Any partner (including SDL) can alter their connector's behaviour so that what is displayed as the text for a tab in our UI meets your specific requirements, or specific requirements that make sense for all users of that particular CMS system. The text displayed could be anything. It might be the first few characters of the file name, the last few characters, some other subset like the first 10 letters after the last digit, or something else entirely -- including a portion of the XML markup itself (like a title element or attribute value).

The one API required to do this is ActiveDocument.Title though you may need to use others to build the string itself.

Here are some examples. Keep in mind that these are not real-world examples and almost certainly should not be used as written. They merely show what might be possible.

Code: (Simple Example with Hard Coded Value)
//XMetaL Script Language JScript:
var strDocTitle = "testing";
ActiveDocument.Title = strDocTitle;

SDL should be able to integrate something like this into their solution:
Code: (Example that Builds String from First Character Up to First Equals Sign in File Name)
//XMetaL Script Language JScript:
var strDocTitle = ActiveDocument.Name.substr(0,ActiveDocument.Name.indexOf("="));
ActiveDocument.Title = strDocTitle;

Code: (Example that Builds String from First 10 Characters of File Name)
//XMetaL Script Language JScript:
var strDocTitle = ActiveDocument.Name.substr(0,10);
ActiveDocument.Title = strDocTitle;

Code: (Example that Builds String From Last 10 Characters of File Name)
//XMetaL Script Language JScript:
var strDocTitle = ActiveDocument.Name.substr(ActiveDocument.Name.length-10,10);
ActiveDocument.Title = strDocTitle;

Code: (Example that Builds String from Text in First "title" Element Found in Document)
// XMetaL Script Language JScript:
var rng = ActiveDocument.Range;
rng.MoveToDocumentStart();
rng.MoveToElement("title");
rng.SelectContainerContents();
var strDocTitle = rng.Text;
ActiveDocument.Title = strDocTitle;

The final code that is decided upon should be run as soon as possible after opening a document (so that the user sees it) but obviously after the document has been fully opened so that the Document object is available (used in these examples as ActiveDocument). The particular event used may need to be different depending on what the CMS integration is doing in their other code.

None of the scripts above check to see what it is doing is safe. At minimum it probably should confirm that the document is open in Tags On or Normal view as most of the APIs used here will not function in other views.

ActiveDocument.Title is merely the string displayed in the tab only and does not affect anything else in the system (the real file name or anything else).

Depending on the capabilities of the CMS system it might also be possible to pass an additional meaningful string in from the CMS itself (perhaps some metadata stored about the file. How difficult that would be I cannot say but I think it is a possibility in most cases.

Anyone using a CMS system that requires this type of feature should contact the vendor that provides the connector for that CMS. Clients not using a CMS will probably not need this feature but they can still use this API in any Application-level or Document-level customization of their own making.
« Last Edit: January 08, 2015, 05:43:41 PM by Derek Read » Logged
tahnee_m
Member

Posts: 10


« Reply #2 on: January 12, 2015, 12:56:23 PM »

Thanks for getting back to us on this. We are wondering if it's possible for SDL to have customized the behavior of the tabs on document open but were not able to persist it across save? They are saying they didn’t modify anything but because this behavior changed after installing SP1, that can't be the case. We are looking for confirmation from you guys that nothing in XM9 would cause the tabs to show just the CMS title on open, but reverting back to showing the full name (with GUID) upon saving. We appreciate the help!
« Last Edit: January 12, 2015, 01:17:42 PM by tahnee_m » Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2621



WWW
« Reply #3 on: January 12, 2015, 01:55:25 PM »

I see. Yes, version 9 is resetting the value to the file name when a save is performed.

I wasn't aware of that behaviour. I will check with development to see if that is expected. In the meantime, I assume a fix via scripting should be possible given that SDL should have control over what is occurring during a save (their code should be hooked into the save process in order get the document into the CMS). If SDL can't figure out which event or which part of XMetaL Connector they need to use to do this, or feel that it isn't their issue, please ask them to contact our development team directly (there is a partner email address they SDL should have).
Logged
tahnee_m
Member

Posts: 10


« Reply #4 on: January 12, 2015, 02:17:26 PM »

You mention "the save process in order get the document into the CMS", which I interpret as a checkin. The handling on check in is fine, and if we say check it in but keep it checked out (an option that we have), we get the abbreviated string when the topic reopens. I am curious about Ctrl + S, which saves the local copy of the file (in our case to a folder called "local storage") without writing back to the CMS. Does SDL has the same control over Ctrl+S as they do over checkin as far as hooking their code into it?
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2621



WWW
« Reply #5 on: January 12, 2015, 08:10:20 PM »

Yes, "check-in" was my meaning.

This is trickier, since local save is typically not something a CMS integration is worried about or coded to handle. There is no specific event like "On_Document_After_Save" (or similar) but the event On_Update_UI will run, though it will also run at many other times, so whether that's what they should use I'm not certain.

I think it would be best for SDL to discuss this issue directly as a partner with our developers.
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2621



WWW
« Reply #6 on: January 13, 2015, 02:07:08 PM »

Going back all the way to version 3 (the oldest version I have installed) I see that this API has always behaved this way.

I'll have to discuss with development whether or not it makes sense to alter the behaviour, and I think one can make an argument either way for Save. If the value you are setting is based on the file name (as in your case) then keeping it the same makes sense, but it might not make sense in other cases where the value is coming from somewhere else (saving might alter the document in a way that requires the value to change). It likely wouldn't hurt. Clients that want to change it on Save could still do so (see code below). However, for Save As it is likely that everyone would need to change it, even people basing the value on the file name. So in that case it doesn't save any scripting work.

The software has events in place specially designed to allow people to override what happens for most of the File menu items. This includes Save and Save As. So, the solution is quite simple, provided nothing in your solution is already using those events.

You can implement the following (or have SDL do it) application-level macro to handle Save and SaveAs to local files. SDL's entire solution is essentially application-level so it would likely be fairly trivial for them to put this in place. If they cannot then you can add an MCR into the Startup folder yourself. I've coded the whole file and quoted it below so you can copy and paste it into an empty file and stick that in the Startup folder, then restart and you are good to go. The one thing you will need to change is the portion I've indicated. This would likely need to match whatever script SDL has already coded up for you as part of their check-in code.

Code: (Example -- Manipulating Document Title (Tab Text) On Save and SaveAs Events)
<?xml version="1.0"?>
<!DOCTYPE MACROS SYSTEM "macros.dtd">

<MACROS>

<MACRO name="File_Save" lang="JScript" hide="true"><![CDATA[

//call the standard 'save' action without any special logic
ActiveDocument.Save();

//set the value that displays in the document's tab
//this is just an example and you would need to put your own logic in here
//depending on what you want to display
var strDocTitle = ActiveDocument.Name.substr(0,10);
ActiveDocument.Title = strDocTitle;

]]></MACRO>

<MACRO name="File_SaveAs" lang="JScript" hide="true"><![CDATA[

//call the standard 'save as' action without any special logic
ActiveDocument.SaveAs();

//set the value that displays in the document's tab
//this is just an example and you would need to put your own logic in here
//depending on what you want to display
var strDocTitle = ActiveDocument.Name.substr(0,10);
ActiveDocument.Title = strDocTitle;

]]></MACRO>

</MACROS>
« Last Edit: January 13, 2015, 02:09:41 PM by Derek Read » Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2621



WWW
« Reply #7 on: January 13, 2015, 03:03:36 PM »

OK, so File_Save and File_SaveAs are probably overkill for this issue.

Instead of that you can use the following. It is slightly different coding but essentially the same result. In this case the Save() and SaveAs() methods don't need to be called since saving is not being overridden.

Code: (Example -- Manipulating Document Title (Tab Text) On Save and SaveAs Events)
<?xml version="1.0"?>
<!DOCTYPE MACROS SYSTEM "macros.dtd">

<MACROS>

<MACRO name="On_Document_Save" lang="JScript" hide="true"><![CDATA[

//set the value that displays in the document's tab
//this is just an example and you would need to put your own logic in here
//depending on what you want to display
var strDocTitle = ActiveDocument.Name.substr(0,10);
ActiveDocument.Title = strDocTitle;

]]></MACRO>

<MACRO name="On_Document_SaveAs" lang="JScript" hide="true"><![CDATA[

//set the value that displays in the document's tab
//this is just an example and you would need to put your own logic in here
//depending on what you want to display
var strDocTitle = ActiveDocument.Name.substr(0,10);
ActiveDocument.Title = strDocTitle;

]]></MACRO>

</MACROS>
Logged
Pages: 1
Print
Jump to: