What is the best method to import a fixwidth file into a table with scriptella?
Textfile:
blabla bloblo ble bli
Columnwidth:
(1,7) (8,14) (15,21) (22,24)
Table:
T_IMPORT (
FIELD1 VARCHAR(8),
FIELD2 VARCHAR(8),
FIELD3 VARCHAR(8),
FIELD4 VARCHAR(4)
)
The solution I came up is:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE etl SYSTEM "http://scriptella.javaforge.com/dtd/etl.dtd">
<etl>
<connection id="database" url="jdbc:hsqldb:mem:mymemdb" user="SA" password=""/>
<connection id="in" driver="text" url="${filePath}test_import.txt" />
<query connection-id="in">
<script connection-id="database">
INSERT INTO T_IMPORT
VALUES (
?{column0.substring(0,7)},
?{column0.substring(8,14)},
?{column0.substring(15,21)},
?{column0.substring(22,24)});
</script>
</query>
</etl>
Related
I want to add a space and shade between each element in listview.
How the tool is drawn xml?
Create a xml file Shadow.xml in Android drawable folder.
<?xml version="1.0" encoding="utf-8" ?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item >
<shape
android:shape="rectangle">
<solid android:color="#android:color/darker_gray" />
<corners android:radius="5dp"/>
</shape>
</item>
<item android:right="6dp" android:left="6dp" android:bottom="9dp">
<shape
android:shape="rectangle">
<solid android:color="#android:color/white"/>
<corners android:radius="5dp"/>
</shape>
</item>
</layer-list>
Uasge: Set the shadow with background of Layout. Use divider property to set the space between each element in listview.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/parent"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:gravity="center"
android:background="#drawable/shadow"
android:orientation="vertical">
<ListView
android:id="#+id/listview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:dividerHeight="20px"
android:divider="#android:color/darker_gray"
android:layerType="software"
/>
</LinearLayout>
MainActivity:
ListView listView = FindViewById<ListView>(Resource.Id.listview);
string[] s = new string[] { "a", "b", "c","d","e","f","g","h","i","j","k" };
ArrayAdapter<string> arrayAdapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleListItem1, s);
listView.Adapter = arrayAdapter;
I make a menu according to this guide: https://www.youtube.com/watch?v=aGO-xcpJUBs
How to change the text color and background of the menu item?
my files:
styles.xml
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<style name="MyStyle"
parent="#android:style/Theme.DeviceDefault">
</style>
</resources>
2.menu.xml
<?xml version="1.0" encoding="utf-8" ?>
<menu tools.context=".MainActivity"
xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:title="#string/name"
android:showAsAction="always"
android:id="#+id/iname"/>
<item android:title="#string/email"
android:showAsAction="always"
android:id="#+id/iemail"/>
</menu>
adding this line does not give anything:
android:textColor="#android:color/black"
Change the background of the menu item
You could add an attribute in your styles.xml to change the menu background color :
<item name="android:itemBackground">#FFFCF8FA</item>
Here is my styles.xml :
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<style name="Theme.MyTheme" parent="Theme.MyTheme.Base">
</style>
<!-- Base theme applied no matter what API -->
<style name="Theme.MyTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="windowActionModeOverlay">true</item>
<item name="colorPrimary">#color/primary</item>
<item name="colorPrimaryDark">#color/primaryDark</item>
<item name="colorAccent">#color/accent</item>
<item name="android:itemBackground">#FF8898F1</item>
</style>
</resources>
Change the text color of the menu item
You can implement this feature programmatically, change the color of the MenuItem text easily by using SpannableString instead of string.
Here is my code :
public override bool OnCreateOptionsMenu(IMenu menu)
{
MenuInflater.Inflate(Resource.Menu.menu_form, menu);
for (int i = 0; i < menu.Size(); i++)
{
IMenuItem item = menu.GetItem(i);
Android.Text.SpannableString spanString = new Android.Text.SpannableString(menu.GetItem(i).ToString());
spanString.SetSpan(new ForegroundColorSpan(Android.Graphics.Color.Red), 0, spanString.Length(), 0); //fix the color to red
item.SetTitle(spanString);
}
return true;
}
Effect.
An English font is working in HTML in webview, but the non-English font (Hindi) is not displaying in HTML in webview.
Here is my source code.
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="in.wptrafficanalyzer.webviewcustomfont"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="in.wptrafficanalyzer.webviewcustomfont.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
demo.html
<html>
<head>
<meta http-equiv="content-type" content="text/html;" charset="UTF-8">
<style>
/** Specify a font named "MyFont",
and specify the URL where it can be found: */
#font-face {
font-family: "MyFont";
src: url('file:///android_asset/fonts/BLKCHCRY.TTF');
}
h2 { font-family:"MyFont"}
#font-face {
font-family: "MyFontSD";
src: url('file:///android_asset/fonts/SHREE-DEV7-1076H.TTF');
}
h1 { font-family:"MyFontSD"}
</style>
</head>
<body>
<h2>
Welcome to BLACK CHANCERY FONT
</h2>
<h1>
1234567890
Am{X
</h1>
</body>
</html>
activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<WebView
android:id="#+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="#string/hello_world" />
</RelativeLayout>
MainActivity.java
package in.wptrafficanalyzer.webviewcustomfont;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.webkit.WebView;
public class MainActivity extends Activity {
WebView mWebView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Getting reference to WebView of the activity_main layout
mWebView = (WebView) findViewById(R.id.webview);
// Loading an HTML page into webview
mWebView.loadUrl("file:///android_asset/demo.html");
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
Note:
HTML file demo.html is copied in the assets folder
BLKCHCRY.TTF font file is copied in fonts folder
SHREE-DEV7-1076H.TTF font file is copied in fonts folder
Link to download fonts (SHREE-DEV7-1076H.TTF and BLKCHCRY.TTF)
I'm trying to edit the helloworld from this tutorial:
https://developer.mozilla.org/en-US/Add-ons/Overlay_Extensions/XUL_School/Getting_Started_with_Firefox_Extensions
So, I need to execute a function when page loads, this part of the tutorial explains how to do that:
https://developer.mozilla.org/en-US/Add-ons/Overlay_Extensions/XUL_School/Adding_Events_and_Commands
I edited the browserOverlay.js file, I writed the init function and that listener at the end of the code:
/**
* XULSchoolChrome namespace.
*/
if ("undefined" == typeof(XULSchoolChrome)) {
var XULSchoolChrome = {};
};
/**
* Controls the browser overlay for the Hello World extension.
*/
XULSchoolChrome.BrowserOverlay = {
init : function(event) {
window.alert('aaaaeeee');
},
/**
* Says 'Hello' to the user.
*/
sayHello : function(aEvent) {
let stringBundle = document.getElementById("xulschoolhello-string-bundle");
let message = stringBundle.getString("xulschoolhello.greeting.label");
window.alert(message);
}
};
window.addEventListener("load", function() {
//window.removeEventListener("load", onFirefoxLoadEvent, false); // remove listener, no longer needed
XULSchoolChrome.BrowserOverlay.init();
}, false);
and I edited the broserOverlay.xul, I writed the onload propertie at overlay tag:
<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="chrome://global/skin/" ?>
<?xml-stylesheet type="text/css"
href="chrome://xulschoolhello/skin/browserOverlay.css" ?>
<!DOCTYPE overlay SYSTEM
"chrome://xulschoolhello/locale/browserOverlay.dtd">
<overlay id="xulschoolhello-browser-overlay"
onload="XulSchoolChrome.BrowserOverlay.init();"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/x-javascript"
src="chrome://xulschoolhello/content/browserOverlay.js" />
<stringbundleset id="stringbundleset">
<stringbundle id="xulschoolhello-string-bundle"
src="chrome://xulschoolhello/locale/browserOverlay.properties" />
</stringbundleset>
<menubar id="main-menubar">
<menu id="xulschoolhello-hello-menu" label="&xulschoolhello.hello.label;"
accesskey="&xulschoolhello.helloMenu.accesskey;" insertafter="helpMenu">
<menupopup>
<menuitem id="xulschoolhello-hello-menu-item"
label="&xulschoolhello.hello.label;"
accesskey="&xulschoolhello.helloItem.accesskey;"
oncommand="XULSchoolChrome.BrowserOverlay.sayHello(event);" />
</menupopup>
</menu>
</menubar>
<vbox id="appmenuSecondaryPane">
<menu id="xulschoolhello-hello-menu-2" label="&xulschoolhello.hello.label;"
accesskey="&xulschoolhello.helloMenu.accesskey;"
insertafter="appmenu_addons">
<menupopup>
<menuitem id="xulschoolhello-hello-menu-item-2"
label="&xulschoolhello.hello.label;"
accesskey="&xulschoolhello.helloItem.accesskey;"
oncommand="XULSchoolChrome.BrowserOverlay.sayHello(event);" />
</menupopup>
</menu>
</vbox>
</overlay>
It does not alert on page loads.... why?
I am building app on demo MyFiorri application and I have problem binding data using ODATA. I defined odata in component.js
jQuery.sap.declare("sap.ui.demo.myFiori.Component");
sap.ui.core.UIComponent.extend("sap.ui.demo.myFiori.Component", {
createContent : function() {
// create root view
var oView = sap.ui.view({
id : "app",
viewName : "sap.ui.demo.myFiori.view.App",
type : "JS",
viewData : { component : this }
});
// set i18n model
var i18nModel = new sap.ui.model.resource.ResourceModel({
bundleUrl : "i18n/messageBundle.properties"
});
oView.setModel(i18nModel, "i18n");
// // Using OData model to connect against a real service
var url = "http://localhost:8080/serveris/SERVERIS.svc/";
var oModel = new sap.ui.model.odata.ODataModel(url, true, "", "");
oView.setModel(oModel);
sap.ui.getCore().setModel(oModel);
// set device model
var deviceModel = new sap.ui.model.json.JSONModel({
isTouch : sap.ui.Device.support.touch,
isNoTouch : !sap.ui.Device.support.touch,
isPhone : sap.ui.Device.system.phone,
isNoPhone : !sap.ui.Device.system.phone,
listMode : sap.ui.Device.system.phone ? "None" : "SingleSelectMaster",
listItemType : sap.ui.Device.system.phone ? "Active" : "Inactive"
});
deviceModel.setDefaultBindingMode("OneWay");
oView.setModel(deviceModel, "device");
// done
return oView;
}
});
Now, I need to read these data:
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xml:base="http://localhost:8080/serveris/SERVERIS.svc/">
<script id="tinyhippos-injected"/>
<id>http://localhost:8080/serveris/SERVERIS.svc/Users</id>
<title type="text">Users</title>
<updated>2014-05-27T18:07:01.403+03:00</updated>
<author>
<name/>
</author>
<link href="Users" rel="self" title="Users"/>
<entry>
<id>
http://localhost:8080/serveris/SERVERIS.svc/Users(0)
</id>
<title type="text">Users</title>
<updated>2014-05-27T18:07:01.404+03:00</updated>
<category term="serveris.User" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
<link href="Users(0)" rel="edit" title="User"/>
<link href="Users(0)/TasklistDetails" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/TasklistDetails" title="TasklistDetails"type="application/atom+xml;type=feed"/>
<content type="application/xml">
<m:properties>
<d:Login>jonas</d:Login>
<d:Passw>saugus</d:Passw>
<d:UserId>0</d:UserId>
</m:properties>
</content>
</entry>
<entry>
<id>
http://localhost:8080/serveris/SERVERIS.svc/Users(1)
</id>
<title type="text">Users</title>
<updated>2014-05-27T18:07:01.405+03:00</updated>
<category term="serveris.User" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
<link href="Users(1)" rel="edit" title="User"/>
<link href="Users(1)/TasklistDetails" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/TasklistDetails" title="TasklistDetails"type="application/atom+xml;type=feed"/>
<content type="application/xml">
<m:properties>
<d:Login>petras</d:Login>
<d:Passw>pass</d:Passw>
<d:UserId>1</d:UserId>
</m:properties>
</content>
</entry>
</feed>
I made login.view.xml and login.controller.js in which i want ta access these data
login.view.xml
<core:View
controllerName="sap.ui.demo.myFiori.view.login"
xmlns="sap.m"
xmlns:l="sap.ui.layout"
xmlns:core="sap.ui.core" >
<Page
title="{i18n>LoginIn}">
<VBox
class="marginBoxContent" >
<items>
<Label text="username" />
<Input
id="nameInput"
type="Text"
placeholder="enter username ..." />
<Label text="Pasword" />
<Input
id="passwInput"
type="Password"
placeholder="enter password..." />
<Button text="Prisijungti" press="handleContinue" />
</items>
</VBox>
</Page>
</core:View>
login.controller.js
jQuery.sap.require("sap.ui.demo.myFiori.util.Formatter");
sap.ui.controller("sap.ui.demo.myFiori.view.login", {
handleContinue : function (evt) {
// var authinfo = this.getCore().getModel().getData().Users[0]; In this line I should get data
var name = this.getView().byId("nameInput").getValue();
var paswd = this.getView().byId("passwInput").getValue();
if (name == "authinfo.login" && paswd == "authinfo.passw") {
var context = evt.getSource().getBindingContext();
this.nav.to("Master", context);
}
else {
jQuery.sap.require("sap.m.MessageToast");
sap.m.MessageToast.show("there is no such user or bad login data");
}
}
});
I hope I clearly described my problem.
Put a debug breakpoint in handleContinue function and try to see what shows up in log for sap.ui.getCore().getModel().getData().
If you're able to log something, try to see this way in console:
var theModel = sap.ui.getCore().getModel()
theModel.oData
See what you get as the output and then you can continue.