List of usage examples for org.eclipse.jface.viewers StructuredSelection StructuredSelection
public StructuredSelection(List elements)
List
. From source file:com.amalto.workbench.actions.XSDSkipToFKAction.java
License:Open Source License
@Override public void run() { TreeViewer treeViewer = page.getTreeViewer(); ISelection selection = treeViewer.getSelection(); Object selObj = ((IStructuredSelection) selection).getFirstElement(); if (selObj instanceof XSDParticle) { XSDTerm term = ((XSDParticle) selObj).getTerm(); if (term instanceof XSDElementDeclaration) { XSDElementDeclaration element = (XSDElementDeclaration) term; String fkPath = getFKInfo(element); if (fkPath == null) { MessageDialog.openInformation(null, Messages.XSDSkipToFKAction_actionTitle, Messages.XSDSkipToFKAction_NotFoundFkInfo); return; }//from w w w.ja va 2 s . c o m String entityName = getEntityName(fkPath); EList<XSDElementDeclaration> elementDeclarations = page.getXSDSchema().getElementDeclarations(); for (XSDElementDeclaration elementDeclaration : elementDeclarations) { String name = elementDeclaration.getName(); if (entityName.equals(name)) { StructuredSelection fkSelection = new StructuredSelection(elementDeclaration); page.getElementsViewer().setSelection(fkSelection); break; } } } } }
From source file:com.amalto.workbench.compare.CompareEditorAction.java
License:Open Source License
public void run(IAction action) { cc.setLeftEditable(true);/*from w w w .j av a 2 s. c om*/ cc.setRightEditable(false); // cc.setAncestorLabel("ancestor"); IProject prj = CompareManager.getInstance().createProject("test1111");//$NON-NLS-1$ IFile leftF = prj.getFile("left");//$NON-NLS-1$ IFile rightF = prj.getFile("right");//$NON-NLS-1$ String left = "aaaaaaaaa\n\nee";//$NON-NLS-1$ String right = ";dfeadf\n";//$NON-NLS-1$ try { leftF.create(new ByteArrayInputStream(left.getBytes()), IFile.FORCE, null); rightF.create(new ByteArrayInputStream(right.getBytes()), IFile.FORCE, null); } catch (CoreException e) { log.error(e.getMessage(), e); } ResourceCompareInput input = new ResourceCompareInput(cc); StructuredSelection sel = new StructuredSelection(new IFile[] { leftF, rightF }); input.setSelection(sel, null); CompareUI.openCompareEditor(input); // CompareUI.openCompareEditor(new MyCompareInput(cc)); }
From source file:com.amalto.workbench.compare.CompareManager.java
License:Open Source License
public void compareTwoStream(String left, String right, boolean format, CompareHeadInfo compareHeadInfo, String leftLabel, String rightLabel, boolean leftEditable, boolean rightEditable) throws Exception { if (left == null || right == null) return;//from w w w . j a v a 2s . c o m if (format) { left = XmlUtil.formatCompletely(left, "UTF-8");//$NON-NLS-1$ right = XmlUtil.formatCompletely(right, "UTF-8");//$NON-NLS-1$ } // prepare the two resources IProject prj = createProject("comparewithsvn");//$NON-NLS-1$ IFile leftF = prj.getFile("left");//$NON-NLS-1$ IFile rightF = prj.getFile("right");//$NON-NLS-1$ if (!leftF.exists()) leftF.create(new ByteArrayInputStream(left.getBytes()), IFile.FORCE, null); if (!rightF.exists()) rightF.create(new ByteArrayInputStream(right.getBytes()), IFile.FORCE, null); leftF.setContents(new ByteArrayInputStream(left.getBytes()), IFile.FORCE, null); rightF.setContents(new ByteArrayInputStream(right.getBytes()), IFile.FORCE, null); CompareConfiguration cc = new CompareConfiguration(); cc.setLeftEditable(leftEditable); cc.setRightEditable(rightEditable); if (leftLabel == null) leftLabel = "";//$NON-NLS-1$ cc.setLeftLabel(leftLabel); if (rightLabel == null) rightLabel = "";//$NON-NLS-1$ cc.setRightLabel(rightLabel); ResourceCompareInput input = new ResourceCompareInput(cc); StructuredSelection sel = new StructuredSelection(new IFile[] { leftF, rightF }); input.setSelection(sel, null); input.setCompareHeadInfo(compareHeadInfo); CompareUI.openCompareEditor(input); }
From source file:com.amalto.workbench.detailtabs.sections.composites.ComplexTypeConfigComposite.java
License:Open Source License
private void initUIContentsInComboExtends() { fillCandidatsInComboExtends();/*from w ww .j ava 2s . c o m*/ comboExtends.setSelection(new StructuredSelection(""));//$NON-NLS-1$ if (complexType.getBaseType() != null) comboExtends.setSelection(new StructuredSelection(complexType.getBaseType())); }
From source file:com.amalto.workbench.detailtabs.sections.composites.ComplexTypeConfigComposite.java
License:Open Source License
private void initUIListenerForRadGroupTypes() { SelectionAdapter radGroupTypeChangeListener = new SelectionAdapter() { @Override/*from w w w . j a v a 2 s.c om*/ public void widgetSelected(SelectionEvent e) { XSDComplexTypeDefinition curSelectedExtends = getExtends(); if (isGroupAll()) comboExtends.setSelection(new StructuredSelection(""));//$NON-NLS-1$ if (isGroupSequence() && !Util.isSequenceComplexType(curSelectedExtends)) comboExtends.setSelection(new StructuredSelection(""));//$NON-NLS-1$ if (isGroupChoice() && !Util.isChoiceComplexType(curSelectedExtends)) comboExtends.setSelection(new StructuredSelection(""));//$NON-NLS-1$ fillCandidatsInComboExtends(); refresh(); if (section != null && getGroupTypeCompositor() != Util.getComplexTypeGroupType(complexType)) section.autoCommit(); } }; radGroupAll.addSelectionListener(radGroupTypeChangeListener); radGroupSequence.addSelectionListener(radGroupTypeChangeListener); radGroupChoice.addSelectionListener(radGroupTypeChangeListener); }
From source file:com.amalto.workbench.detailtabs.sections.composites.EntityKeyConfigComposite.java
License:Open Source License
private void initListener2BtnAddField() { lBtnAddFieldListener = new SelectionAdapter() { @Override//from w w w .j av a2 s .c o m public void widgetSelected(SelectionEvent e) { try { KeyWrapper[] selectedKeys = getSelectedKeys(); if (selectedKeys.length == 0) { return; } List<String> topChilds = getTopChildrenNames(); // filter already exist fields List<String> fieldNames = getFieldNames(selectedKeys[0].getSourceKey()); for (String fdv : fieldNames) { if (topChilds.contains(fdv)) { topChilds.remove(fdv); } } SelectFieldDialog selectFieldDlg = new SelectFieldDialog(getShell(), Messages.EntityKeyConfigComposite_SelectOneField, topChilds, null); if (selectFieldDlg.open() != Window.OK) { return; } if ("".equals(selectFieldDlg.getField().trim())) { return; } FieldWrapper newFieldWrapper = new FieldWrapper(selectFieldDlg.getField().trim()); selectedKeys[0].addField(newFieldWrapper); tvFields.setInput(Arrays.asList(selectedKeys[0].getFields())); tvFields.setSelection(new StructuredSelection(newFieldWrapper)); if (section != null) { section.autoCommit(); } } catch (Exception exp) { log.error(exp.getMessage(), exp); } } }; }
From source file:com.amalto.workbench.detailtabs.sections.composites.EntityKeyConfigComposite.java
License:Open Source License
private void initListener2BtnAddKey() { lBtnAddKeyListener = new SelectionAdapter() { @Override/*from w w w. j a va 2 s.com*/ public void widgetSelected(SelectionEvent e) { try { List<String> topChilds = getTopChildrenNames(); IdentityConstraintInputDialog dialog = new IdentityConstraintInputDialog( entityWrapper.getSourceEntity(), getShell(), Messages.EntityKeyConfigComposite_AddANewKey, topChilds, entityWrapper.getSourceEntityName()); dialog.setInputValidator(new NewKeyWrapperValidator(entityWrapper)); if (dialog.open() != Window.OK) { return; } KeyWrapper newKeyWrapper = new KeyWrapper(dialog.getKeyName(), ".", dialog.getType(), //$NON-NLS-1$ new FieldWrapper[] { new FieldWrapper(dialog.getFieldName()) }); entityWrapper.addKey(newKeyWrapper); tvKeys.setInput(Arrays.asList(entityWrapper.getKeys())); tvKeys.setSelection(new StructuredSelection(newKeyWrapper)); if (section != null) { section.autoCommit(); } } catch (Exception exp) { log.error(exp.getMessage(), exp); } } }; }
From source file:com.amalto.workbench.detailtabs.sections.composites.EntityKeyConfigComposite.java
License:Open Source License
private void selectFirstKeyInCurKeyList() { if (tvKeys == null || entityWrapper == null) { return;// w ww . j ava2s . com } if (entityWrapper.hasKey()) { tvKeys.setSelection(new StructuredSelection(entityWrapper.getKeys()[0])); return; } removeUIListeners(); initUIContents(); addUIListeners(); }
From source file:com.amalto.workbench.detailtabs.sections.composites.SimpleTypeConfigComposite.java
License:Open Source License
private void initUIContentForComboBuildInTypes() { comboBuildInTypes.removeSelectionChangedListener(buildInChangedListener); comboBuildInTypes.setInput(Util.getAllBuildInTypes(xsdSimpleType.getSchema())); if (xsdSimpleType.getBaseType() != null) { comboBuildInTypes.setSelection(new StructuredSelection(xsdSimpleType.getBaseType())); }//from ww w. ja va 2 s .c o m radBuildInTypes.setSelection(!comboBuildInTypes.getSelection().isEmpty()); comboBuildInTypes.addSelectionChangedListener(buildInChangedListener); }
From source file:com.amalto.workbench.detailtabs.sections.composites.SimpleTypeConfigComposite.java
License:Open Source License
private void initUIContentsForComboCustomTypes() { comboCustomTypes.removeSelectionChangedListener(customChangedListener); List<String> allCustomTypeNames = null; if (xsdSimpleType.getSchema() != null) { allCustomTypeNames = Util.getAllCustomTypeNames(xsdSimpleType.getSchema()); }/*w w w . ja v a 2s . co m*/ if (xsdSimpleType.getName() != null && allCustomTypeNames != null) { allCustomTypeNames.remove(xsdSimpleType.getName()); } if (allCustomTypeNames != null) { comboCustomTypes.setInput(allCustomTypeNames); } if (xsdSimpleType.getBaseType() != null && xsdSimpleType.getBaseType().getName() != null) { comboCustomTypes.setSelection(new StructuredSelection(xsdSimpleType.getBaseType().getName())); } radCustomTypes.setSelection(!comboCustomTypes.getSelection().isEmpty()); comboCustomTypes.addSelectionChangedListener(customChangedListener); }