Skip to content

Commit

Permalink
Use modern coding style in maven.htmlui module
Browse files Browse the repository at this point in the history
  • Loading branch information
dukescript committed Sep 1, 2020
1 parent b53e2cf commit 6066163
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 61 deletions.
3 changes: 2 additions & 1 deletion javafx/maven.htmlui/nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
javac.source=1.8
javac.source=14
javac.target=1.8
javac.compilerargs=-Xlint -Xlint:-serial
is.autoload=true
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ static class ArchetypeViewModel {
static void init(WizardData data,
Boolean android, Boolean ios, Boolean web, Boolean netbeans
) {
File nbHome = new File(System.getProperty("netbeans.home"));
var nbHome = new File(System.getProperty("netbeans.home"));
data.setNbhome(nbHome.getParent());

final ArchetypeData koArch = new ArchetypeData(
Expand Down Expand Up @@ -120,7 +120,7 @@ static void init(WizardData data,
);
data.getArchetypes().add(visArch);
data.setIosMoe(true);
String srvPath = Boolean.getBoolean("staging.archetypes") ? "stage" : "archetypes";
var srvPath = Boolean.getBoolean("staging.archetypes") ? "stage" : "archetypes";
data.loadArchetypes(srvPath);
data.setAndroidSdkPath(MavenUtilities.getDefault().readAndroidSdkPath());
}
Expand All @@ -142,7 +142,7 @@ static String archetypeVersion(ArchetypeData archetype) {

@ComputedProperty
static String archetypeOpen(ArchetypeData archetype) {
StringBuilder sb = new StringBuilder();
var sb = new StringBuilder();
if (archetype != null) {
for (String item : archetype.getOpen()) {
if (sb.length() > 0) {
Expand Down Expand Up @@ -229,29 +229,26 @@ static void cleanWarning(WizardData data) {

@Function
static void chooseAndroidSDK(final WizardData data) {
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
FileChooserBuilder b = new FileChooserBuilder(WizardData.class).
setSelectionApprover(new FileChooserBuilder.SelectionApprover() {
@Override
public boolean approve(File[] files) {
if (files.length != 1) {
return false;
}
return isValidAndroidSdk(files[0]);
EventQueue.invokeLater(() -> {
var b = new FileChooserBuilder(WizardData.class).
setSelectionApprover(new FileChooserBuilder.SelectionApprover() {
@Override
public boolean approve(File[] files) {
if (files.length != 1) {
return false;
}
}).
setDirectoriesOnly(true);
if (data.getAndroidSdkPath() != null) {
b.setDefaultWorkingDirectory(new File(data.getAndroidSdkPath()));
}
JFileChooser fc = b.createFileChooser();
int res = fc.showOpenDialog(null);
if (res == JFileChooser.APPROVE_OPTION) {
data.setAndroidSdkPath(fc.getSelectedFile().getPath());
MavenUtilities.getDefault().writeAndroidSdkPath(fc.getSelectedFile().getPath());
}
return isValidAndroidSdk(files[0]);
}
}).
setDirectoriesOnly(true);
if (data.getAndroidSdkPath() != null) {
b.setDefaultWorkingDirectory(new File(data.getAndroidSdkPath()));
}
var fc = b.createFileChooser();
int res = fc.showOpenDialog(null);
if (res == JFileChooser.APPROVE_OPTION) {
data.setAndroidSdkPath(fc.getSelectedFile().getPath());
MavenUtilities.getDefault().writeAndroidSdkPath(fc.getSelectedFile().getPath());
}
});
}
Expand All @@ -263,7 +260,7 @@ private static boolean isValidAndroidSdk(File dir) {

@OnPropertyChange(value = "netbeans")
static void verifyNbInstallationDefined(WizardData data) {
boolean ok = !data.isNetbeans() || MavenUtilities.getDefault().readNetBeansInstallation() != null;
var ok = !data.isNetbeans() || MavenUtilities.getDefault().readNetBeansInstallation() != null;
data.setNbInstallationDefined(ok);
}

Expand All @@ -279,7 +276,7 @@ static void deviceSelected(WizardData data) {
private static final RequestProcessor DEVICES = new RequestProcessor("List iOS Devices");
@OnPropertyChange(value = "ios")
static void verifySimulator(WizardData data) {
final List<Device> arr = data.getAvailableSimulators();
var arr = data.getAvailableSimulators();
DEVICES.post(() -> {
DeviceType.listDevices(arr);
String selectedDevice = MavenUtilities.getDefault().readMoeDevice();
Expand All @@ -302,32 +299,29 @@ static void verifySimulator(WizardData data) {

@Function
static void defineNbInstallation(final WizardData data) {
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
FileChooserBuilder b = new FileChooserBuilder(WizardData.class).
setSelectionApprover(new FileChooserBuilder.SelectionApprover() {
@Override
public boolean approve(File[] files) {
if (files.length != 1) {
return false;
}
File platform = new File(files[0], "platform");
File lib = new File(platform, "lib");
File bootJar = new File(lib, "boot.jar");
return bootJar.exists();
EventQueue.invokeLater(() -> {
var b = new FileChooserBuilder(WizardData.class).
setSelectionApprover(new FileChooserBuilder.SelectionApprover() {
@Override
public boolean approve(File[] files) {
if (files.length != 1) {
return false;
}
}).
setDirectoriesOnly(true);
JFileChooser fc = b.createFileChooser();
File f = new File(System.getProperty("netbeans.home"));
fc.setCurrentDirectory(f);
int res = fc.showOpenDialog(null);
if (res == JFileChooser.APPROVE_OPTION) {
MavenUtilities.getDefault().writeNetBeansInstallation(f.getParent());
if (MavenUtilities.getDefault().readNetBeansInstallation() != null) {
data.setNbInstallationDefined(true);
}
File platform = new File(files[0], "platform");
File lib = new File(platform, "lib");
File bootJar = new File(lib, "boot.jar");
return bootJar.exists();
}
}).
setDirectoriesOnly(true);
var fc = b.createFileChooser();
var f = new File(System.getProperty("netbeans.home"));
fc.setCurrentDirectory(f);
int res = fc.showOpenDialog(null);
if (res == JFileChooser.APPROVE_OPTION) {
MavenUtilities.getDefault().writeNetBeansInstallation(f.getParent());
if (MavenUtilities.getDefault().readNetBeansInstallation() != null) {
data.setNbInstallationDefined(true);
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ private MacUtilities() {
})
static void listDevices(List<Device> collectTo) {
collectTo.clear();
Device loading = new Device().assignId(ID_UNKNOWN).
var loading = new Device().assignId(ID_UNKNOWN).
assignName(Bundle.MSG_Loading()).
assignInfo(Bundle.MSG_Loading());
collectTo.add(loading);

ProcessBuilder pb = ProcessBuilder.getLocal();
var pb = ProcessBuilder.getLocal();
pb.setExecutable("instruments");
pb.setArguments(Arrays.asList("-s", "devices"));
pb.setRedirectErrorStream(true);
Expand All @@ -75,7 +75,7 @@ static void listDevices(List<Device> collectTo) {
}


final InputStream is = p.getInputStream();
var is = p.getInputStream();
parseDevices(collectTo, is);
p.destroy();
collectTo.remove(loading);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,10 @@ private String readProperty(final String tag) {
if (!this.settings.isFile()) {
return null;
}
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder;
dBuilder = dbFactory.newDocumentBuilder();
Document settingsDoc = dBuilder.parse(this.settings);
NodeList elementsByTagName = settingsDoc.getElementsByTagName(tag);
var dbFactory = DocumentBuilderFactory.newInstance();
var dBuilder = dbFactory.newDocumentBuilder();
var settingsDoc = dBuilder.parse(this.settings);
var elementsByTagName = settingsDoc.getElementsByTagName(tag);
if (elementsByTagName.getLength() >0) return elementsByTagName.item(0).getTextContent();
return null;
} catch (NoSuchFileException ex) {
Expand Down

0 comments on commit 6066163

Please sign in to comment.