그래서 저는 직장에서 플러그인을 작업 중이며 ContentProposalAdapter를 사용할 수있는 상황에 처했습니다. 기본적으로 누군가가 다른 사람의 이름을 입력하기 시작하면 현재 쿼리와 일치하는 이름 목록이 선행 형식 (a la Google)으로 반환됩니다. 그래서 IContentProposalProvider 클래스를 만들었습니다.이 클래스는 getProposals() 메서드를 호출 할 때 백그라운드에서 제안을 가져 오는 스레드를 처리합니다. 내가 겪고있는 문제는 HTTP를 통해 제안서를받는 처리가 이루어지는 경쟁 조건에 부딪혀 실제로 제안을 받기 전에 제안을 얻으려고한다는 것입니다.인터넷에서 JFace ContentProposalAdapter를 채우려면 어떻게해야합니까?
이제 스레드 지옥 문제에 부딪치지 않으려 고합니다. 어쨌든 저를 멀리하게하지는 않습니다. 그래서, 지금까지 제가 한 일이 있습니다. 누구든지 내가 할 수있는 것에 관해 어떤 제안이 있습니까? 좋아
public class ProfilesProposalProvider implements IContentProposalProvider, PropertyChangeListener {
private IContentProposal[] props;
@Override
public IContentProposal[] getProposals(String arg0, int arg1) {
Display display = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().getDisplay();
RunProfilesJobThread t1 = new RunProfilesJobThread(arg0, display);
t1.run();
return props;
}
@Override
public void propertyChange(PropertyChangeEvent arg0) {
if (arg0.getSource() instanceof RunProfilesJobThread){
RunProfilesJobThread thread = (RunProfilesJobThread)arg0.getSource();
props = thread.getProps();
}
}
}
public class RunProfilesJobThread extends Thread {
private ProfileProposal[] props;
private Display display;
private String query;
public RunProfilesJobThread(String query, Display display){
this.query = query;
}
@Override
public void run() {
if (!(query.equals(""))){
GetProfilesJob job = new GetProfilesJob("profiles", query);
job.schedule();
try {
job.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
GetProfilesJobInfoThread thread = new GetProfilesJobInfoThread(job.getResults());
try {
thread.join();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
props = thread.getProps();
}
}
public ProfileProposal[] getProps(){
return props;
}
}
public class GetProfilesJobInfoThread extends Thread {
private ArrayList<String> names;
private ProfileProposal[] props;
public GetProfilesJobInfoThread(ArrayList<String> names){
this.names = names;
}
@Override
public void run() {
if (names != null){
props = new ProfileProposal[names.size()];
for (int i = 0; i < props.length - 1; i++){
ProfileProposal temp = new ProfileProposal(names.get(i), names.get(i));
props[i] = temp;
}
}
}
public ProfileProposal[] getProps(){
return props;
}
}