use of com.intellij.openapi.ui.DialogWrapper in project intellij-community by JetBrains.
the class ArchiveDiffTool method canShow.
@Override
public boolean canShow(DiffRequest request) {
final DiffContent[] contents = request.getContents();
final DialogWrapper instance = DialogWrapper.findInstance(IdeFocusManager.getInstance(request.getProject()).getFocusOwner());
if (instance != null && instance.isModal())
return false;
if (contents.length == 2) {
final VirtualFile file1 = contents[0].getFile();
final VirtualFile file2 = contents[1].getFile();
if (file1 != null && file2 != null) {
final FileType type1 = contents[0].getContentType();
final FileType type2 = contents[1].getContentType();
return type1 == type2 && type1 instanceof ArchiveFileType;
}
}
return false;
}
use of com.intellij.openapi.ui.DialogWrapper in project intellij-community by JetBrains.
the class IdeaDialogFixture method getDialogWrapperFrom.
@Nullable
protected static <T extends DialogWrapper> T getDialogWrapperFrom(@NotNull JDialog dialog, Class<T> dialogWrapperType) {
try {
WeakReference<DialogWrapper> dialogWrapperRef = field("myDialogWrapper").ofType(new TypeRef<WeakReference<DialogWrapper>>() {
}).in(dialog).get();
assertNotNull(dialogWrapperRef);
DialogWrapper wrapper = dialogWrapperRef.get();
if (dialogWrapperType.isInstance(wrapper)) {
return dialogWrapperType.cast(wrapper);
}
} catch (ReflectionError ignored) {
}
return null;
}
use of com.intellij.openapi.ui.DialogWrapper in project intellij-community by JetBrains.
the class AbstractModuleDataService method ruleOrphanModules.
/**
* There is a possible case that an external module has been un-linked from ide project. There are two ways to process
* ide modules which correspond to that external project:
* <pre>
* <ol>
* <li>Remove them from ide project as well;</li>
* <li>Keep them at ide project as well;</li>
* </ol>
* </pre>
* This method handles that situation, i.e. it asks a user what should be done and acts accordingly.
*
* @param orphanModules modules which correspond to the un-linked external project
* @param project current ide project
* @param externalSystemId id of the external system which project has been un-linked from ide project
*/
private static void ruleOrphanModules(@NotNull final List<Module> orphanModules, @NotNull final Project project, @NotNull final ProjectSystemId externalSystemId, @NotNull final Consumer<List<Module>> result) {
ExternalSystemApiUtil.executeOnEdt(true, () -> {
List<Module> toRemove = ContainerUtil.newSmartList();
if (ApplicationManager.getApplication().isHeadlessEnvironment()) {
toRemove.addAll(orphanModules);
} else {
final JPanel content = new JPanel(new GridBagLayout());
content.add(new JLabel(ExternalSystemBundle.message("orphan.modules.text", externalSystemId.getReadableName())), ExternalSystemUiUtil.getFillLineConstraints(0));
final CheckBoxList<Module> orphanModulesList = new CheckBoxList<>();
orphanModulesList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
orphanModulesList.setItems(orphanModules, module -> module.getName());
for (Module module : orphanModules) {
orphanModulesList.setItemSelected(module, true);
}
orphanModulesList.setBorder(IdeBorderFactory.createEmptyBorder(8));
content.add(orphanModulesList, ExternalSystemUiUtil.getFillLineConstraints(0));
content.setBorder(IdeBorderFactory.createEmptyBorder(0, 0, 8, 0));
DialogWrapper dialog = new DialogWrapper(project) {
{
setTitle(ExternalSystemBundle.message("import.title", externalSystemId.getReadableName()));
init();
}
@Nullable
@Override
protected JComponent createCenterPanel() {
return new JBScrollPane(content);
}
@NotNull
protected Action[] createActions() {
return new Action[] { getOKAction() };
}
};
dialog.showAndGet();
for (int i = 0; i < orphanModules.size(); i++) {
Module module = orphanModules.get(i);
if (orphanModulesList.isItemSelected(i)) {
toRemove.add(module);
}
}
}
result.consume(toRemove);
});
}
use of com.intellij.openapi.ui.DialogWrapper in project intellij-community by JetBrains.
the class ExtractMethodObjectProcessor method moveUsedMethodsToInner.
void moveUsedMethodsToInner() {
if (!myUsages.isEmpty()) {
if (ApplicationManager.getApplication().isUnitTestMode()) {
WriteAction.run(() -> {
for (MethodToMoveUsageInfo usage : myUsages) {
final PsiMember member = (PsiMember) usage.getElement();
LOG.assertTrue(member != null);
myInnerClass.add(member.copy());
member.delete();
}
});
return;
}
final List<MemberInfo> memberInfos = new ArrayList<>();
for (MethodToMoveUsageInfo usage : myUsages) {
memberInfos.add(new MemberInfo((PsiMethod) usage.getElement()));
}
final MemberSelectionPanel panel = new MemberSelectionPanel("&Methods to move to the extracted class", memberInfos, null);
DialogWrapper dlg = new DialogWrapper(myProject, false) {
{
init();
setTitle("Move Methods Used in Extracted Block Only");
}
@Override
protected JComponent createCenterPanel() {
return panel;
}
};
if (dlg.showAndGet()) {
WriteAction.run(() -> {
for (MemberInfoBase<PsiMember> memberInfo : panel.getTable().getSelectedMemberInfos()) {
if (memberInfo.isChecked()) {
myInnerClass.add(memberInfo.getMember().copy());
memberInfo.getMember().delete();
}
}
});
}
}
}
use of com.intellij.openapi.ui.DialogWrapper in project intellij-community by JetBrains.
the class CreateDialogAction method invokeDialog.
@NotNull
protected PsiElement[] invokeDialog(final Project project, final PsiDirectory directory) {
final MyInputValidator validator = new JavaNameValidator(project, directory);
final MyContentPane contentPane = new MyContentPane();
final DialogWrapper dialog = new DialogWrapper(project, true) {
{
init();
setTitle(UIDesignerBundle.message("title.new.dialog"));
}
protected JComponent createCenterPanel() {
return contentPane.getPanel();
}
protected void doOKAction() {
myRecentGenerateOK = contentPane.myChkGenerateOK.isSelected();
myRecentGenerateCancel = contentPane.myChkGenerateCancel.isSelected();
myRecentGenerateMain = contentPane.myChkGenerateMain.isSelected();
final String inputString = contentPane.myTfClassName.getText().trim();
if (validator.checkInput(inputString) && validator.canClose(inputString)) {
close(OK_EXIT_CODE);
}
}
public JComponent getPreferredFocusedComponent() {
return contentPane.myTfClassName;
}
};
dialog.show();
return validator.getCreatedElements();
}
Aggregations