use of com.intellij.openapi.ui.DialogWrapper in project intellij-community by JetBrains.
the class EditSourceForDialogAction method actionPerformed.
public void actionPerformed(AnActionEvent e) {
final Navigatable[] navigatableArray = e.getData(CommonDataKeys.NAVIGATABLE_ARRAY);
if (navigatableArray != null && navigatableArray.length > 0) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
public void run() {
OpenSourceUtil.navigate(navigatableArray);
}
});
DialogWrapper dialog = DialogWrapper.findInstance(mySourceComponent);
if (dialog != null && dialog.isModal()) {
dialog.doCancelAction();
}
}
}
use of com.intellij.openapi.ui.DialogWrapper in project intellij-community by JetBrains.
the class IntroduceVariableHandler method reportConflicts.
protected boolean reportConflicts(final MultiMap<PsiElement, String> conflicts, final Project project, IntroduceVariableSettings dialog) {
ConflictsDialog conflictsDialog = new ConflictsDialog(project, conflicts);
conflictsDialog.show();
final boolean ok = conflictsDialog.isOK();
if (!ok && conflictsDialog.isShowConflicts()) {
if (dialog instanceof DialogWrapper)
((DialogWrapper) dialog).close(DialogWrapper.CANCEL_EXIT_CODE);
}
return ok;
}
use of com.intellij.openapi.ui.DialogWrapper in project intellij-community by JetBrains.
the class XDebuggerEditorBase method showCodeFragmentEditor.
private void showCodeFragmentEditor(Component parent, XDebuggerEditorBase baseEditor) {
DialogWrapper dialog = new DialogWrapper(parent, true) {
CodeFragmentInputComponent inputComponent = new CodeFragmentInputComponent(baseEditor.getProject(), baseEditor.getEditorsProvider(), mySourcePosition, XExpressionImpl.changeMode(baseEditor.getExpression(), EvaluationMode.CODE_FRAGMENT), null, null);
{
setTitle("Edit");
init();
}
@Nullable
@Override
protected String getDimensionServiceKey() {
return "#xdebugger.code.fragment.editor";
}
@Nullable
@Override
protected JComponent createCenterPanel() {
JPanel component = inputComponent.getMainComponent();
component.setPreferredSize(JBUI.size(300, 200));
return component;
}
@Override
protected void doOKAction() {
super.doOKAction();
baseEditor.setExpression(inputComponent.getInputEditor().getExpression());
JComponent component = baseEditor.getPreferredFocusedComponent();
if (component != null) {
IdeFocusManager.findInstance().requestFocus(component, false);
}
}
@Nullable
@Override
public JComponent getPreferredFocusedComponent() {
return inputComponent.getInputEditor().getPreferredFocusedComponent();
}
};
dialog.show();
}
use of com.intellij.openapi.ui.DialogWrapper in project intellij-community by JetBrains.
the class BinaryDiffTool method show.
public void show(final DiffRequest data) {
final DiffContent current = data.getContents()[0];
final DiffContent upToDate = data.getContents()[1];
final Project project = data.getProject();
if ((current instanceof FileContent && upToDate instanceof FileContent) || (current.getContentType() instanceof UIBasedFileType && upToDate.getContentType() instanceof UIBasedFileType)) {
final VirtualFile src = current.getFile();
final VirtualFile trg = upToDate.getFile();
if (src != null && trg != null) {
final PanelCreator creator = new PanelCreator(data);
if (creator.isCanCreatePanel()) {
new DialogWrapper(data.getProject()) {
public DiffPanel myPanel;
{
setModal(false);
init();
}
@Override
protected String getDimensionServiceKey() {
return "BinaryDiffDialog";
}
@NotNull
@Override
protected Action[] createActions() {
final Action close = getCancelAction();
close.putValue(Action.NAME, "&Close");
return new Action[] { close };
}
@Override
protected JComponent createCenterPanel() {
myPanel = creator.create(getWindow(), getDisposable(), BinaryDiffTool.this);
return myPanel.getComponent();
}
}.show();
return;
} else {
final DirDiffManager diffManager = DirDiffManager.getInstance(project);
final DiffElement before = diffManager.createDiffElement(src);
final DiffElement after = diffManager.createDiffElement(trg);
if (before != null && after != null && diffManager.canShow(after, before)) {
diffManager.showDiff(before, after);
return;
}
}
}
}
try {
final boolean equal = Arrays.equals(current.getBytes(), upToDate.getBytes());
Messages.showMessageDialog(equal ? DiffBundle.message("binary.files.are.identical.message") : DiffBundle.message("binary.files.are.different.message"), equal ? DiffBundle.message("files.are.identical.dialog.title") : DiffBundle.message("files.are.different.dialog.title"), Messages.getInformationIcon());
} catch (IOException e) {
LOG.error(e);
}
}
use of com.intellij.openapi.ui.DialogWrapper in project intellij-community by JetBrains.
the class FileDocumentManagerImpl method handleErrorsOnSave.
private void handleErrorsOnSave(@NotNull Map<Document, IOException> failures) {
if (ApplicationManager.getApplication().isUnitTestMode()) {
IOException ioException = ContainerUtil.getFirstItem(failures.values());
if (ioException != null) {
throw new RuntimeException(ioException);
}
return;
}
for (IOException exception : failures.values()) {
LOG.warn(exception);
}
final String text = StringUtil.join(failures.values(), Throwable::getMessage, "\n");
final DialogWrapper dialog = new DialogWrapper(null) {
{
init();
setTitle(UIBundle.message("cannot.save.files.dialog.title"));
}
@Override
protected void createDefaultActions() {
super.createDefaultActions();
myOKAction.putValue(Action.NAME, UIBundle.message(myOnClose ? "cannot.save.files.dialog.ignore.changes" : "cannot.save.files.dialog.revert.changes"));
myOKAction.putValue(DEFAULT_ACTION, null);
if (!myOnClose) {
myCancelAction.putValue(Action.NAME, CommonBundle.getCloseButtonText());
}
}
@Override
protected JComponent createCenterPanel() {
final JPanel panel = new JPanel(new BorderLayout(0, 5));
panel.add(new JLabel(UIBundle.message("cannot.save.files.dialog.message")), BorderLayout.NORTH);
final JTextPane area = new JTextPane();
area.setText(text);
area.setEditable(false);
area.setMinimumSize(new Dimension(area.getMinimumSize().width, 50));
panel.add(new JBScrollPane(area, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER), BorderLayout.CENTER);
return panel;
}
};
if (dialog.showAndGet()) {
for (Document document : failures.keySet()) {
reloadFromDisk(document);
}
}
}
Aggregations