RTSDK : Update layout of build wizard
authordaeryong.park <bdragon.park@samsung.com>
Tue, 4 Apr 2017 08:07:32 +0000 (17:07 +0900)
committerdaeryong.park <bdragon.park@samsung.com>
Tue, 4 Apr 2017 08:21:23 +0000 (17:21 +0900)
- Move kernel config button to the bottom
- Update margin and size of toolchain select widgets

Change-Id: I19370b89864e766914b25f53667f9044e2a58ad5
Signed-off-by: daeryong.park <bdragon.park@samsung.com>
rt-ide/tizen.rt.product.plugin/src/org/tizen/rt/ide/build/RtosBuildDialogPage.java
rt-ide/tizen.rt.product.plugin/src/org/tizen/rt/ide/build/RtosBuildWizardDialog.java

index b96d493..8c04b89 100644 (file)
 package org.tizen.rt.ide.build;
 
 import java.io.File;
-import java.io.IOException;
 import java.util.List;
 
-import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.jface.viewers.ArrayContentProvider;
 import org.eclipse.jface.viewers.DoubleClickEvent;
 import org.eclipse.jface.viewers.IDoubleClickListener;
@@ -47,15 +45,14 @@ import org.eclipse.swt.SWT;
 import org.eclipse.swt.browser.Browser;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
 import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.layout.RowLayout;
 import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.DirectoryDialog;
-import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.swt.widgets.Table;
@@ -63,7 +60,6 @@ import org.eclipse.swt.widgets.TableColumn;
 import org.eclipse.swt.widgets.Text;
 import org.tizen.rt.ide.Messages;
 import org.tizen.rt.ide.RtosCommandManager;
-import org.tizen.rt.ide.util.ResourceUtil;
 
 /**
  * DeviceGuideDialogPage Select Emulator Wizard Feature
@@ -73,7 +69,6 @@ public class RtosBuildDialogPage extends WizardPage {
 
     public final static String DEFAULT_DESC_FILE = "index.html"; //$NON-NLS-1$
     public final static String DEFAULT_DESC_HTML_FORMAT = "<html><body><h2>%s</h2>App : %s</body></html>"; //$NON-NLS-1$
-    public final static String[] KERNEL_CONFIG_CMD = new String[] { "gnome-terminal", "--command", "make menuconfig" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
 
     private Shell shell;
     private Table buildOptionTable;
@@ -81,7 +76,6 @@ public class RtosBuildDialogPage extends WizardPage {
     private TableViewer boardTableViewer;
     private TableViewer buildOptionTableViewer;
     private Button selectToolchainBtn;
-    private Button kernelConfigBtn;
     private Browser browser;
     private Text toolchainText;
     private Composite composite;
@@ -165,7 +159,7 @@ public class RtosBuildDialogPage extends WizardPage {
                 IStructuredSelection selection = (IStructuredSelection) event.getSelection();
                 if (selection.isEmpty()) {
                     browser.setText(""); //$NON-NLS-1$
-                    kernelConfigBtn.setEnabled(false);
+                    getKernelConfigBtn().setEnabled(false);
                     setPageComplete(false);
                 } else {
                     for (Object o : selection.toArray()) {
@@ -177,7 +171,7 @@ public class RtosBuildDialogPage extends WizardPage {
                         } else {
                             browser.setText(String.format(DEFAULT_DESC_HTML_FORMAT, bOption.getBoard(), bOption.getBuildOption()));
                         }
-                        kernelConfigBtn.setEnabled(true);
+                        getKernelConfigBtn().setEnabled(true);
                         setPageComplete(true);
                     }
                 }
@@ -205,11 +199,14 @@ public class RtosBuildDialogPage extends WizardPage {
         browser.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
 
         composite = new Composite(container, SWT.NONE);
-        composite.setLayout(new GridLayout(4, false));
+        GridLayout toolchainLayout = new GridLayout(4, false);
+        toolchainLayout.marginWidth = 0;
+        toolchainLayout.marginHeight = 0;
+        composite.setLayout(toolchainLayout);
         composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
 
         lblNewLabel = new Label(composite, SWT.NONE);
-        lblNewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
+        lblNewLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1));
         lblNewLabel.setText(Messages.RtosBuildDialogPage_lblNewLabel_text);
 
         toolchainText = new Text(composite, SWT.BORDER);
@@ -218,14 +215,20 @@ public class RtosBuildDialogPage extends WizardPage {
 
         selectToolchainBtn = new Button(composite, SWT.NONE);
         selectToolchainBtn.setText(Messages.RtosBuildDialogPage_ToolchainButtonText);
+        gd = new GridData(SWT.RIGHT, SWT.CENTER, false, false);
+        gd.widthHint = 80;
+        selectToolchainBtn.setLayoutData(gd);
 
         clearToolchainBtn = new Button(composite, SWT.NONE);
         clearToolchainBtn.setText(Messages.RtosBuildDialogPage_clearToolchainBtn_text);
+        gd = new GridData(SWT.RIGHT, SWT.CENTER, false, false);
+        gd.widthHint = 80;
+        clearToolchainBtn.setLayoutData(gd);
 
         selectToolchainBtn.addSelectionListener(new SelectionAdapter() {
             @Override
             public void widgetSelected(SelectionEvent arg0) {
-                DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.SHEET);
+                DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.APPLICATION_MODAL);
                 dialog.setMessage(Messages.RtosBuildDialogPage_ToolchainDialogMessage);
                 String toolchainPath = dialog.open();
                 if (toolchainPath != null) {
@@ -252,32 +255,16 @@ public class RtosBuildDialogPage extends WizardPage {
         btnLayout.pack = false;
         btnGroupComposite.setLayout(btnLayout);
 
-        kernelConfigBtn = new Button(btnGroupComposite, SWT.NONE);
-        kernelConfigBtn.setText(Messages.RtosBuildDialogPage_KernelConfigButtonText);
-        kernelConfigBtn.setEnabled(false);
-        kernelConfigBtn.addSelectionListener(new SelectionListener() {
-            @Override
-            public void widgetDefaultSelected(SelectionEvent arg0) {
-            }
-
-            @Override
-            public void widgetSelected(SelectionEvent arg0) {
-                try {
-                    Runtime.getRuntime().exec(KERNEL_CONFIG_CMD, null,
-                            new File(ResourceUtil.getCurrentProject().getLocation().toString() + File.separator + "os")); //$NON-NLS-1$
-                } catch (IOException e) {
-                    MessageDialog.openError(Display.getDefault().getActiveShell(), "Error", Messages.RtosBuildDialogPage_KconfigErrorMessage); //$NON-NLS-1$
-                    return;
-                }
-            }
-        });
-
         initialize();
         dialogChanged();
 
         setControl(parentComposite);
     }
 
+    protected Control getKernelConfigBtn() {
+        return ((RtosBuildWizardDialog) getContainer()).getKernelConfigButton();
+    }
+
     /**
      * Tests if the current workbench selection is a suitable container to use.
      */
index 1077d40..7375720 100644 (file)
 
 package org.tizen.rt.ide.build;
 
+import java.io.File;
+import java.io.IOException;
+
 import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.resource.JFaceResources;
 import org.eclipse.jface.wizard.IWizard;
 import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
 import org.eclipse.swt.graphics.Rectangle;
+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.Button;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Shell;
+import org.tizen.rt.ide.Messages;
 import org.tizen.rt.ide.util.OSChecker;
+import org.tizen.rt.ide.util.ResourceUtil;
 
 /**
  * RtosBuildWizardDialog
  * @author jm.jaemin.kim{@literal <jm.jaemin.kim>} (S-Core)
  */
 public class RtosBuildWizardDialog extends WizardDialog {
-    private Composite parent;
+
+    public static final String[] KERNEL_CONFIG_CMD = new String[] { "gnome-terminal", "--command", "make menuconfig" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+    public static final int KERNEL_CONFIG_BTN_ID = 9999;
+    public static final String LAUNCHER_LABEL = "Make"; //$NON-NLS-1$
+
     private int x = 0;
     private int y = 0;
     private final int width = OSChecker.isWindows() ? 800 : 875;
@@ -56,6 +75,8 @@ public class RtosBuildWizardDialog extends WizardDialog {
     private Button make;
     // private Button cancel;
 
+    private Button kernelConfigButton;
+
     public RtosBuildWizardDialog(Shell parentShell, IWizard newWizard) {
         super(parentShell, newWizard);
         Rectangle bounds = null;
@@ -105,12 +126,39 @@ public class RtosBuildWizardDialog extends WizardDialog {
     // @Override
     @Override
     protected void createButtonsForButtonBar(Composite p) {
-        this.parent = p;
-        super.createButtonsForButtonBar(parent);
-
-        String LAUNCHER_LABEL = "Make"; //$NON-NLS-1$
+        // Parent's LayoutData alignments changed SWT.RIGHT to SWT.FILL
+        // So kernel config button can located at left side of wizard
+        GridData data = new GridData(SWT.FILL, SWT.CENTER, true, false);
+        data.horizontalIndent = 10;
+        data.verticalIndent = 10;
+        p.setLayoutData(data);
+
+        // parent's layout changed GridLayout to FormLayout
+        // For kernel config button must be located at left side
+        // Other buttons must be located at right side
+        // FormLayout make this easy
+        FormLayout parentLayout = new FormLayout();
+        p.setLayout(parentLayout);
+
+        // create kernel config button
+        createKernelConfigButton(p);
+
+        // Wrap the rest of the basic buttons (make, cancel) in a composite
+        Composite comp = new Composite(p, SWT.NONE);
+        FormData fd = new FormData();
+        fd.right = new FormAttachment(100, -5);
+        fd.bottom = new FormAttachment(100, -10);
+        comp.setLayoutData(fd);
+        GridLayout gl = new GridLayout();
+        gl.marginWidth = 0;
+        gl.marginHeight = 0;
+        comp.setLayout(gl);
+
+        // create other buttons
+        super.createButtonsForButtonBar(comp);
 
         // LAUNCHER_LABEL
+        // OK button's label changed to "Make"
         make = getButton(IDialogConstants.FINISH_ID);
         make.setText(LAUNCHER_LABEL);
         make.addSelectionListener(new SelectionAdapter() {
@@ -123,4 +171,37 @@ public class RtosBuildWizardDialog extends WizardDialog {
         setButtonLayoutData(make);
     }
 
+    private void createKernelConfigButton(Composite parent) {
+        kernelConfigButton = new Button(parent, SWT.PUSH);
+        kernelConfigButton.setFont(JFaceResources.getDialogFont());
+        kernelConfigButton.setData(new Integer(KERNEL_CONFIG_BTN_ID));
+        kernelConfigButton.setText(Messages.RtosBuildDialogPage_KernelConfigButtonText);
+        kernelConfigButton.setEnabled(false);
+
+        FormData fd = new FormData();
+        fd.left = new FormAttachment(0, 0);
+        kernelConfigButton.setLayoutData(fd);
+
+        kernelConfigButton.addSelectionListener(new SelectionListener() {
+            @Override
+            public void widgetDefaultSelected(SelectionEvent arg0) {
+            }
+
+            @Override
+            public void widgetSelected(SelectionEvent arg0) {
+                try {
+                    Runtime.getRuntime().exec(KERNEL_CONFIG_CMD, null,
+                            new File(ResourceUtil.getCurrentProject().getLocation().toString() + File.separator + "os")); //$NON-NLS-1$
+                } catch (IOException e) {
+                    MessageDialog.openError(Display.getDefault().getActiveShell(), "Error", Messages.RtosBuildDialogPage_KconfigErrorMessage); //$NON-NLS-1$
+                    return;
+                }
+            }
+        });
+    }
+
+    public Button getKernelConfigButton() {
+        return kernelConfigButton;
+    }
+
 }