use of com.intellij.openapi.application.impl.ApplicationImpl in project intellij-community by JetBrains.
the class InitialConfigurationDialog method doOKAction.
@Override
protected void doOKAction() {
Project project = CommonDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(myMainPanel));
super.doOKAction();
// set keymap
((KeymapManagerImpl) KeymapManager.getInstance()).setActiveKeymap((Keymap) myKeymapComboBox.getSelectedItem());
// set color scheme
EditorColorsManager.getInstance().setGlobalScheme((EditorColorsScheme) myColorSchemeComboBox.getSelectedItem());
// create default todo_pattern for color scheme
TodoConfiguration.getInstance().resetToDefaultTodoPatterns();
final boolean createScript = myCreateScriptCheckbox.isSelected();
final boolean createEntry = myCreateEntryCheckBox.isSelected();
if (createScript || createEntry) {
final String pathName = myScriptPathTextField.getText();
final boolean globalEntry = myGlobalEntryCheckBox.isSelected();
ProgressManager.getInstance().run(new Task.Backgroundable(project, getTitle()) {
@Override
public void run(@NotNull final ProgressIndicator indicator) {
indicator.setFraction(0.0);
if (createScript) {
indicator.setText("Creating launcher script...");
try {
CreateLauncherScriptAction.createLauncherScript(pathName);
} catch (Exception e) {
CreateLauncherScriptAction.reportFailure(e, getProject());
}
}
indicator.setFraction(0.5);
if (createEntry) {
indicator.setText("Creating desktop entry...");
try {
CreateDesktopEntryAction.createDesktopEntry(globalEntry);
} catch (Exception e) {
CreateDesktopEntryAction.reportFailure(e, getProject());
}
}
indicator.setFraction(1.0);
}
});
}
UIManager.LookAndFeelInfo info = (UIManager.LookAndFeelInfo) myAppearanceComboBox.getSelectedItem();
LafManagerImpl lafManager = (LafManagerImpl) LafManager.getInstance();
if (info.getName().contains("Darcula") != (LafManager.getInstance().getCurrentLookAndFeel() instanceof DarculaLookAndFeelInfo)) {
lafManager.setLookAndFeelAfterRestart(info);
String message = "IDE appearance settings will be applied after restart. Would you like to restart now?";
int rc = Messages.showYesNoDialog(project, message, "IDE Appearance", Messages.getQuestionIcon());
if (rc == Messages.YES) {
((ApplicationImpl) ApplicationManager.getApplication()).restart(true);
}
} else if (!info.equals(lafManager.getCurrentLookAndFeel())) {
lafManager.setCurrentLookAndFeel(info);
lafManager.updateUI();
}
}
use of com.intellij.openapi.application.impl.ApplicationImpl in project intellij-community by JetBrains.
the class ApplicationActivationStateManager method updateState.
public static boolean updateState(final WindowEvent windowEvent) {
final Application application = ApplicationManager.getApplication();
if (!(application instanceof ApplicationImpl))
return false;
final Window eventWindow = windowEvent.getWindow();
if (windowEvent.getID() == WindowEvent.WINDOW_ACTIVATED || windowEvent.getID() == WindowEvent.WINDOW_GAINED_FOCUS) {
if (state.isInactive()) {
Window window = windowEvent.getWindow();
return setActive(application, window);
}
} else if (windowEvent.getID() == WindowEvent.WINDOW_DEACTIVATED && windowEvent.getOppositeWindow() == null) {
requestToDeactivateTime.getAndSet(System.currentTimeMillis());
// For stuff that cannot wait windowEvent notify about deactivation immediately
if (state.isActive()) {
IdeFrame ideFrame = getIdeFrameFromWindow(windowEvent.getWindow());
if (ideFrame != null) {
application.getMessageBus().syncPublisher(ApplicationActivationListener.TOPIC).applicationDeactivated(ideFrame);
}
}
// We do not know for sure that application is going to be inactive,
// windowEvent could just be showing a popup or another transient window.
// So let's postpone the application deactivation for a while
state = State.DEACTIVATING;
LOG.debug("The app is in the deactivating state");
Timer timer = UIUtil.createNamedTimer("ApplicationDeactivation", Registry.intValue("application.deactivation.timeout"), new ActionListener() {
public void actionPerformed(ActionEvent evt) {
if (state.equals(State.DEACTIVATING)) {
state = State.DEACTIVATED;
LOG.debug("The app is in the deactivated state");
IdeFrame ideFrame = getIdeFrameFromWindow(windowEvent.getWindow());
if (ideFrame != null) {
application.getMessageBus().syncPublisher(ApplicationActivationListener.TOPIC).delayedApplicationDeactivated(ideFrame);
}
}
}
});
timer.setRepeats(false);
timer.start();
return true;
}
return false;
}
use of com.intellij.openapi.application.impl.ApplicationImpl in project intellij-community by JetBrains.
the class IdeaLogger method logErrorHeader.
private void logErrorHeader() {
final String info = ourApplicationInfoProvider.getInfo();
if (info != null) {
myLogger.error(info);
}
if (ourCompilationTimestamp != null) {
myLogger.error("Internal version. Compiled " + ourCompilationTimestamp);
}
myLogger.error("JDK: " + System.getProperties().getProperty("java.version", "unknown"));
myLogger.error("VM: " + System.getProperties().getProperty("java.vm.name", "unknown"));
myLogger.error("Vendor: " + System.getProperties().getProperty("java.vendor", "unknown"));
myLogger.error("OS: " + System.getProperties().getProperty("os.name", "unknown"));
ApplicationImpl application = (ApplicationImpl) ApplicationManager.getApplication();
if (application != null && application.isComponentsCreated() && !application.isDisposed()) {
final String lastPreformedActionId = ourLastActionId;
if (lastPreformedActionId != null) {
myLogger.error("Last Action: " + lastPreformedActionId);
}
CommandProcessor commandProcessor = CommandProcessor.getInstance();
if (commandProcessor != null) {
final String currentCommandName = commandProcessor.getCurrentCommandName();
if (currentCommandName != null) {
myLogger.error("Current Command: " + currentCommandName);
}
}
}
}
use of com.intellij.openapi.application.impl.ApplicationImpl in project intellij-community by JetBrains.
the class EditorColorsManagerImpl method setGlobalScheme.
@Override
public void setGlobalScheme(@Nullable EditorColorsScheme scheme) {
Application application = ApplicationManager.getApplication();
boolean notify = (application instanceof ApplicationImpl && ((ApplicationImpl) application).isLoaded());
mySchemeManager.setCurrent(scheme == null ? getDefaultScheme() : scheme, notify);
}
use of com.intellij.openapi.application.impl.ApplicationImpl in project intellij-community by JetBrains.
the class TrailingSpacesStripperTest method testModifyLineAndExitApplication_ShouldStripEvenWhenCaretIsAtTheChangedLine.
public void testModifyLineAndExitApplication_ShouldStripEvenWhenCaretIsAtTheChangedLine() throws IOException {
configureFromFileText("x.txt", "xxx <caret>\n");
type(' ');
ApplicationImpl application = (ApplicationImpl) ApplicationManager.getApplication();
application.setDisposeInProgress(true);
try {
FileDocumentManager.getInstance().saveAllDocuments();
checkResultByText("xxx<caret>\n");
} finally {
application.setDisposeInProgress(false);
}
}
Aggregations