Java Code Examples for com.intellij.util.ObjectUtil#chooseNotNull()

The following examples show how to use com.intellij.util.ObjectUtil#chooseNotNull() . 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: MessageDialogBuilder.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Messages.YesNoCancelResult
public int show() {
  String yesText = ObjectUtil.chooseNotNull(myYesText, Messages.YES_BUTTON);
  String noText = ObjectUtil.chooseNotNull(myNoText, Messages.NO_BUTTON);
  String cancelText = ObjectUtil.chooseNotNull(myCancelText, Messages.CANCEL_BUTTON);
  try {
    if (Messages.canShowMacSheetPanel() && !Messages.isApplicationInUnitTestOrHeadless()) {
      return MacMessages.getInstance().showYesNoCancelDialog(myTitle, myMessage, yesText, noText, cancelText, WindowManager.getInstance().suggestParentWindow(myProject), myDoNotAskOption);
    }
  }
  catch (Exception ignored) {}

  int buttonNumber = Messages.showDialog(myProject, myMessage, myTitle, new String[]{yesText, noText, cancelText}, 0, myIcon, myDoNotAskOption);
  return buttonNumber == 0 ? Messages.YES : buttonNumber == 1 ? Messages.NO : Messages.CANCEL;

}
 
Example 2
Source File: MessageDialogBuilder.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Messages.YesNoResult
public int show() {
  String yesText = ObjectUtil.chooseNotNull(myYesText, Messages.YES_BUTTON);
  String noText = ObjectUtil.chooseNotNull(myNoText, Messages.NO_BUTTON);
  try {
    if (Messages.canShowMacSheetPanel() && !Messages.isApplicationInUnitTestOrHeadless()) {
      return MacMessages.getInstance().showYesNoDialog(myTitle, myMessage, yesText, noText, WindowManager.getInstance().suggestParentWindow(myProject), myDoNotAskOption);
    }
  } catch (Exception ignored) {}

  return Messages.showDialog(myProject, myMessage, myTitle, new String[]{yesText, noText}, 0, myIcon, myDoNotAskOption) == 0 ? Messages.YES : Messages.NO;

}
 
Example 3
Source File: FileOrDirectoryDependencyTabContext.java    From consulo with Apache License 2.0 5 votes vote down vote up
public FileOrDirectoryDependencyTabContext(Disposable parent, ClasspathPanel panel, StructureConfigurableContext context) {
  super(panel, context);

  myLibraryTypes = new HashMap<LibraryRootsComponentDescriptor, LibraryType>();
  myDefaultDescriptor = new DefaultLibraryRootsComponentDescriptor();

  for (LibraryType<?> libraryType : LibraryEditingUtil.getSuitableTypes(myClasspathPanel)) {
    LibraryRootsComponentDescriptor descriptor = null;
    if (libraryType != null) {
      descriptor = libraryType.createLibraryRootsComponentDescriptor();
    }
    if (descriptor == null) {
      descriptor = myDefaultDescriptor;
    }
    if (!myLibraryTypes.containsKey(descriptor)) {
      myLibraryTypes.put(descriptor, libraryType);
    }
  }

  Module module = myClasspathPanel.getRootModel().getModule();

  myFileChooserDescriptor = createFileChooserDescriptor();
  myFileSystemTree = FileSystemTreeFactory.getInstance().createFileSystemTree(module.getProject(), myFileChooserDescriptor);
  Disposer.register(parent, myFileSystemTree);
  myFileSystemTree.showHiddens(true);
  final VirtualFile dirForSelect = ObjectUtil.chooseNotNull(module.getModuleDir(), module.getProject().getBaseDir());
  if(dirForSelect != null) {
    myFileSystemTree.select(dirForSelect, new Runnable() {
      @Override
      public void run() {
        myFileSystemTree.expand(dirForSelect, null);
      }
    });
  }
}
 
Example 4
Source File: VcsException.java    From consulo with Apache License 2.0 4 votes vote down vote up
@javax.annotation.Nullable
public static String getMessage(@javax.annotation.Nullable Throwable throwable) {
  return throwable != null ? ObjectUtil.chooseNotNull(throwable.getMessage(), throwable.getLocalizedMessage()) : null;
}
 
Example 5
Source File: ScratchRootType.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public Image substituteIcon(@Nonnull Project project, @Nonnull VirtualFile file) {
  Image icon = ObjectUtil.chooseNotNull(super.substituteIcon(project, file), AllIcons.FileTypes.Text);
  return ImageEffects.layered(icon, AllIcons.Actions.Scratch);
}