Java Code Examples for com.intellij.openapi.util.SystemInfo#isMac()

The following examples show how to use com.intellij.openapi.util.SystemInfo#isMac() . 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: ActionUtil.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nullable
public static ShortcutSet getMnemonicAsShortcut(@Nonnull AnAction action) {
  int mnemonic = KeyEvent.getExtendedKeyCodeForChar(action.getTemplatePresentation().getMnemonic());
  if (mnemonic != KeyEvent.VK_UNDEFINED) {
    KeyboardShortcut ctrlAltShortcut = new KeyboardShortcut(KeyStroke.getKeyStroke(mnemonic, InputEvent.ALT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK), null);
    KeyboardShortcut altShortcut = new KeyboardShortcut(KeyStroke.getKeyStroke(mnemonic, InputEvent.ALT_DOWN_MASK), null);
    CustomShortcutSet shortcutSet;
    if (SystemInfo.isMac) {
      if (Registry.is("ide.mac.alt.mnemonic.without.ctrl")) {
        shortcutSet = new CustomShortcutSet(ctrlAltShortcut, altShortcut);
      }
      else {
        shortcutSet = new CustomShortcutSet(ctrlAltShortcut);
      }
    }
    else {
      shortcutSet = new CustomShortcutSet(altShortcut);
    }
    return shortcutSet;
  }
  return null;
}
 
Example 2
Source File: ExternalStorage.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
private static String getOsPrefix() {
  if (SystemInfo.isWindows) {
    return "win";
  }
  else if (SystemInfo.isMac) {
    return "mac";
  }
  else if (SystemInfo.isLinux) {
    return "linux";
  }
  else if (SystemInfo.isFreeBSD) {
    return "bsd";
  }
  else if (SystemInfo.isUnix) {
    return "unix";
  }
  return "other";
}
 
Example 3
Source File: BlazeAndroidRunConfigurationDebuggerManager.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Nullable
public AndroidDebuggerState getAndroidDebuggerState(Project project) {
  AndroidDebugger debuggerToUse = getAndroidDebugger();
  if (debuggerToUse == null) {
    return null;
  }

  AndroidDebuggerState androidDebuggerState = debuggerToUse.createState();
  if (androidDebuggerState instanceof NativeAndroidDebuggerState) {
    NativeAndroidDebuggerState nativeState = (NativeAndroidDebuggerState) androidDebuggerState;
    String workingDirPath = WorkspaceRoot.fromProject(project).directory().getPath();
    nativeState.setWorkingDir(workingDirPath);

    // b/151821788 "/proc/self/cwd" used by linux built binaries isn't valid on MacOS.
    if (SystemInfo.isMac) {
      String sourceMapToWorkspaceRootCommand =
          "settings set target.source-map /proc/self/cwd/ " + workingDirPath;
      ImmutableList<String> startupCommands =
          ImmutableList.<String>builder()
              .addAll(nativeState.getUserStartupCommands())
              .add(sourceMapToWorkspaceRootCommand)
              .build();
      nativeState.setUserStartupCommands(startupCommands);
    }
  }
  return androidDebuggerState;
}
 
Example 4
Source File: MultiSelectDialog.java    From AndroidStringsOneTabTranslation with Apache License 2.0 5 votes vote down vote up
@NotNull
@Override
protected Action[] createActions() {
    Action[] actions;
    if (SystemInfo.isMac) {
        actions = new Action[]{myCancelAction, myOKAction};
    } else {
        actions = new Action[]{myOKAction, myCancelAction};
    }
    return actions;
}
 
Example 5
Source File: OnePixelDivider.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected void processMouseEvent(MouseEvent e) {
  super.processMouseEvent(e);
  if (e.getID() == MouseEvent.MOUSE_CLICKED) {
    if (mySwitchOrientationEnabled
        && e.getClickCount() == 1
        && SwingUtilities.isLeftMouseButton(e) && (SystemInfo.isMac ? e.isMetaDown() : e.isControlDown())) {
      mySplitter.setOrientation(!mySplitter.getOrientation());
    }
    if (myResizeEnabled && e.getClickCount() == 2) {
      mySplitter.setProportion(.5f);
    }
  }
}
 
Example 6
Source File: RtfTransferableData.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static int[] getAdjustedColorComponents(Color color) {
  if (SystemInfo.isMac) {
    // on Mac OS color components are expected in Apple's 'Generic RGB' color space
    ColorSpace genericRgbSpace = MacOSApplicationProvider.getInstance().getGenericRgbColorSpace();
    if (genericRgbSpace != null) {
      float[] components = genericRgbSpace.fromRGB(color.getRGBColorComponents(null));
      return new int[] {
              colorComponentFloatToInt(components[0]),
              colorComponentFloatToInt(components[1]),
              colorComponentFloatToInt(components[2])
      };
    }
  }
  return new int[] {color.getRed(), color.getGreen(), color.getBlue()};
}
 
Example 7
Source File: DialogWrapper.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected final void setCancelButtonIcon(Icon icon) {
  // Setting icons causes buttons be 'square' style instead of
  // 'rounded', which is expected by apple users.
  if (!SystemInfo.isMac) {
    myCancelAction.putValue(Action.SMALL_ICON, icon);
  }
}
 
Example 8
Source File: IconUtil.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static SwingImageRef getAddClassIcon() {
  return SystemInfo.isMac ? AllIcons.ToolbarDecorator.Mac.AddClass : AllIcons.ToolbarDecorator.AddClass;
}
 
Example 9
Source File: DefaultUIDecorator.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public boolean decorateHelpButton() {
  return SystemInfo.isMac;
}
 
Example 10
Source File: Restarter.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static boolean isSupported() {
  return (getRestartCode() != 0 || SystemInfo.isWindows || SystemInfo.isMac) && !ApplicationProperties.isInSandbox();
}
 
Example 11
Source File: CommonBundle.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static String settingsActionDescription() {
  return SystemInfo.isMac ? message("action.settings.description.mac") : message("action.settings.description");
}
 
Example 12
Source File: TextPanel.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public Font getFont() {
  return SystemInfo.isMac ? JBUI.Fonts.label(11) : JBFont.label();
}
 
Example 13
Source File: Messages.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static boolean isMacSheetEmulation() {
  return SystemInfo.isMac && Registry.is("ide.mac.message.dialogs.as.sheets") && Registry.is("ide.mac.message.sheets.java.emulation");
}
 
Example 14
Source File: IconUtil.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static SwingImageRef getMoveDownIcon() {
  return SystemInfo.isMac ? AllIcons.ToolbarDecorator.Mac.MoveDown : AllIcons.ToolbarDecorator.MoveDown;
}
 
Example 15
Source File: ComboBoxWithWidePopup.java    From consulo with Apache License 2.0 4 votes vote down vote up
public ComboBoxWithWidePopup(final ComboBoxModel<E> aModel) {
  super(aModel);

  if (SystemInfo.isMac && UIUtil.isUnderAquaLookAndFeel()) setMaximumRowCount(25);
}
 
Example 16
Source File: EncodingEnvironmentUtil.java    From consulo with Apache License 2.0 4 votes vote down vote up
/**
 * @deprecated use {@link #setLocaleEnvironmentIfMac(GeneralCommandLine)} instead (to be removed in IDEA 16)
 */
public static void fixDefaultEncodingIfMac(@Nonnull GeneralCommandLine commandLine, @Nullable Project project) {
  if (SystemInfo.isMac && !isLocaleDefined(commandLine)) {
    setLocaleEnvironment(commandLine.getEnvironment(), getCharset(project));
  }
}
 
Example 17
Source File: Messages.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static boolean canShowMacSheetPanel() {
  return SystemInfo.isMac && !isApplicationInUnitTestOrHeadless() && Registry.is("ide.mac.message.dialogs.as.sheets");
  //&& !DialogWrapper.isMultipleModalDialogs();
}
 
Example 18
Source File: CommonBundle.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static String settingsTitle() {
  return SystemInfo.isMac ? message("title.settings.mac") : message("title.settings");
}
 
Example 19
Source File: ChooseTargetModel.java    From buck with Apache License 2.0 4 votes vote down vote up
@Override
public char getCheckBoxMnemonic() {
  return SystemInfo.isMac ? 'P' : 'n';
}
 
Example 20
Source File: GotoSymbolModel2.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public char getCheckBoxMnemonic() {
  // Some combination like Alt+N, Ant+O, etc are a dead sysmbols, therefore
  // we have to change mnemonics for Mac users.
  return SystemInfo.isMac?'P':'n';
}