use of org.eclipse.jface.viewers.DecorationOverlayIcon in project hale by halestudio.
the class InstanceValidationReportDetailsPage method createControls.
/**
* @see CustomReportDetailsPage#createControls(Composite)
*/
@Override
public Control createControls(Composite parent) {
// filtered tree sets itself GridData, so set layout to gridlayout
parent.setLayout(GridLayoutFactory.fillDefaults().create());
// create pattern filter for FilteredTree
PatternFilter filter = new TreePathPatternFilter();
filter.setIncludeLeadingWildcard(true);
// create FilteredTree
FilteredTree filteredTree = new TreePathFilteredTree(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL, filter, true);
treeViewer = filteredTree.getViewer();
// set content provider
contentProvider = new InstanceValidationReportDetailsContentProvider();
treeViewer.setContentProvider(contentProvider);
// set label provider
treeViewer.setLabelProvider(new InstanceValidationReportDetailsLabelProvider(contentProvider));
// set comparator
treeViewer.setComparator(new ViewerComparator() {
/**
* @see org.eclipse.jface.viewers.ViewerComparator#category(java.lang.Object)
*/
@Override
public int category(Object element) {
if (element instanceof QName || element instanceof Definition<?>)
// Path
return 0;
else if (element instanceof String)
// Category
return 1;
else
// InstanceValidationMessage
return 2;
}
});
// add menu on right-click
MenuManager menuMgr = new MenuManager();
Menu menu = menuMgr.createContextMenu(treeViewer.getTree());
menuMgr.addMenuListener(new IMenuListener() {
@Override
public void menuAboutToShow(IMenuManager manager) {
if (getValidSelection() == null)
return;
// selection is valid, offer link to transformed data view
manager.add(new ShowExampleAction());
}
});
// remove previous menus
menuMgr.setRemoveAllWhenShown(true);
// add menu to tree
treeViewer.getTree().setMenu(menu);
treeViewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
showSelectionInDataView();
}
});
Image noReportBaseImage = InstanceValidationUIPlugin.getDefault().getImageRegistry().get(InstanceValidationUIPlugin.IMG_INSTANCE_VALIDATION);
reportImage = new DecorationOverlayIcon(noReportBaseImage, PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_DEC_FIELD_WARNING), IDecoration.BOTTOM_LEFT).createImage();
return filteredTree;
}
use of org.eclipse.jface.viewers.DecorationOverlayIcon in project xtext-eclipse by eclipse.
the class XtextEditorErrorTickUpdater method updateEditorImage.
protected void updateEditorImage(XtextEditor xtextEditor) {
Severity severity = getSeverity(xtextEditor);
if (severity != null && severity != Severity.INFO) {
ImageDescriptor descriptor = severity == Severity.ERROR ? XtextPluginImages.DESC_OVR_ERROR : XtextPluginImages.DESC_OVR_WARNING;
DecorationOverlayIcon decorationOverlayIcon = new DecorationOverlayIcon(defaultImage, descriptor, IDecoration.BOTTOM_LEFT);
scheduleUpdateEditor(decorationOverlayIcon);
} else {
scheduleUpdateEditor(defaultImage);
}
}
use of org.eclipse.jface.viewers.DecorationOverlayIcon in project sling by apache.
the class ServersActionModeFiddlerActionDelegate method initToolbarContributedActions.
private void initToolbarContributedActions() {
cleanAction = new Action("Clean Publish...", IAction.AS_PUSH_BUTTON) {
public void run() {
if (server == null) {
MessageDialog.openInformation(view.getSite().getShell(), "No server selected", "A server must be selected");
return;
}
int selection = 2;
if (!doNotAskAgain) {
MessageDialog dialog = new MessageDialog(view.getSite().getShell(), Messages.defaultDialogTitle, null, Messages.dialogPublishClean, MessageDialog.QUESTION_WITH_CANCEL, new String[] { "Cancel", "OK (do not ask again)", "OK" }, 1) {
@Override
protected void configureShell(Shell shell) {
super.configureShell(shell);
setShellStyle(getShellStyle() | SWT.SHEET);
}
};
selection = dialog.open();
}
if (selection != 0) {
if (selection == 1) {
doNotAskAgain = true;
}
IAdaptable info = new IAdaptable() {
public Object getAdapter(Class adapter) {
if (Shell.class.equals(adapter))
return view.getSite().getShell();
if (String.class.equals(adapter))
return "user";
return null;
}
};
server.publish(IServer.PUBLISH_CLEAN, modules, info, null);
}
}
};
cleanAction.setText("Clean Publish...");
cleanAction.setToolTipText("Clean and Publish...");
ImageDescriptor cleanAndPublishImageDesc = new DecorationOverlayIcon(ImageResource.getImageDescriptor(ImageResource.IMG_CLCL_PUBLISH).createImage(), ImageDescriptor.createFromFile(SharedImages.class, "refresh.gif"), IDecoration.BOTTOM_RIGHT);
cleanAction.setImageDescriptor(cleanAndPublishImageDesc);
cleanAction.setId("org.apache.sling.ide.eclipse.ui.actions.CleanPublishAction");
publishAction = new Action("Publish", IAction.AS_PUSH_BUTTON) {
public void run() {
if (server == null) {
MessageDialog.openInformation(view.getSite().getShell(), "No server selected", "A server must be selected");
return;
}
IAdaptable info = new IAdaptable() {
public Object getAdapter(Class adapter) {
if (Shell.class.equals(adapter))
return view.getSite().getShell();
if (String.class.equals(adapter))
return "user";
return null;
}
};
server.publish(IServer.PUBLISH_INCREMENTAL, modules, info, null);
}
};
publishAction.setText("Publish");
publishAction.setToolTipText("Publish");
publishAction.setImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_CLCL_PUBLISH));
publishAction.setId("org.apache.sling.ide.eclipse.ui.actions.PublishAction");
cleanAction.setEnabled(false);
publishAction.setEnabled(false);
cleanActionContributionItem = new ActionContributionItem(cleanAction);
publishActionContributionItem = new ActionContributionItem(publishAction);
appendedToolbarActionContributionItems.add(publishActionContributionItem);
appendedToolbarActionContributionItems.add(cleanActionContributionItem);
}
use of org.eclipse.jface.viewers.DecorationOverlayIcon in project webtools.sourceediting by eclipse.
the class XSDCommonUIUtils method getImageWithErrorOverlay.
public static Image getImageWithErrorOverlay(XSDConcreteComponent input, Image baseImage, boolean isReadOnly) {
Image extensionImage = getUpdatedImage(input, baseImage, isReadOnly);
// $NON-NLS-1$
ImageDescriptor errorOverlay = XSDEditorPlugin.getImageDescriptor("icons/ovr16/error_ovr.gif");
if (baseImage == extensionImage) {
String imageName = input.getClass().getName() + "_error_" + isReadOnly;
Image newImage = XSDEditorPlugin.getDefault().getImageRegistry().get(imageName);
if (newImage == null) {
DecorationOverlayIcon ovr = new DecorationOverlayIcon(baseImage, errorOverlay, IDecoration.TOP_LEFT);
newImage = ovr.createImage();
XSDEditorPlugin.getDefault().getImageRegistry().put(imageName, newImage);
}
return newImage;
} else {
String imageName = input.getClass().getName() + "_extension_error_" + isReadOnly;
Image newImage = XSDEditorPlugin.getDefault().getImageRegistry().get(imageName);
if (newImage == null) {
DecorationOverlayIcon ovr = new DecorationOverlayIcon(extensionImage, errorOverlay, IDecoration.TOP_LEFT);
newImage = ovr.createImage();
XSDEditorPlugin.getDefault().getImageRegistry().put(imageName, newImage);
}
return newImage;
}
}
use of org.eclipse.jface.viewers.DecorationOverlayIcon in project n4js by eclipse.
the class N4JSEditor method applyTitleImageOverlays.
/**
* This method is expected to add all applicable overlays for the title image to the given image descriptor. If no
* overlays are to be added, then the given image descriptor should be returned (this method should never return
* <code>null</code>).
* <p>
* This method should never add overlays to indicate errors/warnings, as this is taken care of by the default
* implementation of {@link XtextEditorErrorTickUpdater}.
*/
public ImageDescriptor applyTitleImageOverlays(ImageDescriptor titleImageDesc) {
if (isReconciling()) {
final Image image = imageHelper.getImage(titleImageDesc);
titleImageDesc = new DecorationOverlayIcon(image, ImageRef.TINY_CLOCK.asImageDescriptor().get(), IDecoration.TOP_RIGHT);
}
return titleImageDesc;
}
Aggregations