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

The following examples show how to use org.eclipse.jface.viewers.LabelProvider. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Test
public void should_bindAddChildButtonEnablement_convert_boolean_value() throws Exception {
    section.init(new WritableValue(aContract().build(), Contract.class));
    final Button button = new Button(parent, SWT.PUSH);
    final TableViewer inputsTableViewer = new TableViewer(parent);
    inputsTableViewer.setLabelProvider(new LabelProvider());
    inputsTableViewer.setContentProvider(ArrayContentProvider.getInstance());

    final ContractInput textParentInput = ProcessFactory.eINSTANCE.createContractInput();
    textParentInput.setType(ContractInputType.TEXT);
    final ContractInput complexParentInput = ProcessFactory.eINSTANCE.createContractInput();
    complexParentInput.setType(ContractInputType.COMPLEX);

    inputsTableViewer.setInput(Arrays.asList(textParentInput, complexParentInput));
    section.bindAddChildButtonEnablement(button, inputsTableViewer);
    assertThat(button.isEnabled()).isFalse();
    assertThat(inputsTableViewer.getSelection().isEmpty()).isTrue();
    inputsTableViewer.setSelection(new StructuredSelection(textParentInput));
    assertThat(button.isEnabled()).isFalse();
    assertThat(inputsTableViewer.getSelection().isEmpty()).isFalse();

    inputsTableViewer.setSelection(new StructuredSelection(complexParentInput));
    assertThat(button.isEnabled()).isTrue();
}
 
Example 2
/**
 * Calculate the hierarchically qualified name of an EObject.
 *
 * @param eob
 *            the EObject to calculate hierarchically name for
 * @param labelProvider
 *            the label provider that knows how to display EObject instances
 *
 * @return the hierarchical name.
 */
public static String calculateHierarchicalDisplayName(EObject eob, LabelProvider labelProvider,
		boolean includeRoot) {
	// Calculate hierarchical logical name, e.g. C/m
	String text = labelProvider.getText(eob);
	EObject currContainer = eob.eContainer();
	while (currContainer != null) {
		if (isShowable(currContainer)) {
			text = labelProvider.getText(currContainer) + DELIMITER + text;
		}
		currContainer = currContainer.eContainer();
		if (currContainer != null && !includeRoot && currContainer instanceof Script)
			break;
	}
	return text;
}
 
Example 3
Source Project: n4js   Source File: ColumnViewerBuilder.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Creates a new {@link TableViewer table viewer} builder with the given list of table column labels.
 *
 * @param columnLabels
 *            a list of table column labels to use for the new table viewer. Cannot be {@code null}. Must not be
 *            empty.
 *
 */
protected ColumnViewerBuilder(final List<String> columnLabels, final CP contentProvider) {
	this.columnLabels = checkNotNull(columnLabels, "columnLabels");
	this.contentProvider = checkNotNull(contentProvider, "contentProvider");
	checkArgument(!this.columnLabels.isEmpty(),
			"Empty column labels are not allowed. At least one column should be specified.");

	headerVisible = true;
	linesVisible = true;
	useHashlookup = false;
	labelProvider = new LabelProvider();
	multipleSelection = false;
	fullSelection = true;
	resizable = true;
	hasBorder = false;
	moveable = true;
}
 
Example 4
Source Project: aCute   Source File: DotnetTestTab.java    License: Eclipse Public License 2.0 6 votes vote down vote up
private void displayClassSelectorDialog() {

		ElementListSelectionDialog dialog = new ElementListSelectionDialog(classBrowseButton.getShell(),
				new LabelProvider());
		dialog.setTitle(Messages.DotnetTestTab_classSelection_title);
		dialog.setMessage(Messages.DotnetTestTab_classSelection_message);
		dialog.setElements(testMethods.keySet().toArray());
		dialog.open();
		String selected = (String) dialog.getFirstResult();
		if (selected != null) {
			methodBrowseButton.setEnabled(true);
			methodLabel.setEnabled(true);
			methodText.setEnabled(true);
			classText.setText(selected);
			setDirty(true);
			updateLaunchConfigurationDialog();
		}
	}
 
Example 5
Source Project: aCute   Source File: DotnetTestTab.java    License: Eclipse Public License 2.0 6 votes vote down vote up
private void displayMethodSelectorDialog() {
	ElementListSelectionDialog dialog = new ElementListSelectionDialog(classBrowseButton.getShell(),
			new LabelProvider());
	dialog.setTitle(NLS.bind(Messages.DotnetTestTab_methodSelection_title, classText.getText()));
	dialog.setMessage(Messages.DotnetTestTab_methodSelection_message);
	List<String> methods = testMethods.get(classText.getText());
	if(methods!=null) {
		dialog.setElements(methods.toArray());
	}
	dialog.open();
	String selected = (String) dialog.getFirstResult();
	if (selected != null) {
		methodText.setText(selected);
		setDirty(true);
		updateLaunchConfigurationDialog();
	}
}
 
Example 6
Source Project: google-cloud-eclipse   Source File: MiniSelector.java    License: Apache License 2.0 6 votes vote down vote up
private void create(Composite parent) {
  displayExecutor = DisplayExecutor.create(parent.getDisplay());
  comboViewer = new ComboViewer(parent, SWT.READ_ONLY | SWT.DROP_DOWN);
  comboViewer.setComparator(new ViewerComparator());
  comboViewer.setLabelProvider(new LabelProvider() {
    @Override
    public String getText(Object element) {
      if (element instanceof GcpProject) {
        GcpProject project = (GcpProject) element;
        return project.getName() + " (" + project.getId() + ")";
      }
      return super.getText(element);
    }
  });
  comboViewer.setContentProvider(ArrayContentProvider.getInstance());
  comboViewer.setInput(EMPTY_PROJECTS);
  parent.addDisposeListener(new DisposeListener() {
    @Override
    public void widgetDisposed(DisposeEvent event) {
      cancelFetch();
    }
  });

  fetch();
}
 
Example 7
Source Project: tlaplus   Source File: FilteredDefinitionSelectionDialog.java    License: MIT License 6 votes vote down vote up
/**
 * Creates a label provider for the detail section below the list<br>
 * The label provider prints out the name of operation definition and the module the operation is defined in 
 */
private ILabelProvider getDetailLabelProvider()
{
    return new LabelProvider() {
        public String getText(Object element)
        {
            if (element instanceof OpDefNode)
            {
                OpDefNode node = (OpDefNode) element;

                return node.getSource().getName().toString()
                        + ((node.getSource().getOriginallyDefinedInModuleNode() != null) ? " : "
                                + node.getSource().getOriginallyDefinedInModuleNode().getName().toString() : "");
            }
            return super.getText(element);
        }
    };
}
 
Example 8
@Override
protected void configureViewer(final StructuredViewer viewer) {
    viewer.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(final Object element) {
            final String displayName = ((org.bonitasoft.studio.actors.model.organization.Group) element).getDisplayName();
            if (displayName == null || displayName.isEmpty()) {
                return ((org.bonitasoft.studio.actors.model.organization.Group) element).getName();
            }
            return displayName;
        }
    });

    if (groupList != null && getViewer() != null) {
        getViewer().setInput(groupList);
        ((TreeViewer) getViewer()).expandAll();
    }
}
 
Example 9
protected void createDomainCombo(Composite leftColumn) {

		Label label = getToolkit().createLabel(leftColumn, "Statechart domain");
		GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.CENTER).applyTo(label);
		domainCombo = new ComboViewer(leftColumn);
		GridDataFactory.fillDefaults().span(1, 1).align(SWT.FILL, SWT.CENTER).applyTo(domainCombo.getCombo());
		Label spacer = getToolkit().createLabel(leftColumn, "");
		GridDataFactory.fillDefaults().applyTo(spacer);
		domainCombo.setContentProvider(new ArrayContentProvider());
		domainCombo.setLabelProvider(new LabelProvider() {
			@Override
			public String getText(Object element) {
				return ((IDomain) element).getName();
			}
		});

		List<IDomain> domains = DomainRegistry.getDomains();
		for (IDomain domainDescriptor : domains) {
			domainCombo.add(domainDescriptor);
		}

		if (domains.size() <= 1) {
			domainCombo.getControl().setEnabled(false);
		}

	}
 
Example 10
/**
    * 
 * @param parent
    * @param url : the url from which we want to get the root url 
 */
public ChooseRootUrlDialog(Shell parent, SVNUrl url) {
	super(parent);
       this.url = url;
       
       List list = new ArrayList();
       
       // we want the user can select "no root url", ie a blank url
       list.add(""); // we cannot add null, we would have a NullPointerException //$NON-NLS-1$
       SVNUrl possibleRoot = this.url;
       while (possibleRoot != null) {
           list.add(possibleRoot);
           possibleRoot = possibleRoot.getParent();
       }        
       
       setTitle(Policy.bind("ChooseRootUrlDialog.rootUrlDialogTitle")); //$NON-NLS-1$
       setAddCancelButton(true);
       setLabelProvider(new LabelProvider());
       setMessage(Policy.bind("ChooseRootUrlDialog.chooseRootUrl")); //$NON-NLS-1$
       setContentProvider(new ListContentProvider());
       setInput(list);
}
 
Example 11
/**
 * Creates a ListViewer whose input is an array of IFiles.
 * 
 * @param parent  the parent of the viewer
 * @param title  the text for the title label
 * @param heightHint  the nominal height of the list
 * @return the created list viewer
 */
public ListViewer createFileListViewer(Composite parent, String title, int heightHint) {
	createLabel(parent, title);
	ListViewer listViewer = new ListViewer(parent, SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
	listViewer.setContentProvider(new IStructuredContentProvider() {
		public Object[] getElements(Object inputElement) {
			return (Object[]) inputElement;
		}
		public void dispose() {
		}
		public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
		}
	});
	listViewer.setLabelProvider(new LabelProvider() {
		public String getText(Object element) {
			return ((IFile) element).getFullPath().toString();
		}
	});
	listViewer.setSorter(new WorkbenchViewerSorter());

	GridData data = new GridData(GridData.FILL_BOTH);
	data.heightHint = heightHint;
	listViewer.getList().setLayoutData(data);
	return listViewer;
}
 
Example 12
Source Project: APICloud-Studio   Source File: CListTable.java    License: GNU General Public License v3.0 6 votes vote down vote up
private void createTable(Composite parent)
{
	tableViewer = new TableViewer(parent, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION);
	tableViewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

	tableViewer.setContentProvider(ArrayContentProvider.getInstance());
	tableViewer.setLabelProvider(new LabelProvider());
	tableViewer.setComparator(new ViewerComparator());
	tableViewer.setInput(items);
	tableViewer.addSelectionChangedListener(new ISelectionChangedListener()
	{

		public void selectionChanged(SelectionChangedEvent event)
		{
			updateStates();
		}

	});
	updateStates();
}
 
Example 13
public UnansweredDocumentsView(Composite parent, IWorkbenchPartSite site,
        Supplier<Questionnaire> questionnaireSupplier, Supplier<IProject> projectSupplier) {
    this.questionnaireSupplier = questionnaireSupplier;
    this.projectSupplier = projectSupplier;

    incompleteDocumentsLabel = new Label(parent, 0);
    incompleteDocumentsLabel.setText(TEMPLATE_ANSWERS_COMPLETE);
    incompleteDocumentsLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false, 2, 1));

    incompleteDocumentsList = new ListViewer(parent, SWT.V_SCROLL);
    GridData gd = new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false, 2, 1);
    gd.heightHint = (int) (((org.eclipse.swt.widgets.List) incompleteDocumentsList.getControl()).getItemHeight()
            * 4);
    gd.widthHint = 300;
    incompleteDocumentsList.getControl().setLayoutData(gd);
    incompleteDocumentsList.getControl().setVisible(false);
    incompleteDocumentsList.setSorter(new ViewerSorter());
    incompleteDocumentsList.setContentProvider(ArrayContentProvider.getInstance());
    incompleteDocumentsList.setLabelProvider(new LabelProvider() {
        @Override
        public String getText(Object element) {
            return ((Document) element).getKey();
        }
    });
    site.setSelectionProvider(incompleteDocumentsList);
}
 
Example 14
Source Project: olca-app   Source File: CostDialog.java    License: Mozilla Public License 2.0 6 votes vote down vote up
private void createCurrencyRow(Composite body, FormToolkit tk) {
	Combo widget = UI.formCombo(body, tk, M.Currency);
	currencyCombo = new ComboViewer(widget);
	currencyCombo.setLabelProvider(new LabelProvider() {
		@Override
		public String getText(Object obj) {
			if (!(obj instanceof Currency))
				return super.getText(obj);
			return ((Currency) obj).name;
		}
	});
	setCurrencyContent(currencyCombo);
	currencyCombo.addSelectionChangedListener(e -> {
		currency = Viewers.getFirst(e.getSelection());
		exchange.currency = currency;
		updateCurrencyLabels();
	});
	UI.filler(body, tk);
}
 
Example 15
Source Project: codeexamples-eclipse   Source File: TaskOverview.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void createPartControl(Composite parent) {
	viewer = new ListViewer(parent);
	viewer.setContentProvider(ArrayContentProvider.getInstance());
	viewer.setLabelProvider(new LabelProvider() {
		@Override
		public String getText(Object element) {
			Task p = (Task) element;
			return p.getSummary();
		};
	});
	viewer.setInput(TaskService.getInstance().getTasks());
	getSite().setSelectionProvider(viewer);
	hookDoubleClickCommand();

}
 
Example 16
Source Project: birt   Source File: ExcelFileSelectionWizardPage.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Create the top composite of the page
 * 
 * @param composite
 * @param label
 */
private void createTopComposite( Composite composite, Label label )
{
	FormData data = new FormData( );
	data.left = new FormAttachment( label, 5 );
	data.right = new FormAttachment( 40, -5 );
	worksheetsCombo = new ComboViewer( composite, SWT.BORDER
			| SWT.READ_ONLY );
	worksheetsCombo.getControl( ).setLayoutData( data );
	worksheetsCombo.setContentProvider( new ArrayContentProvider( ) );
	worksheetsCombo.addSelectionChangedListener( this );
	worksheetsCombo.setLabelProvider( new LabelProvider( ) {

		public String getText( Object element )
		{
			return getFileName( element );
		}
	} );
	data = new FormData( );
	data.left = new FormAttachment( worksheetsCombo.getControl( ), 5 );
	data.top = new FormAttachment( 0, 5 );
}
 
Example 17
public ILabelProvider getDataSetLabelProvider( )
{
	return new LabelProvider( ) {

		public String getText( Object element )
		{
			BindingInfo info = (BindingInfo) element;
			String datasetName = info.getBindingValue( );
			if ( !info.isDataSet( ) )
			{
				if ( !NONE.equals( datasetName ) )
				{
					datasetName += Messages.getString("BindingGroupDescriptorProvider.Flag.DataModel"); //$NON-NLS-1$
				}
			}
			return datasetName;
		}
	};
}
 
Example 18
Source Project: Pydev   Source File: SelectElementDialog.java    License: Eclipse Public License 1.0 6 votes vote down vote up
public static <T> T selectOne(List<T> items, LabelProvider labelProvider, String message) {
    Shell activeShell = Display.getCurrent().getActiveShell();

    SelectElementDialog dialog = new SelectElementDialog(activeShell, labelProvider);
    dialog.setTitle("Select One");
    dialog.setMessage(message);
    dialog.setElements(items.toArray());
    dialog.setMultipleSelection(false);

    int returnCode = dialog.open();
    if (returnCode == Window.OK) {
        return (T) dialog.getFirstResult();
    }
    return null;

}
 
Example 19
public ExpressionViewer createTextControl(final Composite composite, final Text object,
        final IExpressionNatureProvider expressionProvider,
        final LabelProvider autoCompletionLabelProvider) {
    final Input input = getConnectorInput(object.getInputName());
    if (input != null) {
        final ConnectorParameter parameter = connectorConfigurationSupport.getConnectorParameter(object.getInputName(),
                object, input);
        if (parameter != null) {
            createFieldLabel(composite, SWT.CENTER, object.getId(), input.isMandatory());
            return buildExpressionViewer(composite, object, expressionProvider, input, parameter,
                    autoCompletionLabelProvider);
        }
    } else {
        //Should we create a label to warn final user?
        BonitaStudioLog.log("WARNING: No input found with name " + object.getInputName());
    }
    return null;
}
 
Example 20
private void createActorComboViewer(final Composite mainComposite) {
    actorComboViewer = new ComboViewer(mainComposite, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY) ;
    actorComboViewer.getCombo().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()) ;
    actorComboViewer.setContentProvider(new ArrayContentProvider()) ;
    actorComboViewer.setLabelProvider(new LabelProvider(){
        @Override
        public String getText(final Object element) {
            if(element instanceof Actor){
                String doc = ((Actor) element).getDocumentation() ;
                if(doc != null && !doc.isEmpty()){
                    doc = " -- "+ doc ;
                }else{
                    doc = "" ;
                }
                return ((Actor) element).getName() + doc ;
            }
            return super.getText(element);
        }
    });
}
 
Example 21
Source Project: MergeProcessor   Source File: WorkspaceMergeDialog.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Create the table viewer for showing warnings.
 * 
 * @param parent the parent composite of the table viewer
 * @return the table viewer
 */
private static ListViewer createWarningsTableViewer(final Composite parent) {
	final Composite composite = new Composite(parent, SWT.NONE);
	composite.setLayout(new FillLayout());
	GridDataFactory.fillDefaults().span(2, 1).grab(true, true).exclude(true).applyTo(composite);
	final ListViewer tableViewer = new ListViewer(composite);
	tableViewer.setContentProvider(ArrayContentProvider.getInstance());
	tableViewer.setLabelProvider(new LabelProvider());
	return tableViewer;
}
 
Example 22
Source Project: ghidra   Source File: CdtProjectFieldEditor.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected String changePressed() {
	ElementListSelectionDialog dialog =
		new ElementListSelectionDialog(getShell(), new LabelProvider());
	dialog.setTitle("CDT project selection");
	dialog.setMessage("Select an open CDT project:");
	dialog.setElements(CdtUtils.getCDTProjects().stream().map(p -> p.getName()).toArray());
	dialog.open();
	Object[] result = dialog.getResult();
	if (result != null && result.length > 0 && result[0] instanceof String) {
		return (String) result[0];
	}
	return null;
}
 
Example 23
public GenderEditingSupport(ColumnViewer viewer) {
	super(viewer);
	cellEditor = new ComboBoxViewerCellEditor((Composite) getViewer().getControl(), SWT.READ_ONLY);
	cellEditor.setLabelProvider(new LabelProvider());
	cellEditor.setContentProvider(new ArrayContentProvider());
	cellEditor.setInput(Person.Gender.values());
}
 
Example 24
protected void createReturnTypeComposite(final Composite parent) {
    final Composite typeComposite = new Composite(parent, SWT.NONE);
    typeComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    final GridLayout gl = new GridLayout(3, false);
    gl.marginWidth = 0;
    gl.marginHeight = 0;
    typeComposite.setLayout(gl);

    final Label typeLabel = new Label(typeComposite, SWT.NONE);
    typeLabel.setText(Messages.returnType);
    typeLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).create());

    typeCombo = new ComboViewer(typeComposite, SWT.BORDER);
    typeCombo.getCombo().setLayoutData(
            GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.CENTER).indent(10, 0).create());
    typeCombo.setContentProvider(new ExpressionReturnTypeContentProvider());
    typeCombo.setLabelProvider(new LabelProvider());
    typeCombo.setSorter(new ViewerSorter() {

        @Override
        public int compare(final Viewer viewer, final Object e1, final Object e2) {
            final String t1 = (String) e1;
            final String t2 = (String) e2;
            return t1.compareTo(t2);
        }
    });
    typeCombo.getCombo().addModifyListener(e -> fireSelectionChanged());

    browseClassesButton = new Button(typeComposite, SWT.PUSH);
    browseClassesButton.setText(Messages.browse);
    browseClassesButton.setLayoutData(GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).create());
    browseClassesButton.addListener(SWT.Selection, event -> openClassSelectionDialog());
}
 
Example 25
Source Project: nebula   Source File: LazyPageTableExample.java    License: Eclipse Public License 2.0 5 votes vote down vote up
private static TableViewer createTableWithStandardMean(Composite parent) {
	final Table table = new Table(parent, SWT.BORDER | SWT.MULTI
			| SWT.H_SCROLL | SWT.V_SCROLL);
	table.setHeaderVisible(true);
	table.setLinesVisible(true);
	table.setLayoutData(new GridData(GridData.FILL_BOTH));

	final TableViewer viewer = new TableViewer(table);
	viewer.setContentProvider(ArrayContentProvider.getInstance());
	viewer.setLabelProvider(new LabelProvider());
	createColumns(viewer);
	return viewer;
}
 
Example 26
Source Project: nebula   Source File: ScalePageableTableExample.java    License: Eclipse Public License 2.0 5 votes vote down vote up
public static void main(String[] args) {
	Display display = new Display();
	Shell shell = new Shell(display);
	GridLayout layout = new GridLayout(1, false);
	shell.setLayout(layout);

	final List<String> items = createList();

	// 1) Create pageable table with 10 items per page
	// This SWT Component create internally a SWT Table+JFace TreeViewer
	int pageSize = 10;
	PageableTable pageableTable = new PageableTable(shell, SWT.BORDER,
			SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL, pageSize,
			PageResultContentProvider.getInstance(),
			NavigationPageScaleRendererFactory.getFactory(), null);
	pageableTable.setLayoutData(new GridData(GridData.FILL_BOTH));

	// 2) Initialize the table viewer
	TableViewer viewer = pageableTable.getViewer();
	viewer.setContentProvider(ArrayContentProvider.getInstance());
	viewer.setLabelProvider(new LabelProvider());

	// 3) Set the page loader used to load a page (sublist of String)
	// according the page index selected, the page size etc.
	pageableTable.setPageLoader(new PageResultLoaderList<String>(items));

	// 4) Set current page to 0 to display the first page
	pageableTable.setCurrentPage(0);

	shell.setSize(350, 250);
	shell.open();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch())
			display.sleep();
	}
	display.dispose();
}
 
Example 27
Source Project: elexis-3-core   Source File: BlockSelektor.java    License: Eclipse Public License 1.0 5 votes vote down vote up
public BlockSelektor(Shell shell){
	super(shell);
	setTitle("Block Selektion");
	
	setListLabelProvider(new LabelProvider() {
		@Override
		public String getText(Object element){
			if (element == null) {
				return "";
			}
			return ((Leistungsblock) element).getLabel();
		}
	});
}
 
Example 28
Source Project: nebula   Source File: ComboPageableTableExample.java    License: Eclipse Public License 2.0 5 votes vote down vote up
public static void main(String[] args) {
	Display display = new Display();
	Shell shell = new Shell(display);
	GridLayout layout = new GridLayout(1, false);
	shell.setLayout(layout);

	final List<String> items = createList();

	// 1) Create pageable table with 10 items per page
	// This SWT Component create internally a SWT Table+JFace TreeViewer
	int pageSize = 10;
	PageableTable pageableTable = new PageableTable(shell, SWT.BORDER,
			SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL, pageSize,
			PageResultContentProvider.getInstance(),
			NavigationPageComboRendererFactory.getFactory(), null);
	pageableTable.setLayoutData(new GridData(GridData.FILL_BOTH));

	// 2) Initialize the table viewer
	TableViewer viewer = pageableTable.getViewer();
	viewer.setContentProvider(ArrayContentProvider.getInstance());
	viewer.setLabelProvider(new LabelProvider());

	// 3) Set the page loader used to load a page (sublist of String)
	// according the page index selected, the page size etc.
	pageableTable.setPageLoader(new PageResultLoaderList<String>(items));

	// 4) Set current page to 0 to display the first page
	pageableTable.setCurrentPage(0);

	shell.setSize(350, 250);
	shell.open();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch())
			display.sleep();
	}
	display.dispose();
}
 
Example 29
private Composite createGeneralSection() {
  Composite generalSettings = new Composite(mMainTab, SWT.NULL);
  generalSettings.setLayoutData(new GridData(GridData.FILL_BOTH));
  GridLayout layout = new GridLayout(2, false);
  generalSettings.setLayout(layout);

  // Build severity
  Label lblSeverity = new Label(generalSettings, SWT.NULL);
  lblSeverity.setText(Messages.RuleConfigurationEditDialog_lblSeverity);
  lblSeverity.setLayoutData(new GridData());

  mSeverityCombo = new ComboViewer(generalSettings);
  mSeverityCombo.setContentProvider(new ArrayContentProvider());
  mSeverityCombo.setLabelProvider(new LabelProvider() {
    /**
     * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
     */
    @Override
    public String getText(Object element) {
      return ((Severity) element).name();
    }
  });
  mSeverityCombo.getControl().setLayoutData(new GridData());

  Group properties = new Group(generalSettings, SWT.NULL);
  properties.setLayout(new GridLayout(3, false));
  properties.setText(Messages.RuleConfigurationEditDialog_lblProperties);
  GridData gd = new GridData(GridData.FILL_BOTH);
  gd.horizontalSpan = 2;
  properties.setLayoutData(gd);

  createConfigPropertyEntries(properties);

  if (mConfigPropertyWidgets == null || mConfigPropertyWidgets.length == 0) {

    properties.dispose();
  }
  return generalSettings;
}
 
Example 30
Source Project: neoscada   Source File: TimeZoneCellEditor.java    License: Eclipse Public License 1.0 5 votes vote down vote up
public TimeZoneCellEditor ( final Composite composite )
{
    super ( composite, TimeZoneWrapper.getAvailable (), new LabelProvider () {
        @Override
        public String getText ( final Object element )
        {
            final TimeZoneWrapper tzw = (TimeZoneWrapper)element;
            final TimeZone tz = tzw.getTimeZone ();
            return String.format ( "%s (%s)", tz.getID (), tz.getDisplayName () );
        }
    }, true, SWT.SINGLE );
}