List of usage examples for org.eclipse.jface.viewers IStructuredSelection isEmpty
public boolean isEmpty();
From source file:com.symbian.smt.gui.smtwidgets.resources.ResourcesWidget.java
License:Open Source License
private void checkFilesInResourceFilesTable(String[] filenames, ResourcesEnums resourceType) { if (filenames == null) { throw new IllegalArgumentException("Argument filenames cannot be null."); }// w w w. jav a 2s . c o m java.util.List<String> listOfFilenames = Helper.toListOfStrings(filenames); java.util.List<CheckableResourceFilename> checkableFilenames = resourceFilesMap.get(resourceType); if (checkableFilenames == null) { throw new IllegalArgumentException( "Could not find any elements of type [" + resourceType + "] in resourceFilesMap."); } CheckableResourceFilename[] viewerElementsToBeChecked = new CheckableResourceFilename[filenames.length]; int i = 0; for (String filename : listOfFilenames) { CheckableResourceFilename checkableFilename = ResourcesWidgetHelper.filename2checkableFilename(filename, resourceType, resourceFilesMap); checkableFilename.setChecked(true); viewerElementsToBeChecked[i] = checkableFilename; i++; } IStructuredSelection ssel = (IStructuredSelection) resourceTypesViewer.getSelection(); if (!ssel.isEmpty()) { ResourcesEnums selectedType = (ResourcesEnums) ssel.getFirstElement(); if (selectedType.equals(resourceType)) { resourceFilesViewer.setCheckedElements(viewerElementsToBeChecked); } } }
From source file:com.symbian.smt.gui.smtwidgets.resources.ResourcesWidget.java
License:Open Source License
private void createResourceTypesComposite(SashForm sash) { // The Composite that contains the resource types list, along with a // label//from w ww . j av a2s. com Composite resourceTypesComposite = new Composite(sash, SWT.NONE); GridData gd = new GridData(SWT.BEGINNING, SWT.FILL, false, true, 1, 1); resourceTypesComposite.setLayoutData(gd); resourceTypesComposite.setLayout(new GridLayout()); Label l = new Label(resourceTypesComposite, SWT.NONE); gd = new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false, 1, 1); l.setLayoutData(gd); l.setText("Resource Types"); // The List that contains all possible resource types final List list = new List(resourceTypesComposite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE); gd = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1); list.setLayoutData(gd); // The resource type viewer associated with the list resourceTypesViewer = new ListViewer(list); resourceTypesViewer.setContentProvider(new ResourceTypesContentProvider()); resourceTypesViewer.setLabelProvider(new ResourceTypesLabelProvider()); resourceTypesViewer.setInput(ResourcesEnums.values()); resourceTypesViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection ssel = (IStructuredSelection) event.getSelection(); if (ssel.isEmpty()) { return; } ResourcesEnums selectedType = (ResourcesEnums) ssel.getFirstElement(); resourceFilesViewer.setInput( ResourcesWidgetHelper.getCheckableResourceFilenames(selectedType, resourceFilesMap)); resourceFilesViewer.setCheckedElements( ResourcesWidgetHelper.getCheckedResourceFilenames(selectedType, resourceFilesMap)); } }); }
From source file:com.symbian.smt.gui.smtwidgets.resources.ResourcesWidget.java
License:Open Source License
private void populateResourceFilesTable(String[] filenames, ResourcesEnums resourceType) { java.util.List<String> listOfFilenames = Helper.toListOfStrings(filenames); java.util.List<CheckableResourceFilename> checkableFilenames = new ArrayList<CheckableResourceFilename>(); for (String filename : listOfFilenames) { CheckableResourceFilename crf = new CheckableResourceFilename(filename); checkableFilenames.add(crf);/*w w w . j a va 2 s. c o m*/ } IStructuredSelection ssel = (IStructuredSelection) resourceTypesViewer.getSelection(); if (!ssel.isEmpty()) { ResourcesEnums selectedType = (ResourcesEnums) ssel.getFirstElement(); if (selectedType.equals(resourceType)) { resourceFilesViewer.setInput(checkableFilenames); } } resourceFilesMap.put(resourceType, checkableFilenames); }
From source file:com.symbian.tdep.templates.carbide.templatewizard.NewSymbianOSCppTestClassWizard.java
License:Open Source License
public void addPages() { String s = Messages.getString("NewSymbianOSCppClassWizard.ChooseProjectPageTitle"); String s1 = Messages.getString("NewSymbianOSCppClassWizard.ChooseProjectPageDesc"); chooseProjectPage = new ChooseProjectPage(s, s1); IStructuredSelection istructuredselection = getSelection(); if (!istructuredselection.isEmpty()) { Object obj = istructuredselection.getFirstElement(); if (obj instanceof ICProject) obj = ((ICProject) obj).getProject(); if (obj instanceof IProject) chooseProjectPage.setInitialSelection((IProject) obj); }// w w w.j a va 2 s. co m addPage(chooseProjectPage); super.addPages(); }
From source file:com.technophobia.substeps.junit.launcher.tab.SubstepsArgumentTab.java
License:Open Source License
private IResource getContext() { final IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (activeWorkbenchWindow == null) { return null; }//from ww w . j ava 2 s .c o m final IWorkbenchPage page = activeWorkbenchWindow.getActivePage(); if (page != null) { final ISelection selection = page.getSelection(); if (selection instanceof IStructuredSelection) { final IStructuredSelection ss = (IStructuredSelection) selection; if (!ss.isEmpty()) { final Object obj = ss.getFirstElement(); if (obj instanceof IResource) { return (IResource) obj; } } } final IEditorPart part = page.getActiveEditor(); if (part != null) { final IEditorInput input = part.getEditorInput(); return (IResource) input.getAdapter(IResource.class); } } return null; }
From source file:com.technophobia.substeps.junit.ui.component.FeatureViewer.java
License:Open Source License
void handleMenuAboutToShow(final IMenuManager manager) { final IStructuredSelection selection = (IStructuredSelection) selectionProvider.getSelection(); if (!selection.isEmpty()) { final SubstepsTestElement testElement = (SubstepsTestElement) selection.getFirstElement(); final String className = testElement.getClassName(); if (testElement instanceof SubstepsTestParentElement) { manager.add(new OpenFeatureAction(testElement)); manager.add(new Separator()); if (testClassExists(className) && !testRunSession.isKeptAlive()) { manager.add(new RerunTestAction(SubstepsFeatureMessages.RerunAction_label_run, testRunner, testElement.getId(), className, null, ILaunchManager.RUN_MODE)); manager.add(new RerunTestAction(SubstepsFeatureMessages.RerunAction_label_debug, testRunner, testElement.getId(), className, null, ILaunchManager.DEBUG_MODE)); }/*from w ww. j a va2s . c o m*/ } else { final SubstepsTestLeafElement testCaseElement = (SubstepsTestLeafElement) testElement; final String testMethodName = testCaseElement.getTestMethodName(); manager.add(new OpenFeatureAction(testElement)); manager.add(new Separator()); if (testRunSession.isKeptAlive()) { manager.add(new RerunTestAction(SubstepsFeatureMessages.RerunAction_label_rerun, testRunner, testElement.getId(), className, testMethodName, ILaunchManager.RUN_MODE)); } else { manager.add(new RerunTestAction(SubstepsFeatureMessages.RerunAction_label_run, testRunner, testElement.getId(), className, testMethodName, ILaunchManager.RUN_MODE)); manager.add(new RerunTestAction(SubstepsFeatureMessages.RerunAction_label_debug, testRunner, testElement.getId(), className, testMethodName, ILaunchManager.DEBUG_MODE)); } } if (layoutMode.equals(ViewLayout.HIERARCHICAL)) { manager.add(new Separator()); manager.add(new ExpandAllAction()); } } // if (testRunSession != null && testRunSession.getFailureCount() + // testRunSession.getErrorCount() > 0) { // if (!layoutMode.equals(ViewLayout.HIERARCHICAL)) // manager.add(new Separator()); // manager.add(new CopyFailureListAction(testRunnerPart, clipboard)); // } manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS + "-end")); //$NON-NLS-1$ }
From source file:com.toubassi.filebunker.ui.configuration.ConfigurationDialog.java
License:Open Source License
private void createRepositoriesArea(Composite parent) { Composite buttonsComposite = new Composite(parent, SWT.NONE); GridLayout buttonsLayout = new GridLayout(1, true); buttonsLayout.marginHeight = 0;/*from w ww.java2 s . c o m*/ buttonsLayout.marginWidth = 0; buttonsLayout.verticalSpacing = 5; buttonsComposite.setLayout(buttonsLayout); FormData buttonsCompositeFormData = new FormData(); buttonsCompositeFormData.top = new FormAttachment(0, 0); buttonsCompositeFormData.right = new FormAttachment(100, 0); buttonsComposite.setLayoutData(buttonsCompositeFormData); newButton = new Button(buttonsComposite, SWT.NONE); setControlHint(newButton, newButtonHint); newButton.setText("New"); editButton = new Button(buttonsComposite, SWT.NONE); setControlHint(editButton, editButtonHint); editButton.setText("Edit"); deleteButton = new Button(buttonsComposite, SWT.NONE); setControlHint(deleteButton, deleteButtonHint); deleteButton.setText("Delete"); Point deleteSize = deleteButton.computeSize(SWT.DEFAULT, SWT.DEFAULT); int buttonWidth = (int) (deleteSize.x * 1.5); GridData newButtonGridData = new GridData(GridData.FILL_HORIZONTAL); newButtonGridData.widthHint = buttonWidth; newButton.setLayoutData(newButtonGridData); GridData editButtonGridData = new GridData(GridData.FILL_HORIZONTAL); editButtonGridData.widthHint = buttonWidth; editButton.setLayoutData(editButtonGridData); GridData deleteButtonGridData = new GridData(GridData.FILL_HORIZONTAL); deleteButtonGridData.widthHint = buttonWidth; deleteButton.setLayoutData(deleteButtonGridData); newButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { newClicked(); } }); editButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { editClicked(); } }); deleteButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { deleteClicked(); } }); editButton.setEnabled(false); deleteButton.setEnabled(false); storeListViewer = new ListViewer(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); FormData storeListViewerFormData = new FormData(); storeListViewerFormData.top = new FormAttachment(buttonsComposite, 0, SWT.TOP); storeListViewerFormData.left = new FormAttachment(0, 0); storeListViewerFormData.right = new FormAttachment(buttonsComposite, -15); storeListViewerFormData.bottom = new FormAttachment(100, -10); storeListViewerFormData.height = 100; setControlHint(storeListViewer.getList(), storeListViewerHint); storeListViewer.getControl().setLayoutData(storeListViewerFormData); storeListViewer.setContentProvider(new FileStoreListContentProvider(stores)); storeListViewer.setLabelProvider(new FileStoreListLabelProvider()); storeListViewer.setInput(new Object()); storeListViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); editButton.setEnabled(!selection.isEmpty()); deleteButton.setEnabled(!selection.isEmpty()); } }); storeListViewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { editClicked(); } }); Object first = storeListViewer.getElementAt(0); if (first != null) { storeListViewer.setSelection(new StructuredSelection(first)); } }
From source file:com.toubassi.jface.ObjectChooserDialog.java
License:Open Source License
protected void okPressed() { IStructuredSelection selection = (IStructuredSelection) listViewer.getSelection(); if (!selection.isEmpty()) { chosenObject = selection.getFirstElement(); close();/*from ww w . j av a2 s. c o m*/ } }
From source file:com.twinsoft.convertigo.eclipse.property_editors.NamedSourceSelectorEditorComposite.java
License:Open Source License
@Override public void selectionChanged(SelectionChangedEvent event) { try {/*from w w w. ja va 2 s . c o m*/ if (event.getSelection() instanceof IStructuredSelection) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); parentDialog.enableOK(selection.isEmpty() || ((TVObject) selection.getFirstElement()).isSelectable); } } catch (Exception e) { parentDialog.enableOK(false); } }
From source file:com.twinsoft.convertigo.eclipse.views.loggers.EngineLogView.java
License:Open Source License
private void setFilterText(IStructuredSelection selection, int buttonIndex) { if (!selection.isEmpty()) { LogLine logline = (LogLine) selection.getFirstElement(); String columnName = tableViewer.getTable().getColumn(selectedColumnIndex).getText(); String cellValue = getSelectedCellText(columnName, logline); if (cellValue == null) return; String variableName = columnName.toLowerCase(); String filter = filterText.getText(); String txt;/*from ww w. j a v a2s. c o m*/ if (filter.contains("==") || filter.contains("contains") || filter.contains("startsWith") || filter.contains("endsWith")) { filter = filter + " and "; } switch (buttonIndex) { case 0: txt = filter + "(" + variableName + " == \"" + cellValue.replaceAll("\"", "\\\\\"") + "\")"; filterText.setText(txt); break; case 1: txt = filter + "(" + variableName + ".contains(\"" + cellValue.replaceAll("\"", "\\\\\"") + "\"))"; filterText.setText(txt); break; case 2: txt = filter + "(" + variableName + ".startsWith(\"" + cellValue.replaceAll("\"", "\\\\\"") + "\"))"; filterText.setText(txt); break; case 3: txt = filter + "(" + variableName + ".endsWith(\"" + cellValue.replaceAll("\"", "\\\\\"") + "\"))"; filterText.setText(txt); break; case 4: // Add variable txt = filter + "(" + variableName + " == \"" + ((cellValue != null && cellValue != "") ? cellValue.replaceAll("\"", "\\\\\"") : "undefined") + "\")"; filterText.setText(txt); break; default: break; } } }