Skip to content

Commit

Permalink
Djf initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
galisha committed Nov 17, 2019
0 parents commit 5100585
Show file tree
Hide file tree
Showing 301 changed files with 25,199 additions and 0 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# DJF - Desktop Java Forms

Djf is a desktop java forms, the compact and litle master-detail UI library like as FoxBase, but based on Swing.
Djf uses Hibernate mapping concepts for data, for component layout - Miglayout and RSyntaxTextArea for text panels.

Almost all of them, form description and examples of assistances you can see in demo application.

## Features

This forms allows us to moving between UI-items without mouse, by using up-down arrows (with CTRL combination).
Also forms supports model: one parent to many children.

## Requirements

Djf requires JDK 1.6 or higher.

## Licensing

Djf is issued on under the GNU Lesser General Public License.

112 changes: 112 additions & 0 deletions djf-demo/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<?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">
<parent>
<artifactId>djf-parent</artifactId>
<groupId>ru.smartflex.djf</groupId>
<version>1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>djf-demo</artifactId>


<dependencies>
<dependency>
<groupId>ru.smartflex.djf</groupId>
<artifactId>djf</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.26</version>
</dependency>
<dependency>
<groupId>com.miglayout</groupId>
<artifactId>miglayout-core</artifactId>
<version>4.2</version>
</dependency>
<dependency>
<groupId>com.miglayout</groupId>
<artifactId>miglayout-swing</artifactId>
<version>4.2</version>
</dependency>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna-platform</artifactId>
<version>5.1.0</version>
</dependency>
</dependencies>

<build>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
<resource>
<directory>src/main/java</directory>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.2</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.1</version>
<configuration>
<includePom>true</includePom>
</configuration>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.1</version>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>ru.smartflex.djf.demo.MainDjfDemo</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>

</plugins>
</build>

</project>
49 changes: 49 additions & 0 deletions djf-demo/src/main/java/ru/smartflex/djf/demo/MainDjfDemo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package ru.smartflex.djf.demo;

import java.util.Properties;

import ru.smartflex.djf.Djf;
import ru.smartflex.djf.SFConstants;
import ru.smartflex.djf.SimpleAccessible;
import ru.smartflex.djf.SizeFrameEnum;
import ru.smartflex.djf.demo.java.AddressFactory;
import ru.smartflex.djf.demo.java.AppEmulator;
import ru.smartflex.djf.demo.java.CarFactory;

public class MainDjfDemo {

public static void run(String frm) {
Properties props = new Properties();
props.put(SFConstants.PROPERTY_FORM_CLASS, "ru.smartflex.djf.widget.template.FormUI");
props.put(SFConstants.PROPERTY_FRAME_CLASS, "ru.smartflex.djf.widget.template.FrameUI");
props.put(SFConstants.PROPERTY_LABEL_RB_PATH, "ru/smartflex/djf/demo");

props.put(SFConstants.PROPERTY_MASK_DATE, "dd-MM-yyyy");

props.put(SFConstants.PROPERTY_FONT_SIZE, "14"); //12

// Setup for application type

// Before start you can to define restrict labels
// Moreover: if "sfSpecialService" will be removed then on the form these all related items will be lost
SimpleAccessible saMarker = new SimpleAccessible("sfAll", "sfSpecialService", "sfBank");
Djf.getConfigurator().setAccessibleHandler(saMarker);

Djf.getConfigurator().configure(props);

AddressFactory address = new AddressFactory();
CarFactory car = new CarFactory();

Djf.getSession().addBean("app", new AppEmulator(address, car));
Djf.getSession().addBean("adr", address);
Djf.getSession().addBean("car", car);
Djf.getSession().addBean("sessId", "testSessionId");

Djf.runForm(frm, SizeFrameEnum.HALF);
}

public static void main(String[] args) {
MainDjfDemo.run("ru/smartflex/djf/demo/xml/Tasks.frm.xml");
}

}
112 changes: 112 additions & 0 deletions djf-demo/src/main/java/ru/smartflex/djf/demo/java/AddressFactory.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
package ru.smartflex.djf.demo.java;

import java.util.ArrayList;
import java.util.Deque;
import java.util.List;

import ru.smartflex.djf.SmartFlexException;
import ru.smartflex.djf.controller.bean.tree.IBeanWrapper;

public class AddressFactory {

private List<PojoStreet> listAddress = new ArrayList<PojoStreet>();
private byte[] listAddressStore = null;
private boolean listAddressFilled = false;

private PojoStreet dergachevskayaStreet = new PojoStreet(1, "Dergachevskaya street");
private PojoBuilding bld5 = new PojoBuilding("5");
private PojoStreet altataStreet = new PojoStreet(2, "Altata river street");
private PojoBuilding bld19l = new PojoBuilding("19l");

public AddressFactory() {
dergachevskayaStreet.getBuildings().add(new PojoBuilding("1"));
dergachevskayaStreet.getBuildings().add(new PojoBuilding("2"));
dergachevskayaStreet.getBuildings().add(bld5);
dergachevskayaStreet.getBuildings().add(new PojoBuilding("7"));
dergachevskayaStreet.getBuildings().add(new PojoBuilding("10"));
dergachevskayaStreet.getBuildings().add(new PojoBuilding("12a"));

altataStreet.getBuildings().add(new PojoBuilding("2g"));
altataStreet.getBuildings().add(new PojoBuilding("12a"));
altataStreet.getBuildings().add(bld19l);
altataStreet.getBuildings().add(new PojoBuilding("68i"));
}

@SuppressWarnings("WeakerAccess")
public PojoStreet getDergachevskayaStreet() {
return dergachevskayaStreet;
}

@SuppressWarnings("WeakerAccess")
public PojoBuilding getBld5() {
return bld5;
}

@SuppressWarnings("WeakerAccess")
public PojoStreet getAltataStreet() {
return altataStreet;
}

@SuppressWarnings("WeakerAccess")
public PojoBuilding getBld19l() {
return bld19l;
}

@SuppressWarnings({"unchecked", "unused"})
public List<PojoStreet> getAddress() {

if (listAddressFilled) {
listAddress = FactoryHelper.restoreFromStore(listAddressStore);
return listAddress;
}

initialFilling();

listAddressFilled = true;

listAddressStore = FactoryHelper.saveToStore(listAddress);

return listAddress;
}

private void initialFilling() {
listAddress.add(dergachevskayaStreet);
listAddress.add(altataStreet);

}

@SuppressWarnings({"unchecked", "unused"})
public List<PojoStreet> getAddress(Boolean interrupt) {

if (interrupt) {
throw new SmartFlexException("Network error emulation");
}

if (listAddressFilled) {
listAddress = FactoryHelper.restoreFromStore(listAddressStore);
return listAddress;
}

initialFilling();

listAddressFilled = true;

listAddressStore = FactoryHelper.saveToStore(listAddress);

return listAddress;
}

@SuppressWarnings("unused")
public void saveAddress(String idSession, Deque<IBeanWrapper> toSave) {

int i = 1;
for (PojoStreet ps : listAddress) {
if (ps.getIdStreet() == 0) {
ps.setIdStreet(i);
}
i++;
}
listAddressStore = FactoryHelper.saveToStore(listAddress);
}

}
Loading

0 comments on commit 5100585

Please sign in to comment.