Paste Data: Difference between revisions

From Planimate Knowledge Base
Jump to navigation Jump to search
m (Created page with "=== Copying and Pasting Behaviour<br> === A range of cells can be selected and copied either using the "Copy" context menu option or Ctrl-C.<br> For pasting, the context m...")
 
No edit summary
Line 1: Line 1:
=== Copying and Pasting Behaviour<br> ===
== Copying and Pasting Behaviour<br> ==


A range of cells can be selected and copied either using the "Copy"&nbsp;context menu option or Ctrl-C.<br>
A range of cells can be selected and copied either using the "Copy"&nbsp;context menu option or Ctrl-C.<br>  


For pasting, the context menu has options for Paste Over, Paste Insert and Paste Append. These all operate from the selected cell (the column for Paste Append) or top left of a selected region if the selected cell is within it. Ctrl-V&nbsp;acs as the Paste Over.<br>
For pasting, the context menu has options for Paste Over, Paste Insert and Paste Append. These all operate from the selected cell (the column for Paste Append) or top left of a selected region if the selected cell is within it. Ctrl-V&nbsp;acs as the Paste Over.<br>  


Paste Insert inserts rows at the target row for the pasted data. Paste Append adds rows to the bottom of the table. These two options are not available if the table option "User Cannot Add/Delete Rows"&nbsp;is set, only Paste Over existing cells is possible.<br>
Paste Insert inserts rows at the target row for the pasted data. Paste Append adds rows to the bottom of the table. These two options are not available if the table option "User Cannot Add/Delete Rows"&nbsp;is set, only Paste Over existing cells is possible.<br>  


Paste Over ignores columns past the last table column. If you are creating a table in Planimate you could use the "Import From Clipboard"&nbsp;option in the Table Editor File Menu. This is a data import tool that can create table columns and is not being discussed here.<br>
Paste Over ignores columns past the last table column. If you are creating a table in Planimate you could use the "Import From Clipboard"&nbsp;option in the Table Editor File Menu. This is a data import tool that can create table columns and is not being discussed here.<br>  


Pate Over automatically appends rows if the pasted data extends paste the last row in the table unless the "User Cannot Add/Delete Rows"&nbsp;is set for the table.<br>
Paste Over automatically appends rows if the pasted data extends paste the last row in the table unless the "User Cannot Add/Delete Rows"&nbsp;is set for the table.<br>  


Any columns with the "Protect From Edits" column option set are silently skipped during a paste, retaining their existing value. Newly added rows get the clear value for such columns. If all columns are set to "Protect From Edits"&nbsp;then a Paste OVer is effectively ignored.<br>
Any columns with the "Protect From Edits" column option set are silently skipped during a paste, retaining their existing value. Newly added rows get the clear value for such columns. If all columns are set to "Protect From Edits"&nbsp;then a Paste OVer is effectively ignored.<br>  


Copying and pasting honours views with custom column formats/arrangements and row filters. You can paste over row filtered data but Planimate will not insert or append rows whilst there is a row filt<br>
Copying and pasting honours views with custom column formats/arrangements and row filters. You can paste over row filtered data but Planimate will not insert or append rows whilst there is a row filt<br>  


=== Memory vs Clipboard Paste<br> ===
== Memory vs Clipboard Paste<br> ==


Data in the table editor and table views can be copy/pasted within Planimate, between instances of Planimate with different models and between Planimate and other applications such as spreadsheets.<br>
Data in the table editor and table views can be copy/pasted within Planimate, between instances of Planimate with different models and between Planimate and other applications such as spreadsheets.<br>  


When data is copy/pasted within an instance of Planimate, an "in-memory copy" is made, generally the underlying data is copied exactly as represented. This preserves precision even for display formats that truncate the displayed data, do not show years etc.<br>
When data is copy/pasted within an instance of Planimate, an "in-memory copy" is made, generally the underlying data is copied exactly as represented. This preserves precision even for display formats that truncate the displayed data, do not show years etc.<br>  


In cases where another application is active then Planimate is selected, the clipboard is used for pasting. It might well be the same data that was previously copied in that Planimate instance, eg:<br>
In cases where another application is active then Planimate is selected, the clipboard is used for pasting. It might well be the same data that was previously copied in that Planimate instance, eg:<br>  


*you copy some data from a table<br>
*you copy some data from a table<br>  
*you switch to another program<br>
*you switch to another program<br>  
*you switch back to Planimate and paste<br>
*you switch back to Planimate and paste<br>


Copying via the clipboard is especially useful when a user pastes data from a spreadsheet. Some of Planimate's display formats are not clipboard friendly as they may hide seconds, minutes, the date or even the year, making their textual form only useful for reports, not actually useable date data input.
Copying via the clipboard is especially useful when a user pastes data from a spreadsheet. Some of Planimate's display formats are not clipboard friendly as they may hide seconds, minutes, the date or even the year, making their textual form only useful for reports, not actually useable date data input.  


For a developer, copy/pasting such data is not a problem so long as you copy and paste within an instance of Planimate without switching to another application in between.
For a developer, copy/pasting such data is not a problem so long as you copy and paste within an instance of Planimate without switching to another application in between.  


=== Special Paste Handling ===
== Special Paste Handling ==


==== Scaled Units ====
=== Scaled Units ===


To keep consistent with the clipboard, pasting between scaled columns such as "Time Hours (scaled)", "Time Minutes (scaled)"&nbsp;and other unscaled columns such as "Units"&nbsp;always copies the numbers as displayed, even when it is a memory copy.
To keep consistent with the clipboard, pasting between scaled columns such as "Time Hours (scaled)", "Time Minutes (scaled)"&nbsp;and other unscaled columns such as "Units"&nbsp;always copies the numbers as displayed, even when it is a memory copy.  


==== Text Columns ====
=== Text Columns ===


In-memory pasting from a non text column (values, times, labels)&nbsp;into a "Text" formatted column will paste the formatted original cell as text. This is particularly useful for converting labels into pure text.
In-memory pasting from a non text column (values, times, labels)&nbsp;into a "Text" formatted column will paste the formatted original cell as text. This is particularly useful for converting labels into pure text.  


In-memory pasting from a "Text"&nbsp;formatted column into any other format will attempt to interpret the text as the destination format, be it numbers, dates or labels - ie:&nbsp;you can use this to convert text into labels.
In-memory pasting from a "Text"&nbsp;formatted column into any other format will attempt to interpret the text as the destination format, be it numbers, dates or labels - ie:&nbsp;you can use this to convert text into labels.  


The above two cases are consistent with what would happen via the clipboard since there is no distinction between text and no text cells apart from enclosing quotes which are removed upon paste.
The above two cases are consistent with what would happen via the clipboard since there is no distinction between text and no text cells apart from enclosing quotes which are removed upon paste.  


==== Pasting Into Dates ====
=== Pasting Into Dates ===


Planimate is quite generous when pasting into date formatted columns, if the format of the column fails to parse pasted text, Planimate will try each of the main classes of calendar time format that it supports, including the default operating system data format.
Planimate is quite generous when pasting into date formatted columns, if the format of the column fails to parse pasted text, Planimate will try each of the main classes of calendar time format that it supports, including the default operating system data format.  


However if dealing with purely numerical US&nbsp;month/date/year data, it is strongly advised that the desination column be correctly formatted for such US&nbsp;dates as the defaults for date/month/year could easily misinterpret such data. Using named months will avoid this problem.
However if dealing with purely numerical US&nbsp;month/date/year data, it is strongly advised that the desination column be correctly formatted for such US&nbsp;dates as the defaults for date/month/year could easily misinterpret such data. Using named months will avoid this problem.  


If a cell does not parse as a date its logged as an error and the paste continues.
If a cell does not parse as a date its logged as an error and the paste continues.  


==== Units and Times ====
=== Units and Times ===


Planimate first tries the format of the column to parse pasted data. If this fails, it will use simple heuristics (the "autoparser")&nbsp;to look for money, commas and hh:mm / hh:mm:ss type times and paste the value into the cell, with times being converted to seconds as is standard for most time formats (apart from the scaled ones mentioned above). If the autoparser fails, the cell is logged as an error.
Planimate first tries the format of the column to parse pasted data. If this fails, it will use simple heuristics (the "autoparser")&nbsp;to look for money, commas and hh:mm / hh:mm:ss type times and paste the value into the cell, with times being converted to seconds as is standard for most time formats (apart from the scaled ones mentioned above). If the autoparser fails, the cell is logged as an error.  


==== Labels ====
=== Labels ===


Label formatted columns automatically add new labels if the user can add labels into that column, otherwise they are logged as errors.
Label formatted columns automatically add new labels if the user can add labels into that column, otherwise they are logged as errors.  


== Error Handling<br>  ==


Paste errors are not reported cell by cell, a count is kept and they are collected into a log file.


If the model is stopped and the user has the ability to edit (ie:&nbsp;not a PBA) then if errors occur, a dialog reports how many and offers the option to show the log file, which will be opened in the default text editor, typically notepad.<br>


If the model is "ready" (not stopped)&nbsp;then pasting always sends a new broadcast, "_Pasted" which includes attributes:


*"_dataid" :&nbsp;table data object ID if set, or zero
*"_panel"&nbsp; :&nbsp;panel ID of the table's panel
*"_errorcount" :&nbsp;how many errors occured.


If _errorcount is &gt; 0 then s.LastErrorFileNamePath is the error log filename. A trivial handler might just show this file in notepad regardless of the table (given the user has just pasted into it). This file will persist in TEMP, the modeller can delete it if desired.


If table data is copied within the same Planimate and directly
=== Error Log File Format ===


pasted, an 'in-memory' paste of the cell values/text is<br> performed, this means a binary copy of the cell data with the<br> resulting display depending on the format of the cell.<br> This is indicated in the context menu by the dimensions of the<br> data being displayed.
The error log file contains 4 columns, these are:


If you switch tasks away and back to Planimate, pasting occurs<br> via the Windows clipboard. Text data in the clipboard is<br> interpreted according to the format of the cells, with some <br> fallback to basic defaults. For date formatted cells, it <br> attempts to interpret with all the supported date formats.<br> Pasting via clipboard is indicated in the context menu by <br> "(clipboard)" being shown instead of dimensions. This size<br> isn't shown as arbitrarily processing the clipboard (which may<br> contain text the user never intends to paste) would make<br> the UI laggy.
*row iof actual table celll
*column of actual table cell
*error code, from the '''l._import_errors''' label list
*the text which caused the problem, in quotes


- Label List Import Errors <br> - "logged errors" error state<br> - protected cells are skipped<br> paste bc<br>
== Routine operation PasteIntoView ==


<br>table paste handling code. Now supports pasting<br> of arbitrary selected regions at any point in a table. Features<br> include:<br> - works with Ctrl-V or table view context menu. Ctrl-V broadcast<br> is no longer sent and is redundant<br> - auto append of rows as needed unless user cannot append rows<br> to the table in which case only existing rows are altered<br> - supports customised column views and pasting over filtered rows<br> - extra columns are ignored (future version may give more options)<br> - does not stop on error, paste everything it can<br> - auto adds labels if user can do so<br> - can insert or paste over existing rows at any column<br> - can append new rows at entire row or column 1<br> - for copy/paste within an instance of Planimate with it staying<br> active, in-memory paste is performed. If you alt-tab to<br> another application, it pastes via clipboard.<br><br>
Combined with a Ctrl-V&nbsp;key handler, this used to be the way that applications supported pasting into a table. This is still supported however:
 
*do not expect to receive the Ctrl-V&nbsp;key broadcast, this is no longer supported
*The error log file described above is written on errors however no return result is set, instead you receive a new error code l._import_errors[Logged Errors] which indicates that at least one error occured.
*Unless the option IgnoreErrors was included to the operation, the import will stop after the first error and you get the code back for the actual error.


[[Category:Table]]
[[Category:Table]]

Revision as of 15:13, 23 April 2015

Copying and Pasting Behaviour

A range of cells can be selected and copied either using the "Copy" context menu option or Ctrl-C.

For pasting, the context menu has options for Paste Over, Paste Insert and Paste Append. These all operate from the selected cell (the column for Paste Append) or top left of a selected region if the selected cell is within it. Ctrl-V acs as the Paste Over.

Paste Insert inserts rows at the target row for the pasted data. Paste Append adds rows to the bottom of the table. These two options are not available if the table option "User Cannot Add/Delete Rows" is set, only Paste Over existing cells is possible.

Paste Over ignores columns past the last table column. If you are creating a table in Planimate you could use the "Import From Clipboard" option in the Table Editor File Menu. This is a data import tool that can create table columns and is not being discussed here.

Paste Over automatically appends rows if the pasted data extends paste the last row in the table unless the "User Cannot Add/Delete Rows" is set for the table.

Any columns with the "Protect From Edits" column option set are silently skipped during a paste, retaining their existing value. Newly added rows get the clear value for such columns. If all columns are set to "Protect From Edits" then a Paste OVer is effectively ignored.

Copying and pasting honours views with custom column formats/arrangements and row filters. You can paste over row filtered data but Planimate will not insert or append rows whilst there is a row filt

Memory vs Clipboard Paste

Data in the table editor and table views can be copy/pasted within Planimate, between instances of Planimate with different models and between Planimate and other applications such as spreadsheets.

When data is copy/pasted within an instance of Planimate, an "in-memory copy" is made, generally the underlying data is copied exactly as represented. This preserves precision even for display formats that truncate the displayed data, do not show years etc.

In cases where another application is active then Planimate is selected, the clipboard is used for pasting. It might well be the same data that was previously copied in that Planimate instance, eg:

  • you copy some data from a table
  • you switch to another program
  • you switch back to Planimate and paste

Copying via the clipboard is especially useful when a user pastes data from a spreadsheet. Some of Planimate's display formats are not clipboard friendly as they may hide seconds, minutes, the date or even the year, making their textual form only useful for reports, not actually useable date data input.

For a developer, copy/pasting such data is not a problem so long as you copy and paste within an instance of Planimate without switching to another application in between.

Special Paste Handling

Scaled Units

To keep consistent with the clipboard, pasting between scaled columns such as "Time Hours (scaled)", "Time Minutes (scaled)" and other unscaled columns such as "Units" always copies the numbers as displayed, even when it is a memory copy.

Text Columns

In-memory pasting from a non text column (values, times, labels) into a "Text" formatted column will paste the formatted original cell as text. This is particularly useful for converting labels into pure text.

In-memory pasting from a "Text" formatted column into any other format will attempt to interpret the text as the destination format, be it numbers, dates or labels - ie: you can use this to convert text into labels.

The above two cases are consistent with what would happen via the clipboard since there is no distinction between text and no text cells apart from enclosing quotes which are removed upon paste.

Pasting Into Dates

Planimate is quite generous when pasting into date formatted columns, if the format of the column fails to parse pasted text, Planimate will try each of the main classes of calendar time format that it supports, including the default operating system data format.

However if dealing with purely numerical US month/date/year data, it is strongly advised that the desination column be correctly formatted for such US dates as the defaults for date/month/year could easily misinterpret such data. Using named months will avoid this problem.

If a cell does not parse as a date its logged as an error and the paste continues.

Units and Times

Planimate first tries the format of the column to parse pasted data. If this fails, it will use simple heuristics (the "autoparser") to look for money, commas and hh:mm / hh:mm:ss type times and paste the value into the cell, with times being converted to seconds as is standard for most time formats (apart from the scaled ones mentioned above). If the autoparser fails, the cell is logged as an error.

Labels

Label formatted columns automatically add new labels if the user can add labels into that column, otherwise they are logged as errors.

Error Handling

Paste errors are not reported cell by cell, a count is kept and they are collected into a log file.

If the model is stopped and the user has the ability to edit (ie: not a PBA) then if errors occur, a dialog reports how many and offers the option to show the log file, which will be opened in the default text editor, typically notepad.

If the model is "ready" (not stopped) then pasting always sends a new broadcast, "_Pasted" which includes attributes:

  • "_dataid" : table data object ID if set, or zero
  • "_panel"  : panel ID of the table's panel
  • "_errorcount" : how many errors occured.

If _errorcount is > 0 then s.LastErrorFileNamePath is the error log filename. A trivial handler might just show this file in notepad regardless of the table (given the user has just pasted into it). This file will persist in TEMP, the modeller can delete it if desired.

Error Log File Format

The error log file contains 4 columns, these are:

  • row iof actual table celll
  • column of actual table cell
  • error code, from the l._import_errors label list
  • the text which caused the problem, in quotes

Routine operation PasteIntoView

Combined with a Ctrl-V key handler, this used to be the way that applications supported pasting into a table. This is still supported however:

  • do not expect to receive the Ctrl-V key broadcast, this is no longer supported
  • The error log file described above is written on errors however no return result is set, instead you receive a new error code l._import_errors[Logged Errors] which indicates that at least one error occured.
  • Unless the option IgnoreErrors was included to the operation, the import will stop after the first error and you get the code back for the actual error.