Context Menu"

From Documentation
m
m (correct highlight (via JWB))
 
(17 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{Template:UnderConstruction}}
+
{{ZKSpreadsheetEssentialsPageHeader}}
 +
 
 +
 
 +
{{Deprecated|url=http://books.zkoss.org/wiki/ZK_Spreadsheet_Essentials}}
  
{{ZKSpreadsheetEssentialsPageHeader}}
 
  
 
__TOC__
 
__TOC__
  
 
===Purpose===
 
===Purpose===
ZK Spreadsheet supports various context menu for user to perform actions.
+
ZK Spreadsheet supports various context menus to support row/column/cell actions for individual or selected number of cells.  
  
 
===Show Context Menu===
 
===Show Context Menu===
Line 15: Line 17:
 
[[File:ZKSsEss_Spreadsheet_Toolbar_rowContextMenu.png]]
 
[[File:ZKSsEss_Spreadsheet_Toolbar_rowContextMenu.png]]
  
Row context menu use [http://books.zkoss.org/wiki/ZK_Spreadsheet_Essentials/Working_with_ZK_Spreadsheet/Configure_and_Control_ZK_Spreadsheet/Toolbar#Action_Handler ActionHandler] for each button/menuitem. Note the default ActionHandler does nothing when user click '''Paste Special''', '''Format Cell''' and '''Row Height'''
+
For <b>row context menu</b> use [http://books.zkoss.org/wiki/ZK_Spreadsheet_Essentials/Working_with_ZK_Spreadsheet/Configure_and_Control_ZK_Spreadsheet/Toolbar#Action_Handler ActionHandler] for each menuitem. By default, <b>ActionHandler</b> does nothing when users clicks on '''Paste Special''', '''Format Cell''' and '''Row Height''',  to use customized <b>ActionHandler</b> <refer to [http://books.zkoss.org/wiki/ZK_Spreadsheet_Essentials/Working_with_ZK_Spreadsheet/Configure_and_Control_ZK_Spreadsheet/Toolbar#Action_Handler here].
  
 
=====Paste Special=====
 
=====Paste Special=====
 
Refer to [http://books.zkoss.org/wiki/ZK_Spreadsheet_Essentials/Working_with_ZK_Spreadsheet/Configure_and_Control_ZK_Spreadsheet/Toolbar#Paste_Special here]
 
Refer to [http://books.zkoss.org/wiki/ZK_Spreadsheet_Essentials/Working_with_ZK_Spreadsheet/Configure_and_Control_ZK_Spreadsheet/Toolbar#Paste_Special here]
 
=====Format Cell=====
 
=====Format Cell=====
The default ActionHandler does nothing when user click the button, developer could override <javadoc directory="zss"  method="doFormatCell">org.zkoss.zss.ui.sys.ActionHandler</javadoc>
+
By default, <b>ActionHandler</b> does nothing when users clicks the button, developer are able to override <javadoc directory="zss"  method="doFormatCell">org.zkoss.zss.ui.sys.ActionHandler</javadoc>
  
<source lang="java" high="2">
+
<source lang="java" highlight="2">
 
@Override
 
@Override
 
public void doFormatCell(Rect selection) {
 
public void doFormatCell(Rect selection) {
 
Spreadsheet spreadsheet = getSpreadsheet();
 
Spreadsheet spreadsheet = getSpreadsheet();
if (spreadsheet.getBook() != null && validSelection(selection)) {
+
if (spreadsheet.getBook() != null && isValidSelection(selection)) {
 
FormatDialog dialog = new FormatDialog(selection);
 
FormatDialog dialog = new FormatDialog(selection);
 
//omit
 
//omit
Line 36: Line 38:
  
 
=====Row Height=====
 
=====Row Height=====
 +
By default, <b>ActionHandler</b> does nothing when users clicks the button, developers are able to override <javadoc directory="zss"  method="doRowHeight">org.zkoss.zss.ui.sys.ActionHandler</javadoc>
  
[[File:ZKSsEss_Spreadsheet_Toolbar_rowContextMenu_rowHeight.png]]
+
<source lang="java" highlight="2">
<br/>The default ActionHandler does nothing when user click the button, developer could override <javadoc directory="zss"  method="doRowHeight">org.zkoss.zss.ui.sys.ActionHandler</javadoc>
 
 
 
<source lang="java" high="2">
 
 
@Override
 
@Override
 
public void doRowHeight(Rect selection) {
 
public void doRowHeight(Rect selection) {
 
Spreadsheet spreadsheet = getSpreadsheet();
 
Spreadsheet spreadsheet = getSpreadsheet();
if (spreadsheet.getBook() != null && validSelection(selection)) {
+
if (spreadsheet.getBook() != null && isValidSelection(selection)) {
 
HeaderSizeDialog dialog = new HeaderSizeDialog("row", selection);
 
HeaderSizeDialog dialog = new HeaderSizeDialog("row", selection);
 
//omit
 
//omit
Line 57: Line 57:
 
[[File:ZKSsEss_Spreadsheet_Toolbar_columnContextMenu.png]]
 
[[File:ZKSsEss_Spreadsheet_Toolbar_columnContextMenu.png]]
  
Column context menu use [http://books.zkoss.org/wiki/ZK_Spreadsheet_Essentials/Working_with_ZK_Spreadsheet/Configure_and_Control_ZK_Spreadsheet/Toolbar#Action_Handler ActionHandler] for each button/menuitem. Note the default ActionHandler does nothing when user click '''Paste Special''', '''Format Cell''' and '''Column Width'''
+
For column context menu use [http://books.zkoss.org/wiki/ZK_Spreadsheet_Essentials/Working_with_ZK_Spreadsheet/Configure_and_Control_ZK_Spreadsheet/Toolbar#Action_Handler ActionHandler] for each button/menuitem. By default, <b>ActionHandler</b> does nothing when users clicks '''Paste Special''', '''Format Cell''' and '''Column Width''', to use customized <b>ActionHandler</b> refer to [http://books.zkoss.org/wiki/ZK_Spreadsheet_Essentials/Working_with_ZK_Spreadsheet/Configure_and_Control_ZK_Spreadsheet/Toolbar#Action_Handler here] .
  
 
=====Paste Special=====
 
=====Paste Special=====
Line 64: Line 64:
 
Refer to [http://books.zkoss.org/wiki/ZK_Spreadsheet_Essentials/Working_with_ZK_Spreadsheet/Configure_and_Control_ZK_Spreadsheet/Context_Menu#Format_Cell here]
 
Refer to [http://books.zkoss.org/wiki/ZK_Spreadsheet_Essentials/Working_with_ZK_Spreadsheet/Configure_and_Control_ZK_Spreadsheet/Context_Menu#Format_Cell here]
 
=====Column Width=====
 
=====Column Width=====
 +
By default, <b>ActionHandler</b> does nothing when user click the button, developers are able to override <javadoc directory="zss"  method="doColumnWidth">org.zkoss.zss.ui.sys.ActionHandler</javadoc>
  
[[File:ZKSsEss_Spreadsheet_Toolbar_rowContextMenu_columnWidth.png]]
+
<source lang="java" highlight="2">
<br/>The default ActionHandler does nothing when user click the button, developer could override <javadoc directory="zss"  method="doColumnWidth">org.zkoss.zss.ui.sys.ActionHandler</javadoc>
 
 
 
<source lang="java" high="2">
 
 
@Override
 
@Override
 
public void doColumnWidth(Rect selection) {
 
public void doColumnWidth(Rect selection) {
 
Spreadsheet spreadsheet = getSpreadsheet();
 
Spreadsheet spreadsheet = getSpreadsheet();
if (spreadsheet.getBook() != null && validSelection(selection)) {
+
if (spreadsheet.getBook() != null && isValidSelection(selection)) {
 
HeaderSizeDialog dialog = new HeaderSizeDialog("column", selection);
 
HeaderSizeDialog dialog = new HeaderSizeDialog("column", selection);
 
//omit
 
//omit
Line 85: Line 83:
 
[[File:ZKSsEss_Spreadsheet_Toolbar_cellContextMenu.png]]
 
[[File:ZKSsEss_Spreadsheet_Toolbar_cellContextMenu.png]]
  
Cell context menu use [http://books.zkoss.org/wiki/ZK_Spreadsheet_Essentials/Working_with_ZK_Spreadsheet/Configure_and_Control_ZK_Spreadsheet/Toolbar#Action_Handler ActionHandler] for each button/menuitem. Note the default ActionHandler does nothing when user click '''Paste Special''', '''Format Cell''' and '''Hyperlink'''
+
For cell context menu, use [http://books.zkoss.org/wiki/ZK_Spreadsheet_Essentials/Working_with_ZK_Spreadsheet/Configure_and_Control_ZK_Spreadsheet/Toolbar#Action_Handler ActionHandler] for each button/menuitem. By default, <b>ActionHandler</b> does nothing when users click '''Paste Special''', '''Format Cell''' and '''Hyperlink''', to use customized <b>ActionHandler</b> refer to [http://books.zkoss.org/wiki/ZK_Spreadsheet_Essentials/Working_with_ZK_Spreadsheet/Configure_and_Control_ZK_Spreadsheet/Toolbar#Action_Handler here].
  
 
=====Paste Special=====
 
=====Paste Special=====
Line 93: Line 91:
 
=====Hyperlink=====
 
=====Hyperlink=====
 
Refer to [http://books.zkoss.org/wiki/ZK_Spreadsheet_Essentials/Working_with_ZK_Spreadsheet/Configure_and_Control_ZK_Spreadsheet/Toolbar#Hyperlink here]
 
Refer to [http://books.zkoss.org/wiki/ZK_Spreadsheet_Essentials/Working_with_ZK_Spreadsheet/Configure_and_Control_ZK_Spreadsheet/Toolbar#Hyperlink here]
 +
 +
====I18N====
 +
Each menuitem maps to a key, developers can browse all I18 keys by <javadoc directory="zss"  method="getLabelKeys">org.zkoss.zss.ui.Action</javadoc>
 +
 +
Here are the partial keys for context menu
 +
{| border="1"
 +
|-
 +
! Action  || I18 Key
 +
|-
 +
|| Cut || zss.cut
 +
|-
 +
|| Copy || zss.copy
 +
|-
 +
|| Paste Special || zss.pasteSpecial
 +
|-
 +
|| Insert || zss.insert
 +
|-
 +
|| Insert Rows || zss.insertSheetRow
 +
|-
 +
|| Insert Columns || zss.insertSheetColumn
 +
|-
 +
|| Shift Cell Right || zss.shiftCellRight
 +
|-
 +
|| Shift Cell Down || zss.shiftCellDown
 +
|-
 +
|| Delete || zss.del
 +
|-
 +
|| Delete Rows || zss.deleteSheetRow
 +
|-
 +
|| Delete Columns || zss.deleteSheetColumn
 +
|-
 +
|| Shift Cell Left || zss.shiftCellLeft
 +
|-
 +
|| Shift Cell Up || zss.shiftCellUp
 +
|-
 +
|| Clear Context || zss.clearContent
 +
|-
 +
|| Format Cell || zss.formatCell
 +
|-
 +
|| Row Height || zss.rowHeight
 +
|-
 +
|| Column Width || zss.columnWidth
 +
|-
 +
|| Hide Row || zss.hideRow
 +
|-
 +
|| Unhide Row || zss.unhideRow
 +
|-
 +
|| Hide Column || zss.hideColumn
 +
|-
 +
|| Unhide Column || zss.unhideColumn
 +
|-
 +
|| Filter || zss.filter
 +
|-
 +
|| Reapply Filter || zss.reapplyFilter
 +
|-
 +
|| Sort || zss.sort
 +
|-
 +
|| Sort Ascending || zss.sortAscending
 +
|-
 +
|| Sort Descending|| zss.sortDescending
 +
|-
 +
|| Custom Sort|| zss.customSort
 +
|-
 +
|| Hyperlink || zss.hyperlink
 +
|}
 +
 +
Refer to sample [http://code.google.com/p/zkbooks/source/browse/trunk/zssessentials/examples/WebContent/WEB-INF/i3-label.properties i3-label.properties]
  
 
===ZUML===
 
===ZUML===
Here is a sample example ZUL file
+
Here is an example of a ZUL file
  
<source lang="xml" high="4">
+
<source lang="xml" highlight="4">
 
<zk>
 
<zk>
 
<window vflex="1" width="100%" apply="org.zkoss.zssessentials.config.ContextMenuComposer">
 
<window vflex="1" width="100%" apply="org.zkoss.zssessentials.config.ContextMenuComposer">
Line 108: Line 173:
 
</zk>
 
</zk>
 
</source>
 
</source>
 +
 +
View complete source of ZUML [https://code.google.com/p/zkbooks/source/browse/trunk/zssessentials/examples/WebContent/config/contextMenu.zul contextMenu.zul]
  
 
===Composer===
 
===Composer===
The composer use <javadoc directory="zss"  method="setShowContextMenu">org.zkoss.zss.ui.Spreadsheet</javadoc> to show or hide context menu.
+
The composer uses <javadoc directory="zss"  method="setShowContextMenu">org.zkoss.zss.ui.Spreadsheet</javadoc> to show or hide context menu.
<source lang="java" high="3">
+
<source lang="java" highlight="3">
 
public void onClick$toggleContextMenu() {
 
public void onClick$toggleContextMenu() {
 
boolean toggle = !spreadsheet.isShowContextMenu();
 
boolean toggle = !spreadsheet.isShowContextMenu();

Latest revision as of 12:55, 19 January 2022



Stop.png This article is out of date, please refer to http://books.zkoss.org/wiki/ZK_Spreadsheet_Essentials for more up to date information.


Purpose

ZK Spreadsheet supports various context menus to support row/column/cell actions for individual or selected number of cells.

Show Context Menu

Use Spreadsheet.setShowContextMenu to show context menu.

Row

ZKSsEss Spreadsheet Toolbar rowContextMenu.png

For row context menu use ActionHandler for each menuitem. By default, ActionHandler does nothing when users clicks on Paste Special, Format Cell and Row Height, to use customized ActionHandler <refer to here.

Paste Special

Refer to here

Format Cell

By default, ActionHandler does nothing when users clicks the button, developer are able to override ActionHandler.doFormatCell

	@Override
	public void doFormatCell(Rect selection) {
		Spreadsheet spreadsheet = getSpreadsheet();
		if (spreadsheet.getBook() != null && isValidSelection(selection)) {
			FormatDialog dialog = new FormatDialog(selection);
			//omit	
		}
	}

Refer to sample code formatDialog.zul and CustomizedActionHandler.java

Row Height

By default, ActionHandler does nothing when users clicks the button, developers are able to override ActionHandler.doRowHeight

	@Override
	public void doRowHeight(Rect selection) {
		Spreadsheet spreadsheet = getSpreadsheet();
		if (spreadsheet.getBook() != null && isValidSelection(selection)) {
			HeaderSizeDialog dialog = new HeaderSizeDialog("row", selection);
			//omit	
		}
	}

Refer to sample code headerSizeDialog.zul and CustomizedActionHandler.java

Column

ZKSsEss Spreadsheet Toolbar columnContextMenu.png

For column context menu use ActionHandler for each button/menuitem. By default, ActionHandler does nothing when users clicks Paste Special, Format Cell and Column Width, to use customized ActionHandler refer to here .

Paste Special

Refer to here

Format Cell

Refer to here

Column Width

By default, ActionHandler does nothing when user click the button, developers are able to override ActionHandler.doColumnWidth

	@Override
	public void doColumnWidth(Rect selection) {
		Spreadsheet spreadsheet = getSpreadsheet();
		if (spreadsheet.getBook() != null && isValidSelection(selection)) {
			HeaderSizeDialog dialog = new HeaderSizeDialog("column", selection);
			//omit
		}
	}

Refer to sample code headerSizeDialog.zul and CustomizedActionHandler.java

Cell

ZKSsEss Spreadsheet Toolbar cellContextMenu.png

For cell context menu, use ActionHandler for each button/menuitem. By default, ActionHandler does nothing when users click Paste Special, Format Cell and Hyperlink, to use customized ActionHandler refer to here.

Paste Special

Refer to here

Format Cell

Refer to here

Hyperlink

Refer to here

I18N

Each menuitem maps to a key, developers can browse all I18 keys by Action.getLabelKeys

Here are the partial keys for context menu

Action I18 Key
Cut zss.cut
Copy zss.copy
Paste Special zss.pasteSpecial
Insert zss.insert
Insert Rows zss.insertSheetRow
Insert Columns zss.insertSheetColumn
Shift Cell Right zss.shiftCellRight
Shift Cell Down zss.shiftCellDown
Delete zss.del
Delete Rows zss.deleteSheetRow
Delete Columns zss.deleteSheetColumn
Shift Cell Left zss.shiftCellLeft
Shift Cell Up zss.shiftCellUp
Clear Context zss.clearContent
Format Cell zss.formatCell
Row Height zss.rowHeight
Column Width zss.columnWidth
Hide Row zss.hideRow
Unhide Row zss.unhideRow
Hide Column zss.hideColumn
Unhide Column zss.unhideColumn
Filter zss.filter
Reapply Filter zss.reapplyFilter
Sort zss.sort
Sort Ascending zss.sortAscending
Sort Descending zss.sortDescending
Custom Sort zss.customSort
Hyperlink zss.hyperlink

Refer to sample i3-label.properties

ZUML

Here is an example of a ZUL file

<zk>
	<window vflex="1" width="100%" apply="org.zkoss.zssessentials.config.ContextMenuComposer">
		<button id="toggleContextMenu" label="Toggle Context Menu"/>
		<spreadsheet showContextMenu="true"
			id="ss" vflex="true" width="100%"
			src="/WEB-INF/excel/config/ZSS-demo_sample.xlsx" maxcolumns="40" maxrows="200"
			></spreadsheet>
	</window>
</zk>

View complete source of ZUML contextMenu.zul

Composer

The composer uses Spreadsheet.setShowContextMenu to show or hide context menu.

	public void onClick$toggleContextMenu() {
		boolean toggle = !spreadsheet.isShowContextMenu();
		spreadsheet.setShowContextMenu(toggle);
	}

See the full source code for Composer here

Version History

Last Update : 2022/01/19


Version Date Content
2.3.0 April, 2012 Context Menu
     


All source code listed in this book is at Github.


Last Update : 2022/01/19

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.