mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup
GitOrigin-RevId: 4ae4acc8bf15c9f47423f51e4ecfb05cd4331dcd
This commit is contained in:
committed by
intellij-monorepo-bot
parent
7fe2f016f7
commit
80d42199fe
@@ -11,6 +11,7 @@ import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.packaging.artifacts.Artifact;
|
||||
import com.intellij.packaging.elements.PackagingElementFactory;
|
||||
import com.intellij.util.PathUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@@ -79,7 +80,7 @@ public abstract class ArtifactEditorTestCase extends PackagingElementsTestCase {
|
||||
final Ref<Boolean> dialogShown = Ref.create(false);
|
||||
final TestDialog oldDialog = Messages.setTestDialog(new TestDialog() {
|
||||
@Override
|
||||
public int show(String message) {
|
||||
public int show(@NotNull String message) {
|
||||
dialogShown.set(true);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -29,11 +29,11 @@ import com.intellij.ui.components.JBList;
|
||||
import com.intellij.ui.popup.list.GroupedItemsListRenderer;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
import java.awt.*;
|
||||
import java.util.Collections;
|
||||
@@ -55,7 +55,7 @@ public class ProjectTemplateList extends JPanel {
|
||||
add(myPanel, BorderLayout.CENTER);
|
||||
|
||||
GroupedItemsListRenderer<ProjectTemplate> renderer = new GroupedItemsListRenderer<ProjectTemplate>(new ListItemDescriptorAdapter<ProjectTemplate>() {
|
||||
@Nullable
|
||||
@NotNull
|
||||
@Override
|
||||
public String getTextFor(ProjectTemplate value) {
|
||||
return value.getName();
|
||||
@@ -80,12 +80,7 @@ public class ProjectTemplateList extends JPanel {
|
||||
}
|
||||
};
|
||||
myList.setCellRenderer(renderer);
|
||||
myList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
|
||||
@Override
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
updateSelection();
|
||||
}
|
||||
});
|
||||
myList.getSelectionModel().addListSelectionListener(__ -> updateSelection());
|
||||
|
||||
Messages.installHyperlinkSupport(myDescriptionPane);
|
||||
}
|
||||
@@ -104,7 +99,7 @@ public class ProjectTemplateList extends JPanel {
|
||||
}
|
||||
}
|
||||
|
||||
public void setTemplates(List<ProjectTemplate> list, boolean preserveSelection) {
|
||||
public void setTemplates(List<? extends ProjectTemplate> list, boolean preserveSelection) {
|
||||
Collections.sort(list, (o1, o2) -> Comparing.compare(o1 instanceof ArchivedProjectTemplate, o2 instanceof ArchivedProjectTemplate));
|
||||
|
||||
int index = preserveSelection ? myList.getSelectedIndex() : -1;
|
||||
@@ -142,13 +137,10 @@ public class ProjectTemplateList extends JPanel {
|
||||
myList.setSelectedValue(template, true);
|
||||
}
|
||||
}
|
||||
myList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
|
||||
@Override
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
ProjectTemplate template = getSelectedTemplate();
|
||||
if (template != null) {
|
||||
PropertiesComponent.getInstance().setValue(PROJECT_WIZARD_TEMPLATE, template.getName());
|
||||
}
|
||||
myList.getSelectionModel().addListSelectionListener(__ -> {
|
||||
ProjectTemplate template = getSelectedTemplate();
|
||||
if (template != null) {
|
||||
PropertiesComponent.getInstance().setValue(PROJECT_WIZARD_TEMPLATE, template.getName());
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -166,7 +158,7 @@ public class ProjectTemplateList extends JPanel {
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
public boolean setSelectedTemplate(String name) {
|
||||
boolean setSelectedTemplate(@NotNull String name) {
|
||||
ListModel model1 = myList.getModel();
|
||||
for (int j = 0; j < model1.getSize(); j++) {
|
||||
if (name.equals(((ProjectTemplate)model1.getElementAt(j)).getName())) {
|
||||
|
||||
@@ -51,8 +51,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
import java.awt.*;
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
@@ -67,9 +65,9 @@ import java.util.*;
|
||||
public class ProjectTypeStep extends ModuleWizardStep implements SettingsStep, Disposable {
|
||||
private static final Logger LOG = Logger.getInstance(ProjectTypeStep.class);
|
||||
|
||||
public static final Convertor<FrameworkSupportInModuleProvider,String> PROVIDER_STRING_CONVERTOR =
|
||||
private static final Convertor<FrameworkSupportInModuleProvider,String> PROVIDER_STRING_CONVERTOR =
|
||||
o -> o.getId();
|
||||
public static final Function<FrameworkSupportNode, String> NODE_STRING_FUNCTION = FrameworkSupportNodeBase::getId;
|
||||
private static final Function<FrameworkSupportNode, String> NODE_STRING_FUNCTION = FrameworkSupportNodeBase::getId;
|
||||
private static final String TEMPLATES_CARD = "templates card";
|
||||
private static final String FRAMEWORKS_CARD = "frameworks card";
|
||||
private static final String PROJECT_WIZARD_GROUP = "project.wizard.group";
|
||||
@@ -103,12 +101,7 @@ public class ProjectTypeStep extends ModuleWizardStep implements SettingsStep, D
|
||||
|
||||
myProjectTypeList.setModel(new CollectionListModel<>(groups));
|
||||
myProjectTypeList.setSelectionModel(new SingleSelectionModel());
|
||||
myProjectTypeList.addListSelectionListener(new ListSelectionListener() {
|
||||
@Override
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
updateSelection();
|
||||
}
|
||||
});
|
||||
myProjectTypeList.addListSelectionListener(__ -> updateSelection());
|
||||
myProjectTypeList.setCellRenderer(new GroupedItemsListRenderer<TemplatesGroup>(new ListItemDescriptorAdapter<TemplatesGroup>() {
|
||||
@Nullable
|
||||
@Override
|
||||
@@ -184,19 +177,9 @@ public class ProjectTypeStep extends ModuleWizardStep implements SettingsStep, D
|
||||
}
|
||||
};
|
||||
|
||||
myProjectTypeList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
|
||||
@Override
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
projectTypeChanged();
|
||||
}
|
||||
});
|
||||
myProjectTypeList.getSelectionModel().addListSelectionListener(__ -> projectTypeChanged());
|
||||
|
||||
myTemplatesList.addListSelectionListener(new ListSelectionListener() {
|
||||
@Override
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
updateSelection();
|
||||
}
|
||||
});
|
||||
myTemplatesList.addListSelectionListener(__ -> updateSelection());
|
||||
|
||||
for (TemplatesGroup templatesGroup : myTemplatesMap.keySet()) {
|
||||
ModuleBuilder builder = templatesGroup.getModuleBuilder();
|
||||
@@ -236,7 +219,7 @@ public class ProjectTypeStep extends ModuleWizardStep implements SettingsStep, D
|
||||
return ContainerUtil.intersects(Arrays.asList(roles), acceptable);
|
||||
}
|
||||
|
||||
public static MultiMap<TemplatesGroup, ProjectTemplate> getTemplatesMap(WizardContext context) {
|
||||
private static MultiMap<TemplatesGroup, ProjectTemplate> getTemplatesMap(WizardContext context) {
|
||||
ProjectTemplatesFactory[] factories = ProjectTemplatesFactory.EP_NAME.getExtensions();
|
||||
final MultiMap<TemplatesGroup, ProjectTemplate> groups = new MultiMap<>();
|
||||
for (ProjectTemplatesFactory factory : factories) {
|
||||
@@ -347,7 +330,7 @@ public class ProjectTypeStep extends ModuleWizardStep implements SettingsStep, D
|
||||
}
|
||||
|
||||
// new TemplatesGroup selected
|
||||
public void projectTypeChanged() {
|
||||
private void projectTypeChanged() {
|
||||
TemplatesGroup group = getSelectedGroup();
|
||||
if (group == null || group == myLastSelectedGroup) return;
|
||||
myLastSelectedGroup = group;
|
||||
@@ -427,7 +410,7 @@ public class ProjectTypeStep extends ModuleWizardStep implements SettingsStep, D
|
||||
showCard(TEMPLATES_CARD);
|
||||
}
|
||||
|
||||
private void setTemplatesList(TemplatesGroup group, Collection<ProjectTemplate> templates, boolean preserveSelection) {
|
||||
private void setTemplatesList(TemplatesGroup group, Collection<? extends ProjectTemplate> templates, boolean preserveSelection) {
|
||||
List<ProjectTemplate> list = new ArrayList<>(templates);
|
||||
ModuleBuilder moduleBuilder = group.getModuleBuilder();
|
||||
if (moduleBuilder != null && !(moduleBuilder instanceof TemplateModuleBuilder)) {
|
||||
@@ -459,7 +442,7 @@ public class ProjectTypeStep extends ModuleWizardStep implements SettingsStep, D
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ProjectTemplate getSelectedTemplate() {
|
||||
private ProjectTemplate getSelectedTemplate() {
|
||||
return myCurrentCard == TEMPLATES_CARD ? myTemplatesList.getSelectedTemplate() : null;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ import com.intellij.util.NullableFunction;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import com.intellij.util.io.HttpRequests;
|
||||
import org.intellij.lang.annotations.Language;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.JDOMException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -74,7 +75,7 @@ public class RemoteTemplatesFactory extends ProjectTemplatesFactory {
|
||||
|
||||
@NotNull
|
||||
@TestOnly
|
||||
public static MultiMap<String, ArchivedProjectTemplate> createFromText(@NotNull String value) throws IOException, JDOMException {
|
||||
public static MultiMap<String, ArchivedProjectTemplate> createFromText(@NotNull @Language("XML") String value) throws IOException, JDOMException {
|
||||
return create(JDOMUtil.load(value));
|
||||
}
|
||||
|
||||
|
||||
@@ -19,24 +19,25 @@ import com.intellij.util.containers.MultiMap;
|
||||
*/
|
||||
public class RemoteTemplatesTest extends NewProjectWizardTestCase {
|
||||
public void testParsing() throws Exception {
|
||||
MultiMap<String, ArchivedProjectTemplate> map = RemoteTemplatesFactory.createFromText("<templates>\n" +
|
||||
" <template>\n" +
|
||||
" <name>Facelets Demo</name>\n" +
|
||||
" <description><![CDATA[\n" +
|
||||
" Demonstrates IDEA support for Facelets technology\n" +
|
||||
" ]]>\n" +
|
||||
" </description>\n" +
|
||||
" <path>facelets.zip</path>\n" +
|
||||
" <moduleType>JAVA_MODULE</moduleType>\n" +
|
||||
" </template>\n" +
|
||||
" <template>\n" +
|
||||
" <name>Incompatible</name>\n" +
|
||||
" <description>Incompatible</description>\n" +
|
||||
" <path>incompatible.zip</path>\n" +
|
||||
" <moduleType>JAVA_MODULE</moduleType>\n" +
|
||||
" <requiredPlugin>unknown.plugin</requiredPlugin>\n" +
|
||||
" </template>\n" +
|
||||
"</templates>");
|
||||
MultiMap<String, ArchivedProjectTemplate> map = RemoteTemplatesFactory.createFromText(
|
||||
"<templates>\n" +
|
||||
" <template>\n" +
|
||||
" <name>Facelets Demo</name>\n" +
|
||||
" <description><![CDATA[\n" +
|
||||
" Demonstrates IDEA support for Facelets technology\n" +
|
||||
" ]]>\n" +
|
||||
" </description>\n" +
|
||||
" <path>facelets.zip</path>\n" +
|
||||
" <moduleType>JAVA_MODULE</moduleType>\n" +
|
||||
" </template>\n" +
|
||||
" <template>\n" +
|
||||
" <name>Incompatible</name>\n" +
|
||||
" <description>Incompatible</description>\n" +
|
||||
" <path>incompatible.zip</path>\n" +
|
||||
" <moduleType>JAVA_MODULE</moduleType>\n" +
|
||||
" <requiredPlugin>unknown.plugin</requiredPlugin>\n" +
|
||||
" </template>\n" +
|
||||
"</templates>");
|
||||
assertEquals(1, map.size());
|
||||
|
||||
ProjectTemplate facelets = map.values().iterator().next();
|
||||
|
||||
+1
-1
@@ -287,7 +287,7 @@ public class EditorTypingAndNavigationUndoTest extends EditorUndoTestCase {
|
||||
Ref<String> message = new Ref<>();
|
||||
Messages.setTestDialog(new TestDialog() {
|
||||
@Override
|
||||
public int show(String m) {
|
||||
public int show(@NotNull String m) {
|
||||
message.set(m);
|
||||
return Messages.YES;
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ public class GlobalUndoTest extends UndoTestCase implements TestDialog {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int show(String message) {
|
||||
public int show(@NotNull String message) {
|
||||
myConfirmationWasRequested = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -127,18 +127,18 @@ public abstract class ProjectWizardTestCase<T extends AbstractProjectWizard> ext
|
||||
return createModuleFromWizard(project);
|
||||
}
|
||||
|
||||
protected Module createModuleFromWizard(@NotNull Project project) {
|
||||
private Module createModuleFromWizard(@NotNull Project project) {
|
||||
return new NewModuleAction().createModuleFromWizard(project, null, myWizard);
|
||||
}
|
||||
|
||||
protected void runWizard(@NotNull String group,
|
||||
@Nullable final String name,
|
||||
@Nullable Project project,
|
||||
@Nullable final Consumer<? super Step> adjuster) throws IOException {
|
||||
private void runWizard(@NotNull String group,
|
||||
@Nullable final String name,
|
||||
@Nullable Project project,
|
||||
@Nullable final Consumer<? super Step> adjuster) throws IOException {
|
||||
createWizard(project);
|
||||
ProjectTypeStep step = (ProjectTypeStep)myWizard.getCurrentStepObject();
|
||||
if (!step.setSelectedTemplate(group, name)) {
|
||||
throw new IllegalArgumentException(group + '/' + name + " template not found, available groups " + step.availableTemplateGroupsToString());
|
||||
throw new IllegalArgumentException(group + '/' + name + " template not found. Available groups: " + step.availableTemplateGroupsToString());
|
||||
}
|
||||
|
||||
runWizard(step1 -> {
|
||||
@@ -151,7 +151,7 @@ public abstract class ProjectWizardTestCase<T extends AbstractProjectWizard> ext
|
||||
});
|
||||
}
|
||||
|
||||
protected void runWizard(@Nullable Consumer<? super Step> adjuster) {
|
||||
private void runWizard(@Nullable Consumer<? super Step> adjuster) {
|
||||
while (true) {
|
||||
ModuleWizardStep currentStep = myWizard.getCurrentStepObject();
|
||||
if (adjuster != null) {
|
||||
@@ -236,7 +236,7 @@ public abstract class ProjectWizardTestCase<T extends AbstractProjectWizard> ext
|
||||
return ContainerUtil.getFirstItem(ImportModuleAction.createFromWizard(project, myWizard));
|
||||
}
|
||||
|
||||
private static <T> T computeInWriteSafeContext(Supplier<T> supplier) {
|
||||
private static <T> T computeInWriteSafeContext(Supplier<? extends T> supplier) {
|
||||
Ref<T> module = Ref.create();
|
||||
ApplicationManager.getApplication().invokeLater(() -> module.set(supplier.get()));
|
||||
UIUtil.dispatchAllInvocationEvents();
|
||||
|
||||
+2
-2
@@ -568,7 +568,7 @@ public abstract class ExternalSystemImportingTestCase extends ExternalSystemTest
|
||||
final AtomicInteger counter = new AtomicInteger();
|
||||
Messages.setTestDialog(new TestDialog() {
|
||||
@Override
|
||||
public int show(String message) {
|
||||
public int show(@NotNull String message) {
|
||||
counter.set(counter.get() + 1);
|
||||
return 0;
|
||||
}
|
||||
@@ -580,7 +580,7 @@ public abstract class ExternalSystemImportingTestCase extends ExternalSystemTest
|
||||
final AtomicInteger counter = new AtomicInteger();
|
||||
Messages.setTestDialog(new TestDialog() {
|
||||
@Override
|
||||
public int show(String message) {
|
||||
public int show(@NotNull String message) {
|
||||
counter.set(counter.get() + 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -244,7 +244,7 @@ public abstract class SdkType implements SdkTypeId {
|
||||
* @param parentComponent the parent component for showing the dialog.
|
||||
* @param selectedSdk current selected sdk in parentComponent
|
||||
* @param sdkCreatedCallback the callback to which the created SDK is passed.
|
||||
* @implSpec method's implementations should not add sdk to the jdkTable neither invoke {@link SdkType#setupSdkPaths}. Only create and
|
||||
* @implSpec method's implementations should not add sdk to the jdkTable neither invoke {@link SdkType#setupSdkPaths}. Only create and
|
||||
* and pass to the callback. The rest is done by {@link com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectSdksModel#setupSdk(Sdk, Consumer)}
|
||||
*/
|
||||
public void showCustomCreateUI(@NotNull SdkModel sdkModel,
|
||||
|
||||
@@ -1,25 +1,14 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.openapi.ui;
|
||||
|
||||
public interface TestDialog {
|
||||
TestDialog DEFAULT = new TestDialog() {
|
||||
@Override
|
||||
public int show(String message) {
|
||||
throw new RuntimeException(message);
|
||||
}
|
||||
};
|
||||
TestDialog OK = new TestDialog() {
|
||||
@Override
|
||||
public int show(String message) {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
TestDialog NO = new TestDialog() {
|
||||
@Override
|
||||
public int show(String message) {
|
||||
return Messages.NO;
|
||||
}
|
||||
};
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
int show(String message);
|
||||
public interface TestDialog {
|
||||
TestDialog DEFAULT = message -> {
|
||||
throw new RuntimeException(message);
|
||||
};
|
||||
TestDialog OK = __ -> Messages.OK;
|
||||
TestDialog NO = __ -> Messages.NO;
|
||||
|
||||
int show(@NotNull String message);
|
||||
}
|
||||
|
||||
+1
-1
@@ -79,7 +79,7 @@ public class FileEncodingTest extends PlatformTestCase implements TestDialog {
|
||||
private TestDialog myOldTestDialogValue;
|
||||
|
||||
@Override
|
||||
public int show(String message) {
|
||||
public int show(@NotNull String message) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ import java.util.MissingResourceException;
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class RegistryValue {
|
||||
|
||||
private final Registry myRegistry;
|
||||
private final String myKey;
|
||||
@Nullable private final RegistryKeyDescriptor myKeyDescriptor;
|
||||
@@ -121,7 +120,7 @@ public class RegistryValue {
|
||||
if (myKeyDescriptor != null) {
|
||||
return myKeyDescriptor.isRestartRequired();
|
||||
}
|
||||
return Boolean.valueOf(get(myKey + ".restartRequired", "false", false));
|
||||
return Boolean.parseBoolean(get(myKey + ".restartRequired", "false", false));
|
||||
}
|
||||
|
||||
public boolean isChangedFromDefault() {
|
||||
@@ -191,37 +190,22 @@ public class RegistryValue {
|
||||
LOG.info("Registry value '" + myKey + "' has changed to '" + value + '\'');
|
||||
}
|
||||
|
||||
public void setValue(boolean value, Disposable parentDisposable) {
|
||||
public void setValue(boolean value, @NotNull Disposable parentDisposable) {
|
||||
final boolean prev = asBoolean();
|
||||
setValue(value);
|
||||
Disposer.register(parentDisposable, new Disposable() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
setValue(prev);
|
||||
}
|
||||
});
|
||||
Disposer.register(parentDisposable, () -> setValue(prev));
|
||||
}
|
||||
|
||||
public void setValue(int value, Disposable parentDisposable) {
|
||||
public void setValue(int value, @NotNull Disposable parentDisposable) {
|
||||
final int prev = asInteger();
|
||||
setValue(value);
|
||||
Disposer.register(parentDisposable, new Disposable() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
setValue(prev);
|
||||
}
|
||||
});
|
||||
Disposer.register(parentDisposable, () -> setValue(prev));
|
||||
}
|
||||
|
||||
public void setValue(String value, Disposable parentDisposable) {
|
||||
public void setValue(String value, @NotNull Disposable parentDisposable) {
|
||||
final String prev = asString();
|
||||
setValue(value);
|
||||
Disposer.register(parentDisposable, new Disposable() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
setValue(prev);
|
||||
}
|
||||
});
|
||||
Disposer.register(parentDisposable, () -> setValue(prev));
|
||||
}
|
||||
|
||||
boolean isChangedSinceAppStart() {
|
||||
@@ -234,12 +218,7 @@ public class RegistryValue {
|
||||
|
||||
public void addListener(@NotNull final RegistryValueListener listener, @NotNull Disposable parent) {
|
||||
myListeners.add(listener);
|
||||
Disposer.register(parent, new Disposable() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
myListeners.remove(listener);
|
||||
}
|
||||
});
|
||||
Disposer.register(parent, () -> myListeners.remove(listener));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -356,7 +356,7 @@ public abstract class PyEnvTestCase {
|
||||
private final List<Throwable> myExceptions = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public int show(final String message) {
|
||||
public int show(@NotNull final String message) {
|
||||
myMessages.add(message);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user