use of org.intellij.images.options.Options in project intellij-community by JetBrains.
the class EditExternallyAction method actionPerformed.
public void actionPerformed(AnActionEvent e) {
Project project = e.getData(CommonDataKeys.PROJECT);
VirtualFile[] files = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY);
Options options = OptionsManager.getInstance().getOptions();
String executablePath = options.getExternalEditorOptions().getExecutablePath();
if (StringUtil.isEmpty(executablePath)) {
Messages.showErrorDialog(project, ImagesBundle.message("error.empty.external.editor.path"), ImagesBundle.message("error.title.empty.external.editor.path"));
ImagesConfigurable.show(project);
} else {
if (files != null) {
Map<String, String> env = EnvironmentUtil.getEnvironmentMap();
for (String varName : env.keySet()) {
if (SystemInfo.isWindows) {
executablePath = StringUtil.replace(executablePath, "%" + varName + "%", env.get(varName), true);
} else {
executablePath = StringUtil.replace(executablePath, "${" + varName + "}", env.get(varName), false);
}
}
executablePath = FileUtil.toSystemDependentName(executablePath);
File executable = new File(executablePath);
GeneralCommandLine commandLine = new GeneralCommandLine();
final String path = executable.exists() ? executable.getAbsolutePath() : executablePath;
if (SystemInfo.isMac) {
commandLine.setExePath(ExecUtil.getOpenCommandPath());
commandLine.addParameter("-a");
commandLine.addParameter(path);
} else {
commandLine.setExePath(path);
}
ImageFileTypeManager typeManager = ImageFileTypeManager.getInstance();
for (VirtualFile file : files) {
if (file.isInLocalFileSystem() && typeManager.isImage(file)) {
commandLine.addParameter(VfsUtilCore.virtualToIoFile(file).getAbsolutePath());
}
}
commandLine.setWorkDirectory(new File(executablePath).getParentFile());
try {
commandLine.createProcess();
} catch (ExecutionException ex) {
Messages.showErrorDialog(project, ex.getLocalizedMessage(), ImagesBundle.message("error.title.launching.external.editor"));
ImagesConfigurable.show(project);
}
}
}
}
use of org.intellij.images.options.Options in project intellij-community by JetBrains.
the class ImagesConfigurable method reset.
public void reset() {
if (myComponent != null) {
Options options = OptionsManager.getInstance().getOptions();
myComponent.getOptions().inject(options);
myComponent.updateUI();
}
}
use of org.intellij.images.options.Options in project intellij-community by JetBrains.
the class ImagesConfigurable method createComponent.
public JComponent createComponent() {
if (myComponent == null) {
myComponent = new ImagesOptionsComponent();
Options options = OptionsManager.getInstance().getOptions();
options.addPropertyChangeListener(this);
myComponent.getOptions().inject(options);
myComponent.updateUI();
myComponent.getOptions().addPropertyChangeListener(this);
setModified(false);
}
return myComponent.getContentPane();
}
use of org.intellij.images.options.Options in project android by JetBrains.
the class LayeredImageEditor method setImage.
private void setImage(Image image) throws IOException {
ImageDocument document = myImageEditor.getDocument();
BufferedImage previousImage = document.getValue();
document.setValue(Utilities.getDisplayableImage(image));
String format = image.getFormat() + "/" + image.getColorMode();
String description = image.getColorProfileDescription();
if (!description.isEmpty()) {
format += ", " + description;
}
document.setFormat(format);
// from ImageEditorUI
ImageZoomModel zoomModel = myImageEditor.getZoomModel();
if (previousImage == null || !zoomModel.isZoomLevelChanged()) {
Options options = OptionsManager.getInstance().getOptions();
ZoomOptions zoomOptions = options.getEditorOptions().getZoomOptions();
zoomModel.setZoomFactor(1.0d);
if (zoomOptions.isSmartZooming()) {
Dimension preferred = zoomOptions.getPrefferedSize();
if (preferred.width > image.getWidth() && preferred.height > image.getHeight()) {
double factor = (preferred.getWidth() / (double) image.getWidth() + preferred.getHeight() / (double) image.getHeight()) / 2.0d;
zoomModel.setZoomFactor(Math.ceil(factor));
}
}
}
}
use of org.intellij.images.options.Options in project intellij-community by JetBrains.
the class ImagesConfigurable method apply.
public void apply() {
if (myComponent != null) {
Options options = OptionsManager.getInstance().getOptions();
options.inject(myComponent.getOptions());
}
}
Aggregations