Java Code Examples for org.eclipse.jface.viewers.StructuredSelection#iterator()
The following examples show how to use
org.eclipse.jface.viewers.StructuredSelection#iterator() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PluginConfigurationDialog.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
public void editPuginConfig() { ISelection selection = tableViewer.getSelection(); if (selection != null && !selection.isEmpty() && selection instanceof StructuredSelection) { StructuredSelection structuredSelection = (StructuredSelection) selection; Iterator<PluginConfigBean> it = structuredSelection.iterator(); if (it.hasNext()) { PluginConfigBean configBean = it.next(); PluginConfigManageDialog dialog = new PluginConfigManageDialog(getShell(), false); dialog.create(); dialog.setEditInitData(configBean); int result = dialog.open(); if (result == IDialogConstants.OK_ID) { refreshTable(dialog.getCurPluginBean()); } } } else { MessageDialog.openInformation(getShell(), Messages.getString("dialog.PluginConfigurationDialog.msgTitle"), Messages.getString("dialog.PluginConfigurationDialog.msg1")); } }
Example 2
Source File: SuperInterfaceSelectionDialog.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void addSelectedInterfaces() { StructuredSelection selection= getSelectedItems(); if (selection == null) return; for (Iterator<?> iter= selection.iterator(); iter.hasNext();) { Object obj= iter.next(); if (obj instanceof TypeNameMatch) { accessedHistoryItem(obj); TypeNameMatch type= (TypeNameMatch) obj; String qualifiedName= getNameWithTypeParameters(type.getType()); String message; if (fTypeWizardPage.addSuperInterface(qualifiedName)) { message= Messages.format(NewWizardMessages.SuperInterfaceSelectionDialog_interfaceadded_info, BasicElementLabels.getJavaElementName(qualifiedName)); } else { message= Messages.format(NewWizardMessages.SuperInterfaceSelectionDialog_interfacealreadyadded_info, BasicElementLabels.getJavaElementName(qualifiedName)); } updateStatus(new StatusInfo(IStatus.INFO, message)); } } }
Example 3
Source File: AbstractSuperTypeSelectionDialog.java From sarl with Apache License 2.0 | 6 votes |
/** Adds selected interfaces to the list. */ private void fillWizardPageWithSelectedTypes() { final StructuredSelection selection = getSelectedItems(); if (selection == null) { return; } for (final Iterator<?> iter = selection.iterator(); iter.hasNext();) { final Object obj = iter.next(); if (obj instanceof TypeNameMatch) { accessedHistoryItem(obj); final TypeNameMatch type = (TypeNameMatch) obj; final String qualifiedName = Utilities.getNameWithTypeParameters(type.getType()); final String message; if (addTypeToWizardPage(this.typeWizardPage, qualifiedName)) { message = MessageFormat.format(Messages.AbstractSuperTypeSelectionDialog_2, TextProcessor.process(qualifiedName, JAVA_ELEMENT_DELIMITERS)); } else { message = MessageFormat.format(Messages.AbstractSuperTypeSelectionDialog_3, TextProcessor.process(qualifiedName, JAVA_ELEMENT_DELIMITERS)); } updateStatus(new StatusInfo(IStatus.INFO, message)); } } }
Example 4
Source File: SrxLanguageRulesManageDialog.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
public void editLangRule() { ISelection selection = tableViewer.getSelection(); if (!selection.isEmpty() && selection != null && selection instanceof StructuredSelection) { StructuredSelection structSelection = (StructuredSelection) selection; @SuppressWarnings("unchecked") Iterator<LanguageRuleBean> it = structSelection.iterator(); // 只修改选中规则中的一个 if (it.hasNext()) { LanguageRuleBean selectBean = it.next(); AddOrEditLangRuleOfSrxDialog editDialog = new AddOrEditLangRuleOfSrxDialog(getShell(), false, langRulesList); editDialog.create(); editDialog.setEditInitData(selectBean); int editResult = editDialog.open(); if (editResult == IDialogConstants.OK_ID) { refreshTable(editDialog.getCurLangRuleBean()); } } } else { MessageDialog.openInformation(getShell(), Messages.getString("srx.SrxLanguageRulesManageDialog.msgTitle"), Messages.getString("srx.SrxLanguageRulesManageDialog.msg7")); } }
Example 5
Source File: AddOrEditSrxConfigDialog.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
/** * 修改语言规则,备注,在修改语言规则名称时,也会同步修改映射中语言规则的名称 ; */ private void editLangRules() { ISelection selection = langTableViewer.getSelection(); if (!selection.isEmpty() && selection != null && selection instanceof StructuredSelection) { StructuredSelection struSelection = (StructuredSelection) selection; @SuppressWarnings("unchecked") Iterator<String[]> it = struSelection.iterator(); if (it.hasNext()) { // 获取所选中的语言规则的名称 String langRuleName = it.next()[1]; SrxLanguageRulesManageDialog dialog = new SrxLanguageRulesManageDialog(getShell(), false, handler, srxLocation); dialog.create(); dialog.setEditInitData(langRuleName); int result = dialog.open(); if (result == IDialogConstants.OK_ID) { refreshLangTable(dialog.getCurLanguageRuleName()); } } } else { MessageDialog.openInformation(getShell(), Messages.getString("srx.AddOrEditSrxConfigDialog.msgTitle2"), Messages.getString("srx.AddOrEditSrxConfigDialog.msg6")); } }
Example 6
Source File: SrxMapRulesManageDialog.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
public void editMapRule() { ISelection selection = tableViewer.getSelection(); if (!selection.isEmpty() && selection != null && selection instanceof StructuredSelection) { StructuredSelection structSelection = (StructuredSelection) selection; @SuppressWarnings("unchecked") Iterator<MapRuleBean> it = structSelection.iterator(); if (it.hasNext()) { MapRuleBean selectBean = it.next(); AddOrEditMapRuleOfSrxDialog dialog = new AddOrEditMapRuleOfSrxDialog(getShell(), false, mapRulesList, handler, srxLocation); dialog.create(); dialog.setEditInitData(selectBean); int result = dialog.open(); if (result == IDialogConstants.OK_ID) { refreshTable(dialog.getCurMapRuleBean()); } } refreshTable(null); } else { MessageDialog.openInformation(getShell(), Messages.getString("srx.SrxMapRulesManageDialog.msgTitle2"), Messages.getString("srx.SrxMapRulesManageDialog.msg2")); } }
Example 7
Source File: SrxMapRulesManageDialog.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
public void editMapRule() { ISelection selection = tableViewer.getSelection(); if (!selection.isEmpty() && selection != null && selection instanceof StructuredSelection) { StructuredSelection structSelection = (StructuredSelection) selection; @SuppressWarnings("unchecked") Iterator<MapRuleBean> it = structSelection.iterator(); if (it.hasNext()) { MapRuleBean selectBean = it.next(); AddOrEditMapRuleOfSrxDialog dialog = new AddOrEditMapRuleOfSrxDialog(getShell(), false, mapRulesList, handler, srxLocation); dialog.create(); dialog.setEditInitData(selectBean); int result = dialog.open(); if (result == IDialogConstants.OK_ID) { refreshTable(dialog.getCurMapRuleBean()); } } refreshTable(null); } else { MessageDialog.openInformation(getShell(), Messages.getString("srx.SrxMapRulesManageDialog.msgTitle2"), Messages.getString("srx.SrxMapRulesManageDialog.msg2")); } }
Example 8
Source File: SrxLanguageRulesManageDialog.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
public void editLangRule() { ISelection selection = tableViewer.getSelection(); if (!selection.isEmpty() && selection != null && selection instanceof StructuredSelection) { StructuredSelection structSelection = (StructuredSelection) selection; @SuppressWarnings("unchecked") Iterator<LanguageRuleBean> it = structSelection.iterator(); // 只修改选中规则中的一个 if (it.hasNext()) { LanguageRuleBean selectBean = it.next(); AddOrEditLangRuleOfSrxDialog editDialog = new AddOrEditLangRuleOfSrxDialog(getShell(), false, langRulesList); editDialog.create(); editDialog.setEditInitData(selectBean); int editResult = editDialog.open(); if (editResult == IDialogConstants.OK_ID) { refreshTable(editDialog.getCurLangRuleBean()); } } } else { MessageDialog.openInformation(getShell(), Messages.getString("srx.SrxLanguageRulesManageDialog.msgTitle"), Messages.getString("srx.SrxLanguageRulesManageDialog.msg7")); } }
Example 9
Source File: PluginConfigurationDialog.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
public void editPuginConfig() { ISelection selection = tableViewer.getSelection(); if (selection != null && !selection.isEmpty() && selection instanceof StructuredSelection) { StructuredSelection structuredSelection = (StructuredSelection) selection; Iterator<PluginConfigBean> it = structuredSelection.iterator(); if (it.hasNext()) { PluginConfigBean configBean = it.next(); PluginConfigManageDialog dialog = new PluginConfigManageDialog(getShell(), false); dialog.create(); dialog.setEditInitData(configBean); int result = dialog.open(); if (result == IDialogConstants.OK_ID) { refreshTable(dialog.getCurPluginBean()); } } } else { MessageDialog.openInformation(getShell(), Messages.getString("dialog.PluginConfigurationDialog.msgTitle"), Messages.getString("dialog.PluginConfigurationDialog.msg1")); } }
Example 10
Source File: AddOrEditSrxConfigDialog.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
public void editMapRules() { ISelection selection = mapTableViewer.getSelection(); if (!selection.isEmpty() && selection != null && selection instanceof StructuredSelection) { StructuredSelection struSelection = (StructuredSelection) selection; @SuppressWarnings("unchecked") Iterator<String[]> it = struSelection.iterator(); if (it.hasNext()) { // 获取所选中的映射规则的名称 String mapRuleName = it.next()[1]; SrxMapRulesManageDialog dialog = new SrxMapRulesManageDialog(getShell(), false, handler, srxLocation); dialog.create(); dialog.setEditInitData(mapRuleName); int result = dialog.open(); if (result == IDialogConstants.OK_ID) { refreshMapTable(dialog.getCurMapRuleName()); } } } else { MessageDialog.openInformation(getShell(), Messages.getString("srx.AddOrEditSrxConfigDialog.msgTitle2"), Messages.getString("srx.AddOrEditSrxConfigDialog.msg7")); } }
Example 11
Source File: AddOrEditSrxConfigDialog.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
/** * 修改语言规则,备注,在修改语言规则名称时,也会同步修改映射中语言规则的名称 ; */ private void editLangRules() { ISelection selection = langTableViewer.getSelection(); if (!selection.isEmpty() && selection != null && selection instanceof StructuredSelection) { StructuredSelection struSelection = (StructuredSelection) selection; @SuppressWarnings("unchecked") Iterator<String[]> it = struSelection.iterator(); if (it.hasNext()) { // 获取所选中的语言规则的名称 String langRuleName = it.next()[1]; SrxLanguageRulesManageDialog dialog = new SrxLanguageRulesManageDialog(getShell(), false, handler, srxLocation); dialog.create(); dialog.setEditInitData(langRuleName); int result = dialog.open(); if (result == IDialogConstants.OK_ID) { refreshLangTable(dialog.getCurLanguageRuleName()); } } } else { MessageDialog.openInformation(getShell(), Messages.getString("srx.AddOrEditSrxConfigDialog.msgTitle2"), Messages.getString("srx.AddOrEditSrxConfigDialog.msg6")); } }
Example 12
Source File: SelectExamplePage.java From statecharts with Eclipse Public License 1.0 | 5 votes |
@Override public void selectionChanged(SelectionChangedEvent event) { StructuredSelection structuredSelection = (StructuredSelection) event.getSelection(); Iterator<?> iter = structuredSelection.iterator(); List<IExampleData> selectedItems = Lists.newArrayList(); while(iter.hasNext()) { Object next = iter.next(); if (next instanceof IExampleData) { selectedItems.add((IExampleData)next); } } updateSelection(selectedItems); }
Example 13
Source File: SrxConfigurationDialog.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
/** * 编辑SRX文件 ; */ private void editSrx() { ISelection selection = tableViewer.getSelection(); if (!selection.isEmpty() && selection != null && selection instanceof StructuredSelection) { StructuredSelection structSelection = (StructuredSelection) selection; @SuppressWarnings("unchecked") Iterator<String[]> it = structSelection.iterator(); if (it.hasNext()) { String srxName = it.next()[1]; if (isSystemSrx(srxName)) { MessageDialog.openInformation(getShell(), Messages.getString("dialogs.CatalogManagerDialog.msgTitle2"), Messages.getString("srx.SrxConfigurationDialog.msg4")); return; } CreateOrUpdataSRXDialog editDialog = new CreateOrUpdataSRXDialog(getShell(), false); editDialog.create(); editDialog.setEditInitData(srxName); int result = editDialog.open(); if (result == IDialogConstants.OK_ID) { String editedSrxName = editDialog.getCurSrxName(); if (!openSrx(ADConstants.configLocation + ADConstants.AD_SRXConfigFolder + File.separator + editedSrxName)) { return; } AddOrEditSrxConfigDialog addDialog = new AddOrEditSrxConfigDialog(getShell(), editedSrxName, handler); addDialog.open(); refreshTable(editedSrxName); } } } }
Example 14
Source File: SrxConfigurationDialog.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
/** * 编辑SRX文件 ; */ private void editSrx() { ISelection selection = tableViewer.getSelection(); if (!selection.isEmpty() && selection != null && selection instanceof StructuredSelection) { StructuredSelection structSelection = (StructuredSelection) selection; @SuppressWarnings("unchecked") Iterator<String[]> it = structSelection.iterator(); if (it.hasNext()) { String srxName = it.next()[1]; if (isSystemSrx(srxName)) { MessageDialog.openInformation(getShell(), Messages.getString("dialogs.CatalogManagerDialog.msgTitle2"), Messages.getString("srx.SrxConfigurationDialog.msg4")); return; } CreateOrUpdataSRXDialog editDialog = new CreateOrUpdataSRXDialog(getShell(), false); editDialog.create(); editDialog.setEditInitData(srxName); int result = editDialog.open(); if (result == IDialogConstants.OK_ID) { String editedSrxName = editDialog.getCurSrxName(); if (!openSrx(ADConstants.configLocation + ADConstants.AD_SRXConfigFolder + File.separator + editedSrxName)) { return; } AddOrEditSrxConfigDialog addDialog = new AddOrEditSrxConfigDialog(getShell(), editedSrxName, handler); addDialog.open(); refreshTable(editedSrxName); } } } }
Example 15
Source File: AttributeViewPage.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * Parse out the DE models for all kinds of input source. * * @param selection * the current selection. * @return */ protected List getModelList( ISelection selection ) { List list = new ArrayList( ); if ( selection == null ) return list; if ( !( selection instanceof StructuredSelection ) ) return list; StructuredSelection structured = (StructuredSelection) selection; if ( structured.getFirstElement( ) instanceof ReportElementEditPart ) { boolean bool = false; for ( Iterator it = structured.iterator( ); it.hasNext( ); ) { ReportElementEditPart object = (ReportElementEditPart) it.next( ); if ( object instanceof DummyEditpart ) { list.add( object.getModel( ) ); bool = true; } if ( !bool ) { list.add( object.getModel( ) ); } } } else { list = structured.toList( ); } return list; }
Example 16
Source File: GraphicalEditorWithFlyoutPalette.java From birt with Eclipse Public License 1.0 | 5 votes |
private List getModelList( ISelection selection ) { List list = new ArrayList( ); if ( selection == null ) return list; if ( !( selection instanceof StructuredSelection ) ) return list; StructuredSelection structured = (StructuredSelection) selection; if ( structured.getFirstElement( ) instanceof ReportElementEditPart ) { boolean bool = false; for ( Iterator it = structured.iterator( ); it.hasNext( ); ) { ReportElementEditPart object = (ReportElementEditPart) it.next( ); if ( object instanceof DummyEditpart ) { list.add( object.getModel( ) ); bool = true; } if ( !bool ) { list.add( object.getModel( ) ); } } } else { list = structured.toList( ); } return list; }
Example 17
Source File: EditorAreaDropAdapter.java From tmxeditor8 with GNU General Public License v2.0 | 4 votes |
private void asyncDrop(DropTargetEvent event, IWorkbenchPage page) { if (LocalSelectionTransfer.getTransfer().isSupportedType(event.currentDataType)) { // 处理“导航视图”拖拽过来的文件 if (!(event.data instanceof StructuredSelection)) { return; } StructuredSelection selection = (StructuredSelection) event.data; for (Iterator<?> iter = selection.iterator(); iter.hasNext();) { Object o = iter.next(); if (o instanceof IFile) { IFile file = (IFile) o; // 仅打开从导航视图中拖过来的 XLIFF 文件 if (CommonFunction.validXlfExtensionByFileName(file.getName())) { try { IDE.openEditor(page, file, true); } catch (PartInitException e) { LOGGER.error(" ", e); // silently ignore problems opening the editor } } } } } else if (FileTransfer.getInstance().isSupportedType(event.currentDataType)) { // 处理从工作空间以外拖拽过来的文件 // 从工作空间以外拖过来的文件不做处理 // String[] filePaths = (String[]) event.data; // if (filePaths != null && filePaths.length != 0) { // boolean isXliffFile = true; // 是 XLIFF 文件 // for (String filePath : filePaths) { // if (!CommonFunction.validXlfExtensionByFileName(filePath)) { // isXliffFile = false; // break; // } // } // if (isXliffFile) { // 全部都是 XLIFF 文件 // for (int i = 0; i < filePaths.length; i++) { // IFileStore fileStore = EFS.getLocalFileSystem().getStore(new Path(filePaths[i])); // try { // IDE.openEditorOnFileStore(page, fileStore); // } catch (PartInitException e) { // LOGGER.error("", e); // // silently ignore problems opening the editor // } // } // } else { // 否则,就弹出创建项目的对话框,要求创建项目。 // NewProjectAction action = new NewProjectAction(window); // action.run(); // // TODO 如果成功创建项目,则把拖进来的文件自动拷贝到项目中来。 // // 未解决问题:无法获取是否已经成功创建(可能用户点击了“取消”)。 // } // } } }
Example 18
Source File: PluginConfigurationDialog.java From translationstudio8 with GNU General Public License v2.0 | 4 votes |
private void deletePluginData() { ISelection selection = tableViewer.getSelection(); if (selection != null && !selection.isEmpty() && selection instanceof StructuredSelection) { boolean response = MessageDialog.openConfirm(getShell(), Messages.getString("dialog.PluginConfigurationDialog.msgTitle2"), Messages.getString("dialog.PluginConfigurationDialog.msg2")); if (!response) { return; } StructuredSelection structuredSelection = (StructuredSelection) selection; @SuppressWarnings("unchecked") Iterator<PluginConfigBean> it = structuredSelection.iterator(); VTDGen vg = new VTDGen(); vg.parseFile(pluginXmlLocation, true); VTDNav vn = vg.getNav(); AutoPilot ap = new AutoPilot(vn); try { XMLModifier xm = new XMLModifier(vn); while (it.hasNext()) { PluginConfigBean configBean = it.next(); String xpath = manage.buildXpath(configBean); ap.selectXPath(xpath); while (ap.evalXPath() != -1) { xm.remove(); manage.deletePluginMenu(configBean.getId()); } ap.resetXPath(); } FileOutputStream fos = new FileOutputStream(pluginXmlLocation); BufferedOutputStream bos = new BufferedOutputStream(fos); xm.output(bos); // 写入文件 bos.close(); fos.close(); refreshTable(null); } catch (Exception e) { LOGGER.error("", e); } } else { MessageDialog.openInformation(getShell(), Messages.getString("dialog.PluginConfigurationDialog.msgTitle"), Messages.getString("dialog.PluginConfigurationDialog.msg3")); } }
Example 19
Source File: ReportPropertySheetPage.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * @param selection * @return */ private List<Object> getModelList( ISelection selection ) { List<Object> list = new ArrayList<Object>( ); if ( selection == null ) return list; if ( !( selection instanceof StructuredSelection ) ) return list; StructuredSelection structured = (StructuredSelection) selection; if ( structured.getFirstElement( ) instanceof ReportElementEditPart ) { for ( Iterator it = structured.iterator( ); it.hasNext( ); ) { ReportElementEditPart object = (ReportElementEditPart) it.next( ); if ( object instanceof DummyEditpart ) { list.clear( ); list.add( object.getModel( ) ); break; } list.add( object.getModel( ) ); } } else { list = structured.toList( ); if ( list != null && list.size( ) > 0 ) { List<Object> modelList = new ArrayList<Object>( ); for ( int i = 0; i < list.size( ); i++ ) { Object obj = list.get( i ); if ( obj instanceof IAdaptable ) { Object realModel = ( (IAdaptable) obj ).getAdapter( DesignElementHandle.class ); if ( realModel != null ) modelList.add( realModel ); else modelList.add( obj ); } else modelList.add( obj ); } list = modelList; } } return list; }
Example 20
Source File: PluginConfigurationDialog.java From tmxeditor8 with GNU General Public License v2.0 | 4 votes |
private void deletePluginData() { ISelection selection = tableViewer.getSelection(); if (selection != null && !selection.isEmpty() && selection instanceof StructuredSelection) { boolean response = MessageDialog.openConfirm(getShell(), Messages.getString("dialog.PluginConfigurationDialog.msgTitle2"), Messages.getString("dialog.PluginConfigurationDialog.msg2")); if (!response) { return; } StructuredSelection structuredSelection = (StructuredSelection) selection; @SuppressWarnings("unchecked") Iterator<PluginConfigBean> it = structuredSelection.iterator(); VTDGen vg = new VTDGen(); vg.parseFile(pluginXmlLocation, true); VTDNav vn = vg.getNav(); AutoPilot ap = new AutoPilot(vn); try { XMLModifier xm = new XMLModifier(vn); while (it.hasNext()) { PluginConfigBean configBean = it.next(); String xpath = manage.buildXpath(configBean); ap.selectXPath(xpath); while (ap.evalXPath() != -1) { xm.remove(); manage.deletePluginMenu(configBean.getId()); } ap.resetXPath(); } FileOutputStream fos = new FileOutputStream(pluginXmlLocation); BufferedOutputStream bos = new BufferedOutputStream(fos); xm.output(bos); // 写入文件 bos.close(); fos.close(); refreshTable(null); } catch (Exception e) { LOGGER.error("", e); } } else { MessageDialog.openInformation(getShell(), Messages.getString("dialog.PluginConfigurationDialog.msgTitle"), Messages.getString("dialog.PluginConfigurationDialog.msg3")); } }