proxy-dialog: change proxy dialog
authorminkee.lee <minkee.lee@samsung.com>
Tue, 5 Jan 2016 05:21:24 +0000 (14:21 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Tue, 5 Jan 2016 09:12:27 +0000 (18:12 +0900)
Apply new UI to proxy dialog.

Change-Id: Ieddb9dc6584c7febb08cc64fa0bc7db9c90fa244
Signed-off-by: minkee.lee <minkee.lee@samsung.com>
resource/strings/uimessages.properties
src/org/tizen/emulator/manager/ui/renewal/dialog/Dialog.java
src/org/tizen/emulator/manager/ui/renewal/dialog/DialogButtons.java
src/org/tizen/emulator/manager/ui/renewal/dialog/DialogTitle.java
src/org/tizen/emulator/manager/ui/renewal/dialog/network/AddressPortItem.java [new file with mode: 0644]
src/org/tizen/emulator/manager/ui/renewal/dialog/network/HTTPCheckBoxItem.java [new file with mode: 0644]
src/org/tizen/emulator/manager/ui/renewal/dialog/network/ProxyDialog.java [new file with mode: 0644]
src/org/tizen/emulator/manager/ui/renewal/item/modify/common/CheckBoxSubItem.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/NetProxyItem.java
src/org/tizen/emulator/manager/ui/renewal/widgets/TextInputBox.java
src/org/tizen/emulator/manager/ui/renewal/widgets/WidgetHelper.java

index b000ced..cbc93e2 100644 (file)
@@ -74,6 +74,8 @@ PModifyViewPage.DPIError.1=Display Density should be from 100 to 480
 PModifyViewPage.FailedToLoad.0=Failed to load template
 ProcessorViewItem.Error.0=Please use processors 1 at non-UG platform.
 ProcessorViewItem.Error.1=Multi-processors might cause VM slower.
+ProxyDialog.Title=Proxy Setting
+ProxyDialog.HTTPCheckBoxTitle=Use this proxy for all protocols
 SkinSubViewItem.SkinToolTip.0=check skin directory: .
 SuspendSupportViewItem.SuspendWarning.0=This is incomplete feature. It may not work properly.
 TapGuideDialogForWin.CreateBridgeDialog.0=Create a network bridge
index 35a382a..688dd33 100644 (file)
@@ -64,6 +64,10 @@ public class Dialog {
 
        protected static final int BORDER_WIDTH = 1;
 
+       public int getBodyHeight() {
+               return height - DialogTitle.TITLE_COMP_HEIGHT - DialogButtons.BUTTON_COMP_HEIGHT;
+       }
+
        public void setOkButton(NinePatchButton okButton) {
                this.okButton = okButton;
        }
index 99c9eef..480a15e 100644 (file)
@@ -43,7 +43,7 @@ import org.tizen.emulator.manager.ui.renewal.widgets.NinePatchButton;
 
 public class DialogButtons {
 
-       private static final int BUTTON_COMP_HEIGHT = 48;
+       public static final int BUTTON_COMP_HEIGHT = 48;
 
        private static final int BUTTON_WIDTH = 106;
        private static final int BUTTON_HEIGHT = 26;
index 07d6c1c..2bbe841 100644 (file)
@@ -46,7 +46,7 @@ import org.tizen.emulator.manager.renewal.resources.FontResources;
 
 public class DialogTitle {
 
-       private static final int TITLE_COMP_HEIGHT = 31;
+       public static final int TITLE_COMP_HEIGHT = 31;
        private static final int TITLE_MARGIN_TOP = 7;
        private static final int TITLE_MARGIN_LEFT = 15;
 
diff --git a/src/org/tizen/emulator/manager/ui/renewal/dialog/network/AddressPortItem.java b/src/org/tizen/emulator/manager/ui/renewal/dialog/network/AddressPortItem.java
new file mode 100644 (file)
index 0000000..1e06ec4
--- /dev/null
@@ -0,0 +1,318 @@
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * JiHye Kim <jihye424.kim@samsung.com>
+ * Minkee Lee <minkee.lee@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho.p@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.ui.renewal.dialog.network;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.events.VerifyEvent;
+import org.eclipse.swt.events.VerifyListener;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+import org.tizen.emulator.manager.renewal.resources.ColorResources;
+import org.tizen.emulator.manager.renewal.resources.FontResources;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.ModifyItem;
+import org.tizen.emulator.manager.ui.renewal.widgets.TextInputBox;
+import org.tizen.emulator.manager.ui.renewal.widgets.WidgetHelper;
+
+class AddressPortItem {
+       Composite comp;
+       ProxyDialog dialog;
+
+       Canvas ipLabel, portLabel;
+       TextInputBox ipInput, portInput;
+       int compHeight;
+
+       String ip = "", port = "";
+       String title;
+
+       boolean isEnabled = true;
+       private static int MAX_PORT = 65535;
+
+       static int TEXT_WIDGET_MARGIN_WIDTH = 5;
+       static String PORT_LABEL_TEXT = "Port";
+       static String LABEL_COLON = " :";
+       public static Integer[] rate = {3,9,3,4};
+       private static int rateTotal;
+
+       static {
+               int total = 0;
+               for (int i : rate) {
+                       total += i;
+               }
+               rateTotal = total;
+       }
+
+       public void setEnabled(boolean isEnable) {
+               this.isEnabled = isEnable;
+               if (!isEnable) {
+                       ipInput.setText("");
+                       portInput.setText("");
+               }
+               redraw();
+       }
+
+       public String getIP() {
+               return ip;
+       }
+
+       public String getPort() {
+               return port;
+       }
+
+       private void redraw() {
+               ipInput.setEnabled(isEnabled);
+               portInput.setEnabled(isEnabled);
+               ipLabel.redraw();
+               portLabel.redraw();
+       }
+
+       public AddressPortItem(ProxyDialog dialog, Composite parent, GridData layoutData, String title) {
+               this.dialog = dialog;
+               this.title = title;
+               this.compHeight = layoutData.heightHint;
+
+               comp = new Composite(parent, SWT.NONE);
+               comp.setLayoutData(layoutData);
+               comp.setBackground(ColorResources.WHITE.getColor());
+               setCompLayout();
+
+               createWidget();
+       }
+
+
+       public void setIpPort(String value) {
+               int idx = value.lastIndexOf(":"); //$NON-NLS-1$
+               if (idx > 0) {
+                       ip = value.substring(0,idx);
+                       port = value.substring(idx+1, value.length());
+               }
+
+               ipInput.setText(ip);
+               portInput.setText(port);
+       }
+
+       private void setCompLayout() {
+               GridLayout layout = new GridLayout();
+               layout.numColumns = rate.length;
+               layout.marginWidth = 0;
+               layout.marginHeight = 0;
+               layout.horizontalSpacing = 0;
+               comp.setLayout(layout);
+       }
+
+       private void createWidget() {
+               ipLabel = createLabel(0, title);
+               ipInput = createTextBox(1);
+               portLabel = createLabel(2, PORT_LABEL_TEXT);
+               portInput = createTextBox(3);
+
+               ipInput.setTextLimit(40);
+               portInput.setTextLimit(6);
+               addInputListener();
+       }
+
+       private void addInputListener() {
+               ipInput.getTextWidget().addModifyListener(new ModifyListener() {
+
+                       @Override
+                       public void modifyText(ModifyEvent e) {
+                               ip = ((Text)e.widget).getText();
+                               dialog.checkAllValues();
+                       }
+               });
+
+               portInput.getTextWidget().addModifyListener(new ModifyListener() {
+
+                       @Override
+                       public void modifyText(ModifyEvent e) {
+                               port = ((Text)e.widget).getText();
+                               dialog.checkAllValues();
+                       }
+               });
+
+               portInput.getTextWidget().addVerifyListener(new VerifyListener() {
+
+                       @Override
+                       public void verifyText(VerifyEvent e) {
+                               Text text = (Text) e.getSource();
+                               int newValue;
+                               int oldValue;
+                               // get old text and create new text by using the
+                               // VerifyEvent.text
+                               final String oldS = text.getText();
+                               String newS = oldS.substring(0, e.start) + e.text
+                                               + oldS.substring(e.end);
+
+                               boolean isInteger = true;
+                               if (newS.isEmpty()) {
+                                       e.doit = true;
+                                       return;
+                               }
+
+                               try {
+                                       newValue = Integer.parseInt(newS);
+                                       if (newValue > MAX_PORT) {
+                                               e.doit = false;
+                                               return;
+                                       }
+
+                                       if (!oldS.isEmpty()) {
+                                               oldValue = Integer.parseInt(oldS);
+                                               if (newValue == oldValue) {
+                                                       e.doit = false;
+                                                       return;
+                                               }
+                                       }
+                               } catch (NumberFormatException ex) {
+                                       isInteger = false;
+                               }
+
+                               if (!isInteger)
+                                       e.doit = false;
+                       }
+               });
+       }
+
+       public boolean checkValue() {
+               boolean isValid = false;
+               if (ip.isEmpty()) {
+                       if (port.isEmpty()) {
+                               isValid = true;
+                       }
+
+               } else {
+                       if (!port.isEmpty() && !port.equals("0")) {
+                               isValid = true;
+                       }
+               }
+               return isValid;
+       }
+
+       private Canvas createLabel(int index, String title) {
+               Composite widgetComp = createWidgetComp(index);
+
+               Canvas canvas = new Canvas(widgetComp, SWT.NONE);
+               canvas.setBackground(ColorResources.WHITE.getColor());
+               canvas.setLayoutData(getLabelLayout());
+               WidgetHelper.drawText(canvas, title + LABEL_COLON, SWT.RIGHT);
+               drawTitle(canvas, title + LABEL_COLON);
+               return canvas;
+       }
+
+       private TextInputBox createTextBox(int index) {
+               Composite widgetComp = createWidgetComp(index);
+
+               TextInputBox input = new TextInputBox(widgetComp, SWT.NONE);
+               input.setLayoutData(getTextInputLayout());
+               return input;
+       }
+
+       private Composite createWidgetComp(int index) {
+               Composite widgetComp = new Composite(comp, SWT.NONE);
+               widgetComp.setBackground(ColorResources.WHITE.getColor());
+               widgetComp.setLayoutData(getWidgetLayout(index));
+               widgetComp.setLayout(new FormLayout());
+               return widgetComp;
+       }
+
+
+       private void drawTitle(Canvas canvas, final String text) {
+               canvas.addPaintListener(new PaintListener() {
+
+                       @Override
+                       public void paintControl(PaintEvent e) {
+                               GC gc = e.gc;
+                               if (isEnabled) {
+                                       gc.setForeground(ColorResources.CONTENT_FONT.getColor());
+
+                               } else {
+                                       gc.setForeground(ColorResources.DISABLED_TEXT.getColor());
+                               }
+                               gc.setFont(FontResources.CONTENT.getFont());
+
+                               int itemHeight = ((Composite)e.widget).getBounds().height;
+                               Point textExt = gc.textExtent(text);
+                               int posY = (itemHeight - textExt.y) / 2;
+
+                               // right align
+                               int posX = ((Composite)e.widget).getBounds().width - textExt.x;
+                               String displayText = WidgetHelper.shortenText(gc, text,  ((Composite)e.widget).getClientArea());
+                               gc.drawText(displayText, posX, posY);
+                       }
+               });
+       }
+
+       private FormData getTextInputLayout() {
+               FormData data = new FormData();
+               data.top = new FormAttachment(0, (compHeight - ModifyItem.WIDGET_HEIGHT) / 2);
+               data.height = ModifyItem.WIDGET_HEIGHT;
+               data.left = new FormAttachment(0, TEXT_WIDGET_MARGIN_WIDTH);
+               data.right = new FormAttachment(100, -TEXT_WIDGET_MARGIN_WIDTH);
+               return data;
+       }
+
+       private static FormData getLabelLayout() {
+               FormData data = new FormData();
+               data.top = new FormAttachment(0, 0);
+               data.left = new FormAttachment(0, 0);
+               data.right = new FormAttachment(100, 0);
+               data.bottom = new FormAttachment(100, 0);
+               return data;
+       }
+
+       private static GridData getWidgetLayout(int index) {
+               GridData data = new GridData();
+               data.grabExcessVerticalSpace = true;
+               data.verticalAlignment = SWT.FILL;
+               data.widthHint = getWidth(index);
+               return data;
+       }
+
+       public static int getWidth(int index) {
+               if (index >= rate.length) {
+                       return 0;
+               }
+               return ProxyDialog.CONTENT_WIDTH * rate[index] / rateTotal;
+       }
+
+
+}
diff --git a/src/org/tizen/emulator/manager/ui/renewal/dialog/network/HTTPCheckBoxItem.java b/src/org/tizen/emulator/manager/ui/renewal/dialog/network/HTTPCheckBoxItem.java
new file mode 100644 (file)
index 0000000..fb6b926
--- /dev/null
@@ -0,0 +1,119 @@
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * JiHye Kim <jihye424.kim@samsung.com>
+ * Minkee Lee <minkee.lee@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho.p@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+
+package org.tizen.emulator.manager.ui.renewal.dialog.network;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.tizen.emulator.manager.renewal.resources.ColorResources;
+import org.tizen.emulator.manager.ui.Messages;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.CheckBoxSubItem;
+import org.tizen.emulator.manager.ui.renewal.widgets.CheckBoxButton;
+import org.tizen.emulator.manager.ui.renewal.widgets.WidgetHelper;
+
+class HTTPCheckBoxItem {
+       Composite comp;
+       CheckBoxButton checkBox;
+       Canvas textCanvas;
+       ProxyDialog dialog;
+
+       int compHeight;
+       boolean isChecked;
+
+       static String TITLE = Messages.getString("ProxyDialog.HTTPCheckBoxTitle");
+
+       public HTTPCheckBoxItem(ProxyDialog dialog, Composite parent, GridData layoutData) {
+               this.dialog = dialog;
+               compHeight = layoutData.heightHint;
+               comp = new Composite(parent, SWT.NONE);
+               comp.setLayoutData(layoutData);
+               comp.setLayout(new FormLayout());
+               comp.setBackground(ColorResources.WHITE.getColor());
+
+               createCheckBox();
+               createTextLabel();
+               addSelectionListener();
+       }
+
+       public boolean isChecked() {
+               return isChecked;
+       }
+
+       private void createCheckBox() {
+               checkBox = new CheckBoxButton(comp, SWT.PUSH);
+               FormData data = new FormData(CheckBoxSubItem.CHECK_BOX_WIDTH,
+                               CheckBoxSubItem.CHECK_BOX_HEIGHT);
+               data.top = new FormAttachment(0, (compHeight - CheckBoxSubItem.CHECK_BOX_HEIGHT) / 2);
+               data.left = new FormAttachment(0, AddressPortItem.getWidth(0) + 5);
+               checkBox.setBackground(ColorResources.WHITE.getColor());
+               checkBox.setLayoutData(data);
+       }
+
+       private void createTextLabel() {
+               textCanvas = new Canvas(comp, SWT.NONE);
+               int textWidth = WidgetHelper.calcTextWidth(textCanvas, TITLE);
+               FormData data = new FormData();
+               data.left = new FormAttachment(checkBox, 3);
+               data.width = textWidth;
+               data.top = new FormAttachment(0,0);
+               data.bottom = new FormAttachment(100,0);
+               textCanvas.setLayoutData(data);
+               textCanvas.setBackground(ColorResources.WHITE.getColor());
+               WidgetHelper.drawText(textCanvas, TITLE, SWT.NONE);
+       }
+
+
+       private void addSelectionListener() {
+               Listener listener = new Listener() {
+                       @Override
+                       public void handleEvent(Event e) {
+                               switch(e.type) {
+                               case SWT.Selection:
+                                       isChecked = ((CheckBoxButton)e.widget).isSelection();
+                                       dialog.setApplyAllProtocol(isChecked);
+
+                               default:
+                                       break;
+                               }
+
+                       }
+               };
+               checkBox.addListener(SWT.Selection, listener);
+       }
+
+}
diff --git a/src/org/tizen/emulator/manager/ui/renewal/dialog/network/ProxyDialog.java b/src/org/tizen/emulator/manager/ui/renewal/dialog/network/ProxyDialog.java
new file mode 100644 (file)
index 0000000..1a4fd32
--- /dev/null
@@ -0,0 +1,215 @@
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * JiHye Kim <jihye424.kim@samsung.com>
+ * Minkee Lee <minkee.lee@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho.p@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+
+package org.tizen.emulator.manager.ui.renewal.dialog.network;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
+import org.tizen.emulator.manager.renewal.resources.ColorResources;
+import org.tizen.emulator.manager.ui.Messages;
+import org.tizen.emulator.manager.ui.renewal.dialog.Dialog;
+
+
+
+public class ProxyDialog extends Dialog {
+
+       private static String TITLE = Messages.getString("ProxyDialog.Title");
+       public static int WIDTH = 400;
+       public static int HEIGHT = 250;
+       public static int CONTENT_MARGIN_WIDTH = 7;
+       public static int CONTENT_MARGIN_HEIGHT = 7;
+
+       public static int CONTENT_WIDTH = WIDTH - (CONTENT_MARGIN_WIDTH * 2) - (BORDER_WIDTH * 2);
+
+       private final String value;
+
+       private AddressPortItem httpItem, httpsItem, ftpItem, socksItem;
+       private HTTPCheckBoxItem httpCheckItem;
+
+       public ProxyDialog(Shell parent, String value) {
+               super(parent, TITLE, WIDTH, HEIGHT, SWT.OK | SWT.CANCEL);
+               this.value = value;
+               // TODO Auto-generated constructor stub
+       }
+
+
+       public static String open(Shell parent, String value) {
+               ProxyDialog dialog = new ProxyDialog(parent, value);
+               dialog.create();
+               dialog.addItems();
+               int res = dialog.open();
+
+               String returnValue = null;
+               if (res == SWT.OK) {
+                       returnValue = dialog.getReturnValue();
+               }
+
+               System.out.println(returnValue);
+               return returnValue;
+
+       }
+
+       public String getReturnValue() {
+               if (httpCheckItem.isChecked()) {
+                       if (httpItem.getIP().isEmpty()
+                                       && httpItem.getPort().isEmpty()) {
+                               return null;
+                       }
+                       String ipPort = httpItem.getIP() + ":" + httpItem.getPort();
+                       return "http_proxy=" + ipPort //$NON-NLS-1$
+                                       + " https_proxy=" + ipPort //$NON-NLS-1$
+                                       + " ftp_proxy=" + ipPort //$NON-NLS-1$
+                                       + " socks_proxy=" + ipPort;//$NON-NLS-1$
+               }
+
+               // not checked
+               String httpProxyAddr = httpItem.getIP();
+               String httpProxyPort = httpItem.getPort();
+               String httpsProxyAddr = httpsItem.getIP();
+               String httpsProxyPort = httpsItem.getPort();
+               String ftpProxyAddr = ftpItem.getIP();
+               String ftpProxyPort = ftpItem.getPort();
+               String socksProxyAddr = socksItem.getIP();
+               String socksProxyPort = socksItem.getPort();
+               String httpProxy;
+               String httpsProxy;
+               String ftpProxy;
+               String socksProxy;
+
+               if (httpProxyAddr.isEmpty() && httpProxyPort.isEmpty()) {
+                       httpProxy = "http_proxy="; //$NON-NLS-1$
+               } else {
+                       httpProxy = "http_proxy=" + httpProxyAddr + ":" //$NON-NLS-1$ //$NON-NLS-2$
+                                       + httpProxyPort;
+               }
+
+               if (httpsProxyAddr.isEmpty() && httpsProxyPort.isEmpty()) {
+                       httpsProxy = "https_proxy="; //$NON-NLS-1$
+               } else {
+                       httpsProxy = "https_proxy=" + httpsProxyAddr + ":" //$NON-NLS-1$ //$NON-NLS-2$
+                                       + httpsProxyPort;
+               }
+
+               if (ftpProxyAddr.isEmpty() && ftpProxyPort.isEmpty()) {
+                       ftpProxy = "ftp_proxy="; //$NON-NLS-1$
+               } else {
+                       ftpProxy = "ftp_proxy=" + ftpProxyAddr + ":" //$NON-NLS-1$ //$NON-NLS-2$
+                                       + ftpProxyPort;
+               }
+
+               if (socksProxyAddr.isEmpty() && socksProxyPort.isEmpty()) {
+                       socksProxy = "socks_proxy="; //$NON-NLS-1$
+               } else {
+                       socksProxy = "socks_proxy=" + socksProxyAddr + ":" //$NON-NLS-1$ //$NON-NLS-2$
+                                       + socksProxyPort;
+               }
+               return httpProxy + " " + httpsProxy + " " + ftpProxy //$NON-NLS-1$ //$NON-NLS-2$
+                               + " " + socksProxy; //$NON-NLS-1$
+       }
+
+       private void addItems() {
+               setBodyLayout();
+
+               Composite body = getBodyComposite();
+               httpItem = new AddressPortItem(this, body, makeLayoutData(), "HTTP");
+               httpCheckItem = new HTTPCheckBoxItem(this, body, makeLayoutData());
+               httpsItem = new AddressPortItem(this, body, makeLayoutData(), "HTTPS");
+               ftpItem = new AddressPortItem(this, body, makeLayoutData(), "FTP");
+               socksItem = new AddressPortItem(this, body, makeLayoutData(), "SOCKS");
+
+               settingItemValue();
+       }
+
+       private void setBodyLayout() {
+               GridLayout layout = new GridLayout();
+               layout.numColumns = 1;
+               layout.verticalSpacing = 0;
+               layout.marginHeight = CONTENT_MARGIN_HEIGHT;
+               layout.marginWidth = CONTENT_MARGIN_WIDTH;
+               getBodyComposite().setLayout(layout);
+               getBodyComposite().setBackground(ColorResources.WHITE.getColor());
+       }
+
+       public GridData makeLayoutData() {
+               GridData data = new GridData(GridData.FILL, SWT.NONE, true, false);
+               data.heightHint = (getBodyHeight() - CONTENT_MARGIN_HEIGHT * 2) / 5;
+               return data;
+       }
+
+       public void setApplyAllProtocol(boolean isApplyAll) {
+               httpsItem.setEnabled(!isApplyAll);
+               ftpItem.setEnabled(!isApplyAll);
+               socksItem.setEnabled(!isApplyAll);
+
+               if (isApplyAll) {
+                       if (!httpItem.getIP().isEmpty()
+                                       && !httpItem.getPort().isEmpty()
+                                       && !httpItem.getPort().equals("0")) {
+                               setOKButtonEnable(true);
+
+                       } else {
+                               setOKButtonEnable(false);
+                       }
+               }
+       }
+
+       public void checkAllValues() {
+               setOKButtonEnable(
+                               (httpItem.checkValue() && httpsItem.checkValue()
+                               && ftpItem.checkValue() && socksItem.checkValue())
+                               );
+       }
+
+       // Set existing address value to text box.
+       // Value have forms of "{http}, {https}, {ftp}, {socks}.
+       // ex : "192.168.1.1:8181, 192.168.1.1:8181, 192.168.1.1:8181, 192.168.1.1:8181"
+       private void settingItemValue() {
+               if (value == null) {
+                       return;
+               }
+
+               String ipPortArr[] = value.split(","); //$NON-NLS-1$
+
+               try {
+                       httpItem.setIpPort(ipPortArr[0]);
+                       httpsItem.setIpPort(ipPortArr[1]);
+                       ftpItem.setIpPort(ipPortArr[2]);
+                       socksItem.setIpPort(ipPortArr[3]);
+               } catch (ArrayIndexOutOfBoundsException e) {
+                       // Nothing to do. Expected exception.
+               }
+       }
+}
+
index 71970e3..c831c92 100644 (file)
@@ -61,7 +61,7 @@ public class CheckBoxSubItem {
        private boolean isUse = true;
 
        public static final int CHECK_BOX_WIDTH = 15;
-       private final int CHECK_BOX_HEIGHT = 14;
+       public static final int CHECK_BOX_HEIGHT = 14;
        public static final int SPACING = 2;
 
        private final int ROW_HEIGHT = ModifyItem.ITEM_HEIGHT + ModifyItem.LINE_WIDTH;
index bba469f..c4e1cf0 100644 (file)
@@ -44,7 +44,7 @@ import org.tizen.emulator.manager.renewal.resources.ColorResources;
 import org.tizen.emulator.manager.renewal.resources.ImageResources;
 import org.tizen.emulator.manager.resources.StringResources;
 import org.tizen.emulator.manager.ui.Messages;
-import org.tizen.emulator.manager.ui.dialog.ProxyDialog;
+import org.tizen.emulator.manager.ui.renewal.dialog.network.ProxyDialog;
 import org.tizen.emulator.manager.ui.renewal.item.ItemName;
 import org.tizen.emulator.manager.ui.renewal.item.ItemState;
 import org.tizen.emulator.manager.ui.renewal.item.modify.common.ComboItem;
@@ -148,7 +148,8 @@ public class NetProxyItem extends ComboItem{
                        @Override
                        public void handleEvent(Event event) {
                                if (event.type == SWT.Selection) {
-                                       settingAddress(ProxyDialog.open(makeDialogValue()));
+                                       settingAddress(ProxyDialog.open(getItemListComp().getShell(),
+                                                       makeDialogValue()));
                                        getItemListComp().checkValid();
                                }
                        }
index 8099118..e067b62 100644 (file)
@@ -67,6 +67,10 @@ public class TextInputBox extends NinePatchBox{
                this(parent, style, false);
        }
 
+       public void setTextLimit(int limit) {
+               text.setTextLimit(limit);
+       }
+
        /**
         * If 'needClearButton' value is true,
         * need to call 'setClearButtonStatus' function when text is modified.
index 3d439ce..5627182 100644 (file)
@@ -86,6 +86,7 @@ public class WidgetHelper {
                                        int itemWidth = ((Composite)e.widget).getBounds().width;
                                        posX = (itemWidth - textExt.x)/ 2;
                                }
+
                                String displayText = shortenText(gc, text,  ((Composite)e.widget).getClientArea());
                                gc.drawText(displayText, posX, posY);
                        }
@@ -103,6 +104,10 @@ public class WidgetHelper {
                return p.x;
        }
 
+       public static int calcTextWidth(Composite comp, String text) {
+               return calcTextWidth(comp, text, FontResources.CONTENT.getFont());
+       }
+
        public static void drawSubTitle(Composite comp, final String text, final int horizentalAlign,
                        final int titleWidth) {
                comp.addPaintListener(new PaintListener() {