ItEr16S09RFComportamentoGraficoPlanificadorItEr15S12: Recovering keyboard navigation on left pane.
It was lost when TaskDetail left being a macro component.
This commit is contained in:
parent
0f93151dd2
commit
a8ea3911b7
2 changed files with 85 additions and 30 deletions
|
|
@ -3,6 +3,7 @@ package org.zkoss.ganttz;
|
||||||
import java.beans.PropertyChangeEvent;
|
import java.beans.PropertyChangeEvent;
|
||||||
import java.beans.PropertyChangeListener;
|
import java.beans.PropertyChangeListener;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -11,6 +12,8 @@ import org.apache.commons.logging.LogFactory;
|
||||||
import org.zkoss.ganttz.util.TaskBean;
|
import org.zkoss.ganttz.util.TaskBean;
|
||||||
import org.zkoss.util.Locales;
|
import org.zkoss.util.Locales;
|
||||||
import org.zkoss.zk.ui.Component;
|
import org.zkoss.zk.ui.Component;
|
||||||
|
import org.zkoss.zk.ui.event.Event;
|
||||||
|
import org.zkoss.zk.ui.event.EventListener;
|
||||||
import org.zkoss.zk.ui.event.KeyEvent;
|
import org.zkoss.zk.ui.event.KeyEvent;
|
||||||
import org.zkoss.zk.ui.util.GenericForwardComposer;
|
import org.zkoss.zk.ui.util.GenericForwardComposer;
|
||||||
import org.zkoss.zul.Datebox;
|
import org.zkoss.zul.Datebox;
|
||||||
|
|
@ -120,10 +123,6 @@ public class TaskDetail extends GenericForwardComposer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Textbox[] getTextBoxes() {
|
|
||||||
return new Textbox[] { nameBox, startDateTextBox, endDateTextBox };
|
|
||||||
}
|
|
||||||
|
|
||||||
public void focusGoUp(int position) {
|
public void focusGoUp(int position) {
|
||||||
TaskDetail aboveDetail = taskDetailNavigator.getAboveDetail();
|
TaskDetail aboveDetail = taskDetailNavigator.getAboveDetail();
|
||||||
if (aboveDetail != null) {
|
if (aboveDetail != null) {
|
||||||
|
|
@ -136,7 +135,7 @@ public class TaskDetail extends GenericForwardComposer {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void receiveFocus(int position) {
|
public void receiveFocus(int position) {
|
||||||
this.getTextBoxes()[position].focus();
|
this.getTextBoxes().get(position).focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void focusGoDown(int position) {
|
public void focusGoDown(int position) {
|
||||||
|
|
@ -159,8 +158,8 @@ public class TaskDetail extends GenericForwardComposer {
|
||||||
|
|
||||||
public void userWantsToMove(Textbox textbox, KeyEvent keyEvent) {
|
public void userWantsToMove(Textbox textbox, KeyEvent keyEvent) {
|
||||||
Navigation navigation = Navigation.getIntentFrom(keyEvent);
|
Navigation navigation = Navigation.getIntentFrom(keyEvent);
|
||||||
List<Textbox> textBoxSiblingsIncludedItself = getTextBoxSiblingsIncludedItself(textbox);
|
List<Textbox> textBoxes = getTextBoxes();
|
||||||
int position = textBoxSiblingsIncludedItself.indexOf(textbox);
|
int position = textBoxes.indexOf(textbox);
|
||||||
switch (navigation) {
|
switch (navigation) {
|
||||||
case UP:
|
case UP:
|
||||||
focusGoUp(position);
|
focusGoUp(position);
|
||||||
|
|
@ -170,14 +169,14 @@ public class TaskDetail extends GenericForwardComposer {
|
||||||
break;
|
break;
|
||||||
case LEFT:
|
case LEFT:
|
||||||
if (position == 0) {
|
if (position == 0) {
|
||||||
focusGoUp(getTextBoxes().length - 1);
|
focusGoUp(getTextBoxes().size() - 1);
|
||||||
} else {
|
} else {
|
||||||
textBoxSiblingsIncludedItself.get(position - 1).focus();
|
textBoxes.get(position - 1).focus();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case RIGHT:
|
case RIGHT:
|
||||||
if (position < textBoxSiblingsIncludedItself.size() - 1)
|
if (position < textBoxes.size() - 1)
|
||||||
textBoxSiblingsIncludedItself.get(position + 1).focus();
|
textBoxes.get(position + 1).focus();
|
||||||
else {
|
else {
|
||||||
focusGoDown(0);
|
focusGoDown(0);
|
||||||
}
|
}
|
||||||
|
|
@ -187,12 +186,8 @@ public class TaskDetail extends GenericForwardComposer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Textbox> getTextBoxSiblingsIncludedItself(Textbox textbox) {
|
private List<Textbox> getTextBoxes() {
|
||||||
Component parent = textbox.getParent();
|
return Arrays.asList(nameBox, startDateTextBox, endDateTextBox);
|
||||||
List<Component> children = parent.getChildren();
|
|
||||||
List<Textbox> textboxes = Planner.findComponentsOfType(Textbox.class,
|
|
||||||
children);
|
|
||||||
return textboxes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -215,20 +210,36 @@ public class TaskDetail extends GenericForwardComposer {
|
||||||
associatedTextBox.setVisible(true);
|
associatedTextBox.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doAfterCompose(Component component) throws Exception {
|
public void doAfterCompose(Component component) throws Exception {
|
||||||
super.doAfterCompose(component);
|
super.doAfterCompose(component);
|
||||||
component.setVariable("top", this, true);
|
|
||||||
findComponents((Treerow) component);
|
findComponents((Treerow) component);
|
||||||
|
registerListeners();
|
||||||
updateComponents();
|
updateComponents();
|
||||||
taskBean.addFundamentalPropertiesChangeListener(new PropertyChangeListener() {
|
taskBean
|
||||||
|
.addFundamentalPropertiesChangeListener(new PropertyChangeListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void propertyChange(PropertyChangeEvent evt) {
|
public void propertyChange(PropertyChangeEvent evt) {
|
||||||
updateComponents();
|
updateComponents();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerListeners() {
|
||||||
|
registerKeyboardListener(nameBox);
|
||||||
|
registerKeyboardListener(startDateTextBox);
|
||||||
|
registerKeyboardListener(endDateTextBox);
|
||||||
|
|
||||||
|
registerOnEnterListener(startDateTextBox);
|
||||||
|
registerOnEnterListener(endDateTextBox);
|
||||||
|
|
||||||
|
registerBlurListener(startDateBox);
|
||||||
|
registerBlurListener(endDateBox);
|
||||||
|
|
||||||
|
registerOnChange(nameBox);
|
||||||
|
registerOnChange(startDateBox);
|
||||||
|
registerOnChange(endDateBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void findComponents(Treerow row) {
|
private void findComponents(Treerow row) {
|
||||||
|
|
@ -255,6 +266,37 @@ public class TaskDetail extends GenericForwardComposer {
|
||||||
nameBox = (Textbox) treecell.getChildren().get(0);
|
nameBox = (Textbox) treecell.getChildren().get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void registerKeyboardListener(final Textbox textBox) {
|
||||||
|
textBox.addEventListener("onCtrlKey", new EventListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEvent(Event event) throws Exception {
|
||||||
|
userWantsToMove(textBox, (KeyEvent) event);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerOnChange(Component component) {
|
||||||
|
component.addEventListener("onChange", new EventListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEvent(Event event) throws Exception {
|
||||||
|
updateBean();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerOnEnterListener(final Textbox textBox) {
|
||||||
|
textBox.addEventListener("onOK", new EventListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEvent(Event event) throws Exception {
|
||||||
|
userWantsDateBox(textBox);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private void findComponentsForStartDateCell(Treecell treecell) {
|
private void findComponentsForStartDateCell(Treecell treecell) {
|
||||||
startDateTextBox = findTextBoxOfCell(treecell);
|
startDateTextBox = findTextBoxOfCell(treecell);
|
||||||
startDateBox = findDateBoxOfCell(treecell);
|
startDateBox = findDateBoxOfCell(treecell);
|
||||||
|
|
@ -265,6 +307,16 @@ public class TaskDetail extends GenericForwardComposer {
|
||||||
endDateTextBox = findTextBoxOfCell(treecell);
|
endDateTextBox = findTextBoxOfCell(treecell);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void registerBlurListener(final Datebox datebox) {
|
||||||
|
datebox.addEventListener("onBlur", new EventListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEvent(Event event) throws Exception {
|
||||||
|
dateBoxHasLostFocus(datebox);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public void updateBean() {
|
public void updateBean() {
|
||||||
if (getEndDateBox().getValue().before(getStartDateBox().getValue())) {
|
if (getEndDateBox().getValue().before(getStartDateBox().getValue())) {
|
||||||
updateComponents();
|
updateComponents();
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,16 @@
|
||||||
<treerow sclass="taskdetail_grid">
|
<treerow sclass="taskdetail_grid">
|
||||||
|
<zscript><![CDATA[
|
||||||
|
]]>
|
||||||
|
</zscript>
|
||||||
<treecell>
|
<treecell>
|
||||||
<textbox ctrlKeys="#down#up#right#left" onCtrlKey="top.userWantsToMove(self,event);" value="" onChange="top.updateBean();" class="task_title"/>
|
<textbox ctrlKeys="#down#up#right#left" class="task_title"/>
|
||||||
</treecell>
|
</treecell>
|
||||||
<treecell>
|
<treecell>
|
||||||
<textbox value="" ctrlKeys="#down#up#right#left" onCtrlKey="top.userWantsToMove(self,event);" onChange="top.updateBean();" onOK="top.userWantsDateBox(self);" />
|
<textbox value="" ctrlKeys="#down#up#right#left" />
|
||||||
<datebox compact="true" onChange="top.updateBean();" visible="${false}" onBlur="top.dateBoxHasLostFocus(self);"/>
|
<datebox compact="true" visible="${false}"/>
|
||||||
</treecell>
|
</treecell>
|
||||||
<treecell>
|
<treecell>
|
||||||
<textbox ctrlKeys="#down#up#right#left" onCtrlKey="top.userWantsToMove(self,event);" value="" onChange="top.updateBean();" onOK="top.userWantsDateBox(self);"/>
|
<textbox ctrlKeys="#down#up#right#left" />
|
||||||
<datebox compact="true" onChange="top.updateBean();" visible ="${false}" onBlur="top.dateBoxHasLostFocus(self);" ctrlKeys="#down" onCtrlKey="top.userWantsDateBox(self)"/>
|
<datebox compact="true" visible ="${false}"/>
|
||||||
</treecell>
|
</treecell>
|
||||||
</treerow>
|
</treerow>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue