Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » How to make Content assist working when editors are inside Composite?
How to make Content assist working when editors are inside Composite? [message #905087] Wed, 29 August 2012 16:52 Go to next message
cyriel cysiek is currently offline cyriel cysiekFriend
Messages: 4
Registered: August 2012
Junior Member
Hi,
i've got problem with content assistant. In MultiPageEditor on one tab i've got 2 StructuredTextEditor in one Composite:
MultiPageEditor:
-page0:
--composite: StructuredTextEditor1, StructuredTextEditor2


When StructuredTextEditor are on 2 different pages everything is fine, but when they are on the same page content assist is not working(ctrl+space == no effect). I think(but i'm not sure) that for some reason Composite is not sending events(information that ctrl+space has been pressed) to its children, but i have no idea why... How can i fix that(am i missing something?)?
I'm trying to do that using this code:
void createPage0() {
		Composite composite = new Composite(getContainer(), SWT.NONE);
		GridLayout layout = new GridLayout (1, true);		
		composite.setLayout(layout);
	
		StructuredTextEditor logicInputEditor = new StructuredTextEditor();
	
		IEditorSite site = createSite(logicInputEditor);
		
		try {
			logicInputEditor.init(site, getEditorInput());
		} catch (PartInitException e) {
			e.printStackTrace();
		}
		logicInputEditor.createPartControl(this.getContainer());		
		
		StructuredTextEditor logicOutputEditor = new StructuredTextEditor();
		site = createSite(logicOutputEditor);
		try {
			logicOutputEditor.init(site, createFileEditorInputForFile(projectFullPath, projectPath, "out.html"));
		} catch (PartInitException e) {
			e.printStackTrace();
		}
		logicOutputEditor.createPartControl(composite);
		
		Control[] children = composite.getChildren();
		GridData gd = new GridData();
		gd.grabExcessHorizontalSpace = true;
		gd.grabExcessVerticalSpace = true;
		gd.horizontalAlignment = SWT.FILL;
		gd.verticalAlignment = SWT.FILL;
		children[ 0 ].setLayoutData(gd);
		gd = new GridData();
		gd.horizontalAlignment = SWT.FILL;
		gd.verticalAlignment = SWT.FILL;
		gd.grabExcessHorizontalSpace = true;
		gd.grabExcessVerticalSpace = true;
		children[ 1 ].setLayoutData(gd);
		
		int index = addPage(composite);
		setPageText(index, "Logic");
	}
Re: How to make Content assist working when editors are inside Composite? [message #905605 is a reply to message #905087] Thu, 30 August 2012 18:17 Go to previous message
cyriel cysiek is currently offline cyriel cysiekFriend
Messages: 4
Registered: August 2012
Junior Member
Situation has changed - now content assistant is working almost ok, for both editors. CreatePage0 function is the same, the only change in code is:
@Override
    protected IEditorPart getEditor(int pageIndex) {
        //return super.getEditor(pageIndex);
        super.getEditor(pageIndex);


        if (composite != null)
        {
            Control focus = composite.getDisplay().getFocusControl();

            if (focus !=null){
                while (focus.getParent() != null && focus.getParent() != composite){
                    focus = focus.getParent();
                }

                if (composite.getChildren()[0].equals(focus)){
                    if (logicInputActive != true)
                    {
                        logicInputActive = true;
                        setActiveEditor(logicInputEditor);
                        activateSite();
                    }
                }else if (composite.getChildren()[1].equals(focus)){
                    if (logicInputActive != false)
                    {
                        logicInputActive = false;
                        setActiveEditor(logicOutputEditor);
                        activateSite();
                    }
                }
            }

        }
        StructuredTextEditor o = logicInputActive ? logicInputEditor : logicOutputEditor; 
        return  o;
    }

So i get the element with focus, and whether it's child of logicInputEditor(it "is in" composite.getChildren()[0]) or logicOutputEditor(composite.getChildren()[1]). This part of code works fine(or at least i think so...). Problem is quite weird - if you click on editor TWICE or once + type something(some random letters) - everything is fine(content assistant shows in this editor), if you click only once content assistant shows in last editor in which you clicked twice. So even if getEditor() function returns "correct"(active) editor, for some reason content assistant shows in "wrong" editor. I tried to override getActiveEditor, but it doesn't change anything. Any ideas what can cause this problem and how can i fix that?
Previous Topic:Deployment assembly of projects that include bianry class folders
Next Topic:Associate Custom Content Type with XML Validator.
Goto Forum:
  


Current Time: Thu Apr 25 00:30:13 GMT 2024

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

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

Back to the top