/** @generated */ protected void setupCompartmentCollapsed(View view) { DrawerStyle drawerStyle = (DrawerStyle) view.getStyle(NotationPackage.eINSTANCE.getDrawerStyle()); if (drawerStyle != null) { drawerStyle.setCollapsed(false); } }
/** * initialize the background for a graphical element * * @param view the element to initialize * @param store the preference store * @param elementName the name to the element */ public static void initBackgroundFromPrefs( View view, final IPreferenceStore store, String elementName) { if (!usePreferenceInitializer(view)) { return; } String fillColorConstant = getpreferenceKey(view, elementName, PreferenceConstantHelper.COLOR_FILL); String gradientColorConstant = getpreferenceKey(view, elementName, PreferenceConstantHelper.COLOR_GRADIENT); String gradientPolicyConstant = getpreferenceKey(view, elementName, PreferenceConstantHelper.GRADIENT_POLICY); String shadowConstant = getpreferenceKey(view, elementName, PreferenceConstantHelper.SHADOW); String elementIcon = getpreferenceKey(view, elementName, PreferenceConstantHelper.ELEMENTICON); String qualifiedName = getpreferenceKey(view, elementName, PreferenceConstantHelper.QUALIFIEDNAME); org.eclipse.swt.graphics.RGB fillRGB = PreferenceConverter.getColor(store, fillColorConstant); ViewUtil.setStructuralFeatureValue( view, NotationPackage.eINSTANCE.getFillStyle_FillColor(), FigureUtilities.RGBToInteger(fillRGB)); FillStyle fillStyle = (FillStyle) view.getStyle(NotationPackage.Literals.FILL_STYLE); fillStyle.setFillColor(FigureUtilities.RGBToInteger(fillRGB).intValue()); if (store.getBoolean(gradientPolicyConstant)) { GradientPreferenceConverter gradientPreferenceConverter = new GradientPreferenceConverter(store.getString(gradientColorConstant)); fillStyle.setGradient(gradientPreferenceConverter.getGradientData()); fillStyle.setTransparency(gradientPreferenceConverter.getTransparency()); } EditingDomain domain = EMFHelper.resolveEditingDomain(view); if (domain instanceof TransactionalEditingDomain) { TransactionalEditingDomain editingDomain = (TransactionalEditingDomain) domain; // shadow RecordingCommand shadowcommand = AnnotationStyleProvider.getSetShadowCommand( editingDomain, view, store.getBoolean(shadowConstant)); if (shadowcommand.canExecute()) { shadowcommand.execute(); } // icon label RecordingCommand namelabelIconCommand = AnnotationStyleProvider.getSetElementIconCommand( editingDomain, view, store.getBoolean(elementIcon)); if (namelabelIconCommand.canExecute()) { namelabelIconCommand.execute(); } // qualified name if (!store.getBoolean(qualifiedName)) { RecordingCommand qualifiedNameCommand = AnnotationStyleProvider.getSetQualifiedNameDepthCommand(editingDomain, view, 1000); if (qualifiedNameCommand.canExecute()) { qualifiedNameCommand.execute(); } } } }
/** Caches ID_SORTING, ID_SORTED_OBJECTS and ID_SORTING_KEYS values for local access. */ private void tokenizeSortProperty() { Object model = editPart.getModel(); if (model instanceof View) { View view = (View) model; SortingStyle style = (SortingStyle) view.getStyle(NotationPackage.eINSTANCE.getSortingStyle()); if (style != null) { _sorting = style.getSorting(); _sortedObjects = style.eIsSet(NotationPackage.eINSTANCE.getSortingStyle_SortedObjects()) ? new ArrayList(style.getSortedObjects()) : Collections.EMPTY_LIST; _sortingKeys = style.eIsSet(NotationPackage.eINSTANCE.getSortingStyle_SortingKeys()) ? new HashMap(style.getSortingKeys()) : Collections.EMPTY_MAP; // Currently, only one sorting column can be defined. if (_sortingKeys.size() > 0) { Set keySet = _sortingKeys.keySet(); Iterator iter = keySet.iterator(); if (iter.hasNext()) { _sortColumn = (String) iter.next(); _sortingDirection = (SortingDirection) _sortingKeys.get(_sortColumn); } } } } }
/** @generated NOT */ protected void decorateView( View containerView, View view, IAdaptable semanticAdapter, String semanticHint, int index, boolean persisted) { if (semanticHint == null) { semanticHint = OepcVisualIDRegistry.getType(XORConnectorEditPart.VISUAL_ID); view.setType(semanticHint); } super.decorateView(containerView, view, semanticAdapter, semanticHint, index, persisted); if (!OEPCEditPart.MODEL_ID.equals(OepcVisualIDRegistry.getModelID(containerView))) { EAnnotation shortcutAnnotation = EcoreFactory.eINSTANCE.createEAnnotation(); shortcutAnnotation.setSource("Shortcut"); // $NON-NLS-1$ shortcutAnnotation.getDetails().put("modelID", OEPCEditPart.MODEL_ID); // $NON-NLS-1$ view.getEAnnotations().add(shortcutAnnotation); } // setting up default color background to view style NotationPackage NOTATION = NotationPackage.eINSTANCE; EClass shapeStyle = NOTATION.getShapeStyle(); ShapeStyle style = (ShapeStyle) view.getStyle(shapeStyle); if (style == null) { style = (ShapeStyle) view.createStyle(shapeStyle); } BflowDiagramEditPart.apply(XORConnectorEditPart.class, style); }
/** @generated */ protected Command getOpenCommand(Request request) { EditPart targetEditPart = getTargetEditPart(request); if (false == targetEditPart.getModel() instanceof View) { return null; } View view = (View) targetEditPart.getModel(); Style link = view.getStyle(NotationPackage.eINSTANCE.getHintedDiagramLinkStyle()); if (false == link instanceof HintedDiagramLinkStyle) { return null; } return new ICommandProxy(new OpenDiagramCommand((HintedDiagramLinkStyle) link)); }
/** * getDecoratorTargetClassifier Utility method to determine if the decoratorTarget is a supported * type for this decorator and return the associated Classifier element. * * @param decoratorTarget IDecoratorTarget to check and return valid Classifier target. * @return node Node if IDecoratorTarget can be supported, null otherwise. */ public static Node getDecoratorTargetNode(IDecoratorTarget decoratorTarget) { DescriptionStyle descStyle = null; View node = (View) decoratorTarget.getAdapter(View.class); if (node != null && !(node instanceof Diagram)) { descStyle = (DescriptionStyle) node.getStyle(NotationPackage.eINSTANCE.getDescriptionStyle()); if (descStyle != null) { return (Node) node; } } return null; }
/** * initialize the status of the compartment for the node (Showed or hidden) * * @param view the element to initialize * @param store the preference store * @param elementName the name to the element */ public static void initCompartmentsStatusFromPrefs( View view, final IPreferenceStore store, String elementName) { EList<?> children = view.getPersistedChildren(); if (children != null) { for (Object object : children) { // we look for the name of the compartment for this view EditPart dummyEP = EditPartService.getInstance().createGraphicEditPart((View) object); IGraphicalEditPart epp = (IGraphicalEditPart) dummyEP; IFigure fig1 = epp.getFigure(); if (fig1 instanceof ResizableCompartmentFigure) { String compartmentName = ((ResizableCompartmentFigure) fig1).getCompartmentTitle(); if (compartmentName != null) { String diagramKind = view.getDiagram().getType(); String preferenceKey = PreferenceConstantHelper.getCompartmentElementConstant( diagramKind + "_" + elementName, compartmentName, PreferenceConstantHelper.COMPARTMENT_VISIBILITY); // $NON-NLS-1$ boolean value = store.getBoolean(preferenceKey); if (!value) { // the default value is true : nothing to // do ENamedElement namedElement = PackageUtil.getElement("notation.View.visible"); // $NON-NLS-1$ ViewUtil.setStructuralFeatureValue( (View) object, (EStructuralFeature) namedElement, value); } String compartmentNameVisibilityPreference = PreferenceConstantHelper.getCompartmentElementConstant( diagramKind + "_" + elementName, compartmentName, PreferenceConstantHelper.COMPARTMENT_NAME_VISIBILITY); // $NON-NLS-1$ boolean showCompartmentName = store.getBoolean(compartmentNameVisibilityPreference); View childView = (View) object; TitleStyle style = (TitleStyle) childView.getStyle(NotationPackage.eINSTANCE.getTitleStyle()); if (style != null) { style.setShowTitle(showCompartmentName); } } } dummyEP = null; } } }
@Override protected void initializeFromPreferences(View view) { super.initializeFromPreferences(view); IPreferenceStore store = (IPreferenceStore) getPreferencesHint().getPreferenceStore(); if (store == null) { return; } // Create region default styles ShapeStyle style = (ShapeStyle) view.getStyle(NotationPackage.Literals.SHAPE_STYLE); RGB fillRGB = PreferenceConverter.getColor(store, StatechartPreferenceConstants.PREF_REGION_BACKGROUND); style.setFillColor(FigureUtilities.RGBToInteger(fillRGB)); RGB lineRGB = PreferenceConverter.getColor(store, StatechartPreferenceConstants.PREF_REGION_LINE); style.setLineColor(FigureUtilities.RGBToInteger(lineRGB)); }
/** Caches ID_FILTERING, ID_FILTERED_OBJECTS and ID_FILTERING_KEYS values for local access. */ private void tokenizeFilterProperty() { Object model = editPart.getModel(); if (model instanceof View) { View view = (View) model; FilteringStyle style = (FilteringStyle) view.getStyle(NotationPackage.eINSTANCE.getFilteringStyle()); if (style != null) { _filtering = style.getFiltering(); _filteredObjects = style.eIsSet(NotationPackage.eINSTANCE.getFilteringStyle_FilteredObjects()) ? new ArrayList(style.getFilteredObjects()) : Collections.EMPTY_LIST; _filteringKeys = style.eIsSet(NotationPackage.eINSTANCE.getFilteringStyle_FilteringKeys()) ? new ArrayList(style.getFilteringKeys()) : Collections.EMPTY_LIST; } } }
/** @generated NOT */ protected void decorateView( View containerView, View view, IAdaptable semanticAdapter, String semanticHint, int index, boolean persisted) { if (semanticHint == null) { semanticHint = VcVisualIDRegistry.getType(RelationEditPart.VISUAL_ID); view.setType(semanticHint); } super.decorateView(containerView, view, semanticAdapter, semanticHint, index, persisted); NotationPackage NOTATION = NotationPackage.eINSTANCE; EClass routingStyle = NOTATION.getRoutingStyle(); RoutingStyle routing = (RoutingStyle) view.getStyle(routingStyle); if (routing == null) { routing = (RoutingStyle) view.createStyle(routingStyle); } routing.setRouting(Routing.RECTILINEAR_LITERAL); }
/** * initialize the font for a graphical element * * @param view the element to initialize * @param store the preference store * @param elementName the name to the element */ public static void initFontStyleFromPrefs( View view, final IPreferenceStore store, String elementName) { if (!usePreferenceInitializer(view)) { return; } String fontConstant = getpreferenceKey(view, elementName, PreferenceConstantHelper.FONT); String fontColorConstant = getpreferenceKey(view, elementName, PreferenceConstantHelper.COLOR_FONT); FontStyle viewFontStyle = (FontStyle) view.getStyle(NotationPackage.Literals.FONT_STYLE); if (viewFontStyle != null) { FontData fontData = PreferenceConverter.getFontData(store, fontConstant); viewFontStyle.setFontName(fontData.getName()); viewFontStyle.setFontHeight(fontData.getHeight()); viewFontStyle.setBold((fontData.getStyle() & SWT.BOLD) != 0); viewFontStyle.setItalic((fontData.getStyle() & SWT.ITALIC) != 0); org.eclipse.swt.graphics.RGB fontRGB = PreferenceConverter.getColor(store, fontColorConstant); viewFontStyle.setFontColor(FigureUtilities.RGBToInteger(fontRGB).intValue()); } }
/** @generated */ protected void setupCompartmentTitle(View view) { TitleStyle titleStyle = (TitleStyle) view.getStyle(NotationPackage.eINSTANCE.getTitleStyle()); if (titleStyle != null) { titleStyle.setShowTitle(true); } }
/** {@inheritDoc} */ @Override protected Command getActionCommand() { /* for further information, see bug 302555 */ ViewServiceUtil.forceLoad(); ShowHideCompartmentRequest req = null; CompoundCommand completeCmd = new CompoundCommand("Destroy and Create Compartment Command"); // $NON-NLS-1$ // the commands to hide compartment for (EditPartRepresentation current : this.viewsToDestroy) { if (current instanceof CompartmentEditPartRepresentation) { CompartmentEditPartRepresentation currentRepresentation = (CompartmentEditPartRepresentation) current; View currentView = currentRepresentation.getCompartmentView(); EditPart currentEditPart = currentRepresentation .getRepresentedEditPart(); // should not be null, because a view to delete should // be visible, and so have an existing associated edit // part. // if null, try to find it using gmf methods from the view if (currentEditPart == null) { Activator.log.debug( "Warning! An edit part representation wished to destroy a view, but no edit part exists currently!" + current); currentEditPart = DiagramEditPartsUtil.getEditPartFromView(currentView, selectedElements.get(0)) .getParent(); } if (currentEditPart != null) { req = new ShowHideCompartmentRequest(ShowHideCompartmentRequest.HIDE, currentView); req.setType(ShowHideCompartmentRequest.SHOW_HIDE_COMPARTMENT); Command tmp = currentEditPart.getCommand(req); if (tmp != null && tmp.canExecute()) { completeCmd.add(tmp); } } else { Activator.log.debug( "Impossible to find an edit part for the given representation: " + current); } } // if(current instanceof View) { // EditPart ep = DiagramEditPartsUtil.getEditPartFromView((View)current, // selectedElements.get(0)).getParent(); // req = new ShowHideCompartmentRequest(ShowHideCompartmentRequest.HIDE, // ((View)current).getType()); // req.setType(ShowHideCompartmentRequest.SHOW_HIDE_COMPARTMENT); // Command tmp = ep.getCommand(req); // if(tmp != null && tmp.canExecute()) { // completeCmd.add(tmp); // } // } else if(current instanceof CompartmentTitleRepresentation) { // ShowHideTitleOfCompartmentCommand tmp = new // ShowHideTitleOfCompartmentCommand(this.domain, // (View)((CompartmentTitleRepresentation)current).getRealObject(), false); // if(tmp != null && tmp.canExecute()) { // completeCmd.add(new ICommandProxy(tmp)); // } // } } // the command to show compartment for (EditPartRepresentation current : this.viewsToCreate) { if (current instanceof CompartmentEditPartRepresentation) { CompartmentEditPartRepresentation currentRepresentation = (CompartmentEditPartRepresentation) current; View currentView = currentRepresentation.getCompartmentView(); EditPartRepresentation parentRepresentation = currentRepresentation.getParentRepresentation(); IGraphicalEditPart parentEditPart = parentRepresentation.getRepresentedEditPart(); if (currentView != null && parentEditPart != null) { req = new ShowHideCompartmentRequest(ShowHideCompartmentRequest.SHOW, currentView); req.setType(ShowHideCompartmentRequest.SHOW_HIDE_COMPARTMENT); Command tmp = parentEditPart.getCommand(req); if (tmp != null && tmp.canExecute()) { completeCmd.add(tmp); } } } // if(current instanceof View) { // EditPart ep = CompartmentUtils.getCompartmentTitleRepresentation(rep, // (View)current).getParent(); // req = new ShowHideCompartmentRequest(ShowHideCompartmentRequest.SHOW, // ((View)current).getType()); // req.setType(ShowHideCompartmentRequest.SHOW_HIDE_COMPARTMENT); // Command tmp = ep.getCommand(req); // if(tmp != null && tmp.canExecute()) { // completeCmd.add(tmp); // } // } else if(current instanceof CompartmentTitleRepresentation) { // CompartmentTitleRepresentation compartmentTitleRep = // (CompartmentTitleRepresentation)current; // final View view = (View)compartmentTitleRep.getRealObject(); // Style style = view.getStyle(NotationPackage.eINSTANCE.getTitleStyle()); // if(style == null) { // // style is not existing yet (true for models created with Papyrus 0.7.x) => create now // // See bug 351084 // completeCmd.add(new ICommandProxy(new AbstractTransactionalCommand(domain, "Create // title style", Collections.EMPTY_LIST) { //$NON-NLS-1$ // // public CommandResult doExecuteWithResult(IProgressMonitor dummy, IAdaptable info) { // TitleStyle style = // (TitleStyle)view.createStyle(NotationPackage.eINSTANCE.getTitleStyle()); // style.setShowTitle(false); // return CommandResult.newOKCommandResult(); // } // })); // } // ShowHideTitleOfCompartmentCommand tmp = new // ShowHideTitleOfCompartmentCommand(this.domain, view, true); // if(tmp != null && tmp.canExecute()) { // completeCmd.add(new ICommandProxy(tmp)); // } // } } // now sets the visibility for all shown views for (CompartmentEditPartRepresentation currentRepresentation : visibleRepresentations) { final View currentView = currentRepresentation.getCompartmentView(); boolean newVisibility = currentRepresentation.isTitleVisible(); boolean oldVisibility = CompartmentUtils.isCompartmentTitleVisible(currentView); IGraphicalEditPart parentEditPart = currentRepresentation.getParentRepresentation().getRepresentedEditPart(); final TransactionalEditingDomain domain = parentEditPart.getEditingDomain(); // visibility has changed => change the model if (newVisibility != oldVisibility) { Style style = currentView.getStyle(NotationPackage.eINSTANCE.getTitleStyle()); if (style == null) { // style is not existing yet (true for models created with Papyrus 0.7.x) => create now // See bug 351084 completeCmd.add( new ICommandProxy( new AbstractTransactionalCommand( domain, "Create title style", Collections.EMPTY_LIST) { // $NON-NLS-1$ @Override public CommandResult doExecuteWithResult( IProgressMonitor dummy, IAdaptable info) { TitleStyle style = (TitleStyle) currentView.createStyle(NotationPackage.eINSTANCE.getTitleStyle()); style.setShowTitle(false); return CommandResult.newOKCommandResult(); } })); } ShowHideTitleOfCompartmentCommand tmp = new ShowHideTitleOfCompartmentCommand(domain, currentView, newVisibility); if (tmp != null && tmp.canExecute()) { completeCmd.add(new ICommandProxy(tmp)); } } } return completeCmd; }
/** @generated NOT */ protected void initializeFromPreferences(View view) { super.initializeFromPreferences(view); ((FillStyle) view.getStyle(NotationPackage.Literals.FILL_STYLE)) .setFillColor(FigureUtilities.colorToInteger(DEFAULT_COLOR)); }