Java Code Examples for com.intellij.openapi.actionSystem.AnActionEvent

The following are top voted examples for showing how to use com.intellij.openapi.actionSystem.AnActionEvent. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: android-studio-plugin   File: DownloadAction.java   View source code 6 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent anActionEvent) {
    Project project = anActionEvent.getProject();
    VirtualFile virtualFile = project.getBaseDir();
    VirtualFile source = Utils.getSourceFile(virtualFile, null);
    Crowdin crowdin = new Crowdin();
    String branch = Utils.getCurrentBranch(project);
    crowdin.exportTranslations(branch);
    File downloadTranslations = crowdin.downloadTranslations(source, branch);
    Utils.extractTranslations(downloadTranslations);
    if (downloadTranslations.delete()) {
        System.out.println("all.zip was deleted");
    } else {
        System.out.println("all.zip wasn't deleted");
    }
}
 
Example 2
Project: intellij-randomness   File: PopupAction.java   View source code 6 votes vote down vote up
@Override
public void actionPerformed(final AnActionEvent event) {
    final Project project = event.getProject();
    if (project == null) {
        return;
    }

    final ListPopupImpl popup = (ListPopupImpl) JBPopupFactory.getInstance()
            .createActionGroupPopup(TITLE, new PopupGroup(), event.getDataContext(),
                    JBPopupFactory.ActionSelectionAid.NUMBERING, true, event.getPlace());
    JBPopupHelper.disableSpeedSearch(popup);
    JBPopupHelper.registerShiftActions(popup, TITLE, SHIFT_TITLE);
    JBPopupHelper.registerCtrlActions(popup, TITLE, CTRL_TITLE);

    popup.setAdText(AD_TEXT);
    popup.showCenteredInCurrentWindow(project);
}
 
Example 3
Project: ReciteWords   File: ReciteWords.java   View source code 6 votes vote down vote up
private void getTranslation(AnActionEvent event) {
    Editor mEditor = event.getData(PlatformDataKeys.EDITOR);
    Project project = event.getData(PlatformDataKeys.PROJECT);
    String basePath = project.getBasePath();

    if (null == mEditor) {
        return;
    }
    SelectionModel model = mEditor.getSelectionModel();
    String selectedText = model.getSelectedText();
    if (TextUtils.isEmpty(selectedText)) {
        selectedText = getCurrentWords(mEditor);
        if (TextUtils.isEmpty(selectedText)) {
            return;
        }
    }
    String queryText = strip(addBlanks(selectedText));
    new Thread(new RequestRunnable(mEditor, queryText,basePath)).start();
}
 
Example 4
Project: educational-plugin   File: StudyRefreshAnswerPlaceholder.java   View source code 6 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent e) {
  Project project = e.getProject();
  if (project == null) {
    return;
  }
  final AnswerPlaceholder answerPlaceholder = getAnswerPlaceholder(e);
  if (answerPlaceholder == null) {
    return;
  }
  StudyEditor studyEditor = StudyUtils.getSelectedStudyEditor(project);
  if (studyEditor != null) {
    StudySubtaskUtils.refreshPlaceholder(studyEditor.getEditor(), answerPlaceholder);
    final StudyTaskManager taskManager = StudyTaskManager.getInstance(project);
    answerPlaceholder.reset();
    taskManager.setStatus(answerPlaceholder, StudyStatus.Unchecked);
  }
}
 
Example 5
Project: educational-plugin   File: EduBrowseCoursesAction.java   View source code 6 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent e) {
  EduCoursesPanel panel = new EduCoursesPanel();
  DialogBuilder dialogBuilder = new DialogBuilder().title("Select Course").centerPanel(panel);
  dialogBuilder.addOkAction().setText("Join");
  panel.addCourseValidationListener(new EduCoursesPanel.CourseValidationListener() {
    @Override
    public void validationStatusChanged(boolean canStartCourse) {
      dialogBuilder.setOkActionEnabled(canStartCourse);
    }
  });
  dialogBuilder.setOkOperation(() -> {
    dialogBuilder.getDialogWrapper().close(DialogWrapper.OK_EXIT_CODE);
    Course course = panel.getSelectedCourse();
    String location = panel.getLocationString();
    EduCreateNewProjectDialog.createProject(EduPluginConfigurator.INSTANCE.forLanguage(course.getLanguageById()).getEduCourseProjectGenerator(), course, location);
  });
  dialogBuilder.show();
}
 
Example 6
Project: jgiven-intellij-plugin   File: FilterByJGivenStateAction.java   View source code 6 votes vote down vote up
@Override
public void setSelected(AnActionEvent e, boolean state) {
    JGivenSettings.getInstance().setJGivenFilteringEnabled(state);
    if (e.getProject() == null) {
        return;
    }
    Set<Usage> scenarioStateUsages = usageView.getUsages().stream()
            .filter(u -> u instanceof ReadWriteAccessUsageInfo2UsageAdapter &&
                    scenarioStateAnnotationProvider.isJGivenScenarioState(((ReadWriteAccessUsageInfo2UsageAdapter) u).getElement()))
            .collect(Collectors.toSet());

    if (state) {
        excludedUsages.stream()
                .filter(u -> !scenarioStateUsages.contains(u))
                .forEach(usageView::appendUsage);
    } else {
        excludedUsages = usageView.getUsages().stream()
                .filter(scenarioStateUsages::contains)
                .collect(Collectors.toSet());
        excludedUsages.forEach(usageView::removeUsage);
    }
    e.getProject().getMessageBus().syncPublisher(UsageFilteringRuleProvider.RULES_CHANGED).run();
}
 
Example 7
Project: quicknotes   File: AddToQuickNotes.java   View source code 6 votes vote down vote up
public void actionPerformed( AnActionEvent e ) {
    Editor editor = ( Editor ) e.getDataContext().getData( "editor" );
    SelectionModel selectionModel = editor.getSelectionModel();
    if ( selectionModel != null ) {
        String selectedText = selectionModel.getSelectedText();
        if ( selectedText != null && selectedText.trim().length() > 0 ) {
            Project project = ( Project ) e.getDataContext().getData( DataConstants.PROJECT );
            String panelid = ( String ) project.getUserData( QuickNotes.KEY_PANELID );
            QuickNotesPanel quickNotesPanel = QuickNotesManager.getInstance().getQuickNotesPanel( panelid );
            if ( quickNotesPanel != null ) {
                FileDocumentManager manager = FileDocumentManager.getInstance();
                VirtualFile virtualFile = manager.getFile( editor.getDocument() );
                quickNotesPanel.addNewNote( "[File: " + virtualFile.getPath() + "]\n" + selectedText );
            }
        }
    }
}
 
Example 8
Project: reasonml-idea-plugin   File: RefmtAction.java   View source code 6 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent e) {
    RefmtManager refmt = RefmtManager.getInstance();
    if (refmt != null) {
        PsiFile file = e.getData(PSI_FILE);
        Project project = e.getProject();
        if (project != null && file != null && (file instanceof OclFile || file instanceof RmlFile)) {
            String format = file instanceof OclFile ? "ml" : "re";
            Document document = PsiDocumentManager.getInstance(project).getDocument(file);
            if (document != null) {
                //WriteCommandAction.writeCommandAction(project).run(() -> refmt.refmt(project, format, document));
                WriteCommandAction.runWriteCommandAction(project, () -> refmt.refmt(project, format, document)); // idea#143
            }
        }
    }
}
 
Example 9
Project: hybris-integration-intellij-idea-plugin   File: ProjectRefreshAction.java   View source code 6 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent anActionEvent) {
    final Project project = getEventProject(anActionEvent);

    if (project == null) {
        return;
    }
    removeOldProjectData(project);

    try {
        collectStatistics();
        final AddModuleWizard wizard = getWizard(project);
        final ProjectBuilder projectBuilder = wizard.getProjectBuilder();

        if (projectBuilder instanceof AbstractHybrisProjectImportBuilder) {
            ((AbstractHybrisProjectImportBuilder) projectBuilder).setRefresh(true);
        }
        projectBuilder.commit(project, null, ModulesProvider.EMPTY_MODULES_PROVIDER);
    } catch (ConfigurationException e) {
        Messages.showErrorDialog(
            anActionEvent.getProject(),
            e.getMessage(),
            HybrisI18NBundleUtils.message("hybris.project.import.error.unable.to.proceed")
        );
    }
}
 
Example 10
Project: idea-php-typo3-plugin   File: NewExtensionFileAction.java   View source code 6 votes vote down vote up
@Override
public void actionPerformed(@NotNull AnActionEvent event) {

    final Project project = getEventProject(event);
    if (project == null) {
        this.setStatus(event, false);
        return;
    }

    PsiDirectory bundleDirContext = ExtensionUtility.getExtensionDirectory(event);
    if (bundleDirContext == null) {
        return;
    }

    String className = Messages.showInputDialog(project, "New class name:", "New File", TYPO3CMSIcons.TYPO3_ICON);
    if (StringUtils.isBlank(className)) {
        return;
    }

    if (!PhpNameUtil.isValidClassName(className)) {
        JOptionPane.showMessageDialog(null, "Invalid class name");
        return;
    }

    write(project, bundleDirContext, className);
}
 
Example 11
Project: watchMe   File: SlackSettings.java   View source code 6 votes vote down vote up
public void actionPerformed(AnActionEvent e) {
    this.project = e.getData(CommonDataKeys.PROJECT);

    String description = this.showInputDialog(SlackChannel.getIdDescription(), null);

    if (!isValidField(description)) {
        errorMessage();
        return;
    }

    String token = this.showInputDialog(SlackChannel.getTokenDescription(), null);

    if (!isValidField(token)) {
        errorMessage();
        return;
    }

    String channel = this.showInputDialog(SlackChannel.getChanneNameDescription(), "");

    SlackStorage.getInstance().registerChannel(new SlackChannel(token, description, channel));
    Messages.showMessageDialog(this.project, "Settings Saved.", "Information", Messages.getInformationIcon());
}
 
Example 12
Project: watchMe   File: SlackSettings.java   View source code 6 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent e) {
    final Project project = e.getData(CommonDataKeys.PROJECT);

    List<String> channelsId = SlackStorage.getInstance().getChannelsId();

    if (channelsId.size() > 0) {
        String channelToRemove = Messages.showEditableChooseDialog(
                "Select the channel to remove",
                SlackChannel.getSettingsDescription(),
                SlackStorage.getSlackIcon(),
                channelsId.toArray(new String[channelsId.size()]),
                channelsId.get(0),
                null
        );

        if (channelsId.contains(channelToRemove)) {
            SlackStorage.getInstance().removeChannelByDescription(channelToRemove);
            Messages.showMessageDialog(project, "Channel \"" + channelToRemove + "\" removed.", "Information", Messages.getInformationIcon());
        }
    }
}
 
Example 13
Project: educational-plugin   File: StudyUpdateRecommendationAction.java   View source code 6 votes vote down vote up
@Override
public void update(AnActionEvent e) {
  Presentation presentation = e.getPresentation();

  Project project = e.getProject();
  if (project == null) {
    presentation.setEnabledAndVisible(false);
    return;
  }

  Course course = StudyTaskManager.getInstance(project).getCourse();
  if (course == null || !course.isAdaptive()) {
    presentation.setEnabledAndVisible(false);
    return;
  }

  presentation.setEnabledAndVisible(true);
}
 
Example 14
Project: AndroidSourceViewer   File: CleanAction.java   View source code 6 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent e) {
    cacheFile = new File(Constant.CACHE_PATH);
    if (!cacheFile.exists()) {
        cacheFile.mkdirs();
    }
    long size = FileUtils.sizeOfDirectory(cacheFile);
    DialogBuilder builder = new DialogBuilder();
    builder.setTitle(Constant.TITLE);
    builder.resizable(false);
    builder.setCenterPanel(new JLabel(String.format("Currently occupy storage %.2fM, "
            + "Clean Cache immediately?", size/1024.0/1024.0),
            Messages.getInformationIcon(), SwingConstants.CENTER));
    builder.addOkAction().setText("Clean Now");
    builder.addCancelAction().setText("Cancel");
    builder.setButtonsAlignment(SwingConstants.RIGHT);
    if (builder.show() == 0) {
        clean();
    }
}
 
Example 15
Project: educational-plugin   File: PyCCCreateCourseAction.java   View source code 5 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent e) {
  AbstractNewProjectDialog dialog = new AbstractNewProjectDialog() {
    @Override
    protected DefaultActionGroup createRootStep() {
      return new PyCCCreateCourseProjectStep();
    }
  };
  dialog.show();
}
 
Example 16
Project: intellij-randomness   File: DataInsertActionTest.java   View source code 5 votes vote down vote up
/**
 * Tests that no further actions are taken when the editor is {@code null}.
 */
@Test
public void testActionPerformedNullEditor() {
    final AnActionEvent event = mock(AnActionEvent.class);
    when(event.getData(CommonDataKeys.EDITOR)).thenReturn(null);

    dataInsertAction.actionPerformed(event);

    verify(event, times(1)).getData(CommonDataKeys.EDITOR);
    verifyNoMoreInteractions(event);
}
 
Example 17
Project: CodeGen   File: TemplateAddAction.java   View source code 5 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent anActionEvent) {
    // 1. 显示CodeGroup新增dialog
    TemplateGroupEditDialog dialog = new TemplateGroupEditDialog();
    dialog.setTitle("Create New Group");
    dialog.getButtonOK().addActionListener(it -> {
        // 获取名称和level, 校验
        String name = dialog.getNameTextField().getText();
        String level = dialog.getLevelTextField().getText();
        if (StringUtils.isBlank(name)) {
            showErrorBorder(dialog.getNameTextField(), true);
            return;
        } else {
            showErrorBorder(dialog.getNameTextField(), false);
        }
        if (StringUtils.isBlank(level)) {
            showErrorBorder(dialog.getLevelTextField(), true);
            return;
        } else {
            showErrorBorder(dialog.getLevelTextField(), false);
        }
        // 新增group
        addCodeGroup(new CodeGroup(name.trim(), Integer.valueOf(level.trim())));
        dialog.setVisible(false);
    });
    // 2. 显示dialog
    showDialog(dialog, 300, 150);
}
 
Example 18
Project: GitCommitMessage   File: GetCommitMessageAction.java   View source code 5 votes vote down vote up
@Nullable
private static CommitMessageI getCommitPanel(@Nullable AnActionEvent e) {
    if (e == null) {
        return null;
    }
    Refreshable data = Refreshable.PANEL_KEY.getData(e.getDataContext());
    if (data instanceof CommitMessageI) {
        return (CommitMessageI) data;
    }
    return VcsDataKeys.COMMIT_MESSAGE_CONTROL.getData(e.getDataContext());
}
 
Example 19
Project: RIBs   File: GenerateAction.java   View source code 5 votes vote down vote up
@Override
public final void update(AnActionEvent e) {
  this.dataContext = e.getDataContext();
  final Presentation presentation = e.getPresentation();

  final boolean enabled = isAvailable(dataContext);

  presentation.setVisible(enabled);
  presentation.setEnabled(enabled);
}
 
Example 20
Project: react-native-console   File: RNConsoleImpl.java   View source code 5 votes vote down vote up
@Override
public void update(AnActionEvent e) {
    e.getPresentation().setVisible(myGeneralCommandLine != null);
    e.getPresentation().setEnabled(myGeneralCommandLine != null);
    if(displayName != null) {
        e.getPresentation().setText("Rerun '" + displayName + "'");
        e.getPresentation().setDescription("Rerun '" + displayName + "'");
    } else if(myGeneralCommandLine != null) {
        e.getPresentation().setText("Rerun '" + myGeneralCommandLine.getCommandLineString() + "'");
        e.getPresentation().setDescription("Rerun '" + myGeneralCommandLine.getCommandLineString() + "'");
    }
}
 
Example 21
Project: educational-plugin   File: StudyWindowNavigationAction.java   View source code 5 votes vote down vote up
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
  final Project project = e.getProject();
  if (project == null) {
    return;
  }
  navigateToPlaceholder(project);
}
 
Example 22
Project: AndroidSourceViewer   File: Utils.java   View source code 5 votes vote down vote up
@Nullable
public static String getClassPath(@NotNull AnActionEvent event) {
    String packageName = null;
    PsiElement element = event.getData(LangDataKeys.PSI_ELEMENT);
    if (element == null) {
        return packageName;
    }
    if (element instanceof PsiClass) {
        PsiClass cls = (PsiClass) element;
        if (cls.getContainingClass() != null) {
            // 排除内部类的情况
            packageName = cls.getContainingClass().getQualifiedName();
        } else {
            packageName = cls.getQualifiedName();
        }
        Log.debug("class => " + packageName);
    } else if (element instanceof PsiMethod) {
        PsiMethod method = (PsiMethod) element;
        Log.debug("method => " + method.getName() + " # "
                + method.getContainingClass().getQualifiedName());
        packageName = method.getContainingClass().getQualifiedName();
    } else if (element instanceof PsiVariable) {
        PsiVariable psiVariable = (PsiVariable) element;
        packageName = psiVariable.getType().getCanonicalText();
        // 去除泛型
        if (!Utils.isEmpty(packageName)) {
            packageName = packageName.replaceAll("<.*>", "");
        }
        // FIXME: 2017/11/11 变量对应类是内部类会有问题
        Log.debug("PsiVariable:" + psiVariable.getType().getCanonicalText());
    } else {
        Log.debug("cls = " + element.getClass());
    }
    return packageName;
}
 
Example 23
Project: hybris-integration-intellij-idea-plugin   File: ProjectRefreshAction.java   View source code 5 votes vote down vote up
public static void triggerAction(final DataContext dataContext) {
    ApplicationManager.getApplication().invokeLater(() -> {
        final AnAction action = new ProjectRefreshAction();
        final AnActionEvent actionEvent = AnActionEvent.createFromAnAction(
            action,
            null,
            ActionPlaces.UNKNOWN,
            dataContext
        );
        action.actionPerformed(actionEvent);
    }, ModalityState.NON_MODAL);
}
 
Example 24
Project: IntelliJ-Key-Promoter-X   File: KeyPromoterAction.java   View source code 5 votes vote down vote up
/**
 * Constructor used when we get notified by IDEA through {@link com.intellij.openapi.actionSystem.ex.AnActionListener}
 *
 * @param action action that was performed
 * @param event  event that fired the action
 * @param source the source of the action
 */
KeyPromoterAction(AnAction action, AnActionEvent event, ActionSource source) {
    myMnemonic = event.getPresentation().getMnemonic();
    myIdeaActionID = ActionManager.getInstance().getId(action);
    myDescription = event.getPresentation().getText();
    mySource = source;
    myShortcut = KeyPromoterUtils.getKeyboardShortcutsText(myIdeaActionID);
}
 
Example 25
Project: hybris-integration-intellij-idea-plugin   File: ValidateImpexAction.java   View source code 5 votes vote down vote up
@Override
public void actionPerformed(final AnActionEvent e) {
    final Editor editor = CommonDataKeys.EDITOR.getData(e.getDataContext());
    if (editor != null) {
        final SelectionModel selectionModel = editor.getSelectionModel();
        final ValidateImpexHttpClient client = new ValidateImpexHttpClient();
        final HybrisHttpResult hybrisHttpResult = client.validateImpex(selectionModel.getSelectedText());

        ExecuteHybrisConsole.getInstance().show(hybrisHttpResult, e.getProject());
    }
}
 
Example 26
Project: Dependency-Injection-Graph   File: GenerateDependencyInjectionGraph.java   View source code 5 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent anActionEvent) {
    Project project = anActionEvent.getProject();

    if (project != null) {

        try {
            initFiles(project);
        } catch (IOException e) {
            e.printStackTrace();
        }

        if (TextUtils.isEmpty(apkPath)) {
            chooseAndSaveApkFile(project);
        }

        packageName = PropertiesManager.getData(project, PropertyKeys.PACKAGE_NAME);

        if (TextUtils.isEmpty(packageName)) {
            setPackageName(project);
        }

        isInnerClassEnabled = PropertiesManager.getData(project, PropertyKeys.IS_INNER_CLASS_ENABLE, Strings.TRUE);

        if (!TextUtils.isEmpty(apkPath) && !TextUtils.isEmpty(packageName)) {
            Task task = generateDependencyInjectionGraph(project);
            task.queue();
        }
    }
}
 
Example 27
Project: educational-plugin   File: CCAnswerPlaceholderAction.java   View source code 5 votes vote down vote up
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
  CCState state = getState(e);
  if (state == null) {
    return;
  }
  performAnswerPlaceholderAction(state);
}
 
Example 28
Project: educational-plugin   File: CCEditTaskTextAction.java   View source code 5 votes vote down vote up
@Override
public boolean isSelected(AnActionEvent e) {
  Project project = e.getProject();
  if (project == null) {
    return false;
  }
  return StudyTaskManager.getInstance(project).getToolWindowMode() == StudyToolWindow.StudyToolWindowMode.EDITING;
}
 
Example 29
Project: intellij-postfix-templates   File: OpenJavaScriptTemplatesAction.java   View source code 5 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent anActionEvent) {
	if (anActionEvent.getProject() != null) {
		CptUtil.getTemplateFile("javascript").ifPresent(file -> {
			CptUtil.openFileInEditor(anActionEvent.getProject(), file);
		});
	}
}
 
Example 30
Project: educational-plugin   File: CCCreateStudyItemActionBase.java   View source code 5 votes vote down vote up
@Override
public void update(@NotNull AnActionEvent event) {
  final Presentation presentation = event.getPresentation();
  presentation.setEnabledAndVisible(false);
  final Project project = event.getData(CommonDataKeys.PROJECT);
  final IdeView view = event.getData(LangDataKeys.IDE_VIEW);
  if (project == null || view == null) {
    return;
  }
  if (!StudyUtils.isStudyProject(project) || !CCUtils.isCourseCreator(project)) {
    return;
  }
  final PsiDirectory[] directories = view.getDirectories();
  if (directories.length == 0 || directories.length > 1) {
    return;
  }

  final PsiDirectory sourceDirectory = directories[0];
  final Course course = StudyTaskManager.getInstance(project).getCourse();
  if (course == null || sourceDirectory == null) {
    return;
  }
  if (!isAddedAsLast(sourceDirectory, project, course) && getThresholdItem(course, sourceDirectory) == null) {
    return;
  }
  if (CommonDataKeys.PSI_FILE.getData(event.getDataContext()) != null) {
    return;
  }
  presentation.setEnabledAndVisible(true);
}
 
Example 31
Project: mybatis-log-plugin   File: GoogleTranslateAction.java   View source code 5 votes vote down vote up
public void actionPerformed(AnActionEvent var1) {
    DataContext var2 = var1.getDataContext();
    CopyProvider var3 = (CopyProvider) PlatformDataKeys.COPY_PROVIDER.getData(var2);
    if (var3 != null) {
        var3.performCopy(var2);
        String var4 = (String) CopyPasteManager.getInstance().getContents(DataFlavor.stringFlavor);
        if (StringUtil.isNotEmpty(var4)) {
            BrowserUtil.browse("https://translate.google.com/#en/zh-CN/" + URLEncoder.encode(var4));
        }
    }
}
 
Example 32
Project: educational-plugin   File: CCTaskFileActionBase.java   View source code 5 votes vote down vote up
@Override
public void update(AnActionEvent e) {
  Project project = e.getProject();
  Presentation presentation = e.getPresentation();
  if (project == null || !CCUtils.isCourseCreator(project)) {
    presentation.setEnabledAndVisible(false);
    return;
  }
  final VirtualFile[] virtualFiles = CommonDataKeys.VIRTUAL_FILE_ARRAY.getData(e.getDataContext());
  if (virtualFiles == null || virtualFiles.length == 0) {
    presentation.setEnabledAndVisible(false);
  }
}
 
Example 33
Project: Gherkin-TS-Runner   File: GherkinIconRenderer.java   View source code 5 votes vote down vote up
@Nullable
public AnAction getClickAction() {
    return new AnAction() {
        @Override
        public void actionPerformed(AnActionEvent e) {
            callProtractor();
        }
    };
}
 
Example 34
Project: Android-ORM-ASPlugin   File: AddAnnotationAction.java   View source code 5 votes vote down vote up
@Override
public void update(AnActionEvent event) {
    super.update(event);
    setEnabledInModalContext(true);
    getTemplatePresentation().setEnabled(true);
    getTemplatePresentation().setVisible(true);
}
 
Example 35
Project: educational-plugin   File: EduStartLearningAction.java   View source code 5 votes vote down vote up
@Override
public void update(AnActionEvent e) {
  if (ApplicationManager.getApplication().getExtensions(EduIntelliJProjectTemplate.EP_NAME).length < 1) {
    e.getPresentation().setEnabledAndVisible(false);
  }
  if (!PlatformUtils.isJetBrainsProduct()) {
    e.getPresentation().setEnabledAndVisible(false);
  }
}
 
Example 36
Project: educational-plugin   File: StudyUtils.java   View source code 5 votes vote down vote up
public static void updateAction(@NotNull final AnActionEvent e) {
  final Presentation presentation = e.getPresentation();
  presentation.setEnabled(false);
  final Project project = e.getProject();
  if (project != null) {
    final StudyEditor studyEditor = getSelectedStudyEditor(project);
    if (studyEditor != null) {
      presentation.setEnabledAndVisible(true);
    }
  }
}
 
Example 37
Project: hybris-integration-intellij-idea-plugin   File: GenerateDomModelAction.java   View source code 5 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent e) {
    final Project project = CommonDataKeys.PROJECT.getData(e.getDataContext());
    if (project != null) {
        new DomGenDialog(project).show();
    }
}
 
Example 38
Project: android-studio-plugin   File: UploadAction.java   View source code 5 votes vote down vote up
@Override
public void actionPerformed(@NotNull final AnActionEvent anActionEvent) {
    Project project = anActionEvent.getProject();
    VirtualFile virtualFile = project.getBaseDir();
    String sourcesProp = Utils.getPropertyValue(PROPERTY_SOURCES, true);
    List<String> sourcesList = Utils.getSourcesList(sourcesProp);
    Crowdin crowdin = new Crowdin();
    for (String src : sourcesList) {
        VirtualFile source = Utils.getSourceFile(virtualFile, src);
        String branch = Utils.getCurrentBranch(project);
        crowdin.uploadFile(source, branch);
    }
}
 
Example 39
Project: yaml-format   File: FormatYamlAction.java   View source code 5 votes vote down vote up
@Override
public void update(AnActionEvent event) {
	//在Action显示之前,根据选中文件扩展名判定是否显示此Action
	VirtualFile file = DataKeys.VIRTUAL_FILE.getData(event.getDataContext());
	boolean show = file.isDirectory() || isYamlFile(file.getExtension());
	this.getTemplatePresentation().setEnabled(show);
	this.getTemplatePresentation().setVisible(show);
}
 
Example 40
Project: educational-plugin   File: CCStepicConnector.java   View source code 5 votes vote down vote up
private static void showStepicNotification(@NotNull Project project,
                                           @NotNull NotificationType notificationType, @NotNull String failedActionName) {
  String text = "Log in to Stepik to " + failedActionName;
  Notification notification = new Notification("Stepik", "Failed to " + failedActionName, text, notificationType);
  notification.addAction(new AnAction("Log in") {

    @Override
    public void actionPerformed(AnActionEvent e) {
      EduStepicConnector.doAuthorize(() -> showOAuthDialog());
      notification.expire();
    }
  });

  notification.notify(project);
}