/** * Retrieves the error message associated to this composites current state. The order of * precedence of error is the same as the fields displayed on the UI, which means errors on fields * drawn first are shown with a higher precedence than the errors of fields drawn last. The * instance description field is the only non required field. * * @return the error message, or <code>null</code> if there are no errors */ @Override public String getErrorMessage() { String errMsg = null; Status status = MonkeyOptionsMgt.validate(); if (status.getSeverity() == IStatus.ERROR) { errMsg = status.getMessage(); } return errMsg; }
/** * Creates a MonkeyOptionsComposite object. * * @param parent the parent composite */ public MonkeyOptionsComposite(Composite parent, String monkeyOptions) { super(parent); MonkeyOptionsMgt.loadFromCommandLine(monkeyOptions); createUI(); // Set context Help // PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, // IAndroidDeviceConstants.STARTUP_OPTIONS_HELP); }
/** Create widgets for monkey options */ private void createUI() { Composite mainComposite = this; Layout mainLayout = new GridLayout(); mainComposite.setLayout(mainLayout); // list of monkey options groups List<MonkeyOptionsGroup> monkeyOptionsGroupsList = MonkeyOptionsMgt.getMonkeyOptionsGroupsList(); // list of monkey options in each group List<MonkeyOption> monkeyOptions = null; // Create Tab Folder final TabFolder tabFolder = new TabFolder(mainComposite, SWT.NULL); GridData data = new GridData(SWT.FILL, SWT.FILL, true, false); data.heightHint = TABFOLDER_HEIGHT_HINT; tabFolder.setLayoutData(data); /* * Iterate through Monkey Groups */ for (MonkeyOptionsGroup monkeyOptionGroup : monkeyOptionsGroupsList) { // Create Tab Item TabItem tabItem = new TabItem(tabFolder, SWT.NULL); tabItem.setText(monkeyOptionGroup.getTitle()); Composite group = new Composite(tabFolder, SWT.NULL); group.setLayout(new GridLayout(3, false)); group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); tabItem.setControl(group); // get monkey options in this group monkeyOptions = monkeyOptionGroup.getMonkeyOptions(); /* * Iterate through Monkey Options in this group */ for (final MonkeyOption monkeyOption : monkeyOptions) { // create a checkbox for each monkey option Button checkbox = new Button(group, SWT.CHECK); checkbox.setSelection(monkeyOption.isChecked()); checkbox.setText(monkeyOption.getUserFriendlyName()); checkbox.setToolTipText(monkeyOption.getName() + ": " + monkeyOption.getDescription()); monkeyOption.setCheckedWidget(checkbox); checkbox.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { boolean checkedStatus = ((Button) e.widget).getSelection(); monkeyOption.setChecked(checkedStatus); notifyCompositeChangeListeners(); } }); GridData checkboxData = new GridData(SWT.NULL, SWT.FILL, false, false); checkbox.setLayoutData(checkboxData); // Create input fields depending on the monkey option type switch (monkeyOption.getType()) { case TYPE_NONE: // extend checkbox area along the line checkboxData.widthHint = SWT.DEFAULT; checkboxData.horizontalSpan = 3; checkbox.setLayoutData(checkboxData); break; case TYPE_TEXT: case TYPE_NUMBER: createWidgetsForTextOrNumberType(group, monkeyOption); break; case TYPE_PATH: createWidgetsForPathType(group, monkeyOption); break; default: // none } } } /* * Command Line area */ Composite commandLineArea = new Composite(mainComposite, SWT.NONE); // composite commandLineArea.setLayout(new GridLayout(2, false)); data = new GridData(SWT.FILL, SWT.FILL, true, true); commandLineArea.setLayoutData(data); Label commandLineLabel = new Label(commandLineArea, SWT.NONE); // label commandLineLabel.setText(AndroidNLS.UI_MonkeyOptions_CommandLine); data = new GridData(SWT.FILL, SWT.FILL, false, true); commandLineLabel.setLayoutData(data); commandLine = new Text(commandLineArea, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL); // text data = new GridData(SWT.FILL, SWT.FILL, true, true); commandLineArea.pack(); data.widthHint = commandLineArea.getBounds().width - commandLineLabel.getBounds().width; data.heightHint = commandLineArea.getBounds().height; commandLine.setLayoutData(data); commandLine.setText(MonkeyOptionsMgt.getParamList()); commandLine.setEditable(false); }
/** * Reload the values being displayed in the UI as well as the ones in the model. * * @param monkeyOptions commandLine the command line used to start the emulator */ public void reloadValues(String commandLine) { MonkeyOptionsMgt.loadFromCommandLine(commandLine); }
/** * Update command line value * * @see * org.eclipse.andmore.android.emulator.device.ui.AbstractPropertiesComposite#notifyCompositeChangeListeners() */ @Override protected void notifyCompositeChangeListeners() { commandLine.setText(MonkeyOptionsMgt.getParamList()); super.notifyCompositeChangeListeners(); }