Search in sources :

Example 1 with NotePadMeta

use of org.apache.hop.core.NotePadMeta in project hop by apache.

the class WorkflowMetaTest method shouldUseCoordinatesOfItsTransformsAndNotesWhenCalculatingMinimumPoint.

@Test
public void shouldUseCoordinatesOfItsTransformsAndNotesWhenCalculatingMinimumPoint() {
    Point actionPoint = new Point(500, 500);
    Point notePadMetaPoint = new Point(400, 400);
    ActionMeta actionMeta = mock(ActionMeta.class);
    when(actionMeta.getLocation()).thenReturn(actionPoint);
    NotePadMeta notePadMeta = mock(NotePadMeta.class);
    when(notePadMeta.getLocation()).thenReturn(notePadMetaPoint);
    // empty Workflow return 0 coordinate point
    Point point = workflowMeta.getMinimum();
    assertEquals(0, point.x);
    assertEquals(0, point.y);
    // when Workflow contains a single transform or note, then workflowMeta should return
    // coordinates of it, subtracting borders
    workflowMeta.addAction(0, actionMeta);
    Point actualTransformPoint = workflowMeta.getMinimum();
    assertEquals(actionPoint.x - WorkflowMeta.BORDER_INDENT, actualTransformPoint.x);
    assertEquals(actionPoint.y - WorkflowMeta.BORDER_INDENT, actualTransformPoint.y);
    // when Workflow contains transform or notes, then workflowMeta should return minimal
    // coordinates of them, subtracting borders
    workflowMeta.addNote(notePadMeta);
    Point transformPoint = workflowMeta.getMinimum();
    assertEquals(notePadMetaPoint.x - WorkflowMeta.BORDER_INDENT, transformPoint.x);
    assertEquals(notePadMetaPoint.y - WorkflowMeta.BORDER_INDENT, transformPoint.y);
}
Also used : ActionMeta(org.apache.hop.workflow.action.ActionMeta) Point(org.apache.hop.core.gui.Point) NotePadMeta(org.apache.hop.core.NotePadMeta) Test(org.junit.Test)

Example 2 with NotePadMeta

use of org.apache.hop.core.NotePadMeta in project hop by apache.

the class AsyncWebServiceEditor method createWorkflowFile.

/**
 * Create a new workflow file with a note to explain what's going on
 *
 * @param parent
 */
private void createWorkflowFile(Composite parent) {
    try {
        // Create an empty workflow...
        // 
        WorkflowMeta workflowMeta = new WorkflowMeta();
        // Add a note explaining what's going on.
        // 
        NotePadMeta note = new NotePadMeta("This workflow can set status variables which are picked up when you request the status of this workflow." + Const.CR + "You can use service asyncStatus to query the status.", 150, 350, -1, -1);
        workflowMeta.addNote(note);
        // Save it...
        // 
        HopWorkflowFileType<WorkflowMeta> type = new HopWorkflowFileType<>();
        String filename = BaseDialog.presentFileDialog(// save
        true, parent.getShell(), wFilename, manager.getVariables(), type.getFilterExtensions(), type.getFilterNames(), true);
        if (filename != null) {
            // User specified a pipeline filename
            // 
            String realFilename = manager.getVariables().resolve(filename);
            workflowMeta.setFilename(realFilename);
            workflowMeta.clearChanged();
            HopDataOrchestrationPerspective perspective = HopGui.getDataOrchestrationPerspective();
            // Switch to the perspective
            // 
            perspective.activate();
            // Open it in the Hop GUI
            // 
            HopGui.getDataOrchestrationPerspective().addWorkflow(hopGui, workflowMeta, type);
            // Save the file
            hopGui.fileDelegate.fileSave();
        }
    } catch (Exception e) {
        new ErrorDialog(parent.getShell(), "Error", "Error creating workflow", e);
    }
}
Also used : HopDataOrchestrationPerspective(org.apache.hop.ui.hopgui.perspective.dataorch.HopDataOrchestrationPerspective) HopWorkflowFileType(org.apache.hop.ui.hopgui.file.workflow.HopWorkflowFileType) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) NotePadMeta(org.apache.hop.core.NotePadMeta) WorkflowMeta(org.apache.hop.workflow.WorkflowMeta)

Example 3 with NotePadMeta

use of org.apache.hop.core.NotePadMeta in project hop by apache.

the class AbstractMeta method lowerNote.

/**
 * Lowers a note to the "bottom" of the list by removing the note at the specified index and
 * re-inserting it at the front. Also marks that the notes have changed.
 *
 * @param p the index into the notes list.
 */
public void lowerNote(int p) {
    // if valid index and not first index
    if ((p > 0) && (p < notes.size())) {
        NotePadMeta note = notes.remove(p);
        notes.add(0, note);
        changedNotes = true;
    }
}
Also used : NotePadMeta(org.apache.hop.core.NotePadMeta)

Example 4 with NotePadMeta

use of org.apache.hop.core.NotePadMeta in project hop by apache.

the class AbstractMeta method raiseNote.

/**
 * Raises a note to the "top" of the list by removing the note at the specified index and
 * re-inserting it at the end. Also marks that the notes have changed.
 *
 * @param p the index into the notes list.
 */
public void raiseNote(int p) {
    // if valid index and not last index
    if ((p >= 0) && (p < notes.size() - 1)) {
        NotePadMeta note = notes.remove(p);
        notes.add(note);
        changedNotes = true;
    }
}
Also used : NotePadMeta(org.apache.hop.core.NotePadMeta)

Example 5 with NotePadMeta

use of org.apache.hop.core.NotePadMeta in project hop by apache.

the class HopGuiNotePadDelegate method newNote.

public void newNote(IVariables variables, AbstractMeta meta, int x, int y) {
    String title = BaseMessages.getString(PKG, "PipelineGraph.Dialog.NoteEditor.Title");
    NotePadDialog dd = new NotePadDialog(variables, hopGui.getShell(), title);
    NotePadMeta n = dd.open();
    if (n != null) {
        NotePadMeta npi = new NotePadMeta(n.getNote(), x, y, ConstUi.NOTE_MIN_SIZE, ConstUi.NOTE_MIN_SIZE, n.getFontName(), n.getFontSize(), n.isFontBold(), n.isFontItalic(), n.getFontColorRed(), n.getFontColorGreen(), n.getFontColorBlue(), n.getBackGroundColorRed(), n.getBackGroundColorGreen(), n.getBackGroundColorBlue(), n.getBorderColorRed(), n.getBorderColorGreen(), n.getBorderColorBlue());
        meta.addNote(npi);
        hopGui.undoDelegate.addUndoNew(meta, new NotePadMeta[] { npi }, new int[] { meta.indexOfNote(npi) });
        handler.updateGui();
    }
}
Also used : NotePadDialog(org.apache.hop.ui.hopgui.dialog.NotePadDialog) NotePadMeta(org.apache.hop.core.NotePadMeta)

Aggregations

NotePadMeta (org.apache.hop.core.NotePadMeta)24 Point (org.apache.hop.core.gui.Point)10 HopException (org.apache.hop.core.exception.HopException)8 ActionMeta (org.apache.hop.workflow.action.ActionMeta)8 TransformMeta (org.apache.hop.pipeline.transform.TransformMeta)7 ErrorDialog (org.apache.hop.ui.core.dialog.ErrorDialog)6 ArrayList (java.util.ArrayList)4 PipelineHopMeta (org.apache.hop.pipeline.PipelineHopMeta)4 WorkflowHopMeta (org.apache.hop.workflow.WorkflowHopMeta)4 ITransformMeta (org.apache.hop.pipeline.transform.ITransformMeta)3 HopExtensionPoint (org.apache.hop.core.extension.HopExtensionPoint)2 IPlugin (org.apache.hop.core.plugins.IPlugin)2 HopDataOrchestrationPerspective (org.apache.hop.ui.hopgui.perspective.dataorch.HopDataOrchestrationPerspective)2 Test (org.junit.Test)2 Document (org.w3c.dom.Document)2 Node (org.w3c.dom.Node)2 File (java.io.File)1 EImage (org.apache.hop.core.gui.IGc.EImage)1 IVariables (org.apache.hop.core.variables.IVariables)1 PipelineMeta (org.apache.hop.pipeline.PipelineMeta)1