com.intellij.openapi.project.DefaultProjectFactory Java Examples

The following examples show how to use com.intellij.openapi.project.DefaultProjectFactory. 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: SimpleCheckoutStarter.java    From azure-devops-intellij with MIT License 5 votes vote down vote up
/**
 * Kicks off the SimpleCheckout workflow with the Git Url passed
 */
public void processCommand() {
    final Project project = DefaultProjectFactory.getInstance().getDefaultProject();
    final CheckoutProvider.Listener listener = ProjectLevelVcsManager.getInstance(project).getCompositeCheckoutListener();

    try {
        final SimpleCheckoutController controller = new SimpleCheckoutController(project, listener, gitUrl, ref);
        controller.showModalDialog();
    } catch (Throwable t) {
        //unexpected error occurred while doing simple checkout
        logger.warn("Azure DevOps commandline checkout failed due to an unexpected error", t);
        VcsNotifier.getInstance(project).notifyError(TfPluginBundle.message(TfPluginBundle.KEY_CHECKOUT_DIALOG_TITLE),
                TfPluginBundle.message(TfPluginBundle.KEY_CHECKOUT_ERRORS_UNEXPECTED, t.getMessage()));
    }
}
 
Example #2
Source File: HXMLData.java    From intellij-haxe with Apache License 2.0 5 votes vote down vote up
static private FileASTNode getRootNode(Project project, String hxmlPath) throws HXMLDataException {
  VirtualFile path = LocalFileSystem.getInstance().findFileByPath(hxmlPath);
  if(path == null) {
    throw new HXMLDataException(new FileNotFoundException(hxmlPath));
  }
  if(project == null) {
    project = DefaultProjectFactory.getInstance().getDefaultProject();
  }
  PsiFile file = PsiManager.getInstance(project).findFile(path);
  if(file == null) {
    throw new HXMLDataException("PsiFile not available for " + hxmlPath);
  }
  return file.getNode();
}
 
Example #3
Source File: LightPlatformTestCase.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static PsiDocumentManagerImpl clearUncommittedDocuments(@Nonnull Project project) {
  PsiDocumentManagerImpl documentManager = (PsiDocumentManagerImpl)PsiDocumentManager.getInstance(project);
  documentManager.clearUncommittedDocuments();

  ProjectManagerImpl projectManager = (ProjectManagerImpl)ProjectManager.getInstance();
  if (((DefaultProjectFactoryImpl)DefaultProjectFactory.getInstance()).isDefaultProjectInitialized()) {
    Project defaultProject = projectManager.getDefaultProject();
    ((PsiDocumentManagerImpl)PsiDocumentManager.getInstance(defaultProject)).clearUncommittedDocuments();
  }
  return documentManager;
}
 
Example #4
Source File: ThreadTracker.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void checkLeak() throws AssertionError {
  try {
    if (myDefaultProjectInitialized != ((DefaultProjectFactoryImpl)DefaultProjectFactory.getInstance()).isDefaultProjectInitialized()) return;

    Collection<Thread> after = new THashSet<Thread>(getThreads());
    after.removeAll(before);

    for (Thread thread : after) {
      if (thread == Thread.currentThread()) continue;
      ThreadGroup group = thread.getThreadGroup();
      if (group != null && "system".equals(group.getName()))continue;
      String name = thread.getName();
      if (name.startsWith("AWT-EventQueue-0")) continue;
      if (name.startsWith("JobScheduler pool ")) continue;
      if (wellKnownOffenders.contains(name)) continue;

      String trace = "Thread leaked: " + thread+": "+ name +";\n ";
      for (final StackTraceElement stackTraceElement : thread.getStackTrace()) {
        trace += " at "+stackTraceElement +"\n";
      }
      Assert.fail(trace);
    }
  }
  finally {
    before.clear();
  }
}
 
Example #5
Source File: FileContentImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@RequiredReadAction
public PsiFile createFileFromText(@Nonnull CharSequence text) {
  Project project = getProject();
  if (project == null) {
    project = DefaultProjectFactory.getInstance().getDefaultProject();
  }
  FileType fileType = getFileTypeWithoutSubstitution();
  if (!(fileType instanceof LanguageFileType)) {
    throw new AssertionError("PSI can be created only for a file with LanguageFileType but actual is " + fileType.getClass() + "." +
                             "\nPlease use a proper FileBasedIndexExtension#getInputFilter() implementation for the caller index");
  }
  return createFileFromText(project, text, (LanguageFileType)fileType, myFile, myFileName);
}
 
Example #6
Source File: DirDiffViewer.java    From consulo with Apache License 2.0 4 votes vote down vote up
public DirDiffViewer(@Nonnull DiffContext context, @Nonnull ContentDiffRequest request) {
  myContext = context;
  myRequest = request;

  List<DiffContent> contents = request.getContents();
  DiffElement element1 = createDiffElement(contents.get(0));
  DiffElement element2 = createDiffElement(contents.get(1));

  Project project = context.getProject();
  if (project == null) project = DefaultProjectFactory.getInstance().getDefaultProject();

  DirDiffTableModel model = new DirDiffTableModel(project, element1, element2, new DirDiffSettings());

  myDirDiffPanel = new DirDiffPanel(model, new DirDiffWindow((DirDiffFrame)null) {
    @Override
    public Window getWindow() {
      return null;
    }

    @Override
    public Disposable getDisposable() {
      return DirDiffViewer.this;
    }

    @Override
    public void setTitle(String title) {
    }
  });

  myPanel = new JPanel(new BorderLayout());
  myPanel.add(myDirDiffPanel.getPanel(), BorderLayout.CENTER);
  DataManager.registerDataProvider(myPanel, new DataProvider() {
    @Override
    public Object getData(@Nonnull @NonNls Key dataId) {
      if (PlatformDataKeys.HELP_ID == dataId) {
        return "reference.dialogs.diff.folder";
      }
      return myDirDiffPanel.getData(dataId);
    }
  });
}
 
Example #7
Source File: ThreadTracker.java    From consulo with Apache License 2.0 4 votes vote down vote up
public ThreadTracker() {
  before = getThreads();
  myDefaultProjectInitialized = ((DefaultProjectFactoryImpl)DefaultProjectFactory.getInstance()).isDefaultProjectInitialized();
}
 
Example #8
Source File: EditorListenerTracker.java    From consulo with Apache License 2.0 4 votes vote down vote up
public EditorListenerTracker() {
  EncodingManager.getInstance(); //adds listeners
  EditorEventMulticasterImpl multicaster = (EditorEventMulticasterImpl)EditorFactory.getInstance().getEventMulticaster();
  before = multicaster.getListeners();
  myDefaultProjectInitialized = ((DefaultProjectFactoryImpl)DefaultProjectFactory.getInstance()).isDefaultProjectInitialized();
}
 
Example #9
Source File: WebShowSettingsUtil.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Inject
public WebShowSettingsUtil(DefaultProjectFactory defaultProjectFactory) {
  myDefaultProjectFactory = defaultProjectFactory;
}
 
Example #10
Source File: DesktopShowSettingsUtilImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Inject
DesktopShowSettingsUtilImpl(DefaultProjectFactory defaultProjectFactory, Provider<SdkTable> sdkTableProvider) {
  myDefaultProjectFactory = defaultProjectFactory;
  mySdksModel = new DefaultSdksModel(sdkTableProvider);
}