final TextField<Double> regularPrice = new TextField<Double>("regular", new PropertyModel<Double>(listItem.getModel(), "price"))
{
private static final long serialVersionUID = 1L;
#Override
protected void onConfigure()
{
super.onConfigure();
setEnabled(cashflowStatus.compareTo(CashflowStatus.M_MANUAL) < 0);
}
};
listItem.add(regularPrice);
regularPrice.add(new AjaxFormComponentUpdatingBehavior("onChange")
{
private static final long serialVersionUID = 1L;
#Override
protected void onUpdate(AjaxRequestTarget target)
{
Double updatedValue = listItem.getModelObject().getPrice());
}
});
I wan to get new updated value on change but I am getting the old value from the model. Isn't model get updated and it should give new updated value. Please let me know, what is getting wrong in above code and how to get updated value ?
You should also re-render your component :)
#Override
protected void onUpdate(AjaxRequestTarget target)
{
Double updatedValue = listItem.getModelObject().getPrice());
target.add(this.getComponent());
}
Related
I have 1.0.0 kafka stream application with two classes as below 'class FilterByPolicyStreamsApp' and 'class FilterByPolicyTransformerSupplier'. In my application, I read the events, perform some conditional checks and forward to same kafka in another topic. I able to get the producing time with 'eventsForwardTimeInMs' variable in FilterByPolicyTransformerSupplier class. But I unable to get the consuming time (with and without (de)serialization). How will I get this time? Please help me.
FilterByPolicyStreamsApp .java:
public class FilterByPolicyStreamsApp implements CommandLineRunner {
String policyKafkaTopicName="policy";
String policyFilterDataKafkaTopicName = "policy.filter.data";
String bootstrapServers="11.1.1.1:9092";
String sampleEventsKafkaTopicName = 'sample-.*";
String applicationId="filter-by-policy-app";
String policyFilteredEventsKafkaTopicName = "policy.filter.events";
public static void main(String[] args) {
SpringApplication.run(FilterByPolicyStreamsApp.class, args);
}
#Override
public void run(String... arg0) {
String policyGlobalTableName = policyKafkaTopicName + ".table";
String policyFilterDataGlobalTable = policyFilterDataKafkaTopicName + ".table";
Properties config = new Properties();
config.put(StreamsConfig.APPLICATION_ID_CONFIG, applicationId);
config.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers);
config.put(StreamsConfig.DEFAULT_TIMESTAMP_EXTRACTOR_CLASS_CONFIG, WallclockTimestampExtractor.class);
KStreamBuilder builder = new KStreamBuilder();
builder.globalTable(Serdes.String(), new JsonSerde<>(List.class), policyKafkaTopicName,
policyGlobalTableName);
builder.globalTable(Serdes.String(), new JsonSerde<>(PolicyFilterData.class), policyFilterDataKafkaTopicName,
policyFilterDataGlobalTable);
KStream<String, SampleEvent> events = builder.stream(Serdes.String(),
new JsonSerde<>(SampleEvent.class), Pattern.compile(sampleEventsKafkaTopicName));
events = events.transform(new FilterByPolicyTransformerSupplier(policyGlobalTableName,
policyFilterDataGlobalTable));
events.to(Serdes.String(), new JsonSerde<>(SampleEvent.class), policyFilteredEventsKafkaTopicName);
KafkaStreams streams = new KafkaStreams(builder, config);
streams.start();
streams.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
#Override
public void uncaughtException(Thread t, Throwable e) {
logger.error(e.getMessage(), e);
}
});
}
}
FilterByPolicyTransformerSupplier.java:
public class FilterByPolicyTransformerSupplier
implements TransformerSupplier<String, SampleEvent, KeyValue<String, SampleEvent>> {
private String policyGlobalTableName;
private String policyFilterDataGlobalTable;
public FilterByPolicyTransformerSupplier(String policyGlobalTableName,
String policyFilterDataGlobalTable) {
this.policyGlobalTableName = policyGlobalTableName;
this.policyFilterDataGlobalTable = policyFilterDataGlobalTable;
}
#Override
public Transformer<String, SampleEvent, KeyValue<String, SampleEvent>> get() {
return new Transformer<String, SampleEvent, KeyValue<String, SampleEvent>>() {
private KeyValueStore<String, List<String>> policyStore;
private KeyValueStore<String, PolicyFilterData> policyMetadataStore;
private ProcessorContext context;
#Override
public void close() {
}
#Override
public void init(ProcessorContext context) {
this.context = context;
// Call punctuate every 1 second
this.context.schedule(1000);
policyStore = (KeyValueStore<String, List<String>>) this.context
.getStateStore(policyGlobalTableName);
policyMetadataStore = (KeyValueStore<String, PolicyFilterData>) this.context
.getStateStore(policyFilterDataGlobalTable);
}
#Override
public KeyValue<String, SampleEvent> punctuate(long arg0) {
return null;
}
#Override
public KeyValue<String, SampleEvent> transform(String key, SampleEvent event) {
long eventsForwardTimeInMs = 0;
long forwardedEventCouunt = 0;
List<String> policyIds = policyStore.get(event.getCustomerCode().toLowerCase());
if (policyIds != null) {
for (String policyId : policyIds) {
/*
PolicyFilterData policyFilterMetadata = policyMetadataStore.get(policyId);
Do some condition checks on the event. If it satisfies then will forward them.
if(policyFilterMetadata == null){
continue;
}
*/
// Using context forward as event can map to multiple policies
long startForwardTime = System.currentTimeMillis();
context.forward(policyId, event);
forwardedEventCouunt++;
eventsForwardTimeInMs += System.currentTimeMillis() - startForwardTime;
}
}
return null;
}
};
}
}
I am writing a Market Watch program which displays live quotes in a JFXTreeTableView, but when I update the data in the ObservableList, it doesn't get updated in the JFXTreeTableView. The changeDataDemo() method is actually tracking changes in the prices and is working fine (I'm using RethinkDB changefeeds to do it.) However I have removed the changefeed code here to increase readability. There is a method that adds rows to TreeTableView and is working perfectly but I have removed the code from here.
This is my code:
public class MainWindow implements Initializable {
private ObservableList<MarketWatchEntry> marketWatchEntries = FXCollections.observableArrayList();
private JFXTreeTableColumn<MarketWatchEntry, String> instrument_token_col;
private JFXTreeTableColumn<MarketWatchEntry, String> exchange_col;
private JFXTreeTableColumn<MarketWatchEntry, String> instrument_type_col;
private JFXTreeTableColumn<MarketWatchEntry, String> symbol_col;
private JFXTreeTableColumn<MarketWatchEntry, String> expiry_col;
private JFXTreeTableColumn<MarketWatchEntry, Number> buy_qty_col;
private JFXTreeTableColumn<MarketWatchEntry, Number> buy_price_col;
private JFXTreeTableColumn<MarketWatchEntry, Number> seller_price_col;
private JFXTreeTableColumn<MarketWatchEntry, Number> sell_qty_col;
#FXML
private JFXTreeTableView<MarketWatchEntry> MarketWatch;
#Override
public void initialize(URL location, ResourceBundle resources) {
populateMarketWatch();
}
private void populateMarketWatch() {
instrument_token_col = new JFXTreeTableColumn<>("Instrument Token");
instrument_token_col.setPrefWidth(80);
instrument_token_col.setVisible(false);
instrument_token_col.setCellValueFactory((TreeTableColumn.CellDataFeatures<MarketWatchEntry, String> param) -> param.getValue().getValue().instrument_token);
exchange_col = new JFXTreeTableColumn<>("Exchange");
exchange_col.setPrefWidth(80);
exchange_col.setCellValueFactory((TreeTableColumn.CellDataFeatures<MarketWatchEntry, String> param) -> param.getValue().getValue().exchange);
instrument_type_col = new JFXTreeTableColumn<>("Instrument");
instrument_type_col.setPrefWidth(80);
instrument_type_col.setCellValueFactory((TreeTableColumn.CellDataFeatures<MarketWatchEntry, String> param) -> param.getValue().getValue().instrument_type);
symbol_col = new JFXTreeTableColumn<>("Symbol");
symbol_col.setPrefWidth(80);
symbol_col.setCellValueFactory((TreeTableColumn.CellDataFeatures<MarketWatchEntry, String> param) -> param.getValue().getValue().trading_symbol);
expiry_col = new JFXTreeTableColumn<>("Expiry");
expiry_col.setPrefWidth(80);
expiry_col.setCellValueFactory((TreeTableColumn.CellDataFeatures<MarketWatchEntry, String> param) -> param.getValue().getValue().expiry);
buy_qty_col = new JFXTreeTableColumn<>("Buy Qty");
buy_qty_col.setPrefWidth(80);
buy_qty_col.setCellValueFactory((TreeTableColumn.CellDataFeatures<MarketWatchEntry, Number> param) -> param.getValue().getValue().buy_qty);
buy_price_col = new JFXTreeTableColumn<>("Buyer Price");
buy_price_col.setPrefWidth(80);
buy_price_col.setCellValueFactory((JFXTreeTableColumn.CellDataFeatures<MarketWatchEntry, Number> param) -> param.getValue().getValue().buyer_price);
seller_price_col = new JFXTreeTableColumn<>("Seller Price");
seller_price_col.setPrefWidth(80);
seller_price_col.setCellValueFactory((TreeTableColumn.CellDataFeatures<MarketWatchEntry, Number> param) -> param.getValue().getValue().seller_price);
sell_qty_col = new JFXTreeTableColumn<>("Sell Qty");
sell_qty_col.setPrefWidth(80);
sell_qty_col.setCellValueFactory((TreeTableColumn.CellDataFeatures<MarketWatchEntry, Number> param) -> param.getValue().getValue().sell_qty);
final TreeItem<MarketWatchEntry> root = new RecursiveTreeItem<>(marketWatchEntries, RecursiveTreeObject::getChildren);
MarketWatch.getColumns().setAll(instrument_token_col, exchange_col, instrument_type_col, symbol_col, expiry_col,
buy_qty_col, buy_price_col, seller_price_col, sell_qty_col, ltp_col, ltq_col, open_price_col, high_price_col,
low_price_col, close_price_col, average_price_col, change_col, net_change_col);
MarketWatch.setRoot(root);
MarketWatch.setShowRoot(false);
}
private void changeDataDemo() {
marketWatchEntries.get(0).buyer_price = new SimpleDoubleProperty(100);
}
}
I have removed irrelevant code blocks to increase readability.
My question is how to get TreeTableView to update all the cells when the collection is updated with new data.
MarketWatchEntry class
class MarketWatchEntry extends RecursiveTreeObject<MarketWatchEntry> {
StringProperty instrument_token;
StringProperty exchange;
StringProperty instrument_type;
StringProperty trading_symbol;
StringProperty expiry;
DoubleProperty buy_qty;
DoubleProperty buyer_price;
DoubleProperty seller_price;
DoubleProperty sell_qty;
DoubleProperty last_price;
DoubleProperty last_qty;
DoubleProperty open_price;
DoubleProperty high_price;
DoubleProperty low_price;
DoubleProperty close_price;
DoubleProperty average_price;
DoubleProperty change;
DoubleProperty net_change;
public MarketWatchEntry(String instrument_token, String exchange, String instrument_type, String trading_symbol,
String expiry, double buy_qty, double buy_price, double sell_price, double sell_qty,
double last_price, double last_qty, double open_price, double high_price, double low_price,
double close_price, double average_price, double change, double net_change) {
this.instrument_token = new SimpleStringProperty(instrument_token);
this.exchange = new SimpleStringProperty(exchange);
this.instrument_type = new SimpleStringProperty(instrument_type);
this.trading_symbol = new SimpleStringProperty(trading_symbol);
this.expiry = new SimpleStringProperty(expiry);
this.buy_qty = new SimpleDoubleProperty(buy_qty);
this.buyer_price = new SimpleDoubleProperty(buy_price);
this.sell_qty = new SimpleDoubleProperty(sell_qty);
this.seller_price = new SimpleDoubleProperty(sell_price);
this.last_price = new SimpleDoubleProperty(last_price);
this.last_qty = new SimpleDoubleProperty(last_qty);
this.open_price = new SimpleDoubleProperty(open_price);
this.high_price = new SimpleDoubleProperty(high_price);
this.low_price = new SimpleDoubleProperty(low_price);
this.close_price = new SimpleDoubleProperty(close_price);
this.average_price = new SimpleDoubleProperty(average_price);
this.change = new SimpleDoubleProperty(change);
this.net_change = new SimpleDoubleProperty(net_change);
}
#Override
public boolean equals(Object obj) {
if (obj == null || getClass() != obj.getClass()) {
return false;
}
return this.instrument_token.getValue().equals(((MarketWatchEntry) obj).instrument_token.getValue());
}
#Override
public int hashCode() {
return 7 + 5 * Integer.valueOf(instrument_token.getValue());
}
}
The problem is in your changeDataDemo method:
private void changeDataDemo() {
marketWatchEntries.get(0).buyer_price = new SimpleDoubleProperty(100);
}
You are creating new instances of your properties instead of changing their values.
Something like this works:
private void changeDataDemo() {
marketWatchEntries.get(0).buyer_price.set(100);
}
But it is recommended to provide setters/getters on your Entity class:
class MarketWatchEntry extends RecursiveTreeObject<MarketWatchEntry> {
private final DoubleProperty buyer_price;
...
public MarketWatchEntry(String instrument_token, String exchange, String instrument_type, String trading_symbol,
String expiry, double buy_qty, double buy_price, double sell_price, double sell_qty) {
...
this.buyer_price = new SimpleDoubleProperty(buy_price);
...
}
public final DoubleProperty buyer_priceProperty() {
return buyer_price;
}
public final double getBuyer_price() {
return buyer_price.get();
}
public final void setBuyer_price(double value) {
buyer_price.set(value);
}
...
}
so you can just call:
private void changeDataDemo() {
marketWatchEntries.get(0).setBuyer_price(100);
}
In my code below I created a method which is: I would like to put a variable in putExtra that I can get it in the new activity. The problem is in the new activity gave me the first value(numtelephone) from first element in my list. I know that because of getItem(0), but how can I get the value( numtelephone ) for every element from the list?
public class ListClient extends Activity {
String myJSON,test;
TextView numt;
private static final String TAG_RESULTS="result";
private static final String TAG_NOMCLIENT = "nomclient";
private static String TAG_NUMTELEPHONE ="numtelephone";
private static final String TAG_DEPART ="depart";
private static final String TAG_DESTINATION ="destination";
private static final String TAG_NBRPERSONNE ="nbrpersonne";
JSONArray peoples = null;
ArrayList<HashMap<String, String>> personList;
ListView list;
#SuppressLint("NewApi")
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list_client);
list = (ListView) findViewById(R.id.list);
personList = new ArrayList<HashMap<String,String>>();
getData();
}
protected void showList(){
//json parsing etc...
ListAdapter adapter = new SimpleAdapter(
ListClient.this, personList, R.layout.list_item,
new String[]{TAG_NOMCLIENT,TAG_NUMTELEPHONE,TAG_DEPART,TAG_DEPART,TAG_NBRPERSONNE},
new int[]{R.id.name, R.id.numt, R.id.depart, R.id.destination, R.id.nbrpersonne}
);
list.setAdapter(adapter);
}
public void getData(){
class GetDataJSON extends AsyncTask<String, Void, String>{
#Override
protected String doInBackground(String... params) {
// json dowload from web, not needed in this question
return "";
}
#Override
protected void onPostExecute(String result){
myJSON=result;
showList();
}
}
GetDataJSON g = new GetDataJSON();
g.execute();
}
public void GoUpdate(View v ) {
Intent in = new Intent(getBaseContext(), Update.class);
in.putExtra("NUMTELEPHONE",((HashMap<String, String>)list.getAdapter().getItem(0)).get("numtelephone"));
}
startActivity(in);
}
}
There is simple and only one solution. Delete your xml android:click property of list and add this list#setOnItemClickListener in your onCreate:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list_client);
list = (ListView) findViewById(R.id.list);
personList = new ArrayList<HashMap<String,String>>();
getData();
//this thing has been added
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if(id!=-1){
Intent in = new Intent(getBaseContext(), Update.class);
in.putExtra("NUMTELEPHONE", ((HashMap<String, String>) list.getAdapter().getItem((int)id)).get("numtelephone")); //TAG_NUMTELEPHONE
startActivity(in);
}
}
});
}
To move it from onCreate do:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list_client);
list = (ListView) findViewById(R.id.list);
personList = new ArrayList<HashMap<String, String>>();
getData();
list.setOnItemClickListener(new OnMyListItemClickListener());
}
Context context = this;
private class OnMyListItemClickListener implements AdapterView.OnItemClickListener {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if(id!=-1){
Intent in = new Intent(context, Update.class);
in.putExtra("NUMTELEPHONE", ((HashMap<String, String>) list.getAdapter().getItem((int) id)).get("numtelephone")); //TAG_NUMTELEPHONE
startActivity(in);
}
}
}
Lesson learned - dont create sucha buttons - they are not aware in which item they are, so you cant extract the id - instead just use something like AlertDialog
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if(id!=-1){
AlertDialog.Builder al = new AlertDialog.Builder(context);
al.setMessage("Are you sure you want to do it?");
al.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialogInterface, int i) {
Intent in = new Intent(context, Update.class);
in.putExtra("NUMTELEPHONE", ((HashMap<String, String>) list.getAdapter().getItem((int) id)).get(TAG_NUMTELEPHONE));
startActivity(in);
}
});
al.setNegativeButton(android.R.string.no, null);
al.show();
}
}
Hi i have been strugguling with this for a while. could you please suggest changes.
public class JobDetails extends Panel implements Serializable {
private static Logger LOGGER = Logger.getLogger(JobDetails.class);
public static final long serialVersionUID = 42L;
private List<Job> list;
#Override
protected void onInitialize() {
super.onInitialize();
}
public JobDetails(String id, final PageParameters params) {
super(id);
FeedbackPanel feedbackpanel = new FeedbackPanel("feedbackpanel");
add(feedbackpanel);
String JOBNUMBER = params.get("jobnumber").toString();
String OBJECTTYPE = params.get("objecttype").toString();
String OBJECTNUMBER = params.get("objectnumber").toString();
if (JOBNUMBER != null) {
LOGGER.info("JOBNUMBER != null");
list = Utils.retrieve(JOBNUMBER);
} else {
list = Utils.retrieve(OBJECTTYPE, OBJECTNUMBER);
}
DataView dataView = new DataView("jobs", new ListDataProvider(list)) {
#Override
public void onConfigure() {
super.onConfigure();
setVisible(getDataProvider().size() > 0);
}
#Override
protected void populateItem(final Item item) {
final Job job = (Job) item.getModelObject();
Link plink = new Link("parentJobLink") {
#Override
public void onClick() {
PageParameters p2 = new PageParameters();
p2.add("jobNumber", job.getParentJob());
JobDetails.this.replaceWith(new ParentJobDetails("innerpanel", p2));
}
};
plink.add(new Label("parentJobLabel", job.getParentJob()));
item.add(plink);
item.add(new Label("jobType", job.getJobType()));
item.add(new Label("whoSubmitted", job.getWhoSubmitted()));
item.add(new Label("objectType", job.getObjectType()));
item.add(new Label("objectNumber", job.getObjectNumber()));
item.add(new Label("objectRevision", job.getObjectRevision()));
item.add(new Label("jobStatus", job.getJobStatus()));
}
};
dataView.setItemsPerPage(20);
add(dataView);
add(new CustomPagingNavigator("navigator", dataView));
if (list.size() == 0) {
***"Replace the Current Panel with new(SearchInnerPanel("innerpanel", params)"***
}
}
}
Scenario: when i search for a job, if a job exists job is displayed in this panel and if the job does not exist it is redirected back to the search panel. i am unable to redirect back to the search panel.
Here is how the code should look really like:
public class JobDetails extends Panel {
private static final Logger LOGGER = Logger.getLogger(JobDetails.class);
public static final long serialVersionUID = 42L;
private List<Job> list;
public JobDetails(String id, final PageParameters params) {
super(id);
FeedbackPanel feedbackpanel = new FeedbackPanel("feedbackpanel");
add(feedbackpanel);
}
#Override
protected void onInitialize() {
super.onInitialize();
PageParameters params = getPage().getPageParameters();
String JOBNUMBER = params.get("jobnumber").toString();
String OBJECTTYPE = params.get("objecttype").toString();
String OBJECTNUMBER = params.get("objectnumber").toString();
if (JOBNUMBER != null) {
LOGGER.info("JOBNUMBER != null");
list = Utils.retrieve(JOBNUMBER);
} else {
list = Utils.retrieve(OBJECTTYPE, OBJECTNUMBER);
}
DataView dataView = new DataView("jobs", new ListDataProvider(list)) {
#Override
public void onConfigure() {
super.onConfigure();
setVisible(getDataProvider().size() > 0);
}
#Override
protected void populateItem(final Item item) {
final Job job = (Job) item.getModelObject();
Link plink = new Link("parentJobLink") {
#Override
public void onClick() {
PageParameters p2 = new PageParameters();
p2.add("jobNumber", job.getParentJob());
JobDetails.this.replaceWith(new ParentJobDetails("innerpanel", p2));
}
};
plink.add(new Label("parentJobLabel", job.getParentJob()));
item.add(plink);
item.add(new Label("jobType", job.getJobType()));
item.add(new Label("whoSubmitted", job.getWhoSubmitted()));
item.add(new Label("objectType", job.getObjectType()));
item.add(new Label("objectNumber", job.getObjectNumber()));
item.add(new Label("objectRevision", job.getObjectRevision()));
item.add(new Label("jobStatus", job.getJobStatus()));
}
};
dataView.setItemsPerPage(20);
add(dataView);
add(new CustomPagingNavigator("navigator", dataView));
if (list.size() == 0) {
replaceWith(new(SearchInnerPanel("innerpanel", params));
}
}
}
But it would be much better if you move the code that retrieves the list to the parent of this panel. If there are items in the list then use JobDetails panel, otherwise use SearchInnerPanel
I am having a small application in GWT , the main page is having the initWidget as VerticalPanel and inside there are just other VerticalPanel and horizontalPanels.
But I am not able to see browser scrolling. The verticalpanels are going beyond browser height but there is scrollbars appearing .
Any idea what could be the reason please.
thanks
code::
private Button btnLoad = new Button("load more results");
private CheckBox check_byPakag= new CheckBox("by package");
private CheckBox check_Inheritance= new CheckBox("by inheritance");
private CheckBox check_byComposition= new CheckBox("by composition");
private CheckBox check_byDependency= new CheckBox("by dependency");
private VerticalPanel vpnl_Main = new VerticalPanel();
private FlowPanel flowpanelImages = new FlowPanel();
private VerticalPanel scrollImages;
private IndexServiceAsync rpcService = GWT.create(IndexService.class);
private SuggestBox text_Wild_Card;
private MultiWordSuggestOracle oracle = new MultiWordSuggestOracle();
private int start = 0;
private int finish = 10; // Total number of results to display at first time
private int totalNumberOfResultsToShow = 10; //Total number of results to display on every call(when load more results button is pressed)
private int scrollPosition = 0;
private VerticalPanel vpnlScroll = new VerticalPanel();
public MainPageView(){
check_byPakag.setChecked(true);
check_Inheritance.setChecked(true);
check_byComposition.setChecked(true);
check_byDependency.setChecked(true);
initWidget(vpnl_Main);
getSuggestions();
scrollImages = new VerticalPanel();
scrollImages.add(vpnlScroll);
vpnlScroll.add(flowpanelImages);
btnLoad.setEnabled(false);
vpnl_Main.setSpacing(4);
Window.addResizeHandler(new ResizeHandler(){
#Override
public void onResize(ResizeEvent event) {
}});
}
public void getSuggestions(){
rpcService.getAllSuggestions(new AsyncCallback<List<String>>(){
#Override
public void onFailure(Throwable caught) {
System.out.println(caught.getMessage());
}
#Override
public void onSuccess(List<String> result) {
for(int i=0;i<result.size(); i++){
oracle.add(result.get(i));
}
text_Wild_Card = new SuggestBox(createWildCardOracle());
text_Wild_Card.setText("*");
layout(vpnl_Main);
getIndexData();
}});
}
#SuppressWarnings("deprecation")
public void getIndexData(){
final DecoratedPopupPanel popup = new DecoratedPopupPanel();
popup.setWidget(new Label("Loading.."));
popup.center();
rpcService.getIndexData(text_Wild_Card.getText(), check_byPakag.isChecked(), check_Inheritance.isChecked(), check_byComposition.isChecked(), check_byDependency.isChecked(), start, finish, new AsyncCallback<IndexDataSet>(){
#Override
public void onFailure(Throwable caught) {
Window.alert("getIndexData failed"+ caught.getMessage());
}
#Override
public void onSuccess(IndexDataSet result) {
flowpanelImages.clear();
if(result.hasMore()){
btnLoad.setEnabled(true);
}else{
btnLoad.setEnabled(false);
}
for(int i=0; i< result.getResults().size(); i++){
final Image image = new Image(result.getResults().get(i).stampImageURL);
//////////////
final Label lbl = new Label("dummy");
lbl.setStyleName("invisibleImageLabel");
VerticalPanel vpnlImage = new VerticalPanel();
vpnlImage.add(image);
vpnlImage.add(lbl);
//////////
final DataImage dataImage = new DataImage();
dataImage.setUrl(result.getResults().get(i).stampImageURL);
dataImage.setDescription(result.getResults().get(i).description);
image.addMouseOverHandler(new MouseOverHandler(){
#Override
public void onMouseOver(MouseOverEvent event) {
lbl.setText(dataImage.getDescription());
lbl.setStyleName("imageLabel");
}});
image.addMouseOutHandler(new MouseOutHandler(){
#Override
public void onMouseOut(MouseOutEvent event) {
lbl.setStyleName("invisibleImageLabel");
}});
image.addClickHandler(new ClickHandler(){
#Override
public void onClick(ClickEvent event) {
RootPanel.get("bodyContainer").clear();
History.newItem("diagramView / "+dataImage.getUrl());
}});
vpnlImage.addStyleName("imageStyle");
vpnlImage.addStyleName("paddedFlowPanel");
flowpanelImages.add(vpnlImage);
}
//
HorizontalPanel hpnlBtn = new HorizontalPanel();
hpnlBtn.setWidth("100%");
hpnlBtn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
hpnlBtn.add(btnLoad);
btnLoad.setStyleName("nextLine");
flowpanelImages.add(hpnlBtn);
popup.removeFromParent();
}});
}
private SuggestOracle createWildCardOracle() {
return oracle;
}
private void layout(VerticalPanel vpnl_Main) {
FlexTable flexWildCard = new FlexTable();
VerticalPanel vpnlCheckBoxes = new VerticalPanel();
HorizontalPanel hpnlWildCard = new HorizontalPanel();
flexWildCard.setWidget(0,0,new Label("Show only class diagrams containing classes named: (use * for wildcard)"));
flexWildCard.setWidget(0,1,text_Wild_Card);
text_Wild_Card.setWidth("200px");
vpnlCheckBoxes.setWidth("200px");
vpnlCheckBoxes.add(check_byPakag);
vpnlCheckBoxes.add(check_Inheritance);
vpnlCheckBoxes.add(check_byComposition);
vpnlCheckBoxes.add(check_byDependency);
hpnlWildCard.add(vpnlCheckBoxes);
hpnlWildCard.add(flexWildCard);
vpnl_Main.add(hpnlWildCard);
}