Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added resource to web API dialog form #595

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@
import com.magento.idea.magento2plugin.actions.generation.generator.xml.WebApiDeclarationGenerator;
import com.magento.idea.magento2plugin.magento.packages.HttpMethod;
import com.magento.idea.magento2plugin.magento.packages.WebApiResource;
import com.magento.idea.magento2plugin.ui.FilteredComboBox;
import com.magento.idea.magento2plugin.util.magento.GetAclResourcesListUtil;
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectoryUtil;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.List;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JComponent;
Expand Down Expand Up @@ -54,7 +55,7 @@ public class NewWebApiDeclarationDialog extends AbstractDialog {
private JComboBox<ComboBoxItemData> httpMethod;
private JTextField serviceClass;
private JTextField serviceMethod;
private JComboBox aclResource;
private JComboBox<ComboBoxItemData> aclResource;

// labels
private JLabel routeUrlLabel;//NOPMD
Expand Down Expand Up @@ -170,11 +171,19 @@ private void fillPredefinedValuesAndDisableInputs() {
@SuppressWarnings({"PMD.UnusedPrivateMethod", "PMD.AvoidInstantiatingObjectsInLoops"})
private void createUIComponents() {
httpMethod = new ComboBox<>();
aclResource = new ComboBox<>();

for (final String method : HttpMethod.getHttpMethodList()) {
httpMethod.addItem(new ComboBoxItemData(method, method));
}
aclResource = new FilteredComboBox(WebApiResource.getDefaultResourcesList());

final List<String> aclResources = GetAclResourcesListUtil.execute(project);
final List<String> defaultResources = WebApiResource.getDefaultResourcesList();
defaultResources.addAll(aclResources);

for (final String acl : defaultResources) {
aclResource.addItem(new ComboBoxItemData(acl, acl));
}
}

/**
Expand Down