-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
41f3d8c
commit 9723b19
Showing
19 changed files
with
270 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/main/java/org/kdb/inside/brains/action/execute/ExecuteFileAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package org.kdb.inside.brains.action.execute; | ||
|
||
import com.intellij.openapi.actionSystem.AnActionEvent; | ||
import com.intellij.openapi.actionSystem.CommonDataKeys; | ||
import com.intellij.openapi.actionSystem.DataContext; | ||
import com.intellij.openapi.actionSystem.Presentation; | ||
import com.intellij.psi.PsiFile; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.kdb.inside.brains.QFileType; | ||
import org.kdb.inside.brains.core.InstanceConnection; | ||
|
||
public class ExecuteFileAction extends ExecuteAction { | ||
public void update(@NotNull AnActionEvent e) { | ||
final PsiFile file = CommonDataKeys.PSI_FILE.getData(e.getDataContext()); | ||
|
||
final Presentation presentation = e.getPresentation(); | ||
presentation.setVisible(QFileType.is(file)); | ||
|
||
final InstanceConnection c = getConnection(e.getProject()); | ||
presentation.setEnabled(c != null && c.isConnected()); | ||
|
||
if (file != null) { | ||
presentation.setText("Execute '" + file.getName() + "'"); | ||
} | ||
} | ||
|
||
@Override | ||
protected String getExecutionContent(DataContext context) { | ||
final PsiFile data = CommonDataKeys.PSI_FILE.getData(context); | ||
if (!QFileType.is(data)) { | ||
return null; | ||
} | ||
try { | ||
|
||
final String text = data.getText(); | ||
// end of the file comment that we should exclude as it's parsed by KDB | ||
final int i = getEndOfFileIndex(text); | ||
return i < 0 ? text : text.substring(0, i); | ||
} catch (Exception ex) { | ||
return null; | ||
} | ||
} | ||
|
||
private int getEndOfFileIndex(String text) { | ||
final int i = text.indexOf("\\\r"); | ||
if (i < 0) { | ||
return text.indexOf("\\\n"); | ||
} | ||
return i; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/main/java/org/kdb/inside/brains/view/chart/ToolActions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.kdb.inside.brains.view.chart; | ||
|
||
import com.intellij.openapi.actionSystem.AnAction; | ||
|
||
public record ToolActions(String name, AnAction... actions) { | ||
public static final ToolActions NO_ACTIONS = new ToolActions(null); | ||
|
||
public boolean hasActions() { | ||
return actions.length != 0; | ||
} | ||
} |
Oops, something went wrong.