public void elementChanged( DesignElementHandle element, NotificationEvent ev ) { switch ( ev.getEventType( ) ) { case NotificationEvent.CONTENT_EVENT : case NotificationEvent.ELEMENT_DELETE_EVENT : case NotificationEvent.PROPERTY_EVENT : case NotificationEvent.STYLE_EVENT : case NotificationEvent.THEME_EVENT : case NotificationEvent.TEMPLATE_TRANSFORM_EVENT : { markDirty( true ); refresh( ); // The children of master page edit part keep // virtual model // Those edit part will not get notification // refresh them explicit for ( Iterator it = getChildren( ).iterator( ); it.hasNext( ); ) { ( (AbstractEditPart) it.next( ) ).refresh( ); } } } }
/** * This method should return a {@link org.eclipse.jface.viewers.StructuredSelection} containing * one or more of the viewer's EditParts underline EMF objects . If no editparts are selected, * root EMF object will return * */ public ISelection getSelection() { StructuredSelection selection = (StructuredSelection) viewer.getSelection(); if (!selection.isEmpty()) { List<Object> emfObj = new ArrayList<Object>(); Object[] array = selection.toArray(); for (Object object : array) { if (object instanceof AbstractEditPart) { AbstractEditPart abstractEditPart = (AbstractEditPart) object; if(abstractEditPart instanceof IPropertySourceProvider) { IPropertySourceProvider mergeModelProvider = (IPropertySourceProvider) abstractEditPart; IPropertySource merged = mergeModelProvider.getPropertySource(); if(merged==null) { emfObj.add(abstractEditPart.getModel()); } else { emfObj.add(merged); } } else emfObj.add(abstractEditPart.getModel()); } } return new StructuredSelection(emfObj); } return viewer.getSelection(); }
public Object getAdapter(Object adaptableObject, Class adapterType) { AbstractEditPart part = (AbstractEditPart) adaptableObject; Object model = part.getModel(); if (model instanceof IPropertySource) return model; if (model instanceof IAdaptable) return ((IAdaptable) model).getAdapter(adapterType); return null; }
/** * Tokenizes the first element in the {@code IStructuredSelection} by delegating to the * appropriate tokenizer. */ private void tokenize(final IStructuredSelection selection) { final Object element = selection.getFirstElement(); if (element instanceof IJavaElement) { try { tokenize((IJavaElement) element); } catch (final JavaModelException e) { // do nothing } } else if (element instanceof AbstractEditPart) { final Object model = ((AbstractEditPart) element).getModel(); if (model instanceof IInitiatorEvent) { tokenize((IInitiatorEvent) model); } else if (model instanceof IContour) { tokenize((IContour) model); } } }
protected IAction getAction( ReportLayoutEditor reportDesigner ) { AbstractEditPart part = (AbstractEditPart) selection; ListingHandle handle = (ListingHandle) part.getModel( ); SlotHandle groups = handle.getGroups( ); Iterator iter = groups.iterator( ); GroupHandle groupToEdit = null; // look for the group with the right name while ( iter.hasNext( ) ) { GroupHandle group = (GroupHandle) iter.next( ); if ( group.getName( ) != null && group.getName( ).equals( params[1] ) ) { groupToEdit = group; break; } } // no group with the right name found, use the first one if any if ( groupToEdit == null && groups.getCount( ) > 0 ) { groupToEdit = (GroupHandle) groups.iterator( ).next( ); } if ( groupToEdit != null ) { EditGroupAction action = new EditGroupAction( reportDesigner, groupToEdit ); return action; } return null; }
public PasteElementCommand(AbstractEditPart pasteTarget, GUIEditor guiEditor){ this.pasteTarget = pasteTarget; this.guiEditor = guiEditor; newTopLevelParts = new ArrayList<EditPart>(); }
private Command createPasteCommand() { List selectedObjects = getSelectedObjects(); if(selectedObjects != null && selectedObjects.size() > 0 && selectedObjects.get(0) != null && selectedObjects.get(0) instanceof AbstractEditPart) return new PasteElementCommand(((AbstractEditPart)selectedObjects.get(0)),(GUIEditor)getWorkbenchPart()); return null; }