I'm using an AjaxLink to open a Modal.
This modal displays first a "Are you sure" panel and then a panel with the result of the operation together with a Close button.
I close the modal and if I open it again I get the second panel and not the first.
I would like everytime the modal is opened to get the sequence of panels from the beginning, i.e., starting with the initial panel.
I tried to instantiate the modal inside the AjaxLink but I have issues with the html markup.
HTML
<wicket:panel>
<div wicket:id="modal2"></div>
<button class="btn btn-primary" wicket:id="link"><span
wicket:id="buttonLabel"></span></button>
</wicket:panel>
Java
public class ButtonPayment2 extends Panel{
private static final long serialVersionUID = 1L;
private Label label;
private List<String> current;
private String party;
private DetailsModal2 modal;
private String guid;
#SpringBean
private Environment env;
#SpringBean
private IService service;
public ButtonPayment2(String componentId, IModel<PaymentDomain> rowmodel, String invoiceId, String paymentId){
super(componentId);
current = service.getPById(rowmodel.getObject());
guid = rowmodel.getObject().getPaymentGUID();
initiateButton(current);
modal = new DetailsModal2("modal2",rowmodel,party){
#Override
public void closeAction(AjaxRequestTarget target, boolean toPass) {
super.closeAction(target, toPass);
}
};
modal.header(Model.of("Transaction process"));
modal.setHeaderVisible(true);
modal.setOutputMarkupId(true);
add(modal);
add(new AjaxLink("link"){
private static final long serialVersionUID = 1L;
#Override
public void onClick(AjaxRequestTarget target) {
modal.show(target);
target.add(this);
}//close onclick
}.add(label));//close ajaxLink
modal.detach();
}
}
DetailsModal2.java
public class DetailsModal2 extends Modal<IModel<PaymentDomain>> {
#SpringBean
private IService service;
private String party;
private BootstrapAjaxLink<String> noButton;
private ResponseMessage message;
private String paymentId;
private ProcessingPanel panel2;
private Panel replacedPanel;
private boolean booleanToPass;
private IModel<PaymentDomain> model;
public DetailsModal2(String id, IModel<PaymentDomain> model, String party) {
super(id);
this.party = party;
this.model = model;
this.paymentId = model.getObject().getGUID();
replacedPanel = new AreYouSure("replacedPanel");
replacedPanel.setOutputMarkupId(true);
add(replacedPanel);
panel2 = new ProcessingPanel("replacedPanel");
addButton(new BootstrapAjaxLink<String>("button", null, Buttons.Type.Warning, new ResourceModel("details")) {
private static final long serialVersionUID = 1L;
#Override
public void onClick(AjaxRequestTarget target) {
addNewPanel(new AjaxLazyLoadPanel("replacedPanel") {
#Override
public Component getLazyLoadComponent(String markupId) {
if (!condition) {
message = service.getPayment(paymentId);
if (message == null) {
booleanToPass = true;
return new VotingResultPanel(markupId, true);
} else {
return new VotingResultPanel(markupId, false);
}
} // close if
else if (condition)) {
message = service.setPayment(paymentId);
if (message == null) {
booleanToPass = false;
return new VotingResultPanel(markupId, true);
} else {
System.out.println("" + message.getError());
return new VotingResultPanel(markupId, false);
}
}
else {
System.out.println("It was not possible to access the db");
}
}
}, target);
this.setVisible(false);
target.add(this);
noButton.setLabel(Model.of("Close"));
target.add(noButton);
target.add(this);
}
});
noButton = new BootstrapAjaxLink<String>("button", null, Buttons.Type.Primary) {
private static final long serialVersionUID = 1L;
#Override
public void onClick(AjaxRequestTarget target){
closeAction(target,booleanToPass);
}
}.setLabel(Model.of("No"));
addButton(noButton);
}
public void closeAction(AjaxRequestTarget target, boolean flag){
close(target);
}
public void addNewPanel(Panel addpanel, AjaxRequestTarget target) {
Panel newPanel = null;
newPanel = addpanel;
newPanel.setOutputMarkupId(true);
replacedPanel.replaceWith(newPanel);
target.add(newPanel);
replacedPanel = newPanel;
}
}// close class
HTML of DetailsModal2
<wicket:extend>
<div><span wicket:id="replacedPanel"> </span></div>
</wicket:extend>
New solution for this particular case, DetailsModal2 changed:
public class DetailsModal2 extends Modal<IModel<PaymentDomain>> {
#SpringBean
private IService service;
private Component noButton;
private Component yesButton;
private Component noButton;
private String paymentId;
private Panel replacedPanel;
private IModel<PaymentDomain> model;
public DetailsModal2(String id, IModel<PaymentDomain> model, String party)
{
super(id);
this.party = party;
this.model = model;
this.paymentId = model.getObject().getPaymentGUID();
replacedPanel = new AreYouSure("replacedPanel");
replacedPanel = panel1;
replacedPanel.setOutputMarkupId(true);
add(replacedPanel);
addButton(yesButton = new BootstrapAjaxLink<String>("button", null, Buttons.Type.Warning, new ResourceModel("details")) {
private static final long serialVersionUID = 1L;
#Override
public void onClick(AjaxRequestTarget target) {
addNewPanel(new AjaxLazyLoadPanel("replacedPanel") {
#Override
public Component getLazyLoadComponent(String markupId) {
if (!condition)) {
message = service.getPayment(paymentId);
if (message == null) {
return new VotingResultPanel(markupId, true);
} else
{
return new VotingResultPanel(markupId, false);
}
} // close if
else if (condition)) {
message = service.setPayment(paymentId);
if (message == null) {
return new VotingResultPanel(markupId, true);
} else {
System.out.println("" + message.getError());
return new VotingResultPanel(markupId, false);
}
}
else {
System.out.println("error");
}
}
}, target);
this.setOutputMarkupPlaceholderTag(true);
this.setVisible(false);
noButton.setOutputMarkupPlaceholderTag(true);
noButton.setVisible(false);
closeButton.setVisible(true);
target.add(this, noButton, closeButton);
}
});
noButton = new BootstrapAjaxLink<String>("button", null, Buttons.Type.Primary) {
private static final long serialVersionUID = 1L;
#Override
public void onClick(AjaxRequestTarget target){
close(target);
}
}.setLabel(Model.of("No"));
addButton(noButton);
}
closeButton = new BootstrapAjaxLink<String>("button", null, Buttons.Type.Primary) {
private static final long serialVersionUID = 1L;
#Override
public void onClick(AjaxRequestTarget target){
addNewPanel(panel1,target);
yesButton.setOutputMarkupId(true);
yesButton.setVisible(true);
noButton.setOutputMarkupId(true);
noButton.setVisible(true);
closeButton.setOutputMarkupId(true);
closeButton.setOutputMarkupPlaceholderTag(true);
closeButton.setVisible(false);
target.add(yesButton,noButton,closeButton);
close(target);
}
}.setLabel(Model.of("Close"));
closeButton.setOutputMarkupPlaceholderTag(true);
closeButton.setVisible(false);
addButton(closeButton);
}
public void addNewPanel(Panel addpanel, AjaxRequestTarget target) {
Panel newPanel = null;
newPanel = addpanel;
newPanel.setOutputMarkupId(true);
replacedPanel.replaceWith(newPanel);
target.add(newPanel);
replacedPanel = newPanel;
}
}// close class
you can try to move the following lines
replacedPanel = new AreYouSure("replacedPanel");
replacedPanel.setOutputMarkupId(true);
add(replacedPanel);
to onConfigure and change add() to addOrReplace()
Related
We are using Java Spring framework. We have an endpoint for passing email object.
#RequestMapping(method = RequestMethod.POST, path = "/api/messaging/v1/emailMessages/actions/send")
String sendEmail(#RequestBody Email email);
Here checkmarx says: The email may unintentionally allow setting the value of cc in LinkedList<>, in the object Email.
Email Object is as follow:
public class Email {
private List<String> bcc = new LinkedList<>();
private List<String> cc = new LinkedList<>();
private String content;
private ContentType contentType = ContentType.TXT;
private String from;
private String returnPath;
private Date sent;
private String subject;
private List<EmailAttachment> attachments = new LinkedList<>();
private List<String> to = new LinkedList<>();
public List<String> getBcc() {
return bcc;
}
public void setBcc(String bcc) {
this.bcc = Collections.singletonList(bcc);
}
public void setBcc(List<String> bcc) {
this.bcc = bcc;
}
public List<String> getCc() {
return cc;
}
public void setCc(String cc) {
this.cc = Collections.singletonList(cc);
}
public void setCc(List<String> cc) {
this.cc = cc;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public ContentType getContentType() {
return contentType;
}
public void setContentType(ContentType contentType) {
this.contentType = contentType;
}
public String getFrom() {
return from;
}
public void setFrom(String from) {
this.from = from;
}
public String getReturnPath() {
return returnPath;
}
public void setReturnPath(String returnPath) {
this.returnPath = returnPath;
}
public Date getSent() {
return sent;
}
public void setSent(Date sent) {
this.sent = sent;
}
public String getSubject() {
return subject;
}
public void setSubject(String subject) {
this.subject = subject;
}
public List<String> getTo() {
return to;
}
public void setTo(String to) {
this.to = Collections.singletonList(to);
}
public void setTo(List<String> to) {
this.to = to;
}
public List<EmailAttachment> getAttachments() {
return attachments;
}
public void setAttachments(List<EmailAttachment> attachments) {
this.attachments = attachments;
}
public boolean equals(Object object) {
boolean equals = false;
if (object instanceof Email) {
Email that = (Email) object;
equals = Objects.equal(this.from, that.from)
&& Objects.equal(this.to, that.to)
&& Objects.equal(this.subject, that.subject)
&& Objects.equal(this.content, that.content);
}
return equals;
}
}
I don't understand these findings, how to solve this.
I have added Lombok with #Getter & #Setter annotation to resolve this issue.
I have a modal that displays 3 different panels consecutively (in agreement with the user's choices).
The second panel of this modal is an AjaxLazyLoadPanel and when it appears it is left aligned and not centred aligned, as it is shown in the image below.
Modal showing the busy indicator 1
How can I centre the busy indicator?
Below is the class of the modal
public class DetailsModal2 extends Modal<IModel<PaymentDomain>> {
#SpringBean
private IService service;
private Component noButton;
private Component yesButton;
private Component noButton;
private String paymentId;
private Panel replacedPanel;
private IModel<PaymentDomain> model;
public DetailsModal2(String id, IModel<PaymentDomain> model, String party)
{
super(id);
this.party = party;
this.model = model;
this.paymentId = model.getObject().getPaymentGUID();
replacedPanel = new AreYouSure("replacedPanel");
replacedPanel = panel1;
replacedPanel.setOutputMarkupId(true);
add(replacedPanel);
addButton(yesButton = new BootstrapAjaxLink<String>("button", null, Buttons.Type.Warning, new ResourceModel("details")) {
private static final long serialVersionUID = 1L;
#Override
public void onClick(AjaxRequestTarget target) {
addNewPanel(new AjaxLazyLoadPanel("replacedPanel") {
#Override
public Component getLazyLoadComponent(String markupId) {
if (!condition)) {
message = service.getPayment(paymentId);
if (message == null) {
return new VotingResultPanel(markupId, true);
} else
{
return new VotingResultPanel(markupId, false);
}
} // close if
else if (condition)) {
message = service.setPayment(paymentId);
if (message == null) {
return new VotingResultPanel(markupId, true);
} else {
System.out.println("" + message.getError());
return new VotingResultPanel(markupId, false);
}
}
else {
System.out.println("error");
}
}
}, target);
this.setOutputMarkupPlaceholderTag(true);
this.setVisible(false);
noButton.setOutputMarkupPlaceholderTag(true);
noButton.setVisible(false);
closeButton.setVisible(true);
target.add(this, noButton, closeButton);
}
});
noButton = new BootstrapAjaxLink<String>("button", null, Buttons.Type.Primary) {
private static final long serialVersionUID = 1L;
#Override
public void onClick(AjaxRequestTarget target){
close(target);
}
}.setLabel(Model.of("No"));
addButton(noButton);
}
closeButton = new BootstrapAjaxLink<String>("button", null,
Buttons.Type.Primary) {
private static final long serialVersionUID = 1L;
#Override
public void onClick(AjaxRequestTarget target){
addNewPanel(panel1,target);
yesButton.setOutputMarkupId(true);
yesButton.setVisible(true);
noButton.setOutputMarkupId(true);
noButton.setVisible(true);
closeButton.setOutputMarkupId(true);
closeButton.setOutputMarkupPlaceholderTag(true);
closeButton.setVisible(false);
target.add(yesButton,noButton,closeButton);
close(target);
}
}.setLabel(Model.of("Close"));
closeButton.setOutputMarkupPlaceholderTag(true);
closeButton.setVisible(false);
addButton(closeButton);
}
public void addNewPanel(Panel addpanel, AjaxRequestTarget target) {
Panel newPanel = null;
newPanel = addpanel;
newPanel.setOutputMarkupId(true);
replacedPanel.replaceWith(newPanel);
target.add(newPanel);
replacedPanel = newPanel;
}
}// close class
Have a look at the method AjaxLazyLoadPanel.getLoadingComponent(String). That's the one that creates the busy indicator.
The default implementation simply creates a img tag without any styling:
public Component getLoadingComponent(final String markupId)
{
IRequestHandler handler = new ResourceReferenceRequestHandler(
AbstractDefaultAjaxBehavior.INDICATOR);
return new Label(markupId, "<img alt=\"Loading...\" src=\"" +
RequestCycle.get().urlFor(handler) + "\"/>").setEscapeModelStrings(false);
}
You could overwrite that method and for example surround the img tag with a div tag that has some additional CSS:
#Override
public Component getLoadingComponent(final String markupId)
{
IRequestHandler handler = new ResourceReferenceRequestHandler(
AbstractDefaultAjaxBehavior.INDICATOR);
return new Label(markupId, "<div style=\"text-align: center\"><img alt=\"Loading...\" src=\"" +
RequestCycle.get().urlFor(handler) + "\"/></div>").setEscapeModelStrings(false);
}
Of course you could also return a completly custom Wicket Panel which could show a more complex busy indicator with text, graphics, colours, etc.
I am having a problem with my recyclerview, It only displays the content of the first item like this:
I have no idea what caused this, I'm really confused because I have never encountered something like this before. As you can see on the toast, the response return 3 data but I don't understand why the others are not being displayed.
Playlist.java
public class Playlist extends AppCompatActivity {
// inisiasi toolbar
private Toolbar toolbar;
// navigation drawer
public DrawerLayout drawerLayout;
private ActionBarDrawerToggle drawerToggle;
RecyclerView recyclerView;
String[] id,title,dir, artists;
ArrayList<String> artist;
String navTitles[];
TypedArray navIcons;
RecyclerView.Adapter recyclerViewAdapter;
TextView textView;
String video;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_playlist);
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
drawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
final Drawable upArrow = getResources().getDrawable(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
upArrow.setColorFilter(getResources().getColor(R.color.colorIcons), PorterDuff.Mode.SRC_ATOP);
getSupportActionBar().setHomeAsUpIndicator(upArrow);
Intent intent = getIntent();
video = intent.getStringExtra("songs");
//textView = (TextView) findViewById(R.id.text);
//textView.setText(video);
getPlaylist();
// dir = PlaylistJson.dirs;
//artist = new ArrayList<String>(Arrays.asList(title));
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()){
case android.R.id.home:
finish();
break;
}
return super.onOptionsItemSelected(item);
}
private void getPlaylist(){
final ProgressDialog loading = ProgressDialog.show(this,"Fetching Data","Please wait...",false,false);
//Creating a string request
StringRequest stringRequest = new StringRequest(Request.Method.POST, "http://musicmania.hol.es/playlist/getSongsFromPlaylist",
new Response.Listener<String>() {
#Override
public void onResponse(String response) {
//If we are getting success from server
Toast.makeText(Playlist.this, response, Toast.LENGTH_LONG).show();
loading.dismiss();
showPlaylistJSON(response);
id = PlaylistJson.ids;
title = PlaylistJson.titles;
artists = PlaylistJson.artists;
recyclerView= (RecyclerView) findViewById(R.id.my_recycler_view);
RecyclerViewAdapter adapter=new RecyclerViewAdapter(id, title,artists, Playlist.this);
recyclerView.setAdapter(adapter);
adapter.notifyDataSetChanged();
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(Playlist.this));
}
},
new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
//You can handle error here if you want
}
}){
#Override
protected Map<String, String> getParams() throws AuthFailureError {
Map<String,String> params = new HashMap<>();
//Adding parameters to request
params.put("playlist", video);
//returning parameter
return params;
}
};
//Adding the string request to the queue
RequestQueue requestQueue = Volley.newRequestQueue(this);
requestQueue.add(stringRequest);
}
private void showPlaylistJSON(String json){
PlaylistJson pj = new PlaylistJson(json);
pj.parseJSON();
}
}
RecyclerViewAdapter.java
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.RecyclerViewHolder> {
LayoutInflater inflater;
Context context;
String[] id,title, artists;
public RecyclerViewAdapter(String[] id, String[] titles, String[] artists, Context context){
this.id = id;
this.title = titles;
this.artists = artists;
this.context = context;
}
#Override
public RecyclerViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = null;
RecyclerViewHolder viewHolder = null;
if(Integer.parseInt(id[0]) != 0){
view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_list, parent, false);
viewHolder = new RecyclerViewHolder(view, context);
}else{
view = LayoutInflater.from(parent.getContext()).inflate(R.layout.empty_list, parent, false);
viewHolder = new RecyclerViewHolder(view, context);
}
return viewHolder;
}
#Override
public void onBindViewHolder(RecyclerViewHolder holder, int position) {
if(Integer.parseInt(id[0]) != 0) {
holder.item2.setText(title[position]);
holder.imageView2.setTag(holder);
holder.artist.setText(artists[position]);
}else{
holder.item2.setText(title[position]);
}
}
#Override
public int getItemCount() {
return title.length;
}
public static class RecyclerViewHolder extends RecyclerView.ViewHolder {
TextView item;
ImageView imageView;
TextView item2;
TextView artist;
ImageView imageView2;
ImageButton addtoplaylist;
Context context;
public RecyclerViewHolder(final View itemView, final Context context) {
super(itemView);
this.context = context;
item = (TextView) itemView.findViewById(R.id.tv_NavTitle);
imageView = (ImageView) itemView.findViewById(R.id.iv_NavIcon);
item2 = (TextView) itemView.findViewById(R.id.list_title);
imageView2 = (ImageView) itemView.findViewById(R.id.list_avatar);
artist = (TextView) itemView.findViewById(R.id.list_artist);
itemView.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent(v.getContext(), Video.class);
intent.putExtra("video", ParseJson.dirs[getAdapterPosition()]);
v.getContext().startActivity(intent);
}
});
}
}
}
PlaylistJson.java
package com.example.rendell.musicmaniajukebox.json_model;
import android.widget.Toast;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class PlaylistJson {
public static String[] ids;
public static String[] titles;
public static String[] artists;
public static String[] dirs;
public static final String JSON_ARRAY = "result";
public static final String KEY_ID = "id";
public static final String KEY_TITLE = "title";
public static final String KEY_ARTIST = "artist";
public static final String KEY_DIR = "dir";
private JSONArray users = null;
private String json;
public PlaylistJson(String json){
this.json = json;
}
public void parseJSON(){
JSONObject jsonObject=null;
try {
jsonObject = new JSONObject(json);
users = jsonObject.getJSONArray(JSON_ARRAY);
ids = new String[users.length()];
titles = new String[users.length()];
artists = new String[users.length()];
dirs = new String[users.length()];
for(int i=0;i<users.length();i++){
JSONObject jo = users.getJSONObject(i);
ids[i] = jo.getString(KEY_ID);
titles[i] = jo.getString(KEY_TITLE);
artists[i] = jo.getString(KEY_ARTIST);
dirs[i] = jo.getString(KEY_DIR);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}
So the problem was in my PlaylistJson.java file. My volley response only returns 3 items per set e.g. {"id":1, "title": "song", "artist":"artist"} but I am also initialing for the dir which doesn't receive any json so maybe the bug came from that. Anyway, removed that and it worked.
I am developing an ADF web application with Oracle EBS as the backend to call the procedure(Jdeveloper 12 c).
I have invoked a method calling EBS procedure (return type is list) and the result is stored in arraylist. the list is used to create Data control.
What my problem is i have set values to the data control but when i added that dc to view it shows nothing. But on debugging it shows all the values are set in the array list.
Bean class calling EBS procedure in ApplicationModule
BindingContainer bindings = getBindings();
OperationBinding operationBinding = (OperationBinding) bindings.getOperationBinding("getIexpenseLogin");
List<EmployeePojo> result = (List<EmployeePojo>) operationBinding.execute();
System.out.println("Result= " + result);
employeeDC.getEmployeeLogin(result); // Here the list is passed to the Employee DC class to create data controll.
ApplicationModule Containing Custom Procedure
public List getIexpenseLogin(String username,String password){
CallableStatement cs=null;
List<EmployeePojo> empList=new ArrayList<>();
try{
cs=getDBTransaction().createCallableStatement("begin xx_oie_mob_login.oie_mob_login(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?); end;",0);
cs.setString(1,username);
cs.setString(2, password);
cs.registerOutParameter(3, Types.NUMERIC);
cs.registerOutParameter(4, Types.VARCHAR);
cs.registerOutParameter(5, Types.VARCHAR);
cs.registerOutParameter(6, Types.NUMERIC);
cs.registerOutParameter(7, Types.VARCHAR);
cs.registerOutParameter(8, Types.NUMERIC);
cs.registerOutParameter(9, Types.VARCHAR);
cs.registerOutParameter(10, Types.NUMERIC);
cs.registerOutParameter(11, Types.VARCHAR);
cs.registerOutParameter(12, Types.NUMERIC);
cs.registerOutParameter(13, Types.BLOB);
cs.registerOutParameter(14, Types.VARCHAR);
cs.registerOutParameter(15, Types.VARCHAR);
cs.executeUpdate();
if(cs!=null)
{
EmployeePojo ePojo=new EmployeePojo();
ePojo.setEmployeeId(cs.getString(3));
ePojo.setEmployeeName(cs.getString(4));
ePojo.setEmployeeNumber(cs.getString(5));
ePojo.setManagerId(cs.getString(6));
ePojo.setManagerName(cs.getString(7));
ePojo.setJobId(cs.getString(8));
ePojo.setJobName(cs.getString(9));
ePojo.setOrgId(cs.getString(10));
ePojo.setOrgName(cs.getString(11));
ePojo.setImgId(cs.getString(12));
ePojo.setImage(cs.getBlob(13));
empList.add(ePojo);
}
return empList;
}catch(SQLException e){
throw new JboException(e);
}
}
EmployeeDC class used to create Data controll
public class EmployeeDC {
public EmployeeDC() {
super();
}
BindingContainer bindings = null;
private List<EmployeePojo> employee_data_controll=null;
private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
public void setEmployee_data_controll(List<EmployeePojo> employee_data_controll) {
List<EmployeePojo> oldEmployee_data_controll = this.employee_data_controll;
this.employee_data_controll = employee_data_controll;
propertyChangeSupport.firePropertyChange("employee_data_controll", oldEmployee_data_controll,
employee_data_controll);
}
public List<EmployeePojo> getEmployee_data_controll() {
return employee_data_controll;
}
public void setPropertyChangeSupport(PropertyChangeSupport propertyChangeSupport) {
PropertyChangeSupport oldPropertyChangeSupport = this.propertyChangeSupport;
this.propertyChangeSupport = propertyChangeSupport;
propertyChangeSupport.firePropertyChange("propertyChangeSupport", oldPropertyChangeSupport,
propertyChangeSupport);
}
public PropertyChangeSupport getPropertyChangeSupport() {
return propertyChangeSupport;
}
public void getEmployeeLogin(List<EmployeePojo> result) {
setEmployee_data_controll(result);
getEmployee_data_controll();
System.out.println("DataControl=>"+getEmployee_data_controll().get(0));
}
public void addPropertyChangeListener(PropertyChangeListener l) {
propertyChangeSupport.addPropertyChangeListener(l);
}
public void removePropertyChangeListener(PropertyChangeListener l) {
propertyChangeSupport.removePropertyChangeListener(l);
}
}
EmployeePojo Class
public class EmployeePojo {
private String employeeId;
private String employeeName;
private String employeeNumber;
private String managerId;
private String managerName;
private String jobId;
private String jobName;
private String orgId;
private String orgName;
private String imgId;
private Blob image;
private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
public void setPropertyChangeSupport(PropertyChangeSupport propertyChangeSupport) {
this.propertyChangeSupport = propertyChangeSupport;
}
public PropertyChangeSupport getPropertyChangeSupport() {
return propertyChangeSupport;
}
public void setEmployeeId(String employeeId) {
String oldEmployeeId = this.employeeId;
this.employeeId = employeeId;
propertyChangeSupport.firePropertyChange("employeeId", oldEmployeeId, employeeId);
}
public String getEmployeeId() {
return employeeId;
}
public void setEmployeeName(String employeeName) {
String oldEmployeeName = this.employeeName;
this.employeeName = employeeName;
propertyChangeSupport.firePropertyChange("employeeName", oldEmployeeName, employeeName);
}
public String getEmployeeName() {
return employeeName;
}
public void setEmployeeNumber(String employeeNumber) {
String oldEmployeeNumber = this.employeeNumber;
this.employeeNumber = employeeNumber;
propertyChangeSupport.firePropertyChange("employeeNumber", oldEmployeeNumber, employeeNumber);
}
public String getEmployeeNumber() {
return employeeNumber;
}
public void setManagerId(String managerId) {
String oldManagerId = this.managerId;
this.managerId = managerId;
propertyChangeSupport.firePropertyChange("managerId", oldManagerId, managerId);
}
public String getManagerId() {
return managerId;
}
public void setManagerName(String managerName) {
String oldManagerName = this.managerName;
this.managerName = managerName;
propertyChangeSupport.firePropertyChange("managerName", oldManagerName, managerName);
}
public String getManagerName() {
return managerName;
}
public void setJobId(String jobId) {
String oldJobId = this.jobId;
this.jobId = jobId;
propertyChangeSupport.firePropertyChange("jobId", oldJobId, jobId);
}
public String getJobId() {
return jobId;
}
public void setJobName(String jobName) {
String oldJobName = this.jobName;
this.jobName = jobName;
propertyChangeSupport.firePropertyChange("jobName", oldJobName, jobName);
}
public String getJobName() {
return jobName;
}
public void setOrgId(String orgId) {
String oldOrgId = this.orgId;
this.orgId = orgId;
propertyChangeSupport.firePropertyChange("orgId", oldOrgId, orgId);
}
public String getOrgId() {
return orgId;
}
public void setOrgName(String orgName) {
String oldOrgName = this.orgName;
this.orgName = orgName;
propertyChangeSupport.firePropertyChange("orgName", oldOrgName, orgName);
}
public String getOrgName() {
return orgName;
}
public void setImgId(String imgId) {
String oldImgId = this.imgId;
this.imgId = imgId;
propertyChangeSupport.firePropertyChange("imgId", oldImgId, imgId);
}
public String getImgId() {
return imgId;
}
public void setImage(Blob image) {
Blob oldImage = this.image;
this.image = image;
propertyChangeSupport.firePropertyChange("image", oldImage, image);
}
public Blob getImage() {
return image;
}
public void addPropertyChangeListener(PropertyChangeListener l) {
propertyChangeSupport.addPropertyChangeListener(l);
}
public void removePropertyChangeListener(PropertyChangeListener l) {
propertyChangeSupport.removePropertyChangeListener(l);
}
}
How can I add terminate button to eclipse console toolbar? I create console in this way:
IOConsole console = new IOConsole( name, null, null, true );
ConsolePlugin.getDefault().getConsoleManager().addConsoles( new IConsole[]{console} );
I found solution. Here is the code:
<extension
point="org.eclipse.ui.console.consolePageParticipants">
<consolePageParticipant
class="com.plugin.console.ConsoleActions"
id="com.plugin.console.PageParticipant">
<enablement>
<instanceof value="com.plugin.console.Console"/>
</enablement>
</consolePageParticipant>
</extension>
Console class:
public class Console extends IOConsole {
public Console(String name, ImageDescriptor imageDescriptor) {
super(name, imageDescriptor);
}
public Console(String name, String consoleType, ImageDescriptor imageDescriptor, boolean autoLifeCycle) {
super(name, consoleType, imageDescriptor, autoLifeCycle);
}
}
Console Participant class:
public class ConsoleActions implements IConsolePageParticipant {
private IPageBookViewPage page;
private Action remove, stop;
private IActionBars bars;
private IConsole console;
#Override
public void init(final IPageBookViewPage page, final IConsole console) {
this.console = console;
this.page = page;
IPageSite site = page.getSite();
this.bars = site.getActionBars();
createTerminateAllButton();
createRemoveButton();
bars.getMenuManager().add(new Separator());
bars.getMenuManager().add(remove);
IToolBarManager toolbarManager = bars.getToolBarManager();
toolbarManager.appendToGroup(IConsoleConstants.LAUNCH_GROUP, stop);
toolbarManager.appendToGroup(IConsoleConstants.LAUNCH_GROUP,remove);
bars.updateActionBars();
}
private void createTerminateAllButton() {
ImageDescriptor imageDescriptor = ImageDescriptor.createFromFile(getClass(), "/icons/stop_all_active.gif");
this.stop = new Action("Terminate all", imageDescriptor) {
public void run() {
//code to execute when button is pressed
}
};
}
private void createRemoveButton() {
ImageDescriptor imageDescriptor = ImageDescriptor.createFromFile(getClass(), "/icons/remove_active.gif");
this.remove= new Action("Remove console", imageDescriptor) {
public void run() {
//code to execute when button is pressed
}
};
}
#Override
public void dispose() {
remove= null;
stop = null;
bars = null;
page = null;
}
#Override
public Object getAdapter(Class adapter) {
return null;
}
#Override
public void activated() {
updateVis();
}
#Override
public void deactivated() {
updateVis();
}
private void updateVis() {
if (page == null)
return;
boolean isEnabled = true;
stop.setEnabled(isEnabled);
remove.setEnabled(isEnabled);
bars.updateActionBars();
}
}