use of org.jowidgets.api.command.IExecutionContext in project jo-client-platform by jo-source.
the class BeanRelationGraphImpl method initToolBar.
private IToolBarModel initToolBar() {
final IActionBuilderFactory actionBF = Toolkit.getActionBuilderFactory();
final ToolBarModel model = new ToolBarModel();
model.addTextLabel(Messages.getString("BeanRelationGraphImpl.max.nodecount") + " ");
final IInputFieldBluePrint<Integer> textFieldBP = BPF.inputFieldIntegerNumber().setMaxLength(3).setValue(maxNodeCount);
maxNodeTextField = new InputControlItemModel<Integer>(textFieldBP, 30);
maxNodeTextField.addInputListener(new IInputListener() {
@Override
public void inputChanged() {
if (maxNodeTextField.getValue() != null) {
maxNodeCount = maxNodeTextField.getValue();
relationTreeModel.load();
}
}
});
model.addItem(maxNodeTextField);
model.addSeparator();
model.addTextLabel("Expand Level ");
final IComboBoxSelectionBluePrint<Integer> comboBoxExpandLevelBp = BPF.comboBoxSelectionIntegerNumber().setElements(0, 1, 2, 3, 4, 5).autoCompletionOff();
comboBoxExpandLevel = new InputControlItemModel<Integer>(comboBoxExpandLevelBp, 35);
comboBoxExpandLevel.setValue(autoExpandLevel);
comboBoxExpandLevel.addInputListener(new IInputListener() {
@Override
public void inputChanged() {
if (comboBoxExpandLevel.getValue() != null) {
autoExpandLevel = comboBoxExpandLevel.getValue();
runLayout(true);
vis.run("expand");
}
}
});
model.addItem(comboBoxExpandLevel);
model.addSeparator();
final IActionBuilder settingsDialogActionBuilder = actionBF.create();
settingsDialogActionBuilder.setIcon(CapIcons.GRAPH_SETTINGS);
settingsDialogActionBuilder.setCommand(new ICommandExecutor() {
@Override
public void execute(final IExecutionContext executionContext) throws Exception {
openUpdateLayoutSettingsDialog();
}
});
final ICommandAction settingsDialogAction = settingsDialogActionBuilder.build();
final IComboBoxSelectionBluePrint<GraphLayout> comboBoxBp = BPF.comboBoxSelection(GraphLayout.values());
comboBoxBp.setAutoCompletion(false);
final InputControlItemModel<GraphLayout> comboBox = new InputControlItemModel<GraphLayout>(comboBoxBp, 130);
comboBox.addInputListener(new IInputListener() {
@Override
public void inputChanged() {
layoutManager.resetNodePositions();
settingsDialogAction.setEnabled(true);
setLayout(comboBox.getValue());
if (layoutManager.getLabelEdgeLayout() != null) {
layoutManager.getLabelEdgeLayout().run();
}
layoutManager.assignAnchorPoint(display, activeLayout);
runLayout(true);
if (layoutSettingsDialog != null) {
layoutSettingsDialog.setVisible(false);
layoutSettingsDialog.dispose();
layoutSettingsDialog = null;
}
}
});
comboBox.setValue(GraphLayout.FORCE_DIRECTED_LAYOUT);
model.addItem(comboBox);
final ICheckedItemModel checkItemModel = model.addCheckedItem(CapIcons.GRAPH_ANIMATION, Messages.getMessage("BeanRelationGraphImpl.animation.on").get());
checkItemModel.setSelected(true);
checkItemModel.addItemListener(new IItemStateListener() {
private boolean on = true;
@Override
public void itemStateChanged() {
if (on) {
checkItemModel.setText(Messages.getMessage("BeanRelationGraphImpl.animation.on").get());
switchNodeAnimation(true);
} else {
checkItemModel.setText(Messages.getMessage("BeanRelationGraphImpl.animation.off").get());
switchNodeAnimation(false);
}
on = !on;
}
});
final IActionBuilder groupFilterActionBuilder = actionBF.create();
groupFilterActionBuilder.setIcon(IconsSmall.SETTINGS);
groupFilterActionBuilder.setCommand(new ICommandExecutor() {
@Override
public void execute(final IExecutionContext executionContext) throws Exception {
openUpdateEdgeVisibilityDialog(0);
}
});
final ICommandAction groupFilterAction = groupFilterActionBuilder.build();
model.addSeparator();
model.addAction(settingsDialogAction);
model.addAction(groupFilterAction);
model.addSeparator();
final ICheckedItemModel edgeCheckedItem = model.addCheckedItem("Edge Label");
edgeCheckedItem.setIcon(CapIcons.GRAPH_LETTERING);
edgeCheckedItem.setSelected(false);
edgeCheckedItem.addItemListener(new IItemStateListener() {
@Override
public void itemStateChanged() {
layoutManager.getLabelEdgeLayout().setEdgesVisible(edgeCheckedItem.isSelected());
runLayout(true);
}
});
final IActionBuilder screenShotActionBuilder = actionBF.create();
screenShotActionBuilder.setText(Messages.getMessage("BeanRelationGraphImpl.screenshot").get());
screenShotActionBuilder.setIcon(CapIcons.GRAPH_SNAPSHOT);
screenShotActionBuilder.setToolTipText(Messages.getMessage("BeanRelationGraphImpl.copy.in.clipboard").get());
screenShotActionBuilder.setCommand(new ICommandExecutor() {
@Override
public void execute(final IExecutionContext executionContext) throws Exception {
final BufferedImage bufImage = new BufferedImage(display.getSize().width, display.getSize().height, BufferedImage.TYPE_INT_RGB);
display.paint(bufImage.createGraphics());
java.awt.Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new ImageSelection(bufImage), null);
}
});
final ICommandAction screenShotAction = screenShotActionBuilder.build();
model.addAction(screenShotAction);
return model;
}
use of org.jowidgets.api.command.IExecutionContext in project jo-client-platform by jo-source.
the class BeanTableCreatorActionBuilderFactory method createBuilder.
static <BEAN_TYPE> ICreatorActionBuilder<BEAN_TYPE> createBuilder(final IBeanTable<BEAN_TYPE> table) {
final IBeanTableModel<BEAN_TYPE> model = table.getModel();
final IBeanListModel<BEAN_TYPE> wrappedModel = new ScrollToEndAtAddTableModel<BEAN_TYPE>(table);
final ICapActionFactory actionFactory = CapUiToolkit.actionFactory();
final ICreatorActionBuilder<BEAN_TYPE> builder = actionFactory.creatorActionBuilder(model.getEntityId(), model.getBeanType(), wrappedModel);
builder.setBeanPropertyValidators(model.getBeanPropertyValidators());
builder.setEntityLabelSingular(model.getEntityLabelSingular());
builder.setParentBeansProvider(new IProvider<List<IBeanKey>>() {
@Override
public List<IBeanKey> get() {
return model.getParentBeanKeys();
}
});
final ICreatorService creatorService = model.getCreatorService();
if (creatorService != null) {
builder.setCreatorService(creatorService);
}
// Bean form must have all attributes because a later pluged layouter may use them
final IBeanFormBluePrint<BEAN_TYPE> beanFormBp = CapUiToolkit.bluePrintFactory().beanForm(model.getEntityId(), model.getAttributes());
builder.setAttributes(model.getAttributes());
builder.setBeanForm(beanFormBp);
builder.addExecutionInterceptor(new ExecutionInterceptorAdapter<List<IBeanDto>>() {
@Override
public void beforeExecution(final IExecutionContext executionContext, final IVetoable continueExecution) {
final int pageCount = model.getPageCount();
if (pageCount > 0 && !model.isPageCreated(pageCount - 1)) {
model.loadPage(pageCount - 1);
}
}
});
return builder;
}
Aggregations