I'm using a motionchart in a gwt appliation. My question is how to create a Date object from a string? Following is my code:
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.visualization.client.AbstractDataTable;
import com.google.gwt.visualization.client.DataTable;
import com.google.gwt.visualization.client.VisualizationUtils;
import com.google.gwt.visualization.client.visualizations.LineChart;
import com.google.gwt.visualization.client.visualizations.MotionChart;
import com.google.gwt.visualization.client.visualizations.MotionChart.Options;
import com.google.gwt.visualization.client.AbstractDataTable.ColumnType;
import com.google.gwt.core.client.GWT;
import com.google.gwt.i18n.client.DateTimeFormat;
import component.client.SQLRunner;
import component.client.SQLRunnerAsync;
public class DashboardWidget
{
private HorizontalPanel containerPanel=null;
private DataTable data=null;
public DashboardWidget()
{
containerPanel = new HorizontalPanel();
}
public HorizontalPanel getContainerPanel()
{
SQLRunnerAsync service = (SQLRunnerAsync) GWT.create(SQLRunner.class);
AsyncCallback<ArrayList<String[]>> callback = new AsyncCallback<ArrayList<String[]>>()
{
#Override
public void onFailure(Throwable caught)
{
}
#Override
public void onSuccess(final ArrayList<String[]> result)
{
Runnable onLoadCallback = new Runnable()
{
public void run()
{
DataTable data = DataTable.create();
data.addColumn(ColumnType.STRING, " Name");
data.addColumn(ColumnType.DATE, "Date");
data.addColumn(ColumnType.NUMBER, "Count");
data.addColumn(ColumnType.NUMBER, "Something");
data.addColumn(ColumnType.NUMBER, "Something Else");
data.addRows(result.size());
#**SuppressWarnings("deprecation")
Date date = new Date(1888,06,01);
DateTimeFormat fmt = DateTimeFormat.getFormat("yyyy,MM,dd");**
for(int i=0;i<result.size();i++)
{
String[] temp = result.get(i);
String name=temp[0];//name
String count= temp[2];
String something=temp[3];
String seomthingElse=temp[5];
data.setValue(i, 0, name);//NAME
data.setValue(i, 1, date);//date
data.setValue(i, 2, Integer.parseInt(count));//eloc
data.setValue(i, 3, Integer.parseInt(something));//warning
data.setValue(i, 4, Integer.parseInt(somethingeElse));//static (open) warning
}
Options options = Options.create();
options.setWidth(1000);
options.setHeight(1000);
MotionChart chart = new MotionChart(data, options);
containerPanel.add(chart);
}
};
VisualizationUtils.loadVisualizationApi(onLoadCallback, MotionChart.PACKAGE);
}
};
service.getDataFromDatabase("","","","", callback);
return containerPanel;
}
}
So How Do I create a date object from String for a GWT application?
Can you not use the DateTimeFormat object? Something like this:
Date parsed = fmt.parse(text);
Related
I have two AutoCompleteTextView controls on the same page: ACTV1 and ACTV2 and only one (ACTV1 ) is showing suggestions from my database . For each databinding action I've made a java class separetely: ACTV1.java and ACTV2.java.
But if I am adding an intent filter (MAIN, LAUNCHER) in my manifest file for ACTV2.java class and setting in run configuration ACTV2.java as Launch Action then I won't get suggestions anymore for ACTV1 control but this time I'll get suggestions for ACTV2 control.
The two java classes are identically just that differ the name of some constants/controls name.
package com.fishing2;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONObject;
import android.app.Activity;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
public class CompleteBalti extends Activity {
//private CustomAutoCompleteView CompleteBalti;
private ArrayAdapter<String> adaperbalti;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_partida);
}
final TextWatcher textChecker = new TextWatcher() {
public void afterTextChanged(Editable s) {}
public void beforeTextChanged(CharSequence s, int start, int count, int after) { }
public void onTextChanged(CharSequence s, int start, int before, int count)
{
adaperbalti.clear();
callPHP1();
}
};
private void callPHP1(){
String result = "";
InputStream is=null;
AutoCompleteTextView CompleteBalti = (AutoCompleteTextView) findViewById(R.id.nume_localitate);
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("st",CompleteBalti.getText().toString()));
{
try{
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://192.168.3.159/wtf/balti.php");
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs,"utf-8"));
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(is,"utf-8"),8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
is.close();
result=sb.toString();
result = result.substring(1);
}catch(Exception e){
Log.e("log_tag", "Error in http connection "+e.toString());
}
try{
JSONArray jArray = new JSONArray(result);
JSONObject json_data = null;
for (int i=0;i<jArray.length(); i++)
{
json_data = jArray.getJSONObject(i);
adaperbalti.add(json_data.getString("nume_balta"));
}
} catch(Exception e1){
Log.e("log_tag", "Error converting result "+e1.toString());
}
}
}
}
I am writing a simple app to enter a user into database & display list of users using GWT RPC, Hibernate in Eclipse. The problem I am getting is that the list of users is printed twice.
Here is my code where I call insert user & display users list methods.
package rpctest.client;
import java.util.ArrayList;
import rpctest.shared.User;
import rpctest.shared.FieldVerifier;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.event.dom.client.KeyPressEvent;
import com.google.gwt.event.dom.client.KeyUpEvent;
import com.google.gwt.event.dom.client.KeyUpHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.event.dom.client.KeyPressEvent;
import com.google.gwt.event.dom.client.KeyPressHandler;
/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class Rpctest implements EntryPoint {
final TextBox firstName = new TextBox();
final TextBox lastName = new TextBox();
final Button ans = new Button("Add User");
//final Label label1 = new Label("First Name");
//final Label label2 = new Label("Last Name");
private FlexTable userFlexTable = new FlexTable();
//final Label errorLabel = new Label();
private VerticalPanel mainpanel = new VerticalPanel();
private HorizontalPanel addpanel1 = new HorizontalPanel();
private HorizontalPanel addpanel2 = new HorizontalPanel();
private final RpctestServiceAsync callService = GWT
.create(RpctestService.class);
/**
* This is the entry point method.
*/
public void onModuleLoad() {
userFlexTable.setText(0, 0, "User ID");
userFlexTable.setText(0, 1, "First Name");
userFlexTable.setText(0, 2, "Second Name");
userFlexTable.setText(0, 3, "Remove");
//add input boxes to panel
addpanel1.add(firstName);
addpanel1.add(lastName);
firstName.setFocus(true);
//add input/result panels
mainpanel.add(userFlexTable);
mainpanel.add(addpanel1);
addpanel1.add(ans);
ans.addClickHandler(new ClickHandler() {
#Override
public void onClick(ClickEvent event) {
addStock();
}
});
lastName.addKeyPressHandler(new KeyPressHandler() {
public void onKeyPress(KeyPressEvent event) {
if (event.getCharCode() == KeyCodes.KEY_ENTER) {
addStock();
}
}
});
RootPanel.get().add(mainpanel);
getUser();
}
private void addStock(){
String name1 = firstName.getValue();
// Stock code must be between 1 and 10 chars that are numbers, letters, or dots.
/*if (!name1.matches("^[0-9A-Z\\.]{1,10}$")) {
Window.alert("'" + name1 + "' is not a valid name.");
firstName.selectAll();
return;
}*/
firstName.setValue("");
String name2 = lastName.getValue();
/*if (!name2.matches("^[0-9A-Z\\.]{1,10}$")) {
Window.alert("'" + name1 + "' is not a valid name.");
lastName.selectAll();
return;
}*/
lastName.setValue("");
firstName.setFocus(true);
callService.addUser(name1,name2,
new AsyncCallback<String>() {
public void onFailure(Throwable caught) {
// Show the RPC error message to the user
Window.alert("check your inputs");
}
#Override
public void onSuccess(String result) {
// TODO Auto-generated method stub
// Add the user to the table.
// int row = userFlexTable.getRowCount();
// userFlexTable.setText(row, 1, result);
getUser();
}
});
}
private void getUser(){
callService.getUser(new AsyncCallback<User[]>() {
public void onFailure(Throwable caught) {
// Show the RPC error message to the user
Window.alert("Problem in database connection");
}
#Override
public void onSuccess(User[] result) {
// TODO Auto-generated method stub
for(int i = 0; i < result.length; i ++)
{
//String s = result[i].getFirstName();
int row = userFlexTable.getRowCount();
userFlexTable.setText(row, 0, result[i].getId().toString());
userFlexTable.setText(row, 1, result[i].getFirstName());
userFlexTable.setText(row, 2, result[i].getLastName());
}
}
});
}
}
Man did you notice that you are calling getUser twice if the entered Name is valid and the call to the service is successfull??
You have to remove one of them!
getUser is called on every new entry & all data is entered again into table.
I want a customized StyledText widget which can accept a keyword list,then highlight these keywords!
I found it's very hard to implement it by myself.
God damned! after spent hours searching the web, I finally found some sample code from the book The Definitive Guide to SWT and JFace, it's quite simple :
Main class :
package amarsoft.rcp.base.widgets.test;
import org.eclipse.jface.window.ApplicationWindow;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import amarsoft.rcp.base.widgets.SQLSegmentEditor;
public class PageDemo extends ApplicationWindow {
public PageDemo(Shell parentShell) {
super(parentShell);
final Composite topComp = new Composite(parentShell, SWT.BORDER);
FillLayout fl = new FillLayout();
fl.marginWidth = 100;
topComp.setLayout(fl);
new SQLSegmentEditor(topComp);
}
/**
* #param args
*/
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
new PageDemo(shell);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}
package amarsoft.rcp.base.widgets;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
/**
* SQL语句/SQL语句片段编辑器,除了内容编辑之外,提供一个额外的功能——常用SQL语句关键字高亮显示。
* #author ggfan#amarsoft
*
*/
public class SQLSegmentEditor extends Composite{
private StyledText st;
public SQLSegmentEditor(Composite parent) {
super(parent, SWT.NONE);
this.setLayout(new FillLayout());
st = new StyledText(this, SWT.WRAP);
st.addLineStyleListener(new SQLSegmentLineStyleListener());
}
}
package amarsoft.rcp.base.widgets;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.LineStyleEvent;
import org.eclipse.swt.custom.LineStyleListener;
import org.eclipse.swt.custom.StyleRange;
import org.eclipse.swt.graphics.Color;
import org.eclipse.wb.swt.SWTResourceManager;
public class SQLSegmentLineStyleListener implements LineStyleListener {
private static final Color KEYWORD_COLOR = SWTResourceManager
.getColor(SWT.COLOR_BLUE);
private List<String> keywords = new ArrayList<String>();
public SQLSegmentLineStyleListener() {
super();
keywords.add("select");
keywords.add("from");
keywords.add("where");
}
#Override
public void lineGetStyle(LineStyleEvent event) {
List<StyleRange> styles = new ArrayList<StyleRange>();
int start = 0;
int length = event.lineText.length();
System.out.println("current line length:" + event.lineText.length());
while (start < length) {
System.out.println("while lopp");
if (Character.isLetter(event.lineText.charAt(start))) {
StringBuffer buf = new StringBuffer();
int i = start;
for (; i < length
&& Character.isLetter(event.lineText.charAt(i)); i++) {
buf.append(event.lineText.charAt(i));
}
if (keywords.contains(buf.toString())) {
styles.add(new StyleRange(event.lineOffset + start, i - start, KEYWORD_COLOR, null, SWT.BOLD));
}
start = i;
}
else{
start ++;
}
}
event.styles = (StyleRange[]) styles.toArray(new StyleRange[0]);
}
}
I got the following code from http://robin.mytechtip.com/2010/11/17/gwt-celltable-example-using-asyncdataprovider/#comment-920. I am trying to get it to work with uibinder. The result is that all data is shown in the celltable and therefore the simplePager navigation is disabled.
package com.example.random.client.view;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import com.example.random.shared.Contact;
import com.google.gwt.cell.client.DateCell;
import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.cellview.client.CellTable;
import com.google.gwt.user.cellview.client.Column;
import com.google.gwt.user.cellview.client.SimplePager;
import com.google.gwt.user.cellview.client.TextColumn;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.view.client.AsyncDataProvider;
import com.google.gwt.view.client.HasData;
public class HtmlBinder extends Composite {
private static HtmlBinderUiBinder uiBinder = GWT
.create(HtmlBinderUiBinder.class);
interface HtmlBinderUiBinder extends UiBinder<Widget, HtmlBinder> {
}
#SuppressWarnings("deprecation")
private static final List<Contact> CONTACTS = Arrays.asList(new Contact(
"John", new Date(80, 4, 12), "123 Abc Avenue"), new Contact("Joe",
new Date(85, 2, 22), "22 Lance Ln"), new Contact("Tom", new Date(
85, 3, 22), "33 Lance Ln"), new Contact("Jack",
new Date(85, 4, 22), "44 Lance Ln"), new Contact("Tim", new Date(
85, 5, 22), "55 Lance Ln"), new Contact("Mike",
new Date(85, 6, 22), "66 Lance Ln"), new Contact("George",
new Date(46, 6, 6), "77 Lance Ln"));
/**
* The main CellTable.
*/
#UiField(provided = true)
CellTable<Contact> cellTable;
/**
* The pager used to change the range of data.
*/
#UiField(provided = true)
SimplePager pager;
public HtmlBinder() {
pager = new SimplePager();
cellTable = new CellTable<Contact>(3);
initWidget(uiBinder.createAndBindUi(this));
setupCellTable();
setupSimplePager();
}
private void setupSimplePager() {
pager.setDisplay(cellTable);
}
private void setupCellTable() {
// Add a text column to show the name.
TextColumn<Contact> nameColumn = new TextColumn<Contact>() {
#Override
public String getValue(Contact object) {
return object.getName();
}
};
cellTable.addColumn(nameColumn, "Name");
// Add a date column to show the birthday.
DateCell dateCell = new DateCell();
Column<Contact, Date> dateColumn = new Column<Contact, Date>(dateCell) {
#Override
public Date getValue(Contact object) {
return object.getBirthday();
}
};
cellTable.addColumn(dateColumn, "Birthday");
// Add a text column to show the address.
TextColumn<Contact> addressColumn = new TextColumn<Contact>() {
#Override
public String getValue(Contact object) {
return object.getAddress();
}
};
cellTable.addColumn(addressColumn, "Address");
// Associate an async data provider to the table
// XXX: Use AsyncCallback in the method onRangeChanged
// to actaully get the data from the server side
AsyncDataProvider<Contact> provider = new AsyncDataProvider<Contact>() {
#Override
protected void onRangeChanged(HasData<Contact> display) {
int start = display.getVisibleRange().getStart();
int end = start + display.getVisibleRange().getLength();
end = end >= CONTACTS.size() ? CONTACTS.size() : end;
List<Contact> sub = CONTACTS.subList(start, end);
updateRowData(start, sub);
}
};
provider.addDataDisplay(cellTable);
provider.updateRowCount(CONTACTS.size(), true);
}
}
Entrypoint ...
public void onModuleLoad() {
RootLayoutPanel.get().add(new HtmlBinder());
}
Here I have a set of resource bundles( a .properties java class) that been called by many classes in a eclipse project file. I just wondering is it eclipse got any shortcut key or function to identify automatically the class(resource bundles) from another package that have been call from another class in different package.
The line that call another package resource bundle is
private ResourceBundle useCaseResourceBundle;
The full code is
package my.com.infopro.icba10.accounting.ui.maintainproductgl;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.ResourceBundle;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.border.TitledBorder;
import my.com.infopro.icba10.accounting.delegate.AccountingDelegate;
import my.com.infopro.icba10.accounting.domain.GLField;
import my.com.infopro.icba10.accounting.domain.GLProduct;
import my.com.infopro.icba10.accounting.domain.GLProductDetail;
import my.com.infopro.icba10.admin.vlh.lov.CurrencyLov;
import my.com.infopro.icba10.kernel.uiframework.annotation.ValidationConfigFile;
import my.com.infopro.icba10.kernel.uiframework.binding.PresentationModelFactory;
import my.com.infopro.icba10.kernel.uiframework.component.CustomizedCombobox;
import my.com.infopro.icba10.kernel.uiframework.form.IconFactory;
import my.com.infopro.icba10.kernel.uiframework.form.IconType;
import my.com.infopro.icba10.kernel.uiframework.form.builders.CustomizedPanelBuilder;
import my.com.infopro.icba10.kernel.uiframework.form.builders.PanelBuilderFactory;
import my.com.infopro.icba10.kernel.uiframework.session.UserSessionProfileStore;
import my.com.infopro.icba10.kernel.uiframework.util.LayoutType;
import my.com.infopro.icba10.kernel.uiframework.validation.controls.CustomizedForm;
import my.com.infopro.icba10.kernel.util.configuration.CustomConfig;
import my.com.infopro.icba10.kernel.util.db.DataAccessMode;
import my.com.infopro.icba10.kernel.valuelisthandler.lov.Lov;
import org.apache.commons.beanutils.BeanComparator;
import org.apache.log4j.Logger;
import com.jgoodies.binding.beans.Model;
import com.jgoodies.binding.list.SelectionInList;
/* =================================================================================================
* HISTORY
* -------------------------------------------------------------------------------------------------
* Date Author Remarks
* -------------------------------------------------------------------------------------------------
* 2010/08/22 hmho class created
* =================================================================================================
*/
#ValidationConfigFile("my.com.infopro.icba10.cbs.core.ui.vconfig.maintainproductglset-vconfig")
public class MaintainProductGLCopyPopUp extends CustomizedForm implements ActionListener {
private Logger logger= Logger.getLogger(MaintainProductGLCopyPopUp.class);
private CustomConfig config = CustomConfig.getInstance();
private ResourceBundle useCaseResourceBundle;
private UserSessionProfileStore userSessionProfileStore= UserSessionProfileStore.getInstance();
private CustomizedCombobox currencyComboBox;
private CustomizedCombobox glSetCodeComboBox;
private JButton okButton = new JButton();
private GLProduct fromGLProduct;
private GLProduct toGLProduct;
private MaintainProductGLMaintForm form;
private String glSetCode;
private String glSetDescription;
private Map<String,List<GLProductDetail>> glDetailMap = new HashMap<String,List<GLProductDetail>>();
private AccountingDelegate accountingDelegate;
public MaintainProductGLCopyPopUp(MaintainProductGLMaintForm form,ResourceBundle useCaseResourceBundle,
GLProduct glProduct,Map<String,List<GLProductDetail>> glDetailMap) {
super();
this.form = form;
this.useCaseResourceBundle = useCaseResourceBundle;
this.toGLProduct = glProduct;
this.glDetailMap = glDetailMap;
}
#Override
public boolean isFormValidatable() {
return true;
}
public void init() {
initPanels();
initBindingAndValidation();
initCode();
initEventHandling();
}
private void initPanels() {
setLayout(new BorderLayout());
add(buildCopyPanel(), BorderLayout.CENTER);
}
private void initBindingAndValidation() {
fromGLProduct = new GLProduct();
presentationModelDelegate = PresentationModelFactory.getPresentationModel(this,
getFormBeans(), new String[]{GLProduct.class.getSimpleName()});
fromGLProduct.setBankingConcept(toGLProduct.getBankingConcept());
fromGLProduct.setModuleCode(toGLProduct.getModuleCode());
glSetCode = toGLProduct.getGlSetCode();
glSetDescription = toGLProduct.getGlSetDescription();
logger.debug("init in copy " );
logger.debug("toGLProduct " + toGLProduct.getGlSetCode());
logger.debug("toGLProduct " + toGLProduct.getGlSetDescription());
}
private void initCode() {
accountingDelegate = new AccountingDelegate();
Lov currencyLov = new CurrencyLov();
presentationModelDelegate.bindComboBoxWithValues(currencyComboBox, currencyLov);
}
private void initEventHandling() {
currencyComboBox.addActionListener(this);
okButton.addActionListener(this);
}
private JPanel buildCopyPanel() {
CustomizedPanelBuilder builder = PanelBuilderFactory.createPanelBuilder(LayoutType.SINGLE_CENTERED);
JPanel popupPanel = new JPanel();
popupPanel.setLayout(new BorderLayout());
popupPanel.setBorder(new TitledBorder (useCaseResourceBundle.getString("copyPanel")));
JPanel copyPanel = new JPanel();
currencyComboBox= new CustomizedCombobox();
glSetCodeComboBox= new CustomizedCombobox();
builder.addComponentGroup(useCaseResourceBundle.getString("currency"), "GLProduct.currencyCode", currencyComboBox);
builder.addComponentGroup(useCaseResourceBundle.getString("glSetCode"), "GLProduct.glSetCode", glSetCodeComboBox);
copyPanel = builder.getStandardPanel();
popupPanel.add(copyPanel, BorderLayout.CENTER);
popupPanel.add(buildButtonPanel(), BorderLayout.SOUTH);
return popupPanel;
}
private JPanel buildButtonPanel() {
JPanel innerButtonPanel = new JPanel();
okButton = new JButton();
okButton.setText(useCaseResourceBundle.getString("okButton"));
okButton.setIcon(IconFactory.createIcon(IconType.OK));
innerButtonPanel.add(okButton);
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new BorderLayout());
buttonPanel.add(innerButtonPanel,BorderLayout.EAST);
return buttonPanel;
}
public void registerComponentNames() {
}
#Override
protected void createFormBeans() {
fromGLProduct = new GLProduct();
}
#Override
public Model[] getFormBeans() {
return new Model[]{fromGLProduct};
}
#Override
protected void setFormBeans(final Model[] updatedBean) {
fromGLProduct = (GLProduct) updatedBean[0];
}
public void actionPerformed(ActionEvent event) {
// TODO Auto-generated method stub
final Object sourceObject = event.getSource();
if (sourceObject.equals(okButton)) {
if(null!=fromGLProduct.getCurrencyCode() && null!=fromGLProduct.getGlSetCode()){
setCopyData();
searchFrame.dispose();
}
}
if (sourceObject.equals(currencyComboBox)) {
List<GLProduct> glSetCodeList = accountingDelegate.findAvailableGlProduct(fromGLProduct);
if(glSetCodeList.size()<=0) {
glSetCodeList.add(new GLProduct());
}
presentationModelDelegate.bindComboBoxWithValues(glSetCodeComboBox, glSetCodeList, "glSetCode",true);
glSetCodeComboBox.createListCellRendererHandler();
}
}
private void setCopyData() {
userSessionProfileStore.setApplicationQueryCall();
logger.debug("copying " );
logger.debug("toGLProduct1 " + toGLProduct.getGlSetCode());
logger.debug("toGLProduct1 " + toGLProduct.getGlSetDescription());
GLProduct copyProduct = accountingDelegate.copyGLProducts(fromGLProduct, toGLProduct);
logger.debug("fromGLProduct " + fromGLProduct.getGlSetCode());
logger.debug("fromGLProduct " + fromGLProduct.getGlSetDescription());
logger.debug("copyProduct " + copyProduct.getGlSetCode());
logger.debug("copyProduct " + copyProduct.getGlSetDescription());
GLField glField = new GLField();
if(null!=copyProduct){
// copyProduct.setGlSetCode(glSetCode);
// copyProduct.setGlSetDescription(glSetDescription);
// Model[] models = new Model[] {copyProduct, glField};
// form.getPresentationModelDelegate().reinitBean(copyProduct);
if(copyProduct.getGLProductDetailList().size()>0){
form.getGlSetTableManagerModel().clearItems();
BeanComparator comparator = new BeanComparator("glField");
Collections.sort(copyProduct.getGLProductDetailList(), comparator);
form.setGlSetTableManagerModel(copyProduct.getGLProductDetailList());
logger.debug("Copy List Size 2 " + copyProduct.getGLProductDetailList().size());
}
SelectionInList selectionInList = form.getGlSetTableManagerModel()
.getItemSelectionsList();
List<GLProductDetail> glProductDetails = new ArrayList<GLProductDetail>();
glProductDetails.clear();
for(int i=0;i<selectionInList.getSize();i++){
GLProductDetail glProductDetail = (GLProductDetail) selectionInList
.getElementAt(i);
glProductDetail.setAction(DataAccessMode.INSERT);
glProductDetails.add(glProductDetail);
}
glDetailMap.clear();
glDetailMap.put(useCaseResourceBundle.getString("defaultCategoryCode"),glProductDetails);
form.setGlProductDetailMap(glDetailMap);
for(String key :form.getGlProductDetailMap().keySet()){
List<GLProductDetail>gls = form.getGlProductDetailMap().get(key);
for(GLProductDetail gl:gls){
logger.debug("Map " +gls.size());
if(null!=gl.getGlCode()){
logger.debug("Map " + gl.getGlField());
logger.debug("Map " + gl.getGlCode());
}
}
}
}
}
}
Is there any way so that i can use any key or function in eclipse to open the java file refer by the useCaseResourceBundle from this class. In some case its easier because the class already declared it clearly.
Example
private ResourceBundle resourceBundle = config.getPropResourceBundle("KERN_BUNDLE_UIFRAMEWORK");
Ctrl+Shift+G
or
Menu -> Search -> References -> ...
Search for references to the selected
element in the workspace / Project / Hierarchy / Working Set...