fix: illegal cast

This commit is contained in:
zaaarf 2024-09-28 17:12:35 +02:00
parent da101168e1
commit f815e60605
No known key found for this signature in database
GPG key ID: 102E445F4C3F829B
4 changed files with 13 additions and 9 deletions

View file

@ -17,8 +17,8 @@ import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.Optional; import java.util.Optional;
public class CodeMPToolWindow extends JPanel { public class CodeMPToolPanel extends JPanel {
public CodeMPToolWindow(Project project) { public CodeMPToolPanel(Project project) {
this.draw(project); this.draw(project);
} }
@ -34,7 +34,7 @@ public class CodeMPToolWindow extends JPanel {
JButton connectButton = new JButton(new AbstractAction("Connect...") { JButton connectButton = new JButton(new AbstractAction("Connect...") {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
InteractionUtil.connect(project, () -> CodeMPToolWindow.this.redraw(project)); InteractionUtil.connect(project, () -> CodeMPToolPanel.this.redraw(project));
} }
}); });
this.add(connectButton); this.add(connectButton);
@ -52,7 +52,7 @@ public class CodeMPToolWindow extends JPanel {
InteractionUtil.joinWorkspace( InteractionUtil.joinWorkspace(
project, project,
workspaceName, workspaceName,
() -> CodeMPToolWindow.this.redraw(project) () -> CodeMPToolPanel.this.redraw(project)
); );
} }
}); });
@ -69,7 +69,7 @@ public class CodeMPToolWindow extends JPanel {
); );
InteractionUtil.createBuffer(project, bufferPath); InteractionUtil.createBuffer(project, bufferPath);
CodeMPToolWindow.this.redraw(project); CodeMPToolPanel.this.redraw(project);
} }
}); });
createButton.setSize(createButton.getPreferredSize()); createButton.setSize(createButton.getPreferredSize());

View file

@ -17,7 +17,7 @@ public class CodeMPWindowFactory implements ToolWindowFactory, DumbAware {
) { ) {
ContentFactory contentFactory = ContentFactory.getInstance(); ContentFactory contentFactory = ContentFactory.getInstance();
Content content = contentFactory.createContent( Content content = contentFactory.createContent(
new CodeMPToolWindow(project), new CodeMPToolPanel(project),
"", "",
false false
); );

View file

@ -21,7 +21,7 @@ import mp.code.intellij.CodeMP;
import mp.code.intellij.listeners.BufferEventListener; import mp.code.intellij.listeners.BufferEventListener;
import mp.code.intellij.listeners.CursorEventListener; import mp.code.intellij.listeners.CursorEventListener;
import mp.code.intellij.settings.CodeMPSettings; import mp.code.intellij.settings.CodeMPSettings;
import mp.code.intellij.ui.CodeMPToolWindow; import mp.code.intellij.ui.CodeMPToolPanel;
import mp.code.intellij.util.cb.CursorCallback; import mp.code.intellij.util.cb.CursorCallback;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -260,7 +260,11 @@ public class InteractionUtil {
} }
public static void refreshToolWindow(Project project) { public static void refreshToolWindow(Project project) {
CodeMPToolWindow w = (CodeMPToolWindow) ToolWindowManager.getInstance(project).getToolWindow("CodeMP"); CodeMPToolPanel w = (CodeMPToolPanel) ToolWindowManager.getInstance(project)
.getToolWindow("CodeMPToolWindow")
.getContentManager()
.getContent(0)
.getComponent();
if(w == null) return; if(w == null) return;
w.redraw(project); w.redraw(project);
} }

View file

@ -48,7 +48,7 @@
displayName="CodeMP"/> displayName="CodeMP"/>
<workspaceModel.fileIndexContributor implementation="mp.code.intellij.vfs.CodeMPFileIndexContributor" /> <workspaceModel.fileIndexContributor implementation="mp.code.intellij.vfs.CodeMPFileIndexContributor" />
<toolWindow <toolWindow
id="CodeMP" id="CodeMPToolWindow"
factoryClass="mp.code.intellij.ui.CodeMPWindowFactory" factoryClass="mp.code.intellij.ui.CodeMPWindowFactory"
anchor="right" anchor="right"
doNotActivateOnStart="false" /> doNotActivateOnStart="false" />