コード例 #1
0
  protected void updateSelection() {
    final ReportSelectionModel selectionModel1 = getSelectionModel();
    if (selectionModel1 == null) {
      setEnabled(false);
      editedDataFactory = null;
      return;
    }

    final Object[] selectedObjects = selectionModel1.getSelectedElements();
    for (int i = 0; i < selectedObjects.length; i++) {
      final Object selectedObject = selectedObjects[i];
      if (selectedObject instanceof ReportQueryNode == false) {
        continue;
      }
      final ReportQueryNode queryNode = (ReportQueryNode) selectedObject;
      final DataFactory dataFactory = queryNode.getDataFactory();

      final DataFactoryMetaData metadata = dataFactory.getMetaData();
      if (metadata.isEditable()) {
        setEnabled(true);
        return;
      }
    }

    setEnabled(false);
  }
コード例 #2
0
  public void actionPerformed(final ActionEvent e) {
    final ReportSelectionModel selectionModel1 = getSelectionModel();
    if (selectionModel1 == null) {
      return;
    }

    final Element[] visualElements = selectionModel1.getSelectedVisualElements();
    if (visualElements.length == 0) {
      return;
    }

    final EditableStyleSheet styleSheet = EditableStyleSheet.create(visualElements);

    final Map<StyleKey, Expression> styleExpressions;
    if (visualElements.length != 1) {
      styleExpressions = null;
    } else {
      styleExpressions = visualElements[0].getStyleExpressions();
    }

    final Component parent = getReportDesignerContext().getParent();
    final Window window = LibSwingUtil.getWindowAncestor(parent);
    final ElementFormatDialog dialog = createDialog(window);
    final ElementFormatUndoEntry.EditResult result =
        dialog.performEdit(getReportDesignerContext(), styleSheet, styleExpressions);
    if (result == null) {
      return;
    }

    final ElementFormatUndoEntry undoEntry = result.process(visualElements);
    getActiveContext()
        .getUndo()
        .addChange(ActionMessages.getString("ElementFormatAction.UndoName"), undoEntry);
  }
コード例 #3
0
  /** Invoked when an action occurs. */
  public void actionPerformed(final ActionEvent e) {
    final Object o = comboBox.getSelectedItem();
    if (o != null && o instanceof String == false) {
      return;
    }
    final String font = (String) o;
    final ReportRenderContext activeContext = getActiveContext();
    if (activeContext == null) {
      return;
    }

    final ReportSelectionModel selectionModel1 = getSelectionModel();
    if (selectionModel1 == null) {
      return;
    }
    final Element[] visualElements = selectionModel1.getSelectedVisualElements();
    final ArrayList<UndoEntry> undos = new ArrayList<UndoEntry>();
    for (int i = 0; i < visualElements.length; i++) {
      final Element visualElement = visualElements[i];
      undos.add(StyleEditUndoEntry.createConditional(visualElement, TextStyleKeys.FONT, font));
      visualElement.getStyle().setStyleProperty(TextStyleKeys.FONT, font);
      visualElement.notifyNodePropertiesChanged();
    }
    getActiveContext()
        .getUndo()
        .addChange(
            ActionMessages.getString("ApplyFontFamilyAction.UndoName"),
            new CompoundUndoEntry(undos.toArray(new UndoEntry[undos.size()])));
  }
コード例 #4
0
  /** Invoked when an action occurs. */
  public void actionPerformed(final ActionEvent e) {
    final ReportSelectionModel model = getSelectionModel();
    if (model == null) {
      return;
    }
    final Element[] visualElements = model.getSelectedVisualElements();
    if (visualElements.length <= 1) {
      return;
    }
    final Element[] carrier = new Element[1];
    final Element[] objects = ModelUtility.filterParents(visualElements);
    final MassElementStyleUndoEntryBuilder builder = new MassElementStyleUndoEntryBuilder(objects);

    long minY = Long.MAX_VALUE;
    long maxY = Long.MIN_VALUE;
    for (int j = 0; j < objects.length; j++) {
      final Element object = objects[j];
      final CachedLayoutData data = ModelUtility.getCachedLayoutData(object);
      final long y1 = data.getY();
      final long y2 = y1 + data.getHeight();
      if (y2 > maxY) {
        maxY = y2;
      }
      if (y1 < minY) {
        minY = y1;
      }
    }

    final long centerPoint = minY + (maxY - minY) / 2;

    for (int j = 0; j < objects.length; j++) {
      final Element object = objects[j];
      final CachedLayoutData data = ModelUtility.getCachedLayoutData(object);
      final long elementCenter = data.getY() + data.getHeight() / 2;

      final long delta = centerPoint - elementCenter;
      if (delta == 0) {
        continue;
      }

      carrier[0] = object;
      final MoveDragOperation mop =
          new MoveDragOperation(
              carrier, ORIGIN_POINT, EmptySnapModel.INSTANCE, EmptySnapModel.INSTANCE);
      mop.update(new Point2D.Double(0, StrictGeomUtility.toExternalValue(delta)), 1);
      mop.finish();
    }
    final MassElementStyleUndoEntry massElementStyleUndoEntry = builder.finish();
    getActiveContext()
        .getUndo()
        .addChange(
            ActionMessages.getString("AlignMiddleAction.UndoName"), massElementStyleUndoEntry);
  }
コード例 #5
0
  protected void updateSelection() {
    super.updateSelection();

    final ReportSelectionModel selectionModel = getSelectionModel();
    if (selectionModel == null) {
      return;
    }
    final Element[] visualElements = selectionModel.getSelectedVisualElements();

    boolean selected;
    if (visualElements.length == 0) {
      selected = false;
    } else {
      selected = true;
      for (int i = 0; i < visualElements.length; i++) {
        final Element visualElement = visualElements[i];
        selected &= visualElement.getStyle().getBooleanStyleProperty(TextStyleKeys.ITALIC);
      }
    }
    setSelected(selected);
  }
コード例 #6
0
  /** Invoked when an action occurs. */
  public void actionPerformed(final ActionEvent e) {
    final ReportSelectionModel selectionModel = getSelectionModel();
    if (selectionModel == null) {
      return;
    }
    final Element[] visualElements = selectionModel.getSelectedVisualElements();
    if (visualElements.length == 0) {
      return;
    }
    final ReportRenderContext activeContext = getActiveContext();
    if (activeContext == null) {
      return;
    }

    Boolean value = Boolean.FALSE;
    final ArrayList<UndoEntry> undos = new ArrayList<UndoEntry>();
    for (int i = 0; i < visualElements.length; i++) {
      final Element element = visualElements[i];
      final ElementStyleSheet styleSheet = element.getStyle();
      if (i == 0) {
        if (styleSheet.getBooleanStyleProperty(TextStyleKeys.ITALIC)) {
          value = Boolean.FALSE;
        } else {
          value = Boolean.TRUE;
        }
      }
      undos.add(StyleEditUndoEntry.createConditional(element, TextStyleKeys.ITALIC, value));
      styleSheet.setStyleProperty(TextStyleKeys.ITALIC, value);
      element.notifyNodePropertiesChanged();
    }
    getActiveContext()
        .getUndo()
        .addChange(
            ActionMessages.getString("ItalicsAction.UndoName"),
            new CompoundUndoEntry(undos.toArray(new UndoEntry[undos.size()])));
  }