Unverified Commit 00d6d969 authored by Neil C Smith's avatar Neil C Smith Committed by GitHub
Browse files

Merge pull request #3610 from apache/delivery

Sync delivery to release130 for 13-rc4
parents b3553a6f 677372e1
......@@ -26,8 +26,8 @@ import java.awt.Image;
import java.awt.event.ActionEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import javax.swing.AbstractAction;
import javax.swing.Action;
......@@ -48,6 +48,8 @@ import org.openide.util.RequestProcessor;
import static org.netbeans.modules.gradle.nodes.Bundle.*;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.netbeans.api.project.ProjectUtils;
import org.netbeans.modules.gradle.api.GradleBaseProject;
import org.netbeans.modules.gradle.spi.Utils;
......@@ -59,6 +61,8 @@ import org.openide.nodes.Children;
*/
public class SubProjectsNode extends AbstractNode {
private static final Logger LOG = Logger.getLogger(SubProjectsNode.class.getName());
@StaticResource
private static final String SP_BADGE
= "org/netbeans/modules/gradle/resources/gradle-large-badge.png";
......@@ -122,13 +126,21 @@ public class SubProjectsNode extends AbstractNode {
protected boolean createKeys(final List<Project> projects) {
Set<Project> containedProjects = ProjectUtils.getContainedProjects(project, false);
projects.addAll(containedProjects);
if (containedProjects != null) {
projects.addAll(containedProjects);
} else {
LOG.log(Level.FINE, "No ProjectContainerProvider in the lookup of: {0}", project);
}
return true;
}
@Override
protected Node createNodeForKey(Project key) {
Set<Project> containedProjects = ProjectUtils.getContainedProjects(key, false);
if (containedProjects == null) {
containedProjects = Collections.emptySet();
LOG.log(Level.FINE, "No ProjectContainerProvider in the lookup of: {0}", project);
}
GradleBaseProject gbp = GradleBaseProject.get(project);
String prefix = (gbp != null && !gbp.isRoot() ? gbp.getPath() : "") + ':';
Children ch = containedProjects.isEmpty() ? Children.LEAF : Children.create(new SubProjectsChildFactory(key), true);
......@@ -182,9 +194,7 @@ public class SubProjectsNode extends AbstractNode {
@Override
public Action[] getActions(boolean b) {
ArrayList<Action> lst = new ArrayList<Action>();
lst.add(OpenProjectAction.SINGLETON);
return lst.toArray(new Action[lst.size()]);
return new Action[]{OpenProjectAction.SINGLETON};
}
@Override
......
......@@ -29,6 +29,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import javax.swing.Action;
import javax.swing.Icon;
......@@ -242,7 +243,15 @@ public class ElementNode extends AbstractNode {
Node[] children = ch.getNodes();
for (int i = 0; i < children.length; i++) {
ElementNode c = (ElementNode) children[i];
if (this.getFileObject() != c.getDescription().getElementHandle().getFileObject()) {
// The promise of the API is broken at several places in the
// codebase and thus this needs to be guarded. The assert is in
// place to find the violating places.
assert c.getDescription().getElementHandle() != null;
@SuppressWarnings("null")
FileObject childFileObject = c.getDescription().getElementHandle() != null
? c.getDescription().getElementHandle().getFileObject()
: null;
if (! Objects.equals(this.getFileObject(), childFileObject)) {
// e.g. inherited items may be in another file
// in such a case, incorrect item is highlighted on the navigator window if the FileObjects are not checked
continue;
......
......@@ -24,13 +24,18 @@ import java.util.Collections;
import java.util.List;
import java.util.Set;
import javax.swing.ImageIcon;
import org.netbeans.lib.editor.util.StringEscapeUtils;
import org.netbeans.modules.csl.api.ElementHandle;
import org.netbeans.modules.csl.api.ElementKind;
import org.netbeans.modules.csl.api.HtmlFormatter;
import org.netbeans.modules.csl.api.Modifier;
import org.netbeans.modules.csl.api.OffsetRange;
import org.netbeans.modules.csl.api.StructureItem;
import org.netbeans.modules.csl.spi.ParserResult;
import org.netbeans.modules.css.editor.csl.CssLanguage;
import org.netbeans.modules.css.editor.module.spi.FeatureContext;
import org.netbeans.modules.parsing.api.Snapshot;
import org.openide.filesystems.FileObject;
import org.openide.util.NbBundle;
/**
......@@ -39,29 +44,40 @@ import org.openide.util.NbBundle;
*/
public abstract class TopLevelStructureItem implements StructureItem {
private final ElementHandle elementHandle;
public TopLevelStructureItem(String name, FileObject fileObject) {
this.elementHandle = new TopElementHandle(fileObject, name);
}
@Override
public String getName() {
return elementHandle.getName();
}
@Override
public String getSortText() {
return getName();
return this.elementHandle.getName();
}
@Override
public String getHtml(HtmlFormatter formatter) {
return getName();
return StringEscapeUtils.escapeHtml(this.elementHandle.getName());
}
@Override
public ElementHandle getElementHandle() {
return null;
return elementHandle;
}
@Override
public ElementKind getKind() {
return ElementKind.PACKAGE; //xxx fix - add mode categories to csl
return elementHandle.getKind();
}
@Override
public Set<Modifier> getModifiers() {
return Collections.emptySet();
return elementHandle.getModifiers();
}
@Override
......@@ -102,9 +118,10 @@ public abstract class TopLevelStructureItem implements StructureItem {
public abstract static class ChildrenSetStructureItem extends TopLevelStructureItem {
private Collection<StructureItem> items;
private final Collection<StructureItem> items;
public ChildrenSetStructureItem(Collection<StructureItem> items) {
public ChildrenSetStructureItem(String name, FileObject fileObject, Collection<StructureItem> items) {
super(name, fileObject);
this.items = items;
}
......@@ -116,15 +133,17 @@ public abstract class TopLevelStructureItem implements StructureItem {
public abstract static class ChildrenListStructureItem extends TopLevelStructureItem {
private List<StructureItem> items;
private final List<StructureItem> items;
public ChildrenListStructureItem(List<StructureItem> items) {
public ChildrenListStructureItem(String name, FileObject fileObject, List<StructureItem> items) {
super(name, fileObject);
this.items = items;
}
@Override
@SuppressWarnings("ReturnOfCollectionOrArrayField")
public List<? extends StructureItem> getNestedItems() {
return items;
return new ArrayList<>(items);
}
}
......@@ -133,15 +152,12 @@ public abstract class TopLevelStructureItem implements StructureItem {
private final Snapshot snapshot;
public Rules(List<StructureItem> children, FeatureContext context) {
super(children);
super(NbBundle.getMessage(TopLevelStructureItem.class, "Rules"), //NOI18N
context.getSnapshot().getSource().getFileObject(),
children);
this.snapshot = context.getSnapshot();
}
@Override
public String getName() {
return NbBundle.getMessage(TopLevelStructureItem.class, "Rules"); //NOI18N
}
//return the element range 0 - source lenght to ensure the recursive
//leaf node search mechanism in CSL navigator will try to match
//the rule children
......@@ -157,75 +173,91 @@ public abstract class TopLevelStructureItem implements StructureItem {
}
public static class Elements extends ChildrenSetStructureItem {
public Elements(Collection<StructureItem> items) {
super(items);
}
@Override
public String getName() {
return NbBundle.getMessage(TopLevelStructureItem.class, "Elements"); //NOI18N
super(NbBundle.getMessage(TopLevelStructureItem.class, "Elements"), null, items); //NOI18N
}
}
public static class Classes extends ChildrenSetStructureItem {
public Classes(Collection<StructureItem> children) {
super(children);
}
@Override
public String getName() {
return NbBundle.getMessage(TopLevelStructureItem.class, "Classes"); //NOI18N
super(NbBundle.getMessage(TopLevelStructureItem.class, "Classes"), null, children);
}
}
public static class Ids extends ChildrenSetStructureItem {
public Ids(Collection<StructureItem> children) {
super(children);
}
@Override
public String getName() {
return NbBundle.getMessage(TopLevelStructureItem.class, "Ids"); //NOI18N
super(NbBundle.getMessage(TopLevelStructureItem.class, "Ids"), null, children); //NOI18N
}
}
public static class Namespaces extends ChildrenListStructureItem {
public Namespaces(List<StructureItem> children) {
super(children);
super(NbBundle.getMessage(TopLevelStructureItem.class, "Namespaces"), null, children); //NOI18N
}
@Override
public String getName() {
return NbBundle.getMessage(TopLevelStructureItem.class, "Namespaces"); //NOI18N
}
}
public static class AtRules extends ChildrenListStructureItem {
public AtRules(List<StructureItem> children) {
super(children);
}
@Override
public String getName() {
return NbBundle.getMessage(TopLevelStructureItem.class, "AtRules"); //NOI18N
super(NbBundle.getMessage(TopLevelStructureItem.class, "AtRules"), null, children); //NOI18N
}
}
@NbBundle.Messages("imports=Imports")
public static class Imports extends ChildrenSetStructureItem {
public Imports(Collection<StructureItem> children) {
super(children);
super(Bundle.imports(), null, children);
}
}
private static class TopElementHandle implements ElementHandle {
private final FileObject fileObject;
private final String name;
public TopElementHandle(FileObject fileObject, String name) {
this.fileObject = fileObject;
this.name = name;
}
@Override
public FileObject getFileObject() {
return fileObject;
}
@Override
public String getMimeType() {
return CssLanguage.CSS_MIME_TYPE;
}
@Override
public String getName() {
return Bundle.imports();
return name;
}
@Override
public String getIn() {
return null;
}
@Override
public ElementKind getKind() {
return ElementKind.PACKAGE; //xxx fix - add mode categories to csl
}
@Override
public Set<Modifier> getModifiers() {
return Collections.emptySet();
}
@Override
public boolean signatureEquals(ElementHandle handle) {
return false;
}
@Override
public OffsetRange getOffsetRange(ParserResult result) {
return new OffsetRange(-1, -1);
}
}
}
......@@ -28,9 +28,12 @@ import org.netbeans.modules.csl.api.ElementHandle;
import org.netbeans.modules.csl.api.ElementKind;
import org.netbeans.modules.csl.api.HtmlFormatter;
import org.netbeans.modules.csl.api.Modifier;
import org.netbeans.modules.csl.api.OffsetRange;
import org.netbeans.modules.csl.api.StructureItem;
import org.netbeans.modules.csl.spi.ParserResult;
import org.netbeans.modules.css.editor.module.spi.FeatureContext;
import org.netbeans.modules.parsing.api.Snapshot;
import org.openide.filesystems.FileObject;
import org.openide.util.ImageUtilities;
import org.openide.util.NbBundle;
......@@ -42,7 +45,18 @@ public abstract class CPCategoryStructureItem implements StructureItem {
//let the CP items to be at the top of the navigator
private static final String SORT_TEXT_PREFIX = "0_"; //NOI18N
private final ElementHandle elementHandle;
public CPCategoryStructureItem(ElementHandle elementHandle) {
this.elementHandle = elementHandle;
}
@Override
public String getName() {
return this.elementHandle.getName();
}
@Override
public String getSortText() {
return new StringBuilder().append(SORT_TEXT_PREFIX).append(getName()).toString();
......@@ -55,17 +69,17 @@ public abstract class CPCategoryStructureItem implements StructureItem {
@Override
public ElementHandle getElementHandle() {
return null;
return elementHandle;
}
@Override
public ElementKind getKind() {
return ElementKind.PACKAGE; //xxx fix - add mode categories to csl
return elementHandle.getKind();
}
@Override
public Set<Modifier> getModifiers() {
return Collections.emptySet();
return elementHandle.getModifiers();
}
@Override
......@@ -104,12 +118,12 @@ public abstract class CPCategoryStructureItem implements StructureItem {
return true;
}
public abstract static class ChildrenSetStructureItem extends CPCategoryStructureItem {
private Collection<StructureItem> items;
private final Collection<StructureItem> items;
public ChildrenSetStructureItem(Collection<StructureItem> items) {
public ChildrenSetStructureItem(ElementHandle elementHandle, Collection<StructureItem> items) {
super(elementHandle);
this.items = items;
}
......@@ -123,31 +137,26 @@ public abstract class CPCategoryStructureItem implements StructureItem {
public static class Variables extends ChildrenSetStructureItem {
private static final ImageIcon ICON = new ImageIcon(ImageUtilities.loadImage("org/netbeans/modules/css/prep/editor/resources/variables.gif")); //NOI18N
public Variables(Set<StructureItem> children) {
super(children);
public Variables(Set<StructureItem> children, FeatureContext context) {
super(new DummyElementHandle(context.getFileObject(), Bundle.navigator_item_name_variables()), children);
}
@Override
public ImageIcon getCustomIcon() {
return ICON;
}
@Override
public String getName() {
return Bundle.navigator_item_name_variables();
}
}
@NbBundle.Messages("navigator.item.name.mixins=Mixins")
public static class Mixins extends ChildrenSetStructureItem {
private static final ImageIcon ICON = new ImageIcon(ImageUtilities.loadImage("org/netbeans/modules/css/prep/editor/resources/methods.gif")); //NOI18N
private FeatureContext context;
private final FeatureContext context;
public Mixins(Collection<StructureItem> items, FeatureContext context) {
super(items);
super(new DummyElementHandle(context.getFileObject(), Bundle.navigator_item_name_mixins()), items);
this.context = context;
}
......@@ -156,11 +165,6 @@ public abstract class CPCategoryStructureItem implements StructureItem {
return ICON;
}
@Override
public String getName() {
return Bundle.navigator_item_name_mixins();
}
//return the element range 0 - source lenght to ensure the recursive
//leaf node search mechanism in CSL navigator will try to match
//the rule children
......@@ -175,4 +179,54 @@ public abstract class CPCategoryStructureItem implements StructureItem {
return s.getOriginalOffset(s.getText().length());
}
}
private static class DummyElementHandle implements ElementHandle {
private final FileObject fileObject;
private final String name;
public DummyElementHandle(FileObject fileObject, String name) {
this.fileObject = fileObject;
this.name = name;
}
@Override
public FileObject getFileObject() {
return fileObject;
}
@Override
public String getMimeType() {
return "text/css";
}
@Override
public String getName() {
return name;
}
@Override
public String getIn() {
return null;
}
@Override
public ElementKind getKind() {
return ElementKind.PACKAGE; //xxx fix - add mode categories to csl
}
@Override
public Set<Modifier> getModifiers() {
return Collections.emptySet();
}
@Override
public boolean signatureEquals(ElementHandle handle) {
return false;
}
@Override
public OffsetRange getOffsetRange(ParserResult result) {
return new OffsetRange(-1, -1);
}
}
}
......@@ -712,7 +712,7 @@ public class CPCssEditorModule extends CssEditorModule {
}
if (!vars.isEmpty()) {
result.add(new CPCategoryStructureItem.Variables(vars));
result.add(new CPCategoryStructureItem.Variables(vars, context));
}
if (!mixins.isEmpty()) {
result.add(new CPCategoryStructureItem.Mixins(mixins, context));
......
......@@ -601,7 +601,7 @@ ACSD_librariesLocation=Folder containing location of the library definition file
ACSD_jButtonEdit=Edit classpath items
ACSD_BuildJarAfterCompile=Build JAR after compiling option
LBL_CustomizeRun_Enable_Quick_Run=Enable Quick Run
CustomizerCompile.CompileOnSave=Compile on &Save (requires nb-javac plugin)
CustomizerCompile.CompileOnSave=Compile on &Save
AD_CustomizerCompile.CompileOnSave=If selected, files are compiled when you save them. This option saves you time when you run or debug your application in the IDE.
LBL_CompileOnSaveDescription=<html>If selected, files are compiled when you save them.<br>\
This option saves you time when you run or debug your application in the IDE.<br>\
......
......@@ -601,7 +601,7 @@ ACSD_librariesLocation=Folder containing location of the library definition file
ACSD_jButtonEdit=Edit classpath items
ACSD_BuildJarAfterCompile=Build JAR after compiling option
LBL_CustomizeRun_Enable_Quick_Run=Enable Quick Run
CustomizerCompile.CompileOnSave=Compile on &Save (requires nb-javac plugin)
CustomizerCompile.CompileOnSave=Compile on &Save
AD_CustomizerCompile.CompileOnSave=If selected, files are compiled when you save them. This option saves you time when you run or debug your application in the IDE.
LBL_CompileOnSaveDescription=<html>If selected, files are compiled when you save them.<br>\
This option saves you time when you run or debug your application in the IDE.<br>\
......
......@@ -83,7 +83,7 @@ public class JBrowseModule extends ModuleInstall {
Dialog[] d = new Dialog[1];
DialogDescriptor dd = new DialogDescriptor(Bundle.DESC_FeaturesLimited(), Bundle.TITLE_FeaturesLimited(), true, new Object[] {install, DialogDescriptor.CANCEL_OPTION}, install, DialogDescriptor.DEFAULT_ALIGN, HelpCtx.DEFAULT_HELP, evt -> {
if (install.equals(evt.getActionCommand())) {
PluginManager.installSingle("org.netbeans.lib.nbjavac", Bundle.DN_nbjavac());
PluginManager.installSingle("org.netbeans.libs.nbjavacapi", Bundle.DN_nbjavac());
}
d[0].setVisible(false);
});
......@@ -92,7 +92,7 @@ public class JBrowseModule extends ModuleInstall {
} catch (HeadlessException ex) {
Exceptions.printStackTrace(Exceptions.attachSeverity(ex, Level.FINE));
}
prefs.putBoolean(KEY_WARNING_SHOWN, true);
// prefs.putBoolean(KEY_WARNING_SHOWN, true); // show warning on every boot until fixed
}
});
});
......
......@@ -142,7 +142,7 @@ HINT_ApplicationCoS=<html>Classes compiled with the Compile on Save feature in t
RunJarPanel.lblConfiguration.text=&Configuration:
ActionMappings.txtPackagings.text=
ActionMappings.lblPackagings.text=Supported Packagings:
CompilePanel.cbCompileOnSave.text=Compile on &Save (requires nb-javac plugin)
CompilePanel.cbCompileOnSave.text=Compile on &Save
CompilePanel.btnLearnMore.text=<html><a href="">Learn More about Compile On Save feature in Maven projects</a></html>
ActionMappings.jButton1.text=Show in Toolbar
RunJarPanel.txtVMOptions.AccessibleContext.accessibleDescription=VM options
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment