List of usage examples for org.eclipse.jface.viewers ITableLabelProvider ITableLabelProvider
ITableLabelProvider
From source file:org.eclipse.m2e.core.ui.internal.preferences.LifecycleMappingPropertyPage.java
License:Open Source License
@Override public Control createContents(Composite parent) { Composite container = new Composite(parent, SWT.NULL); GridLayout gl_container = new GridLayout(1, false); gl_container.marginWidth = 0;/*from w w w .j a v a 2 s . c om*/ gl_container.marginHeight = 0; container.setLayout(gl_container); mappingsTreeViewer = new TreeViewer(container, SWT.BORDER); Tree tree = mappingsTreeViewer.getTree(); tree.setHeaderVisible(true); tree.setLinesVisible(true); tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); TreeViewerColumn treeViewerColumn = new TreeViewerColumn(mappingsTreeViewer, SWT.NONE); TreeColumn trclmnGoal = treeViewerColumn.getColumn(); trclmnGoal.setWidth(100); trclmnGoal.setText(Messages.LifecycleMappingPropertyPage_pluginExecution); TreeViewerColumn treeViewerColumn_1 = new TreeViewerColumn(mappingsTreeViewer, SWT.NONE); TreeColumn trclmnNewColumn = treeViewerColumn_1.getColumn(); trclmnNewColumn.setWidth(100); trclmnNewColumn.setText(Messages.LifecycleMappingPropertyPage_mapping); mappingsTreeViewer.setContentProvider(new ITreeContentProvider() { public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } public void dispose() { } public boolean hasChildren(Object element) { return getChildren(element) != null; } public Object getParent(Object element) { return null; } public Object[] getElements(Object inputElement) { if (showPhases) { return phases.keySet().toArray(); } else { Set<MojoExecutionKey> executions; if (showIgnoredExecutions) { executions = mappings.keySet(); } else { executions = new LinkedHashSet<MojoExecutionKey>(); for (Map.Entry<MojoExecutionKey, List<IPluginExecutionMetadata>> entry : mappings .entrySet()) { if (!isIgnoreMapping(entry.getKey(), entry.getValue())) { executions.add(entry.getKey()); } } } return executions.toArray(); } } public Object[] getChildren(Object parentElement) { List<MojoExecutionKey> executions = phases.get(parentElement); if (executions == null || executions.isEmpty()) { return null; } if (showIgnoredExecutions) { return executions.toArray(); } // filter out ignored executions executions = new ArrayList<MojoExecutionKey>(executions); // clone Iterator<MojoExecutionKey> iter = executions.iterator(); while (iter.hasNext()) { MojoExecutionKey execution = iter.next(); if (isIgnoreMapping(execution, mappings.get(execution))) { iter.remove(); } } return !executions.isEmpty() ? executions.toArray() : null; } }); mappingsTreeViewer.setLabelProvider(new ITableLabelProvider() { public void addListener(ILabelProviderListener listener) { } public void dispose() { } public boolean isLabelProperty(Object element, String property) { return false; } public void removeListener(ILabelProviderListener listener) { } public Image getColumnImage(Object element, int columnIndex) { if (columnIndex == 0 && element instanceof MojoExecutionKey) { return isErrorMapping((MojoExecutionKey) element) ? MavenImages.IMG_ERROR : MavenImages.IMG_PASSED; } return null; } public String getColumnText(Object element, int columnIndex) { if (element instanceof MojoExecutionKey) { MojoExecutionKey execution = (MojoExecutionKey) element; switch (columnIndex) { case 0: return LifecycleMappingPropertyPage.this.toString(execution); case 1: return LifecycleMappingPropertyPage.this.toString(execution, mappings.get(execution)); } } return columnIndex == 0 ? element.toString() : null; } }); Menu menu = new Menu(tree); tree.setMenu(menu); final MenuItem mntmShowPhases = new MenuItem(menu, SWT.CHECK); mntmShowPhases.setSelection(showPhases); mntmShowPhases.setText(Messages.LifecycleMappingPropertyPage_showLIfecyclePhases); final MenuItem mntmShowIgnoredExecutions = new MenuItem(menu, SWT.CHECK); mntmShowIgnoredExecutions.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { showIgnoredExecutions = mntmShowIgnoredExecutions.getSelection(); updateMappingsTreeViewer(); } }); mntmShowIgnoredExecutions.setSelection(showIgnoredExecutions); mntmShowIgnoredExecutions.setText(Messages.LifecycleMappingPropertyPage_mntmShowIgnoredExecutions_text); new MenuItem(menu, SWT.SEPARATOR); final MenuItem mntmExpandAll = new MenuItem(menu, SWT.NONE); mntmExpandAll.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { mappingsTreeViewer.expandAll(); } }); mntmExpandAll.setEnabled(showPhases); mntmExpandAll.setText(Messages.LifecycleMappingPropertyPage_mntmExpandAll_text); final MenuItem mntmCollapseAll = new MenuItem(menu, SWT.NONE); mntmCollapseAll.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { mappingsTreeViewer.collapseAll(); } }); mntmCollapseAll.setEnabled(showPhases); mntmCollapseAll.setText(Messages.LifecycleMappingPropertyPage_mntmCollapseAll_text); mntmShowPhases.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { showPhases = mntmShowPhases.getSelection(); mntmExpandAll.setEnabled(showPhases); mntmCollapseAll.setEnabled(showPhases); updateMappingsTreeViewer(); } }); Composite actionsComposite = new Composite(container, SWT.NONE); actionsComposite.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false, 1, 1)); actionsComposite.setLayout(new RowLayout(SWT.HORIZONTAL)); Button btnCopyToClipboard = new Button(actionsComposite, SWT.NONE); btnCopyToClipboard.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { copyToClipboard(); } }); btnCopyToClipboard.setText(Messages.LifecycleMappingPropertyPage_copyToClipboard); mappingsTreeViewer.setInput(facade); updateMappingsTreeViewer(); return container; }
From source file:org.eclipse.m2e.core.ui.internal.preferences.LifecycleMappingsViewer.java
License:Open Source License
/** * @wbp.parser.entryPoint/*from w w w.ja v a 2s.c o m*/ */ public Composite createContents(Composite parent) { Composite container = new Composite(parent, SWT.NULL); GridLayout gl_container = new GridLayout(1, false); gl_container.marginWidth = 0; gl_container.marginHeight = 0; container.setLayout(gl_container); Composite optionsComposit = new Composite(container, SWT.NONE); GridLayout gl_optionsComposit = new GridLayout(3, false); gl_optionsComposit.marginWidth = 0; gl_optionsComposit.marginHeight = 0; optionsComposit.setLayout(gl_optionsComposit); optionsComposit.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); final Button btnShowPhases = new Button(optionsComposit, SWT.CHECK); btnShowPhases.setSelection(showPhases); btnShowPhases.setText(Messages.LifecycleMappingPropertyPage_showLIfecyclePhases); final Button btnShowIgnored = new Button(optionsComposit, SWT.CHECK); btnShowIgnored.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { showIgnoredExecutions = btnShowIgnored.getSelection(); updateMappingsTreeViewer(); } }); btnShowIgnored.setSelection(showIgnoredExecutions); btnShowIgnored.setText(Messages.LifecycleMappingPropertyPage_mntmShowIgnoredExecutions_text); final Action actExpandAll = new Action(Messages.LifecycleMappingPropertyPage_mntmExpandAll_text, MavenImages.EXPANDALL) { public void run() { mappingsTreeViewer.expandAll(); }; }; actExpandAll.setEnabled(showPhases); final Action actCollapseAll = new Action(Messages.LifecycleMappingPropertyPage_mntmCollapseAll_text, MavenImages.COLLAPSEALL) { public void run() { mappingsTreeViewer.collapseAll(); }; }; actCollapseAll.setEnabled(showPhases); Composite toolbarComposite = new Composite(optionsComposit, SWT.NONE); toolbarComposite.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false, 1, 1)); GridLayout gl_toolbarComposite = new GridLayout(1, false); gl_toolbarComposite.marginWidth = 0; gl_toolbarComposite.marginHeight = 0; toolbarComposite.setLayout(gl_toolbarComposite); ToolBar toolBar = new ToolBar(toolbarComposite, SWT.FLAT | SWT.RIGHT); ToolBarManager toolBarManager = new ToolBarManager(toolBar); toolBarManager.add(actExpandAll); toolBarManager.add(actCollapseAll); toolBarManager.update(true); btnShowPhases.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { showPhases = btnShowPhases.getSelection(); actExpandAll.setEnabled(showPhases); actCollapseAll.setEnabled(showPhases); updateMappingsTreeViewer(); } }); mappingsTreeViewer = new TreeViewer(container, SWT.BORDER); Tree tree = mappingsTreeViewer.getTree(); tree.setHeaderVisible(true); tree.setLinesVisible(true); tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); TreeViewerColumn treeViewerColumn = new TreeViewerColumn(mappingsTreeViewer, SWT.NONE); TreeColumn trclmnGoal = treeViewerColumn.getColumn(); trclmnGoal.setWidth(100); trclmnGoal.setText(Messages.LifecycleMappingPropertyPage_pluginExecution); TreeViewerColumn treeViewerColumn_1 = new TreeViewerColumn(mappingsTreeViewer, SWT.NONE); TreeColumn trclmnNewColumn = treeViewerColumn_1.getColumn(); trclmnNewColumn.setWidth(100); trclmnNewColumn.setText(Messages.LifecycleMappingPropertyPage_mapping); TreeViewerColumn treeViewerColumn_2 = new TreeViewerColumn(mappingsTreeViewer, SWT.NONE); TreeColumn trclmnSource = treeViewerColumn_2.getColumn(); trclmnSource.setWidth(100); trclmnSource.setText(Messages.LifecycleMappingsViewer_trclmnSource_text); mappingsTreeViewer.setContentProvider(new ITreeContentProvider() { public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } public void dispose() { } public boolean hasChildren(Object element) { return getChildren(element) != null; } public Object getParent(Object element) { return null; } public Object[] getElements(Object inputElement) { if (showPhases) { return phases.keySet().toArray(); } Set<MojoExecutionKey> executions; if (showIgnoredExecutions) { executions = mappings.keySet(); } else { executions = new LinkedHashSet<MojoExecutionKey>(); for (Map.Entry<MojoExecutionKey, List<IPluginExecutionMetadata>> entry : mappings.entrySet()) { if (!isIgnoreMapping(entry.getKey(), entry.getValue())) { executions.add(entry.getKey()); } } } return executions.toArray(); } public Object[] getChildren(Object parentElement) { List<MojoExecutionKey> executions = phases.get(parentElement); if (executions == null || executions.isEmpty()) { return null; } if (showIgnoredExecutions) { return executions.toArray(); } // filter out ignored executions executions = new ArrayList<MojoExecutionKey>(executions); // clone Iterator<MojoExecutionKey> iter = executions.iterator(); while (iter.hasNext()) { MojoExecutionKey execution = iter.next(); if (isIgnoreMapping(execution, mappings.get(execution))) { iter.remove(); } } return !executions.isEmpty() ? executions.toArray() : null; } }); mappingsTreeViewer.setLabelProvider(new ITableLabelProvider() { public void addListener(ILabelProviderListener listener) { } public void dispose() { } public boolean isLabelProperty(Object element, String property) { return false; } public void removeListener(ILabelProviderListener listener) { } public Image getColumnImage(Object element, int columnIndex) { if (columnIndex == 0 && element instanceof MojoExecutionKey) { return isErrorMapping((MojoExecutionKey) element) ? MavenImages.IMG_ERROR : MavenImages.IMG_PASSED; } return null; } public String getColumnText(Object element, int columnIndex) { if (element instanceof MojoExecutionKey) { MojoExecutionKey execution = (MojoExecutionKey) element; switch (columnIndex) { case 0: return LifecycleMappingsViewer.this.toString(execution); case 1: return LifecycleMappingsViewer.this.toString(execution, mappings.get(execution)); case 2: return getSourcelabel(execution, mappings.get(execution), false); } } return columnIndex == 0 ? element.toString() : null; } }); Composite actionsComposite = new Composite(container, SWT.NONE); actionsComposite.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false, 1, 1)); actionsComposite.setLayout(new RowLayout(SWT.HORIZONTAL)); Button btnCopyToClipboard = new Button(actionsComposite, SWT.NONE); btnCopyToClipboard.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { copyToClipboard(); } }); btnCopyToClipboard.setText(Messages.LifecycleMappingPropertyPage_copyToClipboard); mappingsTreeViewer.setInput(phases); updateMappingsTreeViewer(); return container; }
From source file:org.eclipse.m2e.core.ui.internal.views.build.BuildDebugView.java
License:Open Source License
public void createPartControl(Composite parent) { viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); Tree tree = viewer.getTree();//w w w . ja va2 s . c o m tree.setHeaderVisible(true); tree.setLinesVisible(true); TreeViewerColumn treeViewerColumn = new TreeViewerColumn(viewer, SWT.NONE); TreeColumn trclmnName = treeViewerColumn.getColumn(); trclmnName.setWidth(400); trclmnName.setText(Messages.BuildDebugView_columnName); TreeViewerColumn treeViewerColumn_1 = new TreeViewerColumn(viewer, SWT.NONE); TreeColumn trclmnBuildCount = treeViewerColumn_1.getColumn(); trclmnBuildCount.setWidth(100); trclmnBuildCount.setText(Messages.BuildDebugView_columnBuildNumber); viewer.setLabelProvider(new ITableLabelProvider() { public void removeListener(ILabelProviderListener listener) { } public boolean isLabelProperty(Object element, String property) { return false; } public void dispose() { } public void addListener(ILabelProviderListener listener) { } public String getColumnText(Object element, int columnIndex) { if (element instanceof Node) { return getColumnText((Node) element, columnIndex); } if (columnIndex == 0) { return element.toString(); } return null; } private String getColumnText(Node element, int columnIndex) { switch (columnIndex) { case 0: return element.getName(); case 1: return Integer.toString(element.getBuildCount()); default: // fall through } return null; } public Image getColumnImage(Object element, int columnIndex) { return null; } }); viewer.setContentProvider(new ITreeContentProvider() { public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } public void dispose() { } public boolean hasChildren(Object element) { if (element instanceof ContainerNode) { return !((ContainerNode) element).getResources().isEmpty(); } if (element instanceof CollectionNode<?>) { return !((CollectionNode<?>) element).getMembers().isEmpty(); } return false; } public Object getParent(Object element) { return null; } public Object[] getElements(Object inputElement) { if (inputElement == projects) { List<ProjectNode> sorted; synchronized (projectsLock) { sorted = new ArrayList<ProjectNode>(projects.values()); } Collections.sort(sorted, NODE_COMPARATOR); return sorted.toArray(); } return new Object[0]; } public Object[] getChildren(Object parentElement) { if (parentElement instanceof ProjectNode) { ArrayList<Object> result = new ArrayList<Object>(); final ProjectNode projectNode = (ProjectNode) parentElement; final List<ResourceNode> resources = new ArrayList<ResourceNode>(projectNode.getResources()); if (!resources.isEmpty()) { Collections.sort(resources, NODE_COMPARATOR); result.add(new CollectionNode<ResourceNode>(Messages.BuildDebugView_nodeDelta, resources)); } final List<MojoExecutionNode> executions = new ArrayList<MojoExecutionNode>( projectNode.getMojoExecutions()); if (!executions.isEmpty()) { Collections.sort(executions, NODE_COMPARATOR); result.add(new CollectionNode<MojoExecutionNode>(Messages.BuildDebugView_nodeExecutions, executions)); } return result.toArray(); } else if (parentElement instanceof CollectionNode<?>) { return ((CollectionNode<?>) parentElement).getMembers().toArray(); } else if (parentElement instanceof ContainerNode) { return ((ContainerNode) parentElement).getResources().toArray(); } return null; } }); viewer.setInput(projects); IActionBars actionBars = getViewSite().getActionBars(); IToolBarManager toolBar = actionBars.getToolBarManager(); Action suspendAction = new Action(Messages.BuildDebugView_actionSuspend, IAction.AS_CHECK_BOX) { public void run() { suspended = isChecked(); } }; suspendAction.setImageDescriptor(MavenImages.SUSPEND); suspendAction.setChecked(suspended); Action clearAction = new Action(Messages.BuildDebugView_actionClear, MavenImages.CLEAR) { public void run() { synchronized (projectsLock) { projects.clear(); } refreshJob.schedule(); } }; Action collapseAll = new Action(Messages.BuildDebugView_actionCollapseAll, MavenImages.COLLAPSEALL) { public void run() { viewer.collapseAll(); } }; toolBar.add(collapseAll); toolBar.add(clearAction); toolBar.add(suspendAction); actionBars.updateActionBars(); }
From source file:org.eclipse.m2e.core.ui.internal.wizards.LifecycleMappingPage.java
License:Open Source License
/** * Create contents of the wizard.//from w w w. j a va 2s. co m * * @param parent */ public void createControl(Composite parent) { Composite container = new Composite(parent, SWT.NULL); setControl(container); container.setLayout(new GridLayout(1, false)); treeViewer = new TreeViewer(container, SWT.BORDER | SWT.FULL_SELECTION); Tree tree = treeViewer.getTree(); tree.setLinesVisible(true); tree.setHeaderVisible(true); tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); TreeViewerColumn treeViewerColumn = new TreeViewerColumn(treeViewer, SWT.NONE); TreeColumn trclmnNewColumn = treeViewerColumn.getColumn(); trclmnNewColumn.setText(Messages.LifecycleMappingPage_mavenBuildColumnTitle); TreeViewerColumn columnViewerAction = new TreeViewerColumn(treeViewer, SWT.NONE); TreeColumn columnAction = columnViewerAction.getColumn(); columnAction.setText(Messages.LifecycleMappingPage_actionColumnTitle); columnViewerAction.setEditingSupport(new EditingSupport(treeViewer) { @Override protected void setValue(Object element, Object value) { if (element instanceof ILifecycleMappingLabelProvider) { ILifecycleMappingLabelProvider prov = (ILifecycleMappingLabelProvider) element; int intVal = ((Integer) value).intValue(); List<IMavenDiscoveryProposal> all = mappingConfiguration.getProposals(prov.getKey()); if (ignore.contains(element)) { ignore.remove(element); } else if (ignoreAtDefinition.contains(element)) { ignoreAtDefinition.remove(element); } else if (intVal == all.size() + NO_ACTION_IDX || shouldDeslectProposal(prov)) { IMavenDiscoveryProposal prop = mappingConfiguration.getSelectedProposal(prov.getKey()); mappingConfiguration.removeSelectedProposal(prop); } // Set new selection if (intVal < all.size()) { IMavenDiscoveryProposal sel = all.get(intVal); if (sel != null) { mappingConfiguration.addSelectedProposal(sel); } } else { switch (intVal - all.size()) { case IGNORE_IDX: ignore.add(prov); break; case IGNORE_PARENT_IDX: ignoreAtDefinition.add(prov); } } getViewer().refresh(true); updateErrorCount(); } } @Override protected Object getValue(Object element) { if (element instanceof ILifecycleMappingLabelProvider) { ILifecycleMappingLabelProvider prov = (ILifecycleMappingLabelProvider) element; IMavenDiscoveryProposal prop = mappingConfiguration.getSelectedProposal(prov.getKey()); List<IMavenDiscoveryProposal> all = mappingConfiguration.getProposals(prov.getKey()); if (ignore.contains(element)) { return Integer.valueOf(all.size() + IGNORE_IDX); } else if (ignoreAtDefinition.contains(element)) { return Integer.valueOf(all.size() + IGNORE_PARENT_IDX); } else { int index = all.indexOf(prop); return index >= 0 ? Integer.valueOf(index) : Integer.valueOf(all.size() + NO_ACTION_IDX); } } return Integer.valueOf(0); } @Override protected CellEditor getCellEditor(Object element) { if (element instanceof ILifecycleMappingLabelProvider) { ILifecycleMappingLabelProvider prov = (ILifecycleMappingLabelProvider) element; List<IMavenDiscoveryProposal> all = mappingConfiguration.getProposals(prov.getKey()); List<String> values = new ArrayList<String>(); for (IMavenDiscoveryProposal prop : all) { values.add(NLS.bind(Messages.LifecycleMappingPage_installDescription, prop.toString())); } if (prov.isError(mappingConfiguration)) { values.add(Messages.LifecycleMappingPage_resolveLaterDescription); } else { values.add(EMPTY_STRING); } addIgnoreProposals(values, prov); ComboBoxCellEditor edit = new ComboBoxCellEditor(treeViewer.getTree(), values.toArray(new String[values.size()])); Control cont = edit.getControl(); //this attempts to disable text edits in the combo.. if (cont instanceof CCombo) { CCombo combo = (CCombo) cont; combo.setEditable(false); } return edit; } throw new IllegalStateException(); } @Override protected boolean canEdit(Object element) { if (element instanceof AggregateMappingLabelProvider) { ILifecycleMappingLabelProvider prov = (ILifecycleMappingLabelProvider) element; List<IMavenDiscoveryProposal> all = mappingConfiguration.getProposals(prov.getKey()); return all != null && !all.isEmpty() || prov.getKey() instanceof MojoExecutionMappingRequirement; } return false; } }); treeViewer.setContentProvider(new ITreeContentProvider() { public void dispose() { } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } public Object[] getElements(Object inputElement) { if (inputElement instanceof LifecycleMappingConfiguration) { Map<ILifecycleMappingRequirement, List<ILifecycleMappingLabelProvider>> packagings = new HashMap<ILifecycleMappingRequirement, List<ILifecycleMappingLabelProvider>>(); Map<ILifecycleMappingRequirement, List<ILifecycleMappingLabelProvider>> mojos = new HashMap<ILifecycleMappingRequirement, List<ILifecycleMappingLabelProvider>>(); Collection<ProjectLifecycleMappingConfiguration> projects = ((LifecycleMappingConfiguration) inputElement) .getProjects(); for (ProjectLifecycleMappingConfiguration prjconf : projects) { PackagingTypeMappingConfiguration pack = prjconf.getPackagingTypeMappingConfiguration(); if (pack != null) { ILifecycleMappingRequirement packReq = pack.getLifecycleMappingRequirement(); if (packReq != null && !mappingConfiguration.getProposals(packReq).isEmpty()) { List<ILifecycleMappingLabelProvider> val = packagings.get(packReq); if (val == null) { val = new ArrayList<ILifecycleMappingLabelProvider>(); packagings.put(packReq, val); } val.add(new PackagingTypeMappingLabelProvider(prjconf, pack)); } } List<MojoExecutionMappingConfiguration> mojoExecs = prjconf .getMojoExecutionConfigurations(); if (mojoExecs != null) { for (MojoExecutionMappingConfiguration mojoMap : mojoExecs) { ILifecycleMappingRequirement mojoReq = mojoMap.getLifecycleMappingRequirement(); // include mojo execution if it has available proposals or interesting phase not mapped locally if (mojoReq != null && !mappingConfiguration.getProposals(mojoReq).isEmpty() || (LifecycleMappingFactory .isInterestingPhase(mojoMap.getExecution().getLifecyclePhase()) && !mappingConfiguration.isRequirementSatisfied(mojoReq, true))) { List<ILifecycleMappingLabelProvider> val = mojos.get(mojoReq); if (val == null) { val = new ArrayList<ILifecycleMappingLabelProvider>(); mojos.put(mojoReq, val); } val.add(new MojoExecutionMappingLabelProvider(prjconf, mojoMap)); } } } } List<ILifecycleMappingLabelProvider> toRet = new ArrayList<ILifecycleMappingLabelProvider>(); for (Map.Entry<ILifecycleMappingRequirement, List<ILifecycleMappingLabelProvider>> ent : packagings .entrySet()) { toRet.add(new AggregateMappingLabelProvider(ent.getKey(), ent.getValue())); } for (Map.Entry<ILifecycleMappingRequirement, List<ILifecycleMappingLabelProvider>> ent : mojos .entrySet()) { toRet.add(new AggregateMappingLabelProvider(ent.getKey(), ent.getValue())); } return toRet.toArray(); } return null; } public Object[] getChildren(Object parentElement) { if (parentElement instanceof AggregateMappingLabelProvider) { return ((AggregateMappingLabelProvider) parentElement).getChildren(); } return new Object[0]; } public Object getParent(Object element) { return null; } public boolean hasChildren(Object element) { Object[] children = getChildren(element); return children != null && children.length > 0; } }); treeViewer.setLabelProvider(new ITableLabelProvider() { public void removeListener(ILabelProviderListener listener) { } public boolean isLabelProperty(Object element, String property) { return false; } public void dispose() { } public void addListener(ILabelProviderListener listener) { } public String getColumnText(Object element, int columnIndex) { if (element instanceof ILifecycleMappingLabelProvider) { ILifecycleMappingLabelProvider prov = (ILifecycleMappingLabelProvider) element; if (columnIndex == MAVEN_INFO_IDX) { String text = prov.getMavenText(); if (prov instanceof AggregateMappingLabelProvider && !isHandled(prov)) { text = NLS.bind(Messages.LifecycleMappingPage_errorMavenBuild, new String[] { text, String.valueOf(((AggregateMappingLabelProvider) prov).getChildren().length) }); } return text; } else if (columnIndex == ACTION_INFO_IDX && element instanceof AggregateMappingLabelProvider) { IMavenDiscoveryProposal proposal = mappingConfiguration.getSelectedProposal(prov.getKey()); if (ignore.contains(element)) { return Messages.LifecycleMappingPage_doNotExecutePom; } else if (ignoreAtDefinition.contains(element)) { return Messages.LifecycleMappingPage_doNotExecuteParent; } else if (proposal != null) { return NLS.bind(Messages.LifecycleMappingPage_installDescription, proposal.toString()); //not really feeling well here. } else if (loading || !prov.isError(mappingConfiguration)) { return EMPTY_STRING; } else { return Messages.LifecycleMappingPage_resolveLaterDescription; } } } return null; } public Image getColumnImage(Object element, int columnIndex) { if (columnIndex != 0) { return null; } if (element instanceof AggregateMappingLabelProvider) { ILifecycleMappingLabelProvider prov = (ILifecycleMappingLabelProvider) element; if (prov.isError(mappingConfiguration)) { if (!isHandled(prov)) { return MavenImages.IMG_ERROR; } } return MavenImages.IMG_PASSED; } return MavenImages.IMG_POM; } }); treeViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { if (event.getSelection() instanceof IStructuredSelection && ((IStructuredSelection) event.getSelection()).size() == 1) { ILifecycleMappingLabelProvider prov = (ILifecycleMappingLabelProvider) ((IStructuredSelection) event .getSelection()).getFirstElement(); if (ignore.contains(prov)) { details.setText(Messages.LifecycleMappingPage_doNotExecutePomDescription); license.setText(EMPTY_STRING); } else if (ignoreAtDefinition.contains(prov)) { details.setText(Messages.LifecycleMappingPage_doNotExecuteParentDescription); license.setText(EMPTY_STRING); } else { IMavenDiscoveryProposal proposal = mappingConfiguration.getSelectedProposal(prov.getKey()); details.setText(proposal != null ? proposal.getDescription() : mappingConfiguration.getProposals(prov.getKey()).isEmpty() ? NLS.bind(Messages.LifecycleMappingPage_noMarketplaceEntryDescription, prov.getMavenText()) : EMPTY_STRING); license.setText(proposal == null ? EMPTY_STRING : proposal.getLicense()); } } else { details.setText(EMPTY_STRING); license.setText(EMPTY_STRING); } } }); treeViewer.setComparator(new ViewerComparator() { public int compare(Viewer viewer, Object e1, Object e2) { if (!(e1 instanceof ILifecycleMappingLabelProvider && e2 instanceof ILifecycleMappingLabelProvider)) { return super.compare(viewer, e1, e2); } int cat1 = category(e1); int cat2 = category(e2); if (cat1 != cat2) { return cat1 - cat2; } return ((ILifecycleMappingLabelProvider) e1).getMavenText() .compareTo(((ILifecycleMappingLabelProvider) e2).getMavenText()); } }); Composite composite = new Composite(container, SWT.NONE); composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); composite.setLayout(new GridLayout(3, false)); errorCountLabel = new Label(composite, SWT.NONE); errorCountLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); Button btnNewButton_1 = new Button(composite, SWT.NONE); btnNewButton_1.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { mappingConfiguration.clearSelectedProposals(); ignore.clear(); ignoreAtDefinition.clear(); treeViewer.refresh(); getWizard().getContainer().updateButtons(); // needed to enable/disable Finish button updateErrorCount(); } }); btnNewButton_1.setText(Messages.LifecycleMappingPage_deselectAllButton); autoSelectButton = new Button(composite, SWT.NONE); autoSelectButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { ignore.clear(); ignoreAtDefinition.clear(); discoverProposals(); } }); autoSelectButton.setText(Messages.LifecycleMappingPage_autoSelectButton); // Provide a reasonable height for the details box GC gc = new GC(container); gc.setFont(JFaceResources.getDialogFont()); FontMetrics fontMetrics = gc.getFontMetrics(); gc.dispose(); Group grpDetails = new Group(container, SWT.NONE); grpDetails.setLayout(new GridLayout(1, false)); grpDetails.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1)); grpDetails.setText(Messages.LifecycleMappingPage_descriptionLabel); details = new Text(grpDetails, SWT.WRAP | SWT.READ_ONLY | SWT.V_SCROLL); GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); gd.heightHint = Dialog.convertHeightInCharsToPixels(fontMetrics, 3); gd.minimumHeight = Dialog.convertHeightInCharsToPixels(fontMetrics, 1); details.setLayoutData(gd); Group grpLicense = new Group(container, SWT.NONE); grpLicense.setLayout(new GridLayout(1, false)); grpLicense.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1)); grpLicense.setText(Messages.LifecycleMappingPage_licenseLabel); license = new Text(grpLicense, SWT.READ_ONLY); gd = new GridData(SWT.FILL, SWT.FILL, true, true); gd.heightHint = Dialog.convertHeightInCharsToPixels(fontMetrics, 1); gd.minimumHeight = Dialog.convertHeightInCharsToPixels(fontMetrics, 1); license.setLayoutData(gd); }
From source file:org.eclipse.mylyn.internal.web.tasks.WebQueryWizardPage.java
License:Open Source License
public void createControl(Composite parent) { final Composite composite = new Composite(parent, SWT.NONE); GridLayout gridLayout = new GridLayout(); gridLayout.marginHeight = 0;/*from w ww . j a va 2s .co m*/ gridLayout.marginWidth = 0; gridLayout.verticalSpacing = 0; gridLayout.numColumns = 1; composite.setLayout(gridLayout); if (!inSearchContainer()) { createTitleGroup(composite); } parametersEditor = new ParametersEditor(composite, SWT.NONE); GridData gridData1 = new GridData(SWT.FILL, SWT.FILL, true, true); gridData1.minimumHeight = 90; parametersEditor.setLayoutData(gridData1); ExpandableComposite expComposite = toolkit.createExpandableComposite(composite, ExpandableComposite.COMPACT | ExpandableComposite.TWISTIE); expComposite.setFont(parent.getFont()); GridData gridData_1 = new GridData(SWT.FILL, SWT.FILL, true, false); gridData_1.heightHint = 150; gridData_1.minimumHeight = 150; expComposite.setLayoutData(gridData_1); expComposite.setBackground(parent.getBackground()); expComposite.setText(Messages.WebQueryWizardPage_Advanced_Configuration); expComposite.addExpansionListener(new ExpansionAdapter() { @Override public void expansionStateChanged(ExpansionEvent e) { getControl().getShell().pack(); } }); toolkit.paintBordersFor(expComposite); Composite composite1 = toolkit.createComposite(expComposite, SWT.BORDER); composite1.setLayout(new GridLayout(3, false)); expComposite.setClient(composite1); toolkit.createLabel(composite1, Messages.WebQueryWizardPage_Query_URL_, SWT.NONE); queryUrlText = new Text(composite1, SWT.BORDER); final GridData gridData_2 = new GridData(SWT.FILL, SWT.CENTER, true, false); gridData_2.widthHint = 200; queryUrlText.setLayoutData(gridData_2); queryUrlText.addModifyListener(new ModifyListener() { public void modifyText(final ModifyEvent e) { webPage = null; } }); decorations.add(WebContentProposalProvider.createDecoration(queryUrlText, parametersEditor, false)); Button button = new Button(composite1, SWT.NONE); button.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); button.setText(Messages.WebQueryWizardPage_Open); button.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { openBrowser(); } }); Label queryPatternLabel = toolkit.createLabel(composite1, Messages.WebQueryWizardPage_Query_Pattern_, SWT.NONE); queryPatternLabel.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false)); queryPatternText = new Text(composite1, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.WRAP); GridData gridData = new GridData(SWT.FILL, SWT.TOP, true, false); gridData.widthHint = 200; gridData.heightHint = 60; queryPatternText.setLayoutData(gridData); decorations.add(WebContentProposalProvider.createDecoration(queryPatternText, parametersEditor, true)); Button preview = new Button(composite1, SWT.NONE); preview.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false)); preview.setText(Messages.WebQueryWizardPage_Preview); preview.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { webPage = null; updatePreview(); } }); previewTable = new TableViewer(composite1, SWT.BORDER); // previewTable = new Table(composite1, SWT.BORDER); GridData gridData2 = new GridData(SWT.FILL, SWT.FILL, false, true, 3, 1); gridData2.heightHint = 60; Table table = previewTable.getTable(); table.setLayoutData(gridData2); table.setLinesVisible(true); table.setHeaderVisible(true); TableColumn colId = new TableColumn(table, SWT.NONE); colId.setWidth(100); colId.setText(Messages.WebQueryWizardPage_Id); TableColumn colDescription = new TableColumn(table, SWT.NONE); colDescription.setWidth(200); colDescription.setText(Messages.WebQueryWizardPage_Description); TableColumn colStatus = new TableColumn(table, SWT.NONE); colStatus.setText(Messages.WebQueryWizardPage_Status); colStatus.setWidth(80); TableColumn colType = new TableColumn(table, SWT.NONE); colType.setText(Messages.WebQueryWizardPage_Type); colType.setWidth(80); TableColumn colOwner = new TableColumn(table, SWT.NONE); colOwner.setText(Messages.WebQueryWizardPage_Owner); colOwner.setWidth(120); previewTable.setColumnProperties(new String[] { "Id", "Description", "Status", "Type", "Owner" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ previewTable.setContentProvider(new IStructuredContentProvider() { public void dispose() { } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } public Object[] getElements(Object inputElement) { if (inputElement instanceof Collection<?>) { return ((Collection<?>) inputElement).toArray(); } return new Object[0]; } }); previewTable.setLabelProvider(new ITableLabelProvider() { public String getColumnText(Object element, int columnIndex) { TaskMapper task = (TaskMapper) element; switch (columnIndex) { case 0: return task.getTaskData().getTaskId(); case 1: return task.getSummary(); case 2: return task.getCompletionDate() != null ? Messages.WebQueryWizardPage_complete : Messages.WebQueryWizardPage_incomplete; case 3: return task.getTaskKind(); case 4: return task.getOwner(); } return null; } public Image getColumnImage(Object element, int columnIndex) { return null; } public void addListener(ILabelProviderListener listener) { } public void dispose() { } public boolean isLabelProperty(Object element, String property) { return false; } public void removeListener(ILabelProviderListener listener) { } }); setControl(composite); LinkedHashMap<String, String> vars = new LinkedHashMap<String, String>(); Map<String, String> params = new LinkedHashMap<String, String>(); if (getTaskRepository() != null) { queryUrlText.setText( addVars(vars, getTaskRepository().getProperty(WebRepositoryConnector.PROPERTY_QUERY_URL))); queryPatternText.setText( addVars(vars, getTaskRepository().getProperty(WebRepositoryConnector.PROPERTY_QUERY_REGEXP))); oldProperties = getTaskRepository().getProperties(); params.putAll(oldProperties); } IRepositoryQuery query = getQuery(); if (query != null) { setTitle(query.getSummary()); queryUrlText.setText(addVars(vars, query.getAttribute(WebRepositoryConnector.KEY_QUERY_TEMPLATE))); queryPatternText.setText(addVars(vars, query.getAttribute(WebRepositoryConnector.KEY_QUERY_PATTERN))); params.putAll(WebRepositoryConnector.getQueryParams(query)); } parametersEditor.addParams(params, vars); Dialog.applyDialogFont(composite); }
From source file:org.eclipse.mylyn.reviews.r4e.ui.internal.dialogs.FindUserDialog.java
License:Open Source License
/** * Method attachLabelProvider//from w w w . j av a 2s . c om * * @param aViewer * TableViewer */ private void attachLabelProvider(final TableViewer aViewer) { aViewer.setLabelProvider(new ITableLabelProvider() { public Image getColumnImage(Object aElement, int aColumnIndex) { return null; } public String getColumnText(Object aElement, int aColumnIndex) { final String[] usrElem = ((IUserInfo) aElement).getAttributeValues(); return usrElem[aColumnIndex]; } public void addListener(ILabelProviderListener listener) { } public void removeListener(ILabelProviderListener lpl) { } public void dispose() { } public boolean isLabelProperty(Object element, String property) { return false; } }); }
From source file:org.eclipse.php.internal.ui.dialogs.openType.generic.BasicSelector.java
License:Open Source License
public void setLabelProvider(IBasicSelectorLabelProvider basicSelectorLabelProvider) { this.basicSelectorLabelProvider = basicSelectorLabelProvider; this.tableViewer.setLabelProvider(new ITableLabelProvider() { public Image getColumnImage(Object element, int columnIndex) { return BasicSelector.this.basicSelectorLabelProvider.getElementImage(element); }//w w w . ja v a2 s . c o m public String getColumnText(Object element, int columnIndex) { return BasicSelector.this.basicSelectorLabelProvider.getElementDescription(element); } public void addListener(ILabelProviderListener listener) { } public void dispose() { } public boolean isLabelProperty(Object element, String property) { return false; } public void removeListener(ILabelProviderListener listener) { } }); }
From source file:org.eclipse.ptp.ui.views.ParallelMachinesView.java
License:Open Source License
/** * Create lower text region layout//www .j a va 2s. co m * * @param parent * @return */ protected Composite createLowerRegions(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(2, true); layout.verticalSpacing = 0; layout.horizontalSpacing = 0; composite.setLayout(layout); composite.setLayoutData(new GridData(GridData.FILL_BOTH)); /* inner bottom composite - this one uses a grid layout */ Group nodeGroup = new Group(composite, SWT.BORDER); nodeGroup.setLayout(new FillLayout()); GridData gdtext = new GridData(GridData.FILL_BOTH); gdtext.grabExcessVerticalSpace = true; gdtext.grabExcessHorizontalSpace = true; gdtext.horizontalAlignment = GridData.FILL; gdtext.verticalAlignment = GridData.FILL; nodeGroup.setLayoutData(gdtext); nodeGroup.setText(Messages.ParallelMachinesView_1); Group procGroup = new Group(composite, SWT.BORDER); procGroup.setLayout(new FillLayout()); GridData gdlist = new GridData(GridData.FILL_BOTH); gdlist.grabExcessVerticalSpace = true; gdlist.grabExcessHorizontalSpace = true; gdlist.horizontalAlignment = GridData.FILL; gdlist.verticalAlignment = GridData.FILL; procGroup.setLayoutData(gdlist); procGroup.setText(Messages.ParallelMachinesView_2); nodeAttrTableViewer = new TableViewer(nodeGroup, SWT.FULL_SELECTION | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); Table nodeAttrTable = nodeAttrTableViewer.getTable(); TableColumn col = new TableColumn(nodeAttrTable, SWT.LEFT); col.setText(Messages.ParallelMachinesView_3); col.setWidth(80); col.setResizable(true); col = new TableColumn(nodeAttrTable, SWT.LEFT); col.setText(Messages.ParallelMachinesView_4); col.setWidth(200); col.setResizable(false); nodeAttrTable.setHeaderVisible(true); nodeAttrTable.setLinesVisible(true); nodeAttrTable.addControlListener(new ControlListener() { public void controlMoved(ControlEvent e) { } public void controlResized(ControlEvent e) { Table table = (Table) e.getSource(); int width = table.getClientArea().width; switch (table.getColumnCount()) { case 1: table.getColumn(0).setWidth(width); break; case 2: TableColumn col0 = table.getColumn(0); TableColumn col1 = table.getColumn(1); if (col0.getWidth() + col1.getWidth() < width) { col1.setWidth(width - col0.getWidth()); } } } }); nodeAttrTableViewer.setLabelProvider(new ITableLabelProvider() { public void addListener(ILabelProviderListener listener) { } public void dispose() { } public Image getColumnImage(Object element, int columnIndex) { return null; } public String getColumnText(Object element, int columnIndex) { if (element instanceof IAttribute) { IAttribute<?, ?, ?> attr = (IAttribute<?, ?, ?>) element; switch (columnIndex) { case 0: return attr.getDefinition().getName(); case 1: return attr.getValueAsString(); default: return Messages.ParallelMachinesView_5 + columnIndex; } } return ""; //$NON-NLS-1$ } public boolean isLabelProperty(Object element, String property) { return false; } public void removeListener(ILabelProviderListener listener) { } }); nodeAttrTableViewer.setContentProvider(new IStructuredContentProvider() { public void dispose() { } public Object[] getElements(Object inputElement) { if (inputElement instanceof IElementManager) { IPNode node = getRegisteredNode(); if (node != null) { return node.getDisplayAttributes(); } } return new Object[0]; } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } }); nodeAttrTableViewer.setSorter(new ViewerSorter() { @Override public int compare(Viewer viewer, Object a1, Object a2) { final IAttribute<?, ?, ?> attr1 = (IAttribute<?, ?, ?>) a1; final IAttribute<?, ?, ?> attr2 = (IAttribute<?, ?, ?>) a2; final IAttributeDefinition<?, ?, ?> def1 = attr1.getDefinition(); final IAttributeDefinition<?, ?, ?> def2 = attr2.getDefinition(); return def1.compareTo(def2); } }); nodeAttrTableViewer.setInput(manager); processTableViewer = new TableViewer(procGroup, SWT.FULL_SELECTION | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); Table processTable = processTableViewer.getTable(); new TableColumn(processTable, SWT.LEFT).setWidth(300); processTable.setLinesVisible(true); processTable.addControlListener(new ControlListener() { public void controlMoved(ControlEvent e) { } public void controlResized(ControlEvent e) { Table table = (Table) e.getSource(); int width = table.getClientArea().width; switch (table.getColumnCount()) { case 1: table.getColumn(0).setWidth(width); break; case 2: TableColumn col0 = table.getColumn(0); TableColumn col1 = table.getColumn(1); if (col0.getWidth() + col1.getWidth() < width) { col1.setWidth(width - col0.getWidth()); } } } }); processTableViewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { IStructuredSelection sel = (IStructuredSelection) event.getSelection(); // FIXME PProcessUI goes away when we address UI scalability. // See Bug 311057 openProcessViewer((PProcessUI) sel.getFirstElement()); } }); processTableViewer.setLabelProvider(new LabelProvider() { @Override public Image getImage(Object element) { if (element instanceof PProcessUI) { // FIXME PProcessUI goes away when we address UI // scalability. See Bug 311057 PProcessUI process = (PProcessUI) element; return ParallelImages.procImages[process.getState().ordinal()][0]; } return null; } @Override public String getText(Object element) { if (element instanceof PProcessUI) { // FIXME PProcessUI goes away when we address UI // scalability. See Bug 311057 PProcessUI process = (PProcessUI) element; return process.getJob().getName() + ":" + process.getName(); //$NON-NLS-1$ } return ""; //$NON-NLS-1$ } }); processTableViewer.setContentProvider(new IStructuredContentProvider() { public void dispose() { } public Object[] getElements(Object inputElement) { if (inputElement instanceof IElementManager) { IPNode node = getRegisteredNode(); if (node != null) { // FIXME PProcessUI goes away when we address UI // scalability. See Bug 311057 final List<PProcessUI> procUIs = new LinkedList<PProcessUI>(); final Set<? extends IPJob> jobs = node.getJobs(); for (IPJob job : jobs) { final BitSet procJobRanks = node.getJobProcessRanks(job); for (Integer procJobRank : new BitSetIterable(procJobRanks)) { procUIs.add(new PProcessUI(job, procJobRank)); } } return procUIs.toArray(new PProcessUI[0]); } } return new Object[0]; } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } }); processTableViewer.setSorter(new ViewerSorter() { @Override public int compare(Viewer viewer, Object p1, Object p2) { // FIXME PProcessUI goes away when we address UI scalability. // See Bug 311057 PProcessUI proc1 = (PProcessUI) p1; PProcessUI proc2 = (PProcessUI) p2; String name1 = proc1.getJob().getName() + ":" + proc1.getName(); //$NON-NLS-1$ String name2 = proc2.getJob().getName() + ":" + proc2.getName(); //$NON-NLS-1$ return name1.compareTo(name2); } }); processTableViewer.setInput(manager); return composite; }
From source file:org.eclipse.reqcycle.predicates.ui.dialogs.CheckBoxInputDialog.java
License:Open Source License
private ITableLabelProvider getDefaultLabelProvider() { return new ITableLabelProvider() { @Override//w w w .j a v a2 s.com public void removeListener(ILabelProviderListener listener) { } @Override public boolean isLabelProperty(Object element, String property) { return false; } @Override public void dispose() { } @Override public void addListener(ILabelProviderListener listener) { } @Override public String getColumnText(Object element, int columnIndex) { return element.toString(); } @Override public Image getColumnImage(Object element, int columnIndex) { return null; } }; }
From source file:org.eclipse.team.svn.ui.action.remote.CheckoutAction.java
License:Open Source License
public static ArrayList getOperateResources(HashMap names2resources, final HashMap resources2names, Shell shell, final String location, boolean checkProjectExistance) { NameSet set = CheckoutAction.getExistingProjectNames(); final HashMap existingResources = new HashMap(); final HashMap existingFolders = new HashMap(); ArrayList operateResources = new ArrayList(); File folder;//from w w w . j a va2 s. com for (Iterator iter = names2resources.keySet().iterator(); iter.hasNext();) { String key = (String) iter.next(); String resourceName = FileUtility.formatResourceName(key); Object currentResource = names2resources.get(key); folder = new File(location + "/" + resourceName); //$NON-NLS-1$ if (set.existing.keySet().contains(set.caseInsensitiveOS ? resourceName.toLowerCase() : resourceName) && checkProjectExistance) { existingResources.put(resourceName, currentResource); if (!FileUtility.formatPath(folder.getAbsolutePath()).equals( set.existing.get(set.caseInsensitiveOS ? resourceName.toLowerCase() : resourceName))) { if (folder.exists() && (folder.listFiles() != null && folder.listFiles().length > 0 || folder.isFile())) { existingFolders.put(resourceName, currentResource); } } } else { if (folder.exists() && (folder.listFiles() != null && folder.listFiles().length > 0 || folder.isFile())) { existingFolders.put(resourceName, currentResource); } else { operateResources.add(currentResource); } } } // if some of chosen projects already exist in workspace - let the user decide which of them should be overriden if (existingResources.size() > 0 || existingFolders.size() > 0) { IStructuredContentProvider contentProvider = new IStructuredContentProvider() { public Object[] getElements(Object inputElement) { Set existingSet = new HashSet(); existingSet.addAll(existingResources.keySet()); existingSet.addAll(existingFolders.keySet()); String[] retVal = (String[]) existingSet.toArray(new String[existingSet.size()]); Arrays.sort(retVal); return retVal; } public void dispose() { } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } }; ITableLabelProvider labelProvider = new ITableLabelProvider() { public Image getColumnImage(Object element, int columnIndex) { return null; } public String getColumnText(Object element, int columnIndex) { if (columnIndex == 0) { return (String) element; } else if (columnIndex == 1) { boolean project = existingResources.keySet().contains(element); boolean folder = existingFolders.keySet().contains(element); if (project && folder) { return SVNUIMessages.CheckoutAction_Type2; } else if (project) { return SVNUIMessages.CheckoutAction_Type1; } else if (folder) { return new File(location + "/" + element).isDirectory() //$NON-NLS-1$ ? SVNUIMessages.CheckoutAction_Type3 : SVNUIMessages.CheckoutAction_Type4; } return ""; //$NON-NLS-1$ } return null; } public void addListener(ILabelProviderListener listener) { } public void dispose() { } public boolean isLabelProperty(Object element, String property) { return false; } public void removeListener(ILabelProviderListener listener) { } }; String message = existingResources.size() > 1 ? SVNUIMessages.CheckoutAction_Selection_Description_Multi : SVNUIMessages.CheckoutAction_Selection_Description_Single; ListSelectionPanel panel = new ListSelectionPanel(existingResources, contentProvider, labelProvider, message, existingResources.size() > 1 ? SVNUIMessages.CheckoutAction_Selection_Message_Multi : SVNUIMessages.CheckoutAction_Selection_Message_Single, existingResources.size() > 1 ? SVNUIMessages.CheckoutAction_Selection_Title_Multi : SVNUIMessages.CheckoutAction_Selection_Title_Single, true); if (new DefaultDialog(shell, panel).open() == 0) { Object[] selection = panel.getResultSelections(); for (int i = 0; i < selection.length; i++) { Object selected = existingResources.get(selection[i]); selected = selected == null ? existingFolders.get(selection[i]) : selected; operateResources.add(selected); } } else { operateResources.clear(); } } return operateResources; }