0

GXT set DateField value from string

Here is the code to set GXT datefield value from the date string.

String sdate="24-01-2012";  //24 Jan 2012
DateTimeFormat dformat = DateTimeFormat.getFormat("dd-MM-yyyy");
DateField date2 = new DateField();
date2.getPropertyEditor().setFormat(dtFormat);
Date dDate= dformat.parse(sdate);
date2.setValue(dDate);
0

GXT Grid Column Alignment

How to align GXT grid column?
Answer : it can be done at ColumnConfig.
Here is sample code :

List configs = new ArrayList();

ColumnConfig column = new ColumnConfig();
column.setId("name");
column.setHeader("Company");
column.setWidth(200);
configs.add(column);

column = new ColumnConfig();
column.setId("symbol");
column.setHeader("Symbol");
column.setWidth(100);
configs.add(column);

column = new ColumnConfig();
column.setId("last");
column.setHeader("Last");
column.setAlignment(HorizontalAlignment.RIGHT);
column.setWidth(75);
column.setRenderer(gridNumber);
configs.add(column);

column = new ColumnConfig("change", "Change", 100);
column.setAlignment(HorizontalAlignment.RIGHT);
column.setRenderer(change);
configs.add(column);

The full example can be found here :
http://www.java2s.com/Code/Java/GWT/SetcolumnalignmentnameandheightExtGWT.htm
0

GWT Anchor Image Link

In my project, I need to display image link in GXT grid with the cursor changed to pointer when the cursor hover on the image. When clicked, it will open a new window.

Here is the code :

Anchor anchor =new Anchor();
final Image image = new Image("../resources/images/pdf.png");

anchor.addMouseOverHandler(new MouseOverHandler() {
    
    @Override
    public void onMouseOver(MouseOverEvent event) {
        DOM.setStyleAttribute(image.getElement(), "cursor", "pointer");
    }
});
                
anchor.addMouseOutHandler(new MouseOutHandler() {
    
    @Override
    public void onMouseOut(MouseOutEvent event) {
        DOM.setStyleAttribute(image.getElement(), "cursor", "default");                        
    }
});
anchor.addClickHandler(new ClickHandler() {
    
    @Override
    public void onClick(ClickEvent event) {
        String url="upload/" + model.get(property).toString();
        Window.open(url, "_blank", "");
        Info.display("Hardware", "Show Datasheet");
    }
});                
anchor.getElement().appendChild(image.getElement());            
return anchor;

0

GWT 2.4. Static Google Map in Frame not working

Before this static Google map can be viewed using Frame object and what I need to do is to give the URL of the static map. Please refer to my previous post http://peyotest.blogspot.com/2011/03/gwt-google-map-static-and-dynamic.html
 
Unfortunately, when I upgraded the GWT to version 2.4, it didn't display the image.
It works fine with web page but not image.
So I searched in Google, but there is no one having problem like I did.

Since the static map is an image, so I decided to use image object in GWT and it can be loaded from URL. That's nice and easy solution for me.

Here is the new code :


package com.vcari.jscadav2.client;

import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.ui.Frame;
import com.google.gwt.user.client.ui.Image;

public class SiteMapStaticMapPanel extends SiteMapPanel {

    public SiteMapStaticMapPanel(){
        super();
    }    
    
    Frame frame = new Frame("http://google.com");
    final Image image = new Image();


    @Override
    protected void onRender(Element parent, int index) {
        super.onRender(parent, index);
        //setLayout(new FitLayout());
        setBorders(false);
        image.setWidth("640");
        image.setHeight("430");
        image.setVisible(true);
        add(image);
    }
    
    /**
     * Set map center to the defined latitude and longitude
     * @param latitude
     * @param longitude
     */
    public void setMapCenter(Double latitude, Double longitude, int zoomLevel) {                
       Integer width=this.getWidth();
       Integer height=this.getHeight();
       String url="http://maps.google.com/maps/api/staticmap?center={0},{1}&zoom={2}&size={3}x{4}&maptype=roadmap&sensor=false";
       url+="&markers=color:red7C%{0},{1}";
       //url=String.format(url, latitude,longitude,zoomLevel,width,height);
       url=url.replace("{0}", latitude.toString());
       url=url.replace("{1}", longitude.toString());
       url=url.replace("{2}", String.valueOf(zoomLevel));
       url=url.replace("{3}", width.toString());
       url=url.replace("{4}", height.toString());
       url=url.replace("{5}",  Application.areaName);      
       image.setUrl(url);
    }
}
0

Win 7 Can't Login to Windows Sharing

There is a PC with newly installed Windows 7.
The computer failed to be connected to my office's file server on Windows 2003.
The server keep fail to authenticate the computer and the computer keep asking for user name and password.

The solution:

  • Browse to "Local Policies" -> "Security Options". 
  • Now look for the entry "Network Security: LAN Manager authentication level" and open it. 
  • Click on the dropdown menu and select "Send LM & NTLM - use NTLMv2 session security if negotiated".  Apply the settings.
      Jonathan Ravzin (MCT - Microsoft Certified Trainer)
      URL: http://social.technet.microsoft.com/Forums/en-US/w7itpronetworking/thread/68ffbe2a-09a7-4e29-859c-ca1aaf75dcd1/

0

Ghost Explorer

Ghost Explorer can be downloaded for free from Symantec.

ftp://ftp.symantec.com/public/english_us_canada/products/ghost/utilities/GHO_Explorer.exe

Using this software, ghost file can be view and extracted.
I use ghost software to create image for my Embedded Linux on VortexSx86.
0

GXT Paging ListView

Simply bind the store to ListView and loader to PagingToolBar.
Here is the source code. You might need to refer to my previous posting on JSON reader and paging grid.

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ppktechnology.assetmanagement.client;

import java.util.List;

import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.data.BaseListLoader;
import com.extjs.gxt.ui.client.data.BasePagingLoader;
import com.extjs.gxt.ui.client.data.BeanModel;
import com.extjs.gxt.ui.client.data.BeanModelReader;
import com.extjs.gxt.ui.client.data.ListLoadResult;
import com.extjs.gxt.ui.client.data.ListLoader;
import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.data.RpcProxy;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.ListViewEvent;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.util.Format;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.ListView;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
import com.extjs.gxt.ui.client.widget.toolbar.PagingToolBar;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.ppktechnology.assetmanagement.client.model.ImagesModel;
import com.vcari.client.utils.DataUtils;

/**
 * 
 * @author peyo
 */
@SuppressWarnings({ "rawtypes", "unchecked", "unused" })
public class ImagesList extends LayoutContainer {

    ListStore store = ImagesModel.getInstance().getPagingStore();
    int limit = 20;

    @Override
    protected void onRender(Element parent, int index) {
        super.onRender(parent, index);
        final ContentPanel panel = new ContentPanel();
        setLayout(new FitLayout());
        
        panel.setCollapsible(true);
        panel.setAnimCollapse(false);
        panel.setFrame(true);
        panel.setId("images-view");
        panel.setHeading("Simple ListView (0 items selected)");
        panel.setBodyBorder(false);
        panel.setLayout(new FitLayout());
                
        ListView<ModelData> view = new ListView<ModelData>() {
            @Override
            protected ModelData prepareData(ModelData model) {
                String s = model.get("imagedesc");
                model.set("imagedesc", Format.ellipse(s, 15));
                String thumbnail="images/" +  model.get("thumbnail");
                model.set("thumbnail", DataUtils.formatURL(thumbnail));
                String imagefile="images/" +  model.get("imagefile");
                model.set("imagefile", DataUtils.formatURL(imagefile));
                return model;
            }

        };

         view.addListener(Events.OnDoubleClick, new Listener<ListViewEvent<ModelData>>() {

                @Override
                public void handleEvent(ListViewEvent<ModelData> be) {
                    String imgurl = be.getModel().get("imagefile");
                    com.google.gwt.user.client.Window.open(imgurl, "_blank", "");
                }
            });
        
        final PagingToolBar pagingToolBar = new PagingToolBar(limit);
        pagingToolBar.bind((BasePagingLoader) store.getLoader());
        panel.setBottomComponent(pagingToolBar);
          
        view.setTemplate(getTemplate());
        view.setStore(store);
        view.setItemSelector("div.thumb-wrap");
        view.getSelectionModel().addListener(Events.SelectionChange, new Listener<SelectionChangedEvent<ModelData>>() {

            public void handleEvent(SelectionChangedEvent<ModelData> be) {
                panel.setHeading("Simple ListView (" + be.getSelection().size() + " items selected)");
            }

        });
        panel.add(view);
        add(panel);
        store.getLoader().load();
    }

    private native String getTemplate() /*-{
        return [ '<tpl for=".">', '<div class="thumb-wrap" id="{imageid}">',
                '<div class="thumb"><img src="{imagefile}" title="{imagedesc}"></div>',
                '<span class="x-editable">{imagedesc}</span></div>', '</tpl>',
                '<div class="x-clear"></div>' ].join("");

    }-*/;

}

 
Copyright © peyotest