AppCode: workspaces support
[idea/community.git] / platform / platform-impl / src / com / intellij / openapi / application / ex / ApplicationEx.java
1 /*
2  * Copyright 2000-2009 JetBrains s.r.o.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.intellij.openapi.application.ex;
17
18 import com.intellij.openapi.application.Application;
19 import com.intellij.openapi.progress.Task;
20 import com.intellij.openapi.project.Project;
21 import com.intellij.openapi.util.InvalidDataException;
22 import org.jetbrains.annotations.NotNull;
23 import org.jetbrains.annotations.Nullable;
24
25 import javax.swing.*;
26 import java.io.IOException;
27
28 /**
29  * @author max
30  */
31 public interface ApplicationEx extends Application {
32   /**
33    * Loads the application configuration from the specified path
34    *
35    * @param optionsPath Path to /config folder
36    * @throws IOException
37    * @throws InvalidDataException
38    */
39   void load(String optionsPath) throws IOException, InvalidDataException;
40
41   boolean isInternal();
42
43   @NotNull
44   String getName();
45
46   boolean holdsReadLock();
47
48   void assertReadAccessToDocumentsAllowed();
49
50   void doNotSave();
51   void doNotSave(boolean value);
52   boolean isDoNotSave();
53
54   //force exit
55   void exit(boolean force);
56
57   /**
58    * Runs modal process. For internal use only, see {@link Task}
59    */
60   boolean runProcessWithProgressSynchronously(@NotNull Runnable process,
61                                               @NotNull String progressTitle,
62                                               boolean canBeCanceled,
63                                               Project project);
64
65   /**
66    * Runs modal process. For internal use only, see {@link Task}
67    */
68   boolean runProcessWithProgressSynchronously(@NotNull Runnable process,
69                                               @NotNull String progressTitle,
70                                               boolean canBeCanceled,
71                                               @Nullable Project project,
72                                               JComponent parentComponent);
73
74   /**
75    * Runs modal process. For internal use only, see {@link Task}
76    */
77   boolean runProcessWithProgressSynchronously(@NotNull Runnable process,
78                                               @NotNull String progressTitle,
79                                               boolean canBeCanceled,
80                                               @Nullable Project project,
81                                               JComponent parentComponent,
82                                               final String cancelText);
83
84   boolean isInModalProgressThread();
85
86   void assertIsDispatchThread(@Nullable JComponent component);
87
88   void assertTimeConsuming();
89
90   void runEdtSafeAction(@NotNull Runnable runnable);
91
92   /**
93    * Grab the lock and run the action, in a nonblocking fashion
94    *
95    * @return true if action was run while holding the lock, false if was unable to get the lock and action was not run
96    */
97   boolean tryRunReadAction(@NotNull Runnable action);
98 }