|
22 | 22 | * when opened and on the perform finish. This import wizard uses 3 folders to
|
23 | 23 | * import: The arduino library folder Your 3rd party library folder and the
|
24 | 24 | * Arduino library folder of your hardware
|
25 |
| - * |
| 25 | + * |
26 | 26 | * @author Jan Baeyens
|
27 | 27 | * @see performFinish
|
28 |
| - * |
| 28 | + * |
29 | 29 | */
|
30 | 30 | public class ImportLibraries implements IImportWizard {
|
31 | 31 |
|
32 |
| - private Import_Libraries_Page mProjectSelectionPage; |
33 |
| - private IWizardPage[] mPages; |
34 |
| - private IWizardContainer mWizardContainer = null; |
35 |
| - |
36 |
| - private static String mPageName = Messages.ui_select; |
37 |
| - private static String mPageTitle = Messages.ui_select_Arduino_libraries; |
38 |
| - |
39 |
| - @Override |
40 |
| - public void init(IWorkbench arg0, IStructuredSelection selection) { |
41 |
| - // Entry point is here when right-click project and import -- as opposed |
42 |
| - // to AddLibraryAction.execute() when done via Arduino menu |
43 |
| - } |
44 |
| - |
45 |
| - @Override |
46 |
| - public void addPages() { |
47 |
| - |
48 |
| - // Always create the pages like this at the last minute |
49 |
| - |
50 |
| - IProject theProject = null; |
51 |
| - IProject SelectedProjects[] = ProjectExplorerListener.getSelectedProjects(); |
52 |
| - |
53 |
| - if (SelectedProjects.length > 0) { |
54 |
| - theProject = SelectedProjects[0]; |
55 |
| - this.mProjectSelectionPage = new Import_Libraries_Page(theProject, mPageName, StructuredSelection.EMPTY); |
56 |
| - this.mProjectSelectionPage.setWizard(this); |
57 |
| - this.mPages = new IWizardPage[1]; |
58 |
| - this.mPages[0] = this.mProjectSelectionPage; |
59 |
| - } else { |
60 |
| - |
61 |
| - Activator.log(new Status(IStatus.ERROR, Activator.getId(), Messages.error_no_Arduino_project_selected)); |
62 |
| - } |
63 |
| - } |
64 |
| - |
65 |
| - @Override |
66 |
| - public boolean canFinish() { |
67 |
| - return true; |
68 |
| - } |
69 |
| - |
70 |
| - @Override |
71 |
| - public void createPageControls(Composite pageContainer) {// no code needed |
72 |
| - |
73 |
| - } |
74 |
| - |
75 |
| - @Override |
76 |
| - public void dispose() {// no code needed |
77 |
| - } |
78 |
| - |
79 |
| - @Override |
80 |
| - public IWizardContainer getContainer() { |
81 |
| - return this.mWizardContainer; |
82 |
| - } |
83 |
| - |
84 |
| - @Override |
85 |
| - public Image getDefaultPageImage() { |
86 |
| - return null; |
87 |
| - } |
88 |
| - |
89 |
| - @Override |
90 |
| - public IDialogSettings getDialogSettings() { |
91 |
| - return null; |
92 |
| - } |
93 |
| - |
94 |
| - @Override |
95 |
| - public IWizardPage getNextPage(IWizardPage arg0) { |
96 |
| - for (int i = 0; i < (this.mPages.length - 1); i++) { |
97 |
| - if (arg0 == this.mPages[i]) { |
98 |
| - return this.mPages[i + 1]; |
99 |
| - } |
100 |
| - } |
101 |
| - return null; |
102 |
| - } |
103 |
| - |
104 |
| - @Override |
105 |
| - public IWizardPage getPage(String pageName) { |
106 |
| - for (int i = 0; i < this.mPages.length; i++) { |
107 |
| - if (pageName == this.mPages[i].getName()) |
108 |
| - return this.mPages[i]; |
109 |
| - } |
110 |
| - return null; |
111 |
| - } |
112 |
| - |
113 |
| - @Override |
114 |
| - public int getPageCount() { |
115 |
| - return this.mPages.length; |
116 |
| - } |
117 |
| - |
118 |
| - @Override |
119 |
| - public IWizardPage[] getPages() { |
120 |
| - return this.mPages; |
121 |
| - } |
122 |
| - |
123 |
| - @Override |
124 |
| - public IWizardPage getPreviousPage(IWizardPage arg0) { |
125 |
| - for (int i = 1; i < this.mPages.length; i++) { |
126 |
| - if (arg0 == this.mPages[i]) |
127 |
| - return this.mPages[i - 1]; |
128 |
| - } |
129 |
| - return null; |
130 |
| - } |
131 |
| - |
132 |
| - @Override |
133 |
| - public IWizardPage getStartingPage() { |
134 |
| - return this.mPages[0]; |
135 |
| - } |
136 |
| - |
137 |
| - @Override |
138 |
| - public RGB getTitleBarColor() { |
139 |
| - return null; |
140 |
| - } |
141 |
| - |
142 |
| - @Override |
143 |
| - public String getWindowTitle() { |
144 |
| - return mPageTitle; |
145 |
| - } |
146 |
| - |
147 |
| - @Override |
148 |
| - public boolean isHelpAvailable() { |
149 |
| - return false; |
150 |
| - } |
151 |
| - |
152 |
| - @Override |
153 |
| - public boolean needsPreviousAndNextButtons() { |
154 |
| - return false; |
155 |
| - } |
156 |
| - |
157 |
| - @Override |
158 |
| - public boolean needsProgressMonitor() { |
159 |
| - return false; |
160 |
| - } |
161 |
| - |
162 |
| - @Override |
163 |
| - public boolean performCancel() { |
164 |
| - return true; |
165 |
| - } |
166 |
| - |
167 |
| - @Override |
168 |
| - public boolean performFinish() { |
169 |
| - return this.mProjectSelectionPage.PerformFinish(); |
170 |
| - } |
171 |
| - |
172 |
| - @Override |
173 |
| - public void setContainer(IWizardContainer wizardContainer) { |
174 |
| - this.mWizardContainer = wizardContainer; |
175 |
| - } |
| 32 | + private Import_Libraries_Page mProjectSelectionPage; |
| 33 | + private IWizardPage[] mPages; |
| 34 | + private IWizardContainer mWizardContainer = null; |
| 35 | + |
| 36 | + private static String mPageName = Messages.ui_select; |
| 37 | + private static String mPageTitle = Messages.ui_select_Arduino_libraries; |
| 38 | + |
| 39 | + @Override |
| 40 | + public void init(IWorkbench arg0, IStructuredSelection selection) { |
| 41 | + // Entry point is here when right-click project and import -- as opposed |
| 42 | + // to AddLibraryAction.execute() when done via Arduino menu |
| 43 | + } |
| 44 | + |
| 45 | + @Override |
| 46 | + public void addPages() { |
| 47 | + |
| 48 | + // Always create the pages like this at the last minute |
| 49 | + |
| 50 | + IProject theProject = null; |
| 51 | + IProject SelectedProjects[] = ProjectExplorerListener.getSelectedProjects(); |
| 52 | + |
| 53 | + if (SelectedProjects.length > 0) { |
| 54 | + theProject = SelectedProjects[0]; |
| 55 | + this.mProjectSelectionPage = new Import_Libraries_Page(theProject, mPageName, StructuredSelection.EMPTY); |
| 56 | + this.mProjectSelectionPage.setWizard(this); |
| 57 | + this.mPages = new IWizardPage[1]; |
| 58 | + this.mPages[0] = this.mProjectSelectionPage; |
| 59 | + } else { |
| 60 | + |
| 61 | + Activator.log(new Status(IStatus.ERROR, Activator.getId(), Messages.Handler_No_project_found)); |
| 62 | + } |
| 63 | + } |
| 64 | + |
| 65 | + @Override |
| 66 | + public boolean canFinish() { |
| 67 | + return true; |
| 68 | + } |
| 69 | + |
| 70 | + @Override |
| 71 | + public void createPageControls(Composite pageContainer) {// no code needed |
| 72 | + |
| 73 | + } |
| 74 | + |
| 75 | + @Override |
| 76 | + public void dispose() {// no code needed |
| 77 | + } |
| 78 | + |
| 79 | + @Override |
| 80 | + public IWizardContainer getContainer() { |
| 81 | + return this.mWizardContainer; |
| 82 | + } |
| 83 | + |
| 84 | + @Override |
| 85 | + public Image getDefaultPageImage() { |
| 86 | + return null; |
| 87 | + } |
| 88 | + |
| 89 | + @Override |
| 90 | + public IDialogSettings getDialogSettings() { |
| 91 | + return null; |
| 92 | + } |
| 93 | + |
| 94 | + @Override |
| 95 | + public IWizardPage getNextPage(IWizardPage arg0) { |
| 96 | + for (int i = 0; i < (this.mPages.length - 1); i++) { |
| 97 | + if (arg0 == this.mPages[i]) { |
| 98 | + return this.mPages[i + 1]; |
| 99 | + } |
| 100 | + } |
| 101 | + return null; |
| 102 | + } |
| 103 | + |
| 104 | + @Override |
| 105 | + public IWizardPage getPage(String pageName) { |
| 106 | + for (int i = 0; i < this.mPages.length; i++) { |
| 107 | + if (pageName == this.mPages[i].getName()) |
| 108 | + return this.mPages[i]; |
| 109 | + } |
| 110 | + return null; |
| 111 | + } |
| 112 | + |
| 113 | + @Override |
| 114 | + public int getPageCount() { |
| 115 | + return this.mPages.length; |
| 116 | + } |
| 117 | + |
| 118 | + @Override |
| 119 | + public IWizardPage[] getPages() { |
| 120 | + return this.mPages; |
| 121 | + } |
| 122 | + |
| 123 | + @Override |
| 124 | + public IWizardPage getPreviousPage(IWizardPage arg0) { |
| 125 | + for (int i = 1; i < this.mPages.length; i++) { |
| 126 | + if (arg0 == this.mPages[i]) |
| 127 | + return this.mPages[i - 1]; |
| 128 | + } |
| 129 | + return null; |
| 130 | + } |
| 131 | + |
| 132 | + @Override |
| 133 | + public IWizardPage getStartingPage() { |
| 134 | + return this.mPages[0]; |
| 135 | + } |
| 136 | + |
| 137 | + @Override |
| 138 | + public RGB getTitleBarColor() { |
| 139 | + return null; |
| 140 | + } |
| 141 | + |
| 142 | + @Override |
| 143 | + public String getWindowTitle() { |
| 144 | + return mPageTitle; |
| 145 | + } |
| 146 | + |
| 147 | + @Override |
| 148 | + public boolean isHelpAvailable() { |
| 149 | + return false; |
| 150 | + } |
| 151 | + |
| 152 | + @Override |
| 153 | + public boolean needsPreviousAndNextButtons() { |
| 154 | + return false; |
| 155 | + } |
| 156 | + |
| 157 | + @Override |
| 158 | + public boolean needsProgressMonitor() { |
| 159 | + return false; |
| 160 | + } |
| 161 | + |
| 162 | + @Override |
| 163 | + public boolean performCancel() { |
| 164 | + return true; |
| 165 | + } |
| 166 | + |
| 167 | + @Override |
| 168 | + public boolean performFinish() { |
| 169 | + return this.mProjectSelectionPage.PerformFinish(); |
| 170 | + } |
| 171 | + |
| 172 | + @Override |
| 173 | + public void setContainer(IWizardContainer wizardContainer) { |
| 174 | + this.mWizardContainer = wizardContainer; |
| 175 | + } |
176 | 176 |
|
177 | 177 | }
|
0 commit comments