|
25 | 25 | import io.sloeber.ui.helpers.MyPreferences; |
26 | 26 |
|
27 | 27 | public class ThirdPartyHardwareSelectionPage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { |
28 | | - |
29 | | - private Text urlsText; |
30 | | - BooleanFieldEditor upDateJsons; |
31 | | - |
32 | | - public ThirdPartyHardwareSelectionPage() { |
33 | | - super(org.eclipse.jface.preference.FieldEditorPreferencePage.GRID); |
34 | | - setDescription(Messages.json_maintain); |
35 | | - setPreferenceStore(new ScopedPreferenceStore(ConfigurationScope.INSTANCE, MyPreferences.NODE_ARDUINO)); |
36 | | - } |
37 | | - |
38 | | - @Override |
39 | | - public boolean performOk() { |
40 | | - BoardsManager.setBoardsPackageURL(this.urlsText.getText().split(System.lineSeparator())); |
41 | | - return super.performOk(); |
42 | | - } |
43 | | - |
44 | | - @Override |
45 | | - protected void performDefaults() { |
46 | | - super.performDefaults(); |
47 | | - this.urlsText.setText(BoardsManager.getDefaultBoardsPackageURLs()); |
48 | | - } |
49 | | - |
50 | | - @Override |
51 | | - protected void createFieldEditors() { |
52 | | - String selectedJsons[] = BoardsManager.getBoardsPackageURLList(); |
53 | | - final Composite parent = getFieldEditorParent(); |
54 | | - // Composite control = new Composite(parent, SWT.NONE); |
55 | | - Label title = new Label(parent, SWT.UP); |
56 | | - title.setFont(parent.getFont()); |
57 | | - |
58 | | - title.setText(Messages.ui_url_for_package_index_file); |
59 | | - title.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); |
60 | | - |
61 | | - this.urlsText = new Text(parent, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER | SWT.WRAP); |
62 | | - GridData gd = new GridData(GridData.FILL_BOTH); |
63 | | - this.urlsText.setLayoutData(gd); |
64 | | - this.urlsText.setText(StringUtil.join(selectedJsons, System.lineSeparator())); |
65 | | - |
66 | | - this.upDateJsons = new BooleanFieldEditor(BoardsManager.getUpdateJasonFilesKey(), Messages.json_update, |
67 | | - BooleanFieldEditor.DEFAULT, parent); |
68 | | - addField(this.upDateJsons); |
69 | | - final Hyperlink link = new Hyperlink(parent, SWT.NONE); |
70 | | - link.setText(Messages.json_find); |
71 | | - link.setHref("https://github.com/arduino/Arduino/wiki/Unofficial-list-of-3rd-party-boards-support-urls"); //$NON-NLS-1$ |
72 | | - link.setUnderlined(true); |
73 | | - link.addHyperlinkListener(new HyperlinkAdapter() { |
74 | | - @Override |
75 | | - public void linkActivated(HyperlinkEvent he) { |
76 | | - try { |
77 | | - org.eclipse.swt.program.Program.launch(link.getHref().toString()); |
78 | | - } catch (IllegalArgumentException e) { |
79 | | - Activator.log(new Status(IStatus.ERROR, Activator.getId(), Messages.json_browser_fail, e)); |
80 | | - } |
81 | | - } |
82 | | - }); |
83 | | - |
84 | | - } |
85 | | - |
86 | | - @Override |
87 | | - public void init(IWorkbench arg0) { |
88 | | - // Nothing to do here |
89 | | - |
90 | | - } |
| 28 | + private static final String KEY_UPDATE_JASONS = "Update jsons files"; //$NON-NLS-1$ |
| 29 | + private Text urlsText; |
| 30 | + BooleanFieldEditor upDateJsons; |
| 31 | + |
| 32 | + public ThirdPartyHardwareSelectionPage() { |
| 33 | + super(org.eclipse.jface.preference.FieldEditorPreferencePage.GRID); |
| 34 | + setDescription(Messages.json_maintain); |
| 35 | + setPreferenceStore(new ScopedPreferenceStore(ConfigurationScope.INSTANCE, MyPreferences.NODE_ARDUINO)); |
| 36 | + } |
| 37 | + |
| 38 | + @Override |
| 39 | + public boolean performOk() { |
| 40 | + BoardsManager.setBoardsPackageURL(this.urlsText.getText().split(System.lineSeparator())); |
| 41 | + BoardsManager.setUpdateJsonFilesFlag(this.upDateJsons.getBooleanValue()); |
| 42 | + return super.performOk(); |
| 43 | + } |
| 44 | + |
| 45 | + @Override |
| 46 | + protected void performDefaults() { |
| 47 | + super.performDefaults(); |
| 48 | + this.urlsText.setText(BoardsManager.getDefaultBoardsPackageURLs()); |
| 49 | + } |
| 50 | + |
| 51 | + @Override |
| 52 | + protected void createFieldEditors() { |
| 53 | + String selectedJsons[] = BoardsManager.getBoardsPackageURLList(); |
| 54 | + final Composite parent = getFieldEditorParent(); |
| 55 | + // Composite control = new Composite(parent, SWT.NONE); |
| 56 | + Label title = new Label(parent, SWT.UP); |
| 57 | + title.setFont(parent.getFont()); |
| 58 | + |
| 59 | + title.setText(Messages.ui_url_for_package_index_file); |
| 60 | + title.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); |
| 61 | + |
| 62 | + this.urlsText = new Text(parent, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER | SWT.WRAP); |
| 63 | + GridData gd = new GridData(GridData.FILL_BOTH); |
| 64 | + this.urlsText.setLayoutData(gd); |
| 65 | + this.urlsText.setText(StringUtil.join(selectedJsons, System.lineSeparator())); |
| 66 | + |
| 67 | + this.upDateJsons = new BooleanFieldEditor(KEY_UPDATE_JASONS, Messages.json_update, BooleanFieldEditor.DEFAULT, |
| 68 | + parent); |
| 69 | + addField(this.upDateJsons); |
| 70 | + final Hyperlink link = new Hyperlink(parent, SWT.NONE); |
| 71 | + link.setText(Messages.json_find); |
| 72 | + link.setHref("https://github.com/arduino/Arduino/wiki/Unofficial-list-of-3rd-party-boards-support-urls"); //$NON-NLS-1$ |
| 73 | + link.setUnderlined(true); |
| 74 | + link.addHyperlinkListener(new HyperlinkAdapter() { |
| 75 | + @Override |
| 76 | + public void linkActivated(HyperlinkEvent he) { |
| 77 | + try { |
| 78 | + org.eclipse.swt.program.Program.launch(link.getHref().toString()); |
| 79 | + } catch (IllegalArgumentException e) { |
| 80 | + Activator.log(new Status(IStatus.ERROR, Activator.getId(), Messages.json_browser_fail, e)); |
| 81 | + } |
| 82 | + } |
| 83 | + }); |
| 84 | + |
| 85 | + } |
| 86 | + |
| 87 | + @Override |
| 88 | + public void init(IWorkbench arg0) { |
| 89 | + // Nothing to do here |
| 90 | + |
| 91 | + } |
91 | 92 |
|
92 | 93 | } |
0 commit comments