use of org.eclipse.gef.palette.PaletteEntry in project tdi-studio-se by Talend.
the class TalendPaletteContextMenuProvider method addListNotes.
public void addListNotes(List eleList, Project project, PaletteViewer paletteViewer) {
for (int i = 0; i < eleList.size(); i++) {
PaletteEntry elementLi = (PaletteEntry) eleList.get(i);
if (elementLi instanceof TalendPaletteDrawer) {
List list = ((TalendPaletteDrawer) elementLi).getChildren();
addListNotes(list, project, paletteViewer);
} else if (elementLi instanceof CombinedTemplateCreationEntry) {
addNotes((CombinedTemplateCreationEntry) elementLi, project, paletteViewer);
}
}
}
use of org.eclipse.gef.palette.PaletteEntry in project core by jcryptool.
the class AlgorithmPaletteViewer method makeAndAssignActions.
/**
* Constructs the actions according to the algorithm extension point and
* assigns the actions to the doubleclick listener of the viewer
*/
private void makeAndAssignActions() {
doubleClickHandler = new AbstractHandler() {
public Object execute(ExecutionEvent event) {
Object selection = ((IStructuredSelection) viewer.getSelection()).getFirstElement();
if (selection instanceof PaletteEditPart) {
PaletteEditPart paletteEditPart = (PaletteEditPart) selection;
Object model = paletteEditPart.getModel();
IEditorReference[] editorReferences = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
if (editorReferences.length == 0 && (!((PaletteEntry) model).getParent().getLabel().equals(org.jcryptool.core.Messages.applicationActionBarAdvisor_Menu_Algorithms_PRNG))) {
AlgorithmView.showMessage(Messages.AlgorithmPaletteViewer_0);
} else {
final ICommandService commandService = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
Iterator<CommandInfo> it9 = algorithmList.iterator();
CommandInfo commandInfo = null;
while (it9.hasNext()) {
commandInfo = it9.next();
ShadowAlgorithmHandler handler = (ShadowAlgorithmHandler) commandInfo.getHandler();
String commandId = commandInfo.getCommandId();
if (commandId != null && model.toString().equals("Palette Entry (" + handler.getText() + ")")) {
// $NON-NLS-1$ //$NON-NLS-2$
Command command = commandService.getCommand(commandId);
try {
return command.executeWithChecks(event);
} catch (Exception ex) {
LogUtil.logError(ViewsPlugin.PLUGIN_ID, ex);
return (null);
}
}
}
}
}
return (null);
}
};
viewer.getControl().addMouseListener(new MouseAdapter() {
@Override
public void mouseDoubleClick(final MouseEvent e) {
if (e.button == 1) {
// only left button double clicks
final IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench().getService(IHandlerService.class);
IEvaluationContext evaluationContext = handlerService.createContextSnapshot(true);
ExecutionEvent event = new ExecutionEvent(null, Collections.EMPTY_MAP, null, evaluationContext);
try {
// run assigned action
doubleClickHandler.execute(event);
} catch (ExecutionException ex) {
LogUtil.logError(ViewsPlugin.PLUGIN_ID, ex);
}
}
}
@Override
public void mouseDown(final MouseEvent e) {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
Object obj = selection.getFirstElement();
if (obj instanceof PaletteEditPart) {
AlgorithmView.showContextHelp(extensionPointId, ((PaletteEntry) ((PaletteEditPart) obj).getModel()).getLabel());
viewer.getControl().setFocus();
viewer.setSelection(selection);
}
}
});
}
use of org.eclipse.gef.palette.PaletteEntry in project core by jcryptool.
the class ViewProviderPaletteViewer method makeAndAssignActions.
/**
* Creates the actions and assigns them to the viewers double click listener.
*/
private void makeAndAssignActions() {
doubleClickHandler = new AbstractHandler() {
public Object execute(ExecutionEvent event) {
final ICommandService commandService = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
Object obj = ((IStructuredSelection) viewer.getSelection()).getFirstElement();
if (obj instanceof PaletteEditPart) {
PaletteEditPart part = (PaletteEditPart) obj;
IConfigurationElement[] elements = Platform.getExtensionRegistry().getExtensionPoint(extensionPointId).getConfigurationElements();
for (IConfigurationElement element : elements) {
if (element.getAttribute("name").equals((// $NON-NLS-1$
(PaletteEntry) part.getModel()).getLabel())) {
// $NON-NLS-1$
Command command = commandService.getCommand(element.getAttribute("viewId"));
try {
return command.executeWithChecks(event);
} catch (Exception ex) {
LogUtil.logError(ViewsPlugin.PLUGIN_ID, ex);
return (null);
}
}
}
}
return (null);
}
};
viewer.getControl().addMouseListener(new MouseAdapter() {
@Override
public void mouseDoubleClick(final MouseEvent e) {
if (e.button == 1) {
// only left button double clicks
final IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench().getService(IHandlerService.class);
IEvaluationContext evaluationContext = handlerService.createContextSnapshot(true);
ExecutionEvent event = new ExecutionEvent(null, Collections.EMPTY_MAP, null, evaluationContext);
try {
// run assigned action
doubleClickHandler.execute(event);
} catch (ExecutionException ex) {
LogUtil.logError(ViewsPlugin.PLUGIN_ID, ex);
}
}
}
@Override
public void mouseDown(final MouseEvent e) {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
Object obj = selection.getFirstElement();
if (obj instanceof PaletteEditPart) {
AlgorithmView.showContextHelp(extensionPointId, ((PaletteEntry) ((PaletteEditPart) obj).getModel()).getLabel());
viewer.getControl().setFocus();
viewer.setSelection(selection);
}
}
});
}
use of org.eclipse.gef.palette.PaletteEntry in project core by jcryptool.
the class ViewProviderPaletteViewer method createTree.
/**
* Creates a tree from the extension point structure.
*
* @param needles the search string to filter the elements
*/
private void createTree(String[] needles) {
invisibleRoot = new PaletteRoot();
TreeMap<String, PaletteEntry> sortList = new TreeMap<String, PaletteEntry>();
IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(extensionPointId);
// $NON-NLS-1$
String label = "";
if (extensionPoint.getLabel().equals("analysis")) {
// $NON-NLS-1$
label = AlgorithmView.MENU_TEXT_ANALYSIS;
} else if (extensionPoint.getLabel().equals("games")) {
// $NON-NLS-1$
label = AlgorithmView.MENU_TEXT_GAMES;
} else if (extensionPoint.getLabel().equals("visuals")) {
// $NON-NLS-1$
label = AlgorithmView.MENU_TEXT_VISUALS;
}
PaletteDrawer category = new PaletteDrawer(label);
category.setSmallIcon(ViewsPlugin.getImageDescriptor(TreeView.ICON_FOLDER));
category.setLargeIcon(ViewsPlugin.getImageDescriptor(TreeView.ICON_FOLDER));
invisibleRoot.add(category);
IConfigurationElement[] elements = extensionPoint.getConfigurationElements();
for (IConfigurationElement element : elements) {
// $NON-NLS-1$
String name = element.getAttribute("name");
// filter
boolean show = true;
for (String needle : needles) {
if (// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
!needle.equals("") && !name.toLowerCase().matches(".*" + needle.toLowerCase() + ".*"))
show = false;
}
if (show) {
SelectionToolEntry paletteEntry = new SelectionToolEntry(element.getAttribute("name"), // $NON-NLS-1$ //$NON-NLS-2$
"");
paletteEntry.setSmallIcon(ViewsPlugin.getImageDescriptor(TreeView.ICON_ITEM_JCT));
paletteEntry.setLargeIcon(ViewsPlugin.getImageDescriptor(TreeView.ICON_ITEM_JCT));
paletteEntry.setUserModificationPermission(PaletteEntry.PERMISSION_NO_MODIFICATION);
// $NON-NLS-1$
paletteEntry.setType("");
sortList.put(paletteEntry.getLabel(), paletteEntry);
}
}
// attach items to the category
for (PaletteEntry entry : sortList.values()) {
category.add(entry);
}
}
use of org.eclipse.gef.palette.PaletteEntry in project tdi-studio-se by Talend.
the class TalendEntryEditPart method refreshVisuals.
@Override
protected void refreshVisuals() {
applyChange();
PaletteEntry entry = getPaletteEntry();
talendCustomLabel.setName(entry.getLabel());
talendCustomLabel.setDescription(entry.getDescription());
if (getPreferenceSource().useLargeIcons()) {
setImageDescriptor(entry.getLargeIcon());
} else {
setImageDescriptor(entry.getSmallIcon());
}
int layoutMode = getLayoutSetting();
talendCustomLabel.setLayoutMode(layoutMode);
if (layoutMode == PaletteViewerPreferences.LAYOUT_COLUMNS) {
talendCustomLabel.setBorder(entryCSSStyleSetting.getIconBorder());
} else if (layoutMode == PaletteViewerPreferences.LAYOUT_LIST || layoutMode == PaletteViewerPreferences.LAYOUT_DETAILS) {
talendCustomLabel.setBorder(entryCSSStyleSetting.getListBorder());
} else if (layoutMode == PaletteViewerPreferences.LAYOUT_ICONS && !isToolbarItem()) {
talendCustomLabel.setBorder(entryCSSStyleSetting.getIconBorder());
} else {
talendCustomLabel.setBorder(null);
}
}
Aggregations