Java 类com.intellij.ui.UIBundle 实例源码

项目:intellij-ce-playground    文件:ComponentWithBrowseButton.java   
public ComponentWithBrowseButton(Comp component, @Nullable ActionListener browseActionListener) {
  super(new BorderLayout(SystemInfo.isMac ? 0 : 2, 0));

  myComponent = component;
  // required! otherwise JPanel will occasionally gain focus instead of the component
  setFocusable(false);
  add(myComponent, BorderLayout.CENTER);

  myBrowseButton = new FixedSizeButton(myComponent);
  if (browseActionListener != null) {
    myBrowseButton.addActionListener(browseActionListener);
  }
  // don't force FixedSizeButton to occupy the whole height
  add(wrapWithoutResize(myBrowseButton), BorderLayout.EAST);

  myBrowseButton.setToolTipText(UIBundle.message("component.with.browse.button.browse.button.tooltip.text"));

  // FixedSizeButton isn't focusable but it should be selectable via keyboard.
  if (ApplicationManager.getApplication() != null) {  // avoid crash at design time
    new MyDoClickAction(myBrowseButton).registerShortcut(myComponent);
  }
}
项目:intellij-ce-playground    文件:MemoryUsagePanel.java   
private void updateState() {
  if (!isShowing()) {
    return;
  }

  final Runtime runtime = Runtime.getRuntime();
  final long total = runtime.totalMemory() / MEGABYTE;
  final long used = total - runtime.freeMemory() / MEGABYTE;

  if (total != myLastTotal || used != myLastUsed) {
    myLastTotal = total;
    myLastUsed = used;
    //noinspection SSBasedInspection
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        myBufferedImage = null;
        repaint();
      }
    });

    setToolTipText(UIBundle.message("memory.usage.panel.statistics.message", total, used));
  }
}
项目:intellij-ce-playground    文件:ToolWindowsWidget.java   
@Override
public void addNotify() {
  super.addNotify();
  final String key = "toolwindow.stripes.buttons.info.shown";
  if (UISettings.getInstance().HIDE_TOOL_STRIPES && !PropertiesComponent.getInstance().isTrueValue(key)) {
    PropertiesComponent.getInstance().setValue(key, String.valueOf(true));
    final Alarm alarm = new Alarm();
    alarm.addRequest(new Runnable() {
      @Override
      public void run() {
        GotItMessage.createMessage(UIBundle.message("tool.window.quick.access.title"), UIBundle.message(
          "tool.window.quick.access.message"))
          .setDisposable(ToolWindowsWidget.this)
          .show(new RelativePoint(ToolWindowsWidget.this, new Point(10, 0)), Balloon.Position.above);
        Disposer.dispose(alarm);
      }
    }, 20000);
  }
}
项目:intellij-ce-playground    文件:ToggleReadOnlyAttributePanel.java   
public Consumer<MouseEvent> getClickConsumer() {
  return new Consumer<MouseEvent>() {
    public void consume(MouseEvent mouseEvent) {
      final VirtualFile file = getCurrentFile();
      if (!isReadOnlyApplicableForFile(file)) {
        return;
      }
      FileDocumentManager.getInstance().saveAllDocuments();

      ApplicationManager.getApplication().runWriteAction(new Runnable() {
        public void run() {
          try {
            ReadOnlyAttributeUtil.setReadOnlyAttribute(file, file.isWritable());
            myStatusBar.updateWidget(ID());
          }
          catch (IOException e) {
            Messages.showMessageDialog(getProject(), e.getMessage(), UIBundle.message("error.dialog.title"), Messages.getErrorIcon());
          }
        }
      });
    }
  };
}
项目:intellij-ce-playground    文件:PositionPanel.java   
public Consumer<MouseEvent> getClickConsumer() {
  return new Consumer<MouseEvent>() {
    public void consume(MouseEvent mouseEvent) {
      final Project project = getProject();
      if (project == null) return;
      final Editor editor = getEditor();
      if (editor == null) return;
      final CommandProcessor processor = CommandProcessor.getInstance();
      processor.executeCommand(
        project, new Runnable() {
          public void run() {
            final GotoLineNumberDialog dialog = new GotoLineNumberDialog(project, editor);
            dialog.show();
            IdeDocumentHistory.getInstance(project).includeCurrentCommandAsNavigation();
          }
        },
        UIBundle.message("go.to.line.command.name"),
        null
      );
    }
  };
}
项目:intellij-ce-playground    文件:FileSaverDialogImpl.java   
protected JComponent createFileNamePanel() {
  final JPanel panel = new JPanel(new BorderLayout());
  panel.add(new JLabel(UIBundle.message("file.chooser.save.dialog.file.name")), BorderLayout.WEST);
  myFileName.setText("");
  myFileName.getDocument().addDocumentListener(new DocumentAdapter() {
    @Override
    protected void textChanged(DocumentEvent e) {
      updateOkButton();
    }
  });

  panel.add(myFileName, BorderLayout.CENTER);
  if (myExtensions.getModel().getSize() > 0) {
    myExtensions.setSelectedIndex(0);
    panel.add(myExtensions, BorderLayout.EAST);
  }
  return panel;
}
项目:intellij-ce-playground    文件:NewFileAction.java   
private static void createNewFile(FileSystemTree fileSystemTree, final FileType fileType, final String initialContent) {
  final VirtualFile file = fileSystemTree.getNewFileParent();
  if (file == null || !file.isDirectory()) return;

  String newFileName;
  while (true) {
    newFileName = Messages.showInputDialog(UIBundle.message("create.new.file.enter.new.file.name.prompt.text"),
                                             UIBundle.message("new.file.dialog.title"), Messages.getQuestionIcon());
    if (newFileName == null) {
      return;
    }
    if ("".equals(newFileName.trim())) {
      Messages.showMessageDialog(UIBundle.message("create.new.file.file.name.cannot.be.empty.error.message"),
                                 UIBundle.message("error.dialog.title"), Messages.getErrorIcon());
      continue;
    }
    Exception failReason = ((FileSystemTreeImpl)fileSystemTree).createNewFile(file, newFileName, fileType, initialContent);
    if (failReason != null) {
      Messages.showMessageDialog(UIBundle.message("create.new.file.could.not.create.file.error.message", newFileName),
                                 UIBundle.message("error.dialog.title"), Messages.getErrorIcon());
      continue;
    }
    return;
  }
}
项目:intellij-ce-playground    文件:NewFolderAction.java   
private static void createNewFolder(FileSystemTree fileSystemTree) {
  final VirtualFile file = fileSystemTree.getNewFileParent();
  if (file == null || !file.isDirectory()) return;

  final InputValidatorEx validator = new NewFolderValidator(file);
  final String newFolderName = Messages.showInputDialog(UIBundle.message("create.new.folder.enter.new.folder.name.prompt.text"),
                                                        UIBundle.message("new.folder.dialog.title"), Messages.getQuestionIcon(),
                                                        "", validator);
  if (newFolderName == null) {
    return;
  }
  Exception failReason = ((FileSystemTreeImpl)fileSystemTree).createNewFolder(file, newFolderName);
  if (failReason != null) {
    Messages.showMessageDialog(UIBundle.message("create.new.folder.could.not.create.folder.error.message", newFolderName),
                               UIBundle.message("error.dialog.title"), Messages.getErrorIcon());
  }
}
项目:tools-idea    文件:ComponentWithBrowseButton.java   
public ComponentWithBrowseButton(Comp component, @Nullable ActionListener browseActionListener) {
  super(new BorderLayout(SystemInfo.isMac? 0 : 2, 0));
  myComponent = component;
  // required! otherwise JPanel will occasionally gain focus instead of the component
  setFocusable(false);
  add(myComponent, BorderLayout.CENTER);

  myBrowseButton=new FixedSizeButton(myComponent);
  if (browseActionListener != null)
    myBrowseButton.addActionListener(browseActionListener);
  add(myBrowseButton, BorderLayout.EAST);

  myBrowseButton.setToolTipText(UIBundle.message("component.with.browse.button.browse.button.tooltip.text"));

  // FixedSizeButton isn't focusable but it should be selectable via keyboard.
  if (ApplicationManager.getApplication() != null) {  // avoid crash at design time
    new MyDoClickAction(myBrowseButton).registerShortcut(myComponent);
  }
}
项目:tools-idea    文件:MemoryUsagePanel.java   
private void updateState() {
  if (!isShowing()) {
    return;
  }

  final Runtime runtime = Runtime.getRuntime();
  final long total = runtime.totalMemory() / MEGABYTE;
  final long used = total - runtime.freeMemory() / MEGABYTE;

  if (total != myLastTotal || used != myLastUsed) {
    myLastTotal = total;
    myLastUsed = used;
    //noinspection SSBasedInspection
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        myBufferedImage = null;
        repaint();
      }
    });

    setToolTipText(UIBundle.message("memory.usage.panel.statistics.message", total, used));
  }
}
项目:tools-idea    文件:PositionPanel.java   
public Consumer<MouseEvent> getClickConsumer() {
  return new Consumer<MouseEvent>() {
    public void consume(MouseEvent mouseEvent) {
      final Project project = getProject();
      if (project == null) return;
      final Editor editor = getEditor();
      if (editor == null) return;
      final CommandProcessor processor = CommandProcessor.getInstance();
      processor.executeCommand(
        project, new Runnable() {
          public void run() {
            final GotoLineNumberDialog dialog = new GotoLineNumberDialog(project, editor);
            dialog.show();
            IdeDocumentHistory.getInstance(project).includeCurrentCommandAsNavigation();
          }
        },
        UIBundle.message("go.to.line.command.name"),
        null
      );
    }
  };
}
项目:tools-idea    文件:FileSaverDialogImpl.java   
protected JComponent createFileNamePanel() {
  final JPanel panel = new JPanel(new BorderLayout());
  panel.add(new JLabel(UIBundle.message("file.chooser.save.dialog.file.name")), BorderLayout.WEST);
  myFileName.setText("");
  myFileName.getDocument().addDocumentListener(new DocumentAdapter() {
    protected void textChanged(DocumentEvent e) {
      updateOkButton();
    }
  });

  panel.add(myFileName, BorderLayout.CENTER);
  if (myExtensions.getModel().getSize() > 0) {
    myExtensions.setSelectedIndex(0);
    panel.add(myExtensions, BorderLayout.EAST);
  }
  return panel;
}
项目:tools-idea    文件:NewFileAction.java   
private static void createNewFile(FileSystemTree fileSystemTree, final FileType fileType, final String initialContent) {
  final VirtualFile file = fileSystemTree.getNewFileParent();
  if (file == null || !file.isDirectory()) return;

  String newFileName;
  while (true) {
    newFileName = Messages.showInputDialog(UIBundle.message("create.new.file.enter.new.file.name.prompt.text"),
                                             UIBundle.message("new.file.dialog.title"), Messages.getQuestionIcon());
    if (newFileName == null) {
      return;
    }
    if ("".equals(newFileName.trim())) {
      Messages.showMessageDialog(UIBundle.message("create.new.file.file.name.cannot.be.empty.error.message"),
                                 UIBundle.message("error.dialog.title"), Messages.getErrorIcon());
      continue;
    }
    Exception failReason = ((FileSystemTreeImpl)fileSystemTree).createNewFile(file, newFileName, fileType, initialContent);
    if (failReason != null) {
      Messages.showMessageDialog(UIBundle.message("create.new.file.could.not.create.file.error.message", newFileName),
                                 UIBundle.message("error.dialog.title"), Messages.getErrorIcon());
      continue;
    }
    return;
  }
}
项目:tools-idea    文件:NewFolderAction.java   
private static void createNewFolder(FileSystemTree fileSystemTree) {
  final VirtualFile file = fileSystemTree.getNewFileParent();
  if (file == null || !file.isDirectory()) return;

  String newFolderName;
  while (true) {
    newFolderName = Messages.showInputDialog(UIBundle.message("create.new.folder.enter.new.folder.name.prompt.text"),
                                             UIBundle.message("new.folder.dialog.title"), Messages.getQuestionIcon());
    if (newFolderName == null) {
      return;
    }
    if ("".equals(newFolderName.trim())) {
      Messages.showMessageDialog(UIBundle.message("create.new.folder.folder.name.cannot.be.empty.error.message"),
                                 UIBundle.message("error.dialog.title"), Messages.getErrorIcon());
      continue;
    }
    Exception failReason = ((FileSystemTreeImpl)fileSystemTree).createNewFolder(file, newFolderName);
    if (failReason != null) {
      Messages.showMessageDialog(UIBundle.message("create.new.folder.could.not.create.folder.error.message", newFolderName),
                                 UIBundle.message("error.dialog.title"), Messages.getErrorIcon());
      continue;
    }
    return;
  }
}
项目:consulo    文件:ComponentWithBrowseButton.java   
public ComponentWithBrowseButton(Comp component, @Nullable ActionListener browseActionListener) {
  super(new BorderLayout(SystemInfo.isMac ? 0 : 2, 0));

  myComponent = component;
  // required! otherwise JPanel will occasionally gain focus instead of the component
  setFocusable(false);
  add(myComponent, BorderLayout.CENTER);

  myBrowseButton = new FixedSizeButton(myComponent);
  if (browseActionListener != null) {
    myBrowseButton.addActionListener(browseActionListener);
  }
  add(centerComponentVertically(myBrowseButton), BorderLayout.EAST);

  myBrowseButton.setToolTipText(UIBundle.message("component.with.browse.button.browse.button.tooltip.text"));
  // FixedSizeButton isn't focusable but it should be selectable via keyboard.
  if (ApplicationManager.getApplication() != null) {  // avoid crash at design time
    new MyDoClickAction(myBrowseButton).registerShortcut(myComponent);
  }
  if (ScreenReader.isActive()) {
    myBrowseButton.setFocusable(true);
    myBrowseButton.getAccessibleContext().setAccessibleName("Browse");
  }
}
项目:consulo    文件:MemoryUsagePanel.java   
private void updateState() {
  if (!isShowing()) {
    return;
  }

  final Runtime runtime = Runtime.getRuntime();
  final long total = runtime.totalMemory() / MEGABYTE;
  final long used = total - runtime.freeMemory() / MEGABYTE;

  if (total != myLastTotal || used != myLastUsed) {
    myLastTotal = total;
    myLastUsed = used;
    //noinspection SSBasedInspection
    SwingUtilities.invokeLater(new Runnable() {
      @Override
      public void run() {
        myBufferedImage = null;
        repaint();
      }
    });

    setToolTipText(UIBundle.message("memory.usage.panel.statistics.message", total, used));
  }
}
项目:consulo    文件:ToggleReadOnlyAttributePanel.java   
@Override
public Consumer<MouseEvent> getClickConsumer() {
  return mouseEvent -> {
    final VirtualFile file = getCurrentFile();
    if (!isReadOnlyApplicableForFile(file)) {
      return;
    }
    FileDocumentManager.getInstance().saveAllDocuments();

    try {
      WriteAction.run(() -> ReadOnlyAttributeUtil.setReadOnlyAttribute(file, file.isWritable()));
      myStatusBar.updateWidget(ID());
    }
    catch (IOException e) {
      Messages.showMessageDialog(getProject(), e.getMessage(), UIBundle.message("error.dialog.title"), Messages.getErrorIcon());
    }
  };
}
项目:consulo    文件:PositionPanel.java   
@Override
public Consumer<MouseEvent> getClickConsumer() {
  return mouseEvent -> {
    final Project project = getProject();
    if (project == null) return;
    final Editor editor = getEditor();
    if (editor == null) return;
    final CommandProcessor processor = CommandProcessor.getInstance();
    processor.executeCommand(
            project, () -> {
      final GotoLineNumberDialog dialog = new GotoLineNumberDialog(project, editor);
      dialog.show();
      IdeDocumentHistory.getInstance(project).includeCurrentCommandAsNavigation();
    },
            UIBundle.message("go.to.line.command.name"),
            null
    );
  };
}
项目:consulo    文件:NewFileAction.java   
private static void createNewFile(FileSystemTree fileSystemTree, final FileType fileType, final String initialContent) {
  final VirtualFile file = fileSystemTree.getNewFileParent();
  if (file == null || !file.isDirectory()) return;

  String newFileName;
  while (true) {
    newFileName = Messages.showInputDialog(UIBundle.message("create.new.file.enter.new.file.name.prompt.text"),
                                             UIBundle.message("new.file.dialog.title"), Messages.getQuestionIcon());
    if (newFileName == null) {
      return;
    }
    if ("".equals(newFileName.trim())) {
      Messages.showMessageDialog(UIBundle.message("create.new.file.file.name.cannot.be.empty.error.message"),
                                 UIBundle.message("error.dialog.title"), Messages.getErrorIcon());
      continue;
    }
    Exception failReason = ((FileSystemTreeImpl)fileSystemTree).createNewFile(file, newFileName, fileType, initialContent);
    if (failReason != null) {
      Messages.showMessageDialog(UIBundle.message("create.new.file.could.not.create.file.error.message", newFileName),
                                 UIBundle.message("error.dialog.title"), Messages.getErrorIcon());
      continue;
    }
    return;
  }
}
项目:consulo    文件:NewFolderAction.java   
private static void createNewFolder(FileSystemTree fileSystemTree) {
  final VirtualFile file = fileSystemTree.getNewFileParent();
  if (file == null || !file.isDirectory()) return;

  String newFolderName;
  while (true) {
    newFolderName = Messages.showInputDialog(UIBundle.message("create.new.folder.enter.new.folder.name.prompt.text"),
                                             UIBundle.message("new.folder.dialog.title"), Messages.getQuestionIcon());
    if (newFolderName == null) {
      return;
    }
    if ("".equals(newFolderName.trim())) {
      Messages.showMessageDialog(UIBundle.message("create.new.folder.folder.name.cannot.be.empty.error.message"),
                                 UIBundle.message("error.dialog.title"), Messages.getErrorIcon());
      continue;
    }
    Exception failReason = ((FileSystemTreeImpl)fileSystemTree).createNewFolder(file, newFolderName);
    if (failReason != null) {
      Messages.showMessageDialog(UIBundle.message("create.new.folder.could.not.create.folder.error.message", newFolderName),
                                 UIBundle.message("error.dialog.title"), Messages.getErrorIcon());
      continue;
    }
    return;
  }
}
项目:consulo    文件:FileSaverDialogImpl.java   
protected JComponent createFileNamePanel() {
  final JPanel panel = new JPanel(new BorderLayout());
  panel.add(new JLabel(UIBundle.message("file.chooser.save.dialog.file.name")), BorderLayout.WEST);
  myFileName.setText("");
  myFileName.getDocument().addDocumentListener(new DocumentAdapter() {
    protected void textChanged(DocumentEvent e) {
      updateOkButton();
    }
  });

  panel.add(myFileName, BorderLayout.CENTER);
  if (myExtensions.getModel().getSize() > 0) {
    myExtensions.setSelectedIndex(0);
    panel.add(myExtensions, BorderLayout.EAST);
  }
  return panel;
}
项目:intellij-ce-playground    文件:ClassFilterEditorAddDialog.java   
public ClassFilterEditorAddDialog(Project project, @Nullable String helpId) {
  super(project, true);
  myProject = project;
  myHelpId = helpId;
  setTitle(UIBundle.message("class.filter.editor.add.dialog.title"));
  init();
}
项目:intellij-ce-playground    文件:ClassFilterEditorAddDialog.java   
protected JComponent createCenterPanel() {
  final JPanel panel = new JPanel(new GridBagLayout());
  final JLabel header = new JLabel(UIBundle.message("label.class.filter.editor.add.dialog.filter.pattern"));
  myClassName = new TextFieldWithBrowseButton(new JTextField(35));
  final JLabel iconLabel = new JLabel(Messages.getQuestionIcon());

  panel.add(header, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 10, 0, 0), 0, 0));
  panel.add(myClassName, new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 10, 0, 0), 0, 0));
  panel.add(iconLabel, new GridBagConstraints(0, 0, 1, 2, 0.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(15, 0, 0, 0), 0, 0));

  myClassName.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      PsiClass currentClass = getSelectedClass();
      TreeClassChooser chooser = TreeClassChooserFactory.getInstance(myProject).createNoInnerClassesScopeChooser(
        UIBundle.message("class.filter.editor.choose.class.title"), GlobalSearchScope.allScope(myProject), null, null);
      if (currentClass != null) {
        PsiFile containingFile = currentClass.getContainingFile();
        if (containingFile != null) {
          PsiDirectory containingDirectory = containingFile.getContainingDirectory();
          if (containingDirectory != null) {
            chooser.selectDirectory(containingDirectory);
          }
        }
      }
      chooser.showDialog();
      PsiClass selectedClass = chooser.getSelected();
      if (selectedClass != null) {
        myClassName.setText(selectedClass.getQualifiedName());
      }
    }
  });

  myClassName.setEnabled(myProject != null);

  return panel;
}
项目:intellij-ce-playground    文件:DialogWrapper.java   
/**
 * Invoked by default implementation of "Help" action.
 * Note that the method does nothing if "Help" action isn't enabled.
 * <p/>
 * The default implementation shows the help page with id returned
 * by {@link #getHelpId()}. If that method returns null,
 * a message box with message "no help available" is shown.
 */
protected void doHelpAction() {
  if (myHelpAction.isEnabled()) {
    String helpId = getHelpId();
    if (helpId != null) {
      HelpManager.getInstance().invokeHelp(helpId);
    }
    else {
      Messages.showMessageDialog(getContentPane(), UIBundle.message("there.is.no.help.for.this.dialog.error.message"),
                                 UIBundle.message("no.help.available.dialog.title"), Messages.getInformationIcon());
    }
  }
}
项目:intellij-ce-playground    文件:InsertOverwritePanel.java   
private void updateStatus() {
  final Editor editor = getEditor();
  if (editor == null || !editor.isColumnMode()) {
    myTextPanel.setBorder(null);
    myTextPanel.setVisible(false);
  } else {
    myTextPanel.setBorder(WidgetBorder.INSTANCE);
    myTextPanel.setVisible(true);
    myTextPanel.setText(UIBundle.message("status.bar.column.status.text"));
    myTextPanel.setToolTipText("Column selection mode");
  }
}
项目:intellij-ce-playground    文件:PositionPanel.java   
private String getPositionText(@NotNull Editor editor) {
  if (!editor.isDisposed() && myStatusBar != null) {
    StringBuilder message = new StringBuilder();

    SelectionModel selectionModel = editor.getSelectionModel();
    int caretCount = editor.getCaretModel().getCaretCount();
    if (caretCount > 1) {
      message.append(UIBundle.message("position.panel.caret.count", caretCount));
    }
    else {
      if (selectionModel.hasSelection()) {
        int selectionStart = selectionModel.getSelectionStart();
        int selectionEnd = selectionModel.getSelectionEnd();
        if (selectionEnd > selectionStart) {
          message.append(UIBundle.message("position.panel.selected.chars.count", selectionEnd - selectionStart));
          int selectionStartLine = editor.getDocument().getLineNumber(selectionStart);
          int selectionEndLine = editor.getDocument().getLineNumber(selectionEnd);
          if (selectionEndLine > selectionStartLine) {
            message.append(", ");
            message.append(UIBundle.message("position.panel.selected.lines.count", selectionEndLine - selectionStartLine + 1));
          }
          message.append("     ");
        }
      }
      LogicalPosition caret = editor.getCaretModel().getLogicalPosition();
      message.append(caret.line + 1).append(":").append(caret.column + 1);
    }

    return message.toString();
  }
  else {
    return "";
  }
}
项目:intellij-ce-playground    文件:FileDocumentManagerImpl.java   
@Override
public boolean process(final VirtualFile file, final Document document) {
  String message = UIBundle.message("file.cache.conflict.message.text", file.getPresentableUrl());

  final DialogBuilder builder = new DialogBuilder();
  builder.setCenterPanel(new JLabel(message, Messages.getQuestionIcon(), SwingConstants.CENTER));
  builder.addOkAction().setText(UIBundle.message("file.cache.conflict.load.fs.changes.button"));
  builder.addCancelAction().setText(UIBundle.message("file.cache.conflict.keep.memory.changes.button"));
  builder.addAction(new AbstractAction(UIBundle.message("file.cache.conflict.show.difference.button")) {
    @Override
    public void actionPerformed(ActionEvent e) {
      final ProjectEx project = (ProjectEx)ProjectLocator.getInstance().guessProjectForFile(file);

      FileType fileType = file.getFileType();
      String fsContent = LoadTextUtil.loadText(file).toString();
      DocumentContent content1 = DiffContentFactory.getInstance().create(fsContent, fileType);
      DocumentContent content2 = DiffContentFactory.getInstance().create(project, document, file);
      String title = UIBundle.message("file.cache.conflict.for.file.dialog.title", file.getPresentableUrl());
      String title1 = UIBundle.message("file.cache.conflict.diff.content.file.system.content");
      String title2 = UIBundle.message("file.cache.conflict.diff.content.memory.content");
      DiffRequest request = new SimpleDiffRequest(title, content1, content2, title1, title2);
      request.putUserData(DiffUserDataKeys.GO_TO_SOURCE_DISABLE, true);
      DialogBuilder diffBuilder = new DialogBuilder(project);
      DiffRequestPanel diffPanel = DiffManager.getInstance().createRequestPanel(project, diffBuilder, diffBuilder.getWindow());
      diffPanel.setRequest(request);
      diffBuilder.setCenterPanel(diffPanel.getComponent());
      diffBuilder.setDimensionServiceKey("FileDocumentManager.FileCacheConflict");
      diffBuilder.addOkAction().setText(UIBundle.message("file.cache.conflict.save.changes.button"));
      diffBuilder.addCancelAction();
      diffBuilder.setTitle(title);
      if (diffBuilder.show() == DialogWrapper.OK_EXIT_CODE) {
        builder.getDialogWrapper().close(DialogWrapper.CANCEL_EXIT_CODE);
      }
    }
  });
  builder.setTitle(UIBundle.message("file.cache.conflict.dialog.title"));
  builder.setButtonsAlignment(SwingConstants.CENTER);
  builder.setHelpId("reference.dialogs.fileCacheConflict");
  return builder.show() == 0;
}
项目:intellij-ce-playground    文件:MessagesEx.java   
public static MessageInfo filesAreReadOnly(Project project, String[] files) {
  if (files.length == 1){
    return fileIsReadOnly(project, files[0]);
  } else {
    return error(project, UIBundle.message("files.are.read.only.message.text", filePaths(files)));
  }
}
项目:intellij-ce-playground    文件:FileSaverDialogImpl.java   
@Override
protected void doOKAction() {
  final File file = getFile();
  if (file != null && file.exists()) {
    if (Messages.YES != Messages.showYesNoDialog(getRootPane(),
                                                UIBundle.message("file.chooser.save.dialog.confirmation", file.getName()),
                                                UIBundle.message("file.chooser.save.dialog.confirmation.title"),
                                                Messages.getWarningIcon())) {
      return;
    }
  }
  storeSelection(myFileSystemTree.getSelectedFile());
  super.doOKAction();
}
项目:intellij-ce-playground    文件:VirtualFileDeleteProvider.java   
public void deleteElement(@NotNull DataContext dataContext) {
  final VirtualFile[] files = CommonDataKeys.VIRTUAL_FILE_ARRAY.getData(dataContext);
  if (files == null || files.length == 0) return;
  Project project = CommonDataKeys.PROJECT.getData(dataContext);

  String message = createConfirmationMessage(files);
  int returnValue = Messages.showOkCancelDialog(message, UIBundle.message("delete.dialog.title"), ApplicationBundle.message("button.delete"),
    CommonBundle.getCancelButtonText(), Messages.getQuestionIcon());
  if (returnValue != Messages.OK) return;

  Arrays.sort(files, FileComparator.getInstance());

  final List<String> problems = ContainerUtil.newLinkedList();
  new WriteCommandAction.Simple(project) {

    @Override
    protected void run() throws Throwable {
      for (final VirtualFile file : files) {
        try {
          file.delete(this);
        }
        catch (IOException e) {
          LOG.info(e);
          problems.add(file.getName());
        }
      }

    }
  }.execute();

  if (!problems.isEmpty()) {
    reportDeletionProblem(problems);
  }
}
项目:intellij-ce-playground    文件:VirtualFileDeleteProvider.java   
private static void reportDeletionProblem(List<String> problems) {
  boolean more = false;
  if (problems.size() > 10) {
    problems = problems.subList(0, 10);
    more = true;
  }
  Messages.showMessageDialog("Could not erase files or folders:\n  " + StringUtil.join(problems, ",\n  ") + (more ? "\n  ..." : ""),
                             UIBundle.message("error.dialog.title"), Messages.getErrorIcon());
}
项目:intellij-ce-playground    文件:ColorBlindnessPanel.java   
public ColorBlindnessPanel() {
  super(new HorizontalLayout(JBUI.scale(10)));
  add(HorizontalLayout.LEFT, myCheckBox);
  add(HorizontalLayout.LEFT, myComboBox);

  JLabel label = new SwingActionLink(new AbstractAction(UIBundle.message("color.blindness.link.to.help")) {
    @Override
    public void actionPerformed(ActionEvent event) {
      HelpManager.getInstance().invokeHelp("Colorblind_Settings");
    }
  });
  add(HorizontalLayout.LEFT, label);

  myCheckBox.setSelected(false);
  myCheckBox.addChangeListener(this);
  myCheckBox.setText(UIBundle.message("color.blindness.checkbox.text"));
  int count = 0;
  for (ColorBlindness blindness : ColorBlindness.values()) {
    String name = UIBundle.message(blindness.key);
    if (!name.isEmpty()) {
      myComboBox.addItem(new Item(blindness, name));
      count++;
    }
  }
  myComboBox.setEnabled(false);
  myComboBox.setVisible(count > 1);
  setVisible(count > 0);
}
项目:intellij-ce-playground    文件:TogglePopupHintsPanel.java   
private void updateStatus(PsiFile file) {
  if (isStateChangeable(file)) {
    if (PowerSaveMode.isEnabled()) {
      myCurrentIcon = AllIcons.Ide.HectorNo;
      myToolTipText = "Code analysis is disabled in power save mode.\n";
    }
    else if (HighlightingLevelManager.getInstance(myProject).shouldInspect(file)) {
      myCurrentIcon = AllIcons.Ide.HectorOn;
      myToolTipText = "Current inspection profile: " +
                      InspectionProjectProfileManager.getInstance(file.getProject()).getInspectionProfile().getName() +
                      ".\n";
    }
    else if (HighlightingLevelManager.getInstance(myProject).shouldHighlight(file)) {
      myCurrentIcon = AllIcons.Ide.HectorSyntax;
      myToolTipText = "Highlighting level is: Syntax.\n";
    }
    else {
      myCurrentIcon = AllIcons.Ide.HectorOff;
      myToolTipText = "Inspections are off.\n";
    }
    myToolTipText += UIBundle.message("popup.hints.panel.click.to.configure.highlighting.tooltip.text");
  }
  else {
    myCurrentIcon = AllIcons.Ide.HectorNo;
    myToolTipText = null;
  }

  if (!ApplicationManager.getApplication().isUnitTestMode() && myStatusBar != null) {
    myStatusBar.updateWidget(ID());
  }
}
项目:intellij-ce-playground    文件:EditLogPatternDialog.java   
@Override
protected JComponent createCenterPanel() {
  myFilePattern.addBrowseFolderListener(UIBundle.message("file.chooser.default.title"), null, null, FileChooserDescriptorFactory.createSingleFileOrFolderDescriptor(), TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT);
  myFilePattern.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
    @Override
    protected void textChanged(DocumentEvent e) {
      setOKActionEnabled(myFilePattern.getText() != null && myFilePattern.getText().length() > 0);
    }
  });
  return myWholePanel;
}
项目:tools-idea    文件:ClassFilterEditorAddDialog.java   
public ClassFilterEditorAddDialog(Project project, @Nullable String helpId) {
  super(project, true);
  myProject = project;
  myHelpId = helpId;
  setTitle(UIBundle.message("class.filter.editor.add.dialog.title"));
  init();
}
项目:tools-idea    文件:ClassFilterEditorAddDialog.java   
protected JComponent createCenterPanel() {
  final JPanel panel = new JPanel(new GridBagLayout());
  final JLabel header = new JLabel(UIBundle.message("label.class.filter.editor.add.dialog.filter.pattern"));
  myClassName = new TextFieldWithBrowseButton(new JTextField(35));
  final JLabel iconLabel = new JLabel(Messages.getQuestionIcon());

  panel.add(header, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 10, 0, 0), 0, 0));
  panel.add(myClassName, new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 10, 0, 0), 0, 0));
  panel.add(iconLabel, new GridBagConstraints(0, 0, 1, 2, 0.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(15, 0, 0, 0), 0, 0));

  myClassName.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      PsiClass currentClass = getSelectedClass();
      TreeClassChooser chooser = TreeClassChooserFactory.getInstance(myProject).createNoInnerClassesScopeChooser(
        UIBundle.message("class.filter.editor.choose.class.title"), GlobalSearchScope.allScope(myProject), null, null);
      if (currentClass != null) {
        PsiFile containingFile = currentClass.getContainingFile();
        if (containingFile != null) {
          PsiDirectory containingDirectory = containingFile.getContainingDirectory();
          if (containingDirectory != null) {
            chooser.selectDirectory(containingDirectory);
          }
        }
      }
      chooser.showDialog();
      PsiClass selectedClass = chooser.getSelected();
      if (selectedClass != null) {
        myClassName.setText(selectedClass.getQualifiedName());
      }
    }
  });

  myClassName.setEnabled(myProject != null);

  return panel;
}
项目:tools-idea    文件:DialogWrapper.java   
/**
 * Invoked by default implementation of "Help" action.
 * Note that the method does nothing if "Help" action isn't enabled.
 * <p/>
 * The default implementation shows the help page with id returned
 * by {@link #getHelpId()}. If that method returns null,
 * a message box with message "no help available" is shown.
 */
protected void doHelpAction() {
  if (myHelpAction.isEnabled()) {
    String helpId = getHelpId();
    if (helpId != null) {
      HelpManager.getInstance().invokeHelp(helpId);
    }
    else {
      Messages.showMessageDialog(getContentPane(), UIBundle.message("there.is.no.help.for.this.dialog.error.message"),
                                 UIBundle.message("no.help.available.dialog.title"), Messages.getInformationIcon());
    }
  }
}
项目:tools-idea    文件:InsertOverwritePanel.java   
private void updateStatus() {
  final Editor editor = getEditor();
  if (editor == null || !editor.isColumnMode()) {
    myTextPanel.setBorder(null);
    myTextPanel.setVisible(false);
  } else {
    myTextPanel.setBorder(WidgetBorder.INSTANCE);
    myTextPanel.setVisible(true);
    myTextPanel.setText(UIBundle.message("status.bar.column.status.text"));
    myTextPanel.setToolTipText("Column selection mode");
  }
}
项目:tools-idea    文件:ToggleReadOnlyAttributePanel.java   
public Consumer<MouseEvent> getClickConsumer() {
  return new Consumer<MouseEvent>() {
    public void consume(MouseEvent mouseEvent) {
      final Project project = getProject();
      if (project == null) {
        return;
      }
      final FileEditorManager editorManager = FileEditorManager.getInstance(project);
      final VirtualFile[] files = editorManager.getSelectedFiles();
      if (!isReadOnlyApplicableForFiles(files)) {
        return;
      }
      FileDocumentManager.getInstance().saveAllDocuments();

      ApplicationManager.getApplication().runWriteAction(new Runnable() {
        public void run() {
          try {
            ReadOnlyAttributeUtil.setReadOnlyAttribute(files[0], files[0].isWritable());
            myStatusBar.updateWidget(ID());
          }
          catch (IOException e) {
            Messages.showMessageDialog(project, e.getMessage(), UIBundle.message("error.dialog.title"), Messages.getErrorIcon());
          }
        }
      });
    }
  };
}
项目:tools-idea    文件:InternalDecorator.java   
public final ActionGroup createPopupGroup() {
  final DefaultActionGroup group = createGearPopupGroup();

  group.add(myToggleContentUiTypeAction);

  final DefaultActionGroup moveGroup = new DefaultActionGroup(UIBundle.message("tool.window.move.to.action.group.name"), true);
  final ToolWindowAnchor anchor = myInfo.getAnchor();
  if (anchor != ToolWindowAnchor.TOP) {
    final AnAction topAction = new ChangeAnchorAction(UIBundle.message("tool.window.move.to.top.action.name"), ToolWindowAnchor.TOP);
    moveGroup.add(topAction);
  }
  if (anchor != ToolWindowAnchor.LEFT) {
    final AnAction leftAction = new ChangeAnchorAction(UIBundle.message("tool.window.move.to.left.action.name"), ToolWindowAnchor.LEFT);
    moveGroup.add(leftAction);
  }
  if (anchor != ToolWindowAnchor.BOTTOM) {
    final AnAction bottomAction =
      new ChangeAnchorAction(UIBundle.message("tool.window.move.to.bottom.action.name"), ToolWindowAnchor.BOTTOM);
    moveGroup.add(bottomAction);
  }
  if (anchor != ToolWindowAnchor.RIGHT) {
    final AnAction rightAction =
      new ChangeAnchorAction(UIBundle.message("tool.window.move.to.right.action.name"), ToolWindowAnchor.RIGHT);
    moveGroup.add(rightAction);
  }
  group.add(moveGroup);

  DefaultActionGroup resize = new DefaultActionGroup(ActionsBundle.groupText("ResizeToolWindowGroup"), true);
  resize.add(new ResizeToolWindowAction.Left(myToolWindow, this));
  resize.add(new ResizeToolWindowAction.Right(myToolWindow, this));
  resize.add(new ResizeToolWindowAction.Up(myToolWindow, this));
  resize.add(new ResizeToolWindowAction.Down(myToolWindow, this));

  group.add(resize);

  group.addSeparator();
  group.add(new HideAction());
  return group;
}