org.symbian.tools.mtw.ui/src/org/symbian/tools/mtw/internal/deployment/DeploymentTargetWizardPage.java
changeset 457 f1087591ff71
parent 455 5da55957c779
child 458 5ff93668b08c
equal deleted inserted replaced
456:12b549765c34 457:f1087591ff71
    18  */
    18  */
    19 package org.symbian.tools.mtw.internal.deployment;
    19 package org.symbian.tools.mtw.internal.deployment;
    20 
    20 
    21 import java.lang.reflect.InvocationTargetException;
    21 import java.lang.reflect.InvocationTargetException;
    22 import java.text.MessageFormat;
    22 import java.text.MessageFormat;
       
    23 import java.util.HashMap;
       
    24 import java.util.Map;
    23 
    25 
    24 import org.eclipse.core.runtime.CoreException;
    26 import org.eclipse.core.runtime.CoreException;
    25 import org.eclipse.core.runtime.IProgressMonitor;
    27 import org.eclipse.core.runtime.IProgressMonitor;
    26 import org.eclipse.core.runtime.IStatus;
    28 import org.eclipse.core.runtime.IStatus;
    27 import org.eclipse.core.runtime.SubProgressMonitor;
    29 import org.eclipse.core.runtime.SubProgressMonitor;
    46 import org.eclipse.swt.layout.FormAttachment;
    48 import org.eclipse.swt.layout.FormAttachment;
    47 import org.eclipse.swt.layout.FormData;
    49 import org.eclipse.swt.layout.FormData;
    48 import org.eclipse.swt.layout.FormLayout;
    50 import org.eclipse.swt.layout.FormLayout;
    49 import org.eclipse.swt.widgets.Button;
    51 import org.eclipse.swt.widgets.Button;
    50 import org.eclipse.swt.widgets.Composite;
    52 import org.eclipse.swt.widgets.Composite;
    51 import org.eclipse.swt.widgets.Text;
    53 import org.eclipse.swt.widgets.Control;
    52 import org.eclipse.ui.model.WorkbenchLabelProvider;
    54 import org.eclipse.ui.model.WorkbenchLabelProvider;
       
    55 import org.eclipse.ui.part.PageBook;
    53 import org.symbian.tools.mtw.ui.MTWCoreUI;
    56 import org.symbian.tools.mtw.ui.MTWCoreUI;
    54 import org.symbian.tools.mtw.ui.ProjectMemo;
    57 import org.symbian.tools.mtw.ui.ProjectMemo;
    55 import org.symbian.tools.mtw.ui.deployment.IDeploymentTarget;
    58 import org.symbian.tools.mtw.ui.deployment.IDeploymentTarget;
       
    59 import org.symbian.tools.mtw.ui.deployment.IDeploymentTargetType;
       
    60 import org.symbian.tools.mtw.ui.deployment.ITargetDetailsPane;
    56 
    61 
    57 public class DeploymentTargetWizardPage extends WizardPage {
    62 public class DeploymentTargetWizardPage extends WizardPage {
    58     private final DeployWizardContext context;
    63     private final DeployWizardContext context;
    59     private TableViewer list;
    64     private TableViewer list;
    60     private Text description;
       
    61     private final IDeploymentTarget prev;
    65     private final IDeploymentTarget prev;
       
    66     private PageBook descriptions;
       
    67     private final Map<IDeploymentTargetType, ITargetDetailsPane> panes = new HashMap<IDeploymentTargetType, ITargetDetailsPane>();
       
    68     private Control emptyness;
    62 
    69 
    63     public DeploymentTargetWizardPage(DeployWizardContext context, ProjectMemo memo) {
    70     public DeploymentTargetWizardPage(DeployWizardContext context, ProjectMemo memo) {
    64         super("TargetPage", "Select Deployment Target", null);
    71         super("TargetPage", "Select Deployment Target", null);
    65         this.context = context;
    72         this.context = context;
    66         prev = memo.getPreviousDeploymentTarget();
    73         prev = memo.getPreviousDeploymentTarget();
   107             }
   114             }
   108         });
   115         });
   109         search.setText("Discover");
   116         search.setText("Discover");
   110         search.setImage(MTWCoreUI.getImages().getDiscoverButtonIcon());
   117         search.setImage(MTWCoreUI.getImages().getDiscoverButtonIcon());
   111 
   118 
   112         description = new Text(root, SWT.BORDER | SWT.READ_ONLY);
   119         descriptions = new PageBook(root, SWT.BORDER);
   113         final Button enableLogging = new Button(root, SWT.CHECK);
   120         emptyness = new Composite(descriptions, SWT.NONE);
   114         enableLogging.setText("Enable diagnostic logging");
       
   115         enableLogging.addSelectionListener(new SelectionAdapter() {
       
   116             @Override
       
   117             public void widgetSelected(SelectionEvent e) {
       
   118                 toggleLogging(enableLogging.getSelection());
       
   119             }
       
   120         });
       
   121 
   121 
   122         FormData data = new FormData();
   122         FormData data = new FormData();
   123         data.bottom = new FormAttachment(100, -5);
       
   124         data.left = new FormAttachment(0, 5);
       
   125         enableLogging.setLayoutData(data);
       
   126 
       
   127         data = new FormData();
       
   128         data.left = new FormAttachment(0, 5);
   123         data.left = new FormAttachment(0, 5);
   129         data.right = new FormAttachment(100, -5);
   124         data.right = new FormAttachment(100, -5);
   130         data.bottom = new FormAttachment(enableLogging, -20);
   125         data.bottom = new FormAttachment(100, -5);
   131         description.setLayoutData(data);
   126         data.height = 50;
       
   127         descriptions.setLayoutData(data);
   132 
   128 
   133         data = new FormData();
   129         data = new FormData();
   134         data.top = new FormAttachment(0, 5);
   130         data.top = new FormAttachment(0, 5);
   135         data.right = new FormAttachment(100, -5);
   131         data.right = new FormAttachment(100, -5);
   136         search.setLayoutData(data);
   132         search.setLayoutData(data);
   137 
   133 
   138         data = new FormData();
   134         data = new FormData();
   139         data.left = new FormAttachment(0, 5);
   135         data.left = new FormAttachment(0, 5);
   140         data.top = new FormAttachment(0, 5);
   136         data.top = new FormAttachment(0, 5);
   141         data.bottom = new FormAttachment(description, -10);
   137         data.bottom = new FormAttachment(descriptions, -10);
   142         data.right = new FormAttachment(search, -10);
   138         data.right = new FormAttachment(search, -10);
   143 
   139 
   144         list.getControl().setLayoutData(data);
   140         list.getControl().setLayoutData(data);
   145 
   141 
   146         list.setInput(context.getDeploymentTargets());
   142         list.setInput(context.getDeploymentTargets());
   194     }
   190     }
   195 
   191 
   196     protected void selectDeploymentTarget(DeploymentTargetWrapper target) {
   192     protected void selectDeploymentTarget(DeploymentTargetWrapper target) {
   197         if (target != null) {
   193         if (target != null) {
   198             context.setTarget(target);
   194             context.setTarget(target);
   199             //            String desc = target.getDescription();
       
   200             //            this.description.setText(desc);
       
   201             setMessage(null);
   195             setMessage(null);
   202             setErrorMessage(null);
   196             setErrorMessage(null);
   203             setPageComplete(true);
   197             setPageComplete(true);
       
   198 
       
   199             IDeploymentTargetType type = target.getType();
       
   200             ITargetDetailsPane pane = panes.get(type);
       
   201             if (pane == null) {
       
   202                 pane = MTWCoreUI.getDefault().getPresentations().createDetailsPane(type);
       
   203                 pane.createControl(descriptions);
       
   204                 pane.init(this);
       
   205                 panes.put(type, pane);
       
   206             }
       
   207             pane.setTarget(target.getActualTarget());
       
   208             descriptions.showPage(pane.getControl());
   204         } else {
   209         } else {
       
   210             descriptions.showPage(emptyness);
   205             context.setTarget(null);
   211             context.setTarget(null);
   206             //            description.setText("");
       
   207             setPageComplete(false);
   212             setPageComplete(false);
   208             setMessage(null);
   213             setMessage(null);
   209             setErrorMessage("Select device or emulator to deploy the application");
   214             setErrorMessage("Select device or emulator to deploy the application");
   210         }
   215         }
   211     }
   216     }