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

IIP-13 / Feature Add inline actions for impex files #53

Conversation

vladyanytskyi
Copy link

Added ability to copy text from Impex and Flexible Search files to Hybris Console.

Signed-off-by: Vladyslav Yanytskyi [email protected]


@Override
public void update(@NotNull final AnActionEvent e) {
final DataContext dataContext = e.getDataContext();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to have DataContext dataContext if Project project = e.getProject();?

return isImpex;
}

private List<String> getFilesName(@NotNull final DataContext dataContext) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to have an access to VirtualFile and then check its extension.
Smth like

StructureTreeModel.Node lastPathComponent = (StructureTreeModel.Node) file.getLastPathComponent();
ProjectViewNode element = (ProjectViewNode) lastPathComponent.getElement();
element.getVirtualFile().getExtension();

for (final TreePath treePath : files) {
final DefaultMutableTreeNode lastPathNode = (DefaultMutableTreeNode) treePath.getLastPathComponent();
final PsiFileNode file = (PsiFileNode) lastPathNode.getUserObject();
final HybrisConsolePanel hybrisConsolePanel = getHybrisConsolePanel(project);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you want to check whether the project is not null - then it should be before this line

if (hybrisConsole != null && project != null) {
if (!getTextFromHybrisConsole(project, hybrisConsole).isEmpty()) {
final CopyFileToHybrisConsoleDialog copyFileToHybrisConsoleDialog = new CopyFileToHybrisConsoleDialog(project);
copyFileToHybrisConsoleDialog.setTitle("Flexible Search Console");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

string label is a good candidate to be moved to the property file

}

@Override
public void actionPerformed(@NotNull final AnActionEvent e) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems that common code could be also moved to AbstractCopyFileToHybrisConsoleAction

if (files != null) {
for (final Object file : files) {
final TreePath treePath = (TreePath) file;
names.add(treePath.getLastPathComponent().toString());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't trust to *.toString()

return names;
}

public Object[] getFiles(@NotNull final DataContext dataContext) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try not to return the Object or Object[]
Cast to the specific type which will be returned. like TreePath

return names;
}

public Object[] getFiles(@NotNull final DataContext dataContext) {
Copy link
Collaborator

@MykytaKostiuk MykytaKostiuk Apr 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here we can return array or null (.getSelectionPaths()), is it possible to return just an array, populated or empty?

@MykytaKostiuk MykytaKostiuk merged commit 7bbd3cd into epam:master May 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants