Example #1
0
 private EditorCell getNextLeaf(EditorCell current) {
   if (mySide == CellSide.LEFT) {
     return current.getPrevLeaf(CellConditions.SELECTABLE);
   } else {
     return current.getNextLeaf(CellConditions.SELECTABLE);
   }
 }
 private EditorCell createProperty_uugm4e_a0a0(EditorContext editorContext, SNode node) {
   CellProviderWithRole provider = new PropertyCellProvider(node, editorContext);
   provider.setRole("elementName");
   provider.setNoTargetText("<no elementName>");
   provider.setReadOnly(true);
   EditorCell editorCell;
   editorCell = provider.createEditorCell(editorContext);
   editorCell.setCellId("property_elementName");
   {
     Style style = editorCell.getStyle();
     style.set(StyleAttributes.FONT_STYLE, MPSFonts.BOLD);
     style.set(
         StyleAttributes.TEXT_COLOR,
         new AttributeCalculator<Color>() {
           public Color calculate(EditorCell cell) {
             return ElementReference_Editor._Inline_uugm4e_a0a
                 ._StyleParameter_QueryFunction_uugm4e_a1a0a0(
                     (cell == null ? null : cell.getSNode()),
                     (cell == null ? null : cell.getEditorContext()));
           }
         });
   }
   editorCell.setSubstituteInfo(provider.createDefaultSubstituteInfo());
   SNode attributeConcept = provider.getRoleAttribute();
   Class attributeKind = provider.getRoleAttributeClass();
   if (attributeConcept != null) {
     IOperationContext opContext = editorContext.getOperationContext();
     EditorManager manager = EditorManager.getInstanceFromContext(opContext);
     return manager.createRoleAttributeCell(
         editorContext, attributeConcept, attributeKind, editorCell);
   } else return editorCell;
 }
Example #3
0
 private EditorCell findTarget(EditorCell cell) {
   EditorCell toRight = cell.getLeafToRight(CellConditions.SELECTABLE);
   if (toRight != null) {
     return toRight;
   }
   return cell.getNextLeaf(CellConditions.SELECTABLE);
 }
    private boolean canExecute_internal(
        final KeyEvent keyEvent,
        final EditorContext editorContext,
        final SNode node,
        final List<SNode> selectedNodes) {
      if (ListSequence.fromList(selectedNodes).count() != 1) {
        return false;
      }

      // Selected node should be within TypeVariableDeclaration
      SNode selectedNode = ListSequence.fromList(selectedNodes).first();
      SNode typeVarDeclaration =
          SNodeOperations.getAncestor(
              selectedNode,
              "jetbrains.mps.baseLanguage.structure.TypeVariableDeclaration",
              true,
              false);
      if (typeVarDeclaration == null) {
        return false;
      }

      // Next cell should belong to some other SNode, not our typeVarDeclaration
      jetbrains.mps.nodeEditor.cells.EditorCell selectedCell =
          (jetbrains.mps.nodeEditor.cells.EditorCell) editorContext.getSelectedCell();
      jetbrains.mps.nodeEditor.cells.EditorCell nextLeaf = selectedCell.getNextLeaf();
      if (nextLeaf == null) {
        return false;
      }
      SNode nextCellNode = (SNode) nextLeaf.getSNode();
      return nextCellNode != null && nextCellNode != typeVarDeclaration;
    }
 private EditorCell createProperty_40aq2x_b0(EditorContext editorContext, SNode node) {
   CellProviderWithRole provider = new PropertyCellProvider(node, editorContext);
   provider.setRole("entityName");
   provider.setNoTargetText("<no entityName>");
   EditorCell editorCell;
   editorCell = provider.createEditorCell(editorContext);
   editorCell.setCellId("property_entityName");
   Style style = new StyleImpl();
   XmlSS_StyleSheet.applyXmlEntityRef(style, editorCell);
   editorCell.getStyle().putAll(style);
   editorCell.setSubstituteInfo(
       new CompositeSubstituteInfo(
           editorContext,
           provider.getCellContext(),
           new SubstituteInfoPartExt[] {
             new XmlEntityRef_Editor.XmlEntityRef_entityName_cellMenu_a0b0()
           }));
   SNode attributeConcept = provider.getRoleAttribute();
   Class attributeKind = provider.getRoleAttributeClass();
   if (attributeConcept != null) {
     IOperationContext opContext = editorContext.getOperationContext();
     EditorManager manager = EditorManager.getInstanceFromContext(opContext);
     return manager.createRoleAttributeCell(
         editorContext, attributeConcept, attributeKind, editorCell);
   } else return editorCell;
 }
Example #6
0
 public static void addVariablePattern(EditorContext context) {
   EditorCell contextCell = context.getSelectedCell();
   SNode node = contextCell.getSNode();
   SNode linkDeclaration =
       SNodeOperations.cast(
           contextCell.getLinkDeclaration(),
           "jetbrains.mps.lang.structure.structure.LinkDeclaration");
   SNode genuineLinkDeclaration = SModelUtil.getGenuineLinkDeclaration(linkDeclaration);
   if (linkDeclaration != null
       && SPropertyOperations.hasValue(
           genuineLinkDeclaration, "metaClass", "reference", "reference")) {
     String role = SPropertyOperations.getString(genuineLinkDeclaration, "role");
     AttributeOperations.createAndSetAttrbiute(
         node,
         new IAttributeDescriptor.LinkAttribute(
             SConceptOperations.findConceptDeclaration(
                 "jetbrains.mps.lang.pattern.structure.LinkPatternVariableDeclaration"),
             role),
         "jetbrains.mps.lang.pattern.structure.LinkPatternVariableDeclaration");
   } else {
     AttributeOperations.createAndSetAttrbiute(
         node,
         new IAttributeDescriptor.NodeAttribute(
             SConceptOperations.findConceptDeclaration(
                 "jetbrains.mps.lang.pattern.structure.Pattern")),
         "jetbrains.mps.lang.pattern.structure.PatternVariableDeclaration");
   }
 }
 private EditorCell createConceptProperty_89tgy3_b0(EditorContext editorContext, SNode node) {
   CellProviderWithRole provider = new ConceptPropertyCellProvider(node, editorContext);
   provider.setRole("alias");
   provider.setNoTargetText("<no operation>");
   EditorCell editorCell;
   editorCell = provider.createEditorCell(editorContext);
   editorCell.setCellId("conceptProperty_alias");
   BaseLanguageStyle_StyleSheet.getOperator(editorCell).apply(editorCell);
   editorCell.setSubstituteInfo(
       new CompositeSubstituteInfo(
           editorContext,
           provider.getCellContext(),
           new SubstituteInfoPartExt[] {
             new BaseAssignmentExpression_Editor
                 .ReplaceWith_BaseAssignmentExpression_cellMenu_a0b0(),
             new BaseAssignmentExpression_Editor.BaseAssignmentExpression_generic_cellMenu_b0b0()
           }));
   SNode attributeConcept = provider.getRoleAttribute();
   Class attributeKind = provider.getRoleAttributeClass();
   if (attributeConcept != null) {
     IOperationContext opContext = editorContext.getOperationContext();
     EditorManager manager = EditorManager.getInstanceFromContext(opContext);
     return manager.createRoleAttributeCell(
         editorContext, attributeConcept, attributeKind, editorCell);
   } else return editorCell;
 }
Example #8
0
 private EditorCell findTarget(EditorCell cell) {
   EditorCell toLeft = cell.getLeafToLeft(CellConditions.SELECTABLE);
   if (toLeft != null) {
     return toLeft;
   }
   return cell.getPrevLeaf(CellConditions.SELECTABLE);
 }
Example #9
0
 @Override
 public void execute(final jetbrains.mps.openapi.editor.EditorContext context) {
   EditorComponent editorComponent = ((EditorComponent) context.getEditorComponent());
   SelectionManager selectionManager = editorComponent.getSelectionManager();
   Selection selection = selectionManager.getSelection();
   if (selection instanceof SingularSelection) {
     EditorCell selectedCell = ((SingularSelection) selection).getEditorCell();
     SNode selectedNode = selectedCell.getSNode();
     SNode topMostNodeInSingularContainment =
         findTopMostNodeWithSingularContainment(selectedNode);
     if (topMostNodeInSingularContainment != selectedNode) {
       EditorCell nodeCell = editorComponent.findNodeCell(topMostNodeInSingularContainment);
       if (nodeCell != null) {
         editorComponent.pushSelection(nodeCell);
         editorComponent.scrollToCell(nodeCell);
       }
     } else {
       Selection newSelection =
           selectionManager.createRangeSelection(selectedNode, selectedNode);
       if (newSelection instanceof NodeRangeSelection && selectedCell.isBigCell()) {
         newSelection = ((NodeRangeSelection) newSelection).enlargeSelection(myUp);
       }
       if (newSelection != null) {
         selectionManager.pushSelection(newSelection);
         newSelection.ensureVisible();
       }
     }
   } else if (selection instanceof NodeRangeSelection) {
     Selection newSelection = ((NodeRangeSelection) selection).enlargeSelection(myUp);
     if (newSelection != null) {
       selectionManager.pushSelection(newSelection);
       newSelection.ensureVisible();
     }
   }
 }
 private EditorCell createComponent_hs064c_a(EditorContext editorContext, SNode node) {
   AbstractCellProvider provider = new AliasEditorComponent(node);
   EditorCell editorCell = provider.createEditorCell(editorContext);
   Style style = new StyleImpl();
   BaseLanguageStyle_StyleSheet.applyKeyWord(style, editorCell);
   editorCell.getStyle().putAll(style);
   return editorCell;
 }
 public void execute_internal(EditorContext editorContext, SNode node) {
   jetbrains.mps.nodeEditor.cells.EditorCell current =
       (jetbrains.mps.nodeEditor.cells.EditorCell) editorContext.getSelectedCell();
   jetbrains.mps.nodeEditor.cells.EditorCell toSelect =
       current.getPrevLeaf(CellConditions.SELECTABLE);
   SPropertyOperations.set(node, "caseInsensitive", "" + (false));
   editorContext.getEditorComponent().changeSelection(toSelect);
 }
 private EditorCell createComponent_x00uq0_a0(EditorContext editorContext, SNode node) {
   AbstractCellProvider provider = new AliasEditorComponent(node);
   EditorCell editorCell = provider.createEditorCell(editorContext);
   Style style = new StyleImpl();
   PackagingStyles_StyleSheet.applyKeyword(style, editorCell);
   editorCell.getStyle().putAll(style);
   return editorCell;
 }
 private EditorCell createComponent_7agu8k_a0(EditorContext editorContext, SNode node) {
   AbstractCellProvider provider = new AliasEditorComponent(node);
   EditorCell editorCell = provider.createEditorCell(editorContext);
   Style style = new StyleImpl();
   DataFlow_StyleSheet.applyInstruction(style, editorCell);
   editorCell.getStyle().putAll(style);
   return editorCell;
 }
Example #14
0
 private EditorCell findTarget(EditorComponent editorComponent) {
   Selection selection = editorComponent.getSelectionManager().getSelection();
   if (selection == null) {
     return null;
   }
   List<EditorCell> selectedCells = selection.getSelectedCells();
   EditorCell cell = selectedCells.get(selectedCells.size() - 1);
   return cell.getEndCell(CellConditions.SELECTABLE);
 }
 private EditorCell createComponent_1x071y_a0(EditorContext editorContext, SNode node) {
   AbstractCellProvider provider = new _DeprecatedPart(node);
   EditorCell editorCell = provider.createEditorCell(editorContext);
   {
     Style style = editorCell.getStyle();
     style.set(StyleAttributes.INDENT_LAYOUT_NEW_LINE, true);
   }
   return editorCell;
 }
Example #16
0
 private EditorCell createComponent_2jlgx_a0(EditorContext editorContext, SNode node) {
   AbstractCellProvider provider = new IMethodCall_typeArguments(node);
   EditorCell editorCell = provider.createEditorCell(editorContext);
   {
     Style style = editorCell.getStyle();
     style.set(StyleAttributes.SELECTABLE, false);
   }
   return editorCell;
 }
Example #17
0
 private EditorCell createComponent_h8u2a4_c0(EditorContext editorContext, SNode node) {
   AbstractCellProvider provider = new MessageComponent(node);
   EditorCell editorCell = provider.createEditorCell(editorContext);
   {
     Style style = editorCell.getStyle();
     style.set(StyleAttributes.SELECTABLE, false);
   }
   return editorCell;
 }
Example #18
0
    @Override
    protected void paintWithColor(Graphics graphics, EditorCell cell, Color color) {
      int x = cell.getX() + cell.getLeftInset();
      int y = cell.getY() + cell.getTopInset();
      int width = cell.getWidth() - cell.getLeftInset() - cell.getRightInset() - 1;
      int height = cell.getHeight() - cell.getTopInset() - cell.getBottomInset() - 1;

      graphics.setColor(color);
      ColorAndGraphicsUtil.drawDashedRect(graphics, x, y, width, height);
    }
Example #19
0
 private EditorCell createJComponent_fl5ndt_d1b1a(EditorContext editorContext, SNode node) {
   EditorCell editorCell =
       EditorCell_Component.createComponentCell(
           editorContext,
           node,
           PreferencePage_Editor._QueryFunction_JComponent_fl5ndt_a3b1b0(node, editorContext),
           "_fl5ndt_d1b1a");
   editorCell.setCellId("JComponent_fl5ndt_d1b1a");
   return editorCell;
 }
Example #20
0
 private EditorCell createJComponent_4kucyt_e0(EditorContext editorContext, SNode node) {
   EditorCell editorCell =
       EditorCell_Component.createComponentCell(
           editorContext,
           node,
           PngIcon_Editor._QueryFunction_JComponent_4kucyt_a4a(node, editorContext),
           "_4kucyt_e0");
   editorCell.setCellId("JComponent_4kucyt_e0");
   return editorCell;
 }
Example #21
0
 public void execute(jetbrains.mps.openapi.editor.EditorContext context) {
   EditorCell selection = getDeepestSelectedCell(context);
   EditorCell target = findTarget(selection);
   ((EditorComponent) context.getEditorComponent()).changeSelection(target);
   if (target.isPunctuationLayout() && ((EditorCell_Label) target).isCaretPositionAllowed(1)) {
     ((EditorCell_Label) target).setCaretPosition(1);
   } else if (target instanceof EditorCell_Label) {
     EditorCell_Label label = (EditorCell_Label) target;
     label.home();
   }
 }
Example #22
0
 public static boolean isPatternApplicable(EditorContext context) {
   EditorCell contextCell = context.getSelectedCell();
   if (contextCell == null) {
     return false;
   }
   INodeAdapter node = BaseAdapter.fromNode(contextCell.getSNode());
   if (node == null) {
     return false;
   }
   return node.findParent(PatternExpression.class) != null;
 }
 private EditorCell createAttributedNodeCell_73o0fl_c0(EditorContext editorContext, SNode node) {
   IOperationContext opContext = editorContext.getOperationContext();
   EditorManager manager = EditorManager.getInstanceFromContext(opContext);
   EditorCell editorCell = manager.getCurrentAttributedNodeCell();
   {
     Style style = editorCell.getStyle();
     style.set(StyleAttributes.DRAW_BRACKETS, true);
     style.set(StyleAttributes.BRACKETS_COLOR, MPSColors.pink);
   }
   return editorCell;
 }
 public EditorCell createProperty_4406_0_internal(
     EditorContext context, SNode node, CellProviderWithRole aProvider) {
   CellProviderWithRole provider = aProvider;
   provider.setAuxiliaryCellProvider(null);
   EditorCell editorCell = provider.createEditorCell(context);
   setupBasic_Property_4406_0(editorCell, node, context);
   if (editorCell instanceof EditorCell_Label) {
     setupLabel_Property_4406_0((EditorCell_Label) editorCell, node, context);
   }
   editorCell.setSubstituteInfo(provider.createDefaultSubstituteInfo());
   return editorCell;
 }
Example #25
0
 public void execute(jetbrains.mps.openapi.editor.EditorContext context) {
   EditorCell selectedCell = getDeepestSelectedCell(context);
   int caretX = selectedCell.getCaretX();
   EditorComponent editorComponent = (EditorComponent) context.getEditorComponent();
   if (editorComponent.hasLastCaretX()) {
     caretX = editorComponent.getLastCaretX();
   }
   editorComponent.saveLastCaretX(caretX);
   EditorCell target = findTarget(selectedCell, caretX);
   target.setCaretX(caretX);
   editorComponent.changeSelection(target, false);
 }
Example #26
0
 public void execute(jetbrains.mps.openapi.editor.EditorContext context) {
   SelectionManager selectionManager =
       ((EditorComponent) context.getEditorComponent()).getSelectionManager();
   EditorCell cell = findTarget(selectionManager);
   selectionManager.setSelection(cell);
   if (cell.isPunctuationLayout()
       && (cell instanceof EditorCell_Label)
       && ((EditorCell_Label) cell).isCaretPositionAllowed(1)) {
     ((EditorCell_Label) cell).setCaretPosition(1);
   } else {
     cell.home();
   }
 }
Example #27
0
 public boolean canExecute(final KeyEvent keyEvent, final EditorContext editorContext) {
   EditorCell contextCell = editorContext.getContextCell();
   if ((contextCell == null)) {
     return false;
   }
   SNode contextNode = contextCell.getSNode();
   if (contextNode == null) {
     return false;
   }
   if (contextNode.isInstanceOfConcept("jetbrains.mps.build.packaging.structure.Module")) {
     return true;
   }
   return false;
 }
Example #28
0
  private boolean canPasteBefore(EditorCell selectedCell, List<SNode> pasteNodes) {
    if (!selectedCell.isFirstPositionInBigCell()) return false;
    SNode anchor = selectedCell.getSNode();
    if (anchor.getParent() == null) return false;

    NodeAndRole nodeAndRole =
        new NodePaster(pasteNodes).getActualAnchorNode(anchor, anchor.getRoleInParent());
    if (nodeAndRole == null) return false;

    EditorCell targetCell = selectedCell.getEditor().findNodeCell(nodeAndRole.myNode);
    return targetCell != null
        && targetCell.getFirstLeaf(CellConditions.SELECTABLE) == selectedCell
        && new NodePaster(pasteNodes).canPasteRelative(nodeAndRole.myNode);
  }
 private void adjustSelectionToFoldingState(EditorComponent editorComponent) {
   if (isDescendantCellSelected(editorComponent)) {
     editorComponent.clearSelectionStack();
     jetbrains.mps.nodeEditor.cells.EditorCell editorCellToSelect =
         getFirstLeaf(CellConditions.SELECTABLE);
     if (editorCellToSelect != null) {
       editorComponent.changeSelection(editorCellToSelect);
       editorCellToSelect.home();
     } else {
       editorComponent.changeSelection(this);
       home();
     }
   }
 }
Example #30
0
 @Override
 public boolean canExecute(jetbrains.mps.openapi.editor.EditorContext context) {
   // TODO: this check should be reallocated into Selection.canExecuteAction() method once it
   // created
   Selection selection =
       ((EditorComponent) context.getEditorComponent()).getSelectionManager().getSelection();
   if (selection instanceof NodeRangeSelection) {
     return true;
   }
   if (selection instanceof SingularSelection) {
     EditorCell editorCell = ((SingularSelection) selection).getEditorCell();
     return editorCell.getSNode().getParent() != null;
   }
   return false;
 }