IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

SWT/JFace Java Discussion :

table viewer pas afficher


Sujet :

SWT/JFace Java

  1. #1
    Inactif  
    Profil pro
    Inscrit en
    Mai 2006
    Messages
    2 189
    Détails du profil
    Informations personnelles :
    Âge : 43
    Localisation : Suisse

    Informations forums :
    Inscription : Mai 2006
    Messages : 2 189
    Points : 2 336
    Points
    2 336
    Par défaut table viewer pas afficher
    Salut,

    J'essaye d'afficher une table vide avec deux colonnes dans la page des préférences d'eclipse mais rien ne s'affiche.

    Serait-ce du au fait que les données manques ?

    Ou aurais oublier quelque chose dans la construction du composant

    voici mon code

    d avance merci

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
     
    public class NamespacesPreferencesPage extends AbstractPreferencePage{
     
    	/** The prefix column string constant*/
    	private final static String PREFIX_COLUMN = "Prefix";
    	/** The uri column string constant*/
    	private final static String URI_COLUMN = "Uri";
    	/** The table container*/
    	private Table table;
    	/** The table viewer component*/
    	private TableViewer tableViewer;
    	/** Set column names */
    	private String[] columnNames = new String[] {PREFIX_COLUMN,	URI_COLUMN};
     
    	/**
             * Performs the defaults.
             * 
             * @param preferences The Preferences to update
             * @param defaultPreferences The default Preferences
             */
    	protected void performDefaults(Preferences preferences, Preferences defaultPreferences) {
     
    	}
     
    	/**
             * Performs the Ok.
             * 
             * @param preferences The Preferences to update
             */
    	protected void performOk(Preferences preferences) {
     
    	}
     
     
    	/**
             * Initializes this preference page for the given workbench.
             * <p>
             * This method is called automatically as the preference page is being created and initialized. Clients must not
             * call this method.
             * </p>
             * 
             * @param workbench
             *            the workbench
             */
    	public void init(IWorkbench workbench) {
    	}
     
    	/**
             * Creates the contents of the Preference Page.
             * 
             * @param parent
             *            The parent control
             * @return Control The control
             */
    	protected Control createContents(Composite parent) {
    		Composite panel = new Composite(parent, SWT.NONE);
    		createTable(panel);
    		createTableViewer();
    		return panel;
    	}
     
    	/**
             * Create the Table
             * 
             * @param parent
             *                      The parent component
             */
    	private void createTable(Composite parent) {
    		int style = SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | 
    					SWT.FULL_SELECTION | SWT.HIDE_SELECTION;
     
     
    		table = new Table(parent, style);
     
    		GridData gridData = new GridData(GridData.FILL_BOTH);
    		gridData.grabExcessVerticalSpace = true;
    		gridData.horizontalSpan = 3;
    		table.setLayoutData(gridData);		
     
    		table.setLinesVisible(true);
    		table.setHeaderVisible(true);
     
    		// 1st column with image/checkboxes - NOTE: The SWT.CENTER has no effect!!
    		TableColumn column = new TableColumn(table, SWT.CENTER, 0);		
    		column.setText(PREFIX_COLUMN);
    		column.setWidth(20);
     
    		// 2nd column with task Description
    		column = new TableColumn(table, SWT.LEFT, 1);
    		column.setText(URI_COLUMN);
    		column.setWidth(400);
    		// Add listener to column so tasks are sorted by description when clicked 
    		column.addSelectionListener(new SelectionAdapter() {
     
    			public void widgetSelected(SelectionEvent e) {
    				//tableViewer.setSorter(new ExampleTaskSorter(ExampleTaskSorter.DESCRIPTION));
    			}
    		});	
    	}
     
    	/**
             * Create the TableViewer 
             */
    	private void createTableViewer() {
     
    		tableViewer = new TableViewer(table);
    		tableViewer.setUseHashlookup(true);
    		tableViewer.setColumnProperties(columnNames);
    		// Create the cell editors
    		CellEditor[] editors = new CellEditor[columnNames.length];
    		// Column 1 : Completed (Checkbox)
    		TextCellEditor textEditor = new TextCellEditor(table);
    		editors[0] = textEditor;
    		// Column 2 : Description (Free text)
    		textEditor = new TextCellEditor(table);
    		((Text) textEditor.getControl()).setTextLimit(60);
    		editors[1] = textEditor;
    		// Assign the cell editors to the viewer 
    		tableViewer.setCellEditors(editors);
    	}

  2. #2
    Inactif  
    Profil pro
    Inscrit en
    Mai 2006
    Messages
    2 189
    Détails du profil
    Informations personnelles :
    Âge : 43
    Localisation : Suisse

    Informations forums :
    Inscription : Mai 2006
    Messages : 2 189
    Points : 2 336
    Points
    2 336
    Par défaut
    Trouvé, il fallait simplement définir un layout

  3. #3
    Membre averti

    Profil pro
    Inscrit en
    Août 2006
    Messages
    218
    Détails du profil
    Informations personnelles :
    Âge : 49
    Localisation : France, Rhône (Rhône Alpes)

    Informations forums :
    Inscription : Août 2006
    Messages : 218
    Points : 305
    Points
    305
    Par défaut
    Problème ultra classique

    Pense à mettre le post en résolu, merci,

    Laurent

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. execution requête CREATE TABLE ne pas afficher la table
    Par pancratee dans le forum VBA Access
    Réponses: 2
    Dernier message: 28/12/2009, 10h53
  2. [MySQL] Je n'arrive pas à afficher le nom de mes tables dans une liste déroulante
    Par beegees dans le forum PHP & Base de données
    Réponses: 6
    Dernier message: 08/10/2008, 15h16
  3. [DataGridView] la Table ne s'affiche pas :(
    Par LJL51 dans le forum Windows Forms
    Réponses: 5
    Dernier message: 01/08/2008, 10h11
  4. [BIRT Web Viewer] Pas de données affichées
    Par BODIGUEL dans le forum BIRT
    Réponses: 2
    Dernier message: 02/07/2008, 10h49
  5. Réponses: 11
    Dernier message: 09/12/2004, 15h03

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo