public void readData(final Widget widget) { // HttpServletRequest request = ContextProvider.getRequest(); // String parameter = request.getParameter( "JSON" ); // if( parameter != null ) { // System.out.println( "#### BEGIN ####"); // System.out.println( parameter ); // System.out.println( "#### END ####"); // } Shell shell = (Shell) widget; // [if] Preserve the menu bounds before setting the new shell bounds. preserveMenuBounds(shell); // Important: Order matters, readMode() before readBounds() readBounds(shell); if (WidgetLCAUtil.wasEventSent(shell, JSConst.EVENT_SHELL_CLOSED)) { shell.close(); } processActiveShell(shell); processActivate(shell); ControlLCAUtil.processMouseEvents(shell); ControlLCAUtil.processKeyEvents(shell); ControlLCAUtil.processMenuDetect(shell); WidgetLCAUtil.processHelp(shell); }
private static void writeText(final Shell shell) throws IOException { String text = shell.getText(); if (WidgetLCAUtil.hasChanged(shell, PROP_TEXT, text, "")) { // JSWriter writer = JSWriter.getWriterFor( shell ); text = WidgetLCAUtil.escapeText(text, false); // writer.set( JSConst.QX_FIELD_CAPTION, text ); IWidgetSynchronizer synchronizer = WidgetSynchronizerFactory.getSynchronizerForWidget(shell); synchronizer.setWidgetProperty(JSConst.QX_FIELD_CAPTION, text); } }
private static void updateSelectionListener(final Tree tree) throws IOException { Boolean newValue = Boolean.valueOf(SelectionEvent.hasListener(tree)); String prop = PROP_SELECTION_LISTENERS; if (WidgetLCAUtil.hasChanged(tree, prop, newValue, Boolean.FALSE)) { JSWriter writer = JSWriter.getWriterFor(tree); writer.set("selectionListeners", newValue); } }
private static void writeClipBounds(final ScrolledComposite composite) throws IOException { Rectangle bounds = composite.getBounds(); if (WidgetLCAUtil.hasChanged(composite, PROP_BOUNDS, bounds, null)) { JSWriter writer = JSWriter.getWriterFor(composite); writer.set("clipWidth", bounds.width); writer.set("clipHeight", bounds.height); } }
private static void writeSelectionListener(final ScrolledComposite composite) throws IOException { boolean hasListener = hasSelectionListener(composite); Boolean newValue = Boolean.valueOf(hasListener); String prop = Props.SELECTION_LISTENERS; if (WidgetLCAUtil.hasChanged(composite, prop, newValue, Boolean.FALSE)) { JSWriter writer = JSWriter.getWriterFor(composite); writer.set("hasSelectionListener", newValue); } }
private static void writeShowFocusedControl(final ScrolledComposite composite) throws IOException { Boolean newValue = Boolean.valueOf(composite.getShowFocusedControl()); String prop = PROP_SHOW_FOCUSED_CONTROL; if (WidgetLCAUtil.hasChanged(composite, prop, newValue, Boolean.FALSE)) { JSWriter writer = JSWriter.getWriterFor(composite); writer.set("showFocusedControl", newValue); } }
private void writeAlpha(final Shell shell) throws IOException { int alpha = shell.getAlpha(); if (WidgetLCAUtil.hasChanged(shell, PROP_ALPHA, new Integer(alpha), new Integer(0xFF))) { // JSWriter writer = JSWriter.getWriterFor( shell ); float opacity = (alpha & 0xFF) * 1000 / 0xFF / 1000.0f; // writer.set( "opacity", opacity ); IWidgetSynchronizer synchronizer = WidgetSynchronizerFactory.getSynchronizerForWidget(shell); synchronizer.setWidgetProperty("opacity", opacity); } }
private static void writeMode(final Shell shell) throws IOException { Object defValue = null; Object newValue = getMode(shell); if (WidgetLCAUtil.hasChanged(shell, PROP_MODE, newValue, defValue)) { // JSWriter writer = JSWriter.getWriterFor( shell ); // writer.set( "mode", newValue ); IWidgetSynchronizer synchronizer = WidgetSynchronizerFactory.getSynchronizerForWidget(shell); synchronizer.setWidgetProperty("mode", newValue); } }
private static void writeFullScreen(final Shell shell) throws IOException { Object defValue = Boolean.FALSE; Boolean newValue = Boolean.valueOf(shell.getFullScreen()); if (WidgetLCAUtil.hasChanged(shell, PROP_FULLSCREEN, newValue, defValue)) { // JSWriter writer = JSWriter.getWriterFor( shell ); // writer.set( "fullScreen", newValue ); IWidgetSynchronizer synchronizer = WidgetSynchronizerFactory.getSynchronizerForWidget(shell); synchronizer.setWidgetProperty("fullScreen", newValue); } }
/* (intentionally non-JavaDoc'ed) * This method is declared public only to be accessible from DisplayLCA */ public static void writeActiveControl(final Shell shell) throws IOException { final Control activeControl = getActiveControl(shell); String prop = PROP_ACTIVE_CONTROL; if (WidgetLCAUtil.hasChanged(shell, prop, activeControl, null)) { // JSWriter writer = JSWriter.getWriterFor( shell ); // writer.set( "activeControl", new Object[] { activeControl } ); IWidgetSynchronizer synchronizer = WidgetSynchronizerFactory.getSynchronizerForWidget(shell); synchronizer.setWidgetProperty("activeControl", WidgetUtil.getId(activeControl)); } }
private static void writeActiveShell(final Shell shell) throws IOException { Shell activeShell = shell.getDisplay().getActiveShell(); boolean hasChanged = WidgetLCAUtil.hasChanged(shell, PROP_ACTIVE_SHELL, activeShell, null); if (shell == activeShell && hasChanged) { // JSWriter writer = JSWriter.getWriterFor( shell ); // writer.set( "active", true ); IWidgetSynchronizer synchronizer = WidgetSynchronizerFactory.getSynchronizerForWidget(shell); synchronizer.setWidgetProperty("active", true); } }
public void renderChanges(final Widget widget) throws IOException { Tree tree = (Tree) widget; ControlLCAUtil.writeChanges(tree); updateSelectionListener(tree); writeHeaderHeight(tree); writeHeaderVisible(tree); writeColumnOrder(tree); writeScrollLeft(tree); writeOverflow(tree); WidgetLCAUtil.writeCustomVariant(tree); }
private static void writeOpen(final Shell shell) throws IOException { // TODO [rst] workaround: qx window should be opened only once. Boolean defValue = Boolean.FALSE; Boolean actValue = Boolean.valueOf(shell.getVisible()); if (WidgetLCAUtil.hasChanged(shell, Props.VISIBLE, actValue, defValue) && shell.getVisible()) { // JSWriter writer = JSWriter.getWriterFor( shell ); // writer.call( "open", null ); IWidgetSynchronizer synchronizer = WidgetSynchronizerFactory.getSynchronizerForWidget(shell); synchronizer.call("open"); } }
public void readData(final Widget widget) { Tree tree = (Tree) widget; readSelection(tree); readScrollPosition(tree); processWidgetSelectedEvent(tree); processWidgetDefaultSelectedEvent(tree); ControlLCAUtil.processMouseEvents(tree); ControlLCAUtil.processKeyEvents(tree); ControlLCAUtil.processMenuDetect(tree); WidgetLCAUtil.processHelp(tree); }
private static void writeMinimumSize(final Shell shell) throws IOException { Point newValue = shell.getMinimumSize(); if (WidgetLCAUtil.hasChanged(shell, PROP_MINIMUM_SIZE, newValue)) { // JSWriter writer = JSWriter.getWriterFor( shell ); // writer.set( "minWidth", new Integer( newValue.x ) ); // writer.set( "minHeight", new Integer( newValue.y ) ); IWidgetSynchronizer synchronizer = WidgetSynchronizerFactory.getSynchronizerForWidget(shell); synchronizer.setWidgetProperty("minWidth", newValue.x); synchronizer.setWidgetProperty("minHeight", newValue.y); } }
public void renderChanges(final Widget widget) throws IOException { ScrolledComposite composite = (ScrolledComposite) widget; ControlLCAUtil.writeChanges(composite); writeClipBounds(composite); // TODO [rh] initial positioning of the client-side scroll bar does not work writeBarSelection(composite); // [if] Order is important: writeScrollBars after writeBarSelection writeScrollBars(composite); writeSelectionListener(composite); writeShowFocusedControl(composite); WidgetLCAUtil.writeCustomVariant(composite); }
private static void processWidgetDefaultSelectedEvent(final Tree tree) { HttpServletRequest request = ContextProvider.getRequest(); String eventName = JSConst.EVENT_WIDGET_DEFAULT_SELECTED; if (WidgetLCAUtil.wasEventSent(tree, eventName)) { String itemId = request.getParameter(eventName + ".item"); Item treeItem = (Item) WidgetUtil.find(tree, itemId); int eventType = SelectionEvent.WIDGET_DEFAULT_SELECTED; SelectionEvent event = new SelectionEvent(tree, treeItem, eventType); event.stateMask = EventLCAUtil.readStateMask(JSConst.EVENT_WIDGET_SELECTED_MODIFIER); event.processEvent(); } }
public void readData(final Widget widget) { ScrolledComposite composite = (ScrolledComposite) widget; Point origin = composite.getOrigin(); String value = WidgetLCAUtil.readPropertyValue(widget, PARAM_H_BAR_SELECTION); ScrollBar hScroll = composite.getHorizontalBar(); if (value != null && hScroll != null) { origin.x = Integer.parseInt(value); processSelection(hScroll); } value = WidgetLCAUtil.readPropertyValue(widget, PARAM_V_BAR_SELECTION); ScrollBar vScroll = composite.getVerticalBar(); if (value != null && vScroll != null) { origin.y = Integer.parseInt(value); processSelection(vScroll); } composite.setOrigin(origin); ControlLCAUtil.processMouseEvents(composite); ControlLCAUtil.processKeyEvents(composite); ControlLCAUtil.processMenuDetect(composite); WidgetLCAUtil.processHelp(composite); }
private static void readScrollPosition(final Tree tree) { String left = WidgetLCAUtil.readPropertyValue(tree, "scrollLeft"); String top = WidgetLCAUtil.readPropertyValue(tree, "scrollTop"); if (left != null && top != null) { Object adapter = tree.getAdapter(ITreeAdapter.class); final ITreeAdapter treeAdapter = (ITreeAdapter) adapter; final int newScrollLeft = parsePosition(left); final int newScrollTop = parsePosition(top); final int oldScrollTop = treeAdapter.getScrollTop(); treeAdapter.setScrollLeft(newScrollLeft); treeAdapter.setScrollTop(newScrollTop); if (oldScrollTop != newScrollTop) { ProcessActionRunner.add( new Runnable() { public void run() { treeAdapter.checkAllData(tree); } }); } } }
public void preserveValues(final Widget widget) { ScrolledComposite composite = (ScrolledComposite) widget; ControlLCAUtil.preserveValues(composite); IWidgetAdapter adapter = WidgetUtil.getAdapter(composite); adapter.preserve(PROP_BOUNDS, composite.getBounds()); adapter.preserve(PROP_OVERFLOW, getOverflow(composite)); adapter.preserve(PROP_H_BAR_SELECTION, getBarSelection(composite.getHorizontalBar())); adapter.preserve(PROP_V_BAR_SELECTION, getBarSelection(composite.getVerticalBar())); adapter.preserve(Props.SELECTION_LISTENERS, Boolean.valueOf(hasSelectionListener(composite))); adapter.preserve(PROP_SHOW_FOCUSED_CONTROL, Boolean.valueOf(composite.getShowFocusedControl())); WidgetLCAUtil.preserveCustomVariant(composite); }
private static void writeOverflow(final Tree tree) throws IOException { boolean hasHChanged = WidgetLCAUtil.hasChanged(tree, PROP_HAS_H_SCROLL_BAR, hasHScrollBar(tree), Boolean.TRUE); boolean hasVChanged = WidgetLCAUtil.hasChanged(tree, PROP_HAS_V_SCROLL_BAR, hasVScrollBar(tree), Boolean.TRUE); if (hasHChanged || hasVChanged) { boolean scrollX = hasHScrollBar(tree).booleanValue(); boolean scrollY = hasVScrollBar(tree).booleanValue(); String overflow; if (scrollX && scrollY) { overflow = "scroll"; } else if (scrollX) { overflow = "scrollX"; } else if (scrollY) { overflow = "scrollY"; } else { overflow = "hidden"; } JSWriter writer = JSWriter.getWriterFor(tree); writer.set("treeOverflow", overflow); } }
private void writeColumnOrder(final Tree tree) throws IOException { JSWriter writer = JSWriter.getWriterFor(tree); int[] values = tree.getColumnOrder(); if (values.length > 0) { Integer[] newValue = new Integer[values.length]; for (int i = 0; i < values.length; i++) { newValue[i] = new Integer(values[i]); } if (WidgetLCAUtil.hasChanged(tree, PROP_COLUMN_ORDER, newValue, new Integer[] {})) { writer.set(PROP_COLUMN_ORDER, "columnOrder", newValue, null); } } }
private static void processActiveShell(final Shell shell) { if (WidgetLCAUtil.wasEventSent(shell, JSConst.EVENT_SHELL_ACTIVATED)) { Shell lastActiveShell = shell.getDisplay().getActiveShell(); setActiveShell(shell); ActivateEvent event; if (lastActiveShell != null) { event = new ActivateEvent(lastActiveShell, ActivateEvent.DEACTIVATED); event.processEvent(); } event = new ActivateEvent(shell, ActivateEvent.ACTIVATED); event.processEvent(); } }
private static void writeCloseListener(final Shell shell) throws IOException { // JSWriter writer = JSWriter.getWriterFor( shell ); Boolean newValue = Boolean.valueOf(ShellEvent.hasListener(shell)); Boolean defValue = Boolean.FALSE; // writer.set( PROP_SHELL_LISTENER, "hasShellListener", newValue, defValue ); boolean hasChanged = WidgetLCAUtil.hasChanged(shell, PROP_SHELL_LISTENER, newValue, defValue); if (hasChanged) { IWidgetSynchronizer synchronizer = WidgetSynchronizerFactory.getSynchronizerForWidget(shell); if (newValue.booleanValue()) { synchronizer.addListener("closelistener"); } else { synchronizer.removeListener("closelistener"); } } }
// TODO [rh] is this safe for multiple shells? private static void processActivate(final Shell shell) { HttpServletRequest request = ContextProvider.getRequest(); String widgetId = request.getParameter(JSConst.EVENT_WIDGET_ACTIVATED); if (widgetId != null) { Widget widget = WidgetUtil.find(shell, widgetId); if (widget != null) { setActiveControl(shell, widget); } } else { String activeControlId = WidgetLCAUtil.readPropertyValue(shell, "activeControl"); Widget widget = WidgetUtil.find(shell, activeControlId); if (widget != null) { setActiveControl(shell, widget); } } }
private static void processWidgetSelectedEvent(final Tree tree) { HttpServletRequest request = ContextProvider.getRequest(); String eventName = JSConst.EVENT_WIDGET_SELECTED; if (WidgetLCAUtil.wasEventSent(tree, eventName)) { Rectangle bounds = new Rectangle(0, 0, 0, 0); String itemId = request.getParameter(eventName + ".item"); Item treeItem = (Item) WidgetUtil.find(tree, itemId); String detailStr = request.getParameter(eventName + ".detail"); int detail = "check".equals(detailStr) ? SWT.CHECK : SWT.NONE; int eventType = SelectionEvent.WIDGET_SELECTED; int stateMask = EventLCAUtil.readStateMask(JSConst.EVENT_WIDGET_SELECTED_MODIFIER); SelectionEvent event = new SelectionEvent(tree, treeItem, eventType, bounds, stateMask, null, true, detail); event.processEvent(); } }
public void preserveValues(final Widget widget) { ControlLCAUtil.preserveValues((Control) widget); Shell shell = (Shell) widget; IWidgetAdapter adapter = WidgetUtil.getAdapter(shell); adapter.preserve(PROP_ACTIVE_CONTROL, getActiveControl(shell)); adapter.preserve(PROP_ACTIVE_SHELL, shell.getDisplay().getActiveShell()); adapter.preserve(PROP_TEXT, shell.getText()); adapter.preserve(PROP_IMAGE, shell.getImage()); adapter.preserve(PROP_ALPHA, new Integer(shell.getAlpha())); adapter.preserve(PROP_MODE, getMode(shell)); adapter.preserve(PROP_FULLSCREEN, Boolean.valueOf(shell.getFullScreen())); adapter.preserve(PROP_SHELL_LISTENER, Boolean.valueOf(ShellEvent.hasListener(shell))); adapter.preserve(PROP_SHELL_MENU, shell.getMenuBar()); adapter.preserve(PROP_MINIMUM_SIZE, shell.getMinimumSize()); WidgetLCAUtil.preserveCustomVariant(shell); }
public void preserveValues(final Widget widget) { Tree tree = (Tree) widget; ControlLCAUtil.preserveValues((Control) widget); IWidgetAdapter adapter = WidgetUtil.getAdapter(tree); adapter.preserve(PROP_SELECTION_LISTENERS, Boolean.valueOf(SelectionEvent.hasListener(tree))); adapter.preserve(PROP_HEADER_HEIGHT, new Integer(tree.getHeaderHeight())); adapter.preserve(PROP_HEADER_VISIBLE, Boolean.valueOf(tree.getHeaderVisible())); int[] values = tree.getColumnOrder(); Integer[] columnOrder = new Integer[values.length]; for (int i = 0; i < values.length; i++) { columnOrder[i] = new Integer(values[i]); } adapter.preserve(PROP_COLUMN_ORDER, columnOrder); adapter.preserve(PROP_SCROLL_LEFT, getScrollLeft(tree)); adapter.preserve(PROP_HAS_H_SCROLL_BAR, hasHScrollBar(tree)); adapter.preserve(PROP_HAS_V_SCROLL_BAR, hasVScrollBar(tree)); WidgetLCAUtil.preserveCustomVariant(tree); }
private static void readSelection(final Tree tree) { String value = WidgetLCAUtil.readPropertyValue(tree, "selection"); if (value != null) { String[] values = value.split(","); TreeItem[] selectedItems = new TreeItem[values.length]; boolean validItemFound = false; for (int i = 0; i < values.length; i++) { selectedItems[i] = (TreeItem) WidgetUtil.find(tree, values[i]); if (selectedItems[i] != null) { validItemFound = true; } } if (!validItemFound) { selectedItems = new TreeItem[0]; } tree.setSelection(selectedItems); } }
private static void writeImage(final Shell shell) throws IOException { if ((shell.getStyle() & SWT.TITLE) != 0) { Image image = shell.getImage(); if (image == null) { Image[] defaultImages = shell.getImages(); if (defaultImages.length > 0) { image = defaultImages[0]; } } if (WidgetLCAUtil.hasChanged(shell, PROP_IMAGE, image, null)) { // JSWriter writer = JSWriter.getWriterFor( shell ); // writer.set( JSConst.QX_FIELD_ICON, // ResourceFactory.getImagePath( image ) ); IWidgetSynchronizer synchronizer = WidgetSynchronizerFactory.getSynchronizerForWidget(shell); synchronizer.setWidgetProperty(JSConst.QX_FIELD_ICON, ResourceFactory.getImagePath(image)); } } }