private void checkContextGroupSource() { IContextManager contextManager = getContextManager(); if (helper == null) { return; } if (contextManager != null) { helper.initHelper(contextManager); Map<String, Item> items = new HashMap<String, Item>(); boolean needRefresh = false; for (IContextParameter param : contextManager.getDefaultContext().getContextParameterList()) { if (!param.isBuiltIn()) { String source = param.getSource(); Item sourceItem = items.get(source); if (sourceItem == null) { sourceItem = ContextUtils.getRepositoryContextItemById(source); } if (sourceItem == null) { // source not found needRefresh = true; param.setSource(IContextParameter.BUILT_IN); propagateType(contextManager, param); } else { items.put(source, sourceItem); } } } if (needRefresh) { setModifiedFlag(contextManager); modelManager.refresh(); } } }
/** * 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(); }
/** * Constructor. * * @param parent * @param style */ public ContextNebulaGridComposite(Composite parent, IContextModelManager manager) { super(parent, SWT.NONE); modelManager = manager; buttonList = new ArrayList<Button>(); this.helper = new ContextManagerHelper(manager.getContextManager()); this.setLayout(GridLayoutFactory.swtDefaults().spacing(0, 0).create()); initializeUI(); // for bug TDI-32674 to set different bgColor of ContextView and RepositoryContextComposite. if (modelManager instanceof ContextComposite && ((ContextComposite) modelManager).isRepositoryContext()) { this.setBackground(parent.getBackground()); } else { // CSS CoreUIPlugin.setCSSClass(this, this.getClass().getSimpleName()); } }
private void removeParentModelInGroupBySource(ContextTableTabParentModel parentModel) { Set<String> paraNames = new HashSet<String>(); String sourceId = parentModel.getSourceId(); if (IContextParameter.BUILT_IN.equals(sourceId)) { String paraName = parentModel.getContextParameter().getName(); paraNames.add(paraName); } else { List<ContextTabChildModel> children = parentModel.getChildren(); if (children != null && children.size() > 0) { for (ContextTabChildModel child : children) { IContextParameter contextPara = child.getContextParameter(); String paraName = contextPara.getName(); paraNames.add(paraName); } } } modelManager.onContextRemoveParameter(getContextManager(), paraNames, sourceId); }
private void setButtonEnableState() { boolean enableState = !modelManager.isReadOnly(); if (this.addButton != null) { this.addButton.setEnabled(enableState); } if (this.removeButton != null) { this.removeButton.setEnabled(enableState); } if (this.moveUpButton != null) { this.moveUpButton.setEnabled(enableState); } if (this.moveDownButton != null) { this.moveDownButton.setEnabled(enableState); } if (this.selectContextVariablesButton != null) { this.selectContextVariablesButton.setEnabled(enableState); } if (contextConfigButton != null) { this.contextConfigButton.setEnabled(enableState); } if (contextsCombo != null) { this.contextsCombo.setEnabled(enableState); } }
private void removeChildModelInGroupBySource(ContextTableTabChildModel child) { IContextParameter contextPara = child.getContextParameter(); String sourceId = contextPara.getSource(); String contextName = contextPara.getName(); modelManager.onContextRemoveParameter(getContextManager(), contextName, sourceId); }
public IContextManager getContextManager() { return modelManager.getContextManager(); }