jsDoc #constructs not inherited by extending Objects? - mootools

I'm using #lends + #constructs + #augments for MooTools Class definitions (custom namespace variation), however I'm getting some inspection issues in PhpStorm in extending classes if I don't include an initialize in the extending class with a #constructs above it. Is it not possible in jsDoc to omit initialize in extending classes OR is PhpStorm inspection just not working correctly?
new Class('Validator.Generic',
/**
* #lends Validator.Generic
*/
{
/**
* #constructs
*/
initialize:function(){}
}
new Class('Validator.Regex',
/**
* #augments Validator.Generic
* #lends Validator.Regex
*/
{
//PhpStorm inspection reports unrecognized symbol Regex unless
//I add a method with #constructs here, even though the class
//it augments has a constructor
});
I've tried variations as well. It only works if I add an initialize to the extending class (e.g. Validator.Regex) along with a #constructs tag to the docblock. This of course is not ideal.

Try adding /** #class Validator.Regex */ above new Class('Validator.Regex')

#lena's answer partially works, but was still arbitrarily failing inspection in seemingly identical situations. I changed my approach and thought about the literal meanings of the tag names. Conclusion: '#class' is to define a type (pseudo statically), '#augments' and '#lends' in the context of a prototype based languages should then imply Instance extensions. This is intuitive in hind sight. All inspections now pass with the following syntax.
/**
* #class Validator.Regex
* #augments {Validator.Generic}
*/
new Class('Validator.Regex',
/**
* #lends {Validator.Regex}
*/
{}
);

Related

How to customise DefaultScheduleEvent and create our own event in PrimeFaces schedule

By default PrimeFaces DefaultScheduleEvent have the following attributes
Title, Description, start date, end date etc.
My question is how to include one or more custom attribute in schedule event.
A not so technical workaround that I used to generate a customized detail dialog is to determine the object type through styleClasses, for example:
public ScheduleModel getEventModel() {
if (eventModel == null) {
eventModel = new DefaultScheduleModel();
/*
* Just fill your model with a couple things, setting a specific styleClass
* for each type. Btw, you can also use this to give a specific appearance
* to each data type
*/
for(Activity act: myActivities){
event = new DefaultScheduleEvent(act.getActName(), act.getStartDate(), act.getEndDate(),"activity");
eventModel.addEvent(event);
}
for(Meeting meet : myMeetings){
event = new DefaultScheduleEvent(meet.getMeetPurpose(), meet.getStartDate(), meet.getEndDate(),"meeting");
eventModel.addEvent(event);
}
}
return eventModel
}
public void onEventSelect(SelectEvent selectEvent) {
if(selectEvent.getStyleClass().contains("activity")){
/*
* Search for object on DB and do stuff.
*/
}
}
In my onEventSelect you can use a searchForActivity(event.getTitle(), event.getStartDate(), event.getEndDate()) on your Session Bean to get all the info related to this specific object. Then you can build a regular view with the retrieved object.
I know this might not be the best way to achieve a "custom event", but will allow you to create whatever class you need and build views based on what you want to show to the user.
Hope it helps, kind regards :)

Arrow functions within classes are not supported in chrome but work fine through babel, why?

The correct syntax for writing arrow functions within a class should be
greet = () => {console.log('greet')}
While this compiles fine in Babel (using es2015 default) the chrome devtools throws an error.
This confuses me, as according to http://caniuse.com/#feat=arrow-functions they are completely supported in Chrome.
Is this a non-standard syntax? If so, why is it supported in Babel. If not, where can I see the support status
You seem to be talking about the class fields proposal:
Field declarations
With the ESnext field declarations proposal, the above example can be written as
class Counter extends HTMLElement {
x = 0;
clicked() {
this.x++;
window.requestAnimationFrame(this.render.bind(this));
}
constructor() {
super();
this.onclick = this.clicked.bind(this);
}
connectedCallback() { this.render(); }
render() {
this.textContent = this.x.toString();
}
}
window.customElements.define('num-counter', Counter);
In the above example, you can see a field declared with the syntax x = 0. You can also declare a field without an initializer as x. By declaring fields up-front, class definitions become more self-documenting; instances go through fewer state transitions, as declared fields are always present.
It's a stage 3 proposal and has nothing to do with arrow functions. Any value can be assigned to a field, including arrow functions.
While this compiles fine in Babel (using es2015 default)
I'm sure other plugins are configured. Since this is a proposal and not part of ES2016, only enabling the ES2015 preset won't transform this syntax.

Why is my class not showing up in autocomplete?

My class was not showing up in autocomplete. It was part of another file and I copied it into it's own file.
The reason it was not showing up was because it was marked internal.
package com.example.model
{
/**
* Holds data.
* */
internal class ChartItemData extends Item {
}
}
The part that was confusing was that it was the only class inside the package. I didn't know you could do that.
I changed it to public and it was immediately visible.

Disable Tab in TabBar

I have a small problem which is hopefully nothing for you. :-)
I have a tabbar in mxml-Form. It looks like that:
<mx:TabBar id="tabBar_" itemClick="clickEvt(event);" selectedIndex="1" creationComplete="check()">
<mx:dataProvider>
<mx:Object label="Components" data="{ComponentTabOverview}"/>
<mx:Object label="Products" data="{ProductTabOverview}"/>
</mx:dataProvider>
</mx:TabBar>
Now I have the problem that I have to check after creating the tabbar, from which state the tabbar is created.
And if its created from an particular state, the first tab has to be disabled.
I did that as follows:
public function check():void {
if(checkstate_){
tabBar_.getChildAt(0).enabled= false;
}
}
Unfortunately it doesn't work.
Can somebody help me out?
Thanks!!!!
Mike
There seems to be an undocumented (it's marked #private in the ASDOCs) property in the NavBar component called enbaledField. The TabBar component extends NavBar at some point in it's class hierarchy.
Here is the code from the Apache Flex github repo (included just so you can read the ASDOC comments):
/**
* #private
* Storage for the enabled property.
*/
private var _enabledField:String = "enabled";
[Bindable("enabledFieldChanged")]
[Inspectable(category="Data")]
/**
* Name of the the field in the <code>dataProvider</code> object
* to use as the enabled label.
*
* #default "enabled"
*
* #langversion 3.0
* #playerversion Flash 11.1
* #playerversion AIR 3.4
* #productversion Flex 4.10
*/
public function get enabledField():String
{
return _enabledField;
}
So theoretically (I don't have Flex installed either), if the elements in your dataProvider have a property called enabled you can disable individual buttons in the TabBar.
Alternatively, if you'd like to use some other field in the dataProvider elements to indicate that the button should be enabled/disabled, you can set a new value on the enableField property.
The caveat seems to be that the ASDOC says this was first included in Flex 4.10. But I think that is odd since this is an older MX component. However, it could be that this property was indeed added in Flex 4.10.
If it's true, that this is only in Flex 4.10, then you could copy the respective bits of code and implement it yourself as #zeus suggested. In particular make note of the private method createNavChildren() in the NavBar class where the magic happens:
//Check for enabled field and assign it to the individual button if it exists.
if (_enabledField != "" && item.hasOwnProperty(_enabledField) == true)
{
navItem.enabled = Boolean(item[_enabledField]);
}
else
{
navItem.enabled = enabled;
}
Here is a link to NavBar class in the github repo that has all of the above code.

Getting javascript error while using smart-gwt

I am using a combination of gwt and smart gwt. However i get the following eror whenever my page loads. please help me with fixing this. .
Please find the attached screenshot for the image of the popup error for the same
15:06:02.097 [ERROR] [detectfiles] 15:06:02.097:TMR5:WARN:Log:Error:
'Object required'
in /sc/modules/ISC_Core.js
at line 1782
[c]Element.getOffsetLeft(_1=>[DIVElement]{ID:isc_0})
[c]Element.getOffset(_1=>"left", _2=>[ImgButton ID:isc_ImgButton_0], _3=>undef, _4=>false, _5=>true)
Canvas.getLeftOffset(_1=>undef)
Canvas.getPageLeft()
Canvas.$414(null, undef)
[c]Page.handleEvent(_1=>null, _2=>"resize", _3=>undef)
[c]EventHandler.$78p(_1=>"landscape")
[c]EventHandler.$hr(_1=>undef)
callback(undefined=>undef)
"isc.EH.$hr()"
[c]Class.fireCallback(_1=>"isc.EH.$hr()", _2=>undef, _3=>Array[0], _4=>Obj{length:2}, _5=>true) on [Class Timer]
[c]Timer.$in(_1=>"$ir28")
anonymous()
"isc.Timer.$in('$ir28')"
com.smartgwt.client.core.JsObject$SGWT_WARN: 15:06:02.097:TMR5:WARN:Log:Error:
'Object required'
in /sc/modules/ISC_Core.js
at line 1782
[c]Element.getOffsetLeft(_1=>[DIVElement]{ID:isc_0})
[c]Element.getOffset(_1=>"left", _2=>[ImgButton ID:isc_ImgButton_0], _3=>undef, _4=>false, _5=>true)
Canvas.getLeftOffset(_1=>undef)
Canvas.getPageLeft()
Canvas.$414(null, undef)
[c]Page.handleEvent(_1=>null, _2=>"resize", _3=>undef)
[c]EventHandler.$78p(_1=>"landscape")
[c]EventHandler.$hr(_1=>undef)
callback(undefined=>undef)
"isc.EH.$hr()"
[c]Class.fireCallback(_1=>"isc.EH.$hr()", _2=>undef, _3=>Array[0], _4=>Obj{length:2}, _5=>true) on [Class Timer]
[c]Timer.$in(_1=>"$ir28")
anonymous()
"isc.Timer.$in('$ir28')"
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:105)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:292)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
at java.lang.Thread.run(Thread.java:662)
Here is a piece of code in which I am using TreeGrid inside a popup
private PopupPanel createConsoPopup() {
final PopupPanel consoPopup = new PopupPanel();
consoPopup.setAnimationEnabled(true);
consoPopup.setAutoHideEnabled(true);
VerticalPanel consoContent = new VerticalPanel();
VEPConsoTree consoTree = new VEPConsoTree(lineTreeNode, vepConsoTree);
vepConsoTree = consoTree.getCheckStationTree();
vepConsoTree.addSelectionChangedHandler(new SelectionChangedHandler() {
#Override
public void onSelectionChanged(SelectionEvent event) {
((TextBox)flexTable.getWidget(selectedRowNum, 0)).setText(vepConsoTree.getSelectedRecord().getAttribute("vepAreaName")+"_"+vepConsoTree.getSelectedRecord().getAttribute("checkStationName"));
consoPopup.hide();
}
});
consoContent.add(consoTree);
consoPopup.add(consoContent);
return consoPopup;
}
Following is my VEPConsoTree class:
package com.renault.veppwrstats.client;
import com.google.gwt.user.client.ui.Composite;
import com.smartgwt.client.types.TreeModelType;
import com.smartgwt.client.widgets.events.DrawEvent;
import com.smartgwt.client.widgets.events.DrawHandler;
import com.smartgwt.client.widgets.tree.Tree;
import com.smartgwt.client.widgets.tree.TreeGrid;
import com.smartgwt.client.widgets.tree.TreeNode;
public class VEPConsoTree extends Composite {
private TreeNode[] lineTreeNode;
private TreeGrid vepConsoTree;
//private DFConstantsForLocale constants = GWT.create(DFConstantsForLocale.class);
/**
* #param lineTreeNode
* #param vepConsoTree
*/
public VEPConsoTree(TreeNode[] lineTreeNode, TreeGrid vepConsoTree) {
super();
this.lineTreeNode = lineTreeNode;
this.vepConsoTree = vepConsoTree;
//Grid grid = chckStatRestrictPanel();
initWidget(vepConsoTree());
}
/**
* This function creates checkStation Restriction Panel(tree) along with
* Select/Unselect All button
*
* #return
*/
private TreeGrid vepConsoTree() {
return createTreeGrid();
}
/**
* This function creates CheckStation Restriction Tree
*
* #return {#link TreeGrid}
*/
private TreeGrid createTreeGrid() {
final TreeGrid chckTreeGrid = new TreeGrid();
chckTreeGrid.setHeight("269px");
chckTreeGrid.setWidth("250px");
chckTreeGrid.setData(createChkStationTree());
//chckTreeGrid.setSelectionAppearance(SelectionAppearance.CHECKBOX);
//chckTreeGrid.setShowPartialSelection(false);
//chckTreeGrid.setCascadeSelection(true);
chckTreeGrid.setFolderIcon(null);
chckTreeGrid.setNodeIcon(null);
chckTreeGrid.setShowConnectors(true);
chckTreeGrid.setShowHeader(false);
//addSelectionChangeHndler(chckTreeGrid);
chckTreeGrid.addDrawHandler(new DrawHandler() {
public void onDraw(DrawEvent event) {
chckTreeGrid.getTree().openAll();
}
});
vepConsoTree = chckTreeGrid;
return chckTreeGrid;
}
/**
* This function creates a basic tree
*/
private Tree createChkStationTree() {
Tree chckStationTree = new Tree();
chckStationTree.setModelType(TreeModelType.PARENT);
chckStationTree.setRootValue(1);
chckStationTree.setIdField("id");
chckStationTree.setOpenProperty("isOpen");
chckStationTree.setData(lineTreeNode);
chckStationTree.setParentIdField("parent");
return chckStationTree;
}
/**
* #return the vepConsoTree
*/
public final TreeGrid getCheckStationTree() {
return vepConsoTree;
}
/**
* #param vepConsoTree the vepConsoTree to set
*/
public final void setCheckStationTree(TreeGrid checkStationTree) {
this.vepConsoTree = checkStationTree;
}
/**
* #return the lineTreeNode
*/
public final TreeNode[] getLineTreeNode() {
return lineTreeNode;
}
/**
* #param lineTreeNode the lineTreeNode to set
*/
public final void setLineTreeNode(TreeNode[] lineTreeNode) {
this.lineTreeNode = lineTreeNode;
}
}
Short answer : don't mix GWT and SmartGWT when you can
Can I mix Smart GWT and GWT widgets?
Yes, with caveats.
Smart GWT has interoperability support that allows a Smart GWT widget
to be added to a GWT container and allows a GWT widget to be added to
a Smart GWT container, and it's appropriate to use this for:
incremental migration to Smart GWT, such as introducing singular,
sophisticated Smart GWT components like the Calendar or CubeGrid to an
existing GWT application
using sophisticated third-party GWT widgets within Smart GWT, where
Smart GWT doesn't have corresponding built-in functionality
However it does not make sense to freely intermix Smart GWT and GWT
(or other) components, that is, for example, you should not place GWT
widgets within a Smart GWT container that is in turn within a GWT
container. In general, don't intermix widgets unless the need for a
feature forces you to.
The reason for this is that there are limits to the maximum degree
that two Ajax widget kits (including GWT) can interoperate - there are
no standards that allow interoperability in the areas of management of
tab order, zIndex management, pixel-perfect layout, section 508
accessibility and multi-level modality.
Note that "bugs" reported when intermixing GWT and Smart GWT
inappropriately (that is, in contradiction to these guidelines) are
generally going to be marked WONTFIX, although we will revisit this in
the future if core GWT begins to support APIs that would allow better
interoperability.
If you really need to mix GWT and SmartGWT here are the guidelines from Isomorphic
Because Smart GWT's pixel-perfect layout and auto-sizing support goes
beyond the capabilities of simple CSS layout, components need to know
the actual pixel width they have been allocated by their parent
element; they cannot "flow into" an HTML element of unspecified size.
The issue here is that GWT's containers do not provide an API similar
to Smart GWT's Canvas.getInnerWidth(), which in Smart GWT can be used
by child components to find out the available space to draw themselves
in, and hence recursively lay out out their own children. Nor do GWT
containers fire events when they are resized, or when the available
width changes for various reasons (e.g. scrollbar(s) introduced, or
CSS style changes add borders and hence reduce space).
A lot of parent<->child coordination and signaling is required to
really create an extensible pixel-perfect layout system. Smart
GWT/SmartClient has implemented all the necessary hooks to allow a
third-party widget to be embedded inside a Canvas and participate in a
precise layout, but GWT is not there yet.
If you absolutely must place a Smart GWT interface inside a GWT
container and you want it to fill the container, the best approach is
to listen for a window-level resize event and run your own layout
calculations that ultimately call resizeTo() on your topmost Smart GWT
widget. All Smart GWT widgets nested under that topmost widget will
then handle layout normally.
NOTE: Don't bother trying to find a way to insert width:100% into
Smart GWT's rendered HTML, this won't work.
source : http://forums.smartclient.com/showthread.php?t=8159