use of org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties in project rap by entirej.
the class EJRWTAbstractScreenRenderer method createScreenItem.
public void createScreenItem(Composite parent, EJScreenItemProperties itemProps, EJScreenType screenType) {
EJFrameworkExtensionProperties itemRendererPropertiesForItem = getItemRendererPropertiesForItem(itemProps);
if (itemProps.isSpacerItem()) {
if (itemProps.isSeparator()) {
int style = SWT.SEPARATOR;
if (itemProps.getSeparatorOrientation() == EJSeparatorOrientation.HORIZONTAL) {
style = style | SWT.HORIZONTAL;
} else {
style = style | SWT.VERTICAL;
}
Label layoutBody = new Label(parent, style);
layoutBody.setLayoutData(createBlockItemGridData(null, itemRendererPropertiesForItem, layoutBody));
switch(itemProps.getSeparatorLineStyle()) {
case DASHED:
layoutBody.setData(EJ_RWT.CUSTOM_VARIANT, "separator_dashed");
break;
case DOTTED:
layoutBody.setData(EJ_RWT.CUSTOM_VARIANT, "separator_dotted");
break;
case DOUBLE:
layoutBody.setData(EJ_RWT.CUSTOM_VARIANT, "separator_double");
break;
default:
layoutBody.setData(EJ_RWT.CUSTOM_VARIANT, "separator");
break;
}
return;
}
Label label = new Label(parent, SWT.NONE);
label.setLayoutData(createBlockItemGridData(null, itemRendererPropertiesForItem, label));
return;
}
EJScreenItemController item = getBlock().getScreenItem(screenType, itemProps.getReferencedItemName());
EJManagedItemRendererWrapper renderer = item.getManagedItemRenderer();
if (renderer != null) {
registerRendererForItem(renderer.getUnmanagedRenderer(), item);
EJFrameworkExtensionProperties blockRequiredItemProperties = itemRendererPropertiesForItem;
String labelPosition = blockRequiredItemProperties.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.LABEL_POSITION_PROPERTY);
String labelOrientation = blockRequiredItemProperties.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.LABEL_ORIENTATION_PROPERTY);
String visualAttribute = blockRequiredItemProperties.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.VISUAL_ATTRIBUTE_PROPERTY);
EJRWTAppItemRenderer itemRenderer = (EJRWTAppItemRenderer) renderer.getUnmanagedRenderer();
boolean hasLabel = itemProps.getLabel() != null && itemProps.getLabel().trim().length() > 0;
if (hasLabel && EJRWTSingleRecordBlockDefinitionProperties.LABEL_POSITION_LEFT_PROPERTY.equals(labelPosition)) {
itemRenderer.createLable(parent);
itemRenderer.createComponent(parent);
labletextAliment(itemRenderer.getGuiComponentLabel(), labelOrientation);
} else if (hasLabel && EJRWTSingleRecordBlockDefinitionProperties.LABEL_POSITION_RIGHT_PROPERTY.equals(labelPosition)) {
itemRenderer.createComponent(parent);
itemRenderer.createLable(parent);
labletextAliment(itemRenderer.getGuiComponentLabel(), labelOrientation);
} else {
itemRenderer.createComponent(parent);
}
itemRenderer.getGuiComponent().setLayoutData(createBlockItemGridData(itemRenderer, blockRequiredItemProperties, itemRenderer.getGuiComponent()));
EJ_RWT.setTestId(itemRenderer.getGuiComponent(), blockRequiredItemProperties.getBlockProperties().getName() + "." + itemRenderer.getRegisteredItemName());
if (itemRenderer.getGuiComponentLabel() != null) {
itemRenderer.getGuiComponentLabel().setLayoutData(createBlockLableGridData(blockRequiredItemProperties));
}
if (visualAttribute != null) {
EJCoreVisualAttributeProperties va = EJCoreProperties.getInstance().getVisualAttributesContainer().getVisualAttributeProperties(visualAttribute);
if (va != null) {
itemRenderer.setInitialVisualAttribute(va);
}
}
if (item.getProperties().getVisualAttributeProperties() != null) {
renderer.setVisualAttribute(item.getProperties().getVisualAttributeProperties());
}
EJScreenItemProperties itemProperties = item.getProperties();
renderer.setVisible(itemProperties.isVisible());
renderer.setEditAllowed(itemProperties.isEditAllowed());
// Add the item to the pane according to its display coordinates.
renderer.setMandatory(itemProperties.isMandatory());
renderer.enableLovActivation(itemProperties.isLovNotificationEnabled());
if (_firstNavigationalItem == null) {
if (itemProperties.isVisible() && itemProperties.isEditAllowed()) {
_firstNavigationalItem = renderer;
}
}
}
}
use of org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties in project rap by entirej.
the class EJRWTTreeRecordBlockDefinition method addBlockControlToCanvas.
@Override
public EJDevBlockRendererDefinitionControl addBlockControlToCanvas(EJMainScreenProperties mainScreenProperties, EJDevBlockDisplayProperties blockDisplayProperties, Composite parent, FormToolkit toolkit) {
EJFrameworkExtensionProperties rendererProperties = blockDisplayProperties.getBlockRendererProperties();
if (blockDisplayProperties != null) {
rendererProperties = rendererProperties.getPropertyGroup(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR);
}
Composite layoutBody;
if (rendererProperties != null && rendererProperties.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE) != null && !EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE_GROUP.equals(rendererProperties.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE))) {
int style = ExpandableComposite.TITLE_BAR;
String mode = rendererProperties.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE);
if (EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE_TWISTIE.equals(mode)) {
style = style | ExpandableComposite.TWISTIE;
} else if (EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE_TREE_NODE.equals(mode)) {
style = style | ExpandableComposite.TREE_NODE;
}
if (rendererProperties.getBooleanProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_EXPANDED, true)) {
style = style | ExpandableComposite.EXPANDED;
}
String title = rendererProperties.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_TITLE);
Section section = toolkit.createSection(parent, style);
if (title != null)
section.setText(title);
section.setFont(parent.getFont());
section.setForeground(parent.getForeground());
if (mainScreenProperties.getDisplayFrame()) {
layoutBody = new Group(section, SWT.NONE);
layoutBody.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
if (mainScreenProperties.getFrameTitle() != null)
((Group) layoutBody).setText(mainScreenProperties.getFrameTitle());
} else {
layoutBody = toolkit.createComposite(section);
}
section.setClient(layoutBody);
} else {
if (mainScreenProperties.getDisplayFrame()) {
layoutBody = new Group(parent, SWT.NONE);
if (mainScreenProperties.getFrameTitle() != null)
((Group) layoutBody).setText(mainScreenProperties.getFrameTitle());
} else {
layoutBody = new Composite(parent, SWT.NONE);
}
}
layoutBody.setLayout(new FillLayout());
EJDevItemGroupDisplayProperties displayProperties = null;
if (blockDisplayProperties.getMainScreenItemGroupDisplayContainer().getAllItemGroupDisplayProperties().size() > 0) {
displayProperties = blockDisplayProperties.getMainScreenItemGroupDisplayContainer().getAllItemGroupDisplayProperties().iterator().next();
}
StringBuilder builder = new StringBuilder();
if (displayProperties != null)
for (EJDevScreenItemDisplayProperties screenItem : displayProperties.getAllItemDisplayProperties()) {
if (!screenItem.isSpacerItem()) {
EJFrameworkExtensionProperties properties = ((EJDevMainScreenItemDisplayProperties) screenItem).getBlockRendererRequiredProperties();
String prefix = properties.getStringProperty(EJRWTTreeBlockDefinitionProperties.ITEM_PREFIX);
if (prefix != null) {
builder.append(prefix);
}
builder.append(screenItem.getReferencedItemName());
String sufix = properties.getStringProperty(EJRWTTreeBlockDefinitionProperties.ITEM_SUFFIX);
if (sufix != null) {
builder.append(sufix);
}
}
}
String tag = builder.toString();
if (tag.length() == 0) {
tag = "<empty>";
}
final Tree browser = new Tree(layoutBody, SWT.BORDER);
for (int i = 0; i < 4; i++) {
TreeItem iItem = new TreeItem(browser, 0);
iItem.setText(tag + " " + (i + 1));
for (int j = 0; j < 4; j++) {
TreeItem jItem = new TreeItem(iItem, 0);
jItem.setText(tag + " " + (j + 1));
}
}
return new EJDevBlockRendererDefinitionControl(blockDisplayProperties, Collections.<EJDevItemRendererDefinitionControl>emptyList());
}
use of org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties in project rap by entirej.
the class EJRWTTreeTableRecordBlockDefinition method addBlockControlToCanvas.
@Override
public EJDevBlockRendererDefinitionControl addBlockControlToCanvas(EJMainScreenProperties mainScreenProperties, EJDevBlockDisplayProperties blockDisplayProperties, Composite parent, FormToolkit toolkit) {
EJFrameworkExtensionProperties rendererProperties = blockDisplayProperties.getBlockRendererProperties();
if (blockDisplayProperties != null) {
rendererProperties = rendererProperties.getPropertyGroup(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR);
}
Composite layoutBody;
if (rendererProperties != null && rendererProperties.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE) != null && !EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE_GROUP.equals(rendererProperties.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE))) {
int style = ExpandableComposite.TITLE_BAR;
String mode = rendererProperties.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE);
if (EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE_TWISTIE.equals(mode)) {
style = style | ExpandableComposite.TWISTIE;
} else if (EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE_TREE_NODE.equals(mode)) {
style = style | ExpandableComposite.TREE_NODE;
}
if (rendererProperties.getBooleanProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_EXPANDED, true)) {
style = style | ExpandableComposite.EXPANDED;
}
String title = rendererProperties.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_TITLE);
Section section = toolkit.createSection(parent, style);
if (title != null)
section.setText(title);
section.setFont(parent.getFont());
section.setForeground(parent.getForeground());
if (mainScreenProperties.getDisplayFrame()) {
layoutBody = new Group(section, SWT.NONE);
layoutBody.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
if (mainScreenProperties.getFrameTitle() != null)
((Group) layoutBody).setText(mainScreenProperties.getFrameTitle());
} else {
layoutBody = toolkit.createComposite(section);
}
section.setClient(layoutBody);
} else {
if (mainScreenProperties.getDisplayFrame()) {
layoutBody = new Group(parent, SWT.NONE);
if (mainScreenProperties.getFrameTitle() != null)
((Group) layoutBody).setText(mainScreenProperties.getFrameTitle());
} else {
layoutBody = new Composite(parent, SWT.NONE);
}
}
layoutBody.setLayout(new GridLayout(mainScreenProperties.getNumCols(), false));
EJRWTTreeRendererDefinitionControl control = addTreeTable(blockDisplayProperties, layoutBody, toolkit);
return control;
}
use of org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties in project rap by entirej.
the class EJRWTUpdateScreenRenderer method setupUpdateScreen.
private void setupUpdateScreen() {
// Setup pane for query window
EJFrameworkExtensionProperties rendererProperties = _block.getProperties().getUpdateScreenRendererProperties();
String title = rendererProperties.getStringProperty(EJRWTScreenRendererDefinitionProperties.TITLE);
final int width = rendererProperties.getIntProperty(EJRWTScreenRendererDefinitionProperties.WIDTH, 300);
final int height = rendererProperties.getIntProperty(EJRWTScreenRendererDefinitionProperties.HEIGHT, 500);
_maximize = rendererProperties.getBooleanProperty(EJRWTScreenRendererDefinitionProperties.MAXIMIZE, false);
final int numCols = rendererProperties.getIntProperty(EJRWTScreenRendererDefinitionProperties.NUM_COLS, 1);
final String updateButtonLabel = rendererProperties.getStringProperty(EJRWTScreenRendererDefinitionProperties.EXECUTE_BUTTON_TEXT);
final String cancelButtonLabel = rendererProperties.getStringProperty(EJRWTScreenRendererDefinitionProperties.CANCEL_BUTTON_TEXT);
EJFrameworkExtensionProperties extraButtonsGroup = rendererProperties.getPropertyGroup(EJRWTScreenRendererDefinitionProperties.EXTRA_BUTTONS_GROUP);
final String button1Label = extraButtonsGroup.getStringProperty(EJRWTScreenRendererDefinitionProperties.EXTRA_BUTTON_ONE_LABEL);
final String button1Command = extraButtonsGroup.getStringProperty(EJRWTScreenRendererDefinitionProperties.EXTRA_BUTTON_ONE_COMMAND);
final String button2Label = extraButtonsGroup.getStringProperty(EJRWTScreenRendererDefinitionProperties.EXTRA_BUTTON_TWO_LABEL);
final String button2Command = extraButtonsGroup.getStringProperty(EJRWTScreenRendererDefinitionProperties.EXTRA_BUTTON_TWO_COMMAND);
final String button3Label = extraButtonsGroup.getStringProperty(EJRWTScreenRendererDefinitionProperties.EXTRA_BUTTON_THREE_LABEL);
final String button3Command = extraButtonsGroup.getStringProperty(EJRWTScreenRendererDefinitionProperties.EXTRA_BUTTON_THREE_COMMAND);
final String button4Label = extraButtonsGroup.getStringProperty(EJRWTScreenRendererDefinitionProperties.EXTRA_BUTTON_FOUR_LABEL);
final String button4Command = extraButtonsGroup.getStringProperty(EJRWTScreenRendererDefinitionProperties.EXTRA_BUTTON_FOUR_COMMAND);
final String button5Label = extraButtonsGroup.getStringProperty(EJRWTScreenRendererDefinitionProperties.EXTRA_BUTTON_FIVE_LABEL);
final String button5Command = extraButtonsGroup.getStringProperty(EJRWTScreenRendererDefinitionProperties.EXTRA_BUTTON_FIVE_COMMAND);
final int ID_BUTTON_1 = 1;
final int ID_BUTTON_2 = 2;
final int ID_BUTTON_3 = 3;
final int ID_BUTTON_4 = 4;
final int ID_BUTTON_5 = 5;
_updateDialog = new EJRWTAbstractDialog(getRWTManager().getShell()) {
@Override
public void createBody(Composite parent) {
EJ_RWT.setTestId(parent, _block.getProperties().getName() + ".update-screen");
parent.setLayout(new FillLayout());
final ScrolledComposite scrollComposite = new EJRWTScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL);
EJRWTEntireJGridPane _mainPane = new EJRWTEntireJGridPane(scrollComposite, numCols);
_mainPane.cleanLayout();
EJBlockProperties blockProperties = _block.getProperties();
addAllItemGroups(blockProperties.getScreenItemGroupContainer(EJScreenType.UPDATE), _mainPane, EJScreenType.UPDATE);
scrollComposite.setContent(_mainPane);
scrollComposite.setExpandHorizontal(true);
scrollComposite.setExpandVertical(true);
// remove the offset
scrollComposite.setMinSize(width, height - 10);
_block.addItemValueChangedListener(EJRWTUpdateScreenRenderer.this);
EJRWTItemTextChangeNotifier.ChangeListener changeListener = new ChangeListener() {
@Override
public void changed() {
validate();
}
};
Collection<EJManagedItemRendererWrapper> registeredRenderers = _itemRegister.getRegisteredRenderers();
for (EJManagedItemRendererWrapper ejManagedItemRendererWrapper : registeredRenderers) {
if (ejManagedItemRendererWrapper.getUnmanagedRenderer() instanceof EJRWTItemTextChangeNotifier) {
((EJRWTItemTextChangeNotifier) ejManagedItemRendererWrapper.getUnmanagedRenderer()).addListener(changeListener);
}
}
}
@Override
public int open() {
validate();
setFoucsItemRenderer();
return super.open();
}
@Override
protected void createButtonsForButtonBar(Composite parent) {
// Add the buttons in reverse order, as they will be added from
// left to right
addExtraButton(parent, button5Label, ID_BUTTON_5);
addExtraButton(parent, button4Label, ID_BUTTON_4);
addExtraButton(parent, button3Label, ID_BUTTON_3);
addExtraButton(parent, button2Label, ID_BUTTON_2);
addExtraButton(parent, button1Label, ID_BUTTON_1);
EJ_RWT.setTestId(createButton(parent, UPDATE_OK_ACTION_COMMAND, updateButtonLabel == null ? "Update" : updateButtonLabel, true), _block.getProperties().getName() + ".ok");
EJ_RWT.setTestId(createButton(parent, UPDATE_CANCEL_ACTION_COMMAND, cancelButtonLabel == null ? "Cancel" : cancelButtonLabel, false), _block.getProperties().getName() + ".cancel");
}
@Override
public void validate() {
Button button = getButton(UPDATE_OK_ACTION_COMMAND);
if (button == null) {
return;
}
Collection<EJScreenItemController> allScreenItems = _block.getAllScreenItems(EJScreenType.UPDATE);
for (EJScreenItemController ejScreenItemController : allScreenItems) {
if (!ejScreenItemController.getManagedItemRenderer().isValid()) {
button.setEnabled(false);
return;
}
}
button.setEnabled(true);
}
private void addExtraButton(Composite parent, String label, int id) {
if (label == null) {
return;
}
Button button = createButton(parent, id, label, false);
EJ_RWT.setTestId(button, _block.getProperties().getName() + ".btn-" + id);
}
@Override
public boolean close() {
_block.removeItemValueChangedListener(EJRWTUpdateScreenRenderer.this);
_block.setRendererFocus(true);
return super.close();
}
@Override
public void canceled() {
_block.updateCancelled();
close();
}
@Override
protected void buttonPressed(int buttonId) {
Display.getDefault().asyncExec(() -> {
try {
switch(buttonId) {
case UPDATE_OK_ACTION_COMMAND:
{
try {
_block.getBlock().updateRecord(_itemRegister.getRegisteredRecord());
if (_block.getUpdateScreenDisplayProperties().getBooleanProperty(EJRWTScreenRendererDefinitionProperties.SAVE_FORM_AFTER_EXECUTE, false)) {
_block.getBlock().getForm().saveChanges();
}
} catch (EJApplicationException e) {
setButtonEnable(buttonId, false);
throw e;
}
close();
break;
}
case UPDATE_CANCEL_ACTION_COMMAND:
{
_block.updateCancelled();
close();
break;
}
case ID_BUTTON_1:
{
_block.executeActionCommand(button1Command, EJScreenType.UPDATE);
break;
}
case ID_BUTTON_2:
{
_block.executeActionCommand(button2Command, EJScreenType.UPDATE);
break;
}
case ID_BUTTON_3:
{
_block.executeActionCommand(button3Command, EJScreenType.UPDATE);
break;
}
case ID_BUTTON_4:
{
_block.executeActionCommand(button4Command, EJScreenType.UPDATE);
break;
}
case ID_BUTTON_5:
{
_block.executeActionCommand(button5Command, EJScreenType.UPDATE);
break;
}
default:
_block.updateCancelled();
break;
}
} catch (EJApplicationException e) {
_logger.trace(e.getMessage());
_frameworkManager.handleException(e);
return;
}
});
}
};
_updateDialog.create();
_updateDialog.getShell().setData("UPDATE - " + _block.getProperties().getName());
_updateDialog.getShell().setText(title != null ? title : "");
// add dialog border offsets
_updateDialog.getShell().setSize(width + 80, height + 100);
}
use of org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties in project rap by entirej.
the class EJRWTApplicationLauncher method createEntryPoint.
public void createEntryPoint(final Application configuration) {
configuration.setOperationMode(getOperationMode());
Map<String, String> properties = new HashMap<String, String>();
if (this.getClass().getClassLoader().getResource("application.ejprop") != null) {
EJFrameworkInitialiser.initialiseFramework("application.ejprop");
} else if (this.getClass().getClassLoader().getResource("EntireJApplication.properties") != null) {
EJFrameworkInitialiser.initialiseFramework("EntireJApplication.properties");
} else {
throw new RuntimeException("application.ejprop not found");
}
final EJCoreProperties coreProperties = EJCoreProperties.getInstance();
EJCoreLayoutContainer layoutContainer = coreProperties.getLayoutContainer();
properties.put(WebClient.PAGE_TITLE, layoutContainer.getTitle());
String favicon = getFavicon();
if (favicon == null) {
favicon = ICONS_FAVICON_ICO;
}
properties.put(WebClient.FAVICON, favicon);
properties.put(WebClient.BODY_HTML, getBodyHtml());
properties.put(WebClient.THEME_ID, THEME_DEFAULT);
addOtherResources(configuration);
configuration.addResource(favicon, new FileResource());
configuration.addResource(getLoadingImage(), new FileResource());
configuration.addStyleSheet(THEME_DEFAULT, "resource/theme/default.css");
String baseThemeCSSLocation = getBaseThemeCSSLocation();
if (baseThemeCSSLocation == null) {
baseThemeCSSLocation = THEME_DEFAULT_CSS;
}
configuration.addStyleSheet(THEME_DEFAULT, baseThemeCSSLocation);
properties.put(WebClient.PAGE_OVERFLOW, "scrollY");
configuration.addResource(baseThemeCSSLocation, new FileResource());
if (getThemeCSSLocation() != null) {
configuration.addStyleSheet(THEME_DEFAULT, getThemeCSSLocation());
configuration.addResource(getThemeCSSLocation(), new FileResource());
}
configuration.addEntryPoint(String.format("/%s", getWebPathContext()), new EntryPointFactory() {
public EntryPoint create() {
try {
RWT.getServiceManager().registerServiceHandler(VACSSServiceHandler.SERVICE_HANDLER, new VACSSServiceHandler());
RWT.getServiceManager().registerServiceHandler(EJRWTFileDownload.SERVICE_HANDLER, EJRWTFileDownload.newServiceHandler());
registerServiceHandlers();
} catch (java.lang.IllegalArgumentException e) {
// ignore if already registered
}
registerWidgetHandlers();
final EntryPoint wrapped = newEntryPoint();
return new EntryPoint() {
public int createUI() {
BrowserNavigation service = RWT.getClient().getService(BrowserNavigation.class);
BrowserNavigationListener listener = new BrowserNavigationListener() {
@Override
public void navigated(BrowserNavigationEvent event) {
EJRWTContext.getPageContext().setState(event.getState());
}
};
service.addBrowserNavigationListener(listener);
int createUI = wrapped.createUI();
return createUI;
}
};
}
private EntryPoint newEntryPoint() {
return new EntryPoint() {
public int createUI() {
{
// connect BaseURL
StringBuffer url = new StringBuffer();
url.append(RWT.getRequest().getContextPath());
url.append(RWT.getRequest().getServletPath());
String encodeURL = RWT.getResponse().encodeURL(url.toString());
if (encodeURL.contains("jsessionid")) {
encodeURL = encodeURL.substring(0, encodeURL.indexOf("jsessionid"));
}
int patchIndex = encodeURL.lastIndexOf(getWebPathContext());
if (patchIndex > -1) {
encodeURL = encodeURL.substring(0, patchIndex);
}
_baseURL = encodeURL;
}
RWTUtils.patchClient(getWebPathContext(), getTimeoutUrl());
EJRWTImageRetriever.setGraphicsProvider(new EJRWTGraphicsProvider() {
@Override
public void promptFileUpload(final EJFileUpload fileUpload, final Callable<Object> callable) {
if (fileUpload.isMultiSelection()) {
EJRWTFileUpload.promptMultipleFileUpload(fileUpload.getTitle(), fileUpload.getUploadSizeLimit(), fileUpload.getUploadTimeLimit(), fileUpload.getFileExtensions().toArray(new String[0]), new FileSelectionCallBack() {
@Override
public void select(String[] files) {
try {
fileUpload.setFilePaths(files != null ? Arrays.asList(files) : null);
callable.call();
} catch (Exception e) {
e.printStackTrace();
}
}
});
} else {
EJRWTFileUpload.promptFileUpload(fileUpload.getTitle(), fileUpload.getUploadSizeLimit(), fileUpload.getUploadTimeLimit(), fileUpload.getFileExtensions().toArray(new String[0]), new FileSelectionCallBack() {
@Override
public void select(String[] files) {
try {
fileUpload.setFilePaths(files != null ? Arrays.asList(files) : null);
callable.call();
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
}
public Image getImage(String name, ClassLoader loader) {
return RWTUtils.getImage(name, loader);
}
@Override
public void open(final String output, String outputName) {
EJRWTFileDownload.download(output, outputName);
RWT.getUISession().addUISessionListener(new UISessionListener() {
private static final long serialVersionUID = 1L;
@Override
public void beforeDestroy(UISessionEvent arg0) {
File f = new File(output);
if (f.exists()) {
f.delete();
}
}
});
}
public float getAvgCharWidth(Font font) {
return RWTUtils.getAvgCharWidth(font);
}
public int getCharHeight(Font font) {
return RWTUtils.getCharHeight(font);
}
public void rendererSection(final Section section) {
section.removeListener(SWT.Dispose, section.getListeners(SWT.Dispose)[0]);
section.removeListener(SWT.Resize, section.getListeners(SWT.Resize)[0]);
section.setFont(section.getParent().getFont());
section.setForeground(section.getParent().getForeground());
Object adapter = section.getAdapter(IWidgetGraphicsAdapter.class);
IWidgetGraphicsAdapter gfxAdapter = (IWidgetGraphicsAdapter) adapter;
gfxAdapter.setRoundedBorder(1, section.getTitleBarBackground(), 2, 2, 0, 0);
Listener listener = new Listener() {
public void handleEvent(Event e) {
Object adapter = section.getAdapter(IWidgetGraphicsAdapter.class);
IWidgetGraphicsAdapter gfxAdapter = (IWidgetGraphicsAdapter) adapter;
Color[] gradientColors = new Color[] { section.getTitleBarBorderColor(), section.getBackground(), section.getTitleBarBackground(), section.getBackground(), section.getBackground() };
int gradientPercent = 0;
Rectangle bounds = section.getClientArea();
if (bounds.height != 0) {
gradientPercent = 30 * 100 / bounds.height;
if (gradientPercent > 100) {
gradientPercent = 100;
}
}
int[] percents = new int[] { 0, 1, 2, gradientPercent, 100 };
gfxAdapter.setBackgroundGradient(gradientColors, percents, true);
gfxAdapter.setRoundedBorder(1, section.getBackground(), 4, 4, 0, 0);
}
};
section.addListener(SWT.Dispose, listener);
section.addListener(SWT.Resize, listener);
}
});
final EJRWTApplicationManager applicationManager;
if (this.getClass().getClassLoader().getResource("application.ejprop") != null) {
applicationManager = (EJRWTApplicationManager) EJFrameworkInitialiser.initialiseFramework("application.ejprop");
} else if (this.getClass().getClassLoader().getResource("EntireJApplication.properties") != null) {
applicationManager = (EJRWTApplicationManager) EJFrameworkInitialiser.initialiseFramework("EntireJApplication.properties");
} else {
throw new RuntimeException("application.ejprop not found");
}
EJRWTContext.getPageContext().setManager(applicationManager);
getContext().getUISession().setAttribute("ej.applicationManager", applicationManager);
EJCoreLayoutContainer layoutContainer = EJCoreProperties.getInstance().getLayoutContainer();
// Now build the application container
EJRWTApplicationContainer appContainer = new EJRWTApplicationContainer(layoutContainer);
// Add the application menu and status bar to the app
// container
EJMessenger messenger = applicationManager.getApplicationMessenger();
if (messenger == null) {
throw new NullPointerException("The ApplicationComponentProvider must provide an Messenger via method: getApplicationMessenger()");
}
Display display = Display.getDefault();
if (display.isDisposed())
display = new Display();
Shell shell = new Shell(display, SWT.NO_TRIM);
// check test mode
StartupParameters service = RWT.getClient().getService(StartupParameters.class);
if (service != null && Boolean.valueOf(service.getParameter("TEST_MODE"))) {
EJ_RWT.setTestMode(true);
}
try {
preApplicationBuild(applicationManager);
} finally {
applicationManager.getConnection().close();
}
applicationManager.buildApplication(appContainer, shell);
final EJRWTApplicationManager appman = applicationManager;
Display.getCurrent().asyncExec(new Runnable() {
@Override
public void run() {
try {
postApplicationBuild(appman);
} finally {
appman.getConnection().close();
}
}
});
shell.layout();
shell.setMaximized(true);
// disable due to RWT bug
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=410895
// ExitConfirmation confirmation =
// RWT.getClient().getService(ExitConfirmation.class);
// String message = getDefaultTabCloseMessage();
// if ("__DEFAULT__".equals(message))
// {
// confirmation.setMessage(String.format("Do you want to close %s ?",
// EJCoreProperties.getInstance().getLayoutContainer().getTitle()));
// }
// else if (message != null)
// {
// confirmation.setMessage(message);
// }
final ServerPushSession pushSession = new ServerPushSession();
RWT.getUISession().addUISessionListener(new UISessionListener() {
public void beforeDestroy(UISessionEvent event) {
if (applicationManager.getApplicationActionProcessor() != null)
try {
applicationManager.getApplicationActionProcessor().whenApplicationEnd(applicationManager);
} catch (EJActionProcessorException e) {
e.printStackTrace();
}
pushSession.stop();
}
});
if (applicationManager.getApplicationActionProcessor() != null)
try {
applicationManager.getApplicationActionProcessor().whenApplicationStart(applicationManager);
} catch (EJActionProcessorException e) {
e.printStackTrace();
}
EJFrameworkExtensionProperties definedProperties = coreProperties.getApplicationDefinedProperties();
if (definedProperties != null && definedProperties.getBooleanProperty("LIVE_CONNECTION", false))
pushSession.start();
return openShell(display, shell);
}
};
}
}, properties);
// services
{
final String SERVICE = "SERVICE";
final String SERVICE_LIST = "SERVICE_LIST";
final String SERVICE_PATH = "SERVICE_PATH";
final String SERVICE_FORM = "SERVICE_FORM";
final String SERVICE_NAME = "SERVICE_NAME";
EJFrameworkExtensionProperties definedProperties = coreProperties.getApplicationDefinedProperties();
if (canLoadServices() && definedProperties != null) {
EJFrameworkExtensionProperties group = definedProperties.getPropertyGroup(SERVICE);
if (group != null && group.getPropertyList(SERVICE_LIST) != null) {
EJCoreFrameworkExtensionPropertyList list = group.getPropertyList(SERVICE_LIST);
List<EJFrameworkExtensionPropertyListEntry> allListEntries = list.getAllListEntries();
for (EJFrameworkExtensionPropertyListEntry entry : allListEntries) {
final String formId = entry.getProperty(SERVICE_FORM);
HashMap<String, String> srvproperties = new HashMap<String, String>(properties);
srvproperties.put(WebClient.PAGE_TITLE, entry.getProperty(SERVICE_NAME));
if (entry.getProperty(SERVICE_PATH) != null && formId != null && formId != null) {
configuration.addEntryPoint(String.format("/%s", entry.getProperty(SERVICE_PATH)), new EntryPointFactory() {
public EntryPoint create() {
try {
RWT.getServiceManager().registerServiceHandler(VACSSServiceHandler.SERVICE_HANDLER, new VACSSServiceHandler());
RWT.getServiceManager().registerServiceHandler(EJRWTFileDownload.SERVICE_HANDLER, EJRWTFileDownload.newServiceHandler());
registerServiceHandlers();
} catch (java.lang.IllegalArgumentException e) {
// ignore if already registered
}
registerWidgetHandlers();
final EntryPoint wrapped = newServiceEntryPoint(formId);
return new EntryPoint() {
public int createUI() {
BrowserNavigation service = RWT.getClient().getService(BrowserNavigation.class);
BrowserNavigationListener listener = new BrowserNavigationListener() {
@Override
public void navigated(BrowserNavigationEvent event) {
EJRWTContext.getPageContext().setState(event.getState());
}
};
service.addBrowserNavigationListener(listener);
int createUI = wrapped.createUI();
return createUI;
}
};
}
private EntryPoint newServiceEntryPoint(String serviceFormID) {
return new EntryPoint() {
public int createUI() {
RWTUtils.patchClient(getWebPathContext(), null);
EJRWTImageRetriever.setGraphicsProvider(new EJRWTGraphicsProvider() {
@Override
public void promptFileUpload(final EJFileUpload fileUpload, final Callable<Object> callable) {
if (fileUpload.isMultiSelection()) {
EJRWTFileUpload.promptMultipleFileUpload(fileUpload.getTitle(), fileUpload.getUploadSizeLimit(), fileUpload.getUploadTimeLimit(), fileUpload.getFileExtensions().toArray(new String[0]), new FileSelectionCallBack() {
@Override
public void select(String[] files) {
try {
fileUpload.setFilePaths(files != null ? Arrays.asList(files) : null);
callable.call();
} catch (Exception e) {
e.printStackTrace();
}
}
});
} else {
EJRWTFileUpload.promptFileUpload(fileUpload.getTitle(), fileUpload.getUploadSizeLimit(), fileUpload.getUploadTimeLimit(), fileUpload.getFileExtensions().toArray(new String[0]), new FileSelectionCallBack() {
@Override
public void select(String[] files) {
try {
fileUpload.setFilePaths(files != null ? Arrays.asList(files) : null);
callable.call();
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
}
public Image getImage(String name, ClassLoader loader) {
return RWTUtils.getImage(name, loader);
}
@Override
public void open(final String output, String outputName) {
EJRWTFileDownload.download(output, outputName);
RWT.getUISession().addUISessionListener(new UISessionListener() {
private static final long serialVersionUID = 1L;
@Override
public void beforeDestroy(UISessionEvent arg0) {
File f = new File(output);
if (f.exists()) {
f.delete();
}
}
});
}
public float getAvgCharWidth(Font font) {
return RWTUtils.getAvgCharWidth(font);
}
public int getCharHeight(Font font) {
return RWTUtils.getCharHeight(font);
}
public void rendererSection(final Section section) {
section.removeListener(SWT.Dispose, section.getListeners(SWT.Dispose)[0]);
section.removeListener(SWT.Resize, section.getListeners(SWT.Resize)[0]);
section.setFont(section.getParent().getFont());
section.setForeground(section.getParent().getForeground());
Object adapter = section.getAdapter(IWidgetGraphicsAdapter.class);
IWidgetGraphicsAdapter gfxAdapter = (IWidgetGraphicsAdapter) adapter;
gfxAdapter.setRoundedBorder(1, section.getTitleBarBackground(), 2, 2, 0, 0);
Listener listener = new Listener() {
public void handleEvent(Event e) {
Object adapter = section.getAdapter(IWidgetGraphicsAdapter.class);
IWidgetGraphicsAdapter gfxAdapter = (IWidgetGraphicsAdapter) adapter;
Color[] gradientColors = new Color[] { section.getTitleBarBorderColor(), section.getBackground(), section.getTitleBarBackground(), section.getBackground(), section.getBackground() };
int gradientPercent = 0;
Rectangle bounds = section.getClientArea();
if (bounds.height != 0) {
gradientPercent = 30 * 100 / bounds.height;
if (gradientPercent > 100) {
gradientPercent = 100;
}
}
int[] percents = new int[] { 0, 1, 2, gradientPercent, 100 };
gfxAdapter.setBackgroundGradient(gradientColors, percents, true);
gfxAdapter.setRoundedBorder(1, section.getBackground(), 4, 4, 0, 0);
}
};
section.addListener(SWT.Dispose, listener);
section.addListener(SWT.Resize, listener);
}
});
final EJRWTApplicationManager applicationManager;
if (this.getClass().getClassLoader().getResource("application.ejprop") != null) {
applicationManager = (EJRWTApplicationManager) EJFrameworkInitialiser.initialiseFramework("application.ejprop");
} else if (this.getClass().getClassLoader().getResource("EntireJApplication.properties") != null) {
applicationManager = (EJRWTApplicationManager) EJFrameworkInitialiser.initialiseFramework("EntireJApplication.properties");
} else {
throw new RuntimeException("application.ejprop not found");
}
EJRWTContext.getPageContext().setManager(applicationManager);
getContext().getUISession().setAttribute("ej.applicationManager", applicationManager);
EJCoreLayoutContainer layoutContainer = EJCoreProperties.getInstance().getLayoutContainer();
// Now build the application container
EJRWTApplicationContainer appContainer = new EJRWTApplicationContainer(layoutContainer);
// Add the application menu and status bar to the app
// container
EJMessenger messenger = applicationManager.getApplicationMessenger();
if (messenger == null) {
throw new NullPointerException("The ApplicationComponentProvider must provide an Messenger via method: getApplicationMessenger()");
}
Display display = Display.getDefault();
if (display.isDisposed())
display = new Display();
Shell shell = new Shell(display, SWT.NO_TRIM);
applicationManager.buildServiceApplication(appContainer, shell, formId);
final EJRWTApplicationManager appman = applicationManager;
Display.getCurrent().asyncExec(new Runnable() {
@Override
public void run() {
try {
postApplicationBuild(appman);
} finally {
appman.getConnection().close();
}
}
});
shell.layout();
shell.setMaximized(true);
final ServerPushSession pushSession = new ServerPushSession();
RWT.getUISession().addUISessionListener(new UISessionListener() {
public void beforeDestroy(UISessionEvent event) {
pushSession.stop();
}
});
pushSession.start();
return openShell(display, shell);
}
};
}
}, srvproperties);
}
}
}
}
}
}
Aggregations