Java 类com.intellij.openapi.application.impl.ApplicationImpl 实例源码
项目:intellij-ce-playground
文件:EditorComponentImpl.java
public EditorComponentImpl(@NotNull EditorImpl editor) {
myEditor = editor;
enableEvents(AWTEvent.KEY_EVENT_MASK | AWTEvent.INPUT_METHOD_EVENT_MASK);
enableInputMethods(true);
setFocusCycleRoot(true);
setOpaque(true);
putClientProperty(Magnificator.CLIENT_PROPERTY_KEY, new Magnificator() {
@Override
public Point magnify(double scale, Point at) {
VisualPosition magnificationPosition = myEditor.xyToVisualPosition(at);
double currentSize = myEditor.getColorsScheme().getEditorFontSize();
int defaultFontSize = EditorColorsManager.getInstance().getGlobalScheme().getEditorFontSize();
myEditor.setFontSize(Math.max((int)(currentSize * scale), defaultFontSize));
return myEditor.visualPositionToXY(magnificationPosition);
}
});
myApplication = (ApplicationImpl)ApplicationManager.getApplication();
}
项目:tools-idea
文件:SchemesManagerImpl.java
public void exportScheme(final E scheme, final String name, final String description) throws WriteExternalException, IOException {
final StreamProvider[] providers = ((ApplicationImpl)ApplicationManager.getApplication()).getStateStore().getStateStorageManager()
.getStreamProviders(RoamingType.GLOBAL);
if (providers != null) {
Document document = myProcessor.writeScheme(scheme);
if (document != null) {
Document wrapped = wrap(document, name, description);
for (StreamProvider provider : providers) {
if (provider instanceof CurrentUserHolder) {
wrapped = (Document)wrapped.clone();
String userName = ((CurrentUserHolder)provider).getCurrentUserName();
if (userName != null) {
wrapped.getRootElement().setAttribute(USER, userName);
}
}
StorageUtil.sendContent(provider, getFileFullPath(UniqueFileNamesProvider.convertName(scheme.getName())) + mySchemeExtension,
wrapped, RoamingType.GLOBAL, false);
}
}
}
}
项目:tools-idea
文件:EditorComponentImpl.java
public EditorComponentImpl(@NotNull EditorImpl editor) {
myEditor = editor;
enableEvents(AWTEvent.KEY_EVENT_MASK | AWTEvent.INPUT_METHOD_EVENT_MASK);
enableInputMethods(true);
setFocusCycleRoot(true);
setOpaque(true);
putClientProperty(Magnificator.CLIENT_PROPERTY_KEY, new Magnificator() {
@Override
public Point magnify(double scale, Point at) {
VisualPosition magnificationPosition = myEditor.xyToVisualPosition(at);
double currentSize = myEditor.getColorsScheme().getEditorFontSize();
int defaultFontSize = EditorColorsManager.getInstance().getGlobalScheme().getEditorFontSize();
myEditor.setFontSize(Math.max((int)(currentSize * scale), defaultFontSize));
return myEditor.visualPositionToXY(magnificationPosition);
}
});
myApplication = (ApplicationImpl)ApplicationManager.getApplication();
}
项目:tools-idea
文件:IdeEventQueue.java
private static boolean processAppActivationEvents(AWTEvent e) {
Application app = ApplicationManager.getApplication();
if (!(app instanceof ApplicationImpl)) return false;
ApplicationImpl appImpl = (ApplicationImpl)app;
if (e instanceof WindowEvent) {
WindowEvent we = (WindowEvent)e;
if (we.getID() == WindowEvent.WINDOW_GAINED_FOCUS && we.getWindow() != null) {
if (we.getOppositeWindow() == null && !appImpl.isActive()) {
appImpl.tryToApplyActivationState(true, we.getWindow());
}
}
else if (we.getID() == WindowEvent.WINDOW_LOST_FOCUS && we.getWindow() != null) {
if (we.getOppositeWindow() == null && appImpl.isActive()) {
appImpl.tryToApplyActivationState(false, we.getWindow());
}
}
}
return false;
}
项目:consulo
文件:ProjectManagerImpl.java
private boolean tryToReloadApplication() {
if (ApplicationManager.getApplication().isDisposed()) {
return false;
}
if (myChangedApplicationFiles.isEmpty()) {
return true;
}
Set<StateStorage> causes = new THashSet<>(myChangedApplicationFiles);
myChangedApplicationFiles.clear();
ReloadComponentStoreStatus status = ComponentStoreImpl.reloadStore(causes, ((ApplicationImpl)ApplicationManager.getApplication()).getStateStore());
if (status == ReloadComponentStoreStatus.RESTART_AGREED) {
ApplicationManagerEx.getApplicationEx().restart(true);
return false;
}
else {
return status == ReloadComponentStoreStatus.SUCCESS || status == ReloadComponentStoreStatus.RESTART_CANCELLED;
}
}
项目:consulo
文件:LocalInspectionsPass.java
@Nonnull
private List<InspectionContext> visitPriorityElementsAndInit(@Nonnull Map<LocalInspectionToolWrapper, Set<String>> toolToSpecifiedLanguageIds,
@Nonnull final InspectionManager iManager,
final boolean isOnTheFly,
@Nonnull final ProgressIndicator indicator,
@Nonnull final List<PsiElement> elements,
@Nonnull final LocalInspectionToolSession session,
@Nonnull List<LocalInspectionToolWrapper> wrappers,
@Nonnull final Set<String> elementDialectIds) {
final List<InspectionContext> init = new ArrayList<>();
List<Map.Entry<LocalInspectionToolWrapper, Set<String>>> entries = new ArrayList<>(toolToSpecifiedLanguageIds.entrySet());
Processor<Map.Entry<LocalInspectionToolWrapper, Set<String>>> processor = pair -> {
LocalInspectionToolWrapper toolWrapper = pair.getKey();
Set<String> dialectIdsSpecifiedForTool = pair.getValue();
((ApplicationImpl)ApplicationManager.getApplication()).executeByImpatientReader(
() -> runToolOnElements(toolWrapper, dialectIdsSpecifiedForTool, iManager, isOnTheFly, indicator, elements, session, init, elementDialectIds));
return true;
};
boolean result = JobLauncher.getInstance().invokeConcurrentlyUnderProgress(entries, indicator, myFailFastOnAcquireReadAction, processor);
if (!result) throw new ProcessCanceledException();
return init;
}
项目:intellij-ce-playground
文件:PlatformUltraLiteTestFixture.java
public void setUp() {
final Application application = ApplicationManager.getApplication();
if (application == null) {
ApplicationImpl testapp = new ApplicationImpl(false, true, true, true, "testapp", null);
ApplicationManager.setApplication(testapp, myAppDisposable);
}
}
项目:intellij-ce-playground
文件:ApplicationManagerEx.java
/**
* @param appName used to load default configs; if you are not sure, use {@link #IDEA_APPLICATION}.
*/
public static void createApplication(boolean internal,
boolean isUnitTestMode,
boolean isHeadlessMode,
boolean isCommandline,
@NotNull @NonNls String appName,
@Nullable Splash splash) {
new ApplicationImpl(internal, isUnitTestMode, isHeadlessMode, isCommandline, appName, splash);
}
项目:intellij-ce-playground
文件:EditorMarkupModelImpl.java
@Override
protected void doPaintTrack(@NotNull Graphics g, @NotNull JComponent c, @NotNull Rectangle bounds) {
if (isMacScrollbarHiddenAndXcodeLikeScrollbar()) {
paintTrackBasement(g, bounds);
return;
}
Rectangle clip = g.getClipBounds().intersection(bounds);
if (clip.height == 0) return;
Rectangle componentBounds = c.getBounds();
ProperTextRange docRange = ProperTextRange.create(0, componentBounds.height);
if (myCachedTrack == null || myCachedHeight != componentBounds.height) {
myCachedTrack = UIUtil.createImage(componentBounds.width, componentBounds.height, BufferedImage.TYPE_INT_ARGB);
myCachedHeight = componentBounds.height;
myDirtyYPositions = docRange;
paintTrackBasement(myCachedTrack.getGraphics(), new Rectangle(0, 0, componentBounds.width, componentBounds.height));
}
if (myDirtyYPositions == WHOLE_DOCUMENT) {
myDirtyYPositions = docRange;
}
if (myDirtyYPositions != null) {
final Graphics2D imageGraphics = myCachedTrack.createGraphics();
((ApplicationImpl)ApplicationManager.getApplication()).editorPaintStart();
try {
myDirtyYPositions = myDirtyYPositions.intersection(docRange);
if (myDirtyYPositions == null) myDirtyYPositions = docRange;
repaint(imageGraphics, componentBounds.width, myDirtyYPositions);
myDirtyYPositions = null;
}
finally {
((ApplicationImpl)ApplicationManager.getApplication()).editorPaintFinish();
}
}
UIUtil.drawImage(g, myCachedTrack, null, 0, 0);
}
项目:intellij-ce-playground
文件:IdeaLogger.java
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);
}
}
}
}
项目:intellij-ce-playground
文件:ApplicationActivationStateManager.java
public static void updateState(Window window) {
final Application application = ApplicationManager.getApplication();
if (!(application instanceof ApplicationImpl)) return;
if (state.isInactive() && window != null) {
setActive(application, window);
}
}
项目:intellij-ce-playground
文件:ApplicationImplTest.java
private static void runReadWrites(final int readIterations, final int writeIterations, int expectedMs) {
final ApplicationImpl application = (ApplicationImpl)ApplicationManager.getApplication();
Disposable disposable = Disposer.newDisposable();
application.disableEventsUntil(disposable);
try {
final int numOfThreads = JobSchedulerImpl.CORES_COUNT;
PlatformTestUtil.startPerformanceTest("lock performance", expectedMs, () -> {
final CountDownLatch reads = new CountDownLatch(numOfThreads);
for (int i = 0; i < numOfThreads; i++) {
final String name = "stress thread " + i;
new Thread(() -> {
System.out.println(name);
for (int i1 = 0; i1 < readIterations; i1++) {
application.runReadAction(() -> {
});
}
reads.countDown();
}, name).start();
}
if (writeIterations > 0) {
System.out.println("write start");
for (int i = 0; i < writeIterations; i++) {
ApplicationManager.getApplication().runWriteAction(() -> {
});
}
System.out.println("write end");
}
reads.await();
}).cpuBound().assertTiming();
}
finally {
Disposer.dispose(disposable);
}
}
项目:intellij-ce-playground
文件:TrailingSpacesStripperTest.java
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);
}
}
项目:material-theme-jetbrains
文件:MTUiUtils.java
/**
* Restart the IDE :-)
*/
public static void restartIde() {
final Application application = ApplicationManager.getApplication();
if (application instanceof ApplicationImpl) {
((ApplicationImpl) application).restart(true);
} else {
application.restart();
}
}
项目:tools-idea
文件:CacheUpdateRunner.java
private static Runnable getProcessWrapper(final Runnable process) {
// launching thread will hold read access for workers
return ApplicationManager.getApplication().isReadAccessAllowed() ? new Runnable() {
@Override
public void run() {
boolean old = ApplicationImpl.setExceptionalThreadWithReadAccessFlag(true);
try {
process.run();
}
finally {
ApplicationImpl.setExceptionalThreadWithReadAccessFlag(old);
}
}
} : process;
}
项目:tools-idea
文件:ApplicationManagerEx.java
public static void createApplication(boolean internal,
boolean isUnitTestMode,
boolean isHeadlessMode,
boolean isCommandline,
@NotNull @NonNls String appName,
@Nullable Splash splash) {
new ApplicationImpl(internal, isUnitTestMode, isHeadlessMode, isCommandline, appName, splash);
}
项目:tools-idea
文件:SchemesManagerImpl.java
@Nullable
private static Document loadGlobalScheme(final String schemePath) throws IOException {
final StreamProvider[] providers = ((ApplicationImpl)ApplicationManager.getApplication()).getStateStore().getStateStorageManager()
.getStreamProviders(RoamingType.GLOBAL);
for (StreamProvider provider : providers) {
if (provider.isEnabled()) {
Document document = StorageUtil.loadDocument(provider.loadContent(schemePath, RoamingType.GLOBAL));
if (document != null) return document;
}
}
return null;
}
项目:tools-idea
文件:SchemesManagerImpl.java
public boolean isImportAvailable() {
final StreamProvider[] providers = ((ApplicationImpl)ApplicationManager.getApplication()).getStateStore().getStateStorageManager()
.getStreamProviders(RoamingType.GLOBAL);
if (providers == null) return false;
for (StreamProvider provider : providers) {
if (provider.isEnabled()) return true;
}
return false;
}
项目:tools-idea
文件:EditorMarkupModelImpl.java
@Override
public void paint(Graphics g) {
((ApplicationImpl)ApplicationManager.getApplication()).editorPaintStart();
final Rectangle bounds = getBounds();
try {
if (UISettings.getInstance().PRESENTATION_MODE) {
g.setColor(getEditor().getColorsScheme().getDefaultBackground());
g.fillRect(0, 0, bounds.width, bounds.height);
if (myErrorStripeRenderer != null) {
myErrorStripeRenderer.paint(this, g, new Rectangle(2, 0, 10, 7));
}
} else {
g.setColor(ButtonlessScrollBarUI.getTrackBackground());
g.fillRect(0, 0, bounds.width, bounds.height);
g.setColor(ButtonlessScrollBarUI.getTrackBorderColor());
g.drawLine(0, 0, 0, bounds.height);
if (myErrorStripeRenderer != null) {
myErrorStripeRenderer.paint(this, g, new Rectangle(5, 2, ERROR_ICON_WIDTH, ERROR_ICON_HEIGHT));
}
}
}
finally {
((ApplicationImpl)ApplicationManager.getApplication()).editorPaintFinish();
}
}
项目:tools-idea
文件:EditorMarkupModelImpl.java
@Override
protected void paintTrack(Graphics g, JComponent c, Rectangle bounds) {
if (UISettings.getInstance().PRESENTATION_MODE) {
g.setColor(getEditor().getColorsScheme().getDefaultBackground());
g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);
return;
}
Rectangle clip = g.getClipBounds().intersection(bounds);
if (clip.height == 0) return;
Rectangle componentBounds = c.getBounds();
ProperTextRange docRange = ProperTextRange.create(0, (int)componentBounds.getHeight());
if (myCachedTrack == null || myCachedTrack.getHeight() != componentBounds.getHeight()) {
myCachedTrack = UIUtil.createImage(componentBounds.width, componentBounds.height, BufferedImage.TYPE_INT_ARGB);
myDirtyYPositions = docRange;
paintTrackBasement(myCachedTrack.getGraphics(), new Rectangle(0, 0, componentBounds.width, componentBounds.height));
}
if (myDirtyYPositions == WHOLE_DOCUMENT) {
myDirtyYPositions = docRange;
}
if (myDirtyYPositions != null) {
final Graphics2D imageGraphics = myCachedTrack.createGraphics();
((ApplicationImpl)ApplicationManager.getApplication()).editorPaintStart();
try {
myDirtyYPositions = myDirtyYPositions.intersection(docRange);
if (myDirtyYPositions == null) myDirtyYPositions = docRange;
repaint(imageGraphics, componentBounds.width, ERROR_ICON_WIDTH - 1, myDirtyYPositions);
myDirtyYPositions = null;
}
finally {
((ApplicationImpl)ApplicationManager.getApplication()).editorPaintFinish();
}
}
UIUtil.drawImage(g, myCachedTrack, null, 0, 0);
}
项目:tools-idea
文件:ApplicationStoreImpl.java
@SuppressWarnings({"UnusedDeclaration"})
public ApplicationStoreImpl(final ApplicationImpl application, PathMacroManager pathMacroManager) {
myApplication = application;
myStateStorageManager = new StateStorageManagerImpl(pathMacroManager.createTrackingSubstitutor(), ROOT_ELEMENT_NAME, application, application.getPicoContainer()) {
@Override
protected StorageData createStorageData(String storageSpec) {
return new FileBasedStorage.FileStorageData(ROOT_ELEMENT_NAME);
}
@Override
protected String getOldStorageSpec(Object component, final String componentName, final StateStorageOperation operation) {
final String fileName;
if (component instanceof NamedJDOMExternalizable) {
fileName = StoragePathMacros.APP_CONFIG + "/" + ((NamedJDOMExternalizable)component).getExternalFileName() + XML_EXTENSION;
}
else {
fileName = DEFAULT_STORAGE_SPEC;
}
return fileName;
}
@Override
protected String getVersionsFilePath() {
return PathManager.getConfigPath() + "/options/appComponentVersions.xml";
}
@Override
protected TrackingPathMacroSubstitutor getMacroSubstitutor(@NotNull final String fileSpec) {
if (fileSpec.equals(StoragePathMacros.APP_CONFIG + "/" + PathMacrosImpl.EXT_FILE_NAME + XML_EXTENSION)) return null;
return super.getMacroSubstitutor(fileSpec);
}
};
myDefaultsStateStorage = new DefaultsStateStorage(null);
}
项目:tools-idea
文件:IdeaLogger.java
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()) {
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);
}
}
}
}
项目:tools-idea
文件:StripTrailingSpacesTest.java
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);
}
}
项目:tools-idea
文件:CompoundShelfFileProcessor.java
public CompoundShelfFileProcessor(final String subdirName) {
mySubdirName = subdirName;
myServerStreamProviders = ((ApplicationImpl)ApplicationManager.getApplication()).getStateStore().getStateStorageManager().getStreamProviders(PER_USER);
FILE_SPEC = "$ROOT_CONFIG$/" + subdirName + "/";
myShelfPath = PathManager.getConfigPath() + File.separator + mySubdirName;
}
项目:consulo
文件:ActivityMonitorTest.java
public void testModalityState() {
assumeFalse("Test cannot be run in headless environment", GraphicsEnvironment.isHeadless());
assertTrue(ApplicationManager.getApplication() instanceof ApplicationImpl);
assertTrue(ApplicationManager.getApplication().isDispatchThread());
assertReady(null);
myMonitor.addActivity(new UiActivity("non_modal_1"), ModalityState.NON_MODAL);
assertBusy(null);
Dialog dialog = new Dialog(new Dialog((Window)null), "d", true);
LaterInvocator.enterModal(dialog);
try {
assertReady(null);
myMonitor.addActivity(new UiActivity("non_modal2"), ModalityState.NON_MODAL);
assertReady(null);
ModalityState m1 = ApplicationManager.getApplication().getModalityStateForComponent(dialog);
myMonitor.addActivity(new UiActivity("modal_1"), m1);
assertBusy(null);
Dialog popup = new Dialog(dialog, "popup", true);
LaterInvocator.enterModal(popup);
ModalityState m2 = ApplicationManager.getApplication().getModalityStateForComponent(popup);
LaterInvocator.leaveModal(popup);
assertTrue("m1: "+m1+"; m2:"+m2, m2.dominates(m1));
myMonitor.addActivity(new UiActivity("modal_2"), m2);
assertBusy(null);
}
finally {
LaterInvocator.leaveModal(dialog);
}
assertBusy(null);
}
项目:consulo
文件:ApplierCompleter.java
@Override
public void compute() {
if (failFastOnAcquireReadAction) {
((ApplicationImpl)ApplicationManager.getApplication()).executeByImpatientReader(()-> wrapInReadActionAndIndicator(this::execAndForkSubTasks));
}
else {
wrapInReadActionAndIndicator(this::execAndForkSubTasks);
}
}
项目:consulo
文件:DumbServiceImpl.java
private void showModalProgress() {
NoAccessDuringPsiEvents.checkCallContext();
try {
((ApplicationImpl)ApplicationManager.getApplication()).executeSuspendingWriteAction(myProject, IdeBundle.message("progress.indexing"), () ->
runBackgroundProcess(ProgressManager.getInstance().getProgressIndicator()));
}
finally {
if (myState.get() != State.SMART) {
assertWeAreWaitingToFinish();
updateFinished();
}
}
}
项目:consulo
文件:EditorMarkupModelImpl.java
@Override
protected void paintComponent(Graphics g) {
Rectangle componentBounds = getBounds();
ProperTextRange docRange = ProperTextRange.create(0, componentBounds.height);
if (myCachedTrack == null || myCachedHeight != componentBounds.height) {
myCachedTrack = UIUtil.createImage(componentBounds.width, componentBounds.height, BufferedImage.TYPE_INT_ARGB);
myCachedHeight = componentBounds.height;
myDirtyYPositions = docRange;
paintBackground(myCachedTrack.getGraphics(), new Rectangle(0, 0, componentBounds.width, componentBounds.height));
}
if (myDirtyYPositions == WHOLE_DOCUMENT) {
myDirtyYPositions = docRange;
}
if (myDirtyYPositions != null) {
final Graphics2D imageGraphics = myCachedTrack.createGraphics();
((ApplicationImpl)ApplicationManager.getApplication()).editorPaintStart();
try {
myDirtyYPositions = myDirtyYPositions.intersection(docRange);
if (myDirtyYPositions == null) myDirtyYPositions = docRange;
repaint(imageGraphics, componentBounds.width, myDirtyYPositions);
myDirtyYPositions = null;
}
finally {
((ApplicationImpl)ApplicationManager.getApplication()).editorPaintFinish();
}
}
UIUtil.drawImage(g, myCachedTrack, null, 0, 0);
if (myErrorStripeRenderer != null) {
myErrorStripeRenderer.paint(this, g, new Point(JBUI.scale(1), 0));
}
}
项目:consulo
文件:IdeaLogger.java
private void logErrorHeader() {
final String info = ourApplicationInfoProvider.getInfo();
if (info != null) {
myLogger.error(info);
}
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()) {
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);
}
}
}
}
项目:consulo
文件:ApplicationActivationStateManager.java
public static void updateState(Window window) {
final Application application = ApplicationManager.getApplication();
if (!(application instanceof ApplicationImpl)) return;
if (state.isInactive() && window != null) {
setActive(application, window);
}
}
项目:consulo
文件:DesktopApplicationPostStarter.java
@Override
public void createApplication(boolean isHeadlessMode, CommandLineArgs args) {
if (!args.isNoSplash()) {
final SplashScreen splashScreen = getSplashScreen();
if (splashScreen == null) {
DesktopSplash splash = new DesktopSplash(false);
mySplashRef.set(splash);
splash.show();
}
}
new ApplicationImpl(isHeadlessMode, mySplashRef);
}
项目:intellij-ce-playground
文件:EditorGutterComponentImpl.java
@Override
public void paint(Graphics g_) {
((ApplicationImpl)ApplicationManager.getApplication()).editorPaintStart();
try {
Rectangle clip = g_.getClipBounds();
if (clip.height < 0) return;
Graphics2D g = IdeBackgroundUtil.withEditorBackground(g_, this);
AffineTransform old = g.getTransform();
if (isMirrored()) {
final AffineTransform transform = new AffineTransform(old);
transform.scale(-1, 1);
transform.translate(-getWidth(), 0);
g.setTransform(transform);
}
EditorUIUtil.setupAntialiasing(g);
Color backgroundColor = getBackground();
// paint all backgrounds
int gutterSeparatorX = getWhitespaceSeparatorOffset();
paintBackground(g, clip, 0, gutterSeparatorX, backgroundColor);
paintBackground(g, clip, gutterSeparatorX, getFoldingAreaWidth(), myEditor.getBackgroundColor());
int firstVisibleOffset = myEditor.logicalPositionToOffset(myEditor.xyToLogicalPosition(new Point(0, clip.y - myEditor.getLineHeight())));
int lastVisibleOffset = myEditor.logicalPositionToOffset(myEditor.xyToLogicalPosition(new Point(0, clip.y + clip.height + myEditor.getLineHeight())));
paintEditorBackgrounds(g, firstVisibleOffset, lastVisibleOffset);
Object hint = g.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
if (!UIUtil.isRetina()) g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
try {
paintAnnotations(g, clip);
paintLineMarkers(g, firstVisibleOffset, lastVisibleOffset);
paintFoldingLines(g, clip);
paintFoldingTree(g, clip, firstVisibleOffset, lastVisibleOffset);
paintLineNumbers(g, clip);
}
finally {
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, hint);
}
g.setTransform(old);
}
finally {
((ApplicationImpl)ApplicationManager.getApplication()).editorPaintFinish();
}
}
项目:intellij-ce-playground
文件:InitialConfigurationDialog.java
@Override
protected void doOKAction() {
final 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...");
CreateLauncherScriptAction.createLauncherScript(project, pathName);
indicator.setFraction(0.5);
}
if (createEntry) {
CreateDesktopEntryAction.createDesktopEntry(project, indicator, globalEntry);
}
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);
int rc = Messages.showYesNoDialog(project, "IDE appearance settings will be applied after restart. Would you like to restart now?",
"IDE Appearance", Messages.getQuestionIcon());
if (rc == Messages.YES) {
((ApplicationImpl) ApplicationManager.getApplication()).restart(true);
}
}
else if (!info.equals(lafManager.getCurrentLookAndFeel())) {
lafManager.setCurrentLookAndFeel(info);
lafManager.updateUI();
}
}
项目:tools-idea
文件:SchemesManagerImpl.java
@NotNull
public Collection<SharedScheme<E>> loadSharedSchemes(Collection<T> currentSchemeList) {
Collection<String> names = new HashSet<String>(getAllSchemeNames(currentSchemeList));
final StreamProvider[] providers = ((ApplicationImpl)ApplicationManager.getApplication()).getStateStore().getStateStorageManager()
.getStreamProviders(RoamingType.GLOBAL);
final HashMap<String, SharedScheme<E>> result = new HashMap<String, SharedScheme<E>>();
if (providers != null) {
for (StreamProvider provider : providers) {
if (provider.isEnabled()) {
String[] paths = provider.listSubFiles(myFileSpec);
for (String subpath : paths) {
try {
final Document subDocument = StorageUtil.loadDocument(provider.loadContent(getFileFullPath(subpath), RoamingType.GLOBAL));
if (subDocument != null) {
SharedSchemeData original = unwrap(subDocument);
final E scheme = myProcessor.readScheme(original.original);
if (!alreadyShared(subpath, currentSchemeList)) {
String schemeName = original.name;
String uniqueName = UniqueNameGenerator.generateUniqueName("[shared] " + schemeName, names);
renameScheme(scheme, uniqueName);
schemeName = uniqueName;
scheme.getExternalInfo().setOriginalPath(getFileFullPath(subpath));
scheme.getExternalInfo().setIsImported(true);
result.put(schemeName,
new SharedScheme<E>(original.user == null ? "unknown" : original.user, original.description, scheme));
}
}
}
catch (Exception e) {
LOG.debug("Cannot load data from IDEAServer: " + e.getLocalizedMessage());
}
}
}
}
}
for (SharedScheme<E> t : result.values()) {
myProcessor.initScheme(t.getScheme());
}
return result.values();
}
项目:tools-idea
文件:InitialConfigurationDialog.java
@Override
protected void doOKAction() {
final Project project = PlatformDataKeys.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...");
CreateLauncherScriptAction.createLauncherScript(project, pathName);
indicator.setFraction(0.5);
}
if (createEntry) {
CreateDesktopEntryAction.createDesktopEntry(project, indicator, globalEntry);
}
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);
int rc = Messages.showYesNoDialog(project, "IDE appearance settings will be applied after restart. Would you like to restart now?",
"IDE Appearance", Messages.getQuestionIcon());
if (rc == Messages.YES) {
((ApplicationImpl) ApplicationManager.getApplication()).restart(true);
}
}
else if (!info.equals(lafManager.getCurrentLookAndFeel())) {
lafManager.setCurrentLookAndFeel(info);
lafManager.updateUI();
}
}
项目:consulo
文件:UnitTestPostStarter.java
@Override
public void createApplication(boolean isHeadlessMode, CommandLineArgs args) {
new ApplicationImpl(isHeadlessMode, mySplashRef);
}
项目:consulo
文件:EditorGutterComponentImpl.java
@Override
public void paint(Graphics g_) {
((ApplicationImpl)ApplicationManager.getApplication()).editorPaintStart();
try {
Rectangle clip = g_.getClipBounds();
if (clip.height < 0) return;
Graphics2D g = (Graphics2D)getComponentGraphics(g_);
AffineTransform old = setMirrorTransformIfNeeded(g, 0, getWidth());
EditorUIUtil.setupAntialiasing(g);
Color backgroundColor = getBackground();
if (myEditor.isDisposed()) {
g.setColor(myEditor.getDisposedBackground());
g.fillRect(clip.x, clip.y, clip.width, clip.height);
return;
}
int startVisualLine = myEditor.yToVisibleLine(clip.y);
int endVisualLine = myEditor.yToVisibleLine(clip.y + clip.height);
// paint all backgrounds
int gutterSeparatorX = getWhitespaceSeparatorOffset();
paintBackground(g, clip, 0, gutterSeparatorX, backgroundColor);
paintBackground(g, clip, gutterSeparatorX, getFoldingAreaWidth(), myEditor.getBackgroundColor());
int firstVisibleOffset = myEditor.visualLineStartOffset(startVisualLine);
int lastVisibleOffset = myEditor.visualLineStartOffset(endVisualLine + 1);
paintEditorBackgrounds(g, firstVisibleOffset, lastVisibleOffset);
Object hint = g.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
if (!UIUtil.isJreHiDPI(g)) g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
try {
paintAnnotations(g, startVisualLine, endVisualLine);
paintLineMarkers(g, firstVisibleOffset, lastVisibleOffset);
paintFoldingLines(g, clip);
paintFoldingTree(g, clip, firstVisibleOffset, lastVisibleOffset);
paintLineNumbers(g, startVisualLine, endVisualLine);
}
finally {
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, hint);
}
if (old != null) g.setTransform(old);
}
finally {
((ApplicationImpl)ApplicationManager.getApplication()).editorPaintFinish();
}
}
项目:consulo
文件:ExportSettingsAction.java
@Nonnull
public static MultiMap<File, ExportableItem> getExportableComponentsMap(final boolean onlyExisting) {
final MultiMap<File, ExportableItem> result = MultiMap.createLinkedSet();
ApplicationImpl application = (ApplicationImpl)ApplicationManager.getApplication();
final StateStorageManager storageManager = application.getStateStore().getStateStorageManager();
ServiceManagerImpl.processAllImplementationClasses(application, (aClass, pluginDescriptor) -> {
State stateAnnotation = aClass.getAnnotation(State.class);
if (stateAnnotation != null && !StringUtil.isEmpty(stateAnnotation.name())) {
int storageIndex;
Storage[] storages = stateAnnotation.storages();
if (storages.length == 1) {
storageIndex = 0;
}
else if (storages.length > 1) {
storageIndex = storages.length - 1;
}
else {
return true;
}
Storage storage = storages[storageIndex];
if (storage.roamingType() != RoamingType.DISABLED) {
String fileSpec = storageManager.buildFileSpec(storage);
if (!fileSpec.startsWith(StoragePathMacros.APP_CONFIG)) {
return true;
}
File file = new File(storageManager.expandMacros(fileSpec));
File additionalExportFile = null;
if (!StringUtil.isEmpty(stateAnnotation.additionalExportFile())) {
additionalExportFile = new File(storageManager.expandMacros(stateAnnotation.additionalExportFile()));
if (onlyExisting && !additionalExportFile.exists()) {
additionalExportFile = null;
}
}
boolean fileExists = !onlyExisting || file.exists();
if (fileExists || additionalExportFile != null) {
File[] files;
if (additionalExportFile == null) {
files = new File[]{file};
}
else {
files = fileExists ? new File[]{file, additionalExportFile} : new File[]{additionalExportFile};
}
ExportableItem item = new ExportableItem(files, getComponentPresentableName(stateAnnotation, aClass, pluginDescriptor));
result.putValue(file, item);
if (additionalExportFile != null) {
result.putValue(additionalExportFile, item);
}
}
}
}
return true;
});
return result;
}
项目:consulo
文件:BraceHighlightingHandler.java
static void lookForInjectedAndMatchBracesInOtherThread(@Nonnull final Editor editor,
@Nonnull final Alarm alarm,
@Nonnull final Processor<BraceHighlightingHandler> processor) {
ApplicationManagerEx.getApplicationEx().assertIsDispatchThread();
if (!isValidEditor(editor)) return;
if (!PROCESSED_EDITORS.add(editor)) {
// Skip processing if that is not really necessary.
// Assuming to be in EDT here.
return;
}
final int offset = editor.getCaretModel().getOffset();
// any request to the UI component need to be done from EDT
final ModalityState modalityState = ModalityState.stateForComponent(editor.getComponent());
final DumbAwareRunnable removeEditorFromProcessed = () -> PROCESSED_EDITORS.remove(editor);
ApplicationManager.getApplication().executeOnPooledThread(() -> {
if (!ApplicationManagerEx.getApplicationEx().tryRunReadAction(() ->
{
try {
((ApplicationImpl)ApplicationManager.getApplication()).executeByImpatientReader(()->{
if (!ProgressIndicatorUtils.runInReadActionWithWriteActionPriority(()->{
if (!isValidEditor(editor)) {
removeFromProcessedLater(editor);
return;
}
@SuppressWarnings("ConstantConditions") // the `project` is valid after the `isValidEditor` call
@Nonnull final Project project = editor.getProject();
final PsiFile psiFile = PsiUtilBase.getPsiFileInEditor(editor, project);
PsiFile injected = psiFile instanceof PsiBinaryFile || !isValidFile(psiFile)
? null
: getInjectedFileIfAny(editor, project, offset, psiFile, alarm);
ApplicationManager.getApplication().invokeLater((DumbAwareRunnable)() -> {
try {
if (isValidEditor(editor) && isValidFile(injected)) {
Editor newEditor = InjectedLanguageUtil.getInjectedEditorForInjectedFile(editor, injected);
BraceHighlightingHandler handler = new BraceHighlightingHandler(project, newEditor, alarm, injected);
processor.process(handler);
}
}
finally {
removeEditorFromProcessed.run();
}
}, modalityState);
})) {
removeFromProcessedLater(editor);
}}
);
}
catch(Exception e) {
// Reset processing flag in case of unexpected exception.
removeFromProcessedLater(editor);
throw e;
}
}
)) {
// write action is queued in AWT. restart after it's finished
ApplicationManager.getApplication().invokeLater(() -> {
removeEditorFromProcessed.run();
lookForInjectedAndMatchBracesInOtherThread(editor, alarm, processor);
}, modalityState);
}
});
}