2424import consulo .compiler .Compiler ;
2525import consulo .compiler .CompilerManager ;
2626import consulo .compiler .action .CompileActionBase ;
27- import consulo .compiler .localize .CompilerLocalize ;
2827import consulo .compiler .resourceCompiler .ResourceCompiler ;
2928import consulo .compiler .scope .FileSetCompileScope ;
3029import consulo .compiler .scope .ModuleCompileScope ;
3130import consulo .dataContext .DataContext ;
31+ import consulo .java .compiler .localize .JavaCompilerLocalize ;
3232import consulo .language .editor .LangDataKeys ;
3333import consulo .language .psi .PsiDirectory ;
3434import consulo .language .psi .PsiElement ;
3535import consulo .language .psi .PsiManager ;
36- import consulo .localize .LocalizeValue ;
3736import consulo .module .Module ;
3837import consulo .module .content .ProjectFileIndex ;
3938import consulo .module .content .ProjectRootManager ;
40- import consulo .platform .base .localize .ActionLocalize ;
4139import consulo .project .Project ;
4240import consulo .ui .annotation .RequiredUIAccess ;
4341import consulo .ui .ex .action .ActionPlaces ;
5654import java .util .function .Predicate ;
5755
5856public class ProcessAnnotationsAction extends CompileActionBase {
57+ public ProcessAnnotationsAction () {
58+ super (JavaCompilerLocalize .actionRunAptText (), JavaCompilerLocalize .actionRunAptDescription (), null );
59+ }
60+
5961 @ Override
6062 @ RequiredUIAccess
6163 protected void doAction (DataContext dataContext , Project project ) {
@@ -106,17 +108,18 @@ public void update(@Nonnull AnActionEvent event) {
106108 return ;
107109 }
108110
111+ presentation .setEnabled (true );
109112 presentation .setVisible (true );
110- presentation .setTextValue (createPresentationText ("" ));
113+ presentation .setTextValue (JavaCompilerLocalize .actionRunAptText ());
114+
111115 FileSetCompileScope scope = getCompilableFiles (project , event .getData (VirtualFile .KEY_OF_ARRAY ));
112116 if (moduleContext == null && scope == null ) {
113117 presentation .setEnabled (false );
114118 return ;
115119 }
116120
117- LocalizeValue elementDescription = LocalizeValue .empty ();
118121 if (moduleContext != null ) {
119- elementDescription = CompilerLocalize . actionCompileDescriptionModule ( moduleContext .getName ());
122+ presentation . setTextValue ( JavaCompilerLocalize . actionRunAptModuleText ( trimName ( moduleContext .getName ()) ));
120123 }
121124 else {
122125 PsiJavaPackage aPackage = null ;
@@ -136,49 +139,33 @@ public void update(@Nonnull AnActionEvent event) {
136139
137140 if (aPackage != null ) {
138141 String name = aPackage .getQualifiedName ();
139- if ( name . isEmpty ()) {
140- //noinspection HardCodedStringLiteral
141- name = "<default>" ;
142- }
143- elementDescription = LocalizeValue . localizeTODO ( "'" + name + "'" );
142+ presentation . setTextValue (
143+ StringUtil . isNotEmpty ( name )
144+ ? JavaCompilerLocalize . actionRunApt0Text ( trimName ( name ))
145+ : JavaCompilerLocalize . actionRunAptDefaultText ()
146+ );
144147 }
145148 else if (files .size () == 1 ) {
146149 VirtualFile file = files .iterator ().next ();
147150 FileType fileType = file .getFileType ();
148151 if (CompilerManager .getInstance (project ).isCompilableFileType (fileType )) {
149- elementDescription = LocalizeValue . localizeTODO ( "'" + file .getName () + "'" );
152+ presentation . setTextValue ( JavaCompilerLocalize . actionRunApt0Text ( trimName ( file .getName ())) );
150153 }
151154 else {
152- if (!ActionPlaces .MAIN_MENU .equals (event .getPlace ())) {
153- // the action should be invisible in popups for non-java files
154- presentation .setEnabled (false );
155- presentation .setVisible (false );
156- return ;
157- }
155+ presentation .setEnabled (false );
156+ // the action should be invisible in popups for non-java files
157+ presentation .setVisible (ActionPlaces .MAIN_MENU .equals (event .getPlace ()));
158158 }
159159 }
160160 else {
161- elementDescription = CompilerLocalize . actionCompileDescriptionSelectedFiles ( );
161+ presentation . setTextValue ( JavaCompilerLocalize . actionRunAptSelectedFilesText () );
162162 }
163163 }
164-
165- if (elementDescription == null ) {
166- presentation .setEnabled (false );
167- return ;
168- }
169-
170- presentation .setTextValue (createPresentationText (elementDescription .get ()));
171- presentation .setEnabled (true );
172164 }
173165
174- private static LocalizeValue createPresentationText (String elementDescription ) {
175- int length = elementDescription .length ();
176- String target = length > 23
177- ? (StringUtil .startsWithChar (elementDescription , '\'' ) ? "'..." : "..." ) + elementDescription .substring (length - 20 , length )
178- : elementDescription ;
179- return StringUtil .isEmpty (target )
180- ? ActionLocalize .actionRunaptText ()
181- : ActionLocalize .actionRunapt1Text (target );
166+ private static String trimName (String name ) {
167+ int length = name .length ();
168+ return length > 23 ? '…' + name .substring (length - 20 , length ) : name ;
182169 }
183170
184171 @ Nullable
0 commit comments