public void update(final AnActionEvent event) { log.debug("update"); super.update(event); final Presentation presentation = event.getPresentation(); final DataContext context = event.getDataContext(); Module module = (Module) context.getData(LangDataKeys.MODULE.getName()); log.debug("update: module: " + module); final boolean hasModule = module != null; presentation.setEnabled(hasModule); presentation.setVisible(hasModule); }
public boolean canClose(String inputString) { final String subDirName = inputString; if (subDirName.length() == 0) { Messages.showMessageDialog( myProject, IdeBundle.message("error.name.should.be.specified"), CommonBundle.getErrorTitle(), Messages.getErrorIcon()); return false; } final boolean multiCreation = StringUtil.containsAnyChar(subDirName, myDelimiters); if (!multiCreation) { try { myDirectory.checkCreateSubdirectory(subDirName); } catch (IncorrectOperationException ex) { Messages.showMessageDialog( myProject, CreateElementActionBase.filterMessage(ex.getMessage()), CommonBundle.getErrorTitle(), Messages.getErrorIcon()); return false; } } Runnable command = new Runnable() { public void run() { final Runnable run = new Runnable() { public void run() { LocalHistoryAction action = LocalHistoryAction.NULL; try { String actionName; String dirPath = myDirectory.getVirtualFile().getPresentableUrl(); actionName = IdeBundle.message( "progress.creating.directory", dirPath, File.separator, subDirName); action = LocalHistory.getInstance().startAction(actionName); createDirectories(subDirName); } catch (final IncorrectOperationException ex) { ApplicationManager.getApplication() .invokeLater( new Runnable() { public void run() { Messages.showMessageDialog( myProject, CreateElementActionBase.filterMessage(ex.getMessage()), CommonBundle.getErrorTitle(), Messages.getErrorIcon()); } }); } finally { action.finish(); } } }; ApplicationManager.getApplication().runWriteAction(run); } }; CommandProcessor.getInstance() .executeCommand( myProject, command, myIsDirectory ? IdeBundle.message("command.create.directory") : IdeBundle.message("command.create.package"), null); return myCreatedElement != null; }