Java Code Examples for org.eclipse.jface.viewers.LabelProvider

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project cilia-workbench, under directory /cilia-workbench-designer/src/fr/liglab/adele/cilia/workbench/designer/view/chainview/abstractchain/.

Source file: DeleteAdapterDialog.java

  22 
vote

public DeleteAdapterDialog(Shell parent,AbstractChain chain){
  super(parent);
  setTitle("Remove adapter");
  setMessage("Select the adapter to be removed");
  setInput(chain.getAdapters());
  setContentProvider(new ArrayContentProvider());
  setLabelProvider(new LabelProvider());
  setHelpAvailable(false);
}
 

Example 2

From project droolsjbpm-tools, under directory /drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/flow/common/view/datatype/editor/impl/.

Source file: DataTypeCombo.java

  22 
vote

public DataTypeCombo(Composite parent,int style,DataTypeRegistry registry){
  super(parent,style);
  this.registry=registry;
  setLayout(new FillLayout());
  dataTypeCombo=new ComboViewer(this,SWT.READ_ONLY);
  dataTypeCombo.setLabelProvider(new LabelProvider(){
    public String getText(    Object element){
      return ((DataTypeRegistry.IDataTypeInfo)element).getName();
    }
  }
);
  dataTypeCombo.add(registry.getDataTypes().toArray(new DataTypeRegistry.IDataTypeInfo[0]));
}
 

Example 3

From project BHT-FPA, under directory /template-codebeispiele/de.bht.fpa.mail.s000000.templates.treeviewer/src/de/bht/fpa/mail/s000000/templates/treeviewer/.

Source file: DemoView.java

  21 
vote

@Override public void createPartControl(Composite parent){
  viewer=new TreeViewer(parent);
  viewer.setLabelProvider(new LabelProvider());
  viewer.setContentProvider(new DemoContentProvider());
  viewer.setInput(createModel());
}
 

Example 4

From project bioclipse.vscreen, under directory /net.bioclipse.vscreen.ui/src/net/bioclipse/vscreen/ui/editors/.

Source file: VScreenEditor.java

  21 
vote

@Override public void createPartControl(Composite parent){
  GridLayout gridLayout=new GridLayout();
  gridLayout.numColumns=1;
  parent.setLayout(gridLayout);
  viewer=new TreeViewer(parent,SWT.BORDER | SWT.MULTI | SWT.H_SCROLL| SWT.V_SCROLL);
  ColumnViewerToolTipSupport.enableFor(viewer);
  viewer.setContentProvider(new VScreenContentProvider());
  viewer.setLabelProvider(new LabelProvider());
  GridData gridData=new GridData(GridData.FILL,GridData.FILL,true,true);
  viewer.getTree().setLayoutData(gridData);
  viewer.setInput(new String[]{"WEEHOOW"});
}
 

Example 5

From project Eclipse, under directory /com.mobilesorcery.sdk.ui/src/com/mobilesorcery/sdk/ui/internal/properties/.

Source file: BuildStepListEditor.java

  21 
vote

BuildStepListEditor(Composite parent,int style){
  super(parent,style);
  setEditAfterAdd(true);
  getList().setLabelProvider(new LabelProvider(){
    @Override public String getText(    Object element){
      return ((IBuildStepFactory)element).getName();
    }
  }
);
}
 

Example 6

From project eclipse-integration-cloudfoundry, under directory /org.cloudfoundry.ide.eclipse.server.ui/src/org/cloudfoundry/ide/eclipse/internal/server/ui/wizards/.

Source file: DeleteServicesWizardPage.java

  21 
vote

public void createControl(Composite parent){
  Composite container=new Composite(parent,SWT.NONE);
  container.setLayout(new GridLayout());
  Table table=new Table(container,SWT.CHECK | SWT.BORDER);
  table.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true));
  viewer=new CheckboxTableViewer(table);
  viewer.addCheckStateListener(new ICheckStateListener(){
    public void checkStateChanged(    CheckStateChangedEvent event){
      checkedElements=viewer.getCheckedElements();
      getWizard().getContainer().updateButtons();
    }
  }
);
  LabelProvider labelProvider=new LabelProvider();
  ITreeContentProvider contentProvider=new ITreeContentProvider(){
    public void inputChanged(    Viewer viewer,    Object oldInput,    Object newInput){
    }
    public void dispose(){
    }
    public Object[] getElements(    Object inputElement){
      return services.toArray();
    }
    public boolean hasChildren(    Object element){
      return false;
    }
    public Object getParent(    Object element){
      return null;
    }
    public Object[] getChildren(    Object parentElement){
      return null;
    }
  }
;
  viewer.setLabelProvider(labelProvider);
  viewer.setContentProvider(contentProvider);
  viewer.setInput(services);
  setControl(container);
  getWizard().getContainer().updateButtons();
}
 

Example 7

From project interactive-self-assessment, under directory /org.eclipse.ui.examples.javaeditor/javaeditorexamplesrc/org/eclipse/ui/examples/javaeditor/.

Source file: JavaContentOutlinePage.java

  21 
vote

public void createControl(Composite parent){
  super.createControl(parent);
  TreeViewer viewer=getTreeViewer();
  viewer.setContentProvider(new ContentProvider());
  viewer.setLabelProvider(new LabelProvider());
  viewer.addSelectionChangedListener(this);
  if (fInput != null)   viewer.setInput(fInput);
}
 

Example 8

From project Vega, under directory /platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/conditions/.

Source file: ConditionTypeComboViewer.java

  21 
vote

private ILabelProvider createLabelProvider(){
  return new LabelProvider(){
    @Override public String getText(    Object element){
      if (element instanceof IHttpConditionType)       return ((IHttpConditionType)element).getName();
 else       return null;
    }
  }
;
}
 

Example 9

From project dawn-isenciaui, under directory /com.isencia.passerelle.workbench.model.editor.ui/src/main/java/com/isencia/passerelle/workbench/model/editor/ui/descriptor/.

Source file: CheckboxPropertyDescriptor.java

  20 
vote

/** 
 * @param id
 * @param displayName
 */
public CheckboxPropertyDescriptor(Object id,String displayName){
  super(id,displayName);
  ticked=Activator.getImageDescriptor("icons/ticked.png").createImage();
  unticked=Activator.getImageDescriptor("icons/unticked.gif").createImage();
  setLabelProvider(new LabelProvider(){
    public Image getImage(    Object element){
      if (Boolean.TRUE.equals(element)) {
        return ticked;
      }
 else {
        return unticked;
      }
    }
    public String getText(    Object element){
      return null;
    }
  }
);
}
 

Example 10

From project egit-github, under directory /org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/issue/.

Source file: IssueRepositoryQueryPage.java

  20 
vote

private void createLabelsArea(Composite parent){
  Group labelsArea=new Group(parent,SWT.NONE);
  labelsArea.setText(Messages.IssueRepositoryQueryPage_LabelsLabel);
  GridDataFactory.fillDefaults().grab(true,true).applyTo(labelsArea);
  GridLayoutFactory.swtDefaults().applyTo(labelsArea);
  labelsViewer=CheckboxTableViewer.newCheckList(labelsArea,SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
  GridDataFactory.fillDefaults().grab(true,true).hint(100,80).applyTo(labelsViewer.getControl());
  labelsViewer.setContentProvider(ArrayContentProvider.getInstance());
  labelsViewer.setLabelProvider(new LabelProvider(){
    public Image getImage(    Object element){
      return GitHubImages.get(GitHubImages.GITHUB_ISSUE_LABEL_OBJ);
    }
  }
);
  labelsViewer.addSelectionChangedListener(new ISelectionChangedListener(){
    public void selectionChanged(    SelectionChangedEvent event){
      setPageComplete(isPageComplete());
    }
  }
);
}
 

Example 11

From project gmc, under directory /src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/.

Source file: CreateVolumePage1.java

  20 
vote

private void createTypeCombo(Composite container){
  typeComboViewer=new ComboViewer(container,SWT.READ_ONLY);
  Combo typeCombo=typeComboViewer.getCombo();
  GridData typeComboData=new GridData(SWT.LEFT,SWT.CENTER,true,false,1,1);
  typeCombo.setLayoutData(typeComboData);
  typeComboViewer.setContentProvider(new ArrayContentProvider());
  VOLUME_TYPE[] volumeTypes=new VOLUME_TYPE[3];
  volumeTypes[0]=VOLUME_TYPE.DISTRIBUTE;
  volumeTypes[1]=VOLUME_TYPE.REPLICATE;
  volumeTypes[2]=VOLUME_TYPE.STRIPE;
  typeComboViewer.setInput(volumeTypes);
  typeCombo.select(0);
  typeComboViewer.setLabelProvider(new LabelProvider(){
    @Override public String getText(    Object element){
      return Volume.getVolumeTypeStr((VOLUME_TYPE)element);
    }
  }
);
  typeComboViewer.addSelectionChangedListener(new ISelectionChangedListener(){
    @Override public void selectionChanged(    SelectionChangedEvent event){
      validateForm();
    }
  }
);
}
 

Example 12

From project grails-ide, under directory /org.grails.ide.eclipse.ui/src/org/grails/ide/eclipse/ui/internal/inplace/.

Source file: GrailsCompletionUtils.java

  20 
vote

public static ContentProposalAdapter addTypeFieldAssistToText(Text text,IProject project){
  KeyStroke triggerKeys=getKeyBindingFor("org.eclipse.ui.edit.text.contentAssist.proposals");
  if (triggerKeys == null) {
    return null;
  }
  if (project == null) {
    return null;
  }
  int bits=SWT.TOP | SWT.LEFT;
  ControlDecoration controlDecoration=new ControlDecoration(text,bits);
  controlDecoration.setMarginWidth(0);
  controlDecoration.setShowHover(true);
  controlDecoration.setShowOnlyOnFocus(true);
  FieldDecoration contentProposalImage=FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
  controlDecoration.setImage(contentProposalImage.getImage());
  GrailsProposalProvider proposalProvider=new GrailsProposalProvider(project,text);
  TextContentAdapter textContentAdapter=new TextContentAdapter();
  ContentProposalAdapter adapter=new ContentProposalAdapter(text,textContentAdapter,proposalProvider,triggerKeys,null);
  ILabelProvider labelProvider=new LabelProvider();
  adapter.setLabelProvider(labelProvider);
  adapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
  adapter.setFilterStyle(ContentProposalAdapter.FILTER_NONE);
  return adapter;
}
 

Example 13

From project ivyde, under directory /org.apache.ivyde.eclipse.resolvevisualizer/src/org/apache/ivyde/eclipse/resolvevisualizer/.

Source file: ClasspathContainerSelectionDialog.java

  20 
vote

public ClasspathContainerSelectionDialog(Shell parentShell){
  super(parentShell,new LabelProvider(){
    public String getText(    Object element){
      IvyClasspathContainer container=(IvyClasspathContainer)element;
      return container.getConf().getJavaProject().getProject().getName() + " -> " + container.getDescription();
    }
  }
);
  setTitle("Ivy Classpath Containers");
  setMessage("Select a container to view in the resolve visualizer.");
  List classpathContainers=new ArrayList();
  IProject[] ivyProjects=IvyClasspathUtil.getIvyProjectsInWorkspace();
  for (int i=0; i < ivyProjects.length; i++) {
    classpathContainers.addAll(IvyClasspathUtil.getIvyClasspathContainers(ivyProjects[i]));
  }
  setElements(classpathContainers.toArray());
  setMultipleSelection(false);
}
 

Example 14

From project JGit, under directory /org.spearce.egit.ui/src/org/spearce/egit/ui/internal/preferences/.

Source file: GitDecoratorPreferencePage.java

  20 
vote

/** 
 * Adds another variable to the given target text A ListSelectionDialog pops up and allow the user to choose the variable, which is then inserted at current position in <code>text</code>
 * @param target the target to add the variable to
 * @param bindings the map of bindings
 */
private void addVariables(Text target,Map bindings){
  final List<StringPair> variables=new ArrayList<StringPair>(bindings.size());
  ILabelProvider labelProvider=new LabelProvider(){
    public String getText(    Object element){
      return ((StringPair)element).s1 + " - " + ((StringPair)element).s2;
    }
  }
;
  IStructuredContentProvider contentsProvider=new IStructuredContentProvider(){
    public Object[] getElements(    Object inputElement){
      return variables.toArray(new StringPair[variables.size()]);
    }
    public void dispose(){
    }
    public void inputChanged(    Viewer viewer,    Object oldInput,    Object newInput){
    }
  }
;
  for (Iterator it=bindings.keySet().iterator(); it.hasNext(); ) {
    StringPair variable=new StringPair();
    variable.s1=(String)it.next();
    variable.s2=(String)bindings.get(variable.s1);
    variables.add(variable);
  }
  ListSelectionDialog dialog=new ListSelectionDialog(this.getShell(),this,contentsProvider,labelProvider,UIText.DecoratorPreferencesPage_selectVariablesToAdd);
  dialog.setTitle(UIText.DecoratorPreferencesPage_addVariablesTitle);
  if (dialog.open() != Window.OK)   return;
  Object[] result=dialog.getResult();
  for (int i=0; i < result.length; i++) {
    target.insert("{" + ((StringPair)result[i]).s1 + "}");
  }
}
 

Example 15

From project recommenders, under directory /plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/ui/.

Source file: ExtdocView.java

  20 
vote

private void createProviderOverview(){
  viewer=new TableViewer(sash);
  viewer.setContentProvider(new ArrayContentProvider());
  viewer.setLabelProvider(new LabelProvider(){
    @Override public String getText(    Object element){
      return ((ExtdocProvider)element).getDescription().getName();
    }
    @Override public Image getImage(    Object element){
      return ((ExtdocProvider)element).getDescription().getImage();
    }
  }
);
  viewer.setInput(providers);
  viewer.addSelectionChangedListener(new ISelectionChangedListener(){
    @Override public void selectionChanged(    SelectionChangedEvent event){
      ExtdocProvider newProvider=RCPUtils.<ExtdocProvider>first(event.getSelection()).orNull();
      if (newProvider == activeProvider) {
        return;
      }
      activeProvider=newProvider;
      Job job=new Job("Update Extdoc"){
        @Override protected IStatus run(        IProgressMonitor monitor){
          onJavaSelection(activeSelection);
          return Status.OK_STATUS;
        }
      }
;
      job.setSystem(true);
      job.schedule();
    }
  }
);
  viewer.setSelection(new StructuredSelection(Iterables.getFirst(providers,null)));
}
 

Example 16

From project savara-tools-eclipse, under directory /plugins/org.savara.tools.scenario/src/main/java/org/savara/tools/scenario/designer/simulate/.

Source file: ScenarioSimulationMainTab.java

  20 
vote

/** 
 * Show a dialog that lists all scenario files within the selected project
 */
protected void handleSearchButtonSelected(){
  IProject project=getProject();
  ILabelProvider labelProvider=new LabelProvider(){
    public String getText(    Object obj){
      String ret="<unknown>";
      if (obj instanceof IResource) {
        String filename=((IResource)obj).getName();
        if (filename.endsWith(DesignerDefinitions.SCENARIO_FILE_EXTENSION)) {
          filename=filename.substring(0,filename.length() - DesignerDefinitions.SCENARIO_FILE_EXTENSION.length() - 1);
        }
        ret=filename + " [" + ((IResource)obj).getParent().getProjectRelativePath()+ "]";
      }
      return (ret);
    }
  }
;
  IResource[] scenarios=null;
  if (project.exists() == false) {
    scenarios=new IResource[0];
  }
 else {
    scenarios=getScenarios(project);
  }
  ElementListSelectionDialog dialog=new ElementListSelectionDialog(getShell(),labelProvider);
  dialog.setTitle("Scenarios");
  dialog.setMessage("Select the relevant scenario");
  dialog.setElements(scenarios);
  if (dialog.open() == Window.OK) {
    IResource file=(IResource)dialog.getFirstResult();
    m_scenario.setText(file.getProjectRelativePath().toString());
  }
}
 

Example 17

From project swtbot, under directory /org.eclipse.swt.examples/src/org/eclipse/jface/snippets/viewers/.

Source file: Snippet009CellEditors.java

  20 
vote

public Snippet009CellEditors(Shell shell){
  final TableViewer v=new TableViewer(shell,SWT.BORDER | SWT.FULL_SELECTION);
  v.setLabelProvider(new LabelProvider());
  v.setContentProvider(new MyContentProvider());
  v.setCellModifier(new ICellModifier(){
    public boolean canModify(    Object element,    String property){
      return ((MyModel)element).counter % 2 == 0;
    }
    public Object getValue(    Object element,    String property){
      return ((MyModel)element).counter + "";
    }
    public void modify(    Object element,    String property,    Object value){
      TableItem item=(TableItem)element;
      ((MyModel)item.getData()).counter=Integer.parseInt(value.toString());
      v.update(item.getData(),null);
    }
  }
);
  v.setColumnProperties(new String[]{"column1"});
  v.setCellEditors(new CellEditor[]{new TextCellEditor(v.getTable())});
  MyModel[] model=createModel();
  v.setInput(model);
  v.getTable().setLinesVisible(true);
}
 

Example 18

From project zest, under directory /org.eclipse.zest.examples/src/org/eclipse/zest/examples/jface/.

Source file: GraphJFaceSnippet3.java

  20 
vote

public static void main(String[] args) throws IOException {
  Display display=new Display();
  Shell shell=new Shell(display);
  shell.setText("Simple Graph File Format");
  FileDialog dialog=new FileDialog(shell,SWT.OPEN);
  dialog.setFilterNames(new String[]{"Simple Graph Files (*.sgf)","All Files (*.*)"});
  dialog.setFilterExtensions(new String[]{"*.sgf","*.*"});
  String directory=System.getProperty("user.dir") + "/src/org/eclipse/zest/tests/jface/SimpleGraph.sgf";
  System.out.println(directory);
  dialog.setFilterPath(directory);
  shell.setLayout(new FillLayout(SWT.VERTICAL));
  shell.setSize(400,400);
  GraphViewer viewer=null;
  viewer=new GraphViewer(shell,SWT.NONE);
  viewer.setContentProvider(new SimpleGraphContentProvider());
  viewer.setLabelProvider(new LabelProvider());
  viewer.setLayoutAlgorithm(new RadialLayoutAlgorithm());
  shell.open();
  String fileName=dialog.open();
  if (fileName == null) {
    viewer.setInput(graph);
  }
 else {
    FileReader fileReader=new FileReader(new File(fileName));
    BufferedReader bufferedReader=new BufferedReader(fileReader);
    StringBuffer stringBuffer=new StringBuffer();
    while (bufferedReader.ready()) {
      stringBuffer.append(bufferedReader.readLine() + "\n");
    }
    viewer.setInput(stringBuffer.toString());
  }
  while (!shell.isDisposed()) {
    if (!display.readAndDispatch()) {
      display.sleep();
    }
  }
  display.dispose();
}