use of com.intellij.openapi.ui.FrameWrapper in project intellij-community by JetBrains.
the class CCShowPreview method showPreviewDialog.
private static void showPreviewDialog(@NotNull Project project, @NotNull VirtualFile userFile, @NotNull TaskFile taskFile) {
final FrameWrapper showPreviewFrame = new FrameWrapper(project);
showPreviewFrame.setTitle(userFile.getName());
LabeledEditor labeledEditor = new LabeledEditor(null);
final EditorFactory factory = EditorFactory.getInstance();
Document document = FileDocumentManager.getInstance().getDocument(userFile);
if (document == null) {
return;
}
final EditorEx createdEditor = (EditorEx) factory.createEditor(document, project, userFile, true);
Disposer.register(project, new Disposable() {
public void dispose() {
factory.releaseEditor(createdEditor);
}
});
for (AnswerPlaceholder answerPlaceholder : taskFile.getActivePlaceholders()) {
if (answerPlaceholder.getActiveSubtaskInfo().isNeedInsertText()) {
answerPlaceholder.setLength(answerPlaceholder.getTaskText().length());
}
Integer minIndex = Collections.min(answerPlaceholder.getSubtaskInfos().keySet());
answerPlaceholder.setUseLength(minIndex >= answerPlaceholder.getActiveSubtaskIndex());
EduAnswerPlaceholderPainter.drawAnswerPlaceholder(createdEditor, answerPlaceholder, JBColor.BLUE);
}
JPanel header = new JPanel();
header.setLayout(new BoxLayout(header, BoxLayout.Y_AXIS));
header.setBorder(new EmptyBorder(10, 10, 10, 10));
header.add(new JLabel("Read-only preview."));
String timeStamp = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(Calendar.getInstance().getTime());
header.add(new JLabel(String.format("Created %s.", timeStamp)));
JComponent editorComponent = createdEditor.getComponent();
labeledEditor.setComponent(editorComponent, header);
createdEditor.setCaretVisible(false);
createdEditor.setCaretEnabled(false);
showPreviewFrame.setComponent(labeledEditor);
showPreviewFrame.setSize(new Dimension(500, 500));
if (!ApplicationManager.getApplication().isUnitTestMode()) {
showPreviewFrame.show();
}
}
use of com.intellij.openapi.ui.FrameWrapper in project intellij-community by JetBrains.
the class MergeTool method show.
public void show(DiffRequest data) {
if (data instanceof MergeRequestImpl) {
showDialog((MergeRequestImpl) data);
return;
}
if (LOG.isDebugEnabled()) {
LOG.debug(new Throwable("MergeTool - frame"));
}
FrameWrapper frameWrapper = new FrameWrapper(data.getProject(), data.getGroupKey());
DiffViewer mergePanel = createMergeComponent(data, null, frameWrapper);
frameWrapper.setComponent(mergePanel.getComponent());
frameWrapper.setPreferredFocusedComponent(mergePanel.getPreferredFocusedComponent());
frameWrapper.closeOnEsc();
frameWrapper.setTitle(data.getWindowTitle());
frameWrapper.setProject(data.getProject());
frameWrapper.show();
}
use of com.intellij.openapi.ui.FrameWrapper 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.FrameWrapper 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();
}
}
Aggregations