Where has HtmlImport annotation gone? - vaadin

I am trying to include custom icons as described in this post. But I can not find the #HtmlImport annotation anymore (Flow V. 20). This annotation was widely used, should it have been replaced I would expect to find at least some documentation.
P.S. I also tried #StyleSheet("./styles/iconexp-iconset-svg.html")
bit it complains:
Couldn't find route for 'styles/iconexp-iconset-svg.html'

Bower was deprecated in favor of npm and HTML Imports in favor of ES modules in Vaadin 14. I don't remember when they were removed, but they are no longer supported in Vaadin 20.
You can check the migration instructions here: https://vaadin.com/docs/v14/guide/upgrading/v10-13/#migration-steps

Building off of Jouni's, here is an example using #JsModule.
(1) Define your iconset in a JavaScript file.
import '#polymer/iron-iconset-svg/iron-iconset-svg';
const templateElem = document.createElement('template');
templateElem.innerHTML = `
<iron-iconset-svg name="namespace"><svg><defs>
<g id="iconname">...</g>
...
</defs></svg></iron-iconset-svg>
`;
document.head.appendChild(templateElem.content);
(2) Import the file in your root layout class.
#JsModule("./icons.js")
public class RootLayout...

Related

Swift Package in workspace: import rule?

I create a swift package in my work space.
I followed this guide just to test things out:
https://sarunw.com/posts/how-to-modularize-existing-ios-projects-using-swift-package/
All went well.
One of the things I added to the package is:
public extension Color {
static let customRed:Color = Color(uiColor: UIColor(named: "customRed", in: .module, compatibleWith: nil)!)
}
I deleted the customRed from the Assets.xcassets in my main app after I added the Assets to the actual package.
Everything works fine now and the package uses the customRed as defined in the package Assets.xcassets.
I have a lot files that use that Color.customRed in the app and I was thinking I had to go to each file and add the import statement for the package at the top. So:
import MyColorPackage
Question: I don't understand why the app works fine without doing that. Files can use the Color.customRed call without adding the import MyColorPackage at the top of the file that uses it. How can files use that customRed without having the import MyColorPackage in the file? App runs fine without importing the module in the files that use the customRed. Why?
The reason for this is due to a longstanding swift bug so you’re not doing anything wrong per se. It has various forms, some fixed over the years, some not but in your case what happens is that the first file in your main project that imports MyColorPackage will cause the whole rest of the project to “see” that Color extension. In my experience this happens only with public extensions nowadays and your package happens to do just that - declare a public extension to SwiftUI’s Color
If you add some public entity in that package, say …
import SwiftUI
public enum MyColorTheme {
public static let myThemeButtonsColor = Color.green
}
… then you won’t be able to use MyColorTheme in any file that doesn’t import MyColorPackage, as per what is intuitively normal.
I would suggest to still add the missing imports whenever you use symbols from that package as this issue might be fixed in a future version and your project will fail to build
Reference: https://github.com/apple/swift/issues/46493

Which directives do I need to import to use material-list-item?

I'm migrating an application to Dart 2 and Angular 5.
I have this code in an html file
<material-list-item *ngFor="let key of keyList"
(trigger)="clickItem(key)">{{key}}
</material-list-item>
Everything works if I declare the use of 'materialDirectives' in the corresponding dart file, but if I only import 'MaterialListItemComponent', the click on the item is not triggered.
I actually tried to add a couple more directives, but using the following list does not work:
MaterialButtonComponent,
MaterialIconComponent,
MaterialDialogComponent,
MaterialListComponent,
MaterialListItemComponent,
MaterialInputComponent,
MaterialPopupComponent,
ModalComponent,
PopupSourceDirective,
ButtonDirective.
materialDirectives is deprecated and I don't wan't to include everything if not necessary. Looking for an answer to this question but also for a way to identify which directives are used by different components.
MaterialListItemComponent extends ButtonDirective which has the logic for trigger. So that should be all you need. Along with NgFor for just the code in your example.
The demo which is similar to your code uses:
FocusItemDirective,
FocusListDirective,
MaterialIconComponent,
MaterialListComponent,
MaterialListItemComponent,
MaterialSelectItemComponent,
NgFor
Is there any runtime errors?

Angular 4+ 3rd party module import 404 error with base tag

I am putting an angular portion into my MVC app. As such, I have added a tag to my layout view to find the Angular source code, and this is working great.
My issue arises in trying to add a 3rd party module to my project. I added it through the package.json with no problem, and added the module to my app.module.ts as follows:
import { FileUploadModule } from 'primeng/fileupload';
The reference is found, Visual Studio is happy, everything is fine. However, when I run the project locally, I get the following 404 error:
GET http://localhost:59911/src/primeng/fileupload 404 (Not Found)
It seems to me likely that the tag is causing the issue, but I can't remove it without killing the rest of the Angular functionality. Any hints? Can I add an override to the imports call?
Thanks, Mike
On PrimeNG's official website they suggested using import { FileUploadModule } from 'primeng/fileupload'; but it doesn't work any more. I guess they didn't update the docs.
You need { FileUploadModule } from 'primeng/primeng';
The structure is
In the primeng.d.ts file PrimeNG re-exported all modules.
export * from './components/fileupload/fileupload';
For now, no matter which PrimeNG module is used, it is all from primeng/primeng. Here's the imported modules in my project:
import {
ButtonModule,
CodeHighlighterModule,
ConfirmDialogModule,
FieldsetModule,
FileUploadModule,
GrowlModule,
MessagesModule
} from 'primeng/primeng';
The version I use is "primeng": "^4.2.1"
The issue was that primeng was not in the mapping, so it was looking for it in src.
I added the following to systemjs.config.js:
in maps:
'primeng': 'npm:primeng',
in packages:
primeng: {
defaultExtension: 'js'
}
Thanks for the help everyone!

Angular 2.0 Dart with Transformer and Router

Running into an weird issue when I use Angular 2.0 Dart. Basically I'm trying to use Router and using pub serve to transform it to JS using the angular transformer. However I get the following error
Cannot find reflection information on RouteRegistry
at dart.wrapException (http://localhost:8080/main.dart.js:2834:17)
at NoReflectionCapabilities.dart.NoReflectionCapabilities.factory$1 (http://localhost:8080/main.dart.js:31991:17)
at Reflector.dart.Reflector.factory$1 (http://localhost:8080/main.dart.js:15565:46)
at Binding.dart.Binding.resolve$0 (http://localhost:8080/main.dart.js:13499:41)
at dart.resolveBindings (http://localhost:8080/main.dart.js:13766:90)
at dart.Injector.static.Injector_resolve (http://localhost:8080/main.dart.js:13898:63)
at bootstrap_closure.dart.bootstrap_closure.call$0 (http://localhost:8080/main.dart.js:9374:37)
at dart._rootRun (http://localhost:8080/main.dart.js:20637:16)
at _ZoneDelegate.dart._ZoneDelegate.run$2 (http://localhost:8080/main.dart.js:22730:41)
at NgZone.dart.NgZone._run$4 (http://localhost:8080/main.dart.js:5098:24)
But removing the transformer
- angular2:
entry_points: web/main.dart
I can see my app and navigate through the routes properly, however the downside is that my Dart2JS file is now 2.8megs
Currently as of Alpha 28, this is not supported. Alpha 30 will have this fixed.
https://github.com/angular/angular/issues/1950
You could add "mirror_mode: verbose" to the angular2 transformer.
Does RouteRegistry come from a different package? If so make sure the angular transformer has also been added to that package (it doesn't have to specify any entry points). The new angular transformer works a lot differently than the old one and it is required on all packages, not just the application package.

Could not find class 'weka.core.FastVector',

I am using weka for my project. but get the error info"could not find class weka.core.FastVector" on the line below. I have already added weka.jar from the build path of the project by adding external jar file. How should I solve this problem? Thanks a lot for your time on reviewing my question.
import weka.core.Attribute;
import weka.core.FastVector;
import weka.core.Instance;
import weka.core.Instances;
FastVector atts;
private void setUpARFF(){
atts = new FastVector();}
I know that FastVector was marked as obsolete a while back, perhaps they've finally removed it. Are you using the dev version of weka (or what version are you using)? FastVector can be replaced with ArrayList (in dev version) so use that instead.

Resources