View | Details | Raw Unified | Return to bug 193064 | Differences between
and this patch

Collapse All | Expand All

(-)Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java (-1 / +45 lines)
Lines 202-207 Link Here
202
	// on Resize
202
	// on Resize
203
	Point oldSize;
203
	Point oldSize;
204
	Font oldFont;
204
	Font oldFont;
205
	CTabFolderPageManager pageManager;
205
	
206
	
206
	// internal constants
207
	// internal constants
207
	static final int DEFAULT_WIDTH = 64;
208
	static final int DEFAULT_WIDTH = 64;
Lines 555-560 Link Here
555
		color.dispose();
556
		color.dispose();
556
	}
557
	}
557
}
558
}
559
boolean canLeaveThePage(int oldIndex, int newIndex) {
560
    if (pageManager != null) {
561
	return pageManager.canLeaveThePage(oldIndex, newIndex);
562
    }
563
    return true;
564
}
558
/*
565
/*
559
* This class was not intended to be subclassed but this restriction
566
* This class was not intended to be subclassed but this restriction
560
* cannot be enforced without breaking backward compatibility.
567
* cannot be enforced without breaking backward compatibility.
Lines 1416-1421 Link Here
1416
	checkWidget();
1423
	checkWidget();
1417
	return mru;
1424
	return mru;
1418
}
1425
}
1426
/**
1427
 * Returns the Page Manager that is used by the <code>CTabfolder</code> before switching between tab-items.
1428
 * 
1429
 * @return the tabfolder's Page Manager, or null if no Page Manager has been set.
1430
 * 
1431
 * @since 3.6
1432
 */
1433
public CTabFolderPageManager getPageManager() {
1434
   return pageManager;
1435
}
1419
int getRightItemEdge (){
1436
int getRightItemEdge (){
1420
	int x = getSize().x - borderRight - 3;
1437
	int x = getSize().x - borderRight - 3;
1421
	if (showMin) x -= BUTTON_SIZE;
1438
	if (showMin) x -= BUTTON_SIZE;
Lines 3185-3190 Link Here
3185
	}
3202
	}
3186
}
3203
}
3187
/**
3204
/**
3205
 * Sets the Page Manager that will be used to by the <code>CTabFolder</code> before 
3206
 * switching between tab-items. 
3207
 * The Page Manager should implement the <code>CTabFolderPageManager</code> and 
3208
 * implement the method <code>canLeaveThePage</code>.
3209
 * 
3210
 * @param pageManager the Page Manager for the <code>CTabFolder</code>
3211
 * 
3212
 * @exception IllegalArgumentException <ul>
3213
 *    <li>ERROR_INVALID_RANGE - if the index is out of range</li>
3214
 * </ul>
3215
 * 
3216
 * @exception SWTException <ul>
3217
 *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
3218
 *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
3219
 * </ul>
3220
 * 
3221
 * @since 3.6
3222
 */
3223
public void setPageManager(CTabFolderPageManager pageManager) {
3224
    	this.pageManager = pageManager;
3225
}
3226
/**
3188
 * Set the selection to the tab at the specified item.
3227
 * Set the selection to the tab at the specified item.
3189
 * 
3228
 * 
3190
 * @param item the tab item to be selected
3229
 * @param item the tab item to be selected
Lines 3222-3228 Link Here
3222
		showItem(selection);
3261
		showItem(selection);
3223
		return;
3262
		return;
3224
	}
3263
	}
3225
	
3264
	/* 
3265
	 * If the user has set a Page Manager for the previously selected tab-item,
3266
	 * then call the canLeaveThePage() method to do any validations in the Page Manager,
3267
	 * before switching the tab. Don't change the tab selection if validation fails.
3268
	 */
3269
	if (selectedIndex != -1 && !canLeaveThePage(selectedIndex, index)) return;
3226
	int oldIndex = selectedIndex;
3270
	int oldIndex = selectedIndex;
3227
	selectedIndex = index;
3271
	selectedIndex = index;
3228
	if (oldIndex != -1) {
3272
	if (oldIndex != -1) {
(-)Eclipse (+25 lines)
Added Link Here
1
package org.eclipse.swt.custom;
2
3
/**
4
 * This is an Interface which provides a mechanism to use a Page Manager for a <code>CTabItem</code>.
5
 * The Page Manager can be used to do any validations as required by the user while switching between tab-items.
6
 * The Page Manager should implement the method <code>canLeaveThePage</code>.
7
 */
8
9
public interface CTabFolderPageManager {
10
    /**
11
     * This method is called before changing the tab selection of the <code>CTabFolder</code>
12
     *  
13
     * @param oldIndex is index of tab selected in the <code>CTabFolder</code>
14
     * @param newIndex is index of the tab that will be selected if this method returns true
15
     * 
16
     * @return <ul>
17
     * <li><code>true</code> if the tab selection should be changed from <code>oldIndex</code>
18
     * to <code>newIndex</code></li>
19
     * <li><code>false</code> if the tab selection should not be changed.</li>
20
     * </ul>
21
     * 
22
     * @since 3.6
23
     */
24
    public boolean canLeaveThePage(int oldIndex, int newIndex);
25
}

Return to bug 193064