use of org.eclipse.jface.resource.ImageDescriptor in project che by eclipse.
the class CompletionProposalCollector method createAnnotationAttributeReferenceProposal.
private IJavaCompletionProposal createAnnotationAttributeReferenceProposal(CompletionProposal proposal) {
StyledString displayString = fLabelProvider.createLabelWithTypeAndDeclaration(proposal);
ImageDescriptor descriptor = fLabelProvider.createMethodImageDescriptor(proposal);
String completion = String.valueOf(proposal.getCompletion());
JavaCompletionProposal javaProposal = new JavaCompletionProposal(completion, proposal.getReplaceStart(), getLength(proposal), getImage(descriptor), displayString, computeRelevance(proposal));
if (fJavaProject != null)
javaProposal.setProposalInfo(new AnnotationAtttributeProposalInfo(fJavaProject, proposal));
return javaProposal;
}
use of org.eclipse.jface.resource.ImageDescriptor in project che by eclipse.
the class CompletionProposalLabelProvider method createImageDescriptor.
/**
* Creates and returns a decorated image descriptor for a completion proposal.
*
* @param proposal the proposal for which to create an image descriptor
* @return the created image descriptor, or <code>null</code> if no image is available
*/
public ImageDescriptor createImageDescriptor(CompletionProposal proposal) {
final int flags = proposal.getFlags();
ImageDescriptor descriptor;
switch(proposal.getKind()) {
case CompletionProposal.METHOD_DECLARATION:
case CompletionProposal.METHOD_NAME_REFERENCE:
case CompletionProposal.METHOD_REF:
case CompletionProposal.CONSTRUCTOR_INVOCATION:
case CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER:
case CompletionProposal.ANNOTATION_ATTRIBUTE_REF:
case CompletionProposal.POTENTIAL_METHOD_DECLARATION:
case CompletionProposal.ANONYMOUS_CLASS_DECLARATION:
case CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION:
descriptor = JavaElementImageProvider.getMethodImageDescriptor(false, flags);
break;
case CompletionProposal.TYPE_REF:
switch(Signature.getTypeSignatureKind(proposal.getSignature())) {
case Signature.CLASS_TYPE_SIGNATURE:
descriptor = JavaElementImageProvider.getTypeImageDescriptor(false, false, flags, false);
break;
case Signature.TYPE_VARIABLE_SIGNATURE:
descriptor = JavaPluginImages.DESC_OBJS_TYPEVARIABLE;
break;
default:
descriptor = null;
}
break;
case CompletionProposal.FIELD_REF:
case CompletionProposal.FIELD_REF_WITH_CASTED_RECEIVER:
descriptor = JavaElementImageProvider.getFieldImageDescriptor(false, flags);
break;
case CompletionProposal.LOCAL_VARIABLE_REF:
case CompletionProposal.VARIABLE_DECLARATION:
descriptor = JavaPluginImages.DESC_OBJS_LOCAL_VARIABLE;
break;
case CompletionProposal.PACKAGE_REF:
descriptor = JavaPluginImages.DESC_OBJS_PACKAGE;
break;
case CompletionProposal.KEYWORD:
case CompletionProposal.LABEL_REF:
descriptor = null;
break;
case CompletionProposal.JAVADOC_METHOD_REF:
case CompletionProposal.JAVADOC_TYPE_REF:
case CompletionProposal.JAVADOC_FIELD_REF:
case CompletionProposal.JAVADOC_VALUE_REF:
case CompletionProposal.JAVADOC_BLOCK_TAG:
case CompletionProposal.JAVADOC_INLINE_TAG:
case CompletionProposal.JAVADOC_PARAM_REF:
descriptor = JavaPluginImages.DESC_OBJS_JAVADOCTAG;
break;
default:
descriptor = null;
Assert.isTrue(false);
}
if (descriptor == null)
return null;
return decorateImageDescriptor(descriptor, proposal);
}
use of org.eclipse.jface.resource.ImageDescriptor in project che by eclipse.
the class BindingLabelProvider method getBindingImageDescriptor.
/**
* Returns the image descriptor for a binding with the flags as defined by {@link JavaElementImageProvider}.
* @param binding The binding to get the image for.
* @param imageFlags The image flags as defined in {@link JavaElementImageProvider}.
* @return the image of the binding or null if there is no image
*/
public static ImageDescriptor getBindingImageDescriptor(IBinding binding, int imageFlags) {
ImageDescriptor baseImage = getBaseImageDescriptor(binding, imageFlags);
if (baseImage != null) {
int adornmentFlags = getAdornmentFlags(binding);
Point size = ((imageFlags & JavaElementImageProvider.SMALL_ICONS) != 0) ? JavaElementImageProvider.SMALL_SIZE : JavaElementImageProvider.BIG_SIZE;
return new JavaElementImageDescriptor(baseImage, adornmentFlags);
}
return null;
}
use of org.eclipse.jface.resource.ImageDescriptor in project translationstudio8 by heartsome.
the class XLIFFEditorImplWithNatTable method openFile.
/**
* 打开文件
* @param files
* @param input
* @throws PartInitException
* ;
*/
private void openFile(List<File> files, IEditorInput input) throws PartInitException {
OpenFile of = new OpenFile(files);
try {
/**
* 异常信息:<br />
* Warning: Detected recursive attempt by part net.heartsome.cat.ts.ui.xliffeditor.nattable.editor to create
* itself (this is probably, but not necessarily, a bug)
*/
if (!PlatformUI.getWorkbench().isStarting()) {
new ProgressMonitorDialog(getSite().getShell()).run(false, true, of);
} else {
of.run(null);
}
// of.run(null);
} catch (InvocationTargetException e) {
throw new PartInitException(e.getMessage(), e);
} catch (InterruptedException e) {
throw new PartInitException(e.getMessage(), e);
}
Map<String, Object> result = of.getOpenFileResult();
if (result == null || Constant.RETURNVALUE_RESULT_SUCCESSFUL != (Integer) result.get(Constant.RETURNVALUE_RESULT)) {
openFileSucceed = false;
Throwable e = (Throwable) result.get(Constant.RETURNVALUE_EXCEPTION);
if (e != null) {
throw new PartInitException(e.getMessage(), e);
}
String msg = (String) result.get(Constant.RETURNVALUE_MSG);
if (msg == null || msg.length() == 0) {
msg = Messages.getString("editor.XLIFFEditorImplWithNatTable.msg4");
}
MessageDialog.openError(getSite().getShell(), Messages.getString("editor.XLIFFEditorImplWithNatTable.msgTitle3"), msg);
// 关闭此编辑器。
close();
} else {
// 成功打开文件时
openFileSucceed = true;
// 判断所打开的文件是否为空,如果为空,进行提示,并关闭编辑器, robert 2013-04-01
int tuSize = handler.countTransUnit();
if (tuSize <= 0) {
MessageDialog.openWarning(getSite().getShell(), Messages.getString("dialog.UpdateNoteDialog.msgTitle1"), Messages.getString("editor.XLIFFEditorImplWithNatTable.cantOpenNullFile"));
close();
}
Image oldTitleImage = titleImage;
if (input != null) {
IEditorRegistry editorRegistry = PlatformUI.getWorkbench().getEditorRegistry();
IEditorDescriptor editorDesc = editorRegistry.findEditor(getSite().getId());
ImageDescriptor imageDesc = editorDesc != null ? editorDesc.getImageDescriptor() : null;
titleImage = imageDesc != null ? imageDesc.createImage() : null;
}
// 如果是合并打开,设置不一样的标志
if (multiFile) {
setTitleImage(net.heartsome.cat.ts.ui.xliffeditor.nattable.Activator.getImageDescriptor("icons/multiFiles.png").createImage());
} else {
setTitleImage(titleImage);
}
if (oldTitleImage != null && !oldTitleImage.isDisposed()) {
oldTitleImage.dispose();
}
JFaceResources.getFontRegistry().addListener(fFontPropertyChangeListener);
}
}
use of org.eclipse.jface.resource.ImageDescriptor in project translationstudio8 by heartsome.
the class ChangeEditorLayoutHandler method updateElement.
public void updateElement(UIElement element, Map parameters) {
String layout = (String) parameters.get("xliffEditor.layout");
if (XLIFFEditorImplWithNatTable.getCurrent().isHorizontalLayout()) {
ImageDescriptor horizontalImageDescriptor = Activator.getImageDescriptor(layout == null ? ImageConstant.TOOL_LAYOUT_HORIZONTAL : "images/view/horizontal.png");
element.setIcon(horizontalImageDescriptor);
element.setTooltip(Messages.getString("handler.ChangeEditorLayoutHandler.horizontalTooltip"));
} else {
ImageDescriptor verticalImageDescriptor = Activator.getImageDescriptor(layout == null ? ImageConstant.TOOL_LAYOUT_VERTICAL : "images/view/vertical.png");
element.setIcon(verticalImageDescriptor);
element.setTooltip(Messages.getString("handler.ChangeEditorLayoutHandler.verticalTooltip"));
}
}
Aggregations