Skip to content

Commit

Permalink
Better Gradle Project Creation Wizard
Browse files Browse the repository at this point in the history
  • Loading branch information
lkishalmi committed Apr 11, 2024
1 parent b5294e0 commit 2aa9006
Show file tree
Hide file tree
Showing 16 changed files with 1,081 additions and 280 deletions.
1 change: 1 addition & 0 deletions extide/gradle/manifest.mf
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ AutoUpdate-Show-In-Client: true
OpenIDE-Module: org.netbeans.modules.gradle/2
OpenIDE-Module-Layer: org/netbeans/modules/gradle/layer.xml
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/gradle/Bundle.properties
OpenIDE-Module-Java-Dependencies: Java > 17
OpenIDE-Module-Specification-Version: 2.40
3 changes: 2 additions & 1 deletion extide/gradle/nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@

file.reference.netbeans-gradle-tooling.jar=release/modules/gradle/netbeans-gradle-tooling.jar
is.autoload=true
javac.source=1.8
javac.source=17
javac.target=17
javac.compilerargs=-Xlint -Xlint:-serial
javadoc.arch=${basedir}/arch.xml
javadoc.apichanges=${basedir}/apichanges.xml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
*
* @author Laszlo Kishalmi
*/
class EscapeProcessingOutputStream extends OutputStream {
public class EscapeProcessingOutputStream extends OutputStream {

private static final RequestProcessor RP = new RequestProcessor(EscapeProcessingOutputStream.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.netbeans.api.project.Project;
import org.netbeans.modules.gradle.output.GradleProcessorFactory;
import org.openide.util.Lookup;
import org.openide.windows.IOColorPrint;
import org.openide.windows.IOColors;
Expand All @@ -57,13 +56,20 @@ public class GradlePlainEscapeProcessor implements EscapeProcessor {
public GradlePlainEscapeProcessor(InputOutput io, RunConfig cfg, boolean error) {
this.io = io;
output = new IODisplayer();
Project prj = cfg.getProject();
if (prj != null) {
processorsFromLookup(prj.getLookup(), cfg);
if (cfg != null) {
Project prj = cfg.getProject();
if (prj != null) {
processorsFromLookup(prj.getLookup(), cfg);
}
}
outType = error ? ERROR : OUTPUT;
processors.add(TASK_LINE_PROCESSOR);
processors.add(STATIC_STRING_PROCESSOR);
processors.add(GradleProcessorFactory.URL_PROCESSOR);
processors.add(GradleProcessorFactory.TASK_LINE_PROCESSOR);
processors.add(GradleProcessorFactory.STATIC_STRING_PROCESSOR);
}

public GradlePlainEscapeProcessor(InputOutput io, boolean error) {
this(io, null, error);
}

private void processorsFromLookup(Lookup lookup, RunConfig cfg) {
Expand Down Expand Up @@ -138,51 +144,4 @@ public void outputLineAction(OutputEvent ev) {

}

private static final OutputProcessor TASK_LINE_PROCESSOR = new OutputProcessor() {
final Pattern TASK_LINE = Pattern.compile("> Task (:[\\w:\\-]+)( [\\w\\-]+)?"); //NOI18N
@Override
public boolean processLine(OutputDisplayer out, String line) {
Matcher m = TASK_LINE.matcher(line);
boolean ret = m.matches();
if (ret) {
String task = m.group(1);
String state = m.group(2);
out.print("> Task "); //NOI18N
out.print(task);
if (state != null) {
OutputType type = LOG_WARNING;
if (state.endsWith("EXECUTED") || state.endsWith("UP-TO-DATE") || state.endsWith("FROM-CACHE")) { //NOI18N
type = LOG_SUCCESS;
} else if (state.endsWith("FAILED")) { //NOI18N
type = LOG_FAILURE;
}
out.print(state , null, type);
}
}
return ret;
}
};

private static final OutputProcessor STATIC_STRING_PROCESSOR = new OutputProcessor() {
private static final String BUILD_FAILED_MSG = "BUILD FAILED"; //NOI18N
private static final String BUILD_SUCCESS_MSG = "BUILD SUCCESSFUL"; //NOI18N
private static final String COD_INCUBATION_MSG = "Configuration on demand is an incubating feature."; //NOI18N
private static final String CONFIG_CACHE_MGS = "Configuration cache "; //NOI18N

@Override
public boolean processLine(OutputDisplayer out, String line) {
OutputType type = null;
if (line.startsWith(COD_INCUBATION_MSG) || line.startsWith(CONFIG_CACHE_MGS)) {
type = LOG_DEBUG;
} else if (line.startsWith(BUILD_SUCCESS_MSG)) {
type = LOG_SUCCESS;
} else if (line.startsWith(BUILD_FAILED_MSG)) {
type = LOG_FAILURE;
}
if (type != null) {
out.print(line, null, type);
}
return type != null;
}
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,12 @@ ProjectAttributesPanelVisual.btBrowse.text=Br&owse...
SubProjectPanelVisual.lbSubProjects.text=Sub-&Projects:
ProjectAttributesPanelVisual.cbInitWrapper.text=Initialize Gradle Wrapper
SubProjectPanelVisual.lbSubProjectHint.text=<html>Hints:<br/>Each non-empty line is treaded as a sub-project to be created.<br/>\nThe format of a line is:<p>\n[rel/path/]<b>&lt;sub-project name&gt;</b>[&lt;whitespace&gt;]&lt;Description&gt;]
GradleInitPanelVisual.btBrowse.text=Browse...
GradleInitPanelVisual.lbLocation.text=Project Location:
GradleInitPanelVisual.lbProjectName.text=Project Name:
GradleInitPanelVisual.lbProjectFolder.text=Project Folder:
GradleInitPanelVisual.lbPackageName.text=Package Name:
GradleInitPanelVisual.lbJavaVersion.text=Java Version:
GradleInitPanelVisual.lbTestFramework.text=Test Framework:
GradleInitPanelVisual.cbComments.text=Generate Comments
GradleInitPanelVisual.lbDSL.text=Gradle DSL
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 org.netbeans.modules.gradle.newproject;

import javax.swing.event.ChangeListener;
import org.openide.WizardDescriptor;
import org.openide.util.HelpCtx;

/**
*
* @author lkishalmi
*/
public class GradleInitPanel implements WizardDescriptor.Panel<WizardDescriptor> {

private GradleInitPanelVisual initPanel;

@Override
public GradleInitPanelVisual getComponent() {
if (initPanel == null) {
initPanel = new GradleInitPanelVisual();
}
return initPanel;
}

@Override
public HelpCtx getHelp() {
return HelpCtx.DEFAULT_HELP;
}

@Override
public void readSettings(WizardDescriptor settings) {
initPanel.read(settings);
}

@Override
public void storeSettings(WizardDescriptor settings) {
initPanel.write(settings);
}

@Override
public boolean isValid() {
return true;
}

@Override
public void addChangeListener(ChangeListener l) {
}

@Override
public void removeChangeListener(ChangeListener l) {
}

}
Loading

0 comments on commit 2aa9006

Please sign in to comment.