mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-05 01:50:56 +07:00
Prevent possible NPE.
This commit is contained in:
@@ -132,7 +132,7 @@ public abstract class AbstractTerminalRunner<T extends Process> {
|
||||
processHandler.startNotify();
|
||||
}
|
||||
|
||||
public static void openSession(TerminalWidget terminal, TtyConnector ttyConnector) {
|
||||
public static void openSession(@NotNull TerminalWidget terminal, @NotNull TtyConnector ttyConnector) {
|
||||
TerminalSession session = terminal.createTerminalSession(ttyConnector);
|
||||
session.start();
|
||||
}
|
||||
@@ -163,7 +163,7 @@ public abstract class AbstractTerminalRunner<T extends Process> {
|
||||
return myProject;
|
||||
}
|
||||
|
||||
public void openSession(TerminalWidget terminalWidget) {
|
||||
public void openSession(@NotNull TerminalWidget terminalWidget) {
|
||||
// Create Server process
|
||||
try {
|
||||
final T process = createProcess();
|
||||
|
||||
@@ -66,41 +66,43 @@ public class TerminalView {
|
||||
});
|
||||
}
|
||||
|
||||
Content content = createToolWindowContentPanel(terminalRunner, myTerminalWidget, toolWindow);
|
||||
if (myTerminalWidget != null) {
|
||||
Content content = createToolWindowContentPanel(terminalRunner, myTerminalWidget, toolWindow);
|
||||
|
||||
toolWindow.getContentManager().addContent(content);
|
||||
toolWindow.getContentManager().addContent(content);
|
||||
|
||||
((ToolWindowManagerEx)ToolWindowManager.getInstance(myProject)).addToolWindowManagerListener(new ToolWindowManagerListener() {
|
||||
@Override
|
||||
public void toolWindowRegistered(@NotNull String id) {
|
||||
}
|
||||
((ToolWindowManagerEx)ToolWindowManager.getInstance(myProject)).addToolWindowManagerListener(new ToolWindowManagerListener() {
|
||||
@Override
|
||||
public void toolWindowRegistered(@NotNull String id) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stateChanged() {
|
||||
ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow(TerminalToolWindowFactory.TOOL_WINDOW_ID);
|
||||
if (window != null) {
|
||||
boolean visible = window.isVisible();
|
||||
if (visible && toolWindow.getContentManager().getContentCount() == 0) {
|
||||
initTerminal(window);
|
||||
@Override
|
||||
public void stateChanged() {
|
||||
ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow(TerminalToolWindowFactory.TOOL_WINDOW_ID);
|
||||
if (window != null) {
|
||||
boolean visible = window.isVisible();
|
||||
if (visible && toolWindow.getContentManager().getContentCount() == 0) {
|
||||
initTerminal(window);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Disposer.register(myProject, new Disposable() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
if (myTerminalWidget != null) {
|
||||
myTerminalWidget.dispose();
|
||||
myTerminalWidget = null;
|
||||
Disposer.register(myProject, new Disposable() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
if (myTerminalWidget != null) {
|
||||
myTerminalWidget.dispose();
|
||||
myTerminalWidget = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private Content createToolWindowContentPanel(@Nullable LocalTerminalDirectRunner terminalRunner,
|
||||
JBTabbedTerminalWidget terminalWidget,
|
||||
ToolWindow toolWindow) {
|
||||
@NotNull JBTabbedTerminalWidget terminalWidget,
|
||||
@NotNull ToolWindow toolWindow) {
|
||||
SimpleToolWindowPanel panel = new SimpleToolWindowPanel(false, true) {
|
||||
@Override
|
||||
public Object getData(@NonNls String dataId) {
|
||||
@@ -108,11 +110,8 @@ public class TerminalView {
|
||||
}
|
||||
};
|
||||
|
||||
if (terminalWidget != null) {
|
||||
panel.setContent(terminalWidget.getComponent());
|
||||
|
||||
panel.addFocusListener(createFocusListener());
|
||||
}
|
||||
panel.setContent(terminalWidget.getComponent());
|
||||
panel.addFocusListener(createFocusListener());
|
||||
|
||||
ActionToolbar toolbar = createToolbar(terminalRunner, terminalWidget, toolWindow);
|
||||
toolbar.getComponent().addFocusListener(createFocusListener());
|
||||
@@ -173,7 +172,7 @@ public class TerminalView {
|
||||
}
|
||||
|
||||
private ActionToolbar createToolbar(@Nullable final LocalTerminalDirectRunner terminalRunner,
|
||||
final JBTabbedTerminalWidget terminal, ToolWindow toolWindow) {
|
||||
@NotNull final JBTabbedTerminalWidget terminal, @NotNull ToolWindow toolWindow) {
|
||||
DefaultActionGroup group = new DefaultActionGroup();
|
||||
|
||||
if (terminalRunner != null) {
|
||||
@@ -206,7 +205,7 @@ public class TerminalView {
|
||||
private final LocalTerminalDirectRunner myTerminalRunner;
|
||||
private final TerminalWidget myTerminal;
|
||||
|
||||
public NewSession(LocalTerminalDirectRunner terminalRunner, TerminalWidget terminal) {
|
||||
public NewSession(@NotNull LocalTerminalDirectRunner terminalRunner, @NotNull TerminalWidget terminal) {
|
||||
super("New Session", "Create New Terminal Session", AllIcons.General.Add);
|
||||
myTerminalRunner = terminalRunner;
|
||||
myTerminal = terminal;
|
||||
@@ -222,7 +221,7 @@ public class TerminalView {
|
||||
private final JBTabbedTerminalWidget myTerminal;
|
||||
private ToolWindow myToolWindow;
|
||||
|
||||
public CloseSession(JBTabbedTerminalWidget terminal, ToolWindow toolWindow) {
|
||||
public CloseSession(@NotNull JBTabbedTerminalWidget terminal, @NotNull ToolWindow toolWindow) {
|
||||
super("Close Session", "Close Terminal Session", AllIcons.Actions.Delete);
|
||||
myTerminal = terminal;
|
||||
myToolWindow = toolWindow;
|
||||
|
||||
@@ -2,23 +2,7 @@
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$/pluginResources">
|
||||
<sourceFolder url="file://$MODULE_DIR$/pluginResources" type="java-resource" />
|
||||
</content>
|
||||
<content url="file://$MODULE_DIR$/pluginTestSrc">
|
||||
<sourceFolder url="file://$MODULE_DIR$/pluginTestSrc" isTestSource="true" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="testFramework-java" />
|
||||
<orderEntry type="library" scope="TEST" name="JUnit3" level="project" />
|
||||
<orderEntry type="module" module-name="java-impl" />
|
||||
<orderEntry type="module" module-name="jam-support-impl" scope="RUNTIME" />
|
||||
<orderEntry type="module" module-name="IntelliLang-java" scope="RUNTIME" />
|
||||
<orderEntry type="module" module-name="python-community-tests" />
|
||||
<orderEntry type="module" module-name="python-community-plugin" />
|
||||
<orderEntry type="module" module-name="python-community" />
|
||||
<orderEntry type="module" module-name="IntelliLang-xml" scope="RUNTIME" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user