Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Problem at showing and hiding a View(cant fix the reason for the problem)
Problem at showing and hiding a View [message #925955] Fri, 28 September 2012 07:09
ben agai is currently offline ben agaiFriend
Messages: 36
Registered: July 2012
Member
hi.

i created a plugin which listens to debugEvents, i created in this class
a ThreadView object(that extends ViewPart) and try to show it in the fifth debugEvent
, and hide the view in the tenth debugEvent, however i always get a nullpointerException.
im pretty stuck i appreciates every suggestions, thanks.

this is the output i get in my JFrame window:

counter: 2
counter: 3
counter: 4
counter: 5
entered first if
finished view creation
fell in showing the view
java.lang.NullPointerException
fell in checking the view visibility
java.lang.NullPointerException
counter: 7
counter: 8
counter: 9
counter: 10
entered second if
fell in hiding the view
java.lang.NullPointerException
view isnt null
fell in checking the view visibility
java.lang.NullPointerException
counter: 11
counter: 12
counter: 13



this is the code i use in the DebugEventListener:

package viewcreate.handlers;


import javax.swing.JFrame;
import javax.swing.JTextArea;

import org.eclipse.debug.core.DebugEvent;
import org.eclipse.debug.core.IDebugEventSetListener;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IViewReference;
import org.eclipse.ui.PlatformUI;

public class GDBEvent implements IDebugEventSetListener{

int counter = 1;
ThreadView view;
JFrame window = new JFrame("check");
JTextArea text = new JTextArea(5, 5);
public GDBEvent(){

window.setSize(300, 300);
window.add(text);
window.setVisible(true);
}

@Override
public void handleDebugEvents(DebugEvent[] events) {
// TODO Auto-generated method stub
if(counter == 5){
text.append("entered first if\n");
counter++;
try{
view = ThreadView.getThreadView();
text.append("finished view creation\n");
}catch(Exception ex){
text.append("fell in createion\n");
text.append(ex.toString()+"\n");
}
try{
viewcreate.Activator.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().showView("ViewCreate");
text.append("finished showing the view\n");
}catch(Exception ex){
text.append("fell in showing the view\n");
text.append(ex.toString()+"\n");
}
try{
boolean check = false;
check = viewcreate.Activator.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().isPartVisible(view);
text.append("is the view visible: "+ check+ "\n");
}catch(Exception ex){
text.append("fell in checking the view visibility\n");
text.append(ex.toString()+"\n");
}
}

if(counter == 10){
text.append("entered second if\n");
try{
viewcreate.Activator.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().hideView(view);
text.append("finished hiding the view\n");
}catch(Exception ex){
text.append("fell in hiding the view\n");
text.append(ex.toString()+"\n");
}
if(view == null)
text.append("view is null\n");
else text.append("view isnt null\n");
try{
boolean check = false;
check = viewcreate.Activator.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().isPartVisible(view);
text.append("is the view visible: "+ check+ "\n");
}catch(Exception ex){
text.append("fell in checking the view visibility\n");
text.append(ex.toString()+"\n");
}
}

counter++;
text.append("counter: " + counter+"\n");
}

}

this is the code of the ThreadView class:

package viewcreate.handlers;


import org.eclipse.swt.custom.StackLayout;
import org.eclipse.swt.widgets.*;
import org.eclipse.ui.part.ViewPart;

public class ThreadView extends ViewPart{

static ThreadView view;
Label error;
Label welcome;
Composite container;
StackLayout layout;

private ThreadView(){
super();
}

public static ThreadView getThreadView(){
if(view == null){
view = new ThreadView();
}
return view;
}

@Override
public void createPartControl(Composite parent) {
// TODO Auto-generated method stub
container = new Composite(parent,0);
layout = new StackLayout();
container.setLayout(layout);
error = new Label(container, 0);
welcome = new Label(container, 0);

layout.topControl = welcome;
container.layout();
}

@Override
public void setFocus() {
layout.topControl.setFocus();
}

}

[Updated on: Fri, 28 September 2012 07:11]

Report message to a moderator

Previous Topic:Do VCS path ignores actually work?
Next Topic:Antenna preprocessor ruins line endings in files
Goto Forum:
  


Current Time: Wed Nov 26 07:06:06 GMT 2014

Powered by FUDForum. Page generated in 0.28012 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software