|
34 | 34 | use php\gui\UXFileChooser; |
35 | 35 | use php\gui\UXForm; |
36 | 36 | use php\gui\UXHyperlink; |
| 37 | +use php\gui\UXImageView; |
37 | 38 | use php\gui\UXLabel; |
38 | 39 | use php\gui\UXListCell; |
39 | 40 | use php\gui\UXListView; |
|
58 | 59 | * @property UXListView $sharedList |
59 | 60 | * @property UXListView $embeddedLibraryList |
60 | 61 | * @property UXAnchorPane $sharedPane |
| 62 | + * @property UXTextField $projectQueryField |
| 63 | + * @property UXButton $projectSearchButton |
61 | 64 | * |
62 | 65 | * Class OpenProjectForm |
63 | 66 | * @package ide\forms |
@@ -245,14 +248,15 @@ protected function sharedCellFactory(array $item) |
245 | 248 | return $line; |
246 | 249 | } |
247 | 250 |
|
248 | | - public function update() |
| 251 | + public function update(string $searchText = '') |
249 | 252 | { |
| 253 | + $searchText = str::lower($searchText); |
250 | 254 | $emptyText = $this->projectListHelper->getEmptyListText(); |
251 | 255 |
|
252 | 256 | $this->projectListHelper->setEmptyListText(_('project.open.searching')); |
253 | 257 | $this->projectListHelper->clear(); |
254 | 258 |
|
255 | | - $th = new Thread(function () use ($emptyText) { |
| 259 | + $th = new Thread(function () use ($emptyText, $searchText) { |
256 | 260 | $projectDirectory = File::of(Ide::get()->getUserConfigValue('projectDirectory')); |
257 | 261 |
|
258 | 262 | $projects = []; |
@@ -281,6 +285,11 @@ public function update() |
281 | 285 | /** @var File $project */ |
282 | 286 | $config = ProjectConfig::createForFile($project); |
283 | 287 | $template = $config->getTemplate(); |
| 288 | + $name = str::lower(fs::nameNoExt($project->getName())); |
| 289 | + |
| 290 | + if ($searchText && !str::contains($name, $searchText)) { |
| 291 | + continue; |
| 292 | + } |
284 | 293 |
|
285 | 294 | uiLater(function () use ($project, $template) { |
286 | 295 | $one = new ImageBox(72, 48); |
@@ -389,7 +398,7 @@ public function updateShared() |
389 | 398 | */ |
390 | 399 | public function doShowing() |
391 | 400 | { |
392 | | - $this->update(); |
| 401 | + $this->update($this->projectQueryField->text); |
393 | 402 | $this->updateLibrary(); |
394 | 403 | $this->updateShared(); |
395 | 404 | } |
@@ -431,12 +440,21 @@ public function doRemove(array $nodes) |
431 | 440 |
|
432 | 441 | if (!FileUtils::deleteDirectory($directory)) { |
433 | 442 | Notifications::error(_('project.open.error.delete.title'), _('project.open.error.delete.description')); |
434 | | - $this->update(); |
| 443 | + $this->update($this->projectQueryField->text); |
435 | 444 | } |
436 | 445 | } |
437 | 446 | } |
438 | 447 | } |
439 | 448 |
|
| 449 | + /** |
| 450 | + * @event projectQueryField.keyUp |
| 451 | + * @event projectSearchButton.action |
| 452 | + */ |
| 453 | + public function doSearchProject() |
| 454 | + { |
| 455 | + $this->update($this->projectQueryField->text); |
| 456 | + } |
| 457 | + |
440 | 458 | /** |
441 | 459 | * @param UXMouseEvent $e |
442 | 460 | */ |
@@ -474,7 +492,7 @@ public function doChoosePath() |
474 | 492 | $this->pathField->text = $path; |
475 | 493 |
|
476 | 494 | Ide::get()->setUserConfigValue('projectDirectory', $path); |
477 | | - $this->update(); |
| 495 | + $this->update($this->projectQueryField->text); |
478 | 496 | } |
479 | 497 | } |
480 | 498 |
|
|
0 commit comments