use of org.eclipse.che.ide.api.filetypes.FileType in project che by eclipse.
the class MavenExtension method registerFileType.
@Inject
private void registerFileType(FileTypeRegistry fileTypeRegistry, MavenResources mavenResources, EditorRegistry editorRegistry, PomEditorProvider editorProvider) {
FileType pomFile = new FileType(mavenResources.maven(), "pom.xml", "pom\\.xml");
fileTypeRegistry.registerFileType(pomFile);
editorRegistry.register(pomFile, editorProvider);
}
use of org.eclipse.che.ide.api.filetypes.FileType in project che by eclipse.
the class RecipeEditorPanelTest method scriptShouldBeReturned.
@Test
public void scriptShouldBeReturned() throws Exception {
FileType fileType = mock(FileType.class);
Document document = mock(Document.class);
when(fileTypeRegistry.getFileTypeByFile(recipeFile)).thenReturn(fileType);
when(editor.getDocument()).thenReturn(document);
presenter.showEditor();
presenter.getScript();
verify(editor).getDocument();
verify(document).getContents();
}
use of org.eclipse.che.ide.api.filetypes.FileType in project che by eclipse.
the class RecipeEditorPanel method initializeEditor.
private void initializeEditor(@NotNull final VirtualFile file) {
FileType fileType = fileTypeRegistry.getFileTypeByFile(file);
editor = getEditor();
editor.activate();
editor.onOpen();
view.showEditor(editor);
// wait when editor is initialized
editor.addPropertyListener(new PropertyListener() {
@Override
public void propertyChanged(PartPresenter source, int propId) {
switch(propId) {
case PROP_INPUT:
view.showEditor(editor);
break;
case PROP_DIRTY:
if (validateUndoOperation()) {
setEnableSaveAndCancelButtons(true);
}
break;
default:
}
}
});
editor.init(new RecipeEditorInput(fileType, file), new OpenEditorCallbackImpl());
}
use of org.eclipse.che.ide.api.filetypes.FileType in project che by eclipse.
the class DebuggerPresenterTest method setup.
@Before
public void setup() {
doReturn(debugger).when(debuggerManager).getActiveDebugger();
doReturn(ERROR_MESSAGE).when(promiseError).getMessage();
presenter = spy(new DebuggerPresenter(view, constant, breakpointManager, notificationManager, debuggerResources, debuggerToolbar, debuggerManager, workspaceAgent));
doNothing().when(presenter).showDebuggerPanel();
presenter.onSelectedVariableElement(selectedVariable);
FileType fileType = mock(FileType.class);
doReturn("java").when(fileType).getExtension();
doReturn(fileType).when(fileTypeRegistry).getFileTypeByFile(eq(file));
}
use of org.eclipse.che.ide.api.filetypes.FileType in project che by eclipse.
the class LanguageServerFileTypeRegister method start.
@Override
public void start(final Callback<WsAgentComponent, Exception> callback) {
Promise<List<LanguageDescriptionDTO>> registeredLanguages = serverLanguageRegistry.getSupportedLanguages();
registeredLanguages.then(new Operation<List<LanguageDescriptionDTO>>() {
@Override
public void apply(List<LanguageDescriptionDTO> langs) throws OperationException {
if (!langs.isEmpty()) {
JsArrayString contentTypes = JsArrayString.createArray().cast();
for (LanguageDescriptionDTO lang : langs) {
String primaryExtension = lang.getFileExtensions().get(0);
for (String ext : lang.getFileExtensions()) {
final FileType fileType = new FileType(resources.file(), ext);
fileTypeRegistry.registerFileType(fileType);
editorRegistry.registerDefaultEditor(fileType, editorProvider);
ext2langId.put(ext, lang.getLanguageId());
}
List<String> mimeTypes = lang.getMimeTypes();
if (mimeTypes.isEmpty()) {
mimeTypes = newArrayList("text/x-" + lang.getLanguageId());
}
for (String contentTypeId : mimeTypes) {
contentTypes.push(contentTypeId);
OrionContentTypeOverlay contentType = OrionContentTypeOverlay.create();
contentType.setId(contentTypeId);
contentType.setName(lang.getLanguageId());
contentType.setExtension(primaryExtension);
contentType.setExtends("text/plain");
// highlighting
OrionHighlightingConfigurationOverlay config = OrionHighlightingConfigurationOverlay.create();
config.setId(lang.getLanguageId() + ".highlighting");
config.setContentTypes(contentTypeId);
config.setPatterns(lang.getHighlightingConfiguration());
Logger logger = Logger.getLogger(LanguageServerFileTypeRegister.class.getName());
contentTypeRegistrant.registerFileType(contentType, config);
}
}
orionHoverRegistrant.registerHover(contentTypes, hoverProvider);
orionOccurrencesRegistrant.registerOccurrencesHandler(contentTypes, occurrencesProvider);
}
callback.onSuccess(LanguageServerFileTypeRegister.this);
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError arg) throws OperationException {
callback.onFailure(new Exception(arg.getMessage(), arg.getCause()));
}
});
}
Aggregations