本文整理汇总了Java中org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart.getModel方法的典型用法代码示例。如果您正苦于以下问题:Java GraphicalEditPart.getModel方法的具体用法?Java GraphicalEditPart.getModel怎么用?Java GraphicalEditPart.getModel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart
的用法示例。
在下文中一共展示了GraphicalEditPart.getModel方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getElement
import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart; //导入方法依赖的package包/类
/**
* Returns the EObject.
*
* @param editPart the edit part.
* @return the EObject.
*/
public static EObject getElement(GraphicalEditPart editPart) {
if (editPart == null) {
return null;
}
Object model = editPart.getModel();
if (!(model instanceof View)) {
return null;
}
View view = (View) model;
return view.getElement();
}
示例2: getBasicNode
import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart; //导入方法依赖的package包/类
/**
* Gets the BasicNode object from a GraphicalEditPart object.
*
* @param element a GraphicalEditPart object.
* @return the BasicNode object
*/
protected BasicNode getBasicNode(GraphicalEditPart element) {
if (element == null) {
return null;
}
BasicNode basicNode = null;
// gets the View object.
Object model = element.getModel();
if (model instanceof View) {
View view = (View) model;
// gets the EObject object.
EObject eObj = view.getElement();
// casts to BasicNode.
if (eObj instanceof BasicNode) {
basicNode = (BasicNode) eObj;
}
}
return basicNode;
}
示例3: testAttribute
import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart; //导入方法依赖的package包/类
/**
* Returns whether the target is appropriate to configure or set parameters.
*
* @see IActionFilter#testAttribute(Object, String, String)
* @param target the target.
* @param name the attribute name.
* @param value the attribute value.
* @return true if and only if the target is appropriate to configure or set parameters; false otherwise.
*/
public boolean testAttribute(Object target, String name, String value) {
boolean result = false;
if (NAME.equals(name) && VALUE.equals(value)) {
GraphicalEditPart graphicalEditPart = (GraphicalEditPart) target;
View view = (View) graphicalEditPart.getModel();
BasicNode node = (BasicNode) view.getElement();
String userdef007 = (String) node.getParameterVals();
if (userdef007 != null && userdef007.trim().length() != 0
&& ParameterItem.isValidParameter(userdef007)) {
result = true;
}
}
if (NAME.equals(name) && CONFIG_VALUE.equals(value)) {
result = true;
}
return result;
}
示例4: repositionConnectionLabels
import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart; //导入方法依赖的package包/类
public static void repositionConnectionLabels(DiagramEditPart diagep,
List<GraphicalEditPart> elements) {
for (EditPart editpart : elements) {
GraphicalEditPart ep = ((GraphicalEditPart) editpart);
@SuppressWarnings("unchecked")
List<ConnectionNodeEditPart> connections = ep.getSourceConnections();
for (ConnectionNodeEditPart connection : connections) {
@SuppressWarnings("unchecked")
List<GraphicalEditPart> labels = connection.getChildren();
for (GraphicalEditPart label : labels) {
List<Class<?>> decorationTypes = Arrays.asList(AssociationNameEditPart.class,
AssociationMultiplicityTargetEditPart.class, AssociationMultiplicitySourceEditPart.class);
String commandName = "RepositioningLabels";
if (isInstanceOfAny(label, decorationTypes)) {
ICommand cmd = new AbstractTransactionalCommand(diagep.getEditingDomain(), commandName, null) {
@Override
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info)
throws ExecutionException {
CSSDecorationNodeImpl v = ((CSSDecorationNodeImpl) label.getModel());
Location LC = (Location) v.getLayoutConstraint();
LC.setX(0);
LC.setY(0);
return CommandResult.newOKCommandResult();
}
};
try {
cmd.execute(new NullProgressMonitor(), null);
} catch (ExecutionException e) {
Logger.sys.warn("Could not execute command " + cmd + " (" + commandName + ")");
}
}
}
}
}
}