Skip to content

Commit d7e482a

Browse files
committed
Функция поиска по проектам.
1 parent 9ed1f3a commit d7e482a

File tree

2 files changed

+49
-10
lines changed

2 files changed

+49
-10
lines changed

develnext/src/ide/forms/OpenProjectForm.fxml

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,32 @@
4848
<content>
4949
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
5050
<children>
51-
<ScrollPane id="projectList" fitToHeight="true" fitToWidth="true" prefHeight="292.0" prefWidth="550.0" style="-fx-border-color: transparent; -fx-border-width: 0px;" AnchorPane.bottomAnchor="3.0" AnchorPane.leftAnchor="3.0" AnchorPane.rightAnchor="3.0" AnchorPane.topAnchor="3.0">
52-
<content>
53-
<FlowPane style="-fx-border-width: 0px;" />
54-
</content>
55-
</ScrollPane>
51+
<VBox layoutX="3.0" layoutY="3.0" spacing="5.0" AnchorPane.bottomAnchor="3.0" AnchorPane.leftAnchor="3.0" AnchorPane.rightAnchor="3.0" AnchorPane.topAnchor="3.0">
52+
<children>
53+
<HBox prefHeight="39.0" prefWidth="630.0" spacing="5.0">
54+
<children>
55+
<Button id="projectSearchButton" maxHeight="1.7976931348623157E308" mnemonicParsing="false" styleClass="icon-flat-search">
56+
<padding>
57+
<Insets left="15.0" right="15.0" />
58+
</padding>
59+
</Button>
60+
<TextField id="projectQueryField" prefHeight="39.0" prefWidth="379.0" promptText="введите ключевые слова для поиска" HBox.hgrow="ALWAYS">
61+
<font>
62+
<Font size="15.0" />
63+
</font>
64+
</TextField>
65+
</children>
66+
</HBox>
67+
<ScrollPane id="projectList" fitToHeight="true" fitToWidth="true" prefHeight="292.0" prefWidth="550.0" style="-fx-border-color: transparent; -fx-border-width: 0px;" VBox.vgrow="ALWAYS">
68+
<content>
69+
<FlowPane style="-fx-border-width: 0px;" />
70+
</content>
71+
</ScrollPane>
72+
</children>
73+
<padding>
74+
<Insets top="5.0" />
75+
</padding>
76+
</VBox>
5677
</children>
5778
</AnchorPane>
5879
</content>

develnext/src/ide/forms/OpenProjectForm.php

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
use php\gui\UXFileChooser;
3535
use php\gui\UXForm;
3636
use php\gui\UXHyperlink;
37+
use php\gui\UXImageView;
3738
use php\gui\UXLabel;
3839
use php\gui\UXListCell;
3940
use php\gui\UXListView;
@@ -58,6 +59,8 @@
5859
* @property UXListView $sharedList
5960
* @property UXListView $embeddedLibraryList
6061
* @property UXAnchorPane $sharedPane
62+
* @property UXTextField $projectQueryField
63+
* @property UXButton $projectSearchButton
6164
*
6265
* Class OpenProjectForm
6366
* @package ide\forms
@@ -245,14 +248,15 @@ protected function sharedCellFactory(array $item)
245248
return $line;
246249
}
247250

248-
public function update()
251+
public function update(string $searchText = '')
249252
{
253+
$searchText = str::lower($searchText);
250254
$emptyText = $this->projectListHelper->getEmptyListText();
251255

252256
$this->projectListHelper->setEmptyListText(_('project.open.searching'));
253257
$this->projectListHelper->clear();
254258

255-
$th = new Thread(function () use ($emptyText) {
259+
$th = new Thread(function () use ($emptyText, $searchText) {
256260
$projectDirectory = File::of(Ide::get()->getUserConfigValue('projectDirectory'));
257261

258262
$projects = [];
@@ -281,6 +285,11 @@ public function update()
281285
/** @var File $project */
282286
$config = ProjectConfig::createForFile($project);
283287
$template = $config->getTemplate();
288+
$name = str::lower(fs::nameNoExt($project->getName()));
289+
290+
if ($searchText && !str::contains($name, $searchText)) {
291+
continue;
292+
}
284293

285294
uiLater(function () use ($project, $template) {
286295
$one = new ImageBox(72, 48);
@@ -389,7 +398,7 @@ public function updateShared()
389398
*/
390399
public function doShowing()
391400
{
392-
$this->update();
401+
$this->update($this->projectQueryField->text);
393402
$this->updateLibrary();
394403
$this->updateShared();
395404
}
@@ -431,12 +440,21 @@ public function doRemove(array $nodes)
431440

432441
if (!FileUtils::deleteDirectory($directory)) {
433442
Notifications::error(_('project.open.error.delete.title'), _('project.open.error.delete.description'));
434-
$this->update();
443+
$this->update($this->projectQueryField->text);
435444
}
436445
}
437446
}
438447
}
439448

449+
/**
450+
* @event projectQueryField.keyUp
451+
* @event projectSearchButton.action
452+
*/
453+
public function doSearchProject()
454+
{
455+
$this->update($this->projectQueryField->text);
456+
}
457+
440458
/**
441459
* @param UXMouseEvent $e
442460
*/
@@ -474,7 +492,7 @@ public function doChoosePath()
474492
$this->pathField->text = $path;
475493

476494
Ide::get()->setUserConfigValue('projectDirectory', $path);
477-
$this->update();
495+
$this->update($this->projectQueryField->text);
478496
}
479497
}
480498

0 commit comments

Comments
 (0)