List of usage examples for org.eclipse.jface.viewers StructuredSelection isEmpty
@Override public boolean isEmpty()
From source file:org.apache.directory.studio.templateeditor.view.preferences.TemplateEntryEditorPreferencePage.java
License:Apache License
/** * Implements the set default template action. *///from w w w . j ava 2 s . c o m private void setDefaultTemplateAction() { StructuredSelection selection = (StructuredSelection) templatesViewer.getSelection(); if (!selection.isEmpty()) { Object selectedObject = selection.getFirstElement(); if (selectedObject instanceof Template) { manager.setDefaultTemplate((Template) selectedObject); templatesViewer.refresh(); updateButtonsStates(); } } }
From source file:org.apache.directory.studio.valueeditors.time.GeneralizedTimeValueDialog.java
License:Apache License
/** * Updates the value using the non raw fields. *//* w ww . jav a2 s .co m*/ private void updateValueFromNonRawFields() { // Retain the format of the GeneralizedTime value // by only updating its calendar object. Calendar calendar = value.getCalendar(); // Time calendar.set(Calendar.HOUR_OF_DAY, hoursSpinner.getSelection()); calendar.set(Calendar.MINUTE, minutesSpinner.getSelection()); calendar.set(Calendar.SECOND, secondsSpinner.getSelection()); // Date calendar.set(Calendar.YEAR, dateCalendar.getYear()); calendar.set(Calendar.MONTH, dateCalendar.getMonth()); calendar.set(Calendar.DAY_OF_MONTH, dateCalendar.getDay()); // Time zone StructuredSelection selection = (StructuredSelection) timezoneComboViewer.getSelection(); if ((selection != null) && (!selection.isEmpty())) { calendar.setTimeZone((TimeZone) selection.getFirstElement()); } }
From source file:org.apache.easyant4e.ivyde.extension.page.BuildLifecycleBlock.java
License:Apache License
protected void createBuildLifecyclePart(final IManagedForm managedForm, final Composite parent) { FormToolkit toolkit = managedForm.getToolkit(); Section section = toolkit.createSection(parent, Section.DESCRIPTION | Section.TITLE_BAR); section.setText("Build Lifecycle"); section.setDescription("The build lifecycle has the following build phases:"); section.marginWidth = 10;/*from w w w.ja va 2s .c o m*/ section.marginHeight = 5; Composite client = toolkit.createComposite(section, SWT.WRAP); GridLayout layout = new GridLayout(); layout.numColumns = 2; layout.marginWidth = 2; layout.marginHeight = 2; client.setLayout(layout); toolkit.paintBordersFor(client); section.setClient(client); final SectionPart spart = new SectionPart(section); managedForm.addPart(spart); TreeViewer viewer = new TreeViewer(client); GridData gd = new GridData(GridData.FILL_BOTH); gd.heightHint = 20; gd.widthHint = 100; viewer.getTree().setLayoutData(gd); viewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { managedForm.fireSelectionChanged(spart, event.getSelection()); } }); viewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { ISelection selection = event.getSelection(); if (selection instanceof StructuredSelection) { StructuredSelection structuredSelection = (StructuredSelection) selection; if (!structuredSelection.isEmpty()) { Object o = structuredSelection.getFirstElement(); if (o instanceof PhaseReport) { runPhase((PhaseReport) o); } else if (o instanceof TargetReport) { runTarget((TargetReport) o); } } } } }); viewer.setContentProvider(buildLifeCycleContentProvider); viewer.setLabelProvider(buildLifecycleLabelProvider); viewer.setInput(page.getEditor().getEditorInput()); // viewer.expandAll(); }
From source file:org.apache.easyant4e.natures.AddEasyAntNatureAction.java
License:Apache License
public void selectionChanged(IAction action, ISelection selection) { if (selection instanceof StructuredSelection) { StructuredSelection structuredSelection = (StructuredSelection) selection; if (!structuredSelection.isEmpty() && structuredSelection.getFirstElement() instanceof IProject) { IProject project = (IProject) structuredSelection.getFirstElement(); if (project.isAccessible()) { this.selectedProject = project; if (action != null) { action.setEnabled(!easyantProjectService.hasEasyAntNature(project)); }//from w w w . j a v a2 s . c o m } } } }
From source file:org.apache.easyant4e.natures.RemoveEasyAntNatureAction.java
License:Apache License
public void selectionChanged(IAction action, ISelection selection) { if (selection instanceof StructuredSelection) { StructuredSelection structuredSelection = (StructuredSelection) selection; if (!structuredSelection.isEmpty() && structuredSelection.getFirstElement() instanceof IProject) { IProject project = (IProject) structuredSelection.getFirstElement(); if (project.isAccessible()) { this.selectedProject = project; if (action != null) { action.setEnabled(easyantProjectService.hasEasyAntNature(project)); }//from www . j a v a 2s.c o m } } } }
From source file:org.apache.opennlp.caseditor.namefinder.NameFinderViewPage.java
License:Apache License
public void createControl(Composite parent) { book = new PageBook(parent, SWT.NONE); messageText = new Text(book, SWT.WRAP | SWT.READ_ONLY); messageText.setText("Loading name finder models ..."); entityList = new TableViewer(book, SWT.NONE); Table entityTable = entityList.getTable(); entityTable.setHeaderVisible(true);//from www .j ava 2 s . c om entityTable.setLinesVisible(true); TableViewerColumn confidenceViewerColumn = new TableViewerColumn(entityList, SWT.NONE); TableColumn confidenceColumn = confidenceViewerColumn.getColumn(); confidenceColumn.setText("%"); confidenceColumn.setWidth(40); TableViewerColumn entityViewerColumn = new TableViewerColumn(entityList, SWT.NONE); TableColumn entityColumn = entityViewerColumn.getColumn(); entityColumn.setText("Entity"); entityColumn.setWidth(135); TableViewerColumn typeViewerColumn = new TableViewerColumn(entityList, SWT.NONE); TableColumn typeColumn = typeViewerColumn.getColumn(); typeColumn.setText("Type"); typeColumn.setWidth(40); entityList.setLabelProvider(new PotentialEntityAnnotationLabelProvider()); entityList.setContentProvider(new EntityContentProvider(this, (AnnotationEditor) editor, entityList)); getSite().setSelectionProvider(entityList); entityList.setComparator(new PotentialAnnotationComperator()); entityList.setInput(editor.getDocument()); getSite().setSelectionProvider(entityList); entityList.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { StructuredSelection selection = (StructuredSelection) event.getSelection(); // There are two types of entities, confirmed and un-confirmed. // Confirmed entities are linked with the according annotation and // are selected through the entity lists selection provider. // Unconfirmed entities are not selected, but the span they are covering // is highlighted and revealed in the Annotation Editor. if (!selection.isEmpty()) { PotentialAnnotation entity = (PotentialAnnotation) selection.getFirstElement(); if (editor instanceof AnnotationEditor) { ((AnnotationEditor) editor).selectAndReveal(entity.getBeginIndex(), entity.getEndIndex() - entity.getBeginIndex()); } } } }); // Display the messageLabel after start up book.showPage(messageText); getSite().getPage().addSelectionListener(this); }
From source file:org.apache.opennlp.caseditor.sentdetect.SentenceDetectorViewPage.java
License:Apache License
@Override public void createControl(Composite parent) { book = new PageBook(parent, SWT.NONE); messageText = new Text(book, SWT.WRAP | SWT.READ_ONLY); messageText.setText("Loading tokenizer model ..."); sentenceList = new TableViewer(book, SWT.NONE); Table entityTable = sentenceList.getTable(); entityTable.setHeaderVisible(true);//from w w w . j a va2 s . c o m entityTable.setLinesVisible(true); TableViewerColumn confidenceViewerColumn = new TableViewerColumn(sentenceList, SWT.NONE); TableColumn confidenceColumn = confidenceViewerColumn.getColumn(); confidenceColumn.setText("%"); confidenceColumn.setWidth(40); TableViewerColumn entityViewerColumn = new TableViewerColumn(sentenceList, SWT.NONE); TableColumn entityColumn = entityViewerColumn.getColumn(); entityColumn.setText("Sentence"); entityColumn.setWidth(135); // TODO: Label provider needs support to display being and end of long texts ... // text in-between can be replaced by three dots. sentenceList.setLabelProvider(new SentenceLabelProvider()); SentenceDetectorJob sentenceDetector = new SentenceDetectorJob(); contentProvider = new SentenceContentProvider(this, (AnnotationEditor) editor, sentenceDetector, sentenceList); sentenceList.setContentProvider(contentProvider); getSite().setSelectionProvider(sentenceList); sentenceList.setInput(editor.getDocument()); sentenceList.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { // if confirmed, send selection event for FS // else, do selectAndReveal StructuredSelection selection = (StructuredSelection) event.getSelection(); if (!selection.isEmpty()) { PotentialAnnotation entity = (PotentialAnnotation) selection.getFirstElement(); if (editor instanceof AnnotationEditor) { ((AnnotationEditor) editor).selectAndReveal(entity.getBeginIndex(), entity.getEndIndex() - entity.getBeginIndex()); } } } }); book.showPage(messageText); }
From source file:org.apache.opennlp.corpus_server.caseditor.CorpusExplorerView.java
License:Apache License
@Override public void createPartControl(Composite parent) { explorerComposite = new Composite(parent, SWT.NONE); GridLayout explorerLayout = new GridLayout(); explorerLayout.numColumns = 2;/*from www. j av a 2s . c o m*/ explorerComposite.setLayout(explorerLayout); // URL field to connect to corpus server and corpus Label serverLabel = new Label(explorerComposite, SWT.NONE); serverLabel.setText("Server:"); serverUrl = new Text(explorerComposite, SWT.BORDER); GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(serverUrl); final IPreferenceStore store = CorpusServerPlugin.getDefault().getPreferenceStore(); String lastUsedServer = store.getString(CorpusServerPreferenceConstants.LAST_USED_SERVER_ADDRESS); if (lastUsedServer.isEmpty()) { lastUsedServer = "http://localhost:8080/corpus-server/rest/corpora/wikinews"; } serverUrl.setText(lastUsedServer); serverUrl.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent event) { store.setValue(CorpusServerPreferenceConstants.LAST_USED_SERVER_ADDRESS, serverUrl.getText()); } }); // Search field to view content of corpus Label queryLabel = new Label(explorerComposite, SWT.NONE); queryLabel.setText("Query"); queryText = new Combo(explorerComposite, SWT.BORDER); GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(queryText); String lastUsedSearchQueriesString = store .getString(CorpusServerPreferenceConstants.LAST_USED_SEARCH_QUERIES); // TODO: Set default via preference initializer if (lastUsedSearchQueriesString.isEmpty()) { lastUsedSearchQueriesString = "*:*"; } String lastUsedQueries[] = lastUsedSearchQueriesString.split(LUCENE_QUERY_DELIMITER); if (lastUsedQueries.length > 0) queryText.setText(lastUsedQueries[0]); for (int i = 0; i < lastUsedQueries.length; i++) { queryText.add(lastUsedQueries[i]); } queryText.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent event) { doSearch(); } @Override public void widgetDefaultSelected(SelectionEvent event) { } }); queryText.addKeyListener(new KeyListener() { @Override public void keyReleased(KeyEvent event) { if (event.character == SWT.CR) doSearch(); } @Override public void keyPressed(KeyEvent event) { } }); Button queryServer = new Button(explorerComposite, SWT.BORDER); queryServer.setText("Query"); GridDataFactory.swtDefaults().span(2, 1).align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(queryServer); queryServer.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent event) { doSearch(); } @Override public void widgetDefaultSelected(SelectionEvent event) { } }); book = new PageBook(explorerComposite, SWT.NONE); GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).span(2, 1).applyTo(book); messageText = new Text(book, SWT.WRAP | SWT.READ_ONLY); messageText.setText("Enter the server address and a query to search a corpus on the Corpus Server."); // List with casIds in the corpus ... (might be later replaced with a title) // The table should later be virtual, and be able to scroll through very huge // lits of CASes ... might be connected to a repository with million of documents searchResultViewer = new TableViewer(book); GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).span(2, 1) .applyTo(searchResultViewer.getControl()); searchResultViewer.setLabelProvider(new ITableLabelProvider() { @Override public void addListener(ILabelProviderListener arg0) { } @Override public void dispose() { } @Override public boolean isLabelProperty(Object arg0, String arg1) { return false; } @Override public void removeListener(ILabelProviderListener arg0) { } @Override public Image getColumnImage(Object arg0, int arg1) { return null; } @Override public String getColumnText(Object arg0, int arg1) { return arg0.toString(); } }); searchResultViewer.addOpenListener(new IOpenListener() { @Override public void open(OpenEvent event) { IWorkbenchPage page = CorpusExplorerView.this.getSite().getPage(); StructuredSelection selection = (StructuredSelection) searchResultViewer.getSelection(); if (selection.isEmpty()) return; String selectedCAS = (String) selection.getFirstElement(); // Hard code it for now, lets work on retrieval code first ... IEditorInput input = new CorpusServerCasEditorInput(serverUrl.getText(), selectedCAS); try { page.openEditor(input, "org.apache.uima.caseditor.editor"); } catch (PartInitException e) { e.printStackTrace(); } } }); book.showPage(messageText); // TODO: Context menu should have open action }
From source file:org.apache.opennlp.corpus_server.caseditor.TaskQueueView.java
License:Apache License
@Override public void createPartControl(Composite parent) { explorerComposite = new Composite(parent, SWT.NONE); GridLayout explorerLayout = new GridLayout(); explorerLayout.numColumns = 2;/*from w w w . ja v a2 s. co m*/ explorerComposite.setLayout(explorerLayout); // URL field to connect to corpus server and corpus Label serverLabel = new Label(explorerComposite, SWT.NONE); serverLabel.setText("Server:"); serverUrl = new Text(explorerComposite, SWT.BORDER); GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(serverUrl); // TOOD: Should be stored in some way, or just done more sophisticated .. serverUrl.setText("http://localhost:8080/corpus-server/rest/queues/ObamaNerTask"); // Button for next cas (gets nexts and closes current one, // if not saved user is asked for it) Button nextDocument = new Button(explorerComposite, SWT.BORDER); nextDocument.setText("Next"); GridDataFactory.swtDefaults().span(2, 1).align(SWT.FILL, SWT.CENTER).grab(true, false) .applyTo(nextDocument); nextDocument.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent event) { Client c = Client.create(); WebResource queueWebResource = c.resource(serverUrl.getText()); ClientResponse response2 = queueWebResource.path("_nextTask").accept(MediaType.APPLICATION_JSON) .header("Content-Type", MediaType.TEXT_XML).get(ClientResponse.class); String casId = response2.getEntity(String.class); // How to get the corpus uri for the item returned from the queue ??? // Queue could always return full URI ... // we also need to corpus the cas id belongs too ... IWorkbenchPage page = TaskQueueView.this.getSite().getPage(); // TODO: Thats a short cut, we need to make this work properly ... IEditorInput input = new CorpusServerCasEditorInput( "http://localhost:8080/corpus-server/rest/corpora/wikinews", casId); try { page.openEditor(input, "org.apache.uima.caseditor.editor"); } catch (PartInitException e) { e.printStackTrace(); } // Add casId to historyViewer ... should be inserted at the top, not bottom. lastInputElements.add(input); historyViewer.insert(input, 0); if (lastInputElements.size() > 10) { IEditorInput tooOldInput = lastInputElements.remove(0); historyViewer.remove(tooOldInput); } } @Override public void widgetDefaultSelected(SelectionEvent event) { } }); // History view ... shows n last opened CASes ... historyViewer = new TableViewer(explorerComposite); historyViewer.setLabelProvider(new ITableLabelProvider() { @Override public void addListener(ILabelProviderListener arg0) { } @Override public void dispose() { } @Override public boolean isLabelProperty(Object arg0, String arg1) { return false; } @Override public void removeListener(ILabelProviderListener arg0) { } @Override public Image getColumnImage(Object arg0, int arg1) { return null; } @Override public String getColumnText(Object arg0, int arg1) { return ((IEditorInput) arg0).getName(); } }); GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).span(2, 1) .applyTo(historyViewer.getTable()); historyViewer.addOpenListener(new IOpenListener() { @Override public void open(OpenEvent event) { StructuredSelection selection = (StructuredSelection) event.getSelection(); if (!selection.isEmpty()) { IWorkbenchPage page = TaskQueueView.this.getSite().getPage(); IEditorInput input = (IEditorInput) selection.getFirstElement(); try { page.openEditor(input, "org.apache.uima.caseditor.editor"); } catch (PartInitException e) { e.printStackTrace(); } } } }); }
From source file:org.bonitasoft.studio.document.ui.DocumentPropertySection.java
License:Open Source License
@Override public void selectionChanged(final SelectionChangedEvent event) { final StructuredSelection listSelection = (StructuredSelection) event.getSelection(); removeButton.setEnabled(!listSelection.isEmpty()); editButton.setEnabled(listSelection.size() == 1); }