Java Code Examples for com.intellij.openapi.actionSystem.AnActionEvent#getModifiers()

The following examples show how to use com.intellij.openapi.actionSystem.AnActionEvent#getModifiers() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OpenAndroidModule.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent e) {
  final VirtualFile projectFile = findProjectFile(e);
  if (projectFile == null) {
    FlutterMessages.showError("Error Opening Android Studio", "Project not found.");
    return;
  }
  final int modifiers = e.getModifiers();
  // From ReopenProjectAction.
  final boolean forceOpenInNewFrame = BitUtil.isSet(modifiers, InputEvent.CTRL_MASK)
                                      || BitUtil.isSet(modifiers, InputEvent.SHIFT_MASK)
                                      || e.getPlace() == ActionPlaces.WELCOME_SCREEN;

  VirtualFile sourceFile = e.getData(CommonDataKeys.VIRTUAL_FILE);
  // Using:
  //ProjectUtil.openOrImport(projectFile.getPath(), e.getProject(), forceOpenInNewFrame);
  // presents the user with a really imposing Gradle project import dialog.
  openOrImportProject(projectFile, e.getProject(), sourceFile, forceOpenInNewFrame);
}
 
Example 2
Source File: OpenAndroidModule.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent e) {
  final VirtualFile projectFile = findProjectFile(e);
  if (projectFile == null) {
    FlutterMessages.showError("Error Opening Android Studio", "Project not found.");
    return;
  }
  final int modifiers = e.getModifiers();
  // From ReopenProjectAction.
  final boolean forceOpenInNewFrame = BitUtil.isSet(modifiers, InputEvent.CTRL_MASK)
                                      || BitUtil.isSet(modifiers, InputEvent.SHIFT_MASK)
                                      || e.getPlace() == ActionPlaces.WELCOME_SCREEN;

  VirtualFile sourceFile = e.getData(CommonDataKeys.VIRTUAL_FILE);
  // Using:
  //ProjectUtil.openOrImport(projectFile.getPath(), e.getProject(), forceOpenInNewFrame);
  // presents the user with a really imposing Gradle project import dialog.
  openOrImportProject(projectFile, e.getProject(), sourceFile, forceOpenInNewFrame);
}
 
Example 3
Source File: ReloadFlutterApp.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
  final Project project = getEventProject(e);
  if (project == null) {
    return;
  }

  // If the shift key is held down, perform a restart. We check to see if we're being invoked from the
  // 'GoToAction' dialog. If so, the modifiers are for the command that opened the go to action dialog.
  final boolean shouldRestart = (e.getModifiers() & InputEvent.SHIFT_MASK) != 0 && !"GoToAction".equals(e.getPlace());

  if (shouldRestart) {
    FlutterInitializer.sendAnalyticsAction(RestartFlutterApp.class.getSimpleName());
    FlutterReloadManager.getInstance(project).saveAllAndRestart(getApp(), FlutterConstants.RELOAD_REASON_MANUAL);
  }
  else {
    // Else perform a hot reload.
    FlutterInitializer.sendAnalyticsAction(this);
    FlutterReloadManager.getInstance(project).saveAllAndReload(getApp(), FlutterConstants.RELOAD_REASON_MANUAL);
  }
}
 
Example 4
Source File: ReloadFlutterApp.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
  final Project project = getEventProject(e);
  if (project == null) {
    return;
  }

  // If the shift key is held down, perform a restart. We check to see if we're being invoked from the
  // 'GoToAction' dialog. If so, the modifiers are for the command that opened the go to action dialog.
  final boolean shouldRestart = (e.getModifiers() & InputEvent.SHIFT_MASK) != 0 && !"GoToAction".equals(e.getPlace());

  if (shouldRestart) {
    FlutterInitializer.sendAnalyticsAction(RestartFlutterApp.class.getSimpleName());
    FlutterReloadManager.getInstance(project).saveAllAndRestart(getApp(), FlutterConstants.RELOAD_REASON_MANUAL);
  }
  else {
    // Else perform a hot reload.
    FlutterInitializer.sendAnalyticsAction(this);
    FlutterReloadManager.getInstance(project).saveAllAndReload(getApp(), FlutterConstants.RELOAD_REASON_MANUAL);
  }
}
 
Example 5
Source File: ListenToFileSystemToggleConfigurationAction.java    From aem-ide-tooling-4-intellij with Apache License 2.0 5 votes vote down vote up
public final void actionPerformed(@NotNull AnActionEvent event) {
    if((event.getModifiers() & MouseEvent.ALT_MASK) != 0) {
        ShowSettingsUtil.getInstance().showSettingsDialog(event.getProject(), AEMPluginConfiguration.DISPLAY_NAME);
    } else {
        boolean state = !this.isSelected(event);
        this.setSelected(event, state);
        Presentation presentation = event.getPresentation();
        presentation.putClientProperty("selected", state);
    }
}
 
Example 6
Source File: DropAnErrorWithAttachmentsAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void actionPerformed(AnActionEvent e) {
  final boolean multipleAttachments = (e.getModifiers() & InputEvent.SHIFT_MASK) != 0;
  Attachment[] attachments;
  if (multipleAttachments) {
    attachments = new Attachment[]{new Attachment("first.txt", "first content"), new Attachment("second.txt", "second content")};
  }
  else {
    attachments = new Attachment[]{new Attachment("attachment.txt", "content")};
  }
  Logger.getInstance("test (with attachments)").error(LogMessageEx.createEvent("test", "test details", attachments));
}
 
Example 7
Source File: ChainActionEvent.java    From emacsIDEAs with Apache License 2.0 4 votes vote down vote up
public ChainActionEvent(AnActionEvent e, Runnable runnable, Editor _editor, Project _project) {
    super(e.getInputEvent(), e.getDataContext(), e.getPlace(), e.getPresentation(), e.getActionManager(), e.getModifiers());
    this._pendingAction = runnable;
    this._editor = _editor;
    this._project = _project;
}
 
Example 8
Source File: VcsContextWrapper.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
public static VcsContextWrapper createInstanceOn(@Nonnull AnActionEvent event) {
  return new VcsContextWrapper(event.getDataContext(), event.getModifiers(), event.getPlace(), event.getPresentation().getText());
}
 
Example 9
Source File: VcsContextFactoryImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
@Nonnull
public VcsContext createContextOn(@Nonnull AnActionEvent event) {
  return new VcsContextWrapper(event.getDataContext(), event.getModifiers(), event.getPlace(), event.getPresentation().getText());
}