Fixed editor width for zk6.

This commit is contained in:
Heng Sin Low 2012-03-05 12:51:50 +08:00
parent 6da3e8a2b8
commit c82793df29
5 changed files with 23 additions and 33 deletions

View File

@ -43,6 +43,7 @@ import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events; import org.zkoss.zk.ui.event.Events;
import org.zkoss.zul.Image; import org.zkoss.zul.Image;
import org.zkoss.zul.Menuitem; import org.zkoss.zul.Menuitem;
import org.zkoss.zul.impl.InputElement;
/** /**
* *
@ -50,7 +51,7 @@ import org.zkoss.zul.Menuitem;
* @date Mar 11, 2007 * @date Mar 11, 2007
* @version $Revision: 0.10 $ * @version $Revision: 0.10 $
*/ */
public abstract class WEditor implements EventListener, PropertyChangeListener public abstract class WEditor implements EventListener<Event>, PropertyChangeListener
{ {
private static final String[] lISTENER_EVENTS = {}; private static final String[] lISTENER_EVENTS = {};
@ -82,6 +83,8 @@ public abstract class WEditor implements EventListener, PropertyChangeListener
protected WEditorPopupMenu popupMenu; protected WEditorPopupMenu popupMenu;
private boolean tableEditor;
public WEditor(Component comp, GridField gridField) { public WEditor(Component comp, GridField gridField) {
this(comp, gridField, -1); this(comp, gridField, -1);
} }
@ -219,13 +222,13 @@ public abstract class WEditor implements EventListener, PropertyChangeListener
{ {
component.addEventListener(event, this); component.addEventListener(event, this);
} }
component.addEventListener(Events.ON_FOCUS, new EventListener() { component.addEventListener(Events.ON_FOCUS, new EventListener<Event>() {
public void onEvent(Event event) throws Exception { public void onEvent(Event event) throws Exception {
hasFocus = true; hasFocus = true;
} }
}); });
component.addEventListener(Events.ON_BLUR, new EventListener() { component.addEventListener(Events.ON_BLUR, new EventListener<Event>() {
public void onEvent(Event event) throws Exception { public void onEvent(Event event) throws Exception {
hasFocus = false; hasFocus = false;
} }
@ -472,7 +475,7 @@ public abstract class WEditor implements EventListener, PropertyChangeListener
//can't stretch bandbox & datebox //can't stretch bandbox & datebox
if (!(getComponent() instanceof Bandbox) && if (!(getComponent() instanceof Bandbox) &&
!(getComponent() instanceof Datebox)) { !(getComponent() instanceof Datebox)) {
String width = "100%"; String width = tableEditor ? "98%" : "100%";
if (getComponent() instanceof Button) { if (getComponent() instanceof Button) {
Button btn = (Button) getComponent(); Button btn = (Button) getComponent();
String zclass = btn.getZclass(); String zclass = btn.getZclass();
@ -485,14 +488,18 @@ public abstract class WEditor implements EventListener, PropertyChangeListener
} }
} else if (getComponent() instanceof Image) { } else if (getComponent() instanceof Image) {
Image image = (Image) getComponent(); Image image = (Image) getComponent();
image.setWidth("48px"); image.setWidth("24px");
image.setHeight("48px"); image.setHeight("24px");
} else {
if (getComponent() instanceof InputElement && !tableEditor) {
((InputElement)getComponent()).setHflex("1");
} else { } else {
((HtmlBasedComponent)getComponent()).setWidth(width); ((HtmlBasedComponent)getComponent()).setWidth(width);
} }
} }
} }
} }
}
public boolean isHasFocus() { public boolean isHasFocus() {
return hasFocus; return hasFocus;
@ -523,6 +530,10 @@ public abstract class WEditor implements EventListener, PropertyChangeListener
} }
} }
public void setTableEditor(boolean b) {
tableEditor = b;
}
/** /**
* @return boolean * @return boolean
*/ */

View File

@ -44,7 +44,7 @@ import org.zkoss.zk.ui.event.Events;
* *
* This class is based on VLocation written by Jorg Janke * This class is based on VLocation written by Jorg Janke
**/ **/
public class WLocationEditor extends WEditor implements EventListener, PropertyChangeListener, ContextMenuListener public class WLocationEditor extends WEditor implements EventListener<Event>, PropertyChangeListener, ContextMenuListener
{ {
private static final String[] LISTENER_EVENTS = {Events.ON_CLICK}; private static final String[] LISTENER_EVENTS = {Events.ON_CLICK};

View File

@ -54,7 +54,7 @@ import org.zkoss.zk.ui.event.Events;
* @date Jul 23, 2007 * @date Jul 23, 2007
*/ */
public class WLocatorEditor extends WEditor implements EventListener, PropertyChangeListener, ContextMenuListener, IZoomableEditor public class WLocatorEditor extends WEditor implements EventListener<Event>, PropertyChangeListener, ContextMenuListener, IZoomableEditor
{ {
private static final String[] LISTENER_EVENTS = {Events.ON_CLICK}; private static final String[] LISTENER_EVENTS = {Events.ON_CLICK};

View File

@ -63,23 +63,6 @@ public class WebEditorFactory
if (editor != null) if (editor != null)
break; break;
} }
if (tableEditor)
{
if (editor.getComponent() instanceof InputElement)
{
((InputElement)editor.getComponent()).setInplace(true);
}
else if (editor.getComponent() instanceof EditorBox)
{
EditorBox box = (EditorBox) editor.getComponent();
box.getTextbox().setInplace(true);
}
else if (editor.getComponent() instanceof NumberBox)
{
NumberBox box = (NumberBox) editor.getComponent();
box.getDecimalbox().setInplace(true);
}
}
return editor; return editor;
} }
} }

View File

@ -93,7 +93,7 @@ import org.zkoss.zul.impl.InputElement;
* *
* @author Low Heng Sin * @author Low Heng Sin
*/ */
public class ADTabpanel extends Div implements Evaluatee, EventListener, public class ADTabpanel extends Div implements Evaluatee, EventListener<Event>,
DataStatusListener, IADTabpanel, VetoableChangeListener DataStatusListener, IADTabpanel, VetoableChangeListener
{ {
/** /**
@ -472,11 +472,7 @@ DataStatusListener, IADTabpanel, VetoableChangeListener
} }
//streach component to fill grid cell //streach component to fill grid cell
if (editor.getComponent() instanceof InputElement) {
((InputElement)editor.getComponent()).setHflex("1");
} else {
editor.fillHorizontal(); editor.fillHorizontal();
}
//setup editor context menu //setup editor context menu
WEditorPopupMenu popupMenu = editor.getPopupMenu(); WEditorPopupMenu popupMenu = editor.getPopupMenu();