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);
}
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);
}
}
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;
}
}
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;
}
}
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();
}
}
Aggregations