diff options
Diffstat (limited to 'plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/editors/bitbake/BitBakeFileEditor.java')
-rw-r--r-- | plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/editors/bitbake/BitBakeFileEditor.java | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/editors/bitbake/BitBakeFileEditor.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/editors/bitbake/BitBakeFileEditor.java new file mode 100644 index 0000000..11dd335 --- /dev/null +++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/editors/bitbake/BitBakeFileEditor.java | |||
@@ -0,0 +1,89 @@ | |||
1 | /***************************************************************************** | ||
2 | * Copyright (c) 2013 Ken Gilmer, Intel Corporation | ||
3 | * All rights reserved. This program and the accompanying materials | ||
4 | * are made available under the terms of the Eclipse Public License v1.0 | ||
5 | * which accompanies this distribution, and is available at | ||
6 | * http://www.eclipse.org/legal/epl-v10.html | ||
7 | * | ||
8 | * Contributors: | ||
9 | * Ken Gilmer - initial API and implementation | ||
10 | * Ioana Grigoropol (Intel) - adapt class for remote support | ||
11 | *******************************************************************************/ | ||
12 | package org.yocto.bc.ui.editors.bitbake; | ||
13 | |||
14 | import java.io.IOException; | ||
15 | import java.lang.reflect.InvocationTargetException; | ||
16 | import java.util.ResourceBundle; | ||
17 | |||
18 | import org.eclipse.core.resources.IFile; | ||
19 | import org.eclipse.core.resources.IProject; | ||
20 | import org.eclipse.core.runtime.CoreException; | ||
21 | import org.eclipse.core.runtime.NullProgressMonitor; | ||
22 | import org.eclipse.core.runtime.Status; | ||
23 | import org.eclipse.ui.IEditorInput; | ||
24 | import org.eclipse.ui.IEditorSite; | ||
25 | import org.eclipse.ui.PartInitException; | ||
26 | import org.eclipse.ui.part.FileEditorInput; | ||
27 | import org.eclipse.ui.texteditor.AbstractDecoratedTextEditor; | ||
28 | import org.eclipse.ui.texteditor.ContentAssistAction; | ||
29 | import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds; | ||
30 | import org.yocto.bc.ui.Activator; | ||
31 | import org.yocto.bc.ui.model.ProjectInfo; | ||
32 | |||
33 | /** | ||
34 | * Editor for BB Recipe | ||
35 | * @author kgilmer | ||
36 | * | ||
37 | */ | ||
38 | public class BitBakeFileEditor extends AbstractDecoratedTextEditor { | ||
39 | |||
40 | public static final String EDITOR_ID = "org.yocto.bc.ui.editors.BitBakeFileEditor"; | ||
41 | static final String CONTENT_ASSIST= "ContentAssist"; | ||
42 | private BitBakeSourceViewerConfiguration viewerConfiguration; | ||
43 | private IFile targetFile; | ||
44 | |||
45 | public BitBakeFileEditor() { | ||
46 | super(); | ||
47 | viewerConfiguration = new BitBakeSourceViewerConfiguration(getSharedColors(), getPreferenceStore()); | ||
48 | setSourceViewerConfiguration(viewerConfiguration); | ||
49 | setDocumentProvider(new BitBakeDocumentProvider(viewerConfiguration)); | ||
50 | } | ||
51 | |||
52 | @Override | ||
53 | protected void createActions() { | ||
54 | super.createActions(); | ||
55 | |||
56 | ResourceBundle bundle= RecipeEditorMessages.getBundle(); | ||
57 | ContentAssistAction action= new ContentAssistAction(bundle, "contentAssist.", this); //$NON-NLS-1$ | ||
58 | action.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS); | ||
59 | setAction(CONTENT_ASSIST, action); | ||
60 | } | ||
61 | |||
62 | @Override | ||
63 | public void init(IEditorSite site, IEditorInput input) throws PartInitException { | ||
64 | |||
65 | if (input instanceof FileEditorInput) { | ||
66 | IProject p = ((FileEditorInput)input).getFile().getProject(); | ||
67 | targetFile = ((FileEditorInput)input).getFile(); | ||
68 | viewerConfiguration.setTargetFile(targetFile); | ||
69 | |||
70 | try { | ||
71 | ProjectInfo projInfo = Activator.getProjInfo(p.getLocationURI()); | ||
72 | ((BitBakeDocumentProvider)getDocumentProvider()).setActiveConnection(projInfo.getConnection()); | ||
73 | viewerConfiguration.setBBSession(Activator.getBBSession(projInfo, new NullProgressMonitor())); | ||
74 | } catch (IOException e) { | ||
75 | e.printStackTrace(); | ||
76 | throw new PartInitException(Status.CANCEL_STATUS); | ||
77 | } catch (InvocationTargetException e) { | ||
78 | e.printStackTrace(); | ||
79 | } catch (CoreException e) { | ||
80 | e.printStackTrace(); | ||
81 | } catch (InterruptedException e) { | ||
82 | e.printStackTrace(); | ||
83 | } catch (Exception e) { | ||
84 | e.printStackTrace(); | ||
85 | } | ||
86 | } | ||
87 | super.init(site, input); | ||
88 | } | ||
89 | } | ||