use of com.intellij.openapi.application.Application in project android by JetBrains.
the class GradleSpecificInitializer method checkInstallPath.
/**
* Gradle has an issue when the studio path contains ! (http://b.android.com/184588)
*/
private static void checkInstallPath() {
if (PathManager.getHomePath().contains("!")) {
final Application app = ApplicationManager.getApplication();
app.getMessageBus().connect(app).subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener() {
@Override
public void appStarting(Project project) {
app.invokeLater(() -> {
String message = String.format("%1$s must not be installed in a path containing '!' or Gradle sync will fail!", ApplicationNamesInfo.getInstance().getProductName());
Notification notification = getNotificationGroup().createNotification(message, NotificationType.ERROR);
notification.setImportant(true);
Notifications.Bus.notify(notification);
});
}
});
}
}
use of com.intellij.openapi.application.Application in project android-selector-intellij-plugin by importre.
the class AndroidSelectorDialog method doOKAction.
@Override
protected void doOKAction() {
String f = filenameText.getText();
final String filename = (f.endsWith(".xml") ? f : f + ".xml").trim();
final String color = getColorName(colorCombo);
final String pressed = getColorName(pressedCombo);
final String pressedV21 = getColorName(pressedV21Combo);
if (!valid(filename, color, pressed, pressedV21)) {
String title = "Invalidation";
String msg = "color, pressed, pressedV21 must start with `@color/`";
showMessageDialog(title, msg);
return;
}
if (exists(filename)) {
String title = "Cannot create files";
String msg = String.format(Locale.US, "`%s` already exists", filename);
showMessageDialog(title, msg);
return;
}
Application app = ApplicationManager.getApplication();
app.runWriteAction(new Runnable() {
@Override
public void run() {
try {
createDrawable(filename, color, pressed);
createDrawableV21(filename, color, pressedV21);
} catch (Exception e) {
e.printStackTrace();
}
}
});
super.doOKAction();
}
use of com.intellij.openapi.application.Application in project ideavim by JetBrains.
the class KeyHandler method handleKeyMapping.
private boolean handleKeyMapping(@NotNull final Editor editor, @NotNull final KeyStroke key, @NotNull final DataContext context) {
final CommandState commandState = CommandState.getInstance(editor);
commandState.stopMappingTimer();
final List<KeyStroke> mappingKeys = commandState.getMappingKeys();
final List<KeyStroke> fromKeys = new ArrayList<KeyStroke>(mappingKeys);
fromKeys.add(key);
final MappingMode mappingMode = commandState.getMappingMode();
if (MappingMode.NVO.contains(mappingMode) && (state != State.NEW_COMMAND || currentArg != Argument.Type.NONE)) {
return false;
}
final KeyMapping mapping = VimPlugin.getKey().getKeyMapping(mappingMode);
final MappingInfo currentMappingInfo = mapping.get(fromKeys);
final MappingInfo prevMappingInfo = mapping.get(mappingKeys);
final MappingInfo mappingInfo = currentMappingInfo != null ? currentMappingInfo : prevMappingInfo;
final Application application = ApplicationManager.getApplication();
if (mapping.isPrefix(fromKeys)) {
mappingKeys.add(key);
if (!application.isUnitTestMode() && Options.getInstance().isSet(Options.TIMEOUT)) {
commandState.startMappingTimer(new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
mappingKeys.clear();
for (KeyStroke keyStroke : fromKeys) {
handleKey(editor, keyStroke, new EditorDataContext(editor), false);
}
}
});
}
return true;
} else if (mappingInfo != null) {
mappingKeys.clear();
final Runnable handleMappedKeys = new Runnable() {
@Override
public void run() {
if (editor.isDisposed()) {
return;
}
final List<KeyStroke> toKeys = mappingInfo.getToKeys();
final VimExtensionHandler extensionHandler = mappingInfo.getExtensionHandler();
final EditorDataContext currentContext = new EditorDataContext(editor);
if (toKeys != null) {
final boolean fromIsPrefix = isPrefix(mappingInfo.getFromKeys(), toKeys);
boolean first = true;
for (KeyStroke keyStroke : toKeys) {
final boolean recursive = mappingInfo.isRecursive() && !(first && fromIsPrefix);
handleKey(editor, keyStroke, currentContext, recursive);
first = false;
}
} else if (extensionHandler != null) {
RunnableHelper.runWriteCommand(editor.getProject(), new Runnable() {
@Override
public void run() {
extensionHandler.execute(editor, context);
}
}, "Vim " + extensionHandler.getClass().getSimpleName(), null);
}
if (prevMappingInfo != null) {
handleKey(editor, key, currentContext);
}
}
};
if (application.isUnitTestMode()) {
handleMappedKeys.run();
} else {
application.invokeLater(handleMappedKeys);
}
return true;
} else {
final List<KeyStroke> unhandledKeys = new ArrayList<KeyStroke>(mappingKeys);
mappingKeys.clear();
for (KeyStroke keyStroke : unhandledKeys) {
handleKey(editor, keyStroke, context, false);
}
return false;
}
}
use of com.intellij.openapi.application.Application in project ideavim by JetBrains.
the class UiHelper method runAfterGotFocus.
/**
* Run code after getting focus on request.
*
* @see #requestFocus
*/
public static void runAfterGotFocus(@NotNull final Runnable runnable) {
final Application application = ApplicationManager.getApplication();
// XXX: One more invokeLater than in requestFocus()
application.invokeLater(new Runnable() {
@Override
public void run() {
application.invokeLater(new Runnable() {
@Override
public void run() {
application.invokeLater(runnable);
}
});
}
});
}
use of com.intellij.openapi.application.Application in project android by JetBrains.
the class SimulatedSyncErrors method simulateRegisteredSyncError.
public static void simulateRegisteredSyncError() {
Application application = ApplicationManager.getApplication();
ExternalSystemException error = application.getUserData(SIMULATED_ERROR_KEY);
if (error != null) {
verifyIsTestMode();
application.putUserData(SIMULATED_ERROR_KEY, null);
throw error;
}
}
Aggregations