Coder Social home page Coder Social logo

yayoi-usecase's Introduction

Yayoi Use Case

Use case project for Yayoi GUI annotation framework

Building

ceylon compile

Use Case

App entry point:

shared void run() =>
	Yayoi(`class App`,
	() {
		logger(`package it.feelburst.yayoi.model.window.swing`).priority = debug;
	}).run();

User app:

yayoi(
	{`package it.feelburst.yayoi.usecase`},
	`value swingFramework`)
shared class App() satisfies Runnable {
	
	autowired
	shared late Window<JFrame> login;
	
	shared actual void run() {}
	
}

Components file:

setLookAndFeel
shared String lookAndFeel() =>
	UIManager.systemLookAndFeelClassName;

window
size(270,150)
centered
exitOnClose
shared JFrame login() =>
	JFrame("Login");

container
parent("login()")
withLayout("panelGroupLayout()")
shared JPanel panel() =>
	JPanel();
	
layout
shared GroupLayout panelGroupLayout(
	named("login().panel()") JPanel panel) {
	value groupLayout = GroupLayout(panel);
	groupLayout.autoCreateContainerGaps = true;
	groupLayout.autoCreateGaps = true;
	return groupLayout;
}
	
component
parent("login().panel()")
shared object emailTextField extends JTextField(20) {}
	
component
parent("login().panel()")
shared object passwordField extends JPasswordField(20) {}
	
component
parent("login().panel()")
onActionPerformed("loginButtonListener")
shared object loginButton extends JButton("Ok") {}
	

listener
shared object loginButtonListener satisfies ActionListener {
	shared actual void actionPerformed(ActionEvent? e) {
		print("On Action Performed");
	}
}

doLayout("login().panel()")
shared void doPanelLayout(
	named("panelGroupLayout()") GroupLayout panelGroupLayout, 
	named("login().panel()") JPanel panel, 
	named("login().panel().emailTextField") JTextField emailTextField,
	named("login().panel().loginButton") JButton loginButton, 
	named("login().panel().passwordField") JPasswordField passwordField) {
	panelGroupLayout.setHorizontalGroup(
		panelGroupLayout.createParallelGroup()
		.addComponent(emailTextField, preferredSize, defaultSize, preferredSize)
		.addComponent(passwordField, preferredSize, defaultSize, preferredSize)
		.addComponent(loginButton, preferredSize, defaultSize, preferredSize));
	panelGroupLayout.setVerticalGroup(
		panelGroupLayout.createSequentialGroup()
		.addComponent(emailTextField, preferredSize, defaultSize, preferredSize)
		.addComponent(passwordField, preferredSize, defaultSize, preferredSize)
		.addComponent(loginButton, preferredSize, defaultSize, preferredSize));
}

Class autowiring support (default WindowListener from Yayoi framework):

listener
shared class DefaultWindowClosedAdapter() extends WindowAdapter() {
	
	autowired
	late ApplicationEventPublisher eventPublisher;
	
	shared actual void windowClosing(WindowEvent? e) =>
		eventPublisher.publishEvent(ShutdownRequested(this));
}

Layout construction on container declaration:

container
parent("main()")
shared JPanel panel() =>
	JPanel(GridLayout(1,1));

yayoi-usecase's People

Contributors

fill0llif avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.