use of org.eclipse.sapphire.Element in project liferay-ide by liferay.
the class ActionsDiagramNodeEditHandlerFactory method create.
@Override
public List<SapphireActionHandler> create() {
ListFactory<SapphireActionHandler> factory = ListFactory.start();
Element element = getElement();
if (element == null) {
return factory.result();
}
ElementList<Action> actions = getActions();
if (_listener == null) {
_listener = new FilteredListener<PropertyEvent>() {
@Override
public void handleTypedEvent(PropertyEvent event) {
broadcast(new Event());
}
};
}
element.attach(_listener, getListPropertyName());
for (Action action : actions) {
action.getName().attach(_listener);
factory.add(new ScriptableOpenActionHandler() {
@Override
public void init(SapphireAction sapphireAction, ActionHandlerDef def) {
super.init(sapphireAction, def);
String name = action.getName().content(true);
setLabel(empty(name) ? "<null>" : name);
addImage(Action.TYPE.image());
}
@Override
protected Scriptable scriptable(Presentation context) {
return action;
}
});
}
return factory.result();
}
use of org.eclipse.sapphire.Element in project liferay-ide by liferay.
the class NotificationsDiagramNodeEditHandlerFactory method create.
@Override
public List<SapphireActionHandler> create() {
ListFactory<SapphireActionHandler> factory = ListFactory.start();
Element element = getElement();
if (element == null) {
return factory.result();
}
List<ActionNotification> notifications = getNotifications();
if (_listener == null) {
_listener = new FilteredListener<PropertyEvent>() {
@Override
public void handleTypedEvent(PropertyEvent event) {
broadcast(new Event());
}
};
}
element.attach(_listener, getListPropertyName());
for (Notification notification : notifications) {
notification.getName().attach(_listener);
factory.add(new TemplateOpenActionHandler() {
@Override
public void init(SapphireAction sapphireAction, ActionHandlerDef def) {
super.init(sapphireAction, def);
String name = notification.getName().content(true);
setLabel(empty(name) ? "<null>" : name);
addImage(ActionNotification.TYPE.image());
}
@Override
protected Notification notification(Presentation context) {
return notification;
}
});
}
return factory.result();
}
use of org.eclipse.sapphire.Element in project liferay-ide by liferay.
the class ShowDiagramPartActionHandler method run.
@Override
protected Object run(Presentation context) {
SapphireDiagramEditorPagePart diagramPart = context.part().nearest(SapphireDiagramEditorPagePart.class);
if (diagramPart != null) {
LabelProvider labelProvider = new LabelProvider() {
@Override
public Image getImage(Object element) {
if (element instanceof DiagramNodePart) {
DiagramNodePart diagramNodePart = (DiagramNodePart) element;
Element modelElement = diagramNodePart.getLocalModelElement();
return diagramPart.getSwtResourceCache().image(modelElement.type().image());
} else if (element instanceof DiagramConnectionPart) {
return diagramPart.getSwtResourceCache().image(Transition.TYPE.image());
} else {
return diagramPart.getSwtResourceCache().image(WorkflowNode.TYPE.image());
}
}
@Override
public String getText(Object element) {
if (element instanceof DiagramNodePart) {
return ((DiagramNodePart) element).getId();
} else if (element instanceof DiagramConnectionPart) {
return ((DiagramConnectionPart) element).getLabel();
} else {
if (element != null) {
return element.toString();
}
return "";
}
}
};
ElementListSelectionDialog dialog = new ElementListSelectionDialog(((SwtPresentation) context).shell(), labelProvider);
List<SapphirePart> parts = new ArrayList<>();
parts.addAll(diagramPart.getNodes());
parts.addAll(diagramPart.getConnections());
dialog.setElements(parts.toArray());
dialog.setMultipleSelection(false);
dialog.setHelpAvailable(false);
dialog.setTitle("Find Part");
dialog.setMessage("Select part:");
dialog.open();
Object[] result = dialog.getResult();
if ((result != null) && (result.length == 1)) {
// select node in diagram
ISapphirePart part = (ISapphirePart) result[0];
if (part instanceof DiagramConnectionPart || part instanceof DiagramNodePart) {
/*
* diagramPart.setSelections( ReadOnlyListFactory.create(
* part ) );
*/
SapphireDiagramEditor diagramEditor = diagramPart.adapt(SapphireDiagramEditor.class);
GraphicalViewer viewer = diagramEditor.getGraphicalViewer();
GraphicalEditPart editpart = diagramEditor.getGraphicalEditPart(part);
if (editpart != null) {
// Force a layout first.
viewer.flush();
viewer.select(editpart);
viewer.reveal(editpart);
}
}
}
}
return null;
}
use of org.eclipse.sapphire.Element in project liferay-ide by liferay.
the class ActionsListAddActionHandler method run.
@Override
protected Object run(Presentation context) {
Element newElement = (Element) super.run(context);
Action newAction = newElement.nearest(Action.class);
addActionDefaults(newAction);
return newAction;
}
use of org.eclipse.sapphire.Element in project liferay-ide by liferay.
the class AddServletFilterMappingAction method run.
@Override
protected Object run(Presentation context) {
Element element = context.part().getLocalModelElement();
Hook hook = element.nearest(Hook.class);
return hook.getServletFilterMappings().insert();
}
Aggregations