Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 52850 Details for
Bug 80318
[Plan Item] Class Diagrams
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Supporting auxiliary plugins for ClassD in form of a patch
patch_80318_aux.txt (text/plain), 181.47 KB, created by
Michael Golubev
on 2006-10-27 11:47:03 EDT
(
hide
)
Description:
Supporting auxiliary plugins for ClassD in form of a patch
Filename:
MIME Type:
Creator:
Michael Golubev
Created:
2006-10-27 11:47:03 EDT
Size:
181.47 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.uml2.diagram.parser >Index: src/org/eclipse/uml2/diagram/parser/lookup/LookupResolverImpl.java >=================================================================== >RCS file: src/org/eclipse/uml2/diagram/parser/lookup/LookupResolverImpl.java >diff -N src/org/eclipse/uml2/diagram/parser/lookup/LookupResolverImpl.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/uml2/diagram/parser/lookup/LookupResolverImpl.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,106 @@ >+/* >+ * Copyright (c) 2006 Borland Software Corporation >+ * >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Michael Golubev (Borland) - initial API and implementation >+ */ >+ >+package org.eclipse.uml2.diagram.parser.lookup; >+ >+import java.util.List; >+ >+import org.eclipse.core.commands.ExecutionException; >+import org.eclipse.core.runtime.IAdaptable; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.emf.transaction.TransactionalEditingDomain; >+import org.eclipse.gef.commands.Command; >+import org.eclipse.gef.requests.CreateRequest; >+import org.eclipse.gmf.runtime.common.core.command.CommandResult; >+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; >+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateUnspecifiedTypeRequest; >+import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; >+import org.eclipse.gmf.runtime.emf.type.core.IElementType; >+import org.eclipse.gmf.runtime.notation.View; >+import org.eclipse.uml2.uml.NamedElement; >+ >+ >+public class LookupResolverImpl implements LookupResolver { >+ private LookupResolveRequest myTheOnlyRequest; >+ private Callback myTheOnlyCallback; >+ private boolean myIsMultipleResolveRequired; >+ private final IGraphicalEditPart myResolvingEditPart; >+ >+ public LookupResolverImpl(IGraphicalEditPart resolvingEditPart){ >+ myResolvingEditPart = resolvingEditPart; >+ } >+ >+ public void addLookupResolveRequest(LookupResolveRequest request, Callback callback){ >+ if (isEmpty()){ >+ myTheOnlyCallback = callback; >+ myTheOnlyRequest = request; >+ } else { >+ myIsMultipleResolveRequired = true; >+ } >+ } >+ >+ public boolean isEmpty(){ >+ return myTheOnlyCallback == null && myTheOnlyRequest == null; >+ } >+ >+ public boolean canResolve(){ >+ return !isEmpty() && !myIsMultipleResolveRequired; >+ } >+ >+ public AbstractTransactionalCommand getResolveCommand() { >+ if (!canResolve()){ >+ return null; >+ } >+ TransactionalEditingDomain domain = myResolvingEditPart.getEditingDomain(); >+ final CreateUnspecifiedTypeRequest createRequest = new CreateUnspecifiedTypeRequest(myTheOnlyRequest.getElementTypes(), myResolvingEditPart.getDiagramPreferencesHint()); >+ final Command gefCommand = myResolvingEditPart.getCommand(createRequest); >+ if (!gefCommand.canExecute()){ >+ return null; >+ } >+ //XXX gef inside transactional command??? >+ return new AbstractTransactionalCommand(domain, "", null){ >+ @Override >+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { >+ gefCommand.execute(); >+ NamedElement resolution = getNewObject(); >+ if (resolution != null){ >+ resolution.eSet(myTheOnlyRequest.getInitFeature(), myTheOnlyRequest.getInitValue()); >+ myTheOnlyCallback.lookupResolved(resolution); >+ } >+ return CommandResult.newOKCommandResult(); >+ } >+ >+ private NamedElement getNewObject(){ >+ for (Object next : createRequest.getElementTypes()){ >+ IElementType nextElementType = (IElementType)next; >+ CreateRequest nextRequest = createRequest.getRequestForType(nextElementType); >+ List allNew = (List)nextRequest.getNewObject(); >+ for (Object nextCreated : allNew){ >+ if (nextCreated instanceof IAdaptable){ >+ View createdView = (View) ((IAdaptable)nextCreated).getAdapter(View.class); >+ if (createdView != null) { >+ EObject createdEntity = createdView.getElement(); >+ if (createdEntity instanceof NamedElement){ >+ return (NamedElement)createdEntity; >+ } >+ } >+ } >+ } >+ } >+ return null; >+ } >+ }; >+ } >+ >+ >+} >Index: build.properties >=================================================================== >RCS file: build.properties >diff -N build.properties >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ build.properties 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,4 @@ >+source.. = src/ >+output.. = bin/ >+bin.includes = META-INF/,\ >+ . >Index: src/org/eclipse/uml2/diagram/parser/ParserAdapter.java >=================================================================== >RCS file: src/org/eclipse/uml2/diagram/parser/ParserAdapter.java >diff -N src/org/eclipse/uml2/diagram/parser/ParserAdapter.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/uml2/diagram/parser/ParserAdapter.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,208 @@ >+/* >+ * Copyright (c) 2006 Borland Software Corporation >+ * >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Michael Golubev (Borland) - initial API and implementation >+ */ >+ >+package org.eclipse.uml2.diagram.parser; >+ >+import java.util.Iterator; >+import java.util.LinkedList; >+import java.util.List; >+ >+import org.eclipse.core.commands.ExecutionException; >+import org.eclipse.core.runtime.IAdaptable; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.emf.common.notify.Notification; >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.emf.ecore.EStructuralFeature; >+import org.eclipse.emf.transaction.TransactionalEditingDomain; >+import org.eclipse.emf.transaction.util.TransactionUtil; >+import org.eclipse.gmf.runtime.common.core.command.CommandResult; >+import org.eclipse.gmf.runtime.common.core.command.ICommand; >+import org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand; >+import org.eclipse.gmf.runtime.common.ui.services.parser.IParser; >+import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus; >+import org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus; >+import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart; >+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; >+import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; >+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand; >+import org.eclipse.jface.text.contentassist.IContentAssistProcessor; >+import org.eclipse.uml2.diagram.parser.lookup.LookupResolver; >+import org.eclipse.uml2.diagram.parser.lookup.LookupResolverImpl; >+import org.eclipse.uml2.diagram.parser.lookup.LookupSuite; >+import org.eclipse.uml2.internal.diagram.parser.MDTDiagramParserPlugin; >+ >+public class ParserAdapter implements IParser { >+ private static final String NOT_AN_OBJECT = "Unknown"; >+ private final ExternalParserBase myDelegate; >+ private final EObject myTester; >+ private final ApplyStrategy myApplier; >+ private final ExternalToString myView; >+ private final ExternalToString myEdit; >+ private final static MessageFormatEscaper ourMessageFormatEscaper = new MessageFormatEscaper(); >+ >+ public ParserAdapter(ExternalParserBase delegate, ApplyStrategy applier){ >+ this(delegate, applier, ExternalToString.NOT_IMPLEMENTED); >+ } >+ >+ public ParserAdapter(ExternalParserBase delegate, ApplyStrategy applier, ExternalToString viewAndEdit){ >+ this(delegate, applier, viewAndEdit, viewAndEdit); >+ } >+ >+ public ParserAdapter(ExternalParserBase delegate, ApplyStrategy applier, ExternalToString view, ExternalToString edit){ >+ myDelegate = delegate; >+ myApplier = applier; >+ myView = view; >+ myEdit = edit; >+ myTester = myDelegate.createSubjectPrototype(); >+ } >+ >+ public IContentAssistProcessor getCompletionProcessor(IAdaptable element) { >+ return null; >+ } >+ >+ public String getEditString(IAdaptable element, int flags) { >+ return getToString(element, flags, myEdit); >+ } >+ >+ public String getPrintString(IAdaptable element, int flags) { >+ return getToString(element, flags, myView); >+ } >+ >+ public final boolean isAffectingEvent(Object event, int flags) { >+ return isAffectingEvent(event); >+ } >+ >+ protected boolean isAffectingEvent(Object event){ >+ if (event instanceof Notification) { >+ Object feature = ((Notification) event).getFeature(); >+ return (feature instanceof EStructuralFeature) && myView.isAffectingFeature((EStructuralFeature)feature); >+ } >+ return false; >+ } >+ >+ public IParserEditStatus isValidEditString(IAdaptable adapter, String editString) { >+ EObject modelObject = (EObject) adapter.getAdapter(EObject.class); >+ if (modelObject == null) { >+ return new ParserEditStatus( >+ MDTDiagramParserPlugin.getPluginID(), IParserEditStatus.UNEDITABLE, >+ "Can not find context object"); >+ } >+ >+ LookupSuite oldLookup = myDelegate.getLookupSuite(); >+ try { >+ myDelegate.setLookupSuite(LookupSuite.NULL_SUITE); >+ myDelegate.parse(myTester, editString, modelObject); >+ return ParserEditStatus.EDITABLE_STATUS; >+ } catch (ExternalParserException e) { >+ //CellEditor uses MessageFormat to format the message >+ //we need to escape '{', '}', '\' to prevent failure while formatting an error >+ String message = e.getMessage(); >+ if (message == null){ >+ message = ""; >+ } >+ message = ourMessageFormatEscaper.getEscaped(message); >+ return new ParserEditStatus( >+ MDTDiagramParserPlugin.getPluginID(), IParserEditStatus.UNEDITABLE, >+ "Invalid input: " + message); >+ } finally { >+ myDelegate.setLookupSuite(oldLookup); >+ } >+ } >+ >+ public ICommand getParseCommand(IAdaptable adapter, String newString, int flags) { >+ final EObject modelObject = (EObject) adapter.getAdapter(EObject.class); >+ if (modelObject == null) { >+ return UnexecutableCommand.INSTANCE; >+ } >+ TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(modelObject); >+ if (editingDomain == null) { >+ return UnexecutableCommand.INSTANCE; >+ } >+ >+ IGraphicalEditPart diagramEditPart = (DiagramEditPart)adapter.getAdapter(DiagramEditPart.class); >+ LookupResolver resolver = LookupResolver.NULL; >+ if (diagramEditPart != null){ >+ resolver = new LookupResolverImpl(diagramEditPart); >+ } >+ myDelegate.setLookupResolver(resolver); >+ >+ final EObject parsed; >+ try { >+ parsed = myDelegate.parseNewObject(modelObject, newString); >+ } catch (ExternalParserException e){ >+ //strange >+ //e.printStackTrace(); >+ return UnexecutableCommand.INSTANCE; >+ } finally { >+ myDelegate.setLookupResolver(null); >+ } >+ >+ List commandList = new LinkedList(); >+ if (resolver.canResolve()){ >+ AbstractTransactionalCommand resolveCommand = resolver.getResolveCommand(); >+ AbstractTransactionalCommand computeAndApplyCommand = new AbstractTransactionalCommand(editingDomain, "", null){ >+ @Override >+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { >+ for (Iterator applyCommands = myApplier.apply(modelObject, parsed).iterator(); applyCommands.hasNext();){ >+ ICommand next = (ICommand)applyCommands.next(); >+ next.execute(monitor, info); >+ } >+ return CommandResult.newOKCommandResult(); >+ } >+ }; >+ commandList.add(resolveCommand); >+ commandList.add(computeAndApplyCommand); >+ } else { >+ commandList.addAll(myApplier.apply(modelObject, parsed)); >+ } >+ return new CompositeTransactionalCommand(editingDomain, getCommandLabel(commandList), commandList); >+ } >+ >+ protected final ExternalToString getViewToString() { >+ return myView; >+ } >+ >+ private String getToString(IAdaptable element, int flags, ExternalToString toString) { >+ EObject modelObject = (EObject) element.getAdapter(EObject.class); >+ return isValidElement(modelObject) ? toString.getToString(modelObject, flags) : NOT_AN_OBJECT; >+ } >+ >+ private String getCommandLabel(List/*1.5 <ICommand>*/ commandList){ >+ return "-not-implemented-"; >+ } >+ >+ protected final boolean isValidElement(Object object){ >+ return object != null && myDelegate.getSubjectClass().isInstance(object); >+ } >+ >+ private static class MessageFormatEscaper { >+ private final char S_QUOTE = '\''; >+ >+ public String getEscaped(String input){ >+ if (!input.contains("'")){ >+ return "'" + input + "'"; >+ } >+ StringBuffer result = new StringBuffer(input.length() + 5); >+ result.append(S_QUOTE); >+ for (int i = 0; i < input.length(); i++){ >+ char next = result.charAt(i); >+ if (next == S_QUOTE){ >+ result.append(S_QUOTE); >+ } >+ result.append(next); >+ } >+ result.append(S_QUOTE); >+ return result.toString(); >+ } >+ } >+ >+} >Index: src/org/eclipse/uml2/diagram/parser/lookup/LookupResolveRequest.java >=================================================================== >RCS file: src/org/eclipse/uml2/diagram/parser/lookup/LookupResolveRequest.java >diff -N src/org/eclipse/uml2/diagram/parser/lookup/LookupResolveRequest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/uml2/diagram/parser/lookup/LookupResolveRequest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,43 @@ >+/* >+ * Copyright (c) 2006 Borland Software Corporation >+ * >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Michael Golubev (Borland) - initial API and implementation >+ */ >+ >+package org.eclipse.uml2.diagram.parser.lookup; >+ >+import java.util.List; >+ >+import org.eclipse.emf.ecore.EStructuralFeature; >+import org.eclipse.gmf.runtime.emf.type.core.IElementType; >+ >+public class LookupResolveRequest { >+ private final List<IElementType> myElementTypes; >+ private final EStructuralFeature myInitFeature; >+ private final Object myInitValue; >+ >+ public LookupResolveRequest(List<IElementType> elementTypes, EStructuralFeature initFeature, Object initValue){ >+ myElementTypes = elementTypes; >+ myInitFeature = initFeature; >+ myInitValue = initValue; >+ } >+ >+ public List<IElementType> getElementTypes() { >+ return myElementTypes; >+ } >+ >+ public EStructuralFeature getInitFeature() { >+ return myInitFeature; >+ } >+ >+ public Object getInitValue() { >+ return myInitValue; >+ } >+ >+} >Index: src/org/eclipse/uml2/diagram/parser/ApplyStrategy.java >=================================================================== >RCS file: src/org/eclipse/uml2/diagram/parser/ApplyStrategy.java >diff -N src/org/eclipse/uml2/diagram/parser/ApplyStrategy.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/uml2/diagram/parser/ApplyStrategy.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,25 @@ >+/* >+ * Copyright (c) 2006 Borland Software Corporation >+ * >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Michael Golubev (Borland) - initial API and implementation >+ */ >+ >+package org.eclipse.uml2.diagram.parser; >+ >+import java.util.Collections; >+import java.util.List; >+ >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand; >+ >+public interface ApplyStrategy { >+ public List/*1.5 <ICommand>*/ apply(EObject modelObject, EObject parsedObject); >+ >+ public static final List/*1.5 <ICommand>*/ NOT_EXECUTABLE = Collections.singletonList(UnexecutableCommand.INSTANCE); >+} >Index: src/org/eclipse/uml2/diagram/parser/lookup/LookupSuiteImpl.java >=================================================================== >RCS file: src/org/eclipse/uml2/diagram/parser/lookup/LookupSuiteImpl.java >diff -N src/org/eclipse/uml2/diagram/parser/lookup/LookupSuiteImpl.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/uml2/diagram/parser/lookup/LookupSuiteImpl.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,44 @@ >+/* >+ * Copyright (c) 2006 Borland Software Corporation >+ * >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Michael Golubev (Borland) - initial API and implementation >+ */ >+ >+package org.eclipse.uml2.diagram.parser.lookup; >+ >+import java.util.HashMap; >+ >+public class LookupSuiteImpl implements LookupSuite { >+ private final HashMap<Class, Lookup> myLookups = new HashMap<Class, Lookup>(); >+ private LookupResolver myLookupResolver = LookupResolver.NULL; >+ >+ public <T> void addLookup(Class<T> clazz, Lookup<T> lookup){ >+ if (myLookups.containsKey(clazz)){ >+ throw new IllegalArgumentException("I already have lookup for :" + clazz); >+ } >+ myLookups.put(clazz, lookup); >+ } >+ >+ public <T> Lookup<T> getLookup(Class<T> clazz) { >+ Lookup<T> result = myLookups.get(clazz); >+ return result == null ? NULL_LOOKUP : result; >+ } >+ >+ public void setLookupResolver(LookupResolver lookupResolver){ >+ myLookupResolver = lookupResolver; >+ if (myLookupResolver == null){ >+ myLookupResolver = LookupResolver.NULL; >+ } >+ } >+ >+ public LookupResolver getLookupResolver() { >+ return myLookupResolver; >+ } >+ >+} >Index: .classpath >=================================================================== >RCS file: .classpath >diff -N .classpath >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ .classpath 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,7 @@ >+<?xml version="1.0" encoding="UTF-8"?> >+<classpath> >+ <classpathentry kind="src" path="src"/> >+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> >+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> >+ <classpathentry kind="output" path="bin"/> >+</classpath> >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: META-INF/MANIFEST.MF >diff -N META-INF/MANIFEST.MF >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ META-INF/MANIFEST.MF 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,28 @@ >+Manifest-Version: 1.0 >+Bundle-ManifestVersion: 2 >+Bundle-Name: UML Diagrams Parser Plug-in >+Bundle-SymbolicName: org.eclipse.uml2.diagram.parser; singleton:=true >+Bundle-Version: 1.0.0 >+Bundle-Localization: plugin >+Bundle-Activator: org.eclipse.uml2.internal.diagram.parser.MDTDiagramParserPlugin >+Require-Bundle: org.eclipse.core.runtime, >+ org.eclipse.jface, >+ org.eclipse.emf.ecore, >+ org.eclipse.emf.ecore.xmi, >+ org.eclipse.emf.edit.ui, >+ org.eclipse.gef;visibility:=reexport, >+ org.eclipse.gmf.runtime.emf.core, >+ org.eclipse.gmf.runtime.emf.commands.core, >+ org.eclipse.gmf.runtime.emf.ui.properties, >+ org.eclipse.gmf.runtime.diagram.ui, >+ org.eclipse.gmf.runtime.diagram.ui.properties, >+ org.eclipse.uml2.uml;visibility:=reexport, >+ org.eclipse.uml2.uml.edit;visibility:=reexport, >+ org.eclipse.emf.ecore;visibility:=reexport, >+ org.eclipse.emf.ecore.edit;visibility:=reexport, >+ org.eclipse.emf.query.ocl;visibility:=reexport, >+ org.eclipse.emf.ocl;visibility:=reexport >+Export-Package: org.eclipse.uml2.diagram.parser, >+ org.eclipse.uml2.diagram.parser.lookup >+Eclipse-LazyStart: true >+ >Index: src/org/eclipse/uml2/internal/diagram/parser/MDTDiagramParserPlugin.java >=================================================================== >RCS file: src/org/eclipse/uml2/internal/diagram/parser/MDTDiagramParserPlugin.java >diff -N src/org/eclipse/uml2/internal/diagram/parser/MDTDiagramParserPlugin.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/uml2/internal/diagram/parser/MDTDiagramParserPlugin.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,40 @@ >+/* >+ * Copyright (c) 2006 Borland Software Corporation >+ * >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Michael Golubev (Borland) - initial API and implementation >+ */ >+ >+package org.eclipse.uml2.internal.diagram.parser; >+ >+import org.eclipse.core.runtime.Plugin; >+import org.osgi.framework.Bundle; >+import org.osgi.framework.BundleContext; >+ >+public class MDTDiagramParserPlugin extends Plugin { >+ private static MDTDiagramParserPlugin anInstance; >+ >+ public void start(BundleContext context) throws Exception { >+ super.start(context); >+ anInstance = this; >+ } >+ >+ public void stop(BundleContext context) throws Exception { >+ anInstance = null; >+ super.stop(context); >+ } >+ >+ public static String getPluginID() { >+ return getDefault().getSymbolicName(); >+ } >+ >+ public static Bundle getDefault() { >+ return anInstance.getBundle(); >+ } >+ >+} >Index: src/org/eclipse/uml2/diagram/parser/lookup/LookupSuite.java >=================================================================== >RCS file: src/org/eclipse/uml2/diagram/parser/lookup/LookupSuite.java >diff -N src/org/eclipse/uml2/diagram/parser/lookup/LookupSuite.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/uml2/diagram/parser/lookup/LookupSuite.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,39 @@ >+/* >+ * Copyright (c) 2006 Borland Software Corporation >+ * >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Michael Golubev (Borland) - initial API and implementation >+ */ >+ >+package org.eclipse.uml2.diagram.parser.lookup; >+ >+import java.util.Collections; >+import java.util.List; >+ >+import org.eclipse.emf.ecore.EObject; >+ >+public interface LookupSuite { >+ public <T> Lookup<T> getLookup(Class<T> clazz); >+ >+ public static final Lookup NULL_LOOKUP = new Lookup(){ >+ public Object lookup(String name, EObject context){ >+ return null; >+ } >+ >+ public List getResolutionElementTypes() { >+ return Collections.emptyList(); >+ } >+ }; >+ >+ public static final LookupSuite NULL_SUITE = new LookupSuite(){ >+ public <T> Lookup<T> getLookup(Class<T> clazz) { >+ return NULL_LOOKUP; >+ } >+ }; >+ >+} >Index: plugin.xml >=================================================================== >RCS file: plugin.xml >diff -N plugin.xml >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ plugin.xml 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,5 @@ >+<?xml version="1.0" encoding="UTF-8"?> >+<?eclipse version="3.0"?> >+ >+<plugin> >+</plugin> >Index: src/org/eclipse/uml2/diagram/parser/ExternalParserException.java >=================================================================== >RCS file: src/org/eclipse/uml2/diagram/parser/ExternalParserException.java >diff -N src/org/eclipse/uml2/diagram/parser/ExternalParserException.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/uml2/diagram/parser/ExternalParserException.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,25 @@ >+/* >+ * Copyright (c) 2006 Borland Software Corporation >+ * >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Michael Golubev (Borland) - initial API and implementation >+ */ >+ >+package org.eclipse.uml2.diagram.parser; >+ >+public class ExternalParserException extends Exception { >+ >+ public ExternalParserException() { >+ super(); >+ } >+ >+ public ExternalParserException(String message) { >+ super(message); >+ } >+ >+} >Index: src/org/eclipse/uml2/diagram/parser/ExternalParserBase.java >=================================================================== >RCS file: src/org/eclipse/uml2/diagram/parser/ExternalParserBase.java >diff -N src/org/eclipse/uml2/diagram/parser/ExternalParserBase.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/uml2/diagram/parser/ExternalParserBase.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,109 @@ >+/* >+ * Copyright (c) 2006 Borland Software Corporation >+ * >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Michael Golubev (Borland) - initial API and implementation >+ */ >+package org.eclipse.uml2.diagram.parser; >+ >+import java.util.List; >+ >+import org.eclipse.emf.ecore.EClass; >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.gmf.runtime.emf.type.core.IElementType; >+import org.eclipse.uml2.diagram.parser.lookup.Lookup; >+import org.eclipse.uml2.diagram.parser.lookup.LookupResolveRequest; >+import org.eclipse.uml2.diagram.parser.lookup.LookupResolver; >+import org.eclipse.uml2.diagram.parser.lookup.LookupSuite; >+import org.eclipse.uml2.uml.NamedElement; >+import org.eclipse.uml2.uml.UMLPackage; >+ >+public abstract class ExternalParserBase { >+ private LookupSuite myLookups = LookupSuite.NULL_SUITE; >+ private LookupResolver myLookupResolver = LookupResolver.NULL; >+ >+ private EObject myContext; >+ >+ public abstract EClass getSubjectClass(); >+ >+ public abstract void parse(EObject target, String text) throws ExternalParserException; >+ >+ public final EObject parseNewObject(EObject context, String text) throws ExternalParserException { >+ myContext = context; >+ try { >+ EObject result = createSubjectPrototype(); >+ parse(result, text); >+ return result; >+ } finally { >+ myContext = null; >+ } >+ } >+ >+ public final void parse(EObject target, String text, EObject context) throws ExternalParserException { >+ myContext = context; >+ try { >+ parse(target, text); >+ } finally { >+ myContext = null; >+ } >+ } >+ >+ public final void setLookupSuite(LookupSuite suite){ >+ myLookups = suite; >+ if (myLookups == null){ >+ myLookups = LookupSuite.NULL_SUITE; >+ } >+ } >+ >+ public final void setLookupResolver(LookupResolver lookupResolver){ >+ myLookupResolver = lookupResolver; >+ if (myLookupResolver == null){ >+ myLookupResolver = LookupResolver.NULL; >+ } >+ } >+ >+ public final LookupSuite getLookupSuite(){ >+ return myLookups; >+ } >+ >+ public final <T> T lookup(Class<T> clazz, String name){ >+ Lookup<T> lookup = getLookupSuite().getLookup(clazz); >+ return lookup.lookup(name, getContext()); >+ } >+ >+ public EObject createSubjectPrototype(){ >+ EClass subjectClass = getSubjectClass(); >+ return subjectClass.getEPackage().getEFactoryInstance().create(subjectClass); >+ } >+ >+ protected final EObject getContext(){ >+ return myContext; >+ } >+ >+ protected final void checkContext(){ >+ if (getContext() == null){ >+ throw new IllegalStateException("I need context element to perform lookups"); >+ } >+ } >+ >+ protected <T extends NamedElement> void applyLookup(Class<T> clazz, String name, LookupResolver.Callback callback){ >+ Lookup<T> lookup = getLookupSuite().getLookup(clazz); >+ T result = lookup.lookup(name, getContext()); >+ if (result != null){ >+ callback.lookupResolved(result); >+ return; >+ } >+ List<IElementType> allowedTypes = lookup.getResolutionElementTypes(); >+ if (allowedTypes.isEmpty()){ >+ return; >+ } >+ LookupResolveRequest request = new LookupResolveRequest(allowedTypes, UMLPackage.eINSTANCE.getNamedElement_Name(), name); >+ myLookupResolver.addLookupResolveRequest(request, callback); >+ } >+ >+} >Index: src/org/eclipse/uml2/diagram/parser/SemanticLabelDirectEditPolicy.java >=================================================================== >RCS file: src/org/eclipse/uml2/diagram/parser/SemanticLabelDirectEditPolicy.java >diff -N src/org/eclipse/uml2/diagram/parser/SemanticLabelDirectEditPolicy.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/uml2/diagram/parser/SemanticLabelDirectEditPolicy.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,36 @@ >+/* >+ * Copyright (c) 2006 Borland Software Corporation >+ * >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Michael Golubev (Borland) - initial API and implementation >+ */ >+ >+package org.eclipse.uml2.diagram.parser; >+ >+import org.eclipse.gef.commands.Command; >+import org.eclipse.gef.requests.DirectEditRequest; >+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy; >+ >+public class SemanticLabelDirectEditPolicy extends LabelDirectEditPolicy { >+ @Override >+ protected Command getDirectEditCommand(DirectEditRequest edit) { >+ Command applyChanges = super.getDirectEditCommand(edit); >+ Command postRefresh = null; >+ if (applyChanges != null && applyChanges.canExecute()){ >+ postRefresh = new PostRefreshCommand(); >+ } >+ return applyChanges.chain(postRefresh); >+ } >+ >+ private class PostRefreshCommand extends Command { >+ @Override >+ public void execute() { >+ getHost().refresh(); >+ } >+ } >+} >Index: src/org/eclipse/uml2/diagram/parser/lookup/LookupResolver.java >=================================================================== >RCS file: src/org/eclipse/uml2/diagram/parser/lookup/LookupResolver.java >diff -N src/org/eclipse/uml2/diagram/parser/lookup/LookupResolver.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/uml2/diagram/parser/lookup/LookupResolver.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,52 @@ >+/* >+ * Copyright (c) 2006 Borland Software Corporation >+ * >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Michael Golubev (Borland) - initial API and implementation >+ */ >+ >+package org.eclipse.uml2.diagram.parser.lookup; >+ >+import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; >+import org.eclipse.uml2.uml.NamedElement; >+ >+public interface LookupResolver { >+ >+ public abstract void addLookupResolveRequest(LookupResolveRequest request, Callback callback); >+ >+ public abstract boolean isEmpty(); >+ >+ public abstract boolean canResolve(); >+ >+ public abstract AbstractTransactionalCommand getResolveCommand(); >+ >+ public static interface Callback { >+ public void lookupResolved(NamedElement resolution); >+ } >+ >+ public static final LookupResolver NULL = new LookupResolver() { >+ >+ public boolean isEmpty() { >+ return true; >+ } >+ >+ public AbstractTransactionalCommand getResolveCommand() { >+ return null; >+ } >+ >+ public boolean canResolve() { >+ return false; >+ } >+ >+ public void addLookupResolveRequest(LookupResolveRequest request, Callback callback) { >+ // >+ } >+ >+ }; >+ >+} >Index: .project >=================================================================== >RCS file: .project >diff -N .project >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ .project 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,28 @@ >+<?xml version="1.0" encoding="UTF-8"?> >+<projectDescription> >+ <name>org.eclipse.uml2.diagram.parser</name> >+ <comment></comment> >+ <projects> >+ </projects> >+ <buildSpec> >+ <buildCommand> >+ <name>org.eclipse.jdt.core.javabuilder</name> >+ <arguments> >+ </arguments> >+ </buildCommand> >+ <buildCommand> >+ <name>org.eclipse.pde.ManifestBuilder</name> >+ <arguments> >+ </arguments> >+ </buildCommand> >+ <buildCommand> >+ <name>org.eclipse.pde.SchemaBuilder</name> >+ <arguments> >+ </arguments> >+ </buildCommand> >+ </buildSpec> >+ <natures> >+ <nature>org.eclipse.pde.PluginNature</nature> >+ <nature>org.eclipse.jdt.core.javanature</nature> >+ </natures> >+</projectDescription> >Index: src/org/eclipse/uml2/diagram/parser/AbstractToString.java >=================================================================== >RCS file: src/org/eclipse/uml2/diagram/parser/AbstractToString.java >diff -N src/org/eclipse/uml2/diagram/parser/AbstractToString.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/uml2/diagram/parser/AbstractToString.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,126 @@ >+/* >+ * Copyright (c) 2006 Borland Software Corporation >+ * >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Michael Golubev (Borland) - initial API and implementation >+ */ >+ >+package org.eclipse.uml2.diagram.parser; >+ >+import org.eclipse.uml2.uml.LiteralUnlimitedNatural; >+import org.eclipse.uml2.uml.MultiplicityElement; >+import org.eclipse.uml2.uml.NamedElement; >+import org.eclipse.uml2.uml.Type; >+import org.eclipse.uml2.uml.TypedElement; >+import org.eclipse.uml2.uml.VisibilityKind; >+ >+public abstract class AbstractToString implements ExternalToString { >+ protected String getVisibility(NamedElement namedElement) { >+ VisibilityKind visibility = namedElement.getVisibility(); >+ switch (visibility.getValue()){ >+ case VisibilityKind.PACKAGE : >+ return "~"; >+ case VisibilityKind.PRIVATE : >+ return "-"; >+ case VisibilityKind.PROTECTED : >+ return "#"; >+ case VisibilityKind.PUBLIC : >+ return ""; //omitted >+ } >+ throw new IllegalArgumentException("Unknown visibility for :" + namedElement + ", that is: " + visibility); >+ } >+ >+ protected void appendName(StringBuffer result, NamedElement namedElement){ >+ if (namedElement == null){ >+ return; >+ } >+ String name = namedElement.getName(); >+ if (!isEmpty(name)){ >+ result.append(name); >+ } >+ } >+ >+ protected void appendType(StringBuffer result, TypedElement typedElement) { >+ if (typedElement == null){ >+ return; >+ } >+ Type type = typedElement.getType(); >+ if (type == null){ >+ return; >+ } >+ appendType(result, type.getName()); >+ } >+ >+ protected static void appendType(StringBuffer result, String typeName) { >+ if (isEmpty(typeName)){ >+ return; >+ } >+ result.append(" : "); >+ result.append(typeName); >+ } >+ >+ protected static boolean isEmpty(String text){ >+ return text == null || text.trim().length() == 0; >+ } >+ >+ protected void appendMultiplicity(StringBuffer result, MultiplicityElement element) { >+ if (element == null){ >+ return; >+ } >+ int lower = element.getLower(); >+ int upper = element.getUpper(); >+ if (upper == 1 && lower == 1){ >+ return; >+ } >+ result.append(" ["); >+ if (lower != upper){ >+ result.append(lower); >+ result.append('.').append('.'); >+ } >+ if (upper == LiteralUnlimitedNatural.UNLIMITED){ >+ result.append('*'); >+ } else { >+ result.append(upper); >+ } >+ result.append(']'); >+ } >+ >+ protected static class ModifiersBuilder { >+ private final StringBuffer myBuffer; >+ >+ public ModifiersBuilder(){ >+ myBuffer = new StringBuffer(); >+ } >+ >+ public void appendModifier(String modifier){ >+ if (modifier.length() == 0){ >+ return; >+ } >+ if (myBuffer.length() != 0){ >+ myBuffer.append(", "); >+ } >+ myBuffer.append(modifier); >+ } >+ >+ public void writeInto(StringBuffer output){ >+ if (myBuffer.length() == 0){ >+ return; >+ } >+ output.append(" "); >+ output.append("{ "); >+ output.append(myBuffer); >+ output.append(" }"); >+ } >+ >+ public String toString() { >+ return super.toString(); >+ } >+ >+ } >+ >+} >Index: src/org/eclipse/uml2/diagram/parser/ExternalToString.java >=================================================================== >RCS file: src/org/eclipse/uml2/diagram/parser/ExternalToString.java >diff -N src/org/eclipse/uml2/diagram/parser/ExternalToString.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/uml2/diagram/parser/ExternalToString.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,39 @@ >+/* >+ * Copyright (c) 2006 Borland Software Corporation >+ * >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Michael Golubev (Borland) - initial API and implementation >+ */ >+ >+package org.eclipse.uml2.diagram.parser; >+ >+import java.util.List; >+ >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.emf.ecore.EStructuralFeature; >+ >+public interface ExternalToString { >+ public String getToString(EObject object, int flags); >+ >+ public boolean isAffectingFeature(EStructuralFeature feature); >+ >+ public static final ExternalToString NOT_IMPLEMENTED = new ExternalToString(){ >+ >+ public String getToString(EObject object, int flags) { >+ return "-NOT-IMPLEMENTED-"; >+ } >+ >+ public boolean isAffectingFeature(EStructuralFeature feature) { >+ return false; >+ } >+ }; >+ >+ public static interface WithReferences extends ExternalToString { >+ public List getAdditionalReferencedElements(EObject object); >+ } >+} >Index: src/org/eclipse/uml2/diagram/parser/lookup/Lookup.java >=================================================================== >RCS file: src/org/eclipse/uml2/diagram/parser/lookup/Lookup.java >diff -N src/org/eclipse/uml2/diagram/parser/lookup/Lookup.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/uml2/diagram/parser/lookup/Lookup.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,23 @@ >+/* >+ * Copyright (c) 2006 Borland Software Corporation >+ * >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Michael Golubev (Borland) - initial API and implementation >+ */ >+ >+package org.eclipse.uml2.diagram.parser.lookup; >+ >+import java.util.List; >+ >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.gmf.runtime.emf.type.core.IElementType; >+ >+public interface Lookup<T> { >+ public T lookup(String name, EObject context); >+ public List<IElementType> getResolutionElementTypes(); >+} >Index: src/org/eclipse/uml2/diagram/parser/BasicApplyStrategy.java >=================================================================== >RCS file: src/org/eclipse/uml2/diagram/parser/BasicApplyStrategy.java >diff -N src/org/eclipse/uml2/diagram/parser/BasicApplyStrategy.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/uml2/diagram/parser/BasicApplyStrategy.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,79 @@ >+/* >+ * Copyright (c) 2006 Borland Software Corporation >+ * >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Michael Golubev (Borland) - initial API and implementation >+ */ >+ >+package org.eclipse.uml2.diagram.parser; >+ >+import java.util.Iterator; >+import java.util.LinkedList; >+import java.util.List; >+ >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.emf.ecore.EReference; >+import org.eclipse.emf.ecore.EStructuralFeature; >+import org.eclipse.gmf.runtime.emf.type.core.commands.DestroyReferenceCommand; >+import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand; >+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest; >+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest; >+ >+public class BasicApplyStrategy implements ApplyStrategy { >+ public List/*1.5 <ICommand>*/ apply(EObject modelObject, EObject parsedObject) { >+ List result = new LinkedList(); >+ for (Iterator it = parsedObject.eClass().getEAllStructuralFeatures().iterator(); it.hasNext();){ >+ EStructuralFeature next = (EStructuralFeature) it.next(); >+ if (parsedObject.eIsSet(next) && !next.isDerived()){ >+ transferValue(result, modelObject, parsedObject, next); >+ } >+ } >+ return result.isEmpty() ? NOT_EXECUTABLE : result; >+ } >+ >+ protected final void transferValue(List output, EObject model, EObject parsed, EStructuralFeature feature){ >+ if (feature.isDerived() || !parsed.eIsSet(feature)){ >+ return; >+ } >+ Object parsedValue = parsed.eGet(feature); >+ Object actualValue = model.eGet(feature); >+ if (safeEquals(parsedValue, actualValue)){ >+ return; >+ } >+ //XXX: workaround for : #152080 >+ //XXX: can not set multi-valued properties using SetValueCommand, >+ //XXX: see https://bugs.eclipse.org/bugs/show_bug.cgi?id=152080 >+ if (feature instanceof EReference && feature.isMany()){ >+ transferValuesList(output, model, parsed, (EReference)feature); >+ return; >+ } >+ SetRequest request = new SetRequest(model, feature, parsedValue); >+ output.add(new SetValueCommand(request)); >+ } >+ >+ private void transferValuesList(List output, EObject model, EObject parsed, EReference isManyReference){ >+ assert isManyReference.isMany(); >+ List<EObject> actualValues = (List<EObject>) model.eGet(isManyReference); >+ List<EObject> parsedValues = (List<EObject>) parsed.eGet(isManyReference); >+ >+ for (EObject nextActual : actualValues){ >+ DestroyReferenceRequest nextRequest = new DestroyReferenceRequest(model, isManyReference, nextActual, false); >+ output.add(new DestroyReferenceCommand(nextRequest)); >+ } >+ >+ for (EObject nextParsed : parsedValues){ >+ SetRequest nextRequest = new SetRequest(model, isManyReference, nextParsed); >+ output.add(new SetValueCommand(nextRequest)); >+ } >+ } >+ >+ protected static <T> boolean safeEquals(T o1, T o2){ >+ return o1 == null ? o2 == null : o1.equals(o2); >+ } >+ >+} >Index: .cvsignore >=================================================================== >RCS file: .cvsignore >diff -N .cvsignore >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ .cvsignore 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,1 @@ >+bin >Index: src/org/eclipse/uml2/diagram/parser/lookup/OCLLookup.java >=================================================================== >RCS file: src/org/eclipse/uml2/diagram/parser/lookup/OCLLookup.java >diff -N src/org/eclipse/uml2/diagram/parser/lookup/OCLLookup.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/uml2/diagram/parser/lookup/OCLLookup.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,65 @@ >+/* >+ * Copyright (c) 2006 Borland Software Corporation >+ * >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Michael Golubev (Borland) - initial API and implementation >+ */ >+ >+package org.eclipse.uml2.diagram.parser.lookup; >+ >+import java.util.ArrayList; >+import java.util.Arrays; >+import java.util.Collection; >+import java.util.Collections; >+import java.util.LinkedList; >+import java.util.List; >+ >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.gmf.runtime.emf.type.core.IElementType; >+import org.eclipse.uml2.uml.NamedElement; >+ >+public class OCLLookup<T extends NamedElement> implements Lookup<T> { >+ public static interface Expression { >+ public Object evaluate(Object context); >+ } >+ >+ private Expression mySelector; >+ private final ArrayList<IElementType> myResolutionTypes; >+ private static final IElementType[] NO_RESOLUTIONS = new IElementType[0]; >+ >+ public OCLLookup(Expression ocl, IElementType[] resolutions){ >+ mySelector = ocl; >+ if (resolutions == null){ >+ resolutions = NO_RESOLUTIONS; >+ } >+ myResolutionTypes = new ArrayList<IElementType>(Arrays.asList(resolutions)); >+ } >+ >+ public List getResolutionElementTypes() { >+ return new ArrayList<IElementType>(myResolutionTypes); >+ } >+ >+ public List<T> computeScope(EObject context){ >+ Object result = mySelector.evaluate(context); >+ if (result instanceof Collection){ >+ return new LinkedList<T>((Collection<T>)result); >+ } >+ return Collections.emptyList(); >+ } >+ >+ public T lookup(String name, EObject context) { >+ List<T> scope = computeScope(context); >+ for (T next : scope){ >+ if (name.equals(next.getName()) || name.equals(next.getQualifiedName())){ >+ return next; >+ } >+ } >+ return null; >+ } >+ >+} >Index: src/org/eclipse/uml2/diagram/parser/SemanticParserAdapter.java >=================================================================== >RCS file: src/org/eclipse/uml2/diagram/parser/SemanticParserAdapter.java >diff -N src/org/eclipse/uml2/diagram/parser/SemanticParserAdapter.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/uml2/diagram/parser/SemanticParserAdapter.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,45 @@ >+/* >+ * Copyright (c) 2006 Borland Software Corporation >+ * >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Michael Golubev (Borland) - initial API and implementation >+ */ >+ >+package org.eclipse.uml2.diagram.parser; >+ >+import java.util.Collections; >+import java.util.List; >+ >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser; >+ >+public class SemanticParserAdapter extends ParserAdapter implements ISemanticParser { >+ >+ public SemanticParserAdapter(ExternalParserBase delegate, ApplyStrategy applier, ExternalToString.WithReferences view, ExternalToString edit) { >+ super(delegate, applier, view, edit); >+ } >+ >+ public SemanticParserAdapter(ExternalParserBase delegate, ApplyStrategy applier, ExternalToString.WithReferences viewAndEdit) { >+ this(delegate, applier, viewAndEdit, viewAndEdit); >+ } >+ >+ public boolean areSemanticElementsAffected(EObject listener, Object notification) { >+ return isAffectingEvent(notification); >+ } >+ >+ public List getSemanticElementsBeingParsed(EObject element) { >+ return isValidElement(element) ? >+ getViewToStringImpl().getAdditionalReferencedElements(element) : >+ Collections.EMPTY_LIST; >+ } >+ >+ private ExternalToString.WithReferences getViewToStringImpl(){ >+ return (ExternalToString.WithReferences)getViewToString(); >+ } >+ >+} >#P org.eclipse.uml2.diagram.common >Index: build.properties >=================================================================== >RCS file: build.properties >diff -N build.properties >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ build.properties 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,4 @@ >+source.. = src/ >+output.. = bin/ >+bin.includes = META-INF/,\ >+ . >Index: src/org/eclipse/uml2/diagram/common/draw2d/PolylineContainer.java >=================================================================== >RCS file: src/org/eclipse/uml2/diagram/common/draw2d/PolylineContainer.java >diff -N src/org/eclipse/uml2/diagram/common/draw2d/PolylineContainer.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/uml2/diagram/common/draw2d/PolylineContainer.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,28 @@ >+/* >+ * Copyright (c) 2006 Borland Software Corporation >+ * >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Michael Golubev (Borland) - initial API and implementation >+ */ >+ >+package org.eclipse.uml2.diagram.common.draw2d; >+ >+import org.eclipse.draw2d.RectangleFigure; >+ >+public class PolylineContainer extends RectangleFigure { >+ public PolylineContainer(){ >+ super(); >+ setOutline(false); >+ setFill(false); >+ } >+ >+ protected boolean useLocalCoordinates() { >+ return true; >+ } >+ >+} >Index: src/org/eclipse/uml2/diagram/common/draw2d/AssociationDecoration.java >=================================================================== >RCS file: src/org/eclipse/uml2/diagram/common/draw2d/AssociationDecoration.java >diff -N src/org/eclipse/uml2/diagram/common/draw2d/AssociationDecoration.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/uml2/diagram/common/draw2d/AssociationDecoration.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,71 @@ >+/* >+ * Copyright (c) 2006 Borland Software Corporation >+ * >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Michael Golubev (Borland) - initial API and implementation >+ */ >+ >+package org.eclipse.uml2.diagram.common.draw2d; >+ >+import org.eclipse.draw2d.ColorConstants; >+import org.eclipse.draw2d.Graphics; >+import org.eclipse.draw2d.PolygonDecoration; >+import org.eclipse.draw2d.geometry.PointList; >+import org.eclipse.swt.graphics.Color; >+import org.eclipse.uml2.uml.AggregationKind; >+import org.eclipse.uml2.uml.Association; >+import org.eclipse.uml2.uml.Property; >+ >+public class AssociationDecoration extends PolygonDecoration { >+ private static final PointList RHOMB = new PointList(new int[] { // >+ // >+ -1, 1, // >+ 0, 0, // >+ -1, -1, // >+ -2, 0, // >+ -1, 1, // >+ }); >+ >+ /** >+ * XXX: navigability arrows and owner-dot decorations are not implemented yet >+ */ >+ private static final PointList ARROW = new PointList(new int[] { // >+ // >+ -1, 1, // >+ 0, 0, // >+ -1, -1, // >+ 0, 0, // >+ -1, 1, // >+ }); >+ >+ public AssociationDecoration() { >+ setTemplate(RHOMB.getCopy()); >+ setScale(7, 3); >+ setVisible(false); >+ setFill(true); >+ } >+ >+ public void update(AggregationKind kind) { >+ if (kind == AggregationKind.COMPOSITE_LITERAL) { >+ setVisible(true); >+ if (getParent() != null && getParent().getForegroundColor() != null){ >+ setBackgroundColor(getParent().getForegroundColor()); >+ } >+ } else if (kind == AggregationKind.SHARED_LITERAL) { >+ setVisible(true); >+ setBackgroundColor(ColorConstants.white); >+ } else { >+ setVisible(false); >+ } >+ } >+ >+ public void update(Association association, Property associationEnd) { >+ update(associationEnd.getAggregation()); >+ } >+ >+} >Index: src/org/eclipse/uml2/diagram/common/parser/port/TokenMgrError.java >=================================================================== >RCS file: src/org/eclipse/uml2/diagram/common/parser/port/TokenMgrError.java >diff -N src/org/eclipse/uml2/diagram/common/parser/port/TokenMgrError.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/uml2/diagram/common/parser/port/TokenMgrError.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,144 @@ >+/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 3.0 */ >+/* >+ * Copyright (c) 2006 Borland Software Corporation >+ * >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Michael Golubev (Borland) - initial API and implementation >+ */ >+package org.eclipse.uml2.diagram.common.parser.port; >+ >+public class TokenMgrError extends Error >+{ >+ /* >+ * Ordinals for various reasons why an Error of this type can be thrown. >+ */ >+ >+ /** >+ * Lexical error occured. >+ */ >+ static final int LEXICAL_ERROR = 0; >+ >+ /** >+ * An attempt wass made to create a second instance of a static token manager. >+ */ >+ static final int STATIC_LEXER_ERROR = 1; >+ >+ /** >+ * Tried to change to an invalid lexical state. >+ */ >+ static final int INVALID_LEXICAL_STATE = 2; >+ >+ /** >+ * Detected (and bailed out of) an infinite loop in the token manager. >+ */ >+ static final int LOOP_DETECTED = 3; >+ >+ /** >+ * Indicates the reason why the exception is thrown. It will have >+ * one of the above 4 values. >+ */ >+ int errorCode; >+ >+ /** >+ * Replaces unprintable characters by their espaced (or unicode escaped) >+ * equivalents in the given string >+ */ >+ protected static final String addEscapes(String str) { >+ StringBuffer retval = new StringBuffer(); >+ char ch; >+ for (int i = 0; i < str.length(); i++) { >+ switch (str.charAt(i)) >+ { >+ case 0 : >+ continue; >+ case '\b': >+ retval.append("\\b"); >+ continue; >+ case '\t': >+ retval.append("\\t"); >+ continue; >+ case '\n': >+ retval.append("\\n"); >+ continue; >+ case '\f': >+ retval.append("\\f"); >+ continue; >+ case '\r': >+ retval.append("\\r"); >+ continue; >+ case '\"': >+ retval.append("\\\""); >+ continue; >+ case '\'': >+ retval.append("\\\'"); >+ continue; >+ case '\\': >+ retval.append("\\\\"); >+ continue; >+ default: >+ if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { >+ String s = "0000" + Integer.toString(ch, 16); >+ retval.append("\\u" + s.substring(s.length() - 4, s.length())); >+ } else { >+ retval.append(ch); >+ } >+ continue; >+ } >+ } >+ return retval.toString(); >+ } >+ >+ /** >+ * Returns a detailed message for the Error when it is thrown by the >+ * token manager to indicate a lexical error. >+ * Parameters : >+ * EOFSeen : indicates if EOF caused the lexicl error >+ * curLexState : lexical state in which this error occured >+ * errorLine : line number when the error occured >+ * errorColumn : column number when the error occured >+ * errorAfter : prefix that was seen before this error occured >+ * curchar : the offending character >+ * Note: You can customize the lexical error message by modifying this method. >+ */ >+ protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) { >+ return("Lexical error at line " + >+ errorLine + ", column " + >+ errorColumn + ". Encountered: " + >+ (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") + >+ "after : \"" + addEscapes(errorAfter) + "\""); >+ } >+ >+ /** >+ * You can also modify the body of this method to customize your error messages. >+ * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not >+ * of end-users concern, so you can return something like : >+ * >+ * "Internal Error : Please file a bug report .... " >+ * >+ * from this method for such cases in the release version of your parser. >+ */ >+ public String getMessage() { >+ return super.getMessage(); >+ } >+ >+ /* >+ * Constructors of various flavors follow. >+ */ >+ >+ public TokenMgrError() { >+ } >+ >+ public TokenMgrError(String message, int reason) { >+ super(message); >+ errorCode = reason; >+ } >+ >+ public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) { >+ this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); >+ } >+} >Index: src/org/eclipse/uml2/diagram/common/parser/port/PortToString.java >=================================================================== >RCS file: src/org/eclipse/uml2/diagram/common/parser/port/PortToString.java >diff -N src/org/eclipse/uml2/diagram/common/parser/port/PortToString.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/uml2/diagram/common/parser/port/PortToString.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,77 @@ >+/* >+ * Copyright (c) 2006 Borland Software Corporation >+ * >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Michael Golubev (Borland) - initial API and implementation >+ */ >+ >+package org.eclipse.uml2.diagram.common.parser.port; >+ >+import java.util.Arrays; >+import java.util.LinkedList; >+import java.util.List; >+ >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.emf.ecore.EStructuralFeature; >+import org.eclipse.uml2.diagram.parser.AbstractToString; >+import org.eclipse.uml2.diagram.parser.ExternalToString.WithReferences; >+import org.eclipse.uml2.uml.Port; >+import org.eclipse.uml2.uml.UMLPackage; >+import org.eclipse.uml2.uml.ValueSpecification; >+ >+public class PortToString extends AbstractToString implements WithReferences { >+ public String getToString(EObject object, int flags) { >+ Port port = asPort(object); >+ StringBuffer result = new StringBuffer(); >+ appendName(result, port); >+ appendType(result, port); >+ appendMultiplicity(result, port); >+ return result.toString(); >+ } >+ >+ private static final List AFFECTING = Arrays.asList(new EStructuralFeature[] { >+ UMLPackage.eINSTANCE.getNamedElement_Visibility(), >+ UMLPackage.eINSTANCE.getNamedElement_Name(), >+ UMLPackage.eINSTANCE.getTypedElement_Type(), >+ UMLPackage.eINSTANCE.getMultiplicityElement_UpperValue(), >+ UMLPackage.eINSTANCE.getMultiplicityElement_LowerValue(), >+ UMLPackage.eINSTANCE.getLiteralUnlimitedNatural_Value(), >+ UMLPackage.eINSTANCE.getLiteralInteger_Value(), >+ UMLPackage.eINSTANCE.getLiteralString_Value(), >+ }); >+ >+ public boolean isAffectingFeature(EStructuralFeature feature) { >+ return AFFECTING.contains(feature); >+ } >+ >+ public List getAdditionalReferencedElements(EObject object) { >+ Port port = asPort(object); >+ List result = new LinkedList(); >+ result.add(port); >+ ValueSpecification upper = port.getUpperValue(); >+ if (upper != null){ >+ result.add(upper); >+ } >+ ValueSpecification lower = port.getLowerValue(); >+ if (lower != null){ >+ result.add(lower); >+ } >+ if (port.getType() != null){ >+ result.add(port.getType()); >+ } >+ return result; >+ } >+ >+ protected Port asPort(EObject object){ >+ if (false == object instanceof Port){ >+ throw new IllegalStateException("I can not provide toString for: " + object); >+ } >+ return (Port)object; >+ } >+ >+} >Index: src/org/eclipse/uml2/diagram/common/parser/port/ParseException.java >=================================================================== >RCS file: src/org/eclipse/uml2/diagram/common/parser/port/ParseException.java >diff -N src/org/eclipse/uml2/diagram/common/parser/port/ParseException.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/uml2/diagram/common/parser/port/ParseException.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,205 @@ >+/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 3.0 */ >+/* >+ * Copyright (c) 2006 Borland Software Corporation >+ * >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Michael Golubev (Borland) - initial API and implementation >+ */ >+package org.eclipse.uml2.diagram.common.parser.port; >+ >+import org.eclipse.uml2.diagram.parser.ExternalParserException; >+ >+/** >+ * This exception is thrown when parse errors are encountered. >+ * You can explicitly create objects of this exception type by >+ * calling the method generateParseException in the generated >+ * parser. >+ * >+ * You can modify this class to customize your error reporting >+ * mechanisms so long as you retain the public fields. >+ */ >+public class ParseException extends ExternalParserException { >+ >+ /** >+ * This constructor is used by the method "generateParseException" >+ * in the generated parser. Calling this constructor generates >+ * a new object of this type with the fields "currentToken", >+ * "expectedTokenSequences", and "tokenImage" set. The boolean >+ * flag "specialConstructor" is also set to true to indicate that >+ * this constructor was used to create this object. >+ * This constructor calls its super class with the empty string >+ * to force the "toString" method of parent class "Throwable" to >+ * print the error message in the form: >+ * ParseException: <result of getMessage> >+ */ >+ public ParseException(Token currentTokenVal, >+ int[][] expectedTokenSequencesVal, >+ String[] tokenImageVal >+ ) >+ { >+ super(""); >+ specialConstructor = true; >+ currentToken = currentTokenVal; >+ expectedTokenSequences = expectedTokenSequencesVal; >+ tokenImage = tokenImageVal; >+ } >+ >+ /** >+ * The following constructors are for use by you for whatever >+ * purpose you can think of. Constructing the exception in this >+ * manner makes the exception behave in the normal way - i.e., as >+ * documented in the class "Throwable". The fields "errorToken", >+ * "expectedTokenSequences", and "tokenImage" do not contain >+ * relevant information. The JavaCC generated code does not use >+ * these constructors. >+ */ >+ >+ public ParseException() { >+ super(); >+ specialConstructor = false; >+ } >+ >+ public ParseException(String message) { >+ super(message); >+ specialConstructor = false; >+ } >+ >+ /** >+ * This variable determines which constructor was used to create >+ * this object and thereby affects the semantics of the >+ * "getMessage" method (see below). >+ */ >+ protected boolean specialConstructor; >+ >+ /** >+ * This is the last token that has been consumed successfully. If >+ * this object has been created due to a parse error, the token >+ * followng this token will (therefore) be the first error token. >+ */ >+ public Token currentToken; >+ >+ /** >+ * Each entry in this array is an array of integers. Each array >+ * of integers represents a sequence of tokens (by their ordinal >+ * values) that is expected at this point of the parse. >+ */ >+ public int[][] expectedTokenSequences; >+ >+ /** >+ * This is a reference to the "tokenImage" array of the generated >+ * parser within which the parse error occurred. This array is >+ * defined in the generated ...Constants interface. >+ */ >+ public String[] tokenImage; >+ >+ /** >+ * This method has the standard behavior when this object has been >+ * created using the standard constructors. Otherwise, it uses >+ * "currentToken" and "expectedTokenSequences" to generate a parse >+ * error message and returns it. If this object has been created >+ * due to a parse error, and you do not catch it (it gets thrown >+ * from the parser), then this method is called during the printing >+ * of the final stack trace, and hence the correct error message >+ * gets displayed. >+ */ >+ public String getMessage() { >+ if (!specialConstructor) { >+ return super.getMessage(); >+ } >+ String expected = ""; >+ int maxSize = 0; >+ for (int i = 0; i < expectedTokenSequences.length; i++) { >+ if (maxSize < expectedTokenSequences[i].length) { >+ maxSize = expectedTokenSequences[i].length; >+ } >+ for (int j = 0; j < expectedTokenSequences[i].length; j++) { >+ expected += tokenImage[expectedTokenSequences[i][j]] + " "; >+ } >+ if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) { >+ expected += "..."; >+ } >+ expected += eol + " "; >+ } >+ String retval = "Encountered \""; >+ Token tok = currentToken.next; >+ for (int i = 0; i < maxSize; i++) { >+ if (i != 0) retval += " "; >+ if (tok.kind == 0) { >+ retval += tokenImage[0]; >+ break; >+ } >+ retval += add_escapes(tok.image); >+ tok = tok.next; >+ } >+ retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn; >+ retval += "." + eol; >+ if (expectedTokenSequences.length == 1) { >+ retval += "Was expecting:" + eol + " "; >+ } else { >+ retval += "Was expecting one of:" + eol + " "; >+ } >+ retval += expected; >+ return retval; >+ } >+ >+ /** >+ * The end of line string for this machine. >+ */ >+ protected String eol = System.getProperty("line.separator", "\n"); >+ >+ /** >+ * Used to convert raw characters to their escaped version >+ * when these raw version cannot be used as part of an ASCII >+ * string literal. >+ */ >+ protected String add_escapes(String str) { >+ StringBuffer retval = new StringBuffer(); >+ char ch; >+ for (int i = 0; i < str.length(); i++) { >+ switch (str.charAt(i)) >+ { >+ case 0 : >+ continue; >+ case '\b': >+ retval.append("\\b"); >+ continue; >+ case '\t': >+ retval.append("\\t"); >+ continue; >+ case '\n': >+ retval.append("\\n"); >+ continue; >+ case '\f': >+ retval.append("\\f"); >+ continue; >+ case '\r': >+ retval.append("\\r"); >+ continue; >+ case '\"': >+ retval.append("\\\""); >+ continue; >+ case '\'': >+ retval.append("\\\'"); >+ continue; >+ case '\\': >+ retval.append("\\\\"); >+ continue; >+ default: >+ if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { >+ String s = "0000" + Integer.toString(ch, 16); >+ retval.append("\\u" + s.substring(s.length() - 4, s.length())); >+ } else { >+ retval.append(ch); >+ } >+ continue; >+ } >+ } >+ return retval.toString(); >+ } >+ >+} >Index: src/org/eclipse/uml2/diagram/common/parser/port/Token.java >=================================================================== >RCS file: src/org/eclipse/uml2/diagram/common/parser/port/Token.java >diff -N src/org/eclipse/uml2/diagram/common/parser/port/Token.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/uml2/diagram/common/parser/port/Token.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,92 @@ >+/* Generated By:JavaCC: Do not edit this line. Token.java Version 3.0 */ >+/* >+ * Copyright (c) 2006 Borland Software Corporation >+ * >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Michael Golubev (Borland) - initial API and implementation >+ */ >+package org.eclipse.uml2.diagram.common.parser.port; >+ >+/** >+ * Describes the input token stream. >+ */ >+ >+public class Token { >+ >+ /** >+ * An integer that describes the kind of this token. This numbering >+ * system is determined by JavaCCParser, and a table of these numbers is >+ * stored in the file ...Constants.java. >+ */ >+ public int kind; >+ >+ /** >+ * beginLine and beginColumn describe the position of the first character >+ * of this token; endLine and endColumn describe the position of the >+ * last character of this token. >+ */ >+ public int beginLine, beginColumn, endLine, endColumn; >+ >+ /** >+ * The string image of the token. >+ */ >+ public String image; >+ >+ /** >+ * A reference to the next regular (non-special) token from the input >+ * stream. If this is the last token from the input stream, or if the >+ * token manager has not read tokens beyond this one, this field is >+ * set to null. This is true only if this token is also a regular >+ * token. Otherwise, see below for a description of the contents of >+ * this field. >+ */ >+ public Token next; >+ >+ /** >+ * This field is used to access special tokens that occur prior to this >+ * token, but after the immediately preceding regular (non-special) token. >+ * If there are no such special tokens, this field is set to null. >+ * When there are more than one such special token, this field refers >+ * to the last of these special tokens, which in turn refers to the next >+ * previous special token through its specialToken field, and so on >+ * until the first special token (whose specialToken field is null). >+ * The next fields of special tokens refer to other special tokens that >+ * immediately follow it (without an intervening regular token). If there >+ * is no such token, this field is null. >+ */ >+ public Token specialToken; >+ >+ /** >+ * Returns the image. >+ */ >+ public String toString() >+ { >+ return image; >+ } >+ >+ /** >+ * Returns a new Token object, by default. However, if you want, you >+ * can create and return subclass objects based on the value of ofKind. >+ * Simply add the cases to the switch for all those special cases. >+ * For example, if you have a subclass of Token called IDToken that >+ * you want to create if ofKind is ID, simlpy add something like : >+ * >+ * case MyParserConstants.ID : return new IDToken(); >+ * >+ * to the following switch statement. Then you can cast matchedToken >+ * variable to the appropriate type and use it in your lexical actions. >+ */ >+ public static final Token newToken(int ofKind) >+ { >+ switch(ofKind) >+ { >+ default : return new Token(); >+ } >+ } >+ >+} >Index: src/org/eclipse/uml2/diagram/common/draw2d/CenterLayout.java >=================================================================== >RCS file: src/org/eclipse/uml2/diagram/common/draw2d/CenterLayout.java >diff -N src/org/eclipse/uml2/diagram/common/draw2d/CenterLayout.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/uml2/diagram/common/draw2d/CenterLayout.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,41 @@ >+/* >+ * Copyright (c) 2006 Borland Software Corporation >+ * >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Michael Golubev (Borland) - initial API and implementation >+ */ >+ >+package org.eclipse.uml2.diagram.common.draw2d; >+ >+import java.util.List; >+ >+import org.eclipse.draw2d.IFigure; >+import org.eclipse.draw2d.StackLayout; >+import org.eclipse.draw2d.geometry.Dimension; >+import org.eclipse.draw2d.geometry.Rectangle; >+ >+public class CenterLayout extends StackLayout { >+ private static final Rectangle RECTANGLE = new Rectangle(); >+ >+ public void layout(IFigure figure) { >+ Rectangle r = figure.getClientArea(); >+ final int centerX = r.x + r.width / 2; >+ final int centerY = r.y + r.height / 2; >+ List children = figure.getChildren(); >+ IFigure child; >+ for (int i = 0; i < children.size(); i++) { >+ child = (IFigure)children.get(i); >+ Dimension prefSize = child.getPreferredSize(); >+ RECTANGLE.x = centerX - prefSize.width / 2; >+ RECTANGLE.y = centerY - prefSize.height / 2; >+ RECTANGLE.width = prefSize.width; >+ RECTANGLE.height = prefSize.height; >+ child.setBounds(RECTANGLE); >+ } >+ } >+} >Index: src/org/eclipse/uml2/diagram/common/parser/port/PortParserConstants.java >=================================================================== >RCS file: src/org/eclipse/uml2/diagram/common/parser/port/PortParserConstants.java >diff -N src/org/eclipse/uml2/diagram/common/parser/port/PortParserConstants.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/uml2/diagram/common/parser/port/PortParserConstants.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,79 @@ >+/* Generated By:JavaCC: Do not edit this line. PortParserConstants.java */ >+/* >+ * Copyright (c) 2006 Borland Software Corporation >+ * >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Michael Golubev (Borland) - initial API and implementation >+ */ >+package org.eclipse.uml2.diagram.common.parser.port; >+ >+public interface PortParserConstants { >+ >+ int EOF = 0; >+ int SLASH = 3; >+ int COLON = 4; >+ int EQUALS = 5; >+ int LBRACKET = 6; >+ int RBRACKET = 7; >+ int LCURLY = 8; >+ int RCURLY = 9; >+ int COMMA = 10; >+ int PLUS = 11; >+ int MINUS = 12; >+ int NUMBER_SIGN = 13; >+ int TILDE = 14; >+ int DOT = 15; >+ int STAR = 16; >+ int READ_ONLY = 17; >+ int UNION = 18; >+ int SUBSETS = 19; >+ int REDEFINES = 20; >+ int ORDERED = 21; >+ int UNORDERED = 22; >+ int UNIQUE = 23; >+ int NON_UNIQUE = 24; >+ int INTEGER_LITERAL = 25; >+ int IDENTIFIER = 26; >+ int LETTER = 27; >+ int DIGIT = 28; >+ >+ int DEFAULT = 0; >+ >+ String[] tokenImage = { >+ "<EOF>", >+ "\" \"", >+ "\"\\t\"", >+ "\"/\"", >+ "\":\"", >+ "\"=\"", >+ "\"[\"", >+ "\"]\"", >+ "\"{\"", >+ "\"}\"", >+ "\",\"", >+ "\"+\"", >+ "\"-\"", >+ "\"#\"", >+ "\"~\"", >+ "\".\"", >+ "\"*\"", >+ "\"readOnly\"", >+ "\"union\"", >+ "\"subsets\"", >+ "\"redefines\"", >+ "\"ordered\"", >+ "\"unordered\"", >+ "\"unique\"", >+ "\"nonunique\"", >+ "<INTEGER_LITERAL>", >+ "<IDENTIFIER>", >+ "<LETTER>", >+ "<DIGIT>", >+ }; >+ >+} >Index: src/org/eclipse/uml2/diagram/common/parser/port/PortParser.java >=================================================================== >RCS file: src/org/eclipse/uml2/diagram/common/parser/port/PortParser.java >diff -N src/org/eclipse/uml2/diagram/common/parser/port/PortParser.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/uml2/diagram/common/parser/port/PortParser.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,509 @@ >+/* Generated By:JavaCC: Do not edit this line. PortParser.java */ >+/* >+ * Copyright (c) 2006 Borland Software Corporation >+ * >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Michael Golubev (Borland) - initial API and implementation >+ */ >+package org.eclipse.uml2.diagram.common.parser.port; >+ >+import java.io.*; >+import org.eclipse.emf.ecore.EClass; >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.uml2.diagram.parser.*; >+import org.eclipse.uml2.diagram.parser.lookup.LookupResolver; >+import org.eclipse.uml2.diagram.parser.lookup.LookupSuite; >+import org.eclipse.uml2.uml.*; >+ >+public class PortParser extends ExternalParserBase implements PortParserConstants { >+ private Port mySubject; >+ >+ private static class TypeLookupCallback implements LookupResolver.Callback { >+ private final Port myPort; >+ >+ public TypeLookupCallback(Port property){ >+ myPort = property; >+ } >+ >+ public void lookupResolved(NamedElement resolution) { >+ if (resolution instanceof Type){ >+ myPort.setType((Type)resolution); >+ } >+ } >+ } >+ >+ public PortParser(){ >+ this(new StringReader("")); >+ } >+ >+ public PortParser(LookupSuite lookup){ >+ this(); >+ setLookupSuite(lookup); >+ } >+ >+ public EClass getSubjectClass(){ >+ return UMLPackage.eINSTANCE.getPort(); >+ } >+ >+ public void parse(EObject target, String text) throws ExternalParserException { >+ checkContext(); >+ ReInit(new StringReader(text)); >+ mySubject = (Port)target; >+ Declaration(); >+ mySubject = null; >+ } >+ >+ protected static int parseInt(Token t) throws ParseException { >+ if (t.kind != PortParserConstants.INTEGER_LITERAL){ >+ throw new IllegalStateException("Token: " + t + ", image: " + t.image); >+ } >+ try { >+ return Integer.parseInt(t.image); //XXX: "0005", "99999999999999999999999" >+ } catch (NumberFormatException e){ >+ throw new ParseException("Not supported integer value:" + t.image); >+ } >+ } >+ >+ final public void Declaration() throws ParseException { >+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { >+ case PLUS: >+ case MINUS: >+ case NUMBER_SIGN: >+ case TILDE: >+ Visibility(); >+ break; >+ default: >+ jj_la1[0] = jj_gen; >+ ; >+ } >+ PortName(); >+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { >+ case COLON: >+ PortType(); >+ break; >+ default: >+ jj_la1[1] = jj_gen; >+ ; >+ } >+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { >+ case LBRACKET: >+ Multiplicity(); >+ break; >+ default: >+ jj_la1[2] = jj_gen; >+ ; >+ } >+ jj_consume_token(0); >+ } >+ >+ final public void PortName() throws ParseException { >+ String name; >+ name = NameWithSpaces(); >+ mySubject.setName(name); >+ } >+ >+ final public void Visibility() throws ParseException { >+ VisibilityKind kind; >+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { >+ case PLUS: >+ jj_consume_token(PLUS); >+ kind = VisibilityKind.PUBLIC_LITERAL; >+ break; >+ case MINUS: >+ jj_consume_token(MINUS); >+ kind = VisibilityKind.PRIVATE_LITERAL; >+ break; >+ case NUMBER_SIGN: >+ jj_consume_token(NUMBER_SIGN); >+ kind = VisibilityKind.PROTECTED_LITERAL; >+ break; >+ case TILDE: >+ jj_consume_token(TILDE); >+ kind = VisibilityKind.PACKAGE_LITERAL; >+ break; >+ default: >+ jj_la1[3] = jj_gen; >+ jj_consume_token(-1); >+ throw new ParseException(); >+ } >+ mySubject.setVisibility(kind); >+ } >+ >+ final public void Multiplicity() throws ParseException { >+ MultiplicityRange(); >+ } >+ >+/* XXX: Parse conflict in case of empty default value >+void MultiplicityDesignator() : >+{ } >+{ >+ <LCURLY> >+ ( >+ ( MultiplicityUnique() [ MultiplicityOrdered() ] ) >+ | >+ ( MultiplicityOrdered() [ MultiplicityUnique() ] ) >+ ) >+ <RCURLY> >+} >+ >+void MultiplicityUnique() : >+{} >+{ >+ <UNIQUE> { mySubject.setIsUnique(true); } >+ | >+ <NON_UNIQUE> { mySubject.setIsUnique(false); } >+} >+ >+void MultiplicityOrdered() : >+{} >+{ >+ <ORDERED> { mySubject.setIsOrdered(true); } >+ | >+ <UNORDERED> { mySubject.setIsOrdered(false); } >+} >+ >+*/ >+ >+/* XXX: ValueSpecification -- how to parse */ >+ final public void MultiplicityRange() throws ParseException { >+ Token tLower = null; >+ Token tUpper; >+ jj_consume_token(LBRACKET); >+ if (jj_2_1(2)) { >+ tLower = jj_consume_token(INTEGER_LITERAL); >+ jj_consume_token(DOT); >+ jj_consume_token(DOT); >+ mySubject.setLower(parseInt(tLower)); >+ } else { >+ ; >+ } >+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { >+ case STAR: >+ tUpper = jj_consume_token(STAR); >+ if (tLower == null){ >+ mySubject.setLower(0); >+ } >+ mySubject.setUpper(LiteralUnlimitedNatural.UNLIMITED); >+ break; >+ case INTEGER_LITERAL: >+ tUpper = jj_consume_token(INTEGER_LITERAL); >+ if (tLower == null){ >+ mySubject.setLower(parseInt(tUpper)); >+ } >+ mySubject.setUpper(parseInt(tUpper)); >+ break; >+ default: >+ jj_la1[4] = jj_gen; >+ jj_consume_token(-1); >+ throw new ParseException(); >+ } >+ jj_consume_token(RBRACKET); >+ } >+ >+ final public void PortType() throws ParseException { >+ String type; >+ jj_consume_token(COLON); >+ type = NameWithSpaces(); >+ applyLookup(Type.class, type, new TypeLookupCallback(mySubject)); >+ } >+ >+ final public String NameWithSpaces() throws ParseException { >+ StringBuffer result = new StringBuffer(); >+ Token t; >+ t = jj_consume_token(IDENTIFIER); >+ result.append(t.image); >+ label_1: >+ while (true) { >+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { >+ case IDENTIFIER: >+ ; >+ break; >+ default: >+ jj_la1[5] = jj_gen; >+ break label_1; >+ } >+ t = jj_consume_token(IDENTIFIER); >+ result.append(' '); result.append(t.image); >+ } >+ {if (true) return result.toString();} >+ throw new Error("Missing return statement in function"); >+ } >+ >+ final private boolean jj_2_1(int xla) { >+ jj_la = xla; jj_lastpos = jj_scanpos = token; >+ try { return !jj_3_1(); } >+ catch(LookaheadSuccess ls) { return true; } >+ finally { jj_save(0, xla); } >+ } >+ >+ final private boolean jj_3_1() { >+ if (jj_scan_token(INTEGER_LITERAL)) return true; >+ if (jj_scan_token(DOT)) return true; >+ return false; >+ } >+ >+ public PortParserTokenManager token_source; >+ JavaCharStream jj_input_stream; >+ public Token token, jj_nt; >+ private int jj_ntk; >+ private Token jj_scanpos, jj_lastpos; >+ private int jj_la; >+ public boolean lookingAhead = false; >+ private boolean jj_semLA; >+ private int jj_gen; >+ final private int[] jj_la1 = new int[6]; >+ static private int[] jj_la1_0; >+ static { >+ jj_la1_0(); >+ } >+ private static void jj_la1_0() { >+ jj_la1_0 = new int[] {0x7800,0x10,0x40,0x7800,0x2010000,0x4000000,}; >+ } >+ final private JJCalls[] jj_2_rtns = new JJCalls[1]; >+ private boolean jj_rescan = false; >+ private int jj_gc = 0; >+ >+ public PortParser(java.io.InputStream stream) { >+ jj_input_stream = new JavaCharStream(stream, 1, 1); >+ token_source = new PortParserTokenManager(jj_input_stream); >+ token = new Token(); >+ jj_ntk = -1; >+ jj_gen = 0; >+ for (int i = 0; i < 6; i++) jj_la1[i] = -1; >+ for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); >+ } >+ >+ public void ReInit(java.io.InputStream stream) { >+ jj_input_stream.ReInit(stream, 1, 1); >+ token_source.ReInit(jj_input_stream); >+ token = new Token(); >+ jj_ntk = -1; >+ jj_gen = 0; >+ for (int i = 0; i < 6; i++) jj_la1[i] = -1; >+ for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); >+ } >+ >+ public PortParser(java.io.Reader stream) { >+ jj_input_stream = new JavaCharStream(stream, 1, 1); >+ token_source = new PortParserTokenManager(jj_input_stream); >+ token = new Token(); >+ jj_ntk = -1; >+ jj_gen = 0; >+ for (int i = 0; i < 6; i++) jj_la1[i] = -1; >+ for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); >+ } >+ >+ public void ReInit(java.io.Reader stream) { >+ jj_input_stream.ReInit(stream, 1, 1); >+ token_source.ReInit(jj_input_stream); >+ token = new Token(); >+ jj_ntk = -1; >+ jj_gen = 0; >+ for (int i = 0; i < 6; i++) jj_la1[i] = -1; >+ for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); >+ } >+ >+ public PortParser(PortParserTokenManager tm) { >+ token_source = tm; >+ token = new Token(); >+ jj_ntk = -1; >+ jj_gen = 0; >+ for (int i = 0; i < 6; i++) jj_la1[i] = -1; >+ for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); >+ } >+ >+ public void ReInit(PortParserTokenManager tm) { >+ token_source = tm; >+ token = new Token(); >+ jj_ntk = -1; >+ jj_gen = 0; >+ for (int i = 0; i < 6; i++) jj_la1[i] = -1; >+ for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); >+ } >+ >+ final private Token jj_consume_token(int kind) throws ParseException { >+ Token oldToken; >+ if ((oldToken = token).next != null) token = token.next; >+ else token = token.next = token_source.getNextToken(); >+ jj_ntk = -1; >+ if (token.kind == kind) { >+ jj_gen++; >+ if (++jj_gc > 100) { >+ jj_gc = 0; >+ for (int i = 0; i < jj_2_rtns.length; i++) { >+ JJCalls c = jj_2_rtns[i]; >+ while (c != null) { >+ if (c.gen < jj_gen) c.first = null; >+ c = c.next; >+ } >+ } >+ } >+ return token; >+ } >+ token = oldToken; >+ jj_kind = kind; >+ throw generateParseException(); >+ } >+ >+ static private final class LookaheadSuccess extends java.lang.Error { } >+ final private LookaheadSuccess jj_ls = new LookaheadSuccess(); >+ final private boolean jj_scan_token(int kind) { >+ if (jj_scanpos == jj_lastpos) { >+ jj_la--; >+ if (jj_scanpos.next == null) { >+ jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken(); >+ } else { >+ jj_lastpos = jj_scanpos = jj_scanpos.next; >+ } >+ } else { >+ jj_scanpos = jj_scanpos.next; >+ } >+ if (jj_rescan) { >+ int i = 0; Token tok = token; >+ while (tok != null && tok != jj_scanpos) { i++; tok = tok.next; } >+ if (tok != null) jj_add_error_token(kind, i); >+ } >+ if (jj_scanpos.kind != kind) return true; >+ if (jj_la == 0 && jj_scanpos == jj_lastpos) throw jj_ls; >+ return false; >+ } >+ >+ final public Token getNextToken() { >+ if (token.next != null) token = token.next; >+ else token = token.next = token_source.getNextToken(); >+ jj_ntk = -1; >+ jj_gen++; >+ return token; >+ } >+ >+ final public Token getToken(int index) { >+ Token t = lookingAhead ? jj_scanpos : token; >+ for (int i = 0; i < index; i++) { >+ if (t.next != null) t = t.next; >+ else t = t.next = token_source.getNextToken(); >+ } >+ return t; >+ } >+ >+ final private int jj_ntk() { >+ if ((jj_nt=token.next) == null) >+ return (jj_ntk = (token.next=token_source.getNextToken()).kind); >+ else >+ return (jj_ntk = jj_nt.kind); >+ } >+ >+ private java.util.Vector jj_expentries = new java.util.Vector(); >+ private int[] jj_expentry; >+ private int jj_kind = -1; >+ private int[] jj_lasttokens = new int[100]; >+ private int jj_endpos; >+ >+ private void jj_add_error_token(int kind, int pos) { >+ if (pos >= 100) return; >+ if (pos == jj_endpos + 1) { >+ jj_lasttokens[jj_endpos++] = kind; >+ } else if (jj_endpos != 0) { >+ jj_expentry = new int[jj_endpos]; >+ for (int i = 0; i < jj_endpos; i++) { >+ jj_expentry[i] = jj_lasttokens[i]; >+ } >+ boolean exists = false; >+ for (java.util.Enumeration e = jj_expentries.elements(); e.hasMoreElements();) { >+ int[] oldentry = (int[])(e.nextElement()); >+ if (oldentry.length == jj_expentry.length) { >+ exists = true; >+ for (int i = 0; i < jj_expentry.length; i++) { >+ if (oldentry[i] != jj_expentry[i]) { >+ exists = false; >+ break; >+ } >+ } >+ if (exists) break; >+ } >+ } >+ if (!exists) jj_expentries.addElement(jj_expentry); >+ if (pos != 0) jj_lasttokens[(jj_endpos = pos) - 1] = kind; >+ } >+ } >+ >+ public ParseException generateParseException() { >+ jj_expentries.removeAllElements(); >+ boolean[] la1tokens = new boolean[29]; >+ for (int i = 0; i < 29; i++) { >+ la1tokens[i] = false; >+ } >+ if (jj_kind >= 0) { >+ la1tokens[jj_kind] = true; >+ jj_kind = -1; >+ } >+ for (int i = 0; i < 6; i++) { >+ if (jj_la1[i] == jj_gen) { >+ for (int j = 0; j < 32; j++) { >+ if ((jj_la1_0[i] & (1<<j)) != 0) { >+ la1tokens[j] = true; >+ } >+ } >+ } >+ } >+ for (int i = 0; i < 29; i++) { >+ if (la1tokens[i]) { >+ jj_expentry = new int[1]; >+ jj_expentry[0] = i; >+ jj_expentries.addElement(jj_expentry); >+ } >+ } >+ jj_endpos = 0; >+ jj_rescan_token(); >+ jj_add_error_token(0, 0); >+ int[][] exptokseq = new int[jj_expentries.size()][]; >+ for (int i = 0; i < jj_expentries.size(); i++) { >+ exptokseq[i] = (int[])jj_expentries.elementAt(i); >+ } >+ return new ParseException(token, exptokseq, tokenImage); >+ } >+ >+ final public void enable_tracing() { >+ } >+ >+ final public void disable_tracing() { >+ } >+ >+ final private void jj_rescan_token() { >+ jj_rescan = true; >+ for (int i = 0; i < 1; i++) { >+ JJCalls p = jj_2_rtns[i]; >+ do { >+ if (p.gen > jj_gen) { >+ jj_la = p.arg; jj_lastpos = jj_scanpos = p.first; >+ switch (i) { >+ case 0: jj_3_1(); break; >+ } >+ } >+ p = p.next; >+ } while (p != null); >+ } >+ jj_rescan = false; >+ } >+ >+ final private void jj_save(int index, int xla) { >+ JJCalls p = jj_2_rtns[index]; >+ while (p.gen > jj_gen) { >+ if (p.next == null) { p = p.next = new JJCalls(); break; } >+ p = p.next; >+ } >+ p.gen = jj_gen + xla - jj_la; p.first = token; p.arg = xla; >+ } >+ >+ static final class JJCalls { >+ int gen; >+ Token first; >+ int arg; >+ JJCalls next; >+ } >+ >+} >Index: src/org/eclipse/uml2/diagram/common/parser/port/JavaCharStream.java >=================================================================== >RCS file: src/org/eclipse/uml2/diagram/common/parser/port/JavaCharStream.java >diff -N src/org/eclipse/uml2/diagram/common/parser/port/JavaCharStream.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/uml2/diagram/common/parser/port/JavaCharStream.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,558 @@ >+/* Generated By:JavaCC: Do not edit this line. JavaCharStream.java Version 3.0 */ >+/* >+ * Copyright (c) 2006 Borland Software Corporation >+ * >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Michael Golubev (Borland) - initial API and implementation >+ */ >+package org.eclipse.uml2.diagram.common.parser.port; >+ >+/** >+ * An implementation of interface CharStream, where the stream is assumed to >+ * contain only ASCII characters (with java-like unicode escape processing). >+ */ >+ >+public class JavaCharStream >+{ >+ public static final boolean staticFlag = false; >+ static final int hexval(char c) throws java.io.IOException { >+ switch(c) >+ { >+ case '0' : >+ return 0; >+ case '1' : >+ return 1; >+ case '2' : >+ return 2; >+ case '3' : >+ return 3; >+ case '4' : >+ return 4; >+ case '5' : >+ return 5; >+ case '6' : >+ return 6; >+ case '7' : >+ return 7; >+ case '8' : >+ return 8; >+ case '9' : >+ return 9; >+ >+ case 'a' : >+ case 'A' : >+ return 10; >+ case 'b' : >+ case 'B' : >+ return 11; >+ case 'c' : >+ case 'C' : >+ return 12; >+ case 'd' : >+ case 'D' : >+ return 13; >+ case 'e' : >+ case 'E' : >+ return 14; >+ case 'f' : >+ case 'F' : >+ return 15; >+ } >+ >+ throw new java.io.IOException(); // Should never come here >+ } >+ >+ public int bufpos = -1; >+ int bufsize; >+ int available; >+ int tokenBegin; >+ protected int bufline[]; >+ protected int bufcolumn[]; >+ >+ protected int column = 0; >+ protected int line = 1; >+ >+ protected boolean prevCharIsCR = false; >+ protected boolean prevCharIsLF = false; >+ >+ protected java.io.Reader inputStream; >+ >+ protected char[] nextCharBuf; >+ protected char[] buffer; >+ protected int maxNextCharInd = 0; >+ protected int nextCharInd = -1; >+ protected int inBuf = 0; >+ >+ protected void ExpandBuff(boolean wrapAround) >+ { >+ char[] newbuffer = new char[bufsize + 2048]; >+ int newbufline[] = new int[bufsize + 2048]; >+ int newbufcolumn[] = new int[bufsize + 2048]; >+ >+ try >+ { >+ if (wrapAround) >+ { >+ System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); >+ System.arraycopy(buffer, 0, newbuffer, >+ bufsize - tokenBegin, bufpos); >+ buffer = newbuffer; >+ >+ System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); >+ System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos); >+ bufline = newbufline; >+ >+ System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); >+ System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos); >+ bufcolumn = newbufcolumn; >+ >+ bufpos += (bufsize - tokenBegin); >+ } >+ else >+ { >+ System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); >+ buffer = newbuffer; >+ >+ System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); >+ bufline = newbufline; >+ >+ System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); >+ bufcolumn = newbufcolumn; >+ >+ bufpos -= tokenBegin; >+ } >+ } >+ catch (Throwable t) >+ { >+ throw new Error(t.getMessage()); >+ } >+ >+ available = (bufsize += 2048); >+ tokenBegin = 0; >+ } >+ >+ protected void FillBuff() throws java.io.IOException >+ { >+ int i; >+ if (maxNextCharInd == 4096) >+ maxNextCharInd = nextCharInd = 0; >+ >+ try { >+ if ((i = inputStream.read(nextCharBuf, maxNextCharInd, >+ 4096 - maxNextCharInd)) == -1) >+ { >+ inputStream.close(); >+ throw new java.io.IOException(); >+ } >+ else >+ maxNextCharInd += i; >+ return; >+ } >+ catch(java.io.IOException e) { >+ if (bufpos != 0) >+ { >+ --bufpos; >+ backup(0); >+ } >+ else >+ { >+ bufline[bufpos] = line; >+ bufcolumn[bufpos] = column; >+ } >+ throw e; >+ } >+ } >+ >+ protected char ReadByte() throws java.io.IOException >+ { >+ if (++nextCharInd >= maxNextCharInd) >+ FillBuff(); >+ >+ return nextCharBuf[nextCharInd]; >+ } >+ >+ public char BeginToken() throws java.io.IOException >+ { >+ if (inBuf > 0) >+ { >+ --inBuf; >+ >+ if (++bufpos == bufsize) >+ bufpos = 0; >+ >+ tokenBegin = bufpos; >+ return buffer[bufpos]; >+ } >+ >+ tokenBegin = 0; >+ bufpos = -1; >+ >+ return readChar(); >+ } >+ >+ protected void AdjustBuffSize() >+ { >+ if (available == bufsize) >+ { >+ if (tokenBegin > 2048) >+ { >+ bufpos = 0; >+ available = tokenBegin; >+ } >+ else >+ ExpandBuff(false); >+ } >+ else if (available > tokenBegin) >+ available = bufsize; >+ else if ((tokenBegin - available) < 2048) >+ ExpandBuff(true); >+ else >+ available = tokenBegin; >+ } >+ >+ protected void UpdateLineColumn(char c) >+ { >+ column++; >+ >+ if (prevCharIsLF) >+ { >+ prevCharIsLF = false; >+ line += (column = 1); >+ } >+ else if (prevCharIsCR) >+ { >+ prevCharIsCR = false; >+ if (c == '\n') >+ { >+ prevCharIsLF = true; >+ } >+ else >+ line += (column = 1); >+ } >+ >+ switch (c) >+ { >+ case '\r' : >+ prevCharIsCR = true; >+ break; >+ case '\n' : >+ prevCharIsLF = true; >+ break; >+ case '\t' : >+ column--; >+ column += (8 - (column & 07)); >+ break; >+ default : >+ break; >+ } >+ >+ bufline[bufpos] = line; >+ bufcolumn[bufpos] = column; >+ } >+ >+ public char readChar() throws java.io.IOException >+ { >+ if (inBuf > 0) >+ { >+ --inBuf; >+ >+ if (++bufpos == bufsize) >+ bufpos = 0; >+ >+ return buffer[bufpos]; >+ } >+ >+ char c; >+ >+ if (++bufpos == available) >+ AdjustBuffSize(); >+ >+ if ((buffer[bufpos] = c = ReadByte()) == '\\') >+ { >+ UpdateLineColumn(c); >+ >+ int backSlashCnt = 1; >+ >+ for (;;) // Read all the backslashes >+ { >+ if (++bufpos == available) >+ AdjustBuffSize(); >+ >+ try >+ { >+ if ((buffer[bufpos] = c = ReadByte()) != '\\') >+ { >+ UpdateLineColumn(c); >+ // found a non-backslash char. >+ if ((c == 'u') && ((backSlashCnt & 1) == 1)) >+ { >+ if (--bufpos < 0) >+ bufpos = bufsize - 1; >+ >+ break; >+ } >+ >+ backup(backSlashCnt); >+ return '\\'; >+ } >+ } >+ catch(java.io.IOException e) >+ { >+ if (backSlashCnt > 1) >+ backup(backSlashCnt); >+ >+ return '\\'; >+ } >+ >+ UpdateLineColumn(c); >+ backSlashCnt++; >+ } >+ >+ // Here, we have seen an odd number of backslash's followed by a 'u' >+ try >+ { >+ while ((c = ReadByte()) == 'u') >+ ++column; >+ >+ buffer[bufpos] = c = (char)(hexval(c) << 12 | >+ hexval(ReadByte()) << 8 | >+ hexval(ReadByte()) << 4 | >+ hexval(ReadByte())); >+ >+ column += 4; >+ } >+ catch(java.io.IOException e) >+ { >+ throw new Error("Invalid escape character at line " + line + >+ " column " + column + "."); >+ } >+ >+ if (backSlashCnt == 1) >+ return c; >+ else >+ { >+ backup(backSlashCnt - 1); >+ return '\\'; >+ } >+ } >+ else >+ { >+ UpdateLineColumn(c); >+ return (c); >+ } >+ } >+ >+ /** >+ * @deprecated >+ * @see #getEndColumn >+ */ >+ >+ public int getColumn() { >+ return bufcolumn[bufpos]; >+ } >+ >+ /** >+ * @deprecated >+ * @see #getEndLine >+ */ >+ >+ public int getLine() { >+ return bufline[bufpos]; >+ } >+ >+ public int getEndColumn() { >+ return bufcolumn[bufpos]; >+ } >+ >+ public int getEndLine() { >+ return bufline[bufpos]; >+ } >+ >+ public int getBeginColumn() { >+ return bufcolumn[tokenBegin]; >+ } >+ >+ public int getBeginLine() { >+ return bufline[tokenBegin]; >+ } >+ >+ public void backup(int amount) { >+ >+ inBuf += amount; >+ if ((bufpos -= amount) < 0) >+ bufpos += bufsize; >+ } >+ >+ public JavaCharStream(java.io.Reader dstream, >+ int startline, int startcolumn, int buffersize) >+ { >+ inputStream = dstream; >+ line = startline; >+ column = startcolumn - 1; >+ >+ available = bufsize = buffersize; >+ buffer = new char[buffersize]; >+ bufline = new int[buffersize]; >+ bufcolumn = new int[buffersize]; >+ nextCharBuf = new char[4096]; >+ } >+ >+ public JavaCharStream(java.io.Reader dstream, >+ int startline, int startcolumn) >+ { >+ this(dstream, startline, startcolumn, 4096); >+ } >+ >+ public JavaCharStream(java.io.Reader dstream) >+ { >+ this(dstream, 1, 1, 4096); >+ } >+ public void ReInit(java.io.Reader dstream, >+ int startline, int startcolumn, int buffersize) >+ { >+ inputStream = dstream; >+ line = startline; >+ column = startcolumn - 1; >+ >+ if (buffer == null || buffersize != buffer.length) >+ { >+ available = bufsize = buffersize; >+ buffer = new char[buffersize]; >+ bufline = new int[buffersize]; >+ bufcolumn = new int[buffersize]; >+ nextCharBuf = new char[4096]; >+ } >+ prevCharIsLF = prevCharIsCR = false; >+ tokenBegin = inBuf = maxNextCharInd = 0; >+ nextCharInd = bufpos = -1; >+ } >+ >+ public void ReInit(java.io.Reader dstream, >+ int startline, int startcolumn) >+ { >+ ReInit(dstream, startline, startcolumn, 4096); >+ } >+ >+ public void ReInit(java.io.Reader dstream) >+ { >+ ReInit(dstream, 1, 1, 4096); >+ } >+ public JavaCharStream(java.io.InputStream dstream, int startline, >+ int startcolumn, int buffersize) >+ { >+ this(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096); >+ } >+ >+ public JavaCharStream(java.io.InputStream dstream, int startline, >+ int startcolumn) >+ { >+ this(dstream, startline, startcolumn, 4096); >+ } >+ >+ public JavaCharStream(java.io.InputStream dstream) >+ { >+ this(dstream, 1, 1, 4096); >+ } >+ >+ public void ReInit(java.io.InputStream dstream, int startline, >+ int startcolumn, int buffersize) >+ { >+ ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096); >+ } >+ public void ReInit(java.io.InputStream dstream, int startline, >+ int startcolumn) >+ { >+ ReInit(dstream, startline, startcolumn, 4096); >+ } >+ public void ReInit(java.io.InputStream dstream) >+ { >+ ReInit(dstream, 1, 1, 4096); >+ } >+ >+ public String GetImage() >+ { >+ if (bufpos >= tokenBegin) >+ return new String(buffer, tokenBegin, bufpos - tokenBegin + 1); >+ else >+ return new String(buffer, tokenBegin, bufsize - tokenBegin) + >+ new String(buffer, 0, bufpos + 1); >+ } >+ >+ public char[] GetSuffix(int len) >+ { >+ char[] ret = new char[len]; >+ >+ if ((bufpos + 1) >= len) >+ System.arraycopy(buffer, bufpos - len + 1, ret, 0, len); >+ else >+ { >+ System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0, >+ len - bufpos - 1); >+ System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1); >+ } >+ >+ return ret; >+ } >+ >+ public void Done() >+ { >+ nextCharBuf = null; >+ buffer = null; >+ bufline = null; >+ bufcolumn = null; >+ } >+ >+ /** >+ * Method to adjust line and column numbers for the start of a token. >+ */ >+ public void adjustBeginLineColumn(int newLine, int newCol) >+ { >+ int start = tokenBegin; >+ int len; >+ >+ if (bufpos >= tokenBegin) >+ { >+ len = bufpos - tokenBegin + inBuf + 1; >+ } >+ else >+ { >+ len = bufsize - tokenBegin + bufpos + 1 + inBuf; >+ } >+ >+ int i = 0, j = 0, k = 0; >+ int nextColDiff = 0, columnDiff = 0; >+ >+ while (i < len && >+ bufline[j = start % bufsize] == bufline[k = ++start % bufsize]) >+ { >+ bufline[j] = newLine; >+ nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j]; >+ bufcolumn[j] = newCol + columnDiff; >+ columnDiff = nextColDiff; >+ i++; >+ } >+ >+ if (i < len) >+ { >+ bufline[j] = newLine++; >+ bufcolumn[j] = newCol + columnDiff; >+ >+ while (i++ < len) >+ { >+ if (bufline[j = start % bufsize] != bufline[++start % bufsize]) >+ bufline[j] = newLine++; >+ else >+ bufline[j] = newLine; >+ } >+ } >+ >+ line = bufline[j]; >+ column = bufcolumn[j]; >+ } >+ >+} >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: META-INF/MANIFEST.MF >diff -N META-INF/MANIFEST.MF >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ META-INF/MANIFEST.MF 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,20 @@ >+Manifest-Version: 1.0 >+Bundle-ManifestVersion: 2 >+Bundle-Name: UML Diagram Commons Plug-in >+Bundle-SymbolicName: org.eclipse.uml2.diagram.common >+Bundle-Version: 1.0.0 >+Bundle-Localization: plugin >+Require-Bundle: org.eclipse.core.runtime, >+ org.eclipse.core.resources, >+ org.eclipse.uml2.uml;visibility:=reexport, >+ org.eclipse.uml2.uml.edit;visibility:=reexport, >+ org.eclipse.emf.ecore;visibility:=reexport, >+ org.eclipse.emf.ecore.edit;visibility:=reexport, >+ org.eclipse.emf.query.ocl;visibility:=reexport, >+ org.eclipse.emf.ocl;visibility:=reexport, >+ org.eclipse.gmf.runtime.draw2d.ui;visibility:=reexport, >+ org.eclipse.draw2d;visibility:=reexport, >+ org.eclipse.uml2.diagram.parser >+Export-Package: org.eclipse.gmf.internal.codegen.draw2d, >+ org.eclipse.uml2.diagram.common.draw2d, >+ org.eclipse.uml2.diagram.common.parser.port;x-friends:="org.eclipse.uml2.diagram.clazz,org.eclipse.uml2.diagram.component" >Index: src/org/eclipse/uml2/diagram/common/parser/port/port.jj >=================================================================== >RCS file: src/org/eclipse/uml2/diagram/common/parser/port/port.jj >diff -N src/org/eclipse/uml2/diagram/common/parser/port/port.jj >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/uml2/diagram/common/parser/port/port.jj 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,310 @@ >+options { >+ JAVA_UNICODE_ESCAPE = true; >+ STATIC=false; >+} >+ >+PARSER_BEGIN(PortParser) >+ >+/* >+ * Copyright (c) 2006 Borland Software Corporation >+ * >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Michael Golubev (Borland) - initial API and implementation >+ */ >+package org.eclipse.uml2.diagram.common.parser.port; >+ >+import java.io.*; >+import org.eclipse.emf.ecore.EClass; >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.uml2.diagram.parser.*; >+import org.eclipse.uml2.diagram.parser.lookup.LookupSuite; >+import org.eclipse.uml2.diagram.parser.lookup.LookupResolver; >+import org.eclipse.uml2.uml.*; >+ >+public class PortParser extends ExternalParserBase { >+ private Port mySubject; >+ >+ private static class TypeLookupCallback implements LookupResolver.Callback { >+ private final Port myPort; >+ >+ public TypeLookupCallback(Port property){ >+ myPort = property; >+ } >+ >+ public void lookupResolved(NamedElement resolution) { >+ if (resolution instanceof Type){ >+ myPort.setType((Type)resolution); >+ } >+ } >+ } >+ >+ public PortParser(){ >+ this(new StringReader("")); >+ } >+ >+ public PortParser(LookupSuite lookup){ >+ this(); >+ setLookupSuite(lookup); >+ } >+ >+ public EClass getSubjectClass(){ >+ return UMLPackage.eINSTANCE.getPort(); >+ } >+ >+ public void parse(EObject target, String text) throws ExternalParserException { >+ checkContext(); >+ ReInit(new StringReader(text)); >+ mySubject = (Port)target; >+ Declaration(); >+ mySubject = null; >+ } >+ >+ protected static int parseInt(Token t) throws ParseException { >+ if (t.kind != PortParserConstants.INTEGER_LITERAL){ >+ throw new IllegalStateException("Token: " + t + ", image: " + t.image); >+ } >+ try { >+ return Integer.parseInt(t.image); //XXX: "0005", "99999999999999999999999" >+ } catch (NumberFormatException e){ >+ throw new ParseException("Not supported integer value:" + t.image); >+ } >+ } >+ >+} >+ >+PARSER_END(PortParser) >+ >+/* WHITE SPACE */ >+ >+SPECIAL_TOKEN : >+{ >+ " " >+| "\t" >+} >+ >+/* SEPARATORS */ >+TOKEN : >+{ >+ < SLASH: "/" > >+| < COLON: ":" > >+| < EQUALS: "=" > >+| < LBRACKET: "[" > >+| < RBRACKET: "]" > >+| < LCURLY: "{" > >+| < RCURLY: "}" > >+| < COMMA: "," > >+} >+ >+/* SPECIAL_MEANING */ >+TOKEN : >+{ >+ < PLUS: "+" > >+| < MINUS: "-" > >+| < NUMBER_SIGN: "#" > >+| < TILDE: "~" > >+| < DOT: "." > >+| < STAR: "*" > >+} >+ >+/* MODIFIERS */ >+TOKEN : >+{ >+ < READ_ONLY: "readOnly" > >+| < UNION: "union" > >+| < SUBSETS: "subsets" > >+| < REDEFINES: "redefines" > >+| < ORDERED: "ordered" > >+| < UNORDERED: "unordered" > >+| < UNIQUE: "unique" > >+| < NON_UNIQUE: "nonunique" > >+} >+ >+/* LITERALS */ >+TOKEN: >+{ >+ < INTEGER_LITERAL: ["0"-"9"] (["0"-"9"])* > >+} >+ >+TOKEN : >+{ >+ < IDENTIFIER: <LETTER> (<LETTER>|<DIGIT>)* > >+| >+ < #LETTER: >+ [ >+ "\u0024", >+ "\u0041"-"\u005a", >+ "\u005f", >+ "\u0061"-"\u007a", >+ "\u00c0"-"\u00d6", >+ "\u00d8"-"\u00f6", >+ "\u00f8"-"\u00ff", >+ "\u0100"-"\u1fff", >+ "\u3040"-"\u318f", >+ "\u3300"-"\u337f", >+ "\u3400"-"\u3d2d", >+ "\u4e00"-"\u9fff", >+ "\uf900"-"\ufaff" >+ ] >+ > >+| >+ < #DIGIT: >+ [ >+ "\u0030"-"\u0039", >+ "\u0660"-"\u0669", >+ "\u06f0"-"\u06f9", >+ "\u0966"-"\u096f", >+ "\u09e6"-"\u09ef", >+ "\u0a66"-"\u0a6f", >+ "\u0ae6"-"\u0aef", >+ "\u0b66"-"\u0b6f", >+ "\u0be7"-"\u0bef", >+ "\u0c66"-"\u0c6f", >+ "\u0ce6"-"\u0cef", >+ "\u0d66"-"\u0d6f", >+ "\u0e50"-"\u0e59", >+ "\u0ed0"-"\u0ed9", >+ "\u1040"-"\u1049" >+ ] >+ > >+} >+ >+void Declaration() : >+{} >+{ >+ ( >+ [ Visibility() ] >+ PortName() >+ [ PortType() ] >+ [ Multiplicity() ] >+ ) <EOF> >+} >+ >+void PortName() : >+{ >+ String name; >+} >+{ >+ name = NameWithSpaces() >+ { >+ mySubject.setName(name); >+ } >+} >+ >+void Visibility() : >+{ >+ VisibilityKind kind; >+} >+{ >+ ( >+ <PLUS> { kind = VisibilityKind.PUBLIC_LITERAL; } >+ | >+ <MINUS> { kind = VisibilityKind.PRIVATE_LITERAL; } >+ | >+ <NUMBER_SIGN> { kind = VisibilityKind.PROTECTED_LITERAL; } >+ | >+ <TILDE> { kind = VisibilityKind.PACKAGE_LITERAL; } >+ ) >+ { >+ mySubject.setVisibility(kind); >+ } >+} >+ >+void Multiplicity() : >+{} >+{ >+ MultiplicityRange() >+ /* XXX: Parse conflict in case of empty DefaultValue, consider "a:int[5]{unique}" >+ [ MultiplicityDesignator() ] >+ */ >+} >+ >+/* XXX: Parse conflict in case of empty default value >+void MultiplicityDesignator() : >+{ } >+{ >+ <LCURLY> >+ ( >+ ( MultiplicityUnique() [ MultiplicityOrdered() ] ) >+ | >+ ( MultiplicityOrdered() [ MultiplicityUnique() ] ) >+ ) >+ <RCURLY> >+} >+ >+void MultiplicityUnique() : >+{} >+{ >+ <UNIQUE> { mySubject.setIsUnique(true); } >+ | >+ <NON_UNIQUE> { mySubject.setIsUnique(false); } >+} >+ >+void MultiplicityOrdered() : >+{} >+{ >+ <ORDERED> { mySubject.setIsOrdered(true); } >+ | >+ <UNORDERED> { mySubject.setIsOrdered(false); } >+} >+ >+*/ >+ >+/* XXX: ValueSpecification -- how to parse */ >+void MultiplicityRange() : >+{ >+ Token tLower = null; >+ Token tUpper; >+} >+{ >+ <LBRACKET> >+ ( >+ [ LOOKAHEAD(2) tLower = <INTEGER_LITERAL> <DOT> <DOT> { mySubject.setLower(parseInt(tLower)); } ] >+ ( >+ tUpper = <STAR> >+ { >+ if (tLower == null){ >+ mySubject.setLower(0); >+ } >+ mySubject.setUpper(LiteralUnlimitedNatural.UNLIMITED); >+ } >+ | >+ tUpper = <INTEGER_LITERAL> >+ { >+ if (tLower == null){ >+ mySubject.setLower(parseInt(tUpper)); >+ } >+ mySubject.setUpper(parseInt(tUpper)); >+ } >+ ) >+ ) >+ <RBRACKET> >+} >+ >+void PortType() : >+{ >+ String type; >+} >+{ >+ <COLON> type = NameWithSpaces() { applyLookup(Type.class, type, new TypeLookupCallback(mySubject)); } >+} >+ >+String NameWithSpaces() : >+{ >+ StringBuffer result = new StringBuffer(); >+ Token t; >+} >+{ >+ ( >+ t = <IDENTIFIER> { result.append(t.image); } >+ ( t = <IDENTIFIER> { result.append(' '); result.append(t.image); } ) * >+ ) >+ { >+ return result.toString(); >+ } >+} >+ >Index: src/org/eclipse/uml2/diagram/common/parser/port/PortParserTokenManager.java >=================================================================== >RCS file: src/org/eclipse/uml2/diagram/common/parser/port/PortParserTokenManager.java >diff -N src/org/eclipse/uml2/diagram/common/parser/port/PortParserTokenManager.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/uml2/diagram/common/parser/port/PortParserTokenManager.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,727 @@ >+/* Generated By:JavaCC: Do not edit this line. PortParserTokenManager.java */ >+/* >+ * Copyright (c) 2006 Borland Software Corporation >+ * >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Michael Golubev (Borland) - initial API and implementation >+ */ >+package org.eclipse.uml2.diagram.common.parser.port; >+import java.io.*; >+import org.eclipse.emf.ecore.EClass; >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.uml2.diagram.parser.*; >+import org.eclipse.uml2.diagram.parser.lookup.LookupResolver; >+import org.eclipse.uml2.diagram.parser.lookup.LookupSuite; >+import org.eclipse.uml2.uml.*; >+ >+public class PortParserTokenManager implements PortParserConstants >+{ >+ public java.io.PrintStream debugStream = System.out; >+ public void setDebugStream(java.io.PrintStream ds) { debugStream = ds; } >+private final int jjStopStringLiteralDfa_0(int pos, long active0) >+{ >+ switch (pos) >+ { >+ case 0: >+ if ((active0 & 0x1fe0000L) != 0L) >+ { >+ jjmatchedKind = 26; >+ return 2; >+ } >+ return -1; >+ case 1: >+ if ((active0 & 0x1fe0000L) != 0L) >+ { >+ jjmatchedKind = 26; >+ jjmatchedPos = 1; >+ return 2; >+ } >+ return -1; >+ case 2: >+ if ((active0 & 0x1fe0000L) != 0L) >+ { >+ jjmatchedKind = 26; >+ jjmatchedPos = 2; >+ return 2; >+ } >+ return -1; >+ case 3: >+ if ((active0 & 0x1fe0000L) != 0L) >+ { >+ jjmatchedKind = 26; >+ jjmatchedPos = 3; >+ return 2; >+ } >+ return -1; >+ case 4: >+ if ((active0 & 0x40000L) != 0L) >+ return 2; >+ if ((active0 & 0x1fa0000L) != 0L) >+ { >+ jjmatchedKind = 26; >+ jjmatchedPos = 4; >+ return 2; >+ } >+ return -1; >+ case 5: >+ if ((active0 & 0x800000L) != 0L) >+ return 2; >+ if ((active0 & 0x17a0000L) != 0L) >+ { >+ jjmatchedKind = 26; >+ jjmatchedPos = 5; >+ return 2; >+ } >+ return -1; >+ case 6: >+ if ((active0 & 0x280000L) != 0L) >+ return 2; >+ if ((active0 & 0x1520000L) != 0L) >+ { >+ jjmatchedKind = 26; >+ jjmatchedPos = 6; >+ return 2; >+ } >+ return -1; >+ case 7: >+ if ((active0 & 0x20000L) != 0L) >+ return 2; >+ if ((active0 & 0x1500000L) != 0L) >+ { >+ jjmatchedKind = 26; >+ jjmatchedPos = 7; >+ return 2; >+ } >+ return -1; >+ default : >+ return -1; >+ } >+} >+private final int jjStartNfa_0(int pos, long active0) >+{ >+ return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0), pos + 1); >+} >+private final int jjStopAtPos(int pos, int kind) >+{ >+ jjmatchedKind = kind; >+ jjmatchedPos = pos; >+ return pos + 1; >+} >+private final int jjStartNfaWithStates_0(int pos, int kind, int state) >+{ >+ jjmatchedKind = kind; >+ jjmatchedPos = pos; >+ try { curChar = input_stream.readChar(); } >+ catch(java.io.IOException e) { return pos + 1; } >+ return jjMoveNfa_0(state, pos + 1); >+} >+private final int jjMoveStringLiteralDfa0_0() >+{ >+ switch(curChar) >+ { >+ case 9: >+ return jjStopAtPos(0, 2); >+ case 32: >+ return jjStopAtPos(0, 1); >+ case 35: >+ return jjStopAtPos(0, 13); >+ case 42: >+ return jjStopAtPos(0, 16); >+ case 43: >+ return jjStopAtPos(0, 11); >+ case 44: >+ return jjStopAtPos(0, 10); >+ case 45: >+ return jjStopAtPos(0, 12); >+ case 46: >+ return jjStopAtPos(0, 15); >+ case 47: >+ return jjStopAtPos(0, 3); >+ case 58: >+ return jjStopAtPos(0, 4); >+ case 61: >+ return jjStopAtPos(0, 5); >+ case 91: >+ return jjStopAtPos(0, 6); >+ case 93: >+ return jjStopAtPos(0, 7); >+ case 110: >+ return jjMoveStringLiteralDfa1_0(0x1000000L); >+ case 111: >+ return jjMoveStringLiteralDfa1_0(0x200000L); >+ case 114: >+ return jjMoveStringLiteralDfa1_0(0x120000L); >+ case 115: >+ return jjMoveStringLiteralDfa1_0(0x80000L); >+ case 117: >+ return jjMoveStringLiteralDfa1_0(0xc40000L); >+ case 123: >+ return jjStopAtPos(0, 8); >+ case 125: >+ return jjStopAtPos(0, 9); >+ case 126: >+ return jjStopAtPos(0, 14); >+ default : >+ return jjMoveNfa_0(1, 0); >+ } >+} >+private final int jjMoveStringLiteralDfa1_0(long active0) >+{ >+ try { curChar = input_stream.readChar(); } >+ catch(java.io.IOException e) { >+ jjStopStringLiteralDfa_0(0, active0); >+ return 1; >+ } >+ switch(curChar) >+ { >+ case 101: >+ return jjMoveStringLiteralDfa2_0(active0, 0x120000L); >+ case 110: >+ return jjMoveStringLiteralDfa2_0(active0, 0xc40000L); >+ case 111: >+ return jjMoveStringLiteralDfa2_0(active0, 0x1000000L); >+ case 114: >+ return jjMoveStringLiteralDfa2_0(active0, 0x200000L); >+ case 117: >+ return jjMoveStringLiteralDfa2_0(active0, 0x80000L); >+ default : >+ break; >+ } >+ return jjStartNfa_0(0, active0); >+} >+private final int jjMoveStringLiteralDfa2_0(long old0, long active0) >+{ >+ if (((active0 &= old0)) == 0L) >+ return jjStartNfa_0(0, old0); >+ try { curChar = input_stream.readChar(); } >+ catch(java.io.IOException e) { >+ jjStopStringLiteralDfa_0(1, active0); >+ return 2; >+ } >+ switch(curChar) >+ { >+ case 97: >+ return jjMoveStringLiteralDfa3_0(active0, 0x20000L); >+ case 98: >+ return jjMoveStringLiteralDfa3_0(active0, 0x80000L); >+ case 100: >+ return jjMoveStringLiteralDfa3_0(active0, 0x300000L); >+ case 105: >+ return jjMoveStringLiteralDfa3_0(active0, 0x840000L); >+ case 110: >+ return jjMoveStringLiteralDfa3_0(active0, 0x1000000L); >+ case 111: >+ return jjMoveStringLiteralDfa3_0(active0, 0x400000L); >+ default : >+ break; >+ } >+ return jjStartNfa_0(1, active0); >+} >+private final int jjMoveStringLiteralDfa3_0(long old0, long active0) >+{ >+ if (((active0 &= old0)) == 0L) >+ return jjStartNfa_0(1, old0); >+ try { curChar = input_stream.readChar(); } >+ catch(java.io.IOException e) { >+ jjStopStringLiteralDfa_0(2, active0); >+ return 3; >+ } >+ switch(curChar) >+ { >+ case 100: >+ return jjMoveStringLiteralDfa4_0(active0, 0x20000L); >+ case 101: >+ return jjMoveStringLiteralDfa4_0(active0, 0x300000L); >+ case 111: >+ return jjMoveStringLiteralDfa4_0(active0, 0x40000L); >+ case 113: >+ return jjMoveStringLiteralDfa4_0(active0, 0x800000L); >+ case 114: >+ return jjMoveStringLiteralDfa4_0(active0, 0x400000L); >+ case 115: >+ return jjMoveStringLiteralDfa4_0(active0, 0x80000L); >+ case 117: >+ return jjMoveStringLiteralDfa4_0(active0, 0x1000000L); >+ default : >+ break; >+ } >+ return jjStartNfa_0(2, active0); >+} >+private final int jjMoveStringLiteralDfa4_0(long old0, long active0) >+{ >+ if (((active0 &= old0)) == 0L) >+ return jjStartNfa_0(2, old0); >+ try { curChar = input_stream.readChar(); } >+ catch(java.io.IOException e) { >+ jjStopStringLiteralDfa_0(3, active0); >+ return 4; >+ } >+ switch(curChar) >+ { >+ case 79: >+ return jjMoveStringLiteralDfa5_0(active0, 0x20000L); >+ case 100: >+ return jjMoveStringLiteralDfa5_0(active0, 0x400000L); >+ case 101: >+ return jjMoveStringLiteralDfa5_0(active0, 0x80000L); >+ case 102: >+ return jjMoveStringLiteralDfa5_0(active0, 0x100000L); >+ case 110: >+ if ((active0 & 0x40000L) != 0L) >+ return jjStartNfaWithStates_0(4, 18, 2); >+ return jjMoveStringLiteralDfa5_0(active0, 0x1000000L); >+ case 114: >+ return jjMoveStringLiteralDfa5_0(active0, 0x200000L); >+ case 117: >+ return jjMoveStringLiteralDfa5_0(active0, 0x800000L); >+ default : >+ break; >+ } >+ return jjStartNfa_0(3, active0); >+} >+private final int jjMoveStringLiteralDfa5_0(long old0, long active0) >+{ >+ if (((active0 &= old0)) == 0L) >+ return jjStartNfa_0(3, old0); >+ try { curChar = input_stream.readChar(); } >+ catch(java.io.IOException e) { >+ jjStopStringLiteralDfa_0(4, active0); >+ return 5; >+ } >+ switch(curChar) >+ { >+ case 101: >+ if ((active0 & 0x800000L) != 0L) >+ return jjStartNfaWithStates_0(5, 23, 2); >+ return jjMoveStringLiteralDfa6_0(active0, 0x600000L); >+ case 105: >+ return jjMoveStringLiteralDfa6_0(active0, 0x1100000L); >+ case 110: >+ return jjMoveStringLiteralDfa6_0(active0, 0x20000L); >+ case 116: >+ return jjMoveStringLiteralDfa6_0(active0, 0x80000L); >+ default : >+ break; >+ } >+ return jjStartNfa_0(4, active0); >+} >+private final int jjMoveStringLiteralDfa6_0(long old0, long active0) >+{ >+ if (((active0 &= old0)) == 0L) >+ return jjStartNfa_0(4, old0); >+ try { curChar = input_stream.readChar(); } >+ catch(java.io.IOException e) { >+ jjStopStringLiteralDfa_0(5, active0); >+ return 6; >+ } >+ switch(curChar) >+ { >+ case 100: >+ if ((active0 & 0x200000L) != 0L) >+ return jjStartNfaWithStates_0(6, 21, 2); >+ break; >+ case 108: >+ return jjMoveStringLiteralDfa7_0(active0, 0x20000L); >+ case 110: >+ return jjMoveStringLiteralDfa7_0(active0, 0x100000L); >+ case 113: >+ return jjMoveStringLiteralDfa7_0(active0, 0x1000000L); >+ case 114: >+ return jjMoveStringLiteralDfa7_0(active0, 0x400000L); >+ case 115: >+ if ((active0 & 0x80000L) != 0L) >+ return jjStartNfaWithStates_0(6, 19, 2); >+ break; >+ default : >+ break; >+ } >+ return jjStartNfa_0(5, active0); >+} >+private final int jjMoveStringLiteralDfa7_0(long old0, long active0) >+{ >+ if (((active0 &= old0)) == 0L) >+ return jjStartNfa_0(5, old0); >+ try { curChar = input_stream.readChar(); } >+ catch(java.io.IOException e) { >+ jjStopStringLiteralDfa_0(6, active0); >+ return 7; >+ } >+ switch(curChar) >+ { >+ case 101: >+ return jjMoveStringLiteralDfa8_0(active0, 0x500000L); >+ case 117: >+ return jjMoveStringLiteralDfa8_0(active0, 0x1000000L); >+ case 121: >+ if ((active0 & 0x20000L) != 0L) >+ return jjStartNfaWithStates_0(7, 17, 2); >+ break; >+ default : >+ break; >+ } >+ return jjStartNfa_0(6, active0); >+} >+private final int jjMoveStringLiteralDfa8_0(long old0, long active0) >+{ >+ if (((active0 &= old0)) == 0L) >+ return jjStartNfa_0(6, old0); >+ try { curChar = input_stream.readChar(); } >+ catch(java.io.IOException e) { >+ jjStopStringLiteralDfa_0(7, active0); >+ return 8; >+ } >+ switch(curChar) >+ { >+ case 100: >+ if ((active0 & 0x400000L) != 0L) >+ return jjStartNfaWithStates_0(8, 22, 2); >+ break; >+ case 101: >+ if ((active0 & 0x1000000L) != 0L) >+ return jjStartNfaWithStates_0(8, 24, 2); >+ break; >+ case 115: >+ if ((active0 & 0x100000L) != 0L) >+ return jjStartNfaWithStates_0(8, 20, 2); >+ break; >+ default : >+ break; >+ } >+ return jjStartNfa_0(7, active0); >+} >+private final void jjCheckNAdd(int state) >+{ >+ if (jjrounds[state] != jjround) >+ { >+ jjstateSet[jjnewStateCnt++] = state; >+ jjrounds[state] = jjround; >+ } >+} >+private final void jjAddStates(int start, int end) >+{ >+ do { >+ jjstateSet[jjnewStateCnt++] = jjnextStates[start]; >+ } while (start++ != end); >+} >+private final void jjCheckNAddTwoStates(int state1, int state2) >+{ >+ jjCheckNAdd(state1); >+ jjCheckNAdd(state2); >+} >+private final void jjCheckNAddStates(int start, int end) >+{ >+ do { >+ jjCheckNAdd(jjnextStates[start]); >+ } while (start++ != end); >+} >+private final void jjCheckNAddStates(int start) >+{ >+ jjCheckNAdd(jjnextStates[start]); >+ jjCheckNAdd(jjnextStates[start + 1]); >+} >+static final long[] jjbitVec0 = { >+ 0x1ff00000fffffffeL, 0xffffffffffffc000L, 0xffffffffL, 0x600000000000000L >+}; >+static final long[] jjbitVec2 = { >+ 0x0L, 0x0L, 0x0L, 0xff7fffffff7fffffL >+}; >+static final long[] jjbitVec3 = { >+ 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL >+}; >+static final long[] jjbitVec4 = { >+ 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffL, 0x0L >+}; >+static final long[] jjbitVec5 = { >+ 0xffffffffffffffffL, 0xffffffffffffffffL, 0x0L, 0x0L >+}; >+static final long[] jjbitVec6 = { >+ 0x3fffffffffffL, 0x0L, 0x0L, 0x0L >+}; >+private final int jjMoveNfa_0(int startState, int curPos) >+{ >+ int[] nextStates; >+ int startsAt = 0; >+ jjnewStateCnt = 3; >+ int i = 1; >+ jjstateSet[0] = startState; >+ int j, kind = 0x7fffffff; >+ for (;;) >+ { >+ if (++jjround == 0x7fffffff) >+ ReInitRounds(); >+ if (curChar < 64) >+ { >+ long l = 1L << curChar; >+ MatchLoop: do >+ { >+ switch(jjstateSet[--i]) >+ { >+ case 1: >+ if ((0x3ff000000000000L & l) != 0L) >+ { >+ if (kind > 25) >+ kind = 25; >+ jjCheckNAdd(0); >+ } >+ else if (curChar == 36) >+ { >+ if (kind > 26) >+ kind = 26; >+ jjCheckNAdd(2); >+ } >+ break; >+ case 0: >+ if ((0x3ff000000000000L & l) == 0L) >+ break; >+ if (kind > 25) >+ kind = 25; >+ jjCheckNAdd(0); >+ break; >+ case 2: >+ if ((0x3ff001000000000L & l) == 0L) >+ break; >+ if (kind > 26) >+ kind = 26; >+ jjCheckNAdd(2); >+ break; >+ default : break; >+ } >+ } while(i != startsAt); >+ } >+ else if (curChar < 128) >+ { >+ long l = 1L << (curChar & 077); >+ MatchLoop: do >+ { >+ switch(jjstateSet[--i]) >+ { >+ case 1: >+ case 2: >+ if ((0x7fffffe87fffffeL & l) == 0L) >+ break; >+ if (kind > 26) >+ kind = 26; >+ jjCheckNAdd(2); >+ break; >+ default : break; >+ } >+ } while(i != startsAt); >+ } >+ else >+ { >+ int hiByte = (int)(curChar >> 8); >+ int i1 = hiByte >> 6; >+ long l1 = 1L << (hiByte & 077); >+ int i2 = (curChar & 0xff) >> 6; >+ long l2 = 1L << (curChar & 077); >+ MatchLoop: do >+ { >+ switch(jjstateSet[--i]) >+ { >+ case 1: >+ case 2: >+ if (!jjCanMove_0(hiByte, i1, i2, l1, l2)) >+ break; >+ if (kind > 26) >+ kind = 26; >+ jjCheckNAdd(2); >+ break; >+ default : break; >+ } >+ } while(i != startsAt); >+ } >+ if (kind != 0x7fffffff) >+ { >+ jjmatchedKind = kind; >+ jjmatchedPos = curPos; >+ kind = 0x7fffffff; >+ } >+ ++curPos; >+ if ((i = jjnewStateCnt) == (startsAt = 3 - (jjnewStateCnt = startsAt))) >+ return curPos; >+ try { curChar = input_stream.readChar(); } >+ catch(java.io.IOException e) { return curPos; } >+ } >+} >+static final int[] jjnextStates = { >+}; >+private static final boolean jjCanMove_0(int hiByte, int i1, int i2, long l1, long l2) >+{ >+ switch(hiByte) >+ { >+ case 0: >+ return ((jjbitVec2[i2] & l2) != 0L); >+ case 48: >+ return ((jjbitVec3[i2] & l2) != 0L); >+ case 49: >+ return ((jjbitVec4[i2] & l2) != 0L); >+ case 51: >+ return ((jjbitVec5[i2] & l2) != 0L); >+ case 61: >+ return ((jjbitVec6[i2] & l2) != 0L); >+ default : >+ if ((jjbitVec0[i1] & l1) != 0L) >+ return true; >+ return false; >+ } >+} >+public static final String[] jjstrLiteralImages = { >+"", null, null, "\57", "\72", "\75", "\133", "\135", "\173", "\175", "\54", >+"\53", "\55", "\43", "\176", "\56", "\52", "\162\145\141\144\117\156\154\171", >+"\165\156\151\157\156", "\163\165\142\163\145\164\163", "\162\145\144\145\146\151\156\145\163", >+"\157\162\144\145\162\145\144", "\165\156\157\162\144\145\162\145\144", "\165\156\151\161\165\145", >+"\156\157\156\165\156\151\161\165\145", null, null, null, null, }; >+public static final String[] lexStateNames = { >+ "DEFAULT", >+}; >+static final long[] jjtoToken = { >+ 0x7fffff9L, >+}; >+static final long[] jjtoSkip = { >+ 0x6L, >+}; >+static final long[] jjtoSpecial = { >+ 0x6L, >+}; >+protected JavaCharStream input_stream; >+private final int[] jjrounds = new int[3]; >+private final int[] jjstateSet = new int[6]; >+protected char curChar; >+public PortParserTokenManager(JavaCharStream stream) >+{ >+ if (JavaCharStream.staticFlag) >+ throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer."); >+ input_stream = stream; >+} >+public PortParserTokenManager(JavaCharStream stream, int lexState) >+{ >+ this(stream); >+ SwitchTo(lexState); >+} >+public void ReInit(JavaCharStream stream) >+{ >+ jjmatchedPos = jjnewStateCnt = 0; >+ curLexState = defaultLexState; >+ input_stream = stream; >+ ReInitRounds(); >+} >+private final void ReInitRounds() >+{ >+ int i; >+ jjround = 0x80000001; >+ for (i = 3; i-- > 0;) >+ jjrounds[i] = 0x80000000; >+} >+public void ReInit(JavaCharStream stream, int lexState) >+{ >+ ReInit(stream); >+ SwitchTo(lexState); >+} >+public void SwitchTo(int lexState) >+{ >+ if (lexState >= 1 || lexState < 0) >+ throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE); >+ else >+ curLexState = lexState; >+} >+ >+protected Token jjFillToken() >+{ >+ Token t = Token.newToken(jjmatchedKind); >+ t.kind = jjmatchedKind; >+ String im = jjstrLiteralImages[jjmatchedKind]; >+ t.image = (im == null) ? input_stream.GetImage() : im; >+ t.beginLine = input_stream.getBeginLine(); >+ t.beginColumn = input_stream.getBeginColumn(); >+ t.endLine = input_stream.getEndLine(); >+ t.endColumn = input_stream.getEndColumn(); >+ return t; >+} >+ >+int curLexState = 0; >+int defaultLexState = 0; >+int jjnewStateCnt; >+int jjround; >+int jjmatchedPos; >+int jjmatchedKind; >+ >+public Token getNextToken() >+{ >+ int kind; >+ Token specialToken = null; >+ Token matchedToken; >+ int curPos = 0; >+ >+ EOFLoop : >+ for (;;) >+ { >+ try >+ { >+ curChar = input_stream.BeginToken(); >+ } >+ catch(java.io.IOException e) >+ { >+ jjmatchedKind = 0; >+ matchedToken = jjFillToken(); >+ matchedToken.specialToken = specialToken; >+ return matchedToken; >+ } >+ >+ jjmatchedKind = 0x7fffffff; >+ jjmatchedPos = 0; >+ curPos = jjMoveStringLiteralDfa0_0(); >+ if (jjmatchedKind != 0x7fffffff) >+ { >+ if (jjmatchedPos + 1 < curPos) >+ input_stream.backup(curPos - jjmatchedPos - 1); >+ if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) >+ { >+ matchedToken = jjFillToken(); >+ matchedToken.specialToken = specialToken; >+ return matchedToken; >+ } >+ else >+ { >+ if ((jjtoSpecial[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) >+ { >+ matchedToken = jjFillToken(); >+ if (specialToken == null) >+ specialToken = matchedToken; >+ else >+ { >+ matchedToken.specialToken = specialToken; >+ specialToken = (specialToken.next = matchedToken); >+ } >+ } >+ continue EOFLoop; >+ } >+ } >+ int error_line = input_stream.getEndLine(); >+ int error_column = input_stream.getEndColumn(); >+ String error_after = null; >+ boolean EOFSeen = false; >+ try { input_stream.readChar(); input_stream.backup(1); } >+ catch (java.io.IOException e1) { >+ EOFSeen = true; >+ error_after = curPos <= 1 ? "" : input_stream.GetImage(); >+ if (curChar == '\n' || curChar == '\r') { >+ error_line++; >+ error_column = 0; >+ } >+ else >+ error_column++; >+ } >+ if (!EOFSeen) { >+ input_stream.backup(1); >+ error_after = curPos <= 1 ? "" : input_stream.GetImage(); >+ } >+ throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR); >+ } >+} >+ >+} >Index: .classpath >=================================================================== >RCS file: .classpath >diff -N .classpath >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ .classpath 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,7 @@ >+<?xml version="1.0" encoding="UTF-8"?> >+<classpath> >+ <classpathentry kind="src" path="src"/> >+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> >+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> >+ <classpathentry kind="output" path="bin"/> >+</classpath> >Index: .cvsignore >=================================================================== >RCS file: .cvsignore >diff -N .cvsignore >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ .cvsignore 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,2 @@ >+bin >+.settings >Index: src/org/eclipse/gmf/internal/codegen/draw2d/GridLayout.java >=================================================================== >RCS file: src/org/eclipse/gmf/internal/codegen/draw2d/GridLayout.java >diff -N src/org/eclipse/gmf/internal/codegen/draw2d/GridLayout.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/gmf/internal/codegen/draw2d/GridLayout.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,787 @@ >+package org.eclipse.gmf.internal.codegen.draw2d; >+ >+import java.util.HashMap; >+import java.util.List; >+import java.util.Map; >+ >+import org.eclipse.draw2d.AbstractLayout; >+import org.eclipse.draw2d.IFigure; >+import org.eclipse.draw2d.LayoutManager; >+import org.eclipse.draw2d.geometry.Dimension; >+import org.eclipse.draw2d.geometry.Rectangle; >+import org.eclipse.swt.SWT; >+ >+ >+/** >+ * Lays out children into a Grid arrangement in which overall aligment and >+ * spacing can be configured, as well as specfic layout requirements for the >+ * each individual member of the GridLayout. This layout is a Draw2D port of the >+ * swt GridLayout. >+ * >+ * <code>GridLayout</code> has a number of configuration fields, and the >+ * Figures it lays out can have an associated layout data object, called >+ * <code>GridLayoutData</code> (similar to the swt GridLayoutData object). The power of >+ * <code>GridLayout</code> lies in the ability to configure >+ * <code>GridLayoutData</code> for each Figure in the layout. >+ * <p> >+ * The following code creates a container Figure managed by a >+ * <code>GridLayout</code> with 2 columns, containing 3 RectangleFigure >+ * shapes, the last of which has been given further layout instructions. >+ * Note that it is the <code>GridLayout</code> method <code>setConstraint</code> >+ * that binds the child <code>Figure</code> to its layout <code>GridLayoutData</code> object. >+ * >+ * <pre> >+ * Figure container = new Figure(); >+ * GridLayout gridLayout = new GridLayout(); >+ * gridLayout.numColumns = 2; >+ * container.setLayout(gridLayout); >+ * >+ * Shape rect; >+ * rect = new RectangleFigure(); >+ * container.add(rect); >+ * >+ * rect = new RectangleFigure(); >+ * container.add(rect); >+ * >+ * rect = new RectangleFigure(); >+ * GridLayoutData GridLayoutData = new GridLayoutData(); >+ * GridLayoutData.widthHint = 150; >+ * layout.setConstraint(rect, GridLayoutData); >+ * >+ * container.add(rect); >+ * </pre> >+ * >+ * <p> >+ * The <code>numColumns</code> field is the most important field in a >+ * <code>GridLayout</code>. Widgets are laid out in columns from left to >+ * right, and a new row is created when <code>numColumns</code>+ 1 figures >+ * are added to the <code>Figure<code> parent container. >+ * >+ * @see GridLayoutData >+ * >+ * @author Asim Ullah >+ * created: Sep 10, 2004 >+ */ >+public class GridLayout extends AbstractLayout { >+ /** >+ * numColumns specifies the number of cell columns in the layout. >+ * >+ * The default value is 1. >+ */ >+ public int numColumns = 1; >+ >+ /** >+ * makeColumnsEqualWidth specifies whether all columns in the layout will be >+ * forced to have the same width. >+ * >+ * The default value is false. >+ */ >+ public boolean makeColumnsEqualWidth = false; >+ >+ /** >+ * marginWidth specifies the number of pixels of horizontal margin that will >+ * be placed along the left and right edges of the layout. >+ * >+ * The default value is 5. >+ */ >+ public int marginWidth = 5; >+ >+ /** >+ * marginHeight specifies the number of pixels of vertical margin that will >+ * be placed along the top and bottom edges of the layout. >+ * >+ * The default value is 5. >+ */ >+ public int marginHeight = 5; >+ >+ /** >+ * horizontalSpacing specifies the number of pixels between the right edge >+ * of one cell and the left edge of its neighbouring cell to the right. >+ * >+ * The default value is 5. >+ */ >+ public int horizontalSpacing = 5; >+ >+ /** >+ * verticalSpacing specifies the number of pixels between the bottom edge of >+ * one cell and the top edge of its neighbouring cell underneath. >+ * >+ * The default value is 5. >+ */ >+ public int verticalSpacing = 5; >+ >+ /** The layout contraints */ >+ protected Map constraints = new HashMap(); >+ >+ /** >+ * Default Constructor >+ */ >+ public GridLayout() { >+ super(); >+ } >+ >+ /** >+ * Constructs a new instance of this class given the number of columns, and >+ * whether or not the columns should be forced to have the same width. >+ * >+ * @param numColumns >+ * the number of columns in the grid >+ * @param makeColumnsEqualWidth >+ * whether or not the columns will have equal width >+ * >+ */ >+ public GridLayout(int numColumns, boolean makeColumnsEqualWidth) { >+ this.numColumns = numColumns; >+ this.makeColumnsEqualWidth = makeColumnsEqualWidth; >+ } >+ >+ /** >+ * @param child >+ * @param wHint >+ * @param hHint >+ * @return >+ */ >+ protected Dimension getChildSize(IFigure child, int wHint, int hHint) { >+ return child.getPreferredSize(wHint, hHint); >+ } >+ >+ GridLayoutData getData(IFigure[][] grid, int row, int column, int rowCount, >+ int columnCount, boolean first) { >+ IFigure figure = grid[row][column]; >+ if (figure != null) { >+ GridLayoutData data = (GridLayoutData) getConstraint(figure); >+ int hSpan = Math.max(1, Math.min(data.horizontalSpan, columnCount)); >+ int vSpan = Math.max(1, data.verticalSpan); >+ int i = first ? row + vSpan - 1 : row - vSpan + 1; >+ int j = first ? column + hSpan - 1 : column - hSpan + 1; >+ if (0 <= i && i < rowCount) { >+ if (0 <= j && j < columnCount) { >+ if (figure == grid[i][j]) >+ return data; >+ } >+ } >+ } >+ return null; >+ } >+ >+ void initChildren(IFigure container) >+ { >+ List children = container.getChildren(); >+ for (int i = 0; i < children.size(); i++) { >+ IFigure child = (IFigure) children.get(i); >+ if (child.getLayoutManager()==null) >+ child.setLayoutManager(this); >+ } >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.draw2d.AbstractLayout#calculatePreferredSize(org.eclipse.draw2d.IFigure, >+ * int, int) >+ */ >+ protected Dimension calculatePreferredSize(IFigure container, int wHint, >+ int hHint) { >+ Dimension size = layout(container, false, 0, 0, wHint, hHint, /* flushCache */ >+ true); >+ if (wHint != SWT.DEFAULT) >+ size.width = wHint; >+ if (hHint != SWT.DEFAULT) >+ size.height = hHint; >+ >+ return size; >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.draw2d.LayoutManager#layout(org.eclipse.draw2d.IFigure) >+ */ >+ public void layout(IFigure container) { >+ //initChildren( container); >+ Rectangle rect = container.getClientArea(); >+ layout(container, true, rect.x, rect.y, rect.width, rect.height, /* flushCache */ >+ true); >+ >+ } >+ >+ Dimension layout(IFigure container, boolean move, int x, int y, int width, >+ int height, boolean flushCache) { >+ if (numColumns < 1) >+ return new Dimension(marginWidth * 2, marginHeight * 2); >+ List children = container.getChildren(); >+ for (int i = 0; i < children.size(); i++) { >+ IFigure child = (IFigure) children.get(i); >+ >+ GridLayoutData data = (GridLayoutData) getConstraint(child); >+ if (data == null) >+ setConstraint(child, data = new GridLayoutData()); >+ if (flushCache) >+ data.flushCache(); >+ data.computeSize(child, flushCache); >+ } >+ >+ /* Build the grid */ >+ int row = 0, column = 0, rowCount = 0, columnCount = numColumns; >+ IFigure[][] grid = new IFigure[4][columnCount]; >+ for (int i = 0; i < children.size(); i++) { >+ IFigure child = (IFigure) children.get(i); >+ GridLayoutData data = (GridLayoutData) getConstraint(child); >+ int hSpan = Math.max(1, Math.min(data.horizontalSpan, columnCount)); >+ int vSpan = Math.max(1, data.verticalSpan); >+ while (true) { >+ int lastRow = row + vSpan; >+ if (lastRow >= grid.length) { >+ IFigure[][] newGrid = new IFigure[lastRow + 4][columnCount]; >+ System.arraycopy(grid, 0, newGrid, 0, grid.length); >+ grid = newGrid; >+ } >+ if (grid[row] == null) { >+ grid[row] = new IFigure[columnCount]; >+ } >+ while (column < columnCount && grid[row][column] != null) { >+ column++; >+ } >+ int endCount = column + hSpan; >+ if (endCount <= columnCount) { >+ int index = column; >+ while (index < endCount && grid[row][index] == null) { >+ index++; >+ } >+ if (index == endCount) >+ break; >+ column = index; >+ } >+ if (column + hSpan >= columnCount) { >+ column = 0; >+ row++; >+ } >+ } >+ for (int j = 0; j < vSpan; j++) { >+ if (grid[row + j] == null) { >+ grid[row + j] = new IFigure[columnCount]; >+ } >+ for (int k = 0; k < hSpan; k++) { >+ grid[row + j][column + k] = child; >+ } >+ } >+ rowCount = Math.max(rowCount, row + vSpan); >+ column += hSpan; >+ } >+ >+ /* Column widths */ >+ int availableWidth = width - horizontalSpacing * (columnCount - 1) >+ - marginWidth * 2; >+ int expandCount = 0; >+ int[] widths = new int[columnCount]; >+ int[] minWidths = new int[columnCount]; >+ boolean[] expandColumn = new boolean[columnCount]; >+ for (int j = 0; j < columnCount; j++) { >+ for (int i = 0; i < rowCount; i++) { >+ GridLayoutData data = getData(grid, i, j, rowCount, columnCount, true); >+ if (data != null) { >+ int hSpan = Math.max(1, Math.min(data.horizontalSpan, >+ columnCount)); >+ if (hSpan == 1) { >+ int w = data.cacheWidth + data.horizontalIndent; >+ widths[j] = Math.max(widths[j], w); >+ if (data.grabExcessHorizontalSpace) { >+ if (!expandColumn[j]) >+ expandCount++; >+ expandColumn[j] = true; >+ } >+ if (data.widthHint != SWT.DEFAULT >+ || !data.grabExcessHorizontalSpace) { >+ minWidths[j] = Math.max(minWidths[j], w); >+ } >+ } >+ } >+ } >+ for (int i = 0; i < rowCount; i++) { >+ GridLayoutData data = getData(grid, i, j, rowCount, columnCount, >+ false); >+ if (data != null) { >+ int hSpan = Math.max(1, Math.min(data.horizontalSpan, >+ columnCount)); >+ if (hSpan > 1) { >+ int spanWidth = 0, spanMinWidth = 0, spanExpandCount = 0; >+ for (int k = 0; k < hSpan; k++) { >+ spanWidth += widths[j - k]; >+ spanMinWidth += minWidths[j - k]; >+ if (expandColumn[j - k]) >+ spanExpandCount++; >+ } >+ if (data.grabExcessHorizontalSpace >+ && spanExpandCount == 0) { >+ expandCount++; >+ expandColumn[j] = true; >+ } >+ int w = data.cacheWidth + data.horizontalIndent >+ - spanWidth - (hSpan - 1) * horizontalSpacing; >+ if (w > 0) { >+ if (spanExpandCount == 0) { >+ widths[j] += w; >+ } else { >+ int delta = w / spanExpandCount; >+ int remainder = w % spanExpandCount, last = -1; >+ for (int k = 0; k < hSpan; k++) { >+ if (expandColumn[j - k]) { >+ widths[last = j - k] += delta; >+ } >+ } >+ if (last > -1) >+ widths[last] += remainder; >+ } >+ } >+ if (data.widthHint != SWT.DEFAULT >+ || !data.grabExcessHorizontalSpace) { >+ w = data.cacheWidth + data.horizontalIndent >+ - spanMinWidth - (hSpan - 1) >+ * horizontalSpacing; >+ if (w > 0) { >+ if (spanExpandCount == 0) { >+ minWidths[j] += w; >+ } else { >+ int delta = w / spanExpandCount; >+ int remainder = w % spanExpandCount, last = -1; >+ for (int k = 0; k < hSpan; k++) { >+ if (expandColumn[j - k]) { >+ minWidths[last = j - k] += delta; >+ } >+ } >+ if (last > -1) >+ minWidths[last] += remainder; >+ } >+ } >+ } >+ } >+ } >+ } >+ } >+ if (makeColumnsEqualWidth) { >+ int minColumnWidth = 0; >+ int columnWidth = 0; >+ for (int i = 0; i < columnCount; i++) { >+ minColumnWidth = Math.max(minColumnWidth, minWidths[i]); >+ columnWidth = Math.max(columnWidth, widths[i]); >+ } >+ columnWidth = width == SWT.DEFAULT || expandCount == 0 >+ ? columnWidth >+ : Math.max(minColumnWidth, availableWidth / columnCount); >+ for (int i = 0; i < columnCount; i++) { >+ expandColumn[i] = expandCount > 0; >+ widths[i] = columnWidth; >+ } >+ } else { >+ if (width != SWT.DEFAULT && expandCount > 0) { >+ int totalWidth = 0; >+ for (int i = 0; i < columnCount; i++) { >+ totalWidth += widths[i]; >+ } >+ int count = expandCount; >+ int delta = (availableWidth - totalWidth) / count; >+ int remainder = (availableWidth - totalWidth) % count; >+ int last = -1; >+ while (totalWidth != availableWidth) { >+ for (int j = 0; j < columnCount; j++) { >+ if (expandColumn[j]) { >+ if (widths[j] + delta > minWidths[j]) { >+ widths[last = j] = widths[j] + delta; >+ } else { >+ widths[j] = minWidths[j]; >+ expandColumn[j] = false; >+ count--; >+ } >+ } >+ } >+ if (last > -1) >+ widths[last] += remainder; >+ >+ for (int j = 0; j < columnCount; j++) { >+ for (int i = 0; i < rowCount; i++) { >+ GridLayoutData data = getData(grid, i, j, rowCount, >+ columnCount, false); >+ if (data != null) { >+ int hSpan = Math.max(1, Math.min( >+ data.horizontalSpan, columnCount)); >+ if (hSpan > 1) { >+ if (data.widthHint != SWT.DEFAULT >+ || !data.grabExcessHorizontalSpace) { >+ int spanWidth = 0, spanExpandCount = 0; >+ for (int k = 0; k < hSpan; k++) { >+ spanWidth += widths[j - k]; >+ if (expandColumn[j - k]) >+ spanExpandCount++; >+ } >+ int w = data.cacheWidth >+ + data.horizontalIndent >+ - spanWidth - (hSpan - 1) >+ * horizontalSpacing; >+ if (w > 0) { >+ if (spanExpandCount == 0) { >+ widths[j] += w; >+ } else { >+ int delta2 = w >+ / spanExpandCount; >+ int remainder2 = w >+ % spanExpandCount, last2 = -1; >+ for (int k = 0; k < hSpan; k++) { >+ if (expandColumn[j - k]) { >+ widths[last2 = j - k] += delta2; >+ } >+ } >+ if (last2 > -1) >+ widths[last2] += remainder2; >+ } >+ } >+ } >+ } >+ } >+ } >+ } >+ if (count == 0) >+ break; >+ totalWidth = 0; >+ for (int i = 0; i < columnCount; i++) { >+ totalWidth += widths[i]; >+ } >+ delta = (availableWidth - totalWidth) / count; >+ remainder = (availableWidth - totalWidth) % count; >+ last = -1; >+ } >+ } >+ } >+ >+ /* Wrapping */ >+ GridLayoutData[] flush = null; >+ int flushLength = 0; >+ if (width != SWT.DEFAULT) { >+ for (int j = 0; j < columnCount; j++) { >+ for (int i = 0; i < rowCount; i++) { >+ GridLayoutData data = getData(grid, i, j, rowCount, columnCount, >+ false); >+ if (data != null) { >+ if (data.heightHint == SWT.DEFAULT) { >+ IFigure child = grid[i][j]; >+ //TEMPORARY CODE >+ int hSpan = Math.max(1, Math.min( >+ data.horizontalSpan, columnCount)); >+ int currentWidth = 0; >+ for (int k = 0; k < hSpan; k++) { >+ currentWidth += widths[j - k]; >+ } >+ currentWidth += (hSpan - 1) * horizontalSpacing >+ - data.horizontalIndent; >+ if ((currentWidth != data.cacheWidth && data.horizontalAlignment == GridLayoutData.FILL) >+ || (data.cacheWidth > currentWidth)) { >+ int trim = 0; >+ /* >+ // *Note*: Left this in place from SWT >+ // GridLayout. Not sure if Draw2D Borders or >+ // Scrollbars 'trim' will need to be takeninto account. >+ >+ if (child instanceof Group) { >+ Group g =(Group)child; trim = g.getSize ().x - >+ g.getClientArea ().width; >+ } else if (child instanceof Scrollable) { >+ Rectangle rect = >+ ((Scrollable) child).computeTrim (0, 0, 0,0); >+ trim = rect.width; } >+ else { >+ trim = child.getBorderWidth () * 2; >+ } >+ */ >+ int oldWidthHint = data.widthHint; >+ data.widthHint = Math.max(0, currentWidth >+ - trim); >+ data.cacheWidth = data.cacheHeight = SWT.DEFAULT; >+ data.computeSize(child, false); >+ data.widthHint = oldWidthHint; >+ if (flush == null) >+ flush = new GridLayoutData[children.size()]; >+ flush[flushLength++] = data; >+ } >+ } >+ } >+ } >+ } >+ } >+ >+ /* Row heights */ >+ int availableHeight = height - verticalSpacing * (rowCount - 1) >+ - marginHeight * 2; >+ expandCount = 0; >+ int[] heights = new int[rowCount]; >+ int[] minHeights = new int[rowCount]; >+ boolean[] expandRow = new boolean[rowCount]; >+ for (int i = 0; i < rowCount; i++) { >+ for (int j = 0; j < columnCount; j++) { >+ GridLayoutData data = getData(grid, i, j, rowCount, columnCount, true); >+ if (data != null) { >+ int vSpan = Math.max(1, Math.min(data.verticalSpan, >+ rowCount)); >+ if (vSpan == 1) { >+ int h = data.cacheHeight; // + data.verticalIndent; >+ heights[i] = Math.max(heights[i], h); >+ if (data.grabExcessVerticalSpace) { >+ if (!expandRow[i]) >+ expandCount++; >+ expandRow[i] = true; >+ } >+ if (data.heightHint != SWT.DEFAULT >+ || !data.grabExcessVerticalSpace) { >+ minHeights[i] = Math.max(minHeights[i], h); >+ } >+ } >+ } >+ } >+ for (int j = 0; j < columnCount; j++) { >+ GridLayoutData data = getData(grid, i, j, rowCount, columnCount, >+ false); >+ if (data != null) { >+ int vSpan = Math.max(1, Math.min(data.verticalSpan, >+ rowCount)); >+ if (vSpan > 1) { >+ int spanHeight = 0, spanMinHeight = 0, spanExpandCount = 0; >+ for (int k = 0; k < vSpan; k++) { >+ spanHeight += heights[i - k]; >+ spanMinHeight += minHeights[i - k]; >+ if (expandRow[i - k]) >+ spanExpandCount++; >+ } >+ if (data.grabExcessVerticalSpace >+ && spanExpandCount == 0) { >+ expandCount++; >+ expandRow[i] = true; >+ } >+ int h = data.cacheHeight - spanHeight - (vSpan - 1) >+ * verticalSpacing; // + data.verticalalIndent >+ if (h > 0) { >+ if (spanExpandCount == 0) { >+ heights[i] += h; >+ } else { >+ int delta = h / spanExpandCount; >+ int remainder = h % spanExpandCount, last = -1; >+ for (int k = 0; k < vSpan; k++) { >+ if (expandRow[i - k]) { >+ heights[last = i - k] += delta; >+ } >+ } >+ if (last > -1) >+ heights[last] += remainder; >+ } >+ } >+ if (data.heightHint != SWT.DEFAULT >+ || !data.grabExcessVerticalSpace) { >+ h = data.cacheHeight - spanMinHeight - (vSpan - 1) >+ * verticalSpacing; // + data.verticalIndent >+ if (h > 0) { >+ if (spanExpandCount == 0) { >+ minHeights[i] += h; >+ } else { >+ int delta = h / spanExpandCount; >+ int remainder = h % spanExpandCount, last = -1; >+ for (int k = 0; k < vSpan; k++) { >+ if (expandRow[i - k]) { >+ minHeights[last = i - k] += delta; >+ } >+ } >+ if (last > -1) >+ minHeights[last] += remainder; >+ } >+ } >+ } >+ } >+ } >+ } >+ } >+ if (height != SWT.DEFAULT && expandCount > 0) { >+ int totalHeight = 0; >+ for (int i = 0; i < rowCount; i++) { >+ totalHeight += heights[i]; >+ } >+ int count = expandCount; >+ int delta = (availableHeight - totalHeight) / count; >+ int remainder = (availableHeight - totalHeight) % count; >+ int last = -1; >+ while (totalHeight != availableHeight) { >+ for (int i = 0; i < rowCount; i++) { >+ if (expandRow[i]) { >+ if (heights[i] + delta > minHeights[i]) { >+ heights[last = i] = heights[i] + delta; >+ } else { >+ heights[i] = minHeights[i]; >+ expandRow[i] = false; >+ count--; >+ } >+ } >+ } >+ if (last > -1) >+ heights[last] += remainder; >+ >+ for (int i = 0; i < rowCount; i++) { >+ for (int j = 0; j < columnCount; j++) { >+ GridLayoutData data = getData(grid, i, j, rowCount, >+ columnCount, false); >+ if (data != null) { >+ int vSpan = Math.max(1, Math.min(data.verticalSpan, >+ rowCount)); >+ if (vSpan > 1) { >+ if (data.heightHint != SWT.DEFAULT >+ || !data.grabExcessVerticalSpace) { >+ int spanHeight = 0, spanExpandCount = 0; >+ for (int k = 0; k < vSpan; k++) { >+ spanHeight += heights[i - k]; >+ if (expandRow[i - k]) >+ spanExpandCount++; >+ } >+ int h = data.cacheHeight - spanHeight >+ - (vSpan - 1) * verticalSpacing; // + >+ // data.verticalIndent >+ if (h > 0) { >+ if (spanExpandCount == 0) { >+ heights[i] += h; >+ } else { >+ int delta2 = h / spanExpandCount; >+ int remainder2 = h >+ % spanExpandCount, last2 = -1; >+ for (int k = 0; k < vSpan; k++) { >+ if (expandRow[i - k]) { >+ heights[last2 = i - k] += delta2; >+ } >+ } >+ if (last2 > -1) >+ heights[last2] += remainder2; >+ } >+ } >+ } >+ } >+ } >+ } >+ } >+ if (count == 0) >+ break; >+ totalHeight = 0; >+ for (int i = 0; i < rowCount; i++) { >+ totalHeight += heights[i]; >+ } >+ delta = (availableHeight - totalHeight) / count; >+ remainder = (availableHeight - totalHeight) % count; >+ last = -1; >+ } >+ } >+ >+ /* Position the IFigures */ >+ if (move) { >+ int gridY = y + marginHeight; >+ for (int i = 0; i < rowCount; i++) { >+ int gridX = x + marginWidth; >+ for (int j = 0; j < columnCount; j++) { >+ GridLayoutData data = getData(grid, i, j, rowCount, columnCount, >+ true); >+ if (data != null) { >+ int hSpan = Math.max(1, Math.min(data.horizontalSpan, >+ columnCount)); >+ int vSpan = Math.max(1, data.verticalSpan); >+ int cellWidth = 0, cellHeight = 0; >+ for (int k = 0; k < hSpan; k++) { >+ cellWidth += widths[j + k]; >+ } >+ for (int k = 0; k < vSpan; k++) { >+ cellHeight += heights[i + k]; >+ } >+ cellWidth += horizontalSpacing * (hSpan - 1); >+ int childX = gridX + data.horizontalIndent; >+ int childWidth = Math.min(data.cacheWidth, cellWidth); >+ switch (data.horizontalAlignment) { >+ case GridLayoutData.CENTER : >+ childX = gridX >+ + Math.max(0, >+ (cellWidth - childWidth) / 2); >+ break; >+ case GridLayoutData.END : >+ childX = gridX >+ + Math.max(0, cellWidth - childWidth); >+ break; >+ case GridLayoutData.FILL : >+ childWidth = cellWidth - data.horizontalIndent; >+ break; >+ } >+ cellHeight += verticalSpacing * (vSpan - 1); >+ int childY = gridY; // + data.verticalIndent; >+ int childHeight = Math >+ .min(data.cacheHeight, cellHeight); >+ switch (data.verticalAlignment) { >+ case GridLayoutData.CENTER : >+ childY = gridY >+ + Math.max(0, >+ (cellHeight - childHeight) / 2); >+ break; >+ case GridLayoutData.END : >+ childY = gridY >+ + Math.max(0, cellHeight - childHeight); >+ break; >+ case GridLayoutData.FILL : >+ childHeight = cellHeight; // - >+ // data.verticalIndent; >+ break; >+ } >+ IFigure child = grid[i][j]; >+ if (child != null) { >+ // following param could be replaced by >+ // Rectangle.SINGLETON >+ child.setBounds(new Rectangle(childX, childY, >+ childWidth, childHeight)); >+ } >+ } >+ gridX += widths[j] + horizontalSpacing; >+ } >+ gridY += heights[i] + verticalSpacing; >+ } >+ } >+ >+ // clean up cache >+ for (int i = 0; i < flushLength; i++) { >+ flush[i].cacheWidth = flush[i].cacheHeight = -1; >+ } >+ >+ int totalDefaultWidth = 0; >+ int totalDefaultHeight = 0; >+ for (int i = 0; i < columnCount; i++) { >+ totalDefaultWidth += widths[i]; >+ } >+ for (int i = 0; i < rowCount; i++) { >+ totalDefaultHeight += heights[i]; >+ } >+ totalDefaultWidth += horizontalSpacing * (columnCount - 1) >+ + marginWidth * 2; >+ totalDefaultHeight += verticalSpacing * (rowCount - 1) + marginHeight >+ * 2; >+ return new Dimension(totalDefaultWidth, totalDefaultHeight); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.draw2d.LayoutManager#getConstraint(org.eclipse.draw2d.IFigure) >+ */ >+ public Object getConstraint(IFigure child) { >+ return constraints.get(child); >+ } >+ >+ /** >+ * Sets the layout constraint of the given figure. The constraints can only >+ * be of type {@link GridLayoutData}. >+ * >+ * @see LayoutManager#setConstraint(IFigure, Object) >+ */ >+ public void setConstraint(IFigure figure, Object newConstraint) { >+ super.setConstraint(figure, newConstraint); >+ if (newConstraint != null) >+ { >+ constraints.put(figure, newConstraint); >+ >+ } >+ } >+ >+} >Index: src/org/eclipse/gmf/internal/codegen/draw2d/GridLayoutData.java >=================================================================== >RCS file: src/org/eclipse/gmf/internal/codegen/draw2d/GridLayoutData.java >diff -N src/org/eclipse/gmf/internal/codegen/draw2d/GridLayoutData.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/gmf/internal/codegen/draw2d/GridLayoutData.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,453 @@ >+package org.eclipse.gmf.internal.codegen.draw2d; >+ >+import org.eclipse.draw2d.IFigure; >+import org.eclipse.draw2d.geometry.Dimension; >+import org.eclipse.swt.SWT; >+ >+ >+/** >+ * <code>GridLayoutData</code> is the layout data object associated with >+ * <code>GridLayout</code>. To set a <code>GridLayoutData</code> object into a >+ * <code>Figure</code>, you use the <code>setConstraint()</code> method of >+ * <code>GridLayout</code> to map the <code>Figure</code> to its layout >+ * <code>GridLayoutData</code>. >+ * <p> >+ * There are two ways to create a <code>GridLayoutData</code> object with certain >+ * fields set. The first is to set the fields directly, like this: >+ * >+ * <pre> >+ * GridLayoutData gridData = new GridLayoutData(); >+ * gridData.horizontalAlignment = GridLayoutData.FILL; >+ * gridData.grabExcessHorizontalSpace = true; >+ * >+ * // associate the figure to the GridLayoutData object >+ * myGridlayout.setConstraint(myFigure, gridData); >+ * </pre> >+ * >+ * The second is to take advantage of convenience style bits defined by >+ * <code>GridLayoutData</code>: >+ * >+ * <pre> >+ * GridLayoutData gridData = new GridLayoutData(GridLayoutData.HORIZONTAL_ALIGN_FILL | GridLayoutData.GRAB_HORIZONTAL); >+ * </pre> >+ * >+ * </p> >+ * <p> >+ * NOTE: Do not reuse <code>GridLayoutData</code> objects. Every child in the parent >+ * <code>Figure</code> that is managed by the <code>GridLayout</code> must >+ * have a unique <code>GridLayoutData</code> object. If the layout data for a Grid >+ * member in a <code>GridLayout</code> is null at layout time, a unique >+ * <code>GridLayoutData</code> object is created for it. >+ * </p> >+ * >+ * [GMF]: NOTE: The set of the ALIGNMENT constants is changed in this class >+ * comparing to original version to match the set of constants in the generated >+ * code. E.g, <code>GridLayoutData.BEGINNING = SWT.BEGINNING - 1</code>. >+ * Thus, this implementation is NOT intended to use SWT.* constants for >+ * alignment. >+ * >+ * @see GridLayout >+ */ >+public final class GridLayoutData { >+ /** >+ * verticalAlignment specifies how figures will be positioned vertically >+ * within a cell. >+ * >+ * The default value is CENTER. >+ * >+ * Possible values are: >+ * >+ * <code>GridLayoutData.BEGINNING = SWT.BEGINNING - 1</code> (or >+ * <code>SWT.TOP - 1</code>): Position the figure at the top of the cell >+ * >+ * <code>GridLayoutData.CENTER = SWT.CENTER - 1</code>: Position the >+ * figure in the vertical center of the cell >+ * >+ * <code>GridLayoutData.END = SWT.END - 1</code> (or >+ * <code>SWT.BOTTOM - 1</code>): Position the figure at the bottom of the >+ * cell >+ * >+ * <code>GridLayoutData.FILL = SWT.FILL - 1</code>: Resize the figure to >+ * fill the cell vertically >+ */ >+ public int verticalAlignment = CENTER; >+ >+ /** >+ * horizontalAlignment specifies how figures will be positioned horizontally >+ * within a cell. >+ * >+ * The default value is BEGINNING. >+ * >+ * Possible values are: >+ * >+ * <code>GridLayoutData.BEGINNING = SWT.BEGINNING - 1</code> (or >+ * <code>SWT.TOP - 1</code>): Position the figure at the left of the cell >+ * >+ * <code>GridLayoutData.CENTER = SWT.CENTER - 1</code>: Position the >+ * figure in the horizontal center of the cell >+ * >+ * <code>GridLayoutData.END = SWT.END - 1</code> (or >+ * <code>SWT.BOTTOM - 1</code>): Position the figure at the right of the >+ * cell >+ * >+ * <code>GridLayoutData.FILL = SWT.FILL - 1</code>: : Resize the figure >+ * to fill the cell horizontally >+ */ >+ public int horizontalAlignment = BEGINNING; >+ >+ /** >+ * widthHint specifies a minimum width for the column. A value of >+ * SWT.DEFAULT indicates that no minimum width is specified. >+ * >+ * The default value is SWT.DEFAULT. >+ */ >+ public int widthHint = SWT.DEFAULT; >+ >+ /** >+ * heightHint specifies a minimum height for the row. A value of >+ * SWT.DEFAULT indicates that no minimum height is specified. >+ * >+ * The default value is SWT.DEFAULT. >+ */ >+ public int heightHint = SWT.DEFAULT; >+ >+ /** >+ * horizontalIndent specifies the number of pixels of indentation >+ * that will be placed along the left side of the cell. >+ * >+ * The default value is 0. >+ */ >+ public int horizontalIndent = 0; >+ >+ /** >+ * horizontalSpan specifies the number of column cells that the figure >+ * will take up. >+ * >+ * The default value is 1. >+ */ >+ public int horizontalSpan = 1; >+ >+ /** >+ * verticalSpan specifies the number of row cells that the figure >+ * will take up. >+ * >+ * The default value is 1. >+ */ >+ public int verticalSpan = 1; >+ >+ /** >+ * grabExcessHorizontalSpace specifies whether the cell will be made >+ * wide enough to fit the remaining horizontal space. >+ * >+ * The default value is false. >+ */ >+ public boolean grabExcessHorizontalSpace = false; >+ >+ /** >+ * grabExcessVerticalSpace specifies whether the cell will be made >+ * tall enough to fit the remaining vertical space. >+ * >+ * The default value is false. >+ */ >+ public boolean grabExcessVerticalSpace = false; >+ >+ /** >+ * Value for horizontalAlignment or verticalAlignment. >+ * Position the figure at the top or left of the cell. >+ */ >+ public static final int BEGINNING = 0; //SWT.BEGINNING - 1; >+ >+ /** >+ * Value for horizontalAlignment or verticalAlignment. >+ * Position the figure in the vertical or horizontal center of the cell >+ */ >+ public static final int CENTER = 1; >+ >+ /** >+ * Value for horizontalAlignment or verticalAlignment. >+ * Position the figure at the bottom or right of the cell >+ */ >+ public static final int END = 2; >+ >+ /** >+ * Value for horizontalAlignment or verticalAlignment. >+ * Resize the figure to fill the cell horizontally or vertically. >+ */ >+ public static final int FILL = 3; //SWT.FILL - 1; >+ >+ /** >+ * Style bit for <code>new GridLayoutData(int)</code>. >+ * Position the figure at the top of the cell. >+ * Not recommended. Use >+ * <code>new GridLayoutData(int, GridLayoutData.BEGINNING, boolean, boolean)</code> >+ * instead. >+ */ >+ public static final int VERTICAL_ALIGN_BEGINNING = 1 << 1; >+ >+ /** >+ * Style bit for <code>new GridLayoutData(int)</code> to position the >+ * figure in the vertical center of the cell. >+ * Not recommended. Use >+ * <code>new GridLayoutData(int, GridLayoutData.CENTER, boolean, boolean)</code> >+ * instead. >+ */ >+ public static final int VERTICAL_ALIGN_CENTER = 1 << 2; >+ >+ /** >+ * Style bit for <code>new GridLayoutData(int)</code> to position the >+ * figure at the bottom of the cell. >+ * Not recommended. Use >+ * <code>new GridLayoutData(int, GridLayoutData.END, boolean, boolean)</code> >+ * instead. >+ */ >+ public static final int VERTICAL_ALIGN_END = 1 << 3; >+ >+ /** >+ * Style bit for <code>new GridLayoutData(int)</code> to resize the >+ * figure to fill the cell vertically. >+ * Not recommended. Use >+ * <code>new GridLayoutData(int, GridLayoutData.FILL, boolean, boolean)</code> >+ * instead >+ */ >+ public static final int VERTICAL_ALIGN_FILL = 1 << 4; >+ >+ /** >+ * Style bit for <code>new GridLayoutData(int)</code> to position the >+ * figure at the left of the cell. >+ * Not recommended. Use >+ * <code>new GridLayoutData(GridLayoutData.BEGINNING, int, boolean, boolean)</code> >+ * instead. >+ */ >+ public static final int HORIZONTAL_ALIGN_BEGINNING = 1 << 5; >+ >+ /** >+ * Style bit for <code>new GridLayoutData(int)</code> to position the >+ * figure in the horizontal center of the cell. >+ * Not recommended. Use >+ * <code>new GridLayoutData(GridLayoutData.CENTER, int, boolean, boolean)</code> >+ * instead. >+ */ >+ public static final int HORIZONTAL_ALIGN_CENTER = 1 << 6; >+ >+ /** >+ * Style bit for <code>new GridLayoutData(int)</code> to position the >+ * figure at the right of the cell. >+ * Not recommended. Use >+ * <code>new GridLayoutData(GridLayoutData.END, int, boolean, boolean)</code> >+ * instead. >+ */ >+ public static final int HORIZONTAL_ALIGN_END = 1 << 7; >+ >+ /** >+ * Style bit for <code>new GridLayoutData(int)</code> to resize the >+ * figure to fill the cell horizontally. >+ * Not recommended. Use >+ * <code>new GridLayoutData(GridLayoutData.FILL, int, boolean, boolean)</code> >+ * instead. >+ */ >+ public static final int HORIZONTAL_ALIGN_FILL = 1 << 8; >+ >+ /** >+ * Style bit for <code>new GridLayoutData(int)</code> to resize the >+ * figure to fit the remaining horizontal space. >+ * Not recommended. Use >+ * <code>new GridLayoutData(int, int, true, boolean)</code> >+ * instead. >+ */ >+ public static final int GRAB_HORIZONTAL = 1 << 9; >+ >+ /** >+ * Style bit for <code>new GridLayoutData(int)</code> to resize the >+ * figure to fit the remaining vertical space. >+ * Not recommended. Use >+ * <code>new GridLayoutData(int, int, boolean, true)</code> >+ * instead. >+ */ >+ public static final int GRAB_VERTICAL = 1 << 10; >+ >+ /** >+ * Style bit for <code>new GridLayoutData(int)</code> to resize the >+ * figure to fill the cell vertically and to fit the remaining >+ * vertical space. >+ * FILL_VERTICAL = VERTICAL_ALIGN_FILL | GRAB_VERTICAL >+ * Not recommended. Use >+ * <code>new GridLayoutData(int, GridLayoutData.FILL, boolean, true)</code> >+ * instead. >+ */ >+ public static final int FILL_VERTICAL = VERTICAL_ALIGN_FILL | GRAB_VERTICAL; >+ >+ /** >+ * Style bit for <code>new GridLayoutData(int)</code> to resize the >+ * figure to fill the cell horizontally and to fit the remaining >+ * horizontal space. >+ * FILL_HORIZONTAL = HORIZONTAL_ALIGN_FILL | GRAB_HORIZONTAL >+ * Not recommended. Use >+ * <code>new GridLayoutData(GridLayoutData.FILL, int, true, boolean)</code> >+ * instead. >+ */ >+ public static final int FILL_HORIZONTAL = HORIZONTAL_ALIGN_FILL | GRAB_HORIZONTAL; >+ >+ /** >+ * Style bit for <code>new GridLayoutData(int)</code> to resize the >+ * figure to fill the cell horizontally and vertically and >+ * to fit the remaining horizontal and vertical space. >+ * FILL_BOTH = FILL_VERTICAL | FILL_HORIZONTAL >+ * Not recommended. Use >+ * <code>new GridLayoutData(GridLayoutData.FILL, GridLayoutData.FILL, true, true)</code> >+ * instead. >+ */ >+ public static final int FILL_BOTH = FILL_VERTICAL | FILL_HORIZONTAL; >+ >+ int cacheWidth = -1, cacheHeight = -1; >+ int [][] cache = new int[2][4]; >+ int cacheIndex = -1; >+ >+/** >+ * Constructs a new instance of GridLayoutData using >+ * default values. >+ */ >+public GridLayoutData () { >+ super (); >+} >+ >+/** >+ * Constructs a new instance based on the GridLayoutData style. >+ * This constructor is not recommended. >+ * >+ * @param style the GridLayoutData style >+ */ >+public GridLayoutData (int style) { >+ super (); >+ if ((style & VERTICAL_ALIGN_BEGINNING) != 0) verticalAlignment = BEGINNING; >+ if ((style & VERTICAL_ALIGN_CENTER) != 0) verticalAlignment = CENTER; >+ if ((style & VERTICAL_ALIGN_FILL) != 0) verticalAlignment = FILL; >+ if ((style & VERTICAL_ALIGN_END) != 0) verticalAlignment = END; >+ if ((style & HORIZONTAL_ALIGN_BEGINNING) != 0) horizontalAlignment = BEGINNING; >+ if ((style & HORIZONTAL_ALIGN_CENTER) != 0) horizontalAlignment = CENTER; >+ if ((style & HORIZONTAL_ALIGN_FILL) != 0) horizontalAlignment = FILL; >+ if ((style & HORIZONTAL_ALIGN_END) != 0) horizontalAlignment = END; >+ grabExcessHorizontalSpace = (style & GRAB_HORIZONTAL) != 0; >+ grabExcessVerticalSpace = (style & GRAB_VERTICAL) != 0; >+} >+ >+/** >+ * Constructs a new instance of GridLayoutData according to the parameters. >+ * >+ * @param horizontalAlignment how figure will be positioned horizontally within a cell >+ * @param verticalAlignment how figure will be positioned vertically within a cell >+ * @param grabExcessHorizontalSpace whether cell will be made wide enough to fit the remaining horizontal space >+ * @param grabExcessVerticalSpace whether cell will be made high enough to fit the remaining vertical space >+ * >+ */ >+public GridLayoutData (int horizontalAlignment, int verticalAlignment, boolean grabExcessHorizontalSpace, boolean grabExcessVerticalSpace) { >+ this (horizontalAlignment, verticalAlignment, grabExcessHorizontalSpace, grabExcessVerticalSpace, 1, 1); >+} >+ >+/** >+ * Constructs a new instance of GridLayoutData according to the parameters. >+ * >+ * @param horizontalAlignment how figure will be positioned horizontally within a cell >+ * @param verticalAlignment how figure will be positioned vertically within a cell >+ * @param grabExcessHorizontalSpace whether cell will be made wide enough to fit the remaining horizontal space >+ * @param grabExcessVerticalSpace whether cell will be made high enough to fit the remaining vertical space >+ * @param horizontalSpan the number of column cells that the figure will take up >+ * @param verticalSpan the number of row cells that the figure will take up >+ * >+ */ >+public GridLayoutData (int horizontalAlignment, int verticalAlignment, boolean grabExcessHorizontalSpace, boolean grabExcessVerticalSpace, int horizontalSpan, int verticalSpan) { >+ super (); >+ this.horizontalAlignment = horizontalAlignment; >+ this.verticalAlignment = verticalAlignment; >+ this.grabExcessHorizontalSpace = grabExcessHorizontalSpace; >+ this.grabExcessVerticalSpace = grabExcessVerticalSpace; >+ this.horizontalSpan = horizontalSpan; >+ this.verticalSpan = verticalSpan; >+} >+ >+/** >+ * Constructs a new instance of GridLayoutData according to the parameters. >+ * A value of SWT.DEFAULT indicates that no minimum width or >+ * no minumum height is specified. >+ * >+ * @param width a minimum width for the column >+ * @param height a minimum height for the row >+ * >+ */ >+public GridLayoutData (int width, int height) { >+ super (); >+ this.widthHint = width; >+ this.heightHint = height; >+} >+ >+Dimension computeSize (IFigure figure, boolean flushCache) { >+ if (cacheWidth != -1 && cacheHeight != -1) { >+ return new Dimension (cacheWidth, cacheHeight); >+ } >+ for (int i = 0; i < cacheIndex + 1; i++) { >+ if (cache [i][0] == widthHint && cache [i][1] == heightHint) { >+ cacheWidth = cache [i][2]; >+ cacheHeight = cache [i][3]; >+ return new Dimension (cacheWidth, cacheHeight); >+ } >+ } >+ >+ Dimension size = figure.getPreferredSize(widthHint,heightHint); >+ if (widthHint!=-1) size.width = widthHint; >+ if (heightHint!=-1) size.height = heightHint; >+ >+ if (cacheIndex < cache.length - 1) cacheIndex++; >+ cache [cacheIndex][0] = widthHint; >+ cache [cacheIndex][1] = heightHint; >+ cacheWidth = cache [cacheIndex][2] = size.width; >+ cacheHeight = cache [cacheIndex][3] = size.height; >+ return size; >+} >+ >+ >+void flushCache () { >+ cacheWidth = cacheHeight = -1; >+ cacheIndex = -1; >+} >+ >+String getName () { >+ String string = getClass ().getName (); >+ int index = string.lastIndexOf ('.'); >+ if (index == -1) return string; >+ return string.substring (index + 1, string.length ()); >+} >+ >+public String toString () { >+ >+ String hAlign = ""; >+ switch (horizontalAlignment) { >+ case FILL: hAlign = "GridLayoutData.FILL"; break; >+ case BEGINNING: hAlign = "GridLayoutData.BEGINNING"; break; >+ case END: hAlign = "GridLayoutData.LEFT"; break; >+ case CENTER: hAlign = "GridLayoutData.CENTER"; break; >+ default: hAlign = "Undefined "+horizontalAlignment; break; >+ } >+ String vAlign = ""; >+ switch (verticalAlignment) { >+ case FILL: vAlign = "GridLayoutData.FILL"; break; >+ case BEGINNING: vAlign = "GridLayoutData.BEGINNING"; break; >+ case END: vAlign = "GridLayoutData.END"; break; >+ case CENTER: vAlign = "GridLayoutData.CENTER"; break; >+ default: vAlign = "Undefined "+verticalAlignment; break; >+ } >+ String string = getName()+" {"; >+ string += "horizontalAlignment="+hAlign+" "; >+ if (horizontalIndent != 0) string += "horizontalIndent="+horizontalIndent+" "; >+ if (horizontalSpan != 1) string += "horizontalSpan="+horizontalSpan+" "; >+ if (grabExcessHorizontalSpace) string += "grabExcessHorizontalSpace="+grabExcessHorizontalSpace+" "; >+ if (widthHint != SWT.DEFAULT) string += "widthHint="+widthHint+" "; >+ string += "verticalAlignment="+vAlign+" "; >+ if (verticalSpan != 1) string += "verticalSpan="+verticalSpan+" "; >+ if (grabExcessVerticalSpace) string += "grabExcessVerticalSpace="+grabExcessVerticalSpace+" "; >+ if (heightHint != SWT.DEFAULT) string += "heightHint="+heightHint+" "; >+ string = string.trim(); >+ string += "}"; >+ return string; >+ >+} >+ >+} >Index: src/org/eclipse/uml2/diagram/common/draw2d/RequiredInterfaceDecoration.java >=================================================================== >RCS file: src/org/eclipse/uml2/diagram/common/draw2d/RequiredInterfaceDecoration.java >diff -N src/org/eclipse/uml2/diagram/common/draw2d/RequiredInterfaceDecoration.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/uml2/diagram/common/draw2d/RequiredInterfaceDecoration.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,77 @@ >+/* >+ * Copyright (c) 2006 Borland Software Corporation >+ * >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Michael Golubev (Borland) - initial API and implementation >+ */ >+ >+package org.eclipse.uml2.diagram.common.draw2d; >+ >+import org.eclipse.draw2d.Graphics; >+import org.eclipse.draw2d.PolylineDecoration; >+import org.eclipse.draw2d.geometry.Point; >+import org.eclipse.draw2d.geometry.PointList; >+import org.eclipse.draw2d.geometry.Rectangle; >+ >+public class RequiredInterfaceDecoration extends PolylineDecoration { >+ private static final Point TEMP_POINT = new Point(); >+ private static final Rectangle TEMP_RECTANGLE = new Rectangle(); >+ >+ private final int GAP = 3; >+ private int myRadius; >+ private int myAngle; >+ >+ public RequiredInterfaceDecoration(){ >+ setRadius(1); >+ setScale(1, 1); >+ } >+ >+ public void setRadius(int radius){ >+ myRadius = radius; >+ setTemplate(new PointList(new int[] {radius - GAP, 0} )); >+ } >+ >+ @Override >+ public Rectangle getBounds() { >+ if (bounds == null){ >+ //implicitly sets bounds >+ super.getBounds(); >+ computeArcBounds(TEMP_RECTANGLE); >+ TEMP_RECTANGLE.expand(1, 1); >+ bounds.union(TEMP_RECTANGLE); >+ } >+ return bounds; >+ } >+ >+ @Override >+ public void setRotation(double angle) { >+ super.setRotation(angle); >+ myAngle = (int) (angle * 180 / Math.PI); >+ } >+ >+ @Override >+ protected void fillShape(Graphics g) { >+ //do nothing >+ } >+ >+ @Override >+ protected void outlineShape(Graphics g) { >+ computeArcBounds(TEMP_RECTANGLE); >+ g.drawArc(TEMP_RECTANGLE, -myAngle + 90, 180); >+ } >+ >+ private void computeArcBounds(Rectangle output){ >+ if (getPoints().size() == 0){ >+ output.setSize(0, 0); >+ return; >+ } >+ getPoints().getPoint(TEMP_POINT, 0); >+ output.setLocation(TEMP_POINT.x - myRadius, TEMP_POINT.y - myRadius); >+ output.setSize(2 * myRadius, 2 * myRadius); >+ } >+} >Index: .project >=================================================================== >RCS file: .project >diff -N .project >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ .project 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,28 @@ >+<?xml version="1.0" encoding="UTF-8"?> >+<projectDescription> >+ <name>org.eclipse.uml2.diagram.common</name> >+ <comment></comment> >+ <projects> >+ </projects> >+ <buildSpec> >+ <buildCommand> >+ <name>org.eclipse.jdt.core.javabuilder</name> >+ <arguments> >+ </arguments> >+ </buildCommand> >+ <buildCommand> >+ <name>org.eclipse.pde.ManifestBuilder</name> >+ <arguments> >+ </arguments> >+ </buildCommand> >+ <buildCommand> >+ <name>org.eclipse.pde.SchemaBuilder</name> >+ <arguments> >+ </arguments> >+ </buildCommand> >+ </buildSpec> >+ <natures> >+ <nature>org.eclipse.pde.PluginNature</nature> >+ <nature>org.eclipse.jdt.core.javanature</nature> >+ </natures> >+</projectDescription>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 80318
:
52154
|
52848
|
52849
| 52850