1 /*
2 * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
582 dataBuffer.append('&');
583 }
584 dataBuffer.append(imageData);
585 submitData(dataBuffer.toString());
586 return;
587 }
588
589 /**
590 * Extracts the value of the name attribute
591 * associated with the input element of type
592 * image. If name is defined it is encoded using
593 * the URLEncoder.encode() method and the
594 * image data is returned in the following format:
595 * name + ".x" +"="+ x +"&"+ name +".y"+"="+ y
596 * otherwise,
597 * "x="+ x +"&y="+ y
598 *
599 * @param point associated with the mouse click.
600 * @return the image data.
601 */
602 private String getImageData(Point point) {
603
604 String mouseCoords = point.x + ":" + point.y;
605 int sep = mouseCoords.indexOf(':');
606 String x = mouseCoords.substring(0, sep);
607 String y = mouseCoords.substring(++sep);
608 String name = (String) getElement().getAttributes().getAttribute(HTML.Attribute.NAME);
609
610 String data;
611 if (name == null || name.equals("")) {
612 data = "x="+ x +"&y="+ y;
613 } else {
614 name = URLEncoder.encode(name);
615 data = name + ".x" +"="+ x +"&"+ name +".y"+"="+ y;
616 }
617 return data;
618 }
619
620
621 /**
799 Option option = model.getElementAt(i);
800 appendBuffer(buffer, name, option.getValue());
801 }
802 }
803 } else if (m instanceof ComboBoxModel) {
804 @SuppressWarnings("unchecked")
805 ComboBoxModel<?> model = (ComboBoxModel)m;
806 Option option = (Option)model.getSelectedItem();
807 if (option != null) {
808 appendBuffer(buffer, name, option.getValue());
809 }
810 }
811 }
812
813 /**
814 * Appends name / value pairs into the
815 * buffer. Both names and values are encoded using the
816 * URLEncoder.encode() method before being added to the
817 * buffer.
818 */
819 private void appendBuffer(StringBuilder buffer, String name, String value) {
820 if (buffer.length() > 0) {
821 buffer.append('&');
822 }
823 String encodedName = URLEncoder.encode(name);
824 buffer.append(encodedName);
825 buffer.append('=');
826 String encodedValue = URLEncoder.encode(value);
827 buffer.append(encodedValue);
828 }
829
830 /**
831 * Returns true if the Element <code>elem</code> represents a control.
832 */
833 private boolean isControl(Element elem) {
834 return elem.isLeaf();
835 }
836
837 /**
838 * Iterates over the element hierarchy to determine if
|
1 /*
2 * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
582 dataBuffer.append('&');
583 }
584 dataBuffer.append(imageData);
585 submitData(dataBuffer.toString());
586 return;
587 }
588
589 /**
590 * Extracts the value of the name attribute
591 * associated with the input element of type
592 * image. If name is defined it is encoded using
593 * the URLEncoder.encode() method and the
594 * image data is returned in the following format:
595 * name + ".x" +"="+ x +"&"+ name +".y"+"="+ y
596 * otherwise,
597 * "x="+ x +"&y="+ y
598 *
599 * @param point associated with the mouse click.
600 * @return the image data.
601 */
602 @SuppressWarnings("deprecation")
603 private String getImageData(Point point) {
604
605 String mouseCoords = point.x + ":" + point.y;
606 int sep = mouseCoords.indexOf(':');
607 String x = mouseCoords.substring(0, sep);
608 String y = mouseCoords.substring(++sep);
609 String name = (String) getElement().getAttributes().getAttribute(HTML.Attribute.NAME);
610
611 String data;
612 if (name == null || name.equals("")) {
613 data = "x="+ x +"&y="+ y;
614 } else {
615 name = URLEncoder.encode(name);
616 data = name + ".x" +"="+ x +"&"+ name +".y"+"="+ y;
617 }
618 return data;
619 }
620
621
622 /**
800 Option option = model.getElementAt(i);
801 appendBuffer(buffer, name, option.getValue());
802 }
803 }
804 } else if (m instanceof ComboBoxModel) {
805 @SuppressWarnings("unchecked")
806 ComboBoxModel<?> model = (ComboBoxModel)m;
807 Option option = (Option)model.getSelectedItem();
808 if (option != null) {
809 appendBuffer(buffer, name, option.getValue());
810 }
811 }
812 }
813
814 /**
815 * Appends name / value pairs into the
816 * buffer. Both names and values are encoded using the
817 * URLEncoder.encode() method before being added to the
818 * buffer.
819 */
820 @SuppressWarnings("deprecation")
821 private void appendBuffer(StringBuilder buffer, String name, String value) {
822 if (buffer.length() > 0) {
823 buffer.append('&');
824 }
825 String encodedName = URLEncoder.encode(name);
826 buffer.append(encodedName);
827 buffer.append('=');
828 String encodedValue = URLEncoder.encode(value);
829 buffer.append(encodedValue);
830 }
831
832 /**
833 * Returns true if the Element <code>elem</code> represents a control.
834 */
835 private boolean isControl(Element elem) {
836 return elem.isLeaf();
837 }
838
839 /**
840 * Iterates over the element hierarchy to determine if
|