Java Code Examples for com.intellij.openapi.actionSystem.Presentation#putClientProperty()

The following examples show how to use com.intellij.openapi.actionSystem.Presentation#putClientProperty() . 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: FlutterViewLocalToggleableAction.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public final void update(@NotNull AnActionEvent e) {
  // selected
  final boolean selected = this.isSelected();
  final Presentation presentation = e.getPresentation();
  presentation.putClientProperty("selected", selected);

  if (!app.isSessionActive()) {
    if (subscription != null) {
      subscription.dispose();
      subscription = null;
    }
    e.getPresentation().setEnabled(false);
    return;
  }

  if (subscription == null) {
    subscription = stream.listen((value) -> {
      this.setSelected(e, value);
    }, true);
  }
}
 
Example 2
Source File: FlutterViewLocalToggleableAction.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public final void update(@NotNull AnActionEvent e) {
  // selected
  final boolean selected = this.isSelected();
  final Presentation presentation = e.getPresentation();
  presentation.putClientProperty("selected", selected);

  if (!app.isSessionActive()) {
    if (subscription != null) {
      subscription.dispose();
      subscription = null;
    }
    e.getPresentation().setEnabled(false);
    return;
  }

  if (subscription == null) {
    subscription = stream.listen((value) -> {
      this.setSelected(e, value);
    }, true);
  }
}
 
Example 3
Source File: FlutterViewToggleableAction.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public final void update(@NotNull AnActionEvent e) {
  // selected
  final boolean selected = this.isSelected();
  final Presentation presentation = e.getPresentation();
  presentation.putClientProperty("selected", selected);

  if (!app.isSessionActive()) {
    dispose();
    e.getPresentation().setEnabled(false);
    return;
  }

  if (currentValueSubscription == null) {
    currentValueSubscription =
      app.getVMServiceManager().getServiceExtensionState(extensionDescription.getExtension()).listen((state) -> {
        if (presentation.getClientProperty("selected") != (Boolean)state.isEnabled()) {
          presentation.putClientProperty("selected", state.isEnabled());
        }
      }, true);
  }

  presentation.setText(
    isSelected()
    ? extensionDescription.getEnabledText()
    : extensionDescription.getDisabledText());

  app.hasServiceExtension(extensionDescription.getExtension(), (enabled) -> {
    e.getPresentation().setEnabled(app.isSessionActive() && enabled);
  });
}
 
Example 4
Source File: FlutterViewLocalToggleableAction.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void actionPerformed(@NotNull AnActionEvent event) {
  this.setSelected(event, !isSelected());
  final Presentation presentation = event.getPresentation();
  presentation.putClientProperty("selected", isSelected());

  super.actionPerformed(event);
}
 
Example 5
Source File: FlutterViewToggleableAction.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public final void update(@NotNull AnActionEvent e) {
  // selected
  final boolean selected = this.isSelected();
  final Presentation presentation = e.getPresentation();
  presentation.putClientProperty("selected", selected);

  if (!app.isSessionActive()) {
    dispose();
    e.getPresentation().setEnabled(false);
    return;
  }

  if (currentValueSubscription == null) {
    currentValueSubscription =
      app.getVMServiceManager().getServiceExtensionState(extensionDescription.getExtension()).listen((state) -> {
        if (presentation.getClientProperty("selected") != (Boolean)state.isEnabled()) {
          presentation.putClientProperty("selected", state.isEnabled());
        }
      }, true);
  }

  presentation.setText(
    isSelected()
    ? extensionDescription.getEnabledText()
    : extensionDescription.getDisabledText());

  app.hasServiceExtension(extensionDescription.getExtension(), (enabled) -> {
    e.getPresentation().setEnabled(app.isSessionActive() && enabled);
  });
}
 
Example 6
Source File: FlutterViewLocalToggleableAction.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void actionPerformed(@NotNull AnActionEvent event) {
  this.setSelected(event, !isSelected());
  final Presentation presentation = event.getPresentation();
  presentation.putClientProperty("selected", isSelected());

  super.actionPerformed(event);
}
 
Example 7
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 8
Source File: ToggleActionButton.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public final void actionPerformed(AnActionEvent e) {
  final boolean state = !isSelected(e);
  setSelected(e, state);
  final Boolean selected = state ? Boolean.TRUE : Boolean.FALSE;
  final Presentation presentation = e.getPresentation();
  presentation.putClientProperty(Toggleable.SELECTED_PROPERTY, selected);
}
 
Example 9
Source File: MenuItemPresentationFactory.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected void processPresentation(Presentation presentation) {
  if (!UISettings.getInstance().SHOW_ICONS_IN_MENUS || myForceHide) {
    presentation.setIcon(null);
    presentation.setDisabledIcon(null);
    presentation.setHoveredIcon(null);
    presentation.putClientProperty(HIDE_ICON, Boolean.TRUE);
  }
}
 
Example 10
Source File: ShowLibraryFramesAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void update(@Nonnull final AnActionEvent e) {
  super.update(e);

  Presentation presentation = e.getPresentation();

  Object isSupported = presentation.getClientProperty(IS_LIBRARY_FRAME_FILTER_SUPPORTED);
  XDebugSession session = e.getData(XDebugSession.DATA_KEY);
  if (isSupported == null) {
    if (session == null) {
      // if session is null and isSupported is null - just return, it means that action created initially not in the xdebugger tab
      presentation.setVisible(false);
      return;
    }

    isSupported = session.getDebugProcess().isLibraryFrameFilterSupported();
    presentation.putClientProperty(IS_LIBRARY_FRAME_FILTER_SUPPORTED, isSupported);
  }

  if (Boolean.TRUE.equals(isSupported)) {
    presentation.setVisible(true);
    final boolean shouldShow = !Boolean.TRUE.equals(presentation.getClientProperty(SELECTED_PROPERTY));
    presentation.setText(shouldShow ? ourTextWhenShowIsOn : ourTextWhenShowIsOff);
  }
  else {
    presentation.setVisible(false);
  }
}
 
Example 11
Source File: ListenToFileSystemToggleConfigurationAction.java    From aem-ide-tooling-4-intellij with Apache License 2.0 4 votes vote down vote up
public void update(@NotNull AnActionEvent event) {
    boolean selected = this.isSelected(event);
    Presentation presentation = event.getPresentation();
    presentation.putClientProperty("selected", selected);
}
 
Example 12
Source File: ToggleActionButton.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public final void updateButton(AnActionEvent e) {
  final Boolean selected = isSelected(e) ? Boolean.TRUE : Boolean.FALSE;
  final Presentation presentation = e.getPresentation();
  presentation.putClientProperty(Toggleable.SELECTED_PROPERTY, selected);
}