📄 codegenutils.java
字号:
package com.cownew.uidesigner.common;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.draw2d.geometry.Rectangle;
import com.cownew.ctk.io.ResourceUtils;
import com.cownew.uidesigner.Activator;
public class CodeGenUtils
{
public static void saveToFile(IFile file, String value,
IProgressMonitor monitor) throws CoreException
{
InputStream stream = null;
try
{
stream = new ByteArrayInputStream(value.getBytes());
if (file.exists())
{
file.setContents(stream, true, true, monitor);
} else
{
file.create(stream, true, monitor);
}
stream.close();
} catch (IOException e)
{
Activator.logException(e);
} finally
{
ResourceUtils.close(stream);
}
}
public static String translateBounds(Rectangle rect)
{
StringBuffer sb = new StringBuffer();
sb.append("new Rectangle(").append(rect.x).append(",").append(rect.y)
.append(",").append(rect.width).append(",").append(rect.height)
.append(")");
return sb.toString();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -