From d11239c402eec37ba28edcfa7ea6ca7c1f01147f Mon Sep 17 00:00:00 2001 From: Tuukka Lehtonen Date: Thu, 15 Sep 2016 21:18:22 +0300 Subject: [PATCH] Sync git svn branch with SVN repository r33198. refs #6688 refs #6692 --- .../graph.tg | Bin 16620 -> 16604 bytes .../graph/DocumentUI.pgraph | 5 +- bundles/org.simantics.event.ontology/graph.tg | Bin 12247 -> 12247 bytes .../graph/Event.pgraph | 6 +- .../graph.tg | Bin 11246 -> 11214 bytes .../graph/Selectionview.pgraph | 7 +- .../schema/toolbarCommand.exsd | 25 ++- .../ui/toolbar/ToolBarCommandRegistry.java | 12 ++ .../ui/toolbar/ToolbarContributor.java | 192 +++++++++++++++--- 9 files changed, 216 insertions(+), 31 deletions(-) diff --git a/bundles/org.simantics.document.ui.ontology/graph.tg b/bundles/org.simantics.document.ui.ontology/graph.tg index a32cf12e7b099dd425525150c5fb82651e506854..66fea40388122bceab20c2c2a1b2f110e3a5154e 100644 GIT binary patch literal 16604 zcmbtb378#Km99!}FP-jAI;-rD#UMyxHVA|eI_WGlWTQJIAWL}ty3+m3>sL*^_tFGV z_I+Puk)VJA%A%;FGAaY=j5uz9ql}Jl)~PyOiQjxPlkdB!`p@~# z`A^+@>sHn4s;0rHFf!zMo{#3W@W1$9Q+pIt!+KNCYNL&*ix#18dfHd8vko->JcijkQiz~0`O~P}x)G{4Zd0zOl14VQR%?Y?FpMBqu!J^mE0pX1^AR)& zO^zEK_nG(rUe_amO?tC)baZrfwKQBn#}uox!)OqUX1e?-eL*=Wvbc?NN->$vKy)k z1hvJ7xHO6i@Nrlwq2SsfMz zf&sYiq2)Cb^(~>a_SLqRgMkfh1}t&5RZ(dG^DL}$Ry;@Bl8G33%=<#QZ=_I^>ikdA z@tn!{bI0T)p|x+*I4qsH55U1lWoS(|$* zBlTLJTmwNnNN61>c&z;<*!_b{&1-}>zBe3APKncKTGIkkJe_-m)4Z%+tI0Ahz0sQ+ z4hKqGO0tCAOor_WS&4g_a6K91K!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zpTHDIo4ggXEm1JP944ccIV=^QvBCb z_@xx)THxBJ;!EGSdiI5j*%vNm+q;-;>teQ@i`jN2X%FgT|KK_-8u>NGa?pm6>>H!x z)^^9&>j~QJ+n?oZWx&t&CGS6eO|)aI)>V8(6!SWUhKl&CFq`N*UpNg7EX*dKtzDINHnWs==3ScR%qUk< z0lj&`spZ?d$oJ1Ec3@m6@@!nYQWmeU${U{95xhemIBmb3Q7UVJZ- zf_r@hX~@*O(rV&~VqbUpYI^$xWV z;SP1!r9m3S{;8=6{XUuFb^W35m*lp#7az&$8u|%{Q87D9UdgwoW>S@}`YpM^LUFs0 z>IdZGBI{ZfHxbu$;A^QOTxRN5;~OU4nu*q+TfZY+Eva$YANPND-&(r}Edm!~#rgQv zLDJ?}s>=hx2$W4#{{L4^k%^PEK9H_=q{`&~^xz-(FR^T{wkXAa6nmBMx)f!1l!GPV zJ&zALI|}&RPd`4+hS`Wv0E%QUhMy za-d|eH$EA6J|Nc-J8ify4c{u+7m#82I}}^f1H`P23vpI9uPnDXt}NcZqB`iWd(?N- zkM7cq16IElt7No!uW81t?=KXvzCZi_)OUi!iQkjY+IQdK^`|JdZa<0d+B7VC@yD_F RNAcYc#ar@K^f#^MzX1XUL*M`a diff --git a/bundles/org.simantics.document.ui.ontology/graph/DocumentUI.pgraph b/bundles/org.simantics.document.ui.ontology/graph/DocumentUI.pgraph index cb7cd6498..3ac065d5e 100644 --- a/bundles/org.simantics.document.ui.ontology/graph/DocumentUI.pgraph +++ b/bundles/org.simantics.document.ui.ontology/graph/DocumentUI.pgraph @@ -15,6 +15,7 @@ UI = : L0.Ontology L0.HasResourceClass "org.simantics.document.ui.DocumentUIResource" UI.Functions : L0.Library +UI.Functions.editorLoaded : L0.Function UI.CSSEditorContribution L0.HasLabel "Wiki Style Editor" @@ -187,7 +188,7 @@ UI.Alternative : VIEWS.Alternative UI.NoDocument UI.Sash : VIEWS.SashForm - VIEWS.onLoaded UI.Functions.editorLoaded : L0.Function + VIEWS.onLoaded UI.Functions.editorLoaded VIEWS.Control.layoutData _ : VIEWS.GridLayout.GridData VIEWS.GridLayout.GridData.horizontalGrab true VIEWS.GridLayout.GridData.verticalGrab true @@ -243,7 +244,7 @@ UI.NoDocument : VIEWS.Composite VIEWS.Button.modifier UI.Functions.onCreateDocumentButton : L0.Function UI.Editor : VIEWS.Composite - VIEWS.onLoaded UI.Functions.editorLoaded : L0.Function + VIEWS.onLoaded UI.Functions.editorLoaded L0.HasValueType "WriteGraph => Variable -> Variable -> Boolean" VIEWS.Control.layoutData _ : VIEWS.GridLayout.GridData VIEWS.GridLayout.GridData.horizontalGrab true diff --git a/bundles/org.simantics.event.ontology/graph.tg b/bundles/org.simantics.event.ontology/graph.tg index ffa0b161cf6e8896f219017ea35028b68cb89b64..ed95dc026f154b526b304d49d7a9caa1fda91329 100644 GIT binary patch delta 785 zcmcZ}e?5Lfl4yMf0|P@E5DNkESs>0r<7cDsbI|yCX#9LMejysa2*^(bVrd{g!oaZk zp(rC$eLRp81H>>#B%<+?(D=z{{1h}k$O2^ZKpsTq*F*U%|ABykVRE8`q$bos4C+9+ zFd&u$;xj-j1?BSq>GMDwKDk*!ofE2)Va4Rb65Az_)dm37z|;m$E|yf^yh<{HyVRL=>NU_=;$JT~vNOgEguEgEJc66^-wP#`i$ug904cfq`iJ5EQ;JBzBQC#B2^$ HZQ%j{44+xa delta 779 zcmZ9|y-EW?6b0a$D98pYWo5^Jx`L)r2!s%Vr6`t4LTrR3@dr^cBrh;c`V{j7l15Sq zQ}_T{8Z0bQ`y_e>X2b4TII!R4E}XmbWS+eBLOm3bJ7f)+Ap>%s{7il#KawBF_wX%J zMm|OCZ&)a54O}5<30Ej<_d(V-he}p-6HA*&dP0L-C)dbT@&S3DyzA|2n3q^7h1r*%yDke`8;^_H z{lO(9t?2H`x=p?ypOeqXr{t5owH)UMazs8P$K-AD7TMjLJ!m86b&)VP5D9E+Z&dmR Dfkj!? diff --git a/bundles/org.simantics.event.ontology/graph/Event.pgraph b/bundles/org.simantics.event.ontology/graph/Event.pgraph index c48cda2d8..bec7cfe4f 100644 --- a/bundles/org.simantics.event.ontology/graph/Event.pgraph +++ b/bundles/org.simantics.event.ontology/graph/Event.pgraph @@ -100,7 +100,8 @@ EVENT.Returns EVENT.Event + <-- EVENT.Event + --> EVENT.Event EVENT.NoReturn L0.HasDescription "A tag for marking events that are not expected to be returned. This can be used as a hint for user interfaces." @@ -111,7 +112,8 @@ EVENT.ReturnEvent L0.HasDescription "Indicates that an event is a return event." @L0.defTag @L0.symmetric - <-- EVENT.Event --> EVENT.Event + <-- EVENT.Event + --> EVENT.Event /* // Future ideas: diff --git a/bundles/org.simantics.selectionview.ontology/graph.tg b/bundles/org.simantics.selectionview.ontology/graph.tg index 67160405a4e25e7e519fbbd66f93893c8d118d5e..757158d3bf4087c45981b5ebc2ddcf5d58127e0e 100644 GIT binary patch literal 11214 zcmb`NhkF%e7RE_P$V~$RD4@7R1gxN7L6ij{1c(BGB!F0%+&c-QH#2eOULeX^R_tP3 zdl!4}4HfKt|E1mcJ@-2|hYz#+Jo{{(=Optx=RN1EQ(&fkFb#%xjvF_w1~#sNzuZrK zYZ_)rIn9S1NjWan(%ls9DTQ$sC2`hBp1@x%{M8f{!nhQbqA<&mZKc|rR;m;!gac6w zX%aV6>VE3#dXl7cL|$DS429B0U1?;va+K>t7t%N=9-*8t9HeMp>W^mSx`)|HMO&Zi zibpf+o3c_+3WtzX>9C|u*cBAZ|9u4YB9n2W^Z#@MctA&j$&}e_+r4}D!YmpJFfsXT zVUi9)Q8ymHYTA0kVwh*=wnpLZ1&bCghIc(fbuFu-Y`7SVY-LyAD2sR6+At2&D8DI9 zhQqWp(y=ot77$%m$?3{^cP6{zEpZ`C;k`t>4T9YRa75y0&Ij?TaD6mT3YmL|&Zwa) z-W8@9n_4QWDeHpF^+8)h>?6jO8gVA#i5-~5!6Y477ZtDrpy?BTv#YQL3k~OhI47fW zS3F!UZAc2yKqOuLije_R_uQ(~mFP%{0}QfFKq3RC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G~XC9Awyv5^99(Q=mv9o{LACBEJ$8MQp zZ-nW1xZX9e2G}1k#>g74bFB6EdVI6TH+a0q=URKkaT@a?Uyq~gU>3*R8~V=%s? z6ZK5>n3voVXef+-qk=2UAw_Y=5{>D`-^J0cFSh)#s2`oVUOL1rc9i7IooM{yFY?Aj z$h=*Zgr~DZcZAYd lxovsbUMbX~AEs)x+D3dq6-SDbn`PHV "Resource -> Resource" + + + @@ -123,6 +127,25 @@ TODO: investigate, if the mechanism could be used with menus aswell. + + + + + + + + + + + + + + + + + + + diff --git a/bundles/org.simantics.ui/src/org/simantics/ui/toolbar/ToolBarCommandRegistry.java b/bundles/org.simantics.ui/src/org/simantics/ui/toolbar/ToolBarCommandRegistry.java index 7287c5ae3..2e2ea3f19 100644 --- a/bundles/org.simantics.ui/src/org/simantics/ui/toolbar/ToolBarCommandRegistry.java +++ b/bundles/org.simantics.ui/src/org/simantics/ui/toolbar/ToolBarCommandRegistry.java @@ -74,6 +74,12 @@ public class ToolBarCommandRegistry implements IExtensionChangeHandler { ext.type = el.getAttribute("type"); ext.value = el.getAttribute("value"); ext.contributorId = el.getContributor().getName(); + for (IConfigurationElement param : el.getChildren("parameter")) { + Parameter parameter = new Parameter(); + parameter.name = param.getAttribute("name"); + parameter.value = param.getAttribute("value"); + ext.parameters.add(parameter); + } tracker.registerObject(el.getDeclaringExtension(), ext, IExtensionTracker.REF_STRONG); extensions.add(ext); @@ -111,6 +117,7 @@ public class ToolBarCommandRegistry implements IExtensionChangeHandler { public String value; public String image; public String contributorId; + public List parameters = new ArrayList<>(); public ToolbarCommandExtension(String commandId) { super(); this.commandId = commandId; @@ -122,5 +129,10 @@ public class ToolBarCommandRegistry implements IExtensionChangeHandler { } } + public class Parameter { + public String name; + public String value; + } + } diff --git a/bundles/org.simantics.ui/src/org/simantics/ui/toolbar/ToolbarContributor.java b/bundles/org.simantics.ui/src/org/simantics/ui/toolbar/ToolbarContributor.java index 84413bb46..0f7d3e26d 100644 --- a/bundles/org.simantics.ui/src/org/simantics/ui/toolbar/ToolbarContributor.java +++ b/bundles/org.simantics.ui/src/org/simantics/ui/toolbar/ToolbarContributor.java @@ -11,6 +11,9 @@ import org.eclipse.core.commands.Command; import org.eclipse.core.commands.CommandEvent; import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.commands.ICommandListener; +import org.eclipse.core.commands.IParameter; +import org.eclipse.core.commands.Parameterization; +import org.eclipse.core.commands.ParameterizedCommand; import org.eclipse.core.commands.State; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IConfigurationElement; @@ -42,11 +45,12 @@ import org.eclipse.ui.handlers.RadioState; import org.eclipse.ui.handlers.RegistryToggleState; import org.eclipse.ui.menus.WorkbenchWindowControlContribution; import org.eclipse.ui.part.EditorActionBarContributor; - import org.simantics.db.common.utils.Logger; import org.simantics.ui.internal.Activator; +import org.simantics.ui.toolbar.ToolBarCommandRegistry.Parameter; import org.simantics.ui.toolbar.ToolBarCommandRegistry.ToolbarCommandExtension; import org.simantics.utils.datastructures.MapList; +import org.simantics.utils.ui.ExceptionUtils; /** @@ -64,7 +68,8 @@ import org.simantics.utils.datastructures.MapList; public class ToolbarContributor extends EditorActionBarContributor implements ICommandListener, IPartListener, CommandStateListener, IExecutableExtension { private static boolean DEBUG = false; // Print debug messages to console - private static boolean REUSE = true; // true: Reuse contribution items / false: delete items on dispose + private boolean REUSE = true; // true: Reuse contribution items (leave toolbar in disabled state when editor closes) + // false: delete items on dispose (remove toolbar editor closes) private static final String PLATFORM = "platform:/plugin/"; @@ -81,6 +86,8 @@ public class ToolbarContributor extends EditorActionBarContributor implements IC MapList actions = new MapList(); CommandStateRegistry stateRegistry; + + IPartListener partListener; private Map menus = new HashMap(); @@ -88,6 +95,28 @@ public class ToolbarContributor extends EditorActionBarContributor implements IC service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class); handlerService = (IHandlerService) PlatformUI.getWorkbench().getService(IHandlerService.class); stateRegistry = CommandStateRegistry.getInstance(); + // we need part listener to be notified for other editor activations (i.e editors that do not use this contributor). + partListener = new IPartListener() { + + @Override + public void partOpened(IWorkbenchPart part) {} + + @Override + public void partDeactivated(IWorkbenchPart part) {} + + @Override + public void partClosed(IWorkbenchPart part) {} + + @Override + public void partBroughtToTop(IWorkbenchPart part) {} + + @Override + public void partActivated(IWorkbenchPart part) { + if (part instanceof IEditorPart) + setContext2((IEditorPart)part); + } + }; + PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().addPartListener(partListener); } @@ -106,7 +135,9 @@ public class ToolbarContributor extends EditorActionBarContributor implements IC if ("toolbar".equals(key)) { toolbarId = value; - } + } else if ("hide".equals(key)) { + REUSE = !Boolean.parseBoolean(value); + } } } @@ -144,6 +175,26 @@ public class ToolbarContributor extends EditorActionBarContributor implements IC if (DEBUG) System.out.println("Adding command to toolbar " +getToolbarId() + " " + ext); String commandId = ext.commandId; Command command = service.getCommand(commandId); + ICommandWrapper wrapper = new CommandWrapper(command); + + ParameterizedCommand parameterizedCommand = null; + + if (ext.parameters.size() > 0) { + try { + Parameterization parameterizations[] = new Parameterization[ext.parameters.size()]; + for (int i = 0; i < ext.parameters.size(); i++) { + Parameter param = ext.parameters.get(i); + IParameter parameter = command.getParameter(param.name); + parameterizations[i] = new Parameterization(parameter, param.value); + } + parameterizedCommand = new ParameterizedCommand(command, parameterizations); + wrapper = new ParameterizedCommandWrapper(parameterizedCommand); + } catch (org.eclipse.core.commands.common.NotDefinedException e) { + e.printStackTrace(); + ExceptionUtils.logError(e); + return; + } + } String type = ext.type; @@ -157,15 +208,15 @@ public class ToolbarContributor extends EditorActionBarContributor implements IC CommandAction a = null; if (type.equals("toggle") && toggleState != null) { - a = new CommandCheckboxAction(command,name,image); + a = new CommandCheckboxAction(wrapper,name,image); stateRegistry.storeDefaultState(commandId); } else if (radioState != null && ext.value != null) { stateRegistry.storeDefaultState(commandId); if (type.equals("radio")) { - a = new CommandRadioAction(command,name,ext.value,image); + a = new CommandRadioAction(wrapper,name,ext.value,image); } else if (type.equals("combo")) { - a = new CommandRadioAction(command,name,ext.value,image); + a = new CommandRadioAction(wrapper,name,ext.value,image); ComboContribution combo = menus.get(commandId); if (REUSE && combo == null) { combo = (ComboContribution)mgr.find(commandId); @@ -190,7 +241,7 @@ public class ToolbarContributor extends EditorActionBarContributor implements IC return; } } else if (type.equals("push")) { - a = new CommandPushAction(command,name,image); + a = new CommandPushAction(wrapper,name,image); } else { if (DEBUG) System.out.println(ext + " is not valid."); Logger.defaultLogError(ext + " is not valid."); @@ -267,6 +318,14 @@ public class ToolbarContributor extends EditorActionBarContributor implements IC setContext((IEditorPart)part); } + private void setContext2(IEditorPart part) { + if (REUSE) + return; + if (this.activePart == part) + return; + setContext(null); + } + private void setContext(IEditorPart part) { this.activePart = part; if (activePart != null && !parts.contains(activePart)) { @@ -289,8 +348,9 @@ public class ToolbarContributor extends EditorActionBarContributor implements IC a.setEnabled(false); } ComboContribution menu = menus.get(commandId); - if (menu != null) + if (menu != null) { menu.setEnabled(false); + } } } @@ -323,13 +383,16 @@ public class ToolbarContributor extends EditorActionBarContributor implements IC actions.clear(); // without this the contributed toolbar widgets would continue reserve the space even when they are destroyed. - // TODO : how to make the toolbar fix its layout? - // Note: Using REUSE flag alleviates the problem, since the widgets are not removed. coolBarManager.update(true); + mgr.update(true); } CommandStateRegistry.getInstance().removeListener(this); super.dispose(); activePart = null; + if (partListener != null) { + PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().addPartListener(partListener); + partListener = null; + } } boolean settingState = false; @@ -354,10 +417,12 @@ public class ToolbarContributor extends EditorActionBarContributor implements IC private void restoreActionStates() { if (activePart == null) return; + if (DEBUG)System.out.println("Restore " + activePart); // toggles Map defaultToggleStates = stateRegistry.getDefaultToggleStates(); for (String commandId : defaultToggleStates.keySet()) { for (CommandAction a : actions.getValues(commandId)) { + if (DEBUG)System.out.println(commandId + " def " + defaultToggleStates.get(commandId)); a.setChecked(defaultToggleStates.get(commandId)); } } @@ -365,6 +430,7 @@ public class ToolbarContributor extends EditorActionBarContributor implements IC if (editorStates != null) { for (String commandId : editorStates.keySet()) { for (CommandAction a : actions.getValues(commandId)) { + if (DEBUG)System.out.println(commandId + " " + editorStates.get(commandId)); a.setChecked(editorStates.get(commandId)); } } @@ -375,6 +441,7 @@ public class ToolbarContributor extends EditorActionBarContributor implements IC String defaultValue = defaultRadioStates.get(commandId); for (CommandAction a : actions.getValues(commandId)) { CommandRadioAction r = (CommandRadioAction)a; + if (DEBUG)System.out.println(commandId + " def " + r.getValue().equals(defaultValue) +" " + r.getValue()); r.setChecked(r.getValue().equals(defaultValue)); } } @@ -385,6 +452,7 @@ public class ToolbarContributor extends EditorActionBarContributor implements IC String defaultValue = editorRadioStates.get(commandId); for (CommandAction a : actions.getValues(commandId)) { CommandRadioAction r = (CommandRadioAction)a; + if (DEBUG)System.out.println(commandId + " " + r.getValue().equals(defaultValue) +" " + r.getValue()); r.setChecked(r.getValue().equals(defaultValue)); } } @@ -434,14 +502,28 @@ public class ToolbarContributor extends EditorActionBarContributor implements IC return (Boolean)toggleState.getValue(); } - private abstract class CommandAction extends Action { + private interface ICommandWrapper { + + public Command getCommand(); + public String getCommandId(); + public void run(); + } + + private class CommandWrapper implements ICommandWrapper{ private Command command; - public CommandAction(Command command, String name, ImageDescriptor image, int style) { - super(name,style); + public CommandWrapper(Command command) { this.command = command; - if (image != null) - setImageDescriptor(image); + } + + @Override + public Command getCommand() { + return command; + } + + @Override + public String getCommandId() { + return command.getId(); } @Override @@ -453,35 +535,93 @@ public class ToolbarContributor extends EditorActionBarContributor implements IC } } + @Override + public boolean equals(Object obj) { + if (obj.getClass() != getClass()) + return false; + CommandWrapper other= (CommandWrapper)obj; + return other.getCommandId().equals(getCommandId()); + } + } + + private class ParameterizedCommandWrapper implements ICommandWrapper{ + private ParameterizedCommand command; + + public ParameterizedCommandWrapper(ParameterizedCommand command) { + this.command = command; + } + + @Override public Command getCommand() { - return command; + return command.getCommand(); } + @Override public String getCommandId() { return command.getId(); } + @Override + public void run() { + try { + handlerService.executeCommand(command, null); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Override + public boolean equals(Object obj) { + if (obj.getClass() != getClass()) + return false; + ParameterizedCommandWrapper other= (ParameterizedCommandWrapper)obj; + return other.command.equals(command); + } + } + + private abstract class CommandAction extends Action { + private ICommandWrapper command; + + public CommandAction(ICommandWrapper command, String name, ImageDescriptor image, int style) { + super(name,style); + this.command = command; + if (image != null) + setImageDescriptor(image); + } + + @Override + public void run() { + command.run(); + } + + public Command getCommand() { + return command.getCommand(); + } + + public String getCommandId() { + return command.getCommandId(); + } + @Override public boolean equals(Object obj) { if (obj.getClass() != getClass()) return false; CommandAction other= (CommandAction)obj; - if (!other.getCommandId().equals(getCommandId())) - return false; - return true; + return command.equals(other.command); } @Override public int hashCode() { - return command.getId().hashCode(); + return command.getCommandId().hashCode(); } } + private class CommandCheckboxAction extends CommandAction { - public CommandCheckboxAction(Command command, String name, ImageDescriptor image) { + public CommandCheckboxAction(ICommandWrapper command, String name, ImageDescriptor image) { super(command,name,image,Action.AS_CHECK_BOX); } @@ -505,7 +645,7 @@ public class ToolbarContributor extends EditorActionBarContributor implements IC private String value; - public CommandRadioAction(Command command, String name, String value, ImageDescriptor image) { + public CommandRadioAction(ICommandWrapper command, String name, String value, ImageDescriptor image) { super(command,name,image,Action.AS_RADIO_BUTTON); this.value = value; } @@ -543,7 +683,7 @@ public class ToolbarContributor extends EditorActionBarContributor implements IC private class CommandPushAction extends CommandAction { - public CommandPushAction(Command command, String name, ImageDescriptor image) { + public CommandPushAction(ICommandWrapper command, String name, ImageDescriptor image) { super(command,name,image,Action.AS_PUSH_BUTTON); } @@ -615,6 +755,12 @@ public class ToolbarContributor extends EditorActionBarContributor implements IC if (combo != null) combo.setEnabled(enabled); } + + @Override + public void dispose() { + combo.dispose(); + super.dispose(); + } } } -- 2.47.1