private void doOK() { ICConfigurationDescription confdesc = getConfdesc(); if (confdesc != null) { saveAllSelections(confdesc); IProject project = confdesc.getProjectDescription().getProject(); Helpers.setTheEnvironmentVariables(project, confdesc, false); try { Helpers.addArduinoCodeToProject(project, confdesc); } catch (CoreException e1) { Common.log( new Status( IStatus.ERROR, Const.CORE_PLUGIN_ID, Messages.error_adding_arduino_code, e1)); } Helpers.removeInvalidIncludeFolders(confdesc); Helpers.setDirtyFlag(project, confdesc); } }
public void draw(Composite composite) { // create the desired layout for this wizard page ICConfigurationDescription confdesc = getConfdesc(); GridLayout theGridLayout = new GridLayout(); theGridLayout.numColumns = this.ncol; composite.setLayout(theGridLayout); GridData theGriddata; this.mAllBoardsFileNames = Helpers.getBoardsFiles(); if (this.mAllBoardsFileNames == null) { Common.log( new Status( IStatus.ERROR, Const.CORE_PLUGIN_ID, "ArduinoHelpers.getBoardsFiles() returns null.\nThis should not happen.\nIt looks like the download of the boards failed.")); //$NON-NLS-1$ } Arrays.sort(this.mAllBoardsFileNames); this.mAllBoardsFiles = new Boards[this.mAllBoardsFileNames.length]; for (int currentBoardFile = 0; currentBoardFile < this.mAllBoardsFileNames.length; currentBoardFile++) { this.mAllBoardsFiles[currentBoardFile] = new Boards(new File(this.mAllBoardsFileNames[currentBoardFile])); } switch (this.mAllBoardsFileNames.length) { case 0: Common.log( new Status( IStatus.ERROR, Const.CORE_PLUGIN_ID, Messages.error_no_platform_files_found, null)); break; case 1: { break; } default: { // create a combo to select the boards createLabel(composite, this.ncol, "The boards.txt file you want to use"); // $NON-NLS-1$ new Label(composite, SWT.NONE).setText("Boards.txt file:"); // $NON-NLS-1$ } } this.mControlBoardsTxtFile = new Combo(composite, SWT.BORDER | SWT.READ_ONLY); theGriddata = new GridData(); theGriddata.horizontalAlignment = SWT.FILL; theGriddata.horizontalSpan = (this.ncol - 1); this.mControlBoardsTxtFile.setLayoutData(theGriddata); this.mControlBoardsTxtFile.setEnabled(false); this.mControlBoardsTxtFile.setItems(this.mAllBoardsFileNames); createLine(composite, this.ncol); // ------- // ------ createLabel(composite, this.ncol, "Your Arduino board specifications"); // $NON-NLS-1$ new Label(composite, SWT.NONE).setText("Board:"); // $NON-NLS-1$ this.mcontrolBoardName = new Combo(composite, SWT.BORDER | SWT.READ_ONLY); theGriddata = new GridData(); theGriddata.horizontalAlignment = SWT.FILL; theGriddata.horizontalSpan = (this.ncol - 1); this.mcontrolBoardName.setLayoutData(theGriddata); this.mcontrolBoardName.setEnabled(false); // ---- this.mControlUploadPort = new LabelCombo( composite, Messages.ui_port, this.ncol - 1, Const.ENV_KEY_JANTJE_COM_PORT, false); this.mControlUploadPort.setItems( ArrayUtil.addAll(Activator.bonjourDiscovery.getList(), Common.listComPorts())); createLine(composite, this.ncol); String[] menuNames = new String[30]; for (int curBoardsFile = 0; curBoardsFile < this.mAllBoardsFiles.length; curBoardsFile++) { ArrayUtil.addAll(menuNames, this.mAllBoardsFiles[curBoardsFile].getMenuNames()); } menuNames = ArrayUtil.removeDuplicates(menuNames); this.mBoardOptionCombos = new LabelCombo[menuNames.length]; for (int currentOption = 0; currentOption < menuNames.length; currentOption++) { String menuName = menuNames[currentOption]; this.mBoardOptionCombos[currentOption] = new LabelCombo( composite, menuName, this.ncol - 1, Const.ENV_KEY_JANTJE_START + menuName, true); } // Create the control to alert parents of changes this.mFeedbackControl = new Text(composite, SWT.None); this.mFeedbackControl.setVisible(false); this.mFeedbackControl.setEnabled(false); theGriddata = new GridData(); theGriddata.horizontalSpan = 0; this.mFeedbackControl.setLayoutData(theGriddata); // End of special controls setValues(confdesc); // enable the listeners childFieldListener controlUploadPortlistener = new childFieldListener(); controlUploadPortlistener.setInfo(this.mControlUploadPort); this.mControlUploadPort.addListener(controlUploadPortlistener); this.mcontrolBoardName.addListener(SWT.Modify, this.BoardModifyListener); this.mControlBoardsTxtFile.addListener(SWT.Modify, this.boardFileModifyListener); for (LabelCombo curLabelCombo : this.mBoardOptionCombos) { childFieldListener comboboxModifyListener = new childFieldListener(); comboboxModifyListener.setInfo(curLabelCombo); curLabelCombo.addListener(comboboxModifyListener); } EnableControls(); Dialog.applyDialogFont(composite); }