Last active
November 11, 2017 19:07
-
-
Save edumelzer/4d629ca18462f08fed55 to your computer and use it in GitHub Desktop.
Actions declaration SwingBuilder / Griffon
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.example | |
import griffon.core.artifact.GriffonController | |
import griffon.metadata.ArtifactProviderFor | |
@ArtifactProviderFor(GriffonController) | |
class ExemploActionsController { | |
ExemploActionsModel model | |
void somarAction() { | |
model.clickCount++ | |
} | |
void subtrairAction() { | |
model.clickCount-- | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.example | |
import griffon.core.artifact.GriffonView | |
import griffon.metadata.ArtifactProviderFor | |
import javax.swing.SwingConstants | |
import java.awt.* | |
@ArtifactProviderFor(GriffonView) | |
class ExemploActionsView { | |
FactoryBuilderSupport builder | |
ExemploActionsModel model | |
void initUI() { | |
builder.with { | |
actions { | |
action(somarAction, | |
name: "Adicionar", | |
shortDescription: "Adiciona 1 ao valor atual") | |
action(subtrairAction, | |
name: "Subtrair", | |
shortDescription: "Subtrai 1 do valor atual") | |
} | |
application(size: [320, 160], id: 'mainWindow', | |
title: application.configuration['application.title'], | |
iconImage: imageIcon('/griffon-icon-48x48.png').image, | |
iconImages: [imageIcon('/griffon-icon-48x48.png').image, | |
imageIcon('/griffon-icon-32x32.png').image, | |
imageIcon('/griffon-icon-16x16.png').image]) { | |
borderLayout() | |
panel (constraints: BorderLayout.CENTER) { | |
flowLayout(alignment: FlowLayout.CENTER) | |
label("Contador: ") | |
label(id: 'clickLabel', text: bind { model.clickCount }, | |
horizontalAlignment: SwingConstants.CENTER) | |
} | |
panel (constraints: BorderLayout.SOUTH) { | |
flowLayout(alignment: FlowLayout.RIGHT) | |
button(somarAction, id: 'somarButton') | |
button(subtrairAction, id: 'subtrairButton') | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment