Category: Programming

Learning how to do raw logic programming

Learning how to do raw logic programming, convert the programming logic directly into logic gates. Found these two book in central library. The first one teach you everything you need to build up logic design. In undergrade year one, i remember uni was teaching us k-map and state diagram but without telling us why they are important and the use-case. I totally get messed and lost in space. Now I finally know how to use them. The verilog book  teach you how to convert programming looping into logic gates, but this book has too much text.

read count : 14

Netbeans in my 2017 MacBook Pro 15 keep CPU over 100% for nothing

Netbeans in my 2017 MacBook Pro 15 keep CPU over 100% for nothing, no task in progress window and the “slowness detection” has nothing, if using it without AC power, it eats up the battery very quick.

netbeans is not optimize for power
If netbeans detected it is running slowly, it will show a notification. But in this case, no notification at all !

read count : 8

[Solved] JRebel can’t reload jsp in netbeans of spring boot project

JRebel can’t reload jsp in netbeans of spring boot project, asked in jrebel forum but seems no one can answer. I finally found a way to fix it. Don’t execute the “spring-boot:run” goal, directly run your main class, this make jrebel able to reload jsp/css/class, just tested. No matter you put your static files in src/main/webapp or src/main/resources, it just works.

dont touch the jrebel.xml

read count : 36

netbeans api to read bookmark line numbers

Below code can read out bookmark line numbers for netbeans. For Java project, the bookmark line number are stored in nbproject/private/private.xml. If it is maven project, the private.xml is not exist but this code still work, there must be some place to store the bookmark info but I just don’t know. These code has a weak point, it won’t read the latest line numbers unless you close the project/netbeans.

			Project project = NetbeansUtil.getProject();
			AuxiliaryConfiguration config = ProjectUtils.getAuxiliaryConfiguration(project);
			org.w3c.dom.Element element = config.getConfigurationFragment("editor-bookmarks", "http://www.netbeans.org/ns/editor-bookmarks/2", false);
			ModuleLib.log("element=" + element);
			if (element != null) {
				NodeList list = element.getElementsByTagNameNS("http://www.netbeans.org/ns/editor-bookmarks/2", "bookmark");
				for (int x = 0; x < list.getLength(); x++) {
					org.w3c.dom.Element enEl = (org.w3c.dom.Element) list.item(x);
					String lineNo = enEl.getTextContent().trim();
					ModuleLib.log("line no=" + lineNo);
				}
			}

read count : 9

Netbeans plugins, able to compile and build != able to install in a clean netbeans

People reported my minimal plugins can’t install in their netbeans. I concluded these:

1) able to compile and build NOT EQUAL to able to install in a clean netbeans
2) able to install your plugin in your netbeans NOT EQUAL to able to install in a clean netbeans

When you meet this error : Project depends on packages not accessible at runtime

Just add the library to in pom

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>com.github.mcheung63</groupId>
        <artifactId>netbeans-minimap</artifactId>
        <version>2.8</version>
        <packaging>nbm</packaging>
        <name>Minimap</name>
        <description>Display the code minimap, programmer can overlook their code.</description>
        <developers>
                <developer>
                        <name>Peter</name>
                        <email>mcheung63@hotmail.com</email>
                        <roles>
                                <role>Founder</role>
                        </roles>
                </developer>
        </developers>
        <build>
                <plugins>
                        <plugin>
                                <groupId>org.codehaus.mojo</groupId>
                                <artifactId>nbm-maven-plugin</artifactId>
                                <version>3.13</version>
                                <extensions>true</extensions>
                                <configuration>
                                        <!--<useOSGiDependencies>false</useOSGiDependencies>-->
                                        <moduleDependencies>
                                                <dependency>
                                                        <id>org.netbeans.api:org-netbeans-modules-editor-lib2</id>
                                                        <type>impl</type>
                                                </dependency>

read count : 20

old netbeans api code to get each line

g.setColor(Color.red);
		int lastLineNo = -1;
		while (hq.moveNext()) {
			AttributeSet as = hq.getAttributes();
			if (as != null) {
				try {
					lineNo = NbDocument.findLineNumber((StyledDocument) document, hq.getStartOffset());
					if (lineNo != lastLineNo) {
						lastLineNo = lineNo;
						g.drawString(String.valueOf(lineNo + 1), 0, fontHeight * (lineNo + 1) - 3);
					}
				} catch (Exception ex) {
					ModuleLib.log(CommonLib.printException(ex));
				}
			}
		}

read count : 16