Skip to content

Commit

Permalink
fixed cancel button + weightx of adavanced settings + insets for labe…
Browse files Browse the repository at this point in the history
…l and fields
  • Loading branch information
teetangh committed Jun 30, 2023
1 parent e01bf00 commit 3999c3a
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ public FunctionDeploymentSettings() {
// Create and configure the left panel
leftPanel = new JPanel();
leftPanel.setLayout(new BorderLayout());
leftPanel.setMaximumSize(new Dimension(200, 800));
leftPanel.setPreferredSize(new Dimension(200, 800));
// leftPanel.setMaximumSize(new Dimension(200, 800));
// leftPanel.setPreferredSize(new Dimension(200, 800));
// leftPanel.setForeground(JBColor.BLACK);
leftPanel.setBackground(new Color(62, 67, 76, 255)); // Jetbrains Darcula background color

Expand Down Expand Up @@ -111,8 +111,8 @@ public Component getListCellRendererComponent(JList<?> list, Object value, int i

// Create and configure the right panel
rightPanel = new JPanel(new CardLayout());
rightPanel.setMaximumSize(new Dimension(800, 800));
rightPanel.setPreferredSize(new Dimension(800, 800));
// rightPanel.setMaximumSize(new Dimension(800, 800));
// rightPanel.setPreferredSize(new Dimension(800, 800));

// Add components to the right panel
GeneralSettings generalSettings = new GeneralSettings();
Expand Down Expand Up @@ -153,20 +153,26 @@ public Component getListCellRendererComponent(JList<?> list, Object value, int i
bottomPanel.setLayout(new BorderLayout());
bottomPanel.setBorder(new EmptyBorder(10, 10, 10, 10)); // Add a margin of 10 pixels around the panel

// Create a new panel with a FlowLayout
JPanel buttonsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));

// Add components to the bottom panel
cancelButton = new JButton("Cancel");
cancelButton.addActionListener(e -> {
// Discard changes
dispose();
});
buttonsPanel.add(cancelButton);

applyButton = new JButton("Apply");
applyButton.addActionListener(e -> {
// Save changes
dispose();
});
bottomPanel.add(applyButton, BorderLayout.EAST);
buttonsPanel.add(applyButton);

cancelButton = new JButton("Cancel");
cancelButton.addActionListener(e -> {
// Discard changes
dispose();
});
bottomPanel.add(cancelButton, BorderLayout.WEST);
// Add the buttons panel to the EAST region of the bottom panel
bottomPanel.add(buttonsPanel, BorderLayout.EAST);

// Add the panels to the main panel with a splitter in the middle
JBSplitter splitter = new JBSplitter(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import com.couchbase.intellij.eventing.components.HelpIcon;
import com.intellij.ui.components.JBLabel;
import com.intellij.util.ui.JBUI;

public class AdvancedSettings {

Expand Down Expand Up @@ -52,15 +53,18 @@ public class AdvancedSettings {
private JFormattedTextField timerContextMaxSizeField;

public AdvancedSettings() {

// Advanced Settings panel
advancedSettingsPanel = new JPanel();
advancedSettingsPanel.setLayout(new GridBagLayout());

GridBagConstraints advancedSettingsPanelConstraints = new GridBagConstraints();
advancedSettingsPanelConstraints.gridx = 0;
advancedSettingsPanelConstraints.gridy = 0;
advancedSettingsPanelConstraints.weightx = 1;

advancedSettingsPanelConstraints.insets = JBUI.insets(5, 5, 5, 5);
advancedSettingsPanelConstraints.anchor = GridBagConstraints.NORTHWEST;
advancedSettingsPanelConstraints.insets = new Insets(5, 5, 5, 5);
advancedSettingsPanelConstraints.fill = GridBagConstraints.HORIZONTAL;

// Add components to the Advanced Settings panel
Expand All @@ -74,6 +78,7 @@ public AdvancedSettings() {
.add(HelpIcon.createHelpIcon("Granularity of system events being captured in the log"));
advancedSettingsPanelConstraints.gridx = 0;
advancedSettingsPanelConstraints.gridy = 0;
advancedSettingsPanelConstraints.insets = JBUI.insets(5, 2, 2, 2); // Change the top inset to be larger
advancedSettingsPanel.add(systemLogLevelPanel, advancedSettingsPanelConstraints);

systemLogLevelComboBox = new JComboBox<>();
Expand All @@ -84,6 +89,8 @@ public AdvancedSettings() {
systemLogLevelComboBox.addItem("Trace");
advancedSettingsPanelConstraints.gridx = 0;
advancedSettingsPanelConstraints.gridy = 1;
advancedSettingsPanelConstraints.insets = JBUI.insets(2, 2, 5, 2); // Change the bottom inset to be
// larger
advancedSettingsPanel.add(systemLogLevelComboBox, advancedSettingsPanelConstraints);

n1qlConsistencyLabel = new JBLabel("N1QL Consistency");
Expand All @@ -96,14 +103,16 @@ public AdvancedSettings() {
.add(HelpIcon.createHelpIcon("Consistency level of N1QL statements in the function:"));
advancedSettingsPanelConstraints.gridx = 0;
advancedSettingsPanelConstraints.gridy = 3;
advancedSettingsPanelConstraints.insets = JBUI.insets(5, 2, 2, 2); // Change the top inset to be larger
advancedSettingsPanel.add(n1qlConsistencyPanel, advancedSettingsPanelConstraints);

n1qlConsistencyComboBox = new JComboBox<>();
n1qlConsistencyComboBox.addItem("None");
n1qlConsistencyComboBox.addItem("Request");
advancedSettingsPanelConstraints.gridx = 0;
advancedSettingsPanelConstraints.gridy = 4;

advancedSettingsPanelConstraints.insets = JBUI.insets(2, 2, 5, 2); // Change the bottom inset to be
// larger
advancedSettingsPanel.add(n1qlConsistencyComboBox, advancedSettingsPanelConstraints);

workersLabel = new JBLabel("Workers");
Expand All @@ -115,6 +124,7 @@ public AdvancedSettings() {
workersPanel.add(HelpIcon.createHelpIcon("Number of workers per node to process the events:"));
advancedSettingsPanelConstraints.gridx = 0;
advancedSettingsPanelConstraints.gridy = 5;
advancedSettingsPanelConstraints.insets = JBUI.insets(5, 2, 2, 2); // Change the top inset to be larger
advancedSettingsPanel.add(workersPanel, advancedSettingsPanelConstraints);

NumberFormat format = NumberFormat.getInstance();
Expand All @@ -132,6 +142,8 @@ public AdvancedSettings() {
advancedSettingsPanelConstraints.gridx = 0;
advancedSettingsPanelConstraints.gridy = 6;
advancedSettingsPanelConstraints.gridwidth = 3;
advancedSettingsPanelConstraints.insets = JBUI.insets(2, 2, 5, 2); // Change the bottom inset to be
// larger
advancedSettingsPanel.add(workersField, advancedSettingsPanelConstraints);

// Add a focus listener to the workersField
Expand Down Expand Up @@ -161,6 +173,7 @@ public void focusLost(FocusEvent e) {
languageCompatibilityPanel.add(HelpIcon.createHelpIcon("Language compatibility of the function:"));
advancedSettingsPanelConstraints.gridx = 0;
advancedSettingsPanelConstraints.gridy = 7;
advancedSettingsPanelConstraints.insets = JBUI.insets(5, 2, 2, 2); // Change the top inset to be larger
advancedSettingsPanel.add(languageCompatibilityPanel, advancedSettingsPanelConstraints);

languageCompatibilityComboBox = new JComboBox<>();
Expand All @@ -169,6 +182,8 @@ public void focusLost(FocusEvent e) {
languageCompatibilityComboBox.addItem("6.6.2");
advancedSettingsPanelConstraints.gridx = 0;
advancedSettingsPanelConstraints.gridy = 8;
advancedSettingsPanelConstraints.insets = JBUI.insets(2, 2, 5, 2); // Change the bottom inset to be
// larger
advancedSettingsPanel.add(languageCompatibilityComboBox, advancedSettingsPanelConstraints);

scriptTimeoutLabel = new JBLabel("Script Timeout");
Expand All @@ -181,6 +196,7 @@ public void focusLost(FocusEvent e) {
.createHelpIcon("Time after which the Function's execution will be timed out:"));
advancedSettingsPanelConstraints.gridx = 0;
advancedSettingsPanelConstraints.gridy = 9;
advancedSettingsPanelConstraints.insets = JBUI.insets(5, 2, 2, 2); // Change the top inset to be larger
advancedSettingsPanel.add(scriptTimeoutPanel, advancedSettingsPanelConstraints);

scriptTimeoutField = new JFormattedTextField(formatter);
Expand All @@ -191,6 +207,8 @@ public void focusLost(FocusEvent e) {
advancedSettingsPanelConstraints.gridx = 0;
advancedSettingsPanelConstraints.gridy = 10;
advancedSettingsPanelConstraints.gridwidth = 3;
advancedSettingsPanelConstraints.insets = JBUI.insets(2, 2, 5, 2); // Change the bottom inset to be
// larger
advancedSettingsPanel.add(scriptTimeoutField, advancedSettingsPanelConstraints);

// Add a focus listener to the scriptTimeoutField
Expand Down Expand Up @@ -223,14 +241,18 @@ public void focusLost(FocusEvent e) {
"Timer Context Size in Bytes. If the size of the Timer Context exceeds this value, the Timer Context will be cleared"));
advancedSettingsPanelConstraints.gridx = 0;
advancedSettingsPanelConstraints.gridy = 11;
advancedSettingsPanelConstraints.insets = JBUI.insets(5, 2, 2, 2); // Change the top inset to be larger
advancedSettingsPanel.add(timerContextMaxSizePanel, advancedSettingsPanelConstraints);

timerContextMaxSizeField = new JFormattedTextField(formatter);
timerContextMaxSizeField.setColumns(20);
timerContextMaxSizeField.setValue(1024);
timerContextMaxSizeField
.setToolTipText("Enter the maximum allowed value of the Timer Context Size in Bytes.");
advancedSettingsPanelConstraints.gridx = 0;
advancedSettingsPanelConstraints.gridy = 12;
advancedSettingsPanelConstraints.insets = JBUI.insets(2, 2, 5, 2); // Change the bottom inset to be
// larger
advancedSettingsPanel.add(timerContextMaxSizeField, advancedSettingsPanelConstraints);

// Add a focus listener to the timerContextMaxSizeField
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.util.ArrayList;
Expand Down Expand Up @@ -33,6 +32,7 @@
import com.intellij.ui.components.JBScrollPane;
import com.intellij.ui.components.JBTextArea;
import com.intellij.ui.components.JBTextField;
import com.intellij.util.ui.JBUI;

public class GeneralSettings {

Expand Down Expand Up @@ -78,7 +78,6 @@ public GeneralSettings() {
generalSettingsPanelConstraints.gridy = 0;
generalSettingsPanelConstraints.weightx = 1.0;
// generalSettingsPanelConstraints.weighty = 1.0;
generalSettingsPanelConstraints.insets = new Insets(5, 5, 5, 5);
generalSettingsPanelConstraints.anchor = GridBagConstraints.NORTHWEST;
generalSettingsPanelConstraints.fill = GridBagConstraints.HORIZONTAL;

Expand All @@ -97,12 +96,14 @@ public GeneralSettings() {
"Please specify a scope to which the function belongs. User should have Eventing Manage Scope Functions permission on this scope"));
generalSettingsPanelConstraints.gridx = 0;
generalSettingsPanelConstraints.gridy = 0;
generalSettingsPanelConstraints.insets = JBUI.insets(5, 2, 2, 2); // Change the top inset to be larger
generalSettingsPanel.add(functionScopePanel, generalSettingsPanelConstraints);

functionScopeBucketComboBox = new JComboBox<>();
// functionScopeBucketComboBox.addActionListener(e -> updateScopes());
generalSettingsPanelConstraints.gridx = 0;
generalSettingsPanelConstraints.gridy = 1;
generalSettingsPanelConstraints.insets = JBUI.insets(2, 2, 5, 2); // Change the bottom inset to be larger
generalSettingsPanel.add(functionScopeBucketComboBox, generalSettingsPanelConstraints);

functionScopeScopeComboBox = new JComboBox<>();
Expand All @@ -125,13 +126,15 @@ public GeneralSettings() {
"Please specify a source location for your function. User should have DCP Data Read permission on this keyspace"));
generalSettingsPanelConstraints.gridx = 0;
generalSettingsPanelConstraints.gridy = 2;
generalSettingsPanelConstraints.insets = JBUI.insets(5, 2, 2, 2); // Change the top inset to be larger
generalSettingsPanel.add(listenToLocationPanel, generalSettingsPanelConstraints);

listenToLocationBucketComboBox = new JComboBox<>();
// listenToLocationBucketComboBox.addActionListener(e -> updateScopes());
generalSettingsPanelConstraints.gridx = 0;
generalSettingsPanelConstraints.gridy = 3;
generalSettingsPanelConstraints.gridwidth = 1;
generalSettingsPanelConstraints.insets = JBUI.insets(2, 2, 5, 2); // Change the bottom inset to be larger
generalSettingsPanel.add(listenToLocationBucketComboBox, generalSettingsPanelConstraints);

listenToLocationScopeComboBox = new JComboBox<>();
Expand Down Expand Up @@ -160,13 +163,15 @@ public GeneralSettings() {
"Please specify a location to store Eventing data. User should have read/write permission on this keyspace"));
generalSettingsPanelConstraints.gridx = 0;
generalSettingsPanelConstraints.gridy = 4;
generalSettingsPanelConstraints.insets = JBUI.insets(5, 2, 2, 2); // Change the top inset to be larger
generalSettingsPanel.add(eventingStoragePanel, generalSettingsPanelConstraints);

eventingStorageBucketComboBox = new JComboBox<>();
// eventingStorageBucketComboBox.addActionListener(e -> updateScopes());
generalSettingsPanelConstraints.gridx = 0;
generalSettingsPanelConstraints.gridy = 5;
generalSettingsPanelConstraints.gridwidth = 1;
generalSettingsPanelConstraints.insets = JBUI.insets(2, 2, 5, 2); // Change the bottom inset to be larger
generalSettingsPanel.add(eventingStorageBucketComboBox, generalSettingsPanelConstraints);

eventingStorageScopeComboBox = new JComboBox<>();
Expand All @@ -187,13 +192,15 @@ public GeneralSettings() {
functionNameLabel.setFont(functionNameLabel.getFont().deriveFont(Font.BOLD));
generalSettingsPanelConstraints.gridx = 0;
generalSettingsPanelConstraints.gridy = 6;
generalSettingsPanelConstraints.insets = JBUI.insets(5, 2, 2, 2); // Change the top inset to be larger
generalSettingsPanel.add(functionNameLabel, generalSettingsPanelConstraints);

functionNameField = new JBTextField(20);
functionNameField.setToolTipText("Enter the name of the function.");
generalSettingsPanelConstraints.gridx = 0;
generalSettingsPanelConstraints.gridy = 7;
generalSettingsPanelConstraints.gridwidth = 3;
generalSettingsPanelConstraints.insets = JBUI.insets(2, 2, 5, 2); // Change the bottom inset to be larger
generalSettingsPanel.add(functionNameField, generalSettingsPanelConstraints);

// Add a focus listener to the functionNameField
Expand Down Expand Up @@ -223,6 +230,7 @@ public void focusLost(FocusEvent e) {
"The preferred Deployment time Feed Boundary for the function.");
generalSettingsPanelConstraints.gridx = 0;
generalSettingsPanelConstraints.gridy = 8;
generalSettingsPanelConstraints.insets = JBUI.insets(5, 2, 2, 2); // Change the top inset to be larger
generalSettingsPanel.add(deploymentFeedBoundaryLabel, generalSettingsPanelConstraints);

deploymentFeedBoundaryComboBox = new JComboBox<>();
Expand All @@ -234,6 +242,7 @@ public void focusLost(FocusEvent e) {
generalSettingsPanelConstraints.gridx = 0;
generalSettingsPanelConstraints.gridy = 9;
generalSettingsPanelConstraints.gridwidth = 3;
generalSettingsPanelConstraints.insets = JBUI.insets(2, 2, 5, 2); // Change the bottom inset to be larger
generalSettingsPanel.add(deploymentFeedBoundaryComboBox, generalSettingsPanelConstraints);

warningLabel = new JBLabel("");
Expand Down Expand Up @@ -261,6 +270,7 @@ public void focusLost(FocusEvent e) {
descriptionLabel.setHorizontalAlignment(JBTextField.LEFT);
generalSettingsPanelConstraints.gridx = 0;
generalSettingsPanelConstraints.gridy = 11;
generalSettingsPanelConstraints.insets = JBUI.insets(5, 2, 2, 2); // Change the top inset to be larger
generalSettingsPanel.add(descriptionLabel, generalSettingsPanelConstraints);

JBTextArea descriptionTextArea = new JBTextArea(15, 20);
Expand Down

0 comments on commit 3999c3a

Please sign in to comment.