Java Code Examples for org.eclipse.swt.custom.CTabItem#setShowClose()

The following examples show how to use org.eclipse.swt.custom.CTabItem#setShowClose() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TabbedEntry.java    From BiglyBT with GNU General Public License v2.0 6 votes vote down vote up
public void setSwtItem(CTabItem swtItem) {
	this.swtItem = swtItem;
	if (swtItem == null) {
		return;
	}

	swtItem.addDisposeListener(e -> closeView( userInitiatedClose ));
	String title = getTitle();
	if (title != null) {
		swtItem.setText(Utils.escapeAccelerators(title));
	}

	updateLeftImage();

	swtItem.setShowClose(isCloseable());

	if (buildonSWTItemSet) {
		build();
	}
	if (showonSWTItemSet) {
		show();
	}
}
 
Example 2
Source File: GamaPreferencesView.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
private void buildContents() {
	tabFolder = new CTabFolder(shell, SWT.TOP | SWT.NO_TRIM);
	tabFolder.setBorderVisible(true);
	tabFolder.setBackgroundMode(SWT.INHERIT_DEFAULT);
	tabFolder.setMRUVisible(true);
	tabFolder.setSimple(false); // rounded tabs
	tabFolder.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true, 2, 1));
	final Map<String, Map<String, List<Pref>>> prefs = GamaPreferences.organizePrefs();
	for (final String tabName : prefs.keySet()) {
		final CTabItem item = new CTabItem(tabFolder, SWT.NONE);
		item.setFont(GamaFonts.getNavigHeaderFont());
		item.setText(tabName);
		item.setImage(prefs_images.get(tabName));
		item.setShowClose(false);
		buildContentsFor(item, prefs.get(tabName));
	}
	buildButtons();
	shell.layout();
}
 
Example 3
Source File: ComponentTitledBorder.java    From arx with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new instance.
 *
 * @param parent
 * @param controller
 * @param title
 * @param id
 */
public ComponentTitledBorder(Composite parent, Controller controller, String title, String id){

    folder = new CTabFolder(parent, SWT.TOP | SWT.BORDER | SWT.FLAT);
    folder.setUnselectedCloseVisible(false);
    folder.setSimple(false);
    
    // Create help button
    if (controller != null) SWTUtil.createHelpButton(controller, folder, id);

    // Prevent closing
    folder.addCTabFolder2Listener(new CTabFolder2Adapter() {
        @Override
        public void close(final CTabFolderEvent event) {
            event.doit = false;
        }
    });
    
    // Create general tab
    tab = new CTabItem(folder, SWT.NULL);
    tab.setText(title);
    tab.setShowClose(false);

    folder.setSelection(tab);
}
 
Example 4
Source File: TabFolderReorder.java    From hop with Apache License 2.0 5 votes vote down vote up
private void moveTabs( CTabFolder folder, DropTargetEvent event ) {
  Point point = folder.toControl( folder.getDisplay().getCursorLocation() );
  CTabItem item = folder.getItem( new Point( point.x, point.y ) );
  if ( item != null && dragItem != null ) {
    Control dragControl = dragItem.getControl();
    String dragText = dragItem.getText();
    Image dragImage = dragItem.getImage();
    String dragToolTip = dragItem.getToolTipText();
    boolean dragShowClose = dragItem.getShowClose();
    Object dragData = dragItem.getData();

    dragItem.setText( item.getText() );
    dragItem.setImage( item.getImage() );
    dragItem.setToolTipText( item.getToolTipText() );
    dragItem.setData( item.getData() );
    dragItem.setShowClose( item.getShowClose() );
    dragItem.setControl( item.getControl() );

    item.setText( dragText );
    item.setImage( dragImage );
    item.setToolTipText( dragToolTip );
    item.setData( dragData );
    item.setShowClose( dragShowClose );
    item.setControl( dragControl );

    folder.setSelection( item );
  }
}
 
Example 5
Source File: ComponentTitledFolder.java    From arx with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new entry in the folder.
 *  
 * @param title
 * @param image
 * @param index
 * @param hideable
 * @param layout
 * @return
 */
public Composite createItem(String title, Image image, int index, boolean hideable, Layout layout) {
    
    Composite composite = new Composite(folder, SWT.NONE);
    composite.setLayout(layout);
    
    CTabItem item = new CTabItem(folder, SWT.NULL, index);
    item.setText(title);
    if (image!=null) item.setImage(image);
    item.setShowClose(false);
    item.setControl(composite);
    entries.add(new TitledFolderEntry(title, composite, image, index, hideable));
    return composite;
}
 
Example 6
Source File: ComponentTitledFolder.java    From arx with Apache License 2.0 5 votes vote down vote up
/**
 * Sets an entry visible
 * @return
 */
private boolean setVisible(String text) {
    List<TitledFolderEntry> list = getInvisibleEntries();
    
    // Find
    for (TitledFolderEntry entry : list) {
        if (entry.text.equals(text)) {

            // Shift
            int index = entry.index;
            for (TitledFolderEntry other : list) {
                if (other.index < entry.index) {
                    index--;
                }
            }
            
            // Show
            CTabItem item = new CTabItem(folder, SWT.NULL, index);
            item.setText(entry.text);
            if (entry.image!=null) item.setImage(entry.image);
            item.setShowClose(false);
            item.setControl(entry.control);
            return true;
        }
    }
    return false;
}
 
Example 7
Source File: ModelEditor.java    From tlaplus with MIT License 4 votes vote down vote up
protected void addPages()
 {
     // TLCUIActivator.getDefault().logDebug("entering ModelEditor#addPages()");
     try
     {
         // This code moves the tabs to the top of the page.
         // This makes them more obvious to the user.
     	final CTabFolder tabFolder = (CTabFolder)getContainer();
     	tabFolder.setTabPosition(SWT.TOP);
     	tabFolder.addCTabFolder2Listener(listener);

for (int i = 0; i < pagesToAdd.length; i++) {
             addPage(pagesToAdd[i]);
             // initialize the page
             // this means the content will be created
             // the data will be loaded
             // the refresh method will update the UI state
             // the dirty listeners will be activated
             if (pagesToAdd[i].getPartControl() == null)
             {
                 pagesToAdd[i].createPartControl(tabFolder);
                 setControl(i, pagesToAdd[i].getPartControl());
                 pagesToAdd[i].getPartControl().setMenu(tabFolder.getMenu());
             }
             
             final CTabItem item = tabFolder.getItem(i);
             // we have to do this to allow our superclass' getEditor(int) to work correctly since we don't
             //		add the page via addPage(IEditorPart,IEditorInput)
             item.setData(pagesToAdd[i]);
             if (pagesToAdd[i] instanceof Closeable) {
     			item.setShowClose(true);
     			
     			indexCloseableMap.put(new Integer(i), (Closeable)pagesToAdd[i]);
             }
         }

         // at this point everything is activated and initialized.
         // run the validation
         UIHelper.runUIAsync(validateRunable);

         
         final ModuleNode rootModule = SemanticHelper.getRootModuleNode();
if ((rootModule != null) && (rootModule.getVariableDecls().length == 0)
		&& (rootModule.getConstantDecls().length == 0)) {
         	addOrShowResultsPage();
         }
         
         if (model.hasStateGraphDump()) {
         	addOrUpdateStateGraphEditor(model.getStateGraphDump());
         }
     } catch (CoreException e)
     {
         TLCUIActivator.getDefault().logError("Error initializing editor", e);
     }

     // TLCUIActivator.getDefault().logDebug("leaving ModelEditor#addPages()");
 }