I need help to implement Cut command for Nattable - nattable

I have try DeleteSelectionHandler with copy command.It works but paste is not working.Copy and paste is working fine.But when i have used Cut( Copy,Delete).Cut works fine but not able to paste data.

This does not work with the existing functionalities in NatTable. Copy + Paste is working internally with cell references. That means when you delete the content in one cell, the stored reference is containing no data anymore that can be copied. For Cut + Paste you need to implement some mechanism that takes the data from the clipboard and prepares is back for pasting again. Similar task to perform when trying to do a copy paste action between different NatTable instances.
For those use cases you always need to work with the clipboard and handle the data there. And that handling is always dependent on your table structure. For example if you have different data types per column, cut + paste could cause data conversion exceptions.

Related

`onDidChangeTextDocument` not triggering after `applyEdit`

I am creating a VS Code extension for editing text files, and based my project off the docs and Cat Customs example.
I currently have a minimal working example that uses a contenteditable div as a text editor to edit *.txt files. Similar to the Cat Customs sample, I use a CustomTextEditorProvider that connects to a Webview containing the editor, and use postMessage to update the document when the Webview text is changed, and then refresh the Webview to match the document if the document is saved. I am also logging occurrences of onDidChangeTextDocument which demonstrates my problem...
My problem is that if I type characters in the editor very quickly, my Webview sends a postMessage for every character and each triggers a corresponding applyEdit call, but many of these applyEdit calls don't seem to actually update the document model. I see the onDidChangeTextDocument event doesn't occur for many of them, and when I hit Ctrl+S to save my document it is missing updates from the latest applyEdit calls.
These are the two files that define everything I described above:
CustomTextEditorProvider : https://github.com/adamerose/markdown-editor/blob/master/src/textEditor.ts
Webview: https://github.com/adamerose/markdown-editor/blob/master/media/textEditorInitScript.js
Video example: https://www.screencast.com/t/tDa1XtqoUAyj
I type asdf slowly and it works fine, then I type 4321 very quickly and the last 2 characters don't trigger onDidChangeTextDocument so when I save it reverts to 43
Here are some related issues but still couldn't solve my problem after reading them:
https://github.com/microsoft/vscode/issues/111331
https://github.com/microsoft/vscode/issues/48908

Ag-Grid wrong row orders in clipboard due to custom row node id

Ag-grid's default rowNodeId is an auto-increment number (0,1,2,3,4...)
For my application, I use a custom rowNodeId which is composed of values inside the grid, like: col_x_value + '#' + col_y_value + '#' + col_z_value:
this.gridOptions.getRowNodeId = (data) => {
return myPkColumns
.sort()
.map(pk) => data[pk])
.join('#')
Issue: When I copy rows to excel, the order in which the rows are pasted in Excel is not like the order I see on the grid.
The order does not seem to follow custom row node id neither..
One solution I have in mind is to use the default rowNodeId + a non-visible column to store the custom id. But this means I need to loop through the grid every time I need to find a specific row.
Any better solutions? Thanks
A possible solution I could think of is implementing callback sendToClipboard(params) so you can control the ordering before sending data to clipboard.
From the docs -
If you want to do the copy to clipboard yourself (ie not use the grids
clipboard interaction) then implement the callback
sendToClipboard(params). Use this if you are in a non-standard web
container that has a bespoke API for interacting with the clipboard.
The callback gets the data to go into the clipboard, it's your job to
call the bespoke API.
Example here

manipulating Microsoft Word DOCX files that have links and track changes using Python

I have been using the excellent python-docx package to read, modify, and write Microsoft Word files. The package supports extracting the text from each paragraph. It also allows accessing a paragraph a "run" at a time, where the run is a set of characters that have the same font information. Unfortunately, when you access a paragraph by runs, you lose the links, because the package does not support links. The package also does not support accessing change tracking information.
My problem is that I need to access change tracking information. Or, more specifically, I need to copy paragraphs that have change tracking indicated from one document to another.
I've tried doing this at the XML level. For example, this code snippet appends the contents of file1.docx to file2.docx:
from docx import Document
doc1 = Document("file1.docx")
doc2 = Document("file2.docx")
doc2.element.body.append(doc1.element.body)
doc2.save("file2-appended.docx")
When I try to open the file on my Mac for complicated files, I get this error:
But if I click OK, the contents are there. The manipulation also works without problem for very simple files.
What am I missing?
The .element attribute is really an "internal" interface and should be named ._element. In most other places I have named it that. What you're getting there is the root element of the document part. You can see what it is by calling:
print(doc2.element.xml)
That element has one and only one w:body element below it, which is what you get when with doc2.element.body (.xml will work on that too, btw, if you want to inspect that element).
What your code is doing is appending one body element at the end of another w:body element and thereby forming invalid XML. The WordprocessingML vocabulary is quite strict about what element can follow another and how many and so forth. The only surprise for me is that it actually sometimes works for you, I take it :)
If you want to manipulate the XML directly, which is what the ._element attribute is there for, you need to do it carefully, in view of the (complex) WordprocessingML XML Schema.
Unlike when you stick to the published API, there's no safety net once ._element (or .element) appears in your code.
Inside the body XML can be relationships to external document parts, like images and hyperlinks. These will only be valid within the document in which they appear. This might explain why some files can be repaired.

Zend Framework Dynamically added fields of a form and populate

I have been attempting to create a form where a user can simply press a button and the form will add a new field for the user to use. I have 2 of these dynamically added field types.
Firstly a field where a user can upload files, by pressing the add button another field is pasted underneath the current field and is ready for use.
I have followed an old guide on how to get this done with a bit of ajax and jQuery.
This guide to be exact: http://www.jeremykendall.net/2009/01/19/dynamically-adding-elements-to-zend-form/
As you can see it's from 2009 and a bit outdated yet it still works under the current Zend Framework version 1.11.11
The problem however arises now that i want an edit / update version of the form. I need to populate it's fields but first of all i need to create enough fields for the data to be stored in. So when there's 3 files that have been uploaded it should create 2 additional fields and place the 3 file names in these fields ready to be edited and updated. Simply using $form->populate($stuff) is not going to work
I just have no idea how to accomplish this and the tutorial on dynamically added fields only goes as far as the addAction and not how to create the editAction under these conditions.
Is there any tutorial out there on how to create and manage forms such as these? I'm sure i am not the only one who's had the idea to builds these kind of forms?
I can add my code if there's a request for it but it's the same as the example from the guide, just a different set of elements in the form.
Adding a small example of it's use.
A user adds an item with 3 files, these files are uploaded along with a filename so in the database it appears like this : File_Id : '1' , File_Name : 'SomeFile' , File_location : 'somewhere/on/my/pc/SomeFile.txt'.
Now the user realizes he forgot a file or wants to delete a file from that list, he goes to the edit page and here i want the form to display the previously added filenames. So if there's 3 files it shows 3 and when there's 2 it shows 2 etc. How do i build a form to dynamically add fields based on the number of uploaded files and then populate them?
Any advice on how to handle this is well appreciated :)
You can make use of the semi-magic setXxx() methods of the form.
Inside the form:
public function setFiles($files) {
foreach ($files as $file) {
$this->addElement(/* add a file element */);
//do other stuff, like decorators to show the file name, etc.
}
}
In your controller:
$files = $model->getFiles();
$form = new Form_EditFiles(array('files' => $files));
By passing an array with key files you will make the form try to call the method named setFiles(), which you have conveniently provided above.
This should push you in the right direction, or so I hope at least.
If I understand you correctly you want to populate file upload fields, which is not possible because of security reasons.
Edit:
You can add Elements inside of the Controller via $form->addElement() (basicly just like the $this->addElement() statements in the Tutorial)

How to use a panel created inside a .fig file by other different .fig file?

I have two distinct files, myguide.fig (and its corresponding mygui.m) which contains the definition of an uitabgroup and the file caract.fig (and its corresponding caract.m) which contains a panel. I call the file caract.m from the file myguide.m and obtain the handle of the panel. Then I change the Parent property of the panel to assign it to one of the tabs of the uitabgroup. I only achieve that this works (setting the Visibility Property of caract.fig off) the first time I run myguide. If I try to run it a second time, I get the error message “Invalid handle object” for the handle of the panel returned. I do not understand what is happening.
Explained here:
http://undocumentedmatlab.com/blog/tab-panels-uitab-and-relatives/
Related articles:
http://undocumentedmatlab.com/blog/uitab-customizations/
http://undocumentedmatlab.com/blog/uitab-colors-icons-images/