Skip to content

Commit

Permalink
Removed HTML4J and used plain old swing components.
Browse files Browse the repository at this point in the history
Refactored the whole UI to go back to swing JDialog with a search field
and a jlist.
  • Loading branch information
Chris committed Jul 13, 2021
1 parent 6e6e7bb commit 01145c8
Show file tree
Hide file tree
Showing 159 changed files with 856 additions and 15,343 deletions.
24 changes: 24 additions & 0 deletions nbactions-netbeans-90.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<actions>
<action>
<actionName>build</actionName>
<packagings>
<packaging>*</packaging>
</packagings>
<goals>
<goal>install</goal>
<goal>-T1C</goal>
</goals>
</action>
<action>
<actionName>rebuild</actionName>
<packagings>
<packaging>*</packaging>
</packagings>
<goals>
<goal>clean</goal>
<goal>install</goal>
<goal>-T1C</goal>
</goals>
</action>
</actions>
107 changes: 1 addition & 106 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.chrisle.netbeans.plugins</groupId>
<artifactId>NbScratchFile</artifactId>
<version>1.8.0</version>
<version>2.0.0</version>
<packaging>nbm</packaging>
<name>NbScratchFile</name>
<description>&lt;h1&gt;Scratch Files for Netbeans (Required JDK 8 &gt; 1.8.0_122 - &lt;a href="https://github.com/Chris2011/NbScratchFile/issues/1#issuecomment-331884374"&gt;#1&lt;/a&gt;)&lt;/h1&gt;
Expand Down Expand Up @@ -34,22 +34,6 @@

&lt;p&gt;&lt;img src="/screenshots/ServiceNodeIntegration.gif?raw=true" alt="Alt text" /&gt;&lt;/p&gt;</description>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>**/ui/.projectKnowledge/**</exclude>
<exclude>**/ui/app/**</exclude>
<exclude>**/ui/build-scripts/**</exclude>
<exclude>**/ui/e2e/**</exclude>
<exclude>**/ui/nbproject/**</exclude>
<exclude>**/ui/tests/**</exclude>
<exclude>**/ui/node_modules/**</exclude>
<exclude>**/ui/node/**</exclude>
<exclude>**/ui/.tmp/**</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
Expand Down Expand Up @@ -77,39 +61,6 @@
<skipIfExist>true</skipIfExist>
</configuration>
</plugin>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>install node and yarn</id>
<goals>
<goal>install-node-and-yarn</goal>
</goals>
</execution>
<execution>
<id>yarn install</id>
<goals>
<goal>yarn</goal>
</goals>
</execution>
<execution>
<id>yarn run build-prod</id>
<goals>
<goal>yarn</goal>
</goals>
<configuration>
<arguments>run build-prod</arguments>
</configuration>
</execution>
</executions>
<configuration>
<nodeVersion>v14.16.1</nodeVersion>
<yarnVersion>v1.22.5</yarnVersion>
<workingDirectory>src/main/resources/org/chrisle/netbeans/plugins/nbscratchfile/ui</workingDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>nbm-maven-plugin</artifactId>
Expand Down Expand Up @@ -152,19 +103,6 @@
<verifyRuntime>skip</verifyRuntime>
</configuration>
</plugin>
<plugin>
<groupId>org.netbeans.html</groupId>
<artifactId>html4j-maven-plugin</artifactId>
<version>1.5.1</version>
<executions>
<execution>
<goals>
<goal>process-js-annotations</goal>
</goals>
<phase>process-classes</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
Expand Down Expand Up @@ -214,54 +152,11 @@
<artifactId>org-openide-util-lookup</artifactId>
<version>RELEASE82</version>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-netbeans-api-htmlui</artifactId>
<version>RELEASE82</version>
<type>jar</type>
<exclusions>
<exclusion>
<groupId>org.netbeans.external</groupId>
<artifactId>net-java-html-boot</artifactId>
</exclusion>
<exclusion>
<groupId>org.netbeans.external</groupId>
<artifactId>net-java-html-boot-fx</artifactId>
</exclusion>
<exclusion>
<groupId>org.netbeans.external</groupId>
<artifactId>net-java-html</artifactId>
</exclusion>
<exclusion>
<groupId>org.netbeans.external</groupId>
<artifactId>net-java-html-geo</artifactId>
</exclusion>
<exclusion>
<groupId>org.netbeans.external</groupId>
<artifactId>net-java-html-json</artifactId>
</exclusion>
<exclusion>
<groupId>org.netbeans.api</groupId>
<artifactId>org-netbeans-libs-javafx</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-modules</artifactId>
<version>RELEASE82</version>
</dependency>
<dependency>
<groupId>org.netbeans.html</groupId>
<artifactId>net.java.html.boot</artifactId>
<version>1.3</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.netbeans.external</groupId>
<artifactId>net-java-html</artifactId>
<version>RELEASE82</version>
</dependency>
</dependencies>
<properties>
<project.author>Chris2011</project.author>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import org.chrisle.netbeans.plugins.utils.WebViewDialog;
import javax.swing.JFrame;
import org.chrisle.netbeans.plugins.nbscratchfile.ui.FilterableFileTypeDialog;
import org.openide.awt.ActionID;
import org.openide.awt.ActionReference;
import org.openide.awt.ActionReferences;
Expand All @@ -42,12 +43,7 @@
})
@Messages("CTL_CreateScratchFile=New Scratch File...")
public final class CreateScratchFile implements ActionListener {
private static WebViewDialog _dialog;
public static final String viewPath = "/org/chrisle/netbeans/plugins/nbscratchfile/ui/dist/index.html";

public static void setDialog(WebViewDialog dialog) {
_dialog = dialog;
}
private final FilterableFileTypeDialog _dialog = new FilterableFileTypeDialog(new JFrame(), false);

@Override
public void actionPerformed(ActionEvent e) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,45 +20,36 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import javax.swing.JDialog;
import javax.swing.JOptionPane;
import org.chrisle.netbeans.plugins.utils.BaseWebViewDialogViewModel;
import org.netbeans.api.actions.Openable;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil;
import org.openide.loaders.DataObject;
import org.openide.util.Exceptions;

/**
*
* @author Chris2011
* @author Chrizzly
*/
public class NbScratchFileViewModel extends BaseWebViewDialogViewModel {
private int counter = 1;
private final JDialog dialog;
public class NbScratchFileViewModel {
private static int counter = 1;

public NbScratchFileViewModel(JDialog dialog) {
this.dialog = dialog;
}

public void setExt(String ext, String languageName) {
public static void setExt(String ext, String languageName) {
try {
Path path = Paths.get(String.format("%s/.netbeans/scratches/%s/scratch%d.%s", System.getProperty("user.home"), languageName, this.counter++, ext));
Path path = Paths.get(String.format("%s/.netbeans/scratches/%s/scratch%d.%s", System.getProperty("user.home"), languageName, NbScratchFileViewModel.counter, ext));
Files.createDirectories(path.getParent());
Files.createFile(path);

FileObject fo = FileUtil.toFileObject(FileUtil.normalizeFile(path.toFile()));
DataObject dataObject = DataObject.find(fo);
Openable openable = dataObject.getLookup().lookup(Openable.class);

dialog.setVisible(false);
openable.open();
NbScratchFileViewModel.counter = 1;
} catch (FileAlreadyExistsException e) {
this.setExt(ext, languageName);
NbScratchFileViewModel.counter++;
NbScratchFileViewModel.setExt(ext, languageName);
System.err.println("already exists: " + e.getMessage());
} catch (IOException ex) {
JOptionPane.showMessageDialog(null, ex.getMessage());
Exceptions.printStackTrace(ex);
ex.printStackTrace();
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* Copyright 2021 Chris.
*
* Licensed 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.chrisle.netbeans.plugins.nbscratchfile.model;

import java.io.IOException;
import java.net.URL;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import org.chrisle.netbeans.plugins.nbscratchfile.CreateScratchFile;

/**
*
* @author Chrl
*/
public class LanguageType {

private final String icon;
private String languageName;
private final String fileExt;
private boolean isPluginRequired = false;

public LanguageType(String languageName, String fileExt, boolean isPluginRequired) {
this.icon = "".equals(fileExt) ? languageName.toLowerCase() : fileExt;
this.languageName = languageName;
this.fileExt = "".equals(fileExt) ? languageName.toLowerCase() : fileExt;
this.isPluginRequired = isPluginRequired;
}

public String Icon() {
return this.icon.toLowerCase();
}

public Icon IconPath() throws IOException {
URL resource = CreateScratchFile.class.getResource(String.format("icons/%s.png", this.fileExt));

if (resource != null) {
return new ImageIcon(resource);
}

return new ImageIcon();
}

public String LanguageLabel() {
return String.format("%s (.%S) %s", this.languageName, this.fileExt, this.isPluginRequired ? "- plugin required" : "");
}

public String LanguageName() {
return this.languageName;
}

public void LanguageName(String value) {
this.languageName = value;
}

public String FileExt() {
return this.fileExt.toLowerCase();
}

// public boolean IsPluginRequired() {
// return this.isPluginRequired;
// }
public void setExt(LanguageType languageType) {
// NbScratchFileViewModel.setExt(languageType.FileExt, languageType.LanguageLabel);
}

// public showPluginRequiredMessage(): string {
// return this.isPluginRequired ? ' - plugin is required' : '';
// }
}
Loading

0 comments on commit 01145c8

Please sign in to comment.