use of com.intellij.openapi.ui.DialogBuilder in project intellij-community by JetBrains.
the class FileTypeConfigurable method editPattern.
private void editPattern(@Nullable final String item) {
final FileType type = myRecognizedFileType.getSelectedFileType();
if (type == null)
return;
final String title = item == null ? FileTypesBundle.message("filetype.edit.add.pattern.title") : FileTypesBundle.message("filetype.edit.edit.pattern.title");
final Language oldLanguage = item == null ? null : myTempTemplateDataLanguages.findAssociatedFileType(item);
final FileTypePatternDialog dialog = new FileTypePatternDialog(item, type, oldLanguage);
final DialogBuilder builder = new DialogBuilder(myPatterns);
builder.setPreferredFocusComponent(dialog.getPatternField());
builder.setCenterPanel(dialog.getMainPanel());
builder.setTitle(title);
builder.showModal(true);
if (builder.getDialogWrapper().isOK()) {
final String pattern = dialog.getPatternField().getText();
if (StringUtil.isEmpty(pattern))
return;
final FileNameMatcher matcher = FileTypeManager.parseFromString(pattern);
FileType registeredFileType = findExistingFileType(matcher);
if (registeredFileType != null && registeredFileType != type) {
if (registeredFileType.isReadOnly()) {
Messages.showMessageDialog(myPatterns.myPatternsList, FileTypesBundle.message("filetype.edit.add.pattern.exists.error", registeredFileType.getDescription()), title, Messages.getErrorIcon());
return;
} else {
if (Messages.OK == Messages.showOkCancelDialog(myPatterns.myPatternsList, FileTypesBundle.message("filetype.edit.add.pattern.exists.message", registeredFileType.getDescription()), FileTypesBundle.message("filetype.edit.add.pattern.exists.title"), FileTypesBundle.message("filetype.edit.add.pattern.reassign.button"), CommonBundle.getCancelButtonText(), Messages.getQuestionIcon())) {
myTempPatternsTable.removeAssociation(matcher, registeredFileType);
if (oldLanguage != null) {
myTempTemplateDataLanguages.removeAssociation(matcher, oldLanguage);
}
myReassigned.put(matcher, registeredFileType);
} else {
return;
}
}
}
if (item != null) {
final FileNameMatcher oldMatcher = FileTypeManager.parseFromString(item);
myTempPatternsTable.removeAssociation(oldMatcher, type);
if (oldLanguage != null) {
myTempTemplateDataLanguages.removeAssociation(oldMatcher, oldLanguage);
}
}
myTempPatternsTable.addAssociation(matcher, type);
myTempTemplateDataLanguages.addAssociation(matcher, dialog.getTemplateDataLanguage());
updateExtensionList();
final int index = myPatterns.getListModel().indexOf(matcher.getPresentableString());
if (index >= 0) {
ScrollingUtil.selectItem(myPatterns.myPatternsList, index);
}
IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
IdeFocusManager.getGlobalInstance().requestFocus(myPatterns.myPatternsList, true);
});
}
}
use of com.intellij.openapi.ui.DialogBuilder in project intellij-community by JetBrains.
the class MergeTool method showDialog.
private static void showDialog(MergeRequestImpl data) {
if (LOG.isDebugEnabled()) {
LOG.debug("MergeTool - dialog");
}
DialogBuilder builder = new DialogBuilder(data.getProject());
builder.setDimensionServiceKey(data.getGroupKey());
builder.setTitle(data.getWindowTitle());
Disposable parent = Disposer.newDisposable();
builder.addDisposable(parent);
MergePanel2 mergePanel = createMergeComponent(data, builder, parent);
builder.setCenterPanel(mergePanel.getComponent());
builder.setPreferredFocusComponent(mergePanel.getPreferredFocusedComponent());
builder.setHelpId(data.getHelpId());
int result = builder.show();
MergeRequestImpl lastData = mergePanel.getMergeRequest();
if (lastData != null) {
lastData.setResult(result);
}
}
use of com.intellij.openapi.ui.DialogBuilder in project intellij-community by JetBrains.
the class FrameDiffTool method show.
public void show(DiffRequest request) {
Collection hints = request.getHints();
boolean shouldOpenDialog = shouldOpenDialog(hints);
if (shouldOpenDialog) {
final DialogBuilder builder = new DialogBuilder(request.getProject());
DiffPanelImpl diffPanel = createDiffPanelIfShouldShow(request, builder.getWindow(), builder, true);
if (diffPanel == null) {
Disposer.dispose(builder);
return;
}
final Runnable onOkRunnable = request.getOnOkRunnable();
if (onOkRunnable != null) {
builder.setOkOperation(() -> {
builder.getDialogWrapper().close(0);
onOkRunnable.run();
});
} else {
builder.removeAllActions();
}
builder.setCenterPanel(diffPanel.getComponent());
builder.setPreferredFocusComponent(diffPanel.getPreferredFocusedComponent());
builder.setTitle(request.getWindowTitle());
builder.setDimensionServiceKey(request.getGroupKey());
new AnAction() {
public void actionPerformed(final AnActionEvent e) {
builder.getDialogWrapper().close(0);
}
}.registerCustomShortcutSet(new CustomShortcutSet(KeymapManager.getInstance().getActiveKeymap().getShortcuts("CloseContent")), diffPanel.getComponent());
showDiffDialog(builder, hints);
} else {
final FrameWrapper frameWrapper = new FrameWrapper(request.getProject(), request.getGroupKey());
DiffPanelImpl diffPanel = createDiffPanelIfShouldShow(request, frameWrapper.getFrame(), frameWrapper, true);
if (diffPanel == null) {
Disposer.dispose(frameWrapper);
return;
}
frameWrapper.setTitle(request.getWindowTitle());
DiffUtil.initDiffFrame(diffPanel.getProject(), frameWrapper, diffPanel, diffPanel.getComponent());
new AnAction() {
public void actionPerformed(final AnActionEvent e) {
frameWrapper.getFrame().dispose();
}
}.registerCustomShortcutSet(new CustomShortcutSet(KeymapManager.getInstance().getActiveKeymap().getShortcuts("CloseContent")), diffPanel.getComponent());
frameWrapper.show();
}
}
use of com.intellij.openapi.ui.DialogBuilder in project intellij-community by JetBrains.
the class MultiLevelDiffTool method show.
@Override
public void show(DiffRequest request) {
Collection hints = request.getHints();
boolean shouldOpenDialog = FrameDiffTool.shouldOpenDialog(hints);
if (shouldOpenDialog) {
final DialogBuilder builder = new DialogBuilder(request.getProject());
final CompositeDiffPanel diffPanel = createPanel(request, builder.getWindow(), builder);
if (diffPanel == null) {
Disposer.dispose(builder);
return;
}
final Runnable onOkRunnable = request.getOnOkRunnable();
if (onOkRunnable != null) {
builder.setOkOperation(() -> {
builder.getDialogWrapper().close(0);
onOkRunnable.run();
});
} else {
builder.removeAllActions();
}
builder.setCenterPanel(diffPanel.getComponent());
builder.setPreferredFocusComponent(diffPanel.getPreferredFocusedComponent());
builder.setTitle(request.getWindowTitle());
builder.setDimensionServiceKey(request.getGroupKey());
new AnAction() {
public void actionPerformed(final AnActionEvent e) {
builder.getDialogWrapper().close(0);
}
}.registerCustomShortcutSet(new CustomShortcutSet(KeymapManager.getInstance().getActiveKeymap().getShortcuts("CloseContent")), diffPanel.getComponent());
diffPanel.setDiffRequest(request);
FrameDiffTool.showDiffDialog(builder, hints);
} else {
final FrameWrapper frameWrapper = new FrameWrapper(request.getProject(), request.getGroupKey());
final CompositeDiffPanel diffPanel = createPanel(request, frameWrapper.getFrame(), frameWrapper);
if (diffPanel == null) {
Disposer.dispose(frameWrapper);
return;
}
frameWrapper.setTitle(request.getWindowTitle());
diffPanel.setDiffRequest(request);
DiffUtil.initDiffFrame(request.getProject(), frameWrapper, diffPanel, diffPanel.getComponent());
new AnAction() {
public void actionPerformed(final AnActionEvent e) {
Disposer.dispose(frameWrapper);
}
}.registerCustomShortcutSet(new CustomShortcutSet(KeymapManager.getInstance().getActiveKeymap().getShortcuts("CloseContent")), diffPanel.getComponent());
frameWrapper.show();
}
}
use of com.intellij.openapi.ui.DialogBuilder in project intellij-community by JetBrains.
the class XmlLanguageInjectionSupport method showInjectionUI.
@Nullable
private static BaseInjection showInjectionUI(final Project project, final BaseInjection xmlInjection) {
final DialogBuilder builder = new DialogBuilder(project);
final AbstractInjectionPanel panel;
if (xmlInjection instanceof XmlTagInjection) {
panel = new XmlTagPanel((XmlTagInjection) xmlInjection, project);
builder.setHelpId("reference.settings.injection.language.injection.settings.xml.tag");
} else if (xmlInjection instanceof XmlAttributeInjection) {
panel = new XmlAttributePanel((XmlAttributeInjection) xmlInjection, project);
builder.setHelpId("reference.settings.injection.language.injection.settings.xml.attribute");
} else
throw new AssertionError();
panel.reset();
builder.addOkAction();
builder.addCancelAction();
builder.setCenterPanel(panel.getComponent());
builder.setTitle(EditInjectionSettingsAction.EDIT_INJECTION_TITLE);
builder.setOkOperation(() -> {
panel.apply();
builder.getDialogWrapper().close(DialogWrapper.OK_EXIT_CODE);
});
if (builder.show() == DialogWrapper.OK_EXIT_CODE) {
return xmlInjection.copy();
}
return null;
}
Aggregations