in src/main/com/intellij/lang/jsgraphql/ui/GraphQLUIProjectService.java [266:344]
private JComponent createEditorHeaderComponent(@NotNull FileEditor fileEditor, @NotNull Editor editor) {
final GraphQLEditorHeaderComponent headerComponent = new GraphQLEditorHeaderComponent();
// variables & settings actions
final DefaultActionGroup settingsActions = new DefaultActionGroup();
settingsActions.add(new GraphQLOpenConfigAction());
settingsActions.add(ActionManager.getInstance().getAction(GraphQLEditEnvironmentVariablesAction.ACTION_ID));
settingsActions.addSeparator();
settingsActions.add(new GraphQLToggleVariablesAction());
final JComponent settingsToolbar = createToolbar(settingsActions, headerComponent);
headerComponent.add(settingsToolbar, BorderLayout.WEST);
// query execute
final DefaultActionGroup queryActions = new DefaultActionGroup();
final AnAction executeGraphQLAction = ActionManager.getInstance().getAction(GraphQLExecuteEditorAction.ACTION_ID);
queryActions.add(executeGraphQLAction);
queryActions.addSeparator();
queryActions.add(new GraphQLRunIntrospectionQueryAction());
queryActions.add(new GraphQLOpenIntrospectionSchemaAction());
final JComponent queryToolbar = createToolbar(queryActions, headerComponent);
// configured endpoints combo box
final GraphQLEndpointsModel endpointsModel =
new GraphQLEndpointsModel(Collections.emptyList(), PropertiesComponent.getInstance(myProject));
final ComboBox<?> endpointComboBox = new ComboBox<>(endpointsModel);
endpointComboBox.setToolTipText(GraphQLBundle.message("graphql.endpoint.tooltip"));
editor.putUserData(GRAPH_QL_ENDPOINTS_MODEL, endpointsModel);
final JPanel endpointComboBoxPanel = new JPanel(new BorderLayout());
endpointComboBoxPanel.setBorder(BorderFactory.createEmptyBorder(1, 2, 2, 2));
endpointComboBoxPanel.add(endpointComboBox);
// splitter to resize endpoints
final OnePixelSplitter splitter = new OnePixelSplitter(false, .25F);
splitter.setBorder(BorderFactory.createEmptyBorder());
splitter.setFirstComponent(endpointComboBoxPanel);
splitter.setSecondComponent(queryToolbar);
splitter.setHonorComponentsMinimumSize(true);
splitter.setAndLoadSplitterProportionKey("JSGraphQLEndpointSplitterProportion");
splitter.setOpaque(false);
splitter.getDivider().setOpaque(false);
headerComponent.add(splitter, BorderLayout.CENTER);
// variables editor
final LightVirtualFile virtualFile = new LightVirtualFile(GRAPH_QL_VARIABLES_JSON, JsonFileType.INSTANCE, "");
final FileEditor variablesFileEditor = TextEditorProvider.getInstance().createEditor(myProject, virtualFile);
Disposer.register(fileEditor, variablesFileEditor);
final EditorEx variablesEditor = (EditorEx)((TextEditor)variablesFileEditor).getEditor();
virtualFile.putUserData(IS_GRAPH_QL_VARIABLES_VIRTUAL_FILE, Boolean.TRUE);
variablesEditor.setPlaceholder(VARIABLES_PLACEHOLDER);
variablesEditor.setShowPlaceholderWhenFocused(true);
variablesEditor.getSettings().setRightMarginShown(false);
variablesEditor.getSettings().setAdditionalLinesCount(0);
variablesEditor.getSettings().setShowIntentionBulb(false);
variablesEditor.getSettings().setFoldingOutlineShown(false);
variablesEditor.getSettings().setLineNumbersShown(false);
variablesEditor.getSettings().setLineMarkerAreaShown(false);
variablesEditor.getSettings().setCaretRowShown(false);
variablesEditor.putUserData(GRAPH_QL_ENDPOINTS_MODEL, endpointsModel);
variablesFileEditor.getComponent().setPreferredSize(JBUI.size(Integer.MAX_VALUE, 150));
// link the query and variables editor together
variablesEditor.putUserData(GRAPH_QL_QUERY_EDITOR, editor);
editor.putUserData(GRAPH_QL_VARIABLES_EDITOR, variablesEditor);
final NonOpaquePanel variablesPanel = new NonOpaquePanel(variablesFileEditor.getComponent());
variablesPanel.setBorder(IdeBorderFactory.createBorder(SideBorder.TOP));
// hide variables by default
variablesPanel.setVisible(false);
variablesEditor.putUserData(GRAPH_QL_QUERY_COMPONENT, variablesPanel);
headerComponent.add(variablesPanel, BorderLayout.SOUTH);
return headerComponent;
}