コード例 #1
0
 // TODO add types from the loaded resources
 // traverse deep into the nested packages
 public IContentAssistProcessor getCompletionProcessor(IAdaptable subject) {
   CollaborationUse cu = doAdapt(subject);
   String name = cu.getName() == null ? "" : cu.getName(); // $NON-NLS-1$
   List<Type> types = getTypeProposals(cu);
   LinkedList<String> names = new LinkedList<String>();
   for (Type next : types) {
     names.add(COLLABORATION_USE_FORMAT.format(new Object[] {name, next.getName()}));
   }
   FixedSetCompletionProcessor cp = new FixedSetCompletionProcessor(names);
   cp.setContext(cu);
   return cp;
 }
コード例 #2
0
 public ICommand getParseCommand(IAdaptable element, String newString, int flags) {
   CollaborationUse cu = doAdapt(element);
   if (cu == null) {
     return UnexecutableCommand.INSTANCE;
   }
   if (newString == null) {
     return UnexecutableCommand.INSTANCE;
   }
   Collaboration oldType = cu.getType();
   String oldName = cu.getName() == null ? "" : cu.getName(); // $NON-NLS-1$
   List<Type> types = getTypeProposals(cu);
   try {
     Object[] parsed = COLLABORATION_USE_FORMAT.parse(newString);
     String newName = (String) parsed[0];
     CompositeCommand cc =
         new CompositeCommand(
             CustomMessages.CollaborationUseParser_collaboration_use_name_parser_command);
     if (!oldName.equals(newName)) {
       cc.add(
           new SetValueCommand(
               new SetRequest(cu, UMLPackage.eINSTANCE.getNamedElement_Name(), newName)));
     }
     if (parsed.length < 2) {
       return cc;
     }
     String newType = (String) parsed[1];
     for (Type next : types) {
       if (newType.equals(next.getName()) && !newType.equals(oldType)) {
         cc.add(
             new SetValueCommand(
                 new SetRequest(cu, UMLPackage.eINSTANCE.getCollaborationUse_Type(), next)));
         break;
       }
     }
     return cc;
   } catch (ParseException e) {
   }
   return UnexecutableCommand.INSTANCE;
 }
コード例 #3
0
 public String getEditString(IAdaptable element, int flags) {
   CollaborationUse cu = doAdapt(element);
   String name = cu.getName() == null ? "" : cu.getName(); // $NON-NLS-1$
   String type = cu.getType() == null ? "" : cu.getType().getName(); // $NON-NLS-1$
   return COLLABORATION_USE_FORMAT.format(new Object[] {name, type});
 }