Is it possible to create a virtual editor in an extension - visual-studio-code

I want to process lots of files in my extension and editors have lots of useful methods that I need to use to process the content of a file with, but I don't want to open each file individually in VSC.
I have been able to read the files I plan on editing but how can I create an editor?
Can this be done?

Have you tried vscode.window.openTextDocument()?
openTextDocument(uri: Uri): Thenable<TextDocument>
Opens a document. Will return early if this document is already open. Otherwise the document is loaded and the didOpen-event fires.
That does not imply showing the editor, which is done with a separate vscode.window.showTextDocument() call, so it should qualify as "virtual".

Related

Persisting data in word document using office add-in

I'm trying to develop word add-in which allows to modify word content. One of the requirement is to select some text and mark it:
change its style (look) - and that is done
Associate that piece of text with some custom/hidden data, ex. an ID.
I want to somehow persist that data within the document, so that:
My add-in can read the document on the start and build a list of 'marked' elements
It should work on different machines - I can create a document on one machine, later open in on other machine, and add-in should be able to retrieve that data.
So far I tried to persist that data by first, getting data as HTML, and add attributes to tags, but that didn't work.
Also tried to add some hidden div, but it was only available during word app lifetime.
Recently, found this link: https://github.com/OfficeDev/Excel-Add-in-JavaScript-PersistCustomSettings , but still it allows to persist data in scope of "browser", so, I assume that on other machine it won't work.
What are my possibilities? Maybe I shouldn't store it within a document, but if not, where?
Developing it using office-js - it should work for both Word 2013 and Word 2016 (so I don't have an access to Word 2016 specific API).
Check out https://dev.office.com/reference/add-ins/shared/settings
The Office JS Settings object allows you to save custom data that persists with the document. It is pretty straight-forward to use. Getting settings is synchronous - saving settings is async. The biggest thing is that you have to remember to call Office.settings.saveAsync() after you have made your changes using Office.settings.set() in order to actually save the changes to the document.
Moreover to Nick's answer which is absolutely correct, you can use "Binding" mechanism.
Bindings are stored in document out-of-the-box, so that, you can access those later at any time.
An example, which fits my needs:
Select some text and click on button in add-in (to call some method)
Call addFromSelectionAsync() method (you can specify an id for it to reference it later)
Access it using getAllAsync() or getByIdAsync() method at any time you need it.
More about it: https://dev.office.com/docs/add-ins/develop/bind-to-regions-in-a-document-or-spreadsheet

Checks before renaming element in Eclipse Application

I'm currently writing an RCP application with custom editors. I'm trying to check if the file that is to be renamed is open in an editor. Using a custom RenameParticipant I can check this and prevent the rename operation, but this happens AFTER the user has entered a new name. I would like the check to happen before. Is this possible?
First, you need to obtain the editors that are opened in your RCP application. Eclipse allows you to do this by means of the following line:
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
Then, you have to check whether your file is opened in one of these editors. To do this, you can iterate the resulting array. Each of the elements of the array is of type IEditorReference. You can get the file that is opened in each editor reference by means of the method getEditorInput().

How to force Word to do a SaveAs on generated document

We have a system where we are generating a report as a Word document (using RDLC).
The report is created in a temporary directory, and then Word is launched to display it to the user.
Word is launched, and the report loaded by:
_wordApplication = (Word.Application)Activator.CreateInstance(Type.GetTypeFromProgID("Word.Application"));
object tempFileNameObj = documentPath;
_wordDocument = _wordApplication.Documents.Open(ref tempFileNameObj);
What I want is to convince Word that this is really a newly created, unsaved file, so it will give the user a SaveAs dialog when they save it (rather than save back to the temporary location).
Ideally, I would like to be able to specify the target directory, and offer a default name.
While the Word is being launched, I can do what I like using Automation, but after Word has been launched, my application will be disconnected from Word, and I would prefer not to leave any macros floating around in the document.
You can rename your .doc file to .dot (Word Template) and if you launch it afterwards, it will create a new File looking exactely like your .doc
If you're not using a macro I believe that the only way to archieve this would be to save the file that they will download be a read-only or user defined template file this way if they wan't to make changes to it they wil have to save it with another name in their computer to save the changes made. If you can use a macro you can archieve more options and even force a save as dialog when the document is opened or when it's closed. I hope this helps as I couldn't find any more information without using a macro.

Network Diagram, Word etc

Making a word document of our network set-up.
We have about 7 servers and I need to include screenshots and other info on each.
Is it possible to have a pic of the server that when clicked will open up another word doc that reveals all of the other info. Can this then be mailed to someone easily?
I think that you should have actually tried to do it in Word before asking. The answer is trivial. For completeness sake:
Right-click on the image, choose "Hyperlink..." from the menu. Select the document you want from the resulting standard file selection dialog.
That's it. Doing ctrl-click on the pickture will open up the document selected though you will probably get a security warning first.
You can also do it from a VBA macro. First select the desired image and then:
ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, Address:= _
"C:\Users\me\Documents\a-document.doc", SubAddress:=""
So you could automate the process of server discovery (or maybe you have the data in a spreadsheet that you could use), adding images and hyperlinks automatically. Probably not worth it for just 7 servers.
I'm not clear what you mean by the last part about emailing. Do you want to email the Master word document or the one opened after clicking on the hyperlink? Either way, Word has a menu option for doing this.
If you are wanting to send the document that is opened from the hyperlink - do you actually need the user to open that document or would you rather email it directly? A simple macro can be written that will ask you for the target email address and send the document directly without having to open it. There are really too many possibilities to write down here - we need more information.

Trying to get along with Interwoven

I am to create a new design (CSS & HTML) for a web site which is created using Interwoven ContentCenter Professional.
Now, I can see the existing files in CMS (Interwoven) but, I can't make changes. My changes are displayed only when I'm in edit mode. Nothing in the live page. I tried to submit, create editions of files but still no good.
How should I create or edit pages in Interwoven CMS?
Thanks.
If you're talking about generic pages, then once you are finished you have to click on the Generate option, then choose a directory and click Finish. Last thing you should do is to choose yeswhen it asks you to Re-generate the page.
What you are trying to do is just creating a new file, not generating a file from TeamSite's Formpublisher. It is just like if you are in Windows Explorer and creating a new file. In order to generate a file from a form entry, you need to be in the templatedata directory, ex: /default/main/branch1/WORKAREA/wa1/templatedata/category/type(on unix) or Y:/default/main/branch1/WORKAREA/wa1/templatedata/category/type (on Windows). There should be a file call datacapture.cfg there. There is another directory called data under the above path which stores your data content record (dcr) that are created from the form. This is the file that you can use to generate which will use the (tpl) file under the presentation directory.