Show TabCreator.java syntax highlighted
/*******************************************************************************
* Contributors:
* Shu Xueling
*******************************************************************************/
package fitEditor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.Text;
import org.jboss.tm.iiop.CoordinatorExt;
import plugin.DeveloperCoordinator;
import plugin.ICoordinator;
import fitService.util.EditorConstants;
import fitService.util.Operation;
import view.FitView;
public class TabCreator {
private TabFolder tabFolder;
private FitView view;
private WikiEditorTab wikiEditorTab;
private LoginTab loginTab;
private ServerViewer serverViewerTab;
// private static TabCreator instance=null;
// last active view
// private int lastActiveView;
/**
* Creates an instance of a LayoutExample embedded inside
* the supplied parent Composite.
*
* @param parent the container of the example
* view MaseView
*/
public TabCreator(Composite parent,FitView view) {
this.setMainView(view);
tabFolder = new TabFolder (parent, SWT.VERTICAL);
tabFolder.addSelectionListener(new SelectionListener(){
public void widgetSelected(SelectionEvent event)
{
int itemIndex=((TabFolder)event.getSource()).getSelectionIndex();
if(itemIndex!=EditorConstants.LOGIN_TAB && !loginTab.checkLoginState())
tabFolder.setSelection(EditorConstants.LOGIN_TAB);
else
{
getMainView().setButtonUsibility(itemIndex);
// wysiwygOperation(itemIndex);
}
// if(lastActiveView==EditorConstants.WIKI_EDITOR_TAB){
//// System.out.println("we are switching form s to e");
//// getServerViewerTab().refreshBrowser();
// ICoordinator coordinator=(DeveloperCoordinator) DeveloperCoordinator.getInstance();
// FitView fv= (FitView) coordinator.getView(FitView.class);
// fv.refreshWikiEditor(getWikiEditorTab().getWikiPageName());
// }
// lastActiveView=itemIndex;
}
public void widgetDefaultSelected(SelectionEvent event)
{
}
});
//create log in tab
Composite tabFolderPage = new Composite (tabFolder, SWT.NULL);
tabFolderPage.setLayout (new FillLayout ());
loginTab = new LoginTab(tabFolderPage,this);
TabItem itemLoginTab = new TabItem (tabFolder, SWT.NULL,0);
itemLoginTab.setText (EditorConstants.LOGIN_TAB_TITLE);
itemLoginTab.setControl (tabFolderPage);
//create wiki editor tab
Composite tabFolderPage1 = new Composite (tabFolder, SWT.NULL);
tabFolderPage1.setLayout (new FillLayout ());
wikiEditorTab = new WikiEditorTab(tabFolderPage1,this);
TabItem itemWikiEditor = new TabItem (tabFolder, SWT.NULL,1);
itemWikiEditor.setText (EditorConstants.WIKI_EDITOR_TAB_TITLE);
itemWikiEditor.setControl (tabFolderPage1);
//create preview tab
// Composite tabFolderPage2 = new Composite(tabFolder, SWT.NULL);
// tabFolderPage2.setLayout(new FillLayout());
//
//
//create server viewer tab
Composite tabFolderPage3 = new Composite (tabFolder, SWT.NULL);
tabFolderPage3.setLayout (new FillLayout ());
serverViewerTab = new ServerViewer(tabFolderPage3,this);
TabItem itemServerViewerTab = new TabItem (tabFolder, SWT.NULL,2);
itemServerViewerTab.setText (EditorConstants.SERVER_VIEWER_TAB_TITLE);
itemServerViewerTab.setControl (tabFolderPage3);
}
// public static TabCreator getInstance(){
// if(instance==null){
// instance=new TabCreator();
// return instance;
// }
// }
public LoginTab getLoginTab()
{
return this.loginTab;
}
public WikiEditorTab getWikiEditorTab()
{
return wikiEditorTab;
}
/**
* Grabs input focus.
*/
public void setFocus() {
tabFolder.setFocus();
}
/**
* Disposes of all resources associated with a particular
* instance of the LayoutExample.
*/
public void dispose() {
tabFolder = null;
}
private void setMainView(FitView view)
{
this.view=view;
}
public FitView getMainView()
{
return this.view;
}
public ServerViewer getServerViewerTab() {
return serverViewerTab;
}
private void wysiwygOperation(int tabIndex)
{
switch(tabIndex)
{
case EditorConstants.SERVER_VIEWER_TAB:
this.getServerViewerTab().refreshBrowser();
break;
default:
break;
}
}
public void showView(int view){
tabFolder.setSelection(view);
}
}
See more files for this project here