Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent CCE NbGradleProjectImpl to DataObject #4943

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ public class GradleCliCompletionProvider implements CompletionProvider {
private static final Pattern PROP_INPUT = Pattern.compile("\\$\\{([\\w.]*)$"); //NOI18N
private static final String INPUT_TOKEN = "input:"; //NOI18N
private static final Set<GradleCommandLine.GradleOptionItem> GRADLE_OPTIONS;

//TODO: Move this one to GradleCommandLine in NetBeans 17
public static final String GRADLE_PROJECT_PROPERTY = "gradle-project"; //NOI18N

static {
Set<GradleCommandLine.GradleOptionItem> all = new HashSet<>();
Expand Down Expand Up @@ -105,7 +108,7 @@ protected void query(CompletionResultSet resultSet, Document doc, int caretOffse
}

Project project = null;
Object prop = doc.getProperty(Document.StreamDescriptionProperty);
Object prop = doc.getProperty(GRADLE_PROJECT_PROPERTY);
if (prop != null && prop instanceof Project) {
project = (Project) prop;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
*/
public final class GradleCommandLine implements Serializable {

private static final String GRADLE_PROJECT_PROPERTY = "gradle-project"; //NOI18N
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leftover ?
But maybe declare the property as public somewhere to have a shared constant.

Copy link
Contributor Author

@lkishalmi lkishalmi Nov 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kind of. Did not want to change the API so late in NB16 cycle, so marked that private and made the two now public non API one with a comment. Will pick that up for NB17

private static final Logger LOGGER = Logger.getLogger(GradleCommandLine.class.getName());
private static final String PROP_JVMARGS = "org.gradle.jvmargs"; // NOI18N
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
import java.util.stream.Collectors;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.Document;
import javax.swing.text.EditorKit;
import org.netbeans.api.project.Project;
import org.netbeans.modules.gradle.api.execute.GradleExecConfiguration;
import org.netbeans.modules.gradle.customizer.BuildActionsCustomizer;
import org.openide.NotificationLineSupport;
import org.openide.filesystems.FileUtil;
import org.openide.text.CloneableEditorSupport;
Expand All @@ -55,7 +55,7 @@ public NewConfigurationPanel(Project project, Supplier<Collection<? extends Grad
initComponents();
EditorKit kit = CloneableEditorSupport.getEditorKit("text/x-gradle-cli"); //NOI18N
txParameters.setEditorKit(kit);
txParameters.getDocument().putProperty(Document.StreamDescriptionProperty, project);
txParameters.getDocument().putProperty(BuildActionsCustomizer.GRADLE_PROJECT_PROPERTY, project);
if (isNew) {
txId.getDocument().addDocumentListener(this);
txId.getDocument().addDocumentListener(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import javax.swing.JList;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.Document;
import javax.swing.text.EditorKit;
import org.netbeans.api.project.Project;
import org.netbeans.modules.gradle.actions.CustomActionRegistrationSupport;
Expand All @@ -58,6 +57,9 @@
@Messages("TXT_CUSTOM=Custom...")
public class BuildActionsCustomizer extends javax.swing.JPanel {

//TODO: Move this one to GradleCommandLine in NetBeans 17
public static final String GRADLE_PROJECT_PROPERTY = "gradle-project"; //NOI18N

private static final String CUSTOM_ACTION = Bundle.TXT_CUSTOM();
private static final String CARD_NOSELECT = "empty"; //NOI18N
private static final String CARD_DETAILS = "details"; //NOI18N
Expand Down Expand Up @@ -103,7 +105,7 @@ public BuildActionsCustomizer(Project project, ConfigurationSnapshot snapshot) {
tfLabel.getDocument().addDocumentListener(applyListener);
EditorKit kit = CloneableEditorSupport.getEditorKit("text/x-gradle-cli"); //NOI18N
taArgs.setEditorKit(kit);
taArgs.getDocument().putProperty(Document.StreamDescriptionProperty, project);
taArgs.getDocument().putProperty(GRADLE_PROJECT_PROPERTY, project);
taArgs.getDocument().addDocumentListener(applyListener);
initDefaultModels();
comboReady = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
package org.netbeans.modules.gradle.execute;

import org.netbeans.modules.gradle.api.execute.GradleCommandLine;
import javax.swing.text.Document;
import javax.swing.text.EditorKit;
import org.netbeans.api.project.Project;
import org.netbeans.modules.gradle.actions.CustomActionRegistrationSupport;
import org.netbeans.modules.gradle.api.execute.GradleExecConfiguration;
import org.netbeans.modules.gradle.customizer.BuildActionsCustomizer;
import org.openide.text.CloneableEditorSupport;

/**
Expand All @@ -50,7 +50,7 @@ public GradleExecutorOptionsPanel(Project project) {
EditorKit kit = CloneableEditorSupport.getEditorKit("text/x-gradle-cli"); //NOI18N
epCLI.setEditorKit(kit);
if (project != null) {
epCLI.getDocument().putProperty(Document.StreamDescriptionProperty, project);
epCLI.getDocument().putProperty(BuildActionsCustomizer.GRADLE_PROJECT_PROPERTY, project);
} else {
tfRememberAs.setEnabled(false);
lbRememberAs.setEnabled(false);
Expand Down