mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
shorten command line: java 9 @argFile explicitly chosen
This commit is contained in:
+1
-1
@@ -67,6 +67,7 @@ public class ApplicationConfigurable extends SettingsEditor<ApplicationConfigura
|
||||
ClassBrowser.createApplicationClassBrowser(project, myModuleSelector).setField(getMainClassField());
|
||||
myVersionDetector = new JreVersionDetector();
|
||||
|
||||
myShortenClasspathModeCombo.setComponent(new ShortenClasspathModeCombo(myProject, myJrePathEditor));
|
||||
myAnchor = UIUtil.mergeComponentsWithAnchor(myMainClass, myCommonProgramParameters, myJrePathEditor, myModule,
|
||||
myShortenClasspathModeCombo);
|
||||
}
|
||||
@@ -136,7 +137,6 @@ public class ApplicationConfigurable extends SettingsEditor<ApplicationConfigura
|
||||
}
|
||||
}));
|
||||
myShortenClasspathModeCombo = new LabeledComponent<>();
|
||||
myShortenClasspathModeCombo.setComponent(new ShortenClasspathModeCombo(myProject));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -34,8 +34,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -100,11 +100,15 @@ public class JrePathEditor extends JPanel implements PanelWithAnchor {
|
||||
myComboBoxModel.add(new CustomJreItem(homePath));
|
||||
}
|
||||
}
|
||||
ComboBox comboBox = new ComboBox(myComboBoxModel, 100);
|
||||
ComboBox<JreComboBoxItem> comboBox = new ComboBox<>(myComboBoxModel, 100);
|
||||
comboBox.setEditable(true);
|
||||
comboBox.setRenderer(new ColoredListCellRendererWrapper<JreComboBoxItem>() {
|
||||
comboBox.setRenderer(new ColoredListCellRenderer<JreComboBoxItem>() {
|
||||
@Override
|
||||
protected void doCustomize(JList list, JreComboBoxItem value, int index, boolean selected, boolean hasFocus) {
|
||||
protected void customizeCellRenderer(@NotNull JList<? extends JreComboBoxItem> list,
|
||||
JreComboBoxItem value,
|
||||
int index,
|
||||
boolean selected,
|
||||
boolean hasFocus) {
|
||||
if (value != null) {
|
||||
value.render(this, selected);
|
||||
}
|
||||
@@ -195,6 +199,10 @@ public class JrePathEditor extends JPanel implements PanelWithAnchor {
|
||||
myLabel.setAnchor(anchor);
|
||||
}
|
||||
|
||||
public void addActionListener(ActionListener listener) {
|
||||
myPathField.getComboBox().addActionListener(listener);
|
||||
}
|
||||
|
||||
interface JreComboBoxItem {
|
||||
void render(SimpleColoredComponent component, boolean selected);
|
||||
String getPresentableText();
|
||||
|
||||
@@ -3,22 +3,22 @@ package com.intellij.execution.ui;
|
||||
|
||||
import com.intellij.execution.ShortenClasspath;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.projectRoots.ProjectJdkTable;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.ui.ComboBox;
|
||||
import com.intellij.ui.ColoredListCellRenderer;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class ShortenClasspathModeCombo extends ComboBox<ShortenClasspath> {
|
||||
private final Project myProject;
|
||||
|
||||
public ShortenClasspathModeCombo(Project project) {
|
||||
public ShortenClasspathModeCombo(Project project, JrePathEditor pathEditor) {
|
||||
myProject = project;
|
||||
addItem(null);
|
||||
for (ShortenClasspath mode : ShortenClasspath.values()) {
|
||||
addItem(mode);
|
||||
}
|
||||
initModel(null, pathEditor);
|
||||
setRenderer(new ColoredListCellRenderer<ShortenClasspath>() {
|
||||
@Override
|
||||
protected void customizeCellRenderer(@NotNull JList<? extends ShortenClasspath> list,
|
||||
@@ -27,7 +27,7 @@ public class ShortenClasspathModeCombo extends ComboBox<ShortenClasspath> {
|
||||
boolean selected,
|
||||
boolean hasFocus) {
|
||||
if (value == null) {
|
||||
ShortenClasspath defaultMode = ShortenClasspath.getDefaultMethod(myProject);
|
||||
ShortenClasspath defaultMode = ShortenClasspath.getDefaultMethod(myProject, getJdkRoot(pathEditor));
|
||||
append("user-local default: " + defaultMode.getPresentableName()).append(" - " + defaultMode.getDescription(), SimpleTextAttributes.GRAYED_ATTRIBUTES);
|
||||
}
|
||||
else {
|
||||
@@ -35,5 +35,39 @@ public class ShortenClasspathModeCombo extends ComboBox<ShortenClasspath> {
|
||||
}
|
||||
}
|
||||
});
|
||||
pathEditor.addActionListener(e -> {
|
||||
Object item = getSelectedItem();
|
||||
initModel((ShortenClasspath)item, pathEditor);
|
||||
});
|
||||
}
|
||||
|
||||
private void initModel(ShortenClasspath preselection, JrePathEditor pathEditor) {
|
||||
removeAllItems();
|
||||
|
||||
String jdkRoot = getJdkRoot(pathEditor);
|
||||
addItem(null);
|
||||
for (ShortenClasspath mode : ShortenClasspath.values()) {
|
||||
if (mode.isApplicable(jdkRoot)) {
|
||||
addItem(mode);
|
||||
}
|
||||
}
|
||||
|
||||
setSelectedItem(preselection);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String getJdkRoot(JrePathEditor pathEditor) {
|
||||
String rootPath = null;
|
||||
String jrePathOrName = pathEditor.getJrePathOrName();
|
||||
if (jrePathOrName != null) {
|
||||
Sdk configuredJdk = ProjectJdkTable.getInstance().findJdk(jrePathOrName);
|
||||
if (configuredJdk != null) {
|
||||
rootPath = configuredJdk.getHomePath();
|
||||
}
|
||||
else {
|
||||
rootPath = jrePathOrName;
|
||||
}
|
||||
}
|
||||
return rootPath;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user