Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HOP-4213 HOP-4509 #1768

Merged
merged 4 commits into from
Oct 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import org.apache.hop.core.gui.plugin.key.KeyboardShortcut;
import org.apache.hop.core.gui.plugin.menu.GuiMenuElement;
import org.apache.hop.core.gui.plugin.menu.GuiMenuItem;
import org.apache.hop.core.gui.plugin.tab.GuiTab;
import org.apache.hop.core.gui.plugin.tab.GuiTabItem;
import org.apache.hop.core.gui.plugin.toolbar.GuiToolbarElement;
import org.apache.hop.core.gui.plugin.toolbar.GuiToolbarItem;
import org.apache.hop.core.util.TranslateUtil;
Expand All @@ -53,14 +55,14 @@ public class GuiRegistry {
* menu elements stored per ID.
*/
private Map<String, Map<String, GuiMenuItem>> guiMenuMap;

private Map<String, Map<String, GuiToolbarItem>> guiToolbarMap;
private Map<String, Map<String, GuiElements>> dataElementsMap;
private Map<String, List<KeyboardShortcut>> shortCutsMap;
private Map<String, List<GuiAction>> contextActionsMap;
private Map<String, List<GuiActionFilter>> contextActionFiltersMap;
private Map<String, List<GuiCallbackMethod>> callbackMethodsMap;
private Map<String, List<GuiElements>> compositeGuiElements;
private Map<String, List<GuiTabItem>> guiTabsMap;

/**
* The first entry in this map is the HopGui ID Then the maps found are GuiPlugin class names and
Expand All @@ -78,6 +80,7 @@ private GuiRegistry() {
guiPluginObjectsMap = new HashMap<>();
callbackMethodsMap = new HashMap<>();
compositeGuiElements = new HashMap<>();
guiTabsMap = new HashMap<>();
}

public static final GuiRegistry getInstance() {
Expand Down Expand Up @@ -380,6 +383,22 @@ public void addCompositeGuiWidgetElement(
elements.add(child);
}

/** Add a GUI element to the registry.
*
* @param guiPluginClassName
* @param method
* @param guiTab
* @param classLoader
*/
public void addGuiTab(String guiPluginClassName, Method method, GuiTab guiTab, ClassLoader classLoader){
List<GuiTabItem> guiTabItemList =
guiTabsMap.computeIfAbsent(guiTab.parentId(), k -> new ArrayList<>());

GuiTabItem guiTabItem = new GuiTabItem(guiPluginClassName, guiTab, method, classLoader);

guiTabItemList.add(guiTabItem);
}

/**
* Add a GUI element to the registry. If there is no elements objects for the parent ID under
* which the element belongs, one will be added.
Expand Down Expand Up @@ -421,6 +440,15 @@ public void sortAllElements() {
}
}

public Map<String, List<GuiTabItem>> getGuiTabsMap(){
return guiTabsMap;
}

public List<GuiTabItem> findGuiTabItems(String parent){
List<GuiTabItem> guiTabItems = guiTabsMap.get(parent);
return guiTabItems;
}

public void addKeyboardShortcut(
String guiPluginClassName, Method method, GuiKeyboardShortcut shortcut) {
List<KeyboardShortcut> shortcuts =
Expand Down
34 changes: 34 additions & 0 deletions core/src/main/java/org/apache/hop/core/gui/plugin/tab/GuiTab.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.hop.core.gui.plugin.tab;

import java.lang.annotation.*;

@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.METHOD})
public @interface GuiTab {

String type() default "";
String id() default "";
String parentId() default "";
String description() default "";
String targetClass() default "";
int tabPosition() default 0;

}
104 changes: 104 additions & 0 deletions core/src/main/java/org/apache/hop/core/gui/plugin/tab/GuiTabItem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.hop.core.gui.plugin.tab;

import org.apache.hop.core.gui.plugin.BaseGuiElements;

import java.lang.reflect.Method;

public class GuiTabItem extends BaseGuiElements implements Comparable<GuiTabItem>{

private String id;
private String parent;
private String pluginClassName;
private GuiTab guiTab;
private String targetClass;
private Method method;
private ClassLoader classLoader;

public GuiTabItem(String pluginClassName, GuiTab guiTab, Method tabMethod, ClassLoader classLoader){
this.id = guiTab.id();
this.parent = guiTab.parentId();
this.pluginClassName = pluginClassName;
this.targetClass = guiTab.targetClass();
this.guiTab = guiTab;
this.method = tabMethod;
this.classLoader = classLoader;
}

public String getPluginClassName() {
return pluginClassName;
}

public void setPluginClassName(String pluginClassName) {
this.pluginClassName = pluginClassName;
}

public GuiTab getGuiTab() {
return guiTab;
}

public void setGuiTab(GuiTab guiTab) {
this.guiTab = guiTab;
}

public Method getMethod() {
return method;
}

public void setMethod(Method method) {
this.method = method;
}

public ClassLoader getClassLoader() {
return classLoader;
}

public void setClassLoader(ClassLoader classLoader) {
this.classLoader = classLoader;
}

public String getTargetClass() {
return targetClass;
}

public void setTargetClass(String targetClass) {
this.targetClass = targetClass;
}

@Override
public int compareTo(GuiTabItem guiTabItem) {
return id.compareTo(guiTabItem.id);
}

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getParent() {
return parent;
}

public void setParent(String parent) {
this.parent = parent;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

-->
<workflow>
<name>write-read-huge-file</name>
<name_sync_with_filename>Y</name_sync_with_filename>
<description/>
<extended_description/>
<workflow_version/>
<created_user>-</created_user>
<created_date>2022/10/27 10:34:32.295</created_date>
<modified_user>-</modified_user>
<modified_date>2022/10/27 10:34:32.295</modified_date>
<parameters>
</parameters>
<actions>
<action>
<name>Start</name>
<description/>
<type>SPECIAL</type>
<attributes/>
<repeat>N</repeat>
<schedulerType>0</schedulerType>
<intervalSeconds>0</intervalSeconds>
<intervalMinutes>60</intervalMinutes>
<hour>12</hour>
<minutes>0</minutes>
<weekDay>1</weekDay>
<DayOfMonth>1</DayOfMonth>
<parallel>N</parallel>
<xloc>64</xloc>
<yloc>112</yloc>
<attributes_hac/>
</action>
<action>
<name>textfileoutput-huge-file.hpl</name>
<description/>
<type>PIPELINE</type>
<attributes/>
<filename>${PROJECT_HOME}/workflows/textfileoutput-huge-file.hpl</filename>
<params_from_previous>N</params_from_previous>
<exec_per_row>N</exec_per_row>
<clear_rows>N</clear_rows>
<clear_files>N</clear_files>
<set_logfile>N</set_logfile>
<logfile/>
<logext/>
<add_date>N</add_date>
<add_time>N</add_time>
<loglevel>Basic</loglevel>
<set_append_logfile>N</set_append_logfile>
<wait_until_finished>Y</wait_until_finished>
<create_parent_folder>N</create_parent_folder>
<run_configuration>local</run_configuration>
<parameters>
<pass_all_parameters>Y</pass_all_parameters>
</parameters>
<parallel>N</parallel>
<xloc>224</xloc>
<yloc>112</yloc>
<attributes_hac/>
</action>
<action>
<name>csvinput-huge-file.hpl</name>
<description/>
<type>PIPELINE</type>
<attributes/>
<filename>${PROJECT_HOME}/workflows/csvinput-huge-file.hpl</filename>
<params_from_previous>N</params_from_previous>
<exec_per_row>N</exec_per_row>
<clear_rows>N</clear_rows>
<clear_files>N</clear_files>
<set_logfile>N</set_logfile>
<logfile/>
<logext/>
<add_date>N</add_date>
<add_time>N</add_time>
<loglevel>Basic</loglevel>
<set_append_logfile>N</set_append_logfile>
<wait_until_finished>Y</wait_until_finished>
<create_parent_folder>N</create_parent_folder>
<run_configuration>local</run_configuration>
<parameters>
<pass_all_parameters>Y</pass_all_parameters>
</parameters>
<parallel>N</parallel>
<xloc>416</xloc>
<yloc>112</yloc>
<attributes_hac/>
</action>
</actions>
<hops>
<hop>
<from>Start</from>
<to>textfileoutput-huge-file.hpl</to>
<enabled>Y</enabled>
<evaluation>Y</evaluation>
<unconditional>Y</unconditional>
</hop>
<hop>
<from>textfileoutput-huge-file.hpl</from>
<to>csvinput-huge-file.hpl</to>
<enabled>Y</enabled>
<evaluation>Y</evaluation>
<unconditional>N</unconditional>
</hop>
</hops>
<notepads>
<notepad>
<backgroundcolorblue>251</backgroundcolorblue>
<backgroundcolorgreen>232</backgroundcolorgreen>
<backgroundcolorred>201</backgroundcolorred>
<bordercolorblue>90</bordercolorblue>
<bordercolorgreen>58</bordercolorgreen>
<bordercolorred>14</bordercolorred>
<fontbold>N</fontbold>
<fontcolorblue>90</fontcolorblue>
<fontcolorgreen>58</fontcolorgreen>
<fontcolorred>14</fontcolorred>
<fontitalic>N</fontitalic>
<fontname>Noto Sans</fontname>
<fontsize>10</fontsize>
<height>27</height>
<xloc>64</xloc>
<yloc>48</yloc>
<note>Create a 25M rows CSV file and read it back in using the CSV Input parrallel processing. </note>
<width>492</width>
</notepad>
</notepads>
<attributes/>
</workflow>
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.widgets.*;

import javax.ws.rs.core.Form;
import java.beans.PropertyDescriptor;
import java.lang.reflect.Method;
import java.util.Collections;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.apache.hop.core.gui.plugin.key.GuiKeyboardShortcut;
import org.apache.hop.core.gui.plugin.key.GuiOsxKeyboardShortcut;
import org.apache.hop.core.gui.plugin.menu.GuiMenuElement;
import org.apache.hop.core.gui.plugin.tab.GuiTab;
import org.apache.hop.core.gui.plugin.toolbar.GuiToolbarElement;
import org.apache.hop.core.plugins.IPlugin;
import org.apache.hop.core.plugins.IPluginType;
Expand Down Expand Up @@ -148,9 +149,14 @@ public static void initGuiPlugins() throws HopException {
guiRegistry.addCompositeGuiWidgetElement(guiWidgetElement, method, classLoader);
} else {
guiRegistry.addGuiWidgetElement(
guiWidgetElement, method, guiPluginClassName, classLoader);
guiWidgetElement, method, guiPluginClassName, classLoader);
}
}

GuiTab guiTab = method.getAnnotation(GuiTab.class);
if(guiTab != null){
guiRegistry.addGuiTab(guiPluginClassName, method, guiTab, classLoader);
}
}
}

Expand Down
Loading