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 :

problème avec GridLayout


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 problème avec GridLayout
    Hello,

    J ai un soucie lorsque j'utilise le gridLayout pour positionner mes elements graphiques, il n y a pas de retour a la deuxième ligne avec le code suivant

    (voir la capture d écran action devrait se trouvé sur la 2eme ligne et non a la fin de la 1ere)

    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
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
     
    	public void createControls(Composite parent, TabbedPropertySheetPage tabbedPropertySheetPage) {
    		super.createControls(parent, tabbedPropertySheetPage);
     
    		TabbedPropertySheetWidgetFactory factory = getWidgetFactory();
     
    		body = factory.createFlatFormComposite(parent);	
    		GridLayout gd = new GridLayout();
    		body.setLayout(gd);
    		gd.numColumns = 6;
    		GridData gridData = null;
     
    		confirmLabel = factory.createCLabel(body, "Confirm:");
    		gridData = new GridData();
    		gridData.heightHint = 50;
     
    		confirmLabel.setLayoutData(gridData);
        	localizationEditor = new LocalizableEditor(body);
     
    		actionLabel = factory.createCLabel(body, "Action:");
    		gridData = new GridData();
    		gridData.heightHint = 50;
    		actionLabel.setLayoutData(gridData);
     
     
    		actionText = factory.createText(body, "");
    		gridData = new GridData(GridData.FILL_HORIZONTAL);
    		gridData.horizontalSpan = 4;
    		gridData.grabExcessHorizontalSpace = true;
    		actionText.setLayoutData(gridData);		
    		actionText.addFocusListener(new FocusAdapter() {
                public void focusLost(FocusEvent e) {
                	String s = actionText.getText();
                	s = (s == null) ? "" : s;
                	if (widget != null) {
                		executeModifyCommand(widget, s);
                	}
                }
            });
     
    		factory.createCLabel(body, "Event:");
    		eventCbx = factory.createCCombo(body);
    		eventCbx.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
    		eventCbx.setEditable(false);
    		eventCbx.addSelectionListener(new SelectionAdapter() {
    			public void widgetSelected(SelectionEvent e) {
    				int index = ((CCombo) e.getSource()).getSelectionIndex();
    				String eventName = eventCbx.getItem(index);
    				currentEventType = findEventType(eventName, getWidget().getType());
    				fillFunctionsList(getWidget(), currentEventType);
    				addBtn.setEnabled(false);
    				modifyBtn.setEnabled(false);
    			}
    		});
     
    		CLabel blankLbl1 = factory.createCLabel(body, "");
    		gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    		gridData.horizontalSpan = 3;
    		blankLbl1.setLayoutData(gridData);
     
    		CLabel fctLbl = factory.createCLabel(body, "Functions:");
    		gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING);
    		gridData.verticalSpan = 3;
    		fctLbl.setLayoutData(gridData);
    		fctList = factory.createList(body, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL);
    		gridData = new GridData(GridData.FILL_BOTH);
    		gridData.verticalSpan = 3;
    		gridData.heightHint = 40;
    		fctList.setLayoutData(gridData);
    		fctList.addSelectionListener(new SelectionAdapter() {
    			public void widgetSelected(SelectionEvent e) {
    				int index = ((List) e.getSource()).getSelectionIndex();
    				String funcName = fctList.getItem(index);
    				FunctionType ft = findFunctionType(funcName, currentEventType);
    				if (ft != currentFunctionType) {
    					currentFunctionType = ft;
    					selectFunctionType(currentFunctionType);
    					addBtn.setEnabled(true);
    					modifyBtn.setEnabled(false);
    				}
    			}
    		});
     
    		CLabel paramsLabel = factory.createCLabel(body, "Parameters:");
    		gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
    		gridData.horizontalSpan = 2;
    		paramsLabel.setLayoutData(gridData);
    		paramsTbl = factory.createTable(body, SWT.SINGLE);
    		gridData = new GridData(GridData.FILL_BOTH);
    		gridData.horizontalSpan = 2;
    		gridData.verticalSpan = 2;
    		paramsTbl.setLayoutData(gridData);
    		paramsTbl.setHeaderVisible(true);
    		addColumn(paramsTbl, "Parameter", 100);
    		addColumn(paramsTbl, "Value", 200);
     
    		/** begin - Add support to edit parameters' value */
    		final TableEditor paramsTblEditor = new TableEditor(paramsTbl);
    		// The editor must have the same size as the cell and must not be any smaller than 50 pixels.
    		paramsTblEditor.horizontalAlignment = SWT.LEFT;
    		paramsTblEditor.grabHorizontal = true;
    		paramsTblEditor.minimumWidth = 50;
    		paramsTbl.addListener(SWT.MouseDown, new Listener() {
    			public void handleEvent(org.eclipse.swt.widgets.Event event) {
    				int nbColumns = paramsTbl.getColumnCount();
    				Rectangle clientArea = paramsTbl.getClientArea();
    				Point pt = new Point(event.x, event.y);
    				int index = paramsTbl.getTopIndex();
    				while (index < paramsTbl.getItemCount()) {
    					boolean visible = false;
    					TableItem item = paramsTbl.getItem(index);
    					for (int cx = 0; cx < nbColumns; cx++) {
    						Rectangle rect = item.getBounds(cx);
    						if (rect.contains(pt)) {
    							installCellEditor(paramsTblEditor, item, index, cx);
    						}
    						if (!visible && rect.intersects(clientArea)) {
    							visible = true;
    						}
    					}
    					if (!visible)
    						return;
    					index++;
    				}
    			}
    		});
    		/** end - Add support to edit parameters' value */
     
    		addBtn = factory.createButton(body, "Add", SWT.PUSH);
    		addBtn.setEnabled(false);
    		addBtn.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.VERTICAL_ALIGN_BEGINNING));
    		addBtn.addSelectionListener(new SelectionAdapter() {
    			public void widgetSelected(SelectionEvent e) {
    				addNewEvent();
    				addBtn.setEnabled(false);
    			}
    		});
     
    		modifyBtn = factory.createButton(body, "Modify", SWT.PUSH);
    		modifyBtn.setEnabled(false);
    		modifyBtn.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.VERTICAL_ALIGN_BEGINNING));
    		modifyBtn.addSelectionListener(new SelectionAdapter() {
    			public void widgetSelected(SelectionEvent e) {
    				modifyEvent();
    				modifyBtn.setEnabled(false);
    			}
    		});
     
    		CLabel eventsLabel = factory.createCLabel(body, "Events:");
    		eventsLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING));
    		eventsTbl = factory.createTable(body, SWT.SINGLE | SWT.CHECK);
    		gridData = new GridData(GridData.FILL_BOTH);
    		gridData.horizontalSpan = 4;
    		eventsTbl.setLayoutData(gridData);
    		eventsTbl.setHeaderVisible(true);
    		addColumn(eventsTbl, "Event", 100);
    		addColumn(eventsTbl, "Function", 100);
    		addColumn(eventsTbl, "Parameters", 400);
     
    		eventsTbl.addSelectionListener(new SelectionAdapter() {
    			public void widgetSelected(SelectionEvent e) {
    				if (((TableItem) e.item).getChecked()) {
    					nbSelectedRow++;
    				} else if (nbSelectedRow > 0) {
    					nbSelectedRow--;
    				}
    				deleteBtn.setEnabled(nbSelectedRow > 0);
     
    			}
    		});
     
    		eventsTbl.addListener(SWT.MouseDown, new Listener() {
    			public void handleEvent(org.eclipse.swt.widgets.Event event) {
    				int nbColumns = eventsTbl.getColumnCount();
    				Rectangle clientArea = eventsTbl.getClientArea();
    				Point pt = new Point(event.x, event.y);
    				int index = eventsTbl.getTopIndex();
    				while (index < eventsTbl.getItemCount()) {
    					boolean visible = false;
    					TableItem item = eventsTbl.getItem(index);
    					for (int cx = 0; cx < nbColumns; cx++) {
    						Rectangle rect = item.getBounds(cx);
    						if (rect.contains(pt)) {
    							prepareWidgetEventModification(index);
    						}
    						if (!visible && rect.intersects(clientArea)) {
    							visible = true;
    						}
    					}
    					if (!visible)
    						return;
    					index++;
    				}
    			}
    		});
     
    		deleteBtn = factory.createButton(body, "Delete", SWT.PUSH);
    		deleteBtn.setEnabled(false);
    		gridData = new GridData(GridData.HORIZONTAL_ALIGN_END);
    		gridData.horizontalSpan = 5;
    		deleteBtn.setLayoutData(gridData);
    		deleteBtn.addSelectionListener(new SelectionAdapter() {
    			public void widgetSelected(SelectionEvent e) {
    				TableItem[] items = eventsTbl.getItems();
    				for (int kx = items.length - 1; kx >= 0; kx--) {
    					if (items[kx].getChecked()) {
    						eventsTbl.remove(kx);
    						Event event = getWidget().getEvents().get(kx);
    						executeDeleteCommand(getWidget(), event);
    					}
    				}
    				fillFunctionsList(getWidget(), currentEventType);
    				addBtn.setEnabled(false);
    				deleteBtn.setEnabled(false);
    				modifyBtn.setEnabled(false);
    			}
    		});
     
    	}
    d avance merci

  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
    j ai modifé mon code de cette manière

    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
     
    		confirm = factory.createFlatFormComposite(parent);	
    		GridLayout gd1 = new GridLayout();
    		confirm.setLayout(gd1);
    		gd1.numColumns = 2;
     
    		GridData gridData = null;
     
    		confirmLabel = factory.createCLabel(confirm, "Confirm message:");
    		gridData = new GridData();
    		gridData.heightHint = 50;
    		gridData.widthHint = 100;
    		confirmLabel.setLayoutData(gridData);
        	localizationEditor = new LocalizableEditor(confirm);
     
    		body = factory.createFlatFormComposite(confirm);
    voir le screen pour le rendu

    je n arrive pas a afficher correctement cette fois ma 1ere ligne

  3. #3
    Membre confirmé Avatar de desert
    Profil pro
    Inscrit en
    Mai 2007
    Messages
    414
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Mai 2007
    Messages : 414
    Points : 479
    Points
    479
    Par défaut
    Cela semble assez complexe au niveau décryptage donc difficile de comprendre sans commentaires.
    confirm est-il le composite qui englobe le tout ?

Discussions similaires

  1. Création Grille avec gridLayout --> Problème de rafraichissement ?
    Par july4474 dans le forum Agents de placement/Fenêtres
    Réponses: 1
    Dernier message: 10/03/2010, 16h41
  2. Problème avec GridLayout
    Par d_hazem dans le forum Agents de placement/Fenêtres
    Réponses: 22
    Dernier message: 06/06/2008, 14h33
  3. Problème avec le GridLayout
    Par mister3957 dans le forum Agents de placement/Fenêtres
    Réponses: 7
    Dernier message: 01/08/2005, 16h59
  4. Problème avec la mémoire virtuelle
    Par Anonymous dans le forum CORBA
    Réponses: 13
    Dernier message: 16/04/2002, 16h10

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