/** * ggu Comment method "changeContextOrder". * * <p>order the context parameter */ public static boolean changeContextOrder( TreeViewer viewer, IContextModelManager modelManager, boolean up) { if (viewer == null || modelManager == null) { return false; } final ISelection selection = viewer.getSelection(); if (selection == null || selection.isEmpty()) { return false; } if (!(selection instanceof IStructuredSelection)) { return false; } IStructuredSelection sSection = (IStructuredSelection) selection; if (sSection.size() != 1) { // not support multi-selection return false; } Object element = sSection.getFirstElement(); IContextParameter movedParam = null; if (element instanceof ContextVariableTabParentModel) { movedParam = ((ContextVariableTabParentModel) element).getContextParameter(); } if (element instanceof ContextTableTabParentModel) { movedParam = ((ContextTableTabParentModel) element).getContextParameter(); } if (movedParam == null) { return false; } OrderContextParameterCommand orderCommand = new OrderContextParameterCommand(modelManager.getContextManager(), movedParam, up); final CommandStack commandStack = modelManager.getCommandStack(); if (commandStack != null) { commandStack.execute(orderCommand); } else { orderCommand.execute(); } // modelManager.refresh(); revertTreeSelection(viewer, movedParam); return orderCommand.isExecution(); }
/** * ggu Comment method "changeContextOrder". * * <p>order the context parameter */ public static boolean changeContextOrder( ISelection selObj, IContextModelManager modelManager, boolean up) { if (selObj == null || selObj.isEmpty()) { return false; } if (!(selObj instanceof IStructuredSelection)) { return false; } IStructuredSelection sSection = (IStructuredSelection) selObj; if (sSection.size() != 1) { // not support multi-selection return false; } Object element = sSection.getFirstElement(); Object model = ((ContextTreeNode) element).getTreeData(); IContextParameter movedParam = null; if (model instanceof ContextTableTabParentModel) { movedParam = ((ContextTableTabParentModel) model).getContextParameter(); } else if (model instanceof ContextTableTabChildModel) { // for bug TDI-32821 movedParam = ((ContextTableTabChildModel) model).getContextParameter(); } if (movedParam == null) { return false; } OrderContextParameterCommand orderCommand = new OrderContextParameterCommand(modelManager.getContextManager(), movedParam, up); final CommandStack commandStack = modelManager.getCommandStack(); if (commandStack != null) { commandStack.execute(orderCommand); } else { orderCommand.execute(); } modelManager.refresh(); return orderCommand.isExecution(); }