Skip to content

Commit

Permalink
Merge branch 'main' into issue-782
Browse files Browse the repository at this point in the history
  • Loading branch information
sbouchet authored Sep 20, 2024
2 parents 40ef4b2 + 79fcda2 commit fbe55fe
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 80 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ dependencies {
'org.mockito:mockito-core:5.12.0',
'org.easytesting:fest-assert:1.4',
'com.redhat.devtools.intellij:intellij-common:1.9.6:test',
'org.awaitility:awaitility:4.2.1',
'org.awaitility:awaitility:4.2.2',
'org.mock-server:mockserver-client-java:5.15.0',
'org.mock-server:mockserver-netty:5.15.0',
'com.redhat.devtools.intellij:intellij-common-ui-test-library:0.4.1',
Expand Down
Binary file modified images/1.10.0/helm-add-dialog.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/1.10.0/helm-chart-install-validation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/1.10.0/helm-chart-install.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/1.10.0/helm-edit-dialog.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/1.10.0/helm-edit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/1.10.0/helm-refresh.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -133,20 +133,20 @@ private void createComponents() {
add(chartNameLabel, "gapleft 4, growx, pushx");

this.statusIcon = new StatusIcon();
add(statusIcon.get(), "pushx, growx");
add(statusIcon.get(), "pushx, growx, wrap");

this.installButton = new JButton("Install");
installButton.addActionListener(this::onInstall);
add(installButton, "spany 2, pushx, alignx right, aligny center, wrap");

add(new JBLabel("Release name:"), "");
add(new JBLabel("Release name:"), "skip");
this.releaseNameText = new JBTextField();
this.releaseNameValidator = new ComponentValidator(parentDisposable)
.withValidator(new ReleaseNameValidator(releaseNameText))
.installOn(releaseNameText)
.andRegisterOnDocumentListener(releaseNameText);
releaseNameText.addKeyListener(onKeyPressed(installButton));
add(releaseNameText, "spanx 2, pushx, growx, wrap");
add(releaseNameText, "spanx 2, pushx, growx");

this.installButton = new JButton("Install");
installButton.addActionListener(this::onInstall);
add(installButton, "pushx, alignx right, aligny center, wrap");

add(new JBLabel("Active " + (odo.isOpenShift() ? "project:" : "namespace:")), "skip, pushx");
this.currentProjectLabel = new JBLabel();
Expand All @@ -156,10 +156,10 @@ private void createComponents() {
add(new JBLabel("Version:"), "skip");
this.versionsComboBox = new ComboBox<>(versionsComboBoxModel);
versionsComboBox.addItemListener(onVersionSelected());
add(versionsComboBox, "spanx 2, width 100:100:100, gap 4 0 0 0, wrap");
add(versionsComboBox, "wmax 100, wrap");

this.valuesOrResultPanel = new ValuesOrResultPanel(parentDisposable, project);
add(valuesOrResultPanel, "skip, spanx, push, grow, gap 0 0 0 4, height 400:600, wrap");
add(valuesOrResultPanel, "spanx, push, grow, gap 0 0 0 4, height 400:600, wrap");

setChart(chart);
valuesOrResultPanel.setValuesListener(onValuesChanged());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import com.intellij.ui.components.JBTextField;
import com.intellij.util.ui.JBUI;
import net.miginfocom.swing.MigLayout;
import org.apache.commons.lang3.StringUtils;
import org.jboss.tools.intellij.openshift.ui.BaseDialog;
import org.jetbrains.annotations.Nullable;

Expand All @@ -33,84 +32,82 @@

public class CreateNewProjectDialog extends BaseDialog {

private static final int WIDTH = 200;
private final String kind;
private final Collection<String> allProjects;
private JBTextField newProjectTextField;
private static final int WIDTH = 200;
private final String kind;
private final Collection<String> allProjects;
private JBTextField newProjectTextField;

private String newProject;
private String newProject;

public CreateNewProjectDialog(@Nullable Project project, Collection<String> allProjects, String kind, Point location) {
super(project, location);
this.kind = kind;
this.allProjects = allProjects;
init();
}
public CreateNewProjectDialog(@Nullable Project project, Collection<String> allProjects, String kind, Point location) {
super(project, location);
this.kind = kind;
this.allProjects = allProjects;
init();
}

@Override
protected void init() {
super.init();
setOKButtonText("Create");
setTitle("Create New " + kind);
}
@Override
protected void init() {
super.init();
setOKButtonText("Create");
setTitle("Create New " + kind);
}

@Override
protected @Nullable JComponent createCenterPanel() {
JComponent panel = new JPanel(new MigLayout(
"flowx, ins 0, gap 0, fillx, filly, hidemode 3",
"[left]10[" + WIDTH +",fill]"));
JLabel newActiveProjectLabel = new JBLabel("New " + kind.toLowerCase() + ":", SwingConstants.LEFT);
newActiveProjectLabel.setBorder(JBUI.Borders.empty(10, 0));
panel.add(newActiveProjectLabel, "left, bottom");
this.newProjectTextField = new JBTextField();
newProjectTextField.selectAll();
panel.add(newProjectTextField, "pushx, growx, wrap");
ComponentValidator activeProjectValidator = new ComponentValidator(myDisposable)
.withValidator(new ActiveProjectValidator())
.installOn(newProjectTextField)
.andRegisterOnDocumentListener(newProjectTextField);
activeProjectValidator.revalidate();
return panel;
}
@Override
protected @Nullable JComponent createCenterPanel() {
JComponent panel = new JPanel(new MigLayout(
"flowx, ins 0, gap 0, fillx, filly, hidemode 3",
"[left]10[" + WIDTH + ",fill]"));
JLabel newActiveProjectLabel = new JBLabel("New " + kind.toLowerCase() + ":", SwingConstants.LEFT);
newActiveProjectLabel.setBorder(JBUI.Borders.empty(10, 0));
panel.add(newActiveProjectLabel, "left, bottom");
this.newProjectTextField = new JBTextField();
newProjectTextField.selectAll();
panel.add(newProjectTextField, "pushx, growx, wrap");
ComponentValidator activeProjectValidator = new ComponentValidator(myDisposable)
.withValidator(new ActiveProjectValidator())
.installOn(newProjectTextField)
.andRegisterOnDocumentListener(newProjectTextField);
activeProjectValidator.revalidate();
return panel;
}

@Override
protected void doOKAction() {
super.doOKAction();
this.newProject = newProjectTextField.getText();
}
@Override
protected void doOKAction() {
super.doOKAction();
this.newProject = newProjectTextField.getText();
}

public String getNewProject() {
return newProject;
}
public String getNewProject() {
return newProject;
}

private class ActiveProjectValidator implements Supplier<ValidationInfo> {
private class ActiveProjectValidator implements Supplier<ValidationInfo> {

private final Pattern nameRegex = Pattern.compile(
"^[a-z0-9]+(([.-])?[a-z0-9])$");
private final Pattern nameRegex = Pattern.compile(
"^[a-z0-9]([-a-z0-9]*[a-z0-9]){0,64}$");

@Override
public ValidationInfo get() {
String activeProject = newProjectTextField.getText();
ValidationInfo validation = getValidationInfo(activeProject);
// update OK button
setOKActionEnabled(validation.okEnabled);
return validation;
}
@Override
public ValidationInfo get() {
String activeProject = newProjectTextField.getText();
ValidationInfo validation = getValidationInfo(activeProject);
// update OK button
setOKActionEnabled(validation.okEnabled);
return validation;
}

private ValidationInfo getValidationInfo(String newProject) {
ValidationInfo validation = new ValidationInfo("").withOKEnabled();
if (StringUtil.isEmptyOrSpaces(newProject)) {
validation = new ValidationInfo("Provide name", newProjectTextField).asWarning();
} else if (newProject.length() > 63) {
validation = new ValidationInfo("Mustn't have > 63 characters", newProjectTextField).asWarning();
} else if (StringUtils.isNumeric(newProject)) {
validation = new ValidationInfo("Mustn't contain only numeric characters", newProjectTextField).asWarning();
} else if (allProjects.contains(newProject)) {
validation = new ValidationInfo("Already exists, choose new name", newProjectTextField).asWarning();
} else if (!nameRegex.matcher(newProject).matches()) {
validation = new ValidationInfo("Must be alphanumeric and may contain -", newProjectTextField);
}
return validation;
}
private ValidationInfo getValidationInfo(String newProject) {
ValidationInfo validation = new ValidationInfo("").withOKEnabled();
if (StringUtil.isEmptyOrSpaces(newProject)) {
validation = new ValidationInfo("Provide name", newProjectTextField).asWarning();
} else if (newProject.length() > 63) {
validation = new ValidationInfo("Must be no more than 63 characters", newProjectTextField).asWarning();
} else if (allProjects.contains(newProject)) {
validation = new ValidationInfo("Already exists, choose new name", newProjectTextField).asWarning();
} else if (!nameRegex.matcher(newProject).matches()) {
validation = new ValidationInfo("Must consist of lower case alphanumeric characters or '-'", newProjectTextField);
}
return validation;
}
}
}

0 comments on commit fbe55fe

Please sign in to comment.