use of com.intellij.openapi.fileEditor.FileEditor in project ideavim by JetBrains.
the class UndoRedoHelper method undo.
public static boolean undo(@NotNull final DataContext context) {
final Project project = PlatformDataKeys.PROJECT.getData(context);
final FileEditor fileEditor = PlatformDataKeys.FILE_EDITOR.getData(context);
final com.intellij.openapi.command.undo.UndoManager undoManager = com.intellij.openapi.command.undo.UndoManager.getInstance(project);
if (fileEditor != null && undoManager.isUndoAvailable(fileEditor)) {
undoManager.undo(fileEditor);
return true;
}
return false;
}
use of com.intellij.openapi.fileEditor.FileEditor in project ideavim by JetBrains.
the class UndoRedoHelper method redo.
public static boolean redo(@NotNull final DataContext context) {
final Project project = PlatformDataKeys.PROJECT.getData(context);
final FileEditor fileEditor = PlatformDataKeys.FILE_EDITOR.getData(context);
final com.intellij.openapi.command.undo.UndoManager undoManager = com.intellij.openapi.command.undo.UndoManager.getInstance(project);
if (fileEditor != null && undoManager.isRedoAvailable(fileEditor)) {
undoManager.redo(fileEditor);
return true;
}
return false;
}
use of com.intellij.openapi.fileEditor.FileEditor in project android by JetBrains.
the class NlModel method overrideConfigurationScreenSize.
/**
* Changes the configuration to use a custom device with screen size defined by xDimension and yDimension.
*/
public void overrideConfigurationScreenSize(@AndroidCoordinate int xDimension, @AndroidCoordinate int yDimension) {
Device original = myConfiguration.getDevice();
// doesn't copy tag id
Device.Builder deviceBuilder = new Device.Builder(original);
if (original != null) {
deviceBuilder.setTagId(original.getTagId());
}
deviceBuilder.setName("Custom");
deviceBuilder.setId(Configuration.CUSTOM_DEVICE_ID);
Device device = deviceBuilder.build();
for (State state : device.getAllStates()) {
Screen screen = state.getHardware().getScreen();
screen.setXDimension(xDimension);
screen.setYDimension(yDimension);
double dpi = screen.getPixelDensity().getDpiValue();
double width = xDimension / dpi;
double height = yDimension / dpi;
double diagonalLength = Math.sqrt(width * width + height * height);
screen.setDiagonalLength(diagonalLength);
screen.setSize(AvdScreenData.getScreenSize(diagonalLength));
screen.setRatio(AvdScreenData.getScreenRatio(xDimension, yDimension));
screen.setScreenRound(device.getDefaultHardware().getScreen().getScreenRound());
screen.setChin(device.getDefaultHardware().getScreen().getChin());
}
// If a custom device already exists, remove it before adding the latest one
List<Device> devices = myConfiguration.getConfigurationManager().getDevices();
boolean customDeviceReplaced = false;
for (int i = 0; i < devices.size(); i++) {
if ("Custom".equals(devices.get(i).getId())) {
devices.set(i, device);
customDeviceReplaced = true;
break;
}
}
if (!customDeviceReplaced) {
devices.add(device);
}
VirtualFile better;
State newState;
//Change the orientation of the device depending on the shape of the canvas
if (xDimension > yDimension) {
better = ConfigurationMatcher.getBetterMatch(myConfiguration, device, "Landscape", null, null);
newState = device.getState("Landscape");
} else {
better = ConfigurationMatcher.getBetterMatch(myConfiguration, device, "Portrait", null, null);
newState = device.getState("Portrait");
}
if (better != null) {
VirtualFile old = myConfiguration.getFile();
assert old != null;
Project project = mySurface.getProject();
OpenFileDescriptor descriptor = new OpenFileDescriptor(project, better, -1);
FileEditorManager manager = FileEditorManager.getInstance(project);
FileEditor selectedEditor = manager.getSelectedEditor(old);
manager.openEditor(descriptor, true);
// Switch to the same type of editor (XML or Layout Editor) in the target file
if (selectedEditor instanceof NlEditor) {
manager.setSelectedEditor(better, NlEditorProvider.DESIGNER_ID);
} else if (selectedEditor != null) {
manager.setSelectedEditor(better, TextEditorProvider.getInstance().getEditorTypeId());
}
AndroidFacet facet = AndroidFacet.getInstance(myConfiguration.getModule());
assert facet != null;
Configuration configuration = facet.getConfigurationManager().getConfiguration(better);
configuration.setEffectiveDevice(device, newState);
} else {
myConfiguration.setEffectiveDevice(device, newState);
}
}
use of com.intellij.openapi.fileEditor.FileEditor in project intellij-plugins by JetBrains.
the class ActionScriptHighlightingTest method setActiveEditor.
private void setActiveEditor(String relativePath) {
VirtualFile file = myFile.getVirtualFile().findFileByRelativePath(relativePath);
FileEditor[] editors = FileEditorManager.getInstance(myProject).getEditors(file);
assertEquals(1, editors.length);
FileEditor fileEditor = editors[0];
assertTrue(fileEditor instanceof TextEditor);
setActiveEditor(((TextEditor) fileEditor).getEditor());
}
use of com.intellij.openapi.fileEditor.FileEditor in project android by JetBrains.
the class LayeredImageEditorProvider method createEditor.
@NotNull
@Override
public FileEditor createEditor(@NotNull Project project, @NotNull VirtualFile file) {
// Use the default image editor to reuse the standard zoom UI, etc.
FileEditorProvider provider = FileEditorProviderManager.getInstance().getProvider("images");
// There is always a standard images provider
assert provider != null;
FileEditor editor = provider.createEditor(project, new EmptyVirtualFile(file));
return new LayeredImageEditor(project, file, editor);
}
Aggregations