use of org.apache.hop.core.gui.plugin.key.GuiOsxKeyboardShortcut in project hop by apache.
the class HopImportGuiPlugin method menuToolsImport.
@GuiMenuElement(root = HopGui.ID_MAIN_MENU, id = ID_MAIN_MENU_FILE_IMPORT, label = "i18n::HopGuiImport.Menu.Item", image = "kettle-logo.svg", parentId = HopGui.ID_MAIN_MENU_FILE, separator = true)
@GuiKeyboardShortcut(control = true, key = 'i')
@GuiOsxKeyboardShortcut(command = true, key = 'i')
public void menuToolsImport() {
HopGui hopGui = HopGui.getInstance();
try {
// Import using this Kettle import plugin...
//
KettleImport kettleImport = new KettleImport();
kettleImport.init(hopGui.getVariables(), hopGui.getLog());
KettleImportDialog dialog = new KettleImportDialog(hopGui.getShell(), hopGui.getVariables(), kettleImport);
dialog.open();
} catch (Exception e) {
new ErrorDialog(hopGui.getShell(), "Error", "Error importing from Kettle", e);
}
}
use of org.apache.hop.core.gui.plugin.key.GuiOsxKeyboardShortcut in project hop by apache.
the class HopGuiPipelineGraph method openReferencedObject.
@GuiKeyboardShortcut(key = 'z')
@GuiOsxKeyboardShortcut(key = 'z')
public void openReferencedObject() {
if (lastMove != null) {
// Hide the tooltip!
hideToolTips();
// Find the transform
TransformMeta transformMeta = pipelineMeta.getTransform(lastMove.x, lastMove.y, iconSize);
if (transformMeta != null) {
// Open referenced object...
//
ITransformMeta iTransformMeta = transformMeta.getTransform();
String[] objectDescriptions = iTransformMeta.getReferencedObjectDescriptions();
if (objectDescriptions == null || objectDescriptions.length == 0) {
return;
}
//
if (objectDescriptions.length == 1) {
HopGuiPipelineTransformContext.openReferencedObject(pipelineMeta, variables, iTransformMeta, objectDescriptions[0], 0);
} else {
// Show Selection dialog...
//
EnterSelectionDialog dialog = new EnterSelectionDialog(getShell(), objectDescriptions, BaseMessages.getString(PKG, "HopGuiPipelineGraph.OpenReferencedObject.Selection.Title"), BaseMessages.getString(PKG, "HopGuiPipelineGraph.OpenReferencedObject.Selection.Message"));
String answer = dialog.open(0);
if (answer != null) {
int index = dialog.getSelectionNr();
HopGuiPipelineTransformContext.openReferencedObject(pipelineMeta, variables, iTransformMeta, answer, index);
}
}
}
}
}
use of org.apache.hop.core.gui.plugin.key.GuiOsxKeyboardShortcut in project hop by apache.
the class HopVfsFileDialog method deleteFile.
@GuiToolbarElement(root = BROWSER_TOOLBAR_PARENT_ID, id = BROWSER_ITEM_ID_DELETE, toolTip = "i18n::HopVfsFileDialog.DeleteFile.Tooltip.Message", image = "ui/images/delete.svg")
// FIXME: Keyboard don't work
@GuiKeyboardShortcut(key = SWT.DEL)
@GuiOsxKeyboardShortcut(key = SWT.DEL)
public void deleteFile() {
FileObject file = getSelectedFileObject();
if (file != null) {
try {
MessageBox box = new MessageBox(shell, SWT.YES | SWT.NO | SWT.ICON_QUESTION);
box.setText(BaseMessages.getString(PKG, "HopVfsFileDialog.DeleteFile.Confirmation.Header"));
box.setMessage(BaseMessages.getString(PKG, "HopVfsFileDialog.DeleteFile.Confirmation.Message") + Const.CR + Const.CR + file.getName());
int answer = box.open();
if ((answer & SWT.YES) != 0) {
// If the selected item to delete is folder, set parent for refresh
if (file.isFolder()) {
wFilename.setText(file.getParent().getName().getURI());
}
boolean deleted = file.delete();
if (deleted) {
refreshBrowser();
}
}
} catch (Exception e) {
showError(BaseMessages.getString(PKG, "HopVfsFileDialog.DeleteFile.Error.Message", file.toString()), e);
}
}
}
use of org.apache.hop.core.gui.plugin.key.GuiOsxKeyboardShortcut in project hop by apache.
the class HopVfsFileDialog method renameFile.
@GuiToolbarElement(root = BROWSER_TOOLBAR_PARENT_ID, id = BROWSER_ITEM_ID_RENAME, toolTip = "i18n::HopVfsFileDialog.RenameFile.Tooltip.Message", image = "ui/images/rename.svg")
// FIXME: Keyboard don't work
@GuiKeyboardShortcut(key = SWT.F2)
@GuiOsxKeyboardShortcut(key = SWT.F2)
public void renameFile() {
FileObject file = getSelectedFileObject();
if (file != null) {
TreeItem item = wBrowser.getSelection()[0];
// The control that will be the editor must be a child of the Tree
Text text = new Text(wBrowser, SWT.BORDER);
text.setText(file.getName().getBaseName());
text.addListener(SWT.FocusOut, event -> text.dispose());
text.addListener(SWT.KeyUp, event -> {
switch(event.keyCode) {
case SWT.CR:
case SWT.KEYPAD_CR:
// If name changed
if (!item.getText().equals(text.getText())) {
try {
// If the selected item to rename is folder, set parent for refresh
if (file.isFolder()) {
wFilename.setText(file.getParent().getName().getURI());
}
FileObject newFile = HopVfs.getFileObject(HopVfs.getFilename(file.getParent()) + "/" + text.getText());
file.moveTo(newFile);
} catch (Exception e) {
showError(BaseMessages.getString(PKG, "HopVfsFileDialog.RenameFile.Error.Message", file), e);
} finally {
text.dispose();
refreshBrowser();
}
}
break;
case SWT.ESC:
text.dispose();
break;
}
});
text.selectAll();
text.setFocus();
wBrowserEditor.setEditor(text, item);
}
}
use of org.apache.hop.core.gui.plugin.key.GuiOsxKeyboardShortcut in project hop by apache.
the class MetadataPerspective method refresh.
@GuiToolbarElement(root = GUI_PLUGIN_TOOLBAR_PARENT_ID, id = TOOLBAR_ITEM_REFRESH, toolTip = "i18n::MetadataPerspective.ToolbarElement.Refresh.Tooltip", image = "ui/images/refresh.svg")
@GuiKeyboardShortcut(key = SWT.F5)
@GuiOsxKeyboardShortcut(key = SWT.F5)
public void refresh() {
try {
tree.setRedraw(false);
tree.removeAll();
// top level: object key
//
IHopMetadataProvider metadataProvider = hopGui.getMetadataProvider();
List<Class<IHopMetadata>> metadataClasses = metadataProvider.getMetadataClasses();
// Sort by name
Collections.sort(metadataClasses, (cl1, cl2) -> {
HopMetadata a1 = HopMetadataUtil.getHopMetadataAnnotation(cl1);
HopMetadata a2 = HopMetadataUtil.getHopMetadataAnnotation(cl2);
return a1.name().compareTo(a2.name());
});
for (Class<IHopMetadata> metadataClass : metadataClasses) {
HopMetadata annotation = HopMetadataUtil.getHopMetadataAnnotation(metadataClass);
Image image = GuiResource.getInstance().getImage(annotation.image(), metadataClass.getClassLoader(), ConstUi.SMALL_ICON_SIZE, ConstUi.SMALL_ICON_SIZE);
TreeItem classItem = new TreeItem(tree, SWT.NONE);
classItem.setText(0, Const.NVL(annotation.name(), ""));
classItem.setImage(image);
classItem.setExpanded(true);
classItem.setData(annotation.key());
classItem.setData(KEY_HELP, annotation.description());
// level 1: object names
//
IHopMetadataSerializer<IHopMetadata> serializer = metadataProvider.getSerializer(metadataClass);
List<String> names = serializer.listObjectNames();
Collections.sort(names);
for (final String name : names) {
TreeItem item = new TreeItem(classItem, SWT.NONE);
item.setText(0, Const.NVL(name, ""));
MetadataEditor<?> editor = this.findEditor(annotation.key(), name);
if (editor != null) {
if (editor.hasChanged()) {
item.setFont(GuiResource.getInstance().getFontBold());
}
}
}
}
TreeUtil.setOptimalWidthOnColumns(tree);
TreeMemory.setExpandedFromMemory(tree, METADATA_PERSPECTIVE_TREE);
tree.setRedraw(true);
} catch (Exception e) {
new ErrorDialog(getShell(), BaseMessages.getString(PKG, "MetadataPerspective.RefreshMetadata.Error.Header"), BaseMessages.getString(PKG, "MetadataPerspective.RefreshMetadata.Error.Message"), e);
}
}
Aggregations