本文整理汇总了Java中com.intellij.openapi.ui.DialogBuilder.setButtonsAlignment方法的典型用法代码示例。如果您正苦于以下问题:Java DialogBuilder.setButtonsAlignment方法的具体用法?Java DialogBuilder.setButtonsAlignment怎么用?Java DialogBuilder.setButtonsAlignment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.ui.DialogBuilder
的用法示例。
在下文中一共展示了DialogBuilder.setButtonsAlignment方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: actionPerformed
import com.intellij.openapi.ui.DialogBuilder; //导入方法依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
cacheFile = new File(Constant.CACHE_PATH);
if (!cacheFile.exists()) {
cacheFile.mkdirs();
}
long size = FileUtils.sizeOfDirectory(cacheFile);
DialogBuilder builder = new DialogBuilder();
builder.setTitle(Constant.TITLE);
builder.resizable(false);
builder.setCenterPanel(new JLabel(String.format("Currently occupy storage %.2fM, "
+ "Clean Cache immediately?", size/1024.0/1024.0),
Messages.getInformationIcon(), SwingConstants.CENTER));
builder.addOkAction().setText("Clean Now");
builder.addCancelAction().setText("Cancel");
builder.setButtonsAlignment(SwingConstants.RIGHT);
if (builder.show() == 0) {
clean();
}
}
示例2: doShowError
import com.intellij.openapi.ui.DialogBuilder; //导入方法依赖的package包/类
private static void doShowError(String title, String description, DialogBuilder builder) {
builder.setTitle(title);
final JTextArea textArea = new JTextArea();
textArea.setEditable(false);
textArea.setText(description);
textArea.setWrapStyleWord(false);
textArea.setLineWrap(true);
final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(textArea);
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
final JPanel panel = new JPanel(new BorderLayout(10, 0));
panel.setPreferredSize(new Dimension(600, 400));
panel.add(scrollPane, BorderLayout.CENTER);
panel.add(new JBLabel("Details:", Messages.getErrorIcon(), SwingConstants.LEFT), BorderLayout.NORTH);
builder.setCenterPanel(panel);
builder.setButtonsAlignment(SwingConstants.CENTER);
builder.addOkAction();
builder.show();
}
示例3: createDialog
import com.intellij.openapi.ui.DialogBuilder; //导入方法依赖的package包/类
/**
* 创建普通对话框
* @param message
* @param okText
* @param cancelText
* @return
*/
public static boolean createDialog(String message, String okText, String cancelText) {
DialogBuilder builder = new DialogBuilder();
builder.setTitle("Dialog Message");
builder.resizable(false);
builder.setCenterPanel(new JLabel(message, Messages.getInformationIcon(), SwingConstants.CENTER));
builder.addOkAction().setText(okText);
builder.addCancelAction().setText(cancelText);
builder.setButtonsAlignment(SwingConstants.CENTER);
return builder.show() == 0;
}
示例4: show
import com.intellij.openapi.ui.DialogBuilder; //导入方法依赖的package包/类
public static void show(final ExecutionException e, final String title, final Project project) {
if (e instanceof RunCanceledByUserException) {
return;
}
if (ApplicationManager.getApplication().isUnitTestMode()) {
throw new RuntimeException(e.getLocalizedMessage());
}
final String message = e.getMessage();
if (message == null || message.length() < 100) {
Messages.showErrorDialog(project, message == null ? "exception was thrown" : message, title);
return;
}
final DialogBuilder builder = new DialogBuilder(project);
builder.setTitle(title);
final JTextArea textArea = new JTextArea();
textArea.setEditable(false);
textArea.setForeground(UIUtil.getLabelForeground());
textArea.setBackground(UIUtil.getLabelBackground());
textArea.setFont(UIUtil.getLabelFont());
textArea.setText(message);
textArea.setWrapStyleWord(false);
textArea.setLineWrap(true);
final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(textArea);
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
final JPanel panel = new JPanel(new BorderLayout(10, 0));
panel.setPreferredSize(JBUI.size(500, 200));
panel.add(scrollPane, BorderLayout.CENTER);
panel.add(new JLabel(Messages.getErrorIcon()), BorderLayout.WEST);
builder.setCenterPanel(panel);
builder.setButtonsAlignment(SwingConstants.CENTER);
builder.addOkAction();
builder.show();
}
示例5: process
import com.intellij.openapi.ui.DialogBuilder; //导入方法依赖的package包/类
@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;
}
示例6: show
import com.intellij.openapi.ui.DialogBuilder; //导入方法依赖的package包/类
public static void show(final ExecutionException e, final String title, final Project project) {
if (e instanceof RunCanceledByUserException) {
return;
}
if (ApplicationManager.getApplication().isUnitTestMode()) {
throw new RuntimeException(e.getLocalizedMessage());
}
final String message = e.getMessage();
if (message == null || message.length() < 100) {
Messages.showErrorDialog(project, message == null ? "exception was thrown" : message, title);
return;
}
final DialogBuilder builder = new DialogBuilder(project);
builder.setTitle(title);
final JTextArea textArea = new JTextArea();
textArea.setEditable(false);
textArea.setForeground(UIUtil.getLabelForeground());
textArea.setBackground(UIUtil.getLabelBackground());
textArea.setFont(UIUtil.getLabelFont());
textArea.setText(message);
textArea.setWrapStyleWord(false);
textArea.setLineWrap(true);
final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(textArea);
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
final JPanel panel = new JPanel(new BorderLayout(10, 0));
panel.setPreferredSize(new Dimension(500, 200));
panel.add(scrollPane, BorderLayout.CENTER);
panel.add(new JLabel(Messages.getErrorIcon()), BorderLayout.WEST);
builder.setCenterPanel(panel);
builder.setButtonsAlignment(SwingConstants.CENTER);
builder.addOkAction();
builder.show();
}
示例7: askReloadFromDisk
import com.intellij.openapi.ui.DialogBuilder; //导入方法依赖的package包/类
public boolean askReloadFromDisk(VirtualFile file, 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(project, 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;
}
示例8: askReloadFromDisk
import com.intellij.openapi.ui.DialogBuilder; //导入方法依赖的package包/类
protected boolean askReloadFromDisk(final VirtualFile file, final Document document) {
ApplicationManager.getApplication().assertIsDispatchThread();
if (!isDocumentUnsaved(document)) return true;
String message = UIBundle.message("file.cache.conflict.message.text", file.getPresentableUrl());
if (ApplicationManager.getApplication().isUnitTestMode()) throw new RuntimeException(message);
final DialogBuilder builder = new DialogBuilder((Project)null);
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) {
String title = UIBundle.message("file.cache.conflict.for.file.dialog.title", file.getPresentableUrl());
final ProjectEx project = (ProjectEx)ProjectLocator.getInstance().guessProjectForFile(file);
SimpleDiffRequest request = new SimpleDiffRequest(project, title);
FileType fileType = file.getFileType();
String fsContent = LoadTextUtil.loadText(file).toString();
request.setContents(new SimpleContent(fsContent, fileType),
new DocumentContent(project, document, fileType));
request.setContentTitles(UIBundle.message("file.cache.conflict.diff.content.file.system.content"),
UIBundle.message("file.cache.conflict.diff.content.memory.content"));
DialogBuilder diffBuilder = new DialogBuilder(project);
DiffPanelImpl diffPanel = (DiffPanelImpl)DiffManager.getInstance().createDiffPanel(diffBuilder.getWindow(), project, diffBuilder, null);
diffPanel.getOptions().setShowSourcePolicy(DiffPanelOptions.ShowSourcePolicy.DONT_SHOW);
diffBuilder.setCenterPanel(diffPanel.getComponent());
diffBuilder.setDimensionServiceKey("FileDocumentManager.FileCacheConflict");
diffPanel.setDiffRequest(request);
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;
}