mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.execution.jar.JarApplicationConfigurable">
|
||||
<grid id="27dc6" binding="myWholePanel" layout-manager="GridLayoutManager" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="27dc6" binding="myWholePanel" layout-manager="GridLayoutManager" row-count="5" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="530" height="400"/>
|
||||
@@ -16,7 +16,7 @@
|
||||
</component>
|
||||
<vspacer id="9634c">
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<component id="a09fc" class="com.intellij.execution.ui.AlternativeJREPanel" binding="myAlternativeJREPanel">
|
||||
@@ -34,6 +34,16 @@
|
||||
<text value="Path to &JAR"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="6fe96" class="com.intellij.openapi.ui.LabeledComponent" binding="myModuleComponent">
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<componentClass value="com.intellij.application.options.ModulesComboBox"/>
|
||||
<labelLocation value="West"/>
|
||||
<text value="Search sources using m&odule's classpath"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.execution.jar;
|
||||
|
||||
import com.intellij.application.options.ModulesComboBox;
|
||||
import com.intellij.execution.ui.AlternativeJREPanel;
|
||||
import com.intellij.execution.ui.CommonJavaParametersPanel;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
|
||||
@@ -34,6 +35,7 @@ import javax.swing.*;
|
||||
public class JarApplicationConfigurable extends SettingsEditor<JarApplicationConfiguration> implements PanelWithAnchor {
|
||||
private CommonJavaParametersPanel myCommonProgramParameters;
|
||||
private LabeledComponent<TextFieldWithBrowseButton> myJarPathComponent;
|
||||
private LabeledComponent<ModulesComboBox> myModuleComponent;
|
||||
private JPanel myWholePanel;
|
||||
|
||||
private AlternativeJREPanel myAlternativeJREPanel;
|
||||
@@ -43,6 +45,9 @@ public class JarApplicationConfigurable extends SettingsEditor<JarApplicationCon
|
||||
public JarApplicationConfigurable(final Project project) {
|
||||
myProject = project;
|
||||
myAnchor = UIUtil.mergeComponentsWithAnchor(myJarPathComponent, myCommonProgramParameters, myAlternativeJREPanel);
|
||||
ModulesComboBox modulesComboBox = myModuleComponent.getComponent();
|
||||
modulesComboBox.allowEmptySelection("<whole project>");
|
||||
modulesComboBox.fillModules(project);
|
||||
}
|
||||
|
||||
public void applyEditorTo(final JarApplicationConfiguration configuration) throws ConfigurationException {
|
||||
@@ -50,12 +55,14 @@ public class JarApplicationConfigurable extends SettingsEditor<JarApplicationCon
|
||||
configuration.setAlternativeJrePath(myAlternativeJREPanel.getPath());
|
||||
configuration.setAlternativeJrePathEnabled(myAlternativeJREPanel.isPathEnabled());
|
||||
configuration.setJarPath(FileUtil.toSystemIndependentName(myJarPathComponent.getComponent().getText()));
|
||||
configuration.setModule(myModuleComponent.getComponent().getSelectedModule());
|
||||
}
|
||||
|
||||
public void resetEditorFrom(final JarApplicationConfiguration configuration) {
|
||||
myCommonProgramParameters.reset(configuration);
|
||||
myJarPathComponent.getComponent().setText(FileUtil.toSystemDependentName(configuration.getJarPath()));
|
||||
myAlternativeJREPanel.init(configuration.getAlternativeJrePath(), configuration.isAlternativeJrePathEnabled());
|
||||
myModuleComponent.getComponent().setSelectedModule(configuration.getModule());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+23
-1
@@ -23,6 +23,7 @@ import com.intellij.execution.runners.ExecutionEnvironment;
|
||||
import com.intellij.execution.util.JavaParametersUtil;
|
||||
import com.intellij.execution.util.ProgramParametersUtil;
|
||||
import com.intellij.openapi.components.PathMacroManager;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.options.SettingsEditor;
|
||||
import com.intellij.openapi.options.SettingsEditorGroup;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -41,13 +42,15 @@ import java.util.Map;
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class JarApplicationConfiguration extends RunConfigurationBase implements CommonJavaRunConfigurationParameters {
|
||||
public class JarApplicationConfiguration extends RunConfigurationBase implements CommonJavaRunConfigurationParameters, SearchScopeProvidingRunProfile {
|
||||
private static final SkipDefaultValuesSerializationFilters SERIALIZATION_FILTERS = new SkipDefaultValuesSerializationFilters();
|
||||
private JarApplicationConfigurationBean myBean = new JarApplicationConfigurationBean();
|
||||
private Map<String, String> myEnvs = new LinkedHashMap<String, String>();
|
||||
private JavaRunConfigurationModule myConfigurationModule;
|
||||
|
||||
public JarApplicationConfiguration(Project project, ConfigurationFactory factory, String name) {
|
||||
super(project, factory, name);
|
||||
myConfigurationModule = new JavaRunConfigurationModule(project, true);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -67,6 +70,15 @@ public class JarApplicationConfiguration extends RunConfigurationBase implements
|
||||
JavaRunConfigurationExtensionManager.getInstance().readExternal(this, element);
|
||||
XmlSerializer.deserializeInto(myBean, element);
|
||||
EnvironmentVariablesComponent.readExternal(element, getEnvs());
|
||||
myConfigurationModule.readExternal(element);
|
||||
}
|
||||
|
||||
public void setModule(Module module) {
|
||||
myConfigurationModule.setModule(module);
|
||||
}
|
||||
|
||||
public Module getModule() {
|
||||
return myConfigurationModule.getModule();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -76,6 +88,9 @@ public class JarApplicationConfiguration extends RunConfigurationBase implements
|
||||
XmlSerializer.serializeInto(myBean, element, SERIALIZATION_FILTERS);
|
||||
EnvironmentVariablesComponent.writeExternal(element, getEnvs());
|
||||
PathMacroManager.getInstance(getProject()).collapsePathsRecursively(element);
|
||||
if (myConfigurationModule.getModule() != null) {
|
||||
myConfigurationModule.writeExternal(element);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -89,6 +104,13 @@ public class JarApplicationConfiguration extends RunConfigurationBase implements
|
||||
JavaRunConfigurationExtensionManager.checkConfigurationIsValid(this);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Module[] getModules() {
|
||||
Module module = myConfigurationModule.getModule();
|
||||
return module != null ? new Module[] {module}: Module.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment environment) throws ExecutionException {
|
||||
|
||||
@@ -19,5 +19,5 @@ package com.intellij.execution.configurations;
|
||||
/**
|
||||
* @author spleaner
|
||||
*/
|
||||
public interface ModuleRunProfile extends RunProfileWithCompileBeforeLaunchOption {
|
||||
public interface ModuleRunProfile extends RunProfileWithCompileBeforeLaunchOption, SearchScopeProvidingRunProfile {
|
||||
}
|
||||
|
||||
+2
-2
@@ -28,8 +28,8 @@ public class SearchScopeProvider {
|
||||
@NotNull
|
||||
public static GlobalSearchScope createSearchScope(@NotNull Project project, @Nullable RunProfile runProfile) {
|
||||
Module[] modules = null;
|
||||
if (runProfile instanceof ModuleRunProfile) {
|
||||
modules = ((ModuleRunProfile)runProfile).getModules();
|
||||
if (runProfile instanceof SearchScopeProvidingRunProfile) {
|
||||
modules = ((SearchScopeProvidingRunProfile)runProfile).getModules();
|
||||
}
|
||||
if (modules == null || modules.length == 0) {
|
||||
return GlobalSearchScope.allScope(project);
|
||||
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.execution.configurations;
|
||||
|
||||
import com.intellij.openapi.module.Module;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Base interface for run configurations that can specify which part of the project should be used to search sources. This information
|
||||
* will be used to provide more accurate navigation to sources from stack traces, debugger, etc
|
||||
*
|
||||
* @author nik
|
||||
*/
|
||||
public interface SearchScopeProvidingRunProfile extends RunProfile {
|
||||
/**
|
||||
* @return modules where to search sources for this configuration
|
||||
*/
|
||||
@NotNull
|
||||
Module[] getModules();
|
||||
}
|
||||
+12
-1
@@ -3,6 +3,7 @@ package com.intellij.application.options;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleType;
|
||||
import com.intellij.ui.ListCellRendererWrapper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
@@ -10,10 +11,20 @@ import javax.swing.*;
|
||||
* @author yole
|
||||
*/
|
||||
public class ModuleListCellRenderer extends ListCellRendererWrapper<Module> {
|
||||
private final String myEmptySelectionText;
|
||||
|
||||
public ModuleListCellRenderer() {
|
||||
this("[none]");
|
||||
}
|
||||
|
||||
public ModuleListCellRenderer(@NotNull String emptySelectionText) {
|
||||
myEmptySelectionText = emptySelectionText;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customize(JList list, Module module, int index, boolean selected, boolean hasFocus) {
|
||||
if (module == null) {
|
||||
setText("[none]");
|
||||
setText(myEmptySelectionText);
|
||||
}
|
||||
else {
|
||||
setIcon(ModuleType.get(module).getIcon());
|
||||
|
||||
@@ -36,6 +36,7 @@ import java.util.List;
|
||||
*/
|
||||
public class ModulesComboBox extends ComboBox {
|
||||
private final SortedComboBoxModel<Module> myModel;
|
||||
private boolean myAllowEmptySelection;
|
||||
|
||||
public ModulesComboBox() {
|
||||
this(new SortedComboBoxModel<Module>(ModulesAlphaComparator.INSTANCE));
|
||||
@@ -58,8 +59,17 @@ public class ModulesComboBox extends ComboBox {
|
||||
setRenderer(new ModuleListCellRenderer());
|
||||
}
|
||||
|
||||
public void allowEmptySelection(@NotNull String emptySelectionText) {
|
||||
myAllowEmptySelection = true;
|
||||
myModel.add(null);
|
||||
setRenderer(new ModuleListCellRenderer(emptySelectionText));
|
||||
}
|
||||
|
||||
public void setModules(@NotNull Collection<Module> modules) {
|
||||
myModel.setAll(modules);
|
||||
if (myAllowEmptySelection) {
|
||||
myModel.add(null);
|
||||
}
|
||||
}
|
||||
|
||||
public void fillModules(@NotNull Project project) {
|
||||
|
||||
+4
-3
@@ -29,8 +29,9 @@ public class ModulesAlphaComparator implements Comparator<Module>{
|
||||
|
||||
@Override
|
||||
public int compare(Module module1, Module module2) {
|
||||
final String name1 = module1.getName();
|
||||
final String name2 = module2.getName();
|
||||
return name1.compareToIgnoreCase(name2);
|
||||
if (module1 == null && module2 == null) return 0;
|
||||
if (module1 == null && module2 != null) return -1;
|
||||
if (module1 != null && module2 == null) return 1;
|
||||
return module1.getName().compareToIgnoreCase(module2.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,17 +153,26 @@ public class StringUtil extends StringUtilRt {
|
||||
int i = 0;
|
||||
|
||||
while (i < text.length()) {
|
||||
final int i1 = ignoreCase? indexOfIgnoreCase(text, oldS, i) : text.indexOf(oldS, i);
|
||||
if (i1 < 0) {
|
||||
if (i == 0) return text;
|
||||
final int index = ignoreCase? indexOfIgnoreCase(text, oldS, i) : text.indexOf(oldS, i);
|
||||
if (index < 0) {
|
||||
if (i == 0) {
|
||||
return text;
|
||||
}
|
||||
|
||||
newText.append(text, i, text.length());
|
||||
break;
|
||||
}
|
||||
else {
|
||||
if (newText == null) newText = new StringBuilder(text.length() - i);
|
||||
newText.append(text, i, i1);
|
||||
if (newText == null) {
|
||||
if (text.length() == oldS.length()) {
|
||||
return newS;
|
||||
}
|
||||
newText = new StringBuilder(text.length() - i);
|
||||
}
|
||||
|
||||
newText.append(text, i, index);
|
||||
newText.append(newS);
|
||||
i = i1 + oldS.length();
|
||||
i = index + oldS.length();
|
||||
}
|
||||
}
|
||||
return newText != null ? newText.toString() : "";
|
||||
@@ -1786,7 +1795,7 @@ public class StringUtil extends StringUtilRt {
|
||||
public static boolean contains(@NotNull CharSequence sequence, @NotNull CharSequence infix) {
|
||||
return indexOf(sequence, infix) >= 0;
|
||||
}
|
||||
|
||||
|
||||
@Contract(pure = true)
|
||||
public static int indexOf(@NotNull CharSequence sequence, @NotNull CharSequence infix) {
|
||||
for (int i = 0; i < sequence.length() - infix.length(); i++) {
|
||||
@@ -2448,7 +2457,7 @@ public class StringUtil extends StringUtilRt {
|
||||
* \r<br>
|
||||
* </blockquote>
|
||||
* will return the following array: foo\r\n, \n, bar\n, \r\n, baz\r, \r
|
||||
*
|
||||
*
|
||||
*/
|
||||
@NotNull
|
||||
@Contract(pure = true)
|
||||
|
||||
@@ -111,7 +111,7 @@ public class StringUtilTest extends TestCase {
|
||||
public void testFormatLinks() {
|
||||
assertEquals("<a href=\"http://a-b+c\">http://a-b+c</a>", StringUtil.formatLinks("http://a-b+c"));
|
||||
}
|
||||
|
||||
|
||||
public void testCopyHeapCharBuffer() {
|
||||
String s = "abcde";
|
||||
CharBuffer buffer = CharBuffer.allocate(s.length());
|
||||
@@ -124,7 +124,7 @@ public class StringUtilTest extends TestCase {
|
||||
assertNull(CharArrayUtil.fromSequenceWithoutCopying(buffer.subSequence(1, 5)));
|
||||
assertNull(CharArrayUtil.fromSequenceWithoutCopying(buffer.subSequence(1, 2)));
|
||||
}
|
||||
|
||||
|
||||
public void testTitleCase() {
|
||||
assertEquals("Couldn't Connect to Debugger", StringUtil.wordsToBeginFromUpperCase("Couldn't connect to debugger"));
|
||||
}
|
||||
@@ -198,7 +198,7 @@ public class StringUtilTest extends TestCase {
|
||||
assertEquals(Arrays.asList("aa"), Arrays.asList(StringUtil.splitByLinesKeepSeparators("aa")));
|
||||
assertEquals(Arrays.asList("\n", "\n", "aa\n", "\n", "bb\n", "cc\n", "\n"),
|
||||
Arrays.asList(StringUtil.splitByLinesKeepSeparators("\n\naa\n\nbb\ncc\n\n")));
|
||||
|
||||
|
||||
assertEquals(Arrays.asList("\r", "\r\n", "\r"), Arrays.asList(StringUtil.splitByLinesKeepSeparators("\r\r\n\r")));
|
||||
assertEquals(Arrays.asList("\r\n", "\r", "\r\n"), Arrays.asList(StringUtil.splitByLinesKeepSeparators("\r\n\r\r\n")));
|
||||
|
||||
@@ -224,4 +224,13 @@ public class StringUtilTest extends TestCase {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void testReplaceReturnReplacementIfTextEqualsToReplacedText() {
|
||||
String newS = "/tmp";
|
||||
assertSame(StringUtil.replace("$PROJECT_FILE$", "$PROJECT_FILE$".toLowerCase().toUpperCase() /* ensure new String instance */, newS), newS);
|
||||
}
|
||||
|
||||
public void testReplace() {
|
||||
assertEquals(StringUtil.replace("$PROJECT_FILE$/filename", "$PROJECT_FILE$", "/tmp"), "/tmp/filename");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user