diff --git a/ui/src/main/java/org/apache/hop/ui/core/widget/TableView.java b/ui/src/main/java/org/apache/hop/ui/core/widget/TableView.java index ace9505c33..08c9a33248 100644 --- a/ui/src/main/java/org/apache/hop/ui/core/widget/TableView.java +++ b/ui/src/main/java/org/apache/hop/ui/core/widget/TableView.java @@ -2665,10 +2665,8 @@ private void setColumnWidthBasedOnTextField(final int colNr, final boolean useVa int strmax = TextSizeUtilFacade.textExtent(str).x + 20; int colmax = tableColumn[colNr].getWidth(); if (strmax > colmax) { - if (!EnvironmentUtils.getInstance().isWeb()) { - if (Const.isOSX() || Const.isLinux()) { - strmax *= 1.4; - } + if (!EnvironmentUtils.getInstance().isWeb() && (Const.isOSX() || Const.isLinux())) { + strmax *= 1.4; } tableColumn[colNr].setWidth(strmax + 30); @@ -3047,14 +3045,14 @@ private boolean isEmpty(int rowNr, int colNr) { if (item != null) { if (colNr >= 0) { String str = item.getText(colNr); - if (str == null || str.length() == 0) { + if (str == null || str.isEmpty()) { empty = true; } } else { empty = true; for (int j = 1; j < table.getColumnCount(); j++) { String str = item.getText(j); - if (str != null && str.length() > 0) { + if (str != null && !str.isEmpty()) { empty = false; } } diff --git a/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/metadata/MetadataPerspective.java b/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/metadata/MetadataPerspective.java index 66472b1113..c1682c391b 100644 --- a/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/metadata/MetadataPerspective.java +++ b/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/metadata/MetadataPerspective.java @@ -17,6 +17,7 @@ package org.apache.hop.ui.hopgui.perspective.metadata; +import java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -116,8 +117,6 @@ public class MetadataPerspective implements IHopPerspective, TabClosable { public static final String TOOLBAR_ITEM_DELETE = "MetadataPerspective-Toolbar-10050-Delete"; public static final String TOOLBAR_ITEM_REFRESH = "MetadataPerspective-Toolbar-10100-Refresh"; - // public static final String CONTEXT_MENU_OPEN = "MetadataPerspective-ContextMenu-10100-Open"; - public static final String KEY_HELP = "Help"; private static final String SUBFOLDERS_ENABLED = "SubFoldersEnabled"; @@ -131,6 +130,8 @@ public class MetadataPerspective implements IHopPerspective, TabClosable { private static final String CONTEXT_MENU_DELETE = "MetadataPerspective-ContextMenu-10050-Delete"; private static final String CONTEXT_MENU_HELP = "MetadataPerspective-ContextMenu-10050-Help"; public static final String PATH = "path"; + public static final String CONST_FOLDER = "FOLDER"; + public static final String CONST_ERROR = "Error"; private static MetadataPerspective instance; @@ -543,18 +544,18 @@ public void onNewMetadata() { @GuiOsxKeyboardShortcut(key = SWT.F3) public void onNewFolder() { String rootFolder = hopGui.getVariables().getVariable("HOP_METADATA_FOLDER"); - if (!rootFolder.endsWith("/") && !rootFolder.endsWith("\\")) { - rootFolder += "/"; + if (!rootFolder.endsWith(File.separator) && !rootFolder.endsWith("\\")) { + rootFolder += File.separator; } TreeItem[] selection = tree.getSelection(); if (selection == null || selection.length == 0) { return; } TreeItem item = selection[0]; - if (!Boolean.valueOf(item.getData(SUBFOLDERS_ENABLED).toString())) { + if (Boolean.FALSE.equals(Boolean.valueOf(item.getData(SUBFOLDERS_ENABLED).toString()))) { new ErrorDialog( getShell(), - "Error", + CONST_ERROR, "Could not create subfolder for this metadata category", new HopException("Could not create subfolder for this metadata category")); return; @@ -624,7 +625,7 @@ public void onEditMetadata() { hopGui.getEventsHandler().fire(HopGuiEvents.MetadataChanged.name()); } catch (Exception e) { - new ErrorDialog(getShell(), "Error", "Error editing metadata", e); + new ErrorDialog(getShell(), CONST_ERROR, "Error editing metadata", e); } } @@ -718,19 +719,19 @@ private String getMetadataObjectName(TreeItem treeItem, Boolean showMetadataClas } String path = treeItem.getData(PATH).toString(); TreeItem parent = treeItem.getParentItem(); - if (showMetadataClassFolder) { + if (Boolean.TRUE.equals(showMetadataClassFolder)) { while (parent != null) { if (parent.getParentItem() == null) { - path = parent.getData() + "/" + path; + path = parent.getData() + File.separator + path; } else { - path = parent.getText(0) + "/" + path; + path = parent.getText(0) + File.separator + path; } parent = parent.getParentItem(); } } else { while (parent != null && parent.getParentItem() != null) { - path = parent.getText(0) + "/" + path; + path = parent.getText(0) + File.separator + path; parent = parent.getParentItem(); } } @@ -745,12 +746,12 @@ private String getMetadataObjectPath(TreeItem treeItem) { private String getMetadataObjectPath(TreeItem treeItem, Boolean showMetadataClassFolder) { String path = treeItem.getData(PATH).toString(); TreeItem parent = treeItem.getParentItem(); - if (showMetadataClassFolder) { + if (Boolean.TRUE.equals(showMetadataClassFolder)) { while (parent != null) { if (parent.getParentItem() == null) { - path = parent.getData() + "/" + path; + path = parent.getData() + File.separator + path; } else { - path = parent.getText(0) + "/" + path; + path = parent.getText(0) + File.separator + path; } parent = parent.getParentItem(); @@ -758,7 +759,7 @@ private String getMetadataObjectPath(TreeItem treeItem, Boolean showMetadataClas } else { while (parent != null && parent.getParentItem() != null) { if (!path.startsWith(parent.getData(PATH).toString())) { - path = parent.getData(PATH) + "/" + path; + path = parent.getData(PATH) + File.separator + path; } parent = parent.getParentItem(); } @@ -851,7 +852,7 @@ public void onDeleteMetadata() { hopGui.getEventsHandler().fire(HopGuiEvents.MetadataDeleted.name()); } catch (Exception e) { - new ErrorDialog(getShell(), "Error", "Error delete metadata", e); + new ErrorDialog(getShell(), CONST_ERROR, "Error delete metadata", e); } } } @@ -886,7 +887,7 @@ public void onHelpMetadata() { PluginRegistry.getInstance().getPlugin(MetadataPluginType.class, annotation.key()); HelpUtils.openHelp(getShell(), plugin); } catch (Exception ex) { - new ErrorDialog(getShell(), "Error", "Error opening URL", ex); + new ErrorDialog(getShell(), CONST_ERROR, "Error opening URL", ex); } } } @@ -963,9 +964,8 @@ public void refresh() { classItem.setImage(image); classItem.setExpanded(true); classItem.setData(annotation.key()); - // classItem.setData(PATH, annotation.key()); classItem.setData(KEY_HELP, annotation.description()); - classItem.setData("type", "FOLDER"); + classItem.setData("type", CONST_FOLDER); classItem.setData(SUBFOLDERS_ENABLED, Boolean.valueOf(annotation.subfoldersEnabled())); // level 1: object names: folders and definitions @@ -1003,12 +1003,11 @@ private void appendChildren( item.setData(SUBFOLDERS_ENABLED, item.getParentItem().getData(SUBFOLDERS_ENABLED)); switch (node.getType()) { case FILE: - item.setImage(GuiResource.getInstance().getImage("ui/images/file.svg")); item.setData("type", "FILE"); break; case FOLDER: item.setImage(GuiResource.getInstance().getImage("ui/images/folder.svg")); - item.setData("type", "FOLDER"); + item.setData("type", CONST_FOLDER); appendChildren(item, node, annotation); break; default: @@ -1054,7 +1053,8 @@ protected void updateSelection() { if (tree.getSelectionCount() > 0) { TreeItem selectedItem = tree.getSelection()[0]; - if (selectedItem.getData("type") == null || selectedItem.getData("type").equals("FOLDER")) { + if (selectedItem.getData("type") == null + || selectedItem.getData("type").equals(CONST_FOLDER)) { objectName = null; type = TreeItemType.FOLDER; } else { @@ -1082,24 +1082,21 @@ protected void updateSelection() { @Override public boolean remove(IHopFileTypeHandler typeHandler) { - if (typeHandler instanceof MetadataEditor editor) { - if (editor.isCloseable()) { - - editors.remove(editor); + if (typeHandler instanceof MetadataEditor editor && editor.isCloseable()) { + editors.remove(editor); - for (CTabItem item : tabFolder.getItems()) { - if (editor.equals(item.getData())) { - item.dispose(); - } + for (CTabItem item : tabFolder.getItems()) { + if (editor.equals(item.getData())) { + item.dispose(); } + } - // Refresh tree to remove bold - // - this.refresh(); + // Refresh tree to remove bold + // + this.refresh(); - // Update Gui menu and toolbar - this.updateGui(); - } + // Update Gui menu and toolbar + this.updateGui(); } return false;