forked from magento/magento2-phpstorm-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReindexHandler.java
90 lines (80 loc) · 2.48 KB
/
ReindexHandler.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
package com.magento.idea.magento2uct.execution.process;
import com.intellij.execution.process.ProcessAdapter;
import com.intellij.execution.process.ProcessEvent;
import com.intellij.execution.process.ProcessHandler;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiDirectory;
import com.magento.idea.magento2uct.execution.ReindexUctCommand;
import com.magento.idea.magento2uct.packages.IndexRegistry;
import com.magento.idea.magento2uct.packages.SupportedVersion;
import java.io.OutputStream;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class ReindexHandler extends ProcessHandler {
private final Project project;
private final PsiDirectory directory;
/**
* Default indexing handler constructor.
*
* @param project Project
* @param directory PsiDirectory
* @param version SupportedVersion
* @param index IndexRegistry
*/
public ReindexHandler(
final @NotNull Project project,
final @NotNull PsiDirectory directory,
final @NotNull SupportedVersion version,
final @NotNull IndexRegistry index
) {
super();
this.project = project;
this.directory = directory;
this.addProcessListener(
new ProcessAdapter() {
@Override
public void startNotified(final @NotNull ProcessEvent event) {
ReindexHandler.this.execute(version, index);
}
}
);
}
/**
* Run indexing process.
*
* @param version SupportedVersion
* @param index IndexRegistry
*/
public void execute(
final @NotNull SupportedVersion version,
final @NotNull IndexRegistry index
) {
final ReindexUctCommand command = new ReindexUctCommand(
project,
directory,
new OutputWrapper(this),
this
);
command.execute(version, index);
}
@Override
protected void destroyProcessImpl() {
notifyProcessTerminated(0);
}
@Override
protected void detachProcessImpl() {
notifyProcessDetached();
}
@Override
public boolean detachIsDefault() {
return false;
}
@Override
public @Nullable OutputStream getProcessInput() {
return null;
}
}