public void testCreateView() {
    final MWindow window = createWindowWithOneView("Part Name");

    MApplication application = ApplicationFactoryImpl.eINSTANCE.createApplication();
    application.getChildren().add(window);
    application.setContext(appContext);
    appContext.set(MApplication.class.getName(), application);

    wb = new E4Workbench(application, appContext);
    wb.createAndRunUI(window);

    MPartSashContainer container = (MPartSashContainer) window.getChildren().get(0);
    MPartStack stack = (MPartStack) container.getChildren().get(0);
    MPart part = (MPart) stack.getChildren().get(0);

    CTabFolder folder = (CTabFolder) stack.getWidget();
    CTabItem item = folder.getItem(0);
    assertEquals("Part Name", item.getText());

    assertFalse(part.isDirty());

    part.setDirty(true);
    assertEquals("*Part Name", item.getText());

    part.setDirty(false);
    assertEquals("Part Name", item.getText());
  }
 public String retrieveCSSProperty(
     Control control, String property, String pseudo, CSSEngine engine) throws Exception {
   if (control instanceof CTabFolder) {
     CTabFolder folder = (CTabFolder) control;
     return Boolean.toString(folder.getSingle());
   }
   return null;
 }
 public void applyCSSProperty(
     Control control, String property, CSSValue value, String pseudo, CSSEngine engine)
     throws Exception {
   boolean isSingle = (Boolean) engine.convert(value, Boolean.class, null);
   if (control instanceof CTabFolder) {
     CTabFolder folder = (CTabFolder) control;
     folder.setSingle(isSingle);
   }
 }
  /* (non-Javadoc)
   * @see org.eclipse.ui.IPresentationPreview#createControl(org.eclipse.swt.widgets.Composite, org.eclipse.ui.themes.ITheme)
   */
  public void createControl(Composite parent, ITheme currentTheme) {
    this.theme = currentTheme;
    folder = new CTabFolder(parent, SWT.BORDER);
    folder.setUnselectedCloseVisible(false);
    folder.setEnabled(false);
    folder.setMaximizeVisible(true);
    folder.setMinimizeVisible(true);

    viewForm = new ViewForm(folder, SWT.NONE);
    viewForm.marginHeight = 0;
    viewForm.marginWidth = 0;
    viewForm.verticalSpacing = 0;
    viewForm.setBorderVisible(false);
    toolBar = new ToolBar(viewForm, SWT.FLAT | SWT.WRAP);
    ToolItem toolItem = new ToolItem(toolBar, SWT.PUSH);

    Image hoverImage = WorkbenchImages.getImage(IWorkbenchGraphicConstants.IMG_LCL_VIEW_MENU);
    toolItem.setImage(hoverImage);

    viewForm.setTopRight(toolBar);

    viewMessage = new CLabel(viewForm, SWT.NONE);
    viewMessage.setText("Etu?"); // $NON-NLS-1$
    viewForm.setTopLeft(viewMessage);

    CTabItem item = new CTabItem(folder, SWT.CLOSE);
    item.setText("Lorem"); // $NON-NLS-1$
    Label text = new Label(viewForm, SWT.NONE);
    viewForm.setContent(text);
    text.setText("Lorem ipsum dolor sit amet"); // $NON-NLS-1$
    item = new CTabItem(folder, SWT.CLOSE);
    item.setText("Ipsum"); // $NON-NLS-1$
    item.setControl(viewForm);
    item.setImage(WorkbenchImages.getImage(ISharedImages.IMG_TOOL_COPY));

    folder.setSelection(item);

    item = new CTabItem(folder, SWT.CLOSE);
    item.setText("Dolor"); // $NON-NLS-1$
    item = new CTabItem(folder, SWT.CLOSE);
    item.setText("Sit"); // $NON-NLS-1$

    currentTheme.addPropertyChangeListener(fontAndColorListener);
    setColorsAndFonts();
    setTabPosition();
    setTabStyle();
  }
  /** Set the folder colors and fonts */
  private void setColorsAndFonts() {
    folder.setSelectionForeground(
        theme.getColorRegistry().get(IWorkbenchThemeConstants.ACTIVE_TAB_TEXT_COLOR));
    folder.setForeground(
        theme.getColorRegistry().get(IWorkbenchThemeConstants.INACTIVE_TAB_TEXT_COLOR));

    Color[] colors = new Color[2];
    colors[0] = theme.getColorRegistry().get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_START);
    colors[1] = theme.getColorRegistry().get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_END);
    colors[0] = theme.getColorRegistry().get(IWorkbenchThemeConstants.ACTIVE_TAB_BG_START);
    colors[1] = theme.getColorRegistry().get(IWorkbenchThemeConstants.ACTIVE_TAB_BG_END);
    folder.setSelectionBackground(
        colors,
        new int[] {theme.getInt(IWorkbenchThemeConstants.ACTIVE_TAB_PERCENT)},
        theme.getBoolean(IWorkbenchThemeConstants.ACTIVE_TAB_VERTICAL));

    folder.setFont(theme.getFontRegistry().get(IWorkbenchThemeConstants.TAB_TEXT_FONT));
    viewMessage.setFont(
        theme.getFontRegistry().get(IWorkbenchThemeConstants.VIEW_MESSAGE_TEXT_FONT));
  }
  /*
   * (non-Javadoc)
   *
   * @see
   * org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands
   * .ExecutionEvent)
   */
  public Object execute(ExecutionEvent event) throws ExecutionException {
    IWorkbenchPart part = HandlerUtil.getActivePart(event);
    if (part != null) {
      IWorkbenchPartSite site = part.getSite();
      if (site instanceof PartSite) {
        final MPart model = ((PartSite) site).getModel();
        Composite partContainer = (Composite) model.getWidget();
        if (partContainer != null) {
          Composite parent = partContainer.getParent();
          while (parent != null && parent instanceof Composite) {
            if (parent instanceof CTabFolder) {
              CTabFolder ctf = (CTabFolder) parent;
              final Control topRight = ctf.getTopRight();
              if (topRight instanceof Composite) {
                for (Control child : ((Composite) topRight).getChildren()) {
                  if (child instanceof ToolBar
                      && "ViewMenu".equals(child.getData())) { // $NON-NLS-1$
                    ToolBar tb = (ToolBar) child;
                    ToolItem ti = tb.getItem(0);
                    Event sevent = new Event();
                    sevent.type = SWT.Selection;
                    sevent.widget = ti;
                    ti.notifyListeners(SWT.Selection, sevent);
                  }
                }
              }
              return null;
            }
            parent = parent.getParent();
          }

          MMenu menuModel = StackRenderer.getViewMenu(model);
          if (menuModel != null) {
            showStandaloneViewMenu(event, model, menuModel, partContainer);
          }
        }
      }
    }
    return null;
  }
 /** Set the tab location from preferences. */
 protected void setTabPosition() {
   tabPos =
       PlatformUI.getPreferenceStore().getInt(IWorkbenchPreferenceConstants.VIEW_TAB_POSITION);
   folder.setTabPosition(tabPos);
 }
 /** Set the tab style from preferences. */
 protected void setTabStyle() {
   boolean traditionalTab =
       PlatformUI.getPreferenceStore()
           .getBoolean(IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS);
   folder.setSimple(traditionalTab);
 }