org.eclipse.swt.custom.CTabItem Java Examples

The following examples show how to use org.eclipse.swt.custom.CTabItem. 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: ScriptDropper.java    From Rel with Apache License 2.0 6 votes vote down vote up
@Override
public void go(DbTreeItem item, String imageName) {
	CTabItem tab = relPanel.getTab(item.getTabName());
	if (tab != null) {
		relPanel.getTabFolder().setSelection(tab);
		MessageDialog.openInformation(relPanel.getShell(), "Note", "You must close the '" + item.getTabName() + "' tab first.");
	} else {
		if (!MessageDialog.openConfirm(relPanel.getShell(), "Confirm DROP", "Are you sure you wish to drop script " + item.getName() + "?"))
			return;
		RevDatabase database = new RevDatabase(relPanel.getConnection());
		if (!database.scriptDelete(item.getName()))
			MessageDialog.openError(relPanel.getShell(), "Error", "Unable to drop script " + item.getName() + ". Check the system log for details.");
		else
			relPanel.redisplayed();
	}
}
 
Example #2
Source File: GamaPreferencesView.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
private void buildContentsFor(final CTabItem tab, final Map<String, List<Pref>> entries) {
	final ParameterExpandBar viewer = new ParameterExpandBar(tab.getParent(), SWT.V_SCROLL);
	contents.add(viewer);
	final GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
	viewer.setLayoutData(data);
	// ?
	viewer.computeSize(tab.getBounds().x, SWT.DEFAULT);
	//
	viewer.setSpacing(5);
	tab.setControl(viewer);
	for (final String groupName : entries.keySet()) {
		final ParameterExpandItem item = new ParameterExpandItem(viewer, entries.get(groupName), SWT.NONE, null);
		item.setText(groupName);
		item.setColor(new GamaColor(230, 230, 230, 255));
		final Composite compo = new Composite(viewer, SWT.NONE);
		compo.setBackground(viewer.getBackground());
		buildGroupContents(compo, entries.get(groupName), NB_DIVISIONS);
		item.setControl(compo);
		item.setHeight(compo.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
		item.setExpanded(true);
	}

}
 
Example #3
Source File: TabSetTest.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Test
public void testRegularCloseTab() {
  final CTabFolder cTabFolder = mock( CTabFolder.class );
  final TabSet tabSet = createTabSet( cTabFolder );

  final CTabItem cTabItem1 = mock( CTabItem.class );
  TabItem firstItem = createItem( tabSet, "first", "1st", cTabItem1 );
  final CTabItem cTabItem2 = mock( CTabItem.class );
  TabItem secondItem = createItem( tabSet, "second", "2nd", cTabItem2 );
  TabItem thirdItem = createItem( tabSet, "third", "3rd", mock( CTabItem.class ) );

  assertEquals( 0, tabSet.indexOf( firstItem ) );
  assertEquals( 1, tabSet.indexOf( secondItem ) );
  assertEquals( 2, tabSet.indexOf( thirdItem ) );

  // after close the previous tab is selected if available
  wireDisposalSelection( cTabFolder, tabSet, cTabItem2, cTabItem1 );
  tabSet.setSelected( secondItem );
  assertEquals( 1, tabSet.getSelectedIndex() );
  secondItem.dispose();
  assertEquals( "should select first", firstItem, tabSet.getSelected() );
}
 
Example #4
Source File: BriefAuswahl.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
public void relabel(){
	UiDesk.asyncExec(new Runnable() {
		public void run(){
			Patient pat = (Patient) ElexisEventDispatcher.getSelected(Patient.class);
			if (form != null && !form.isDisposed()) {
				if (pat == null) {
					form.setText(Messages.BriefAuswahlNoPatientSelected); //$NON-NLS-1$
				} else {
					form.setText(pat.getLabel());
					CTabItem sel = ctab.getSelection();
					if (sel != null) {
						CommonViewer cv = (CommonViewer) sel.getData();
						cv.notify(CommonViewer.Message.update);
					}
				}
			}
		}
	});
	
}
 
Example #5
Source File: AttributeViewPage.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public void createTabItems( List input )
{
	super.createTabItems( input );
	Composite pane = new Composite( tabFolder, SWT.NONE );
	pane.setLayout( new FillLayout( ) );

	new MessageAttributePage( pane, SWT.NONE, input );

	CTabItem tabItem = new CTabItem( tabFolder, SWT.NONE );

	if ( input.get( 0 ) instanceof ModelClassWrapper )
	{
		tabItem.setText( ( (ModelClassWrapper) input.get( 0 ) ).getTypeMessage( ) );
	}
	tabItem.setControl( pane );
}
 
Example #6
Source File: ScriptValuesModDialog.java    From hop with Apache License 2.0 6 votes vote down vote up
private void refresh() {
  // CTabItem item = getCTabItemByName(strActiveScript);
  for ( int i = 0; i < folder.getItemCount(); i++ ) {
    CTabItem item = folder.getItem( i );
    if ( item.getText().equals( strActiveScript ) ) {
      item.setImage( imageActiveScript );
    } else if ( item.getText().equals( strActiveStartScript ) ) {
      item.setImage( imageActiveStartScript );
    } else if ( item.getText().equals( strActiveEndScript ) ) {
      item.setImage( imageActiveEndScript );
    } else {
      item.setImage( imageInactiveScript );
    }
  }
  // modifyScriptTree(null, SET_ACTIVE_ITEM);
}
 
Example #7
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 #8
Source File: TabSetTest.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
/**
 * Ctrl-W on first and second in succession would close first and third
 */
@Test
public void testCloseFirstTabOfThree() {
  final CTabFolder cTabFolder = mock( CTabFolder.class );
  final TabSet tabSet = createTabSet( cTabFolder );

  final CTabItem cTabItem1 = mock( CTabItem.class );
  TabItem firstItem = createItem( tabSet, "first", "1st", cTabItem1 );
  final CTabItem cTabItem2 = mock( CTabItem.class );
  TabItem secondItem = createItem( tabSet, "second", "2nd", cTabItem2 );
  TabItem thirdItem = createItem( tabSet, "third", "3rd", mock( CTabItem.class ) );

  assertEquals( 0, tabSet.indexOf( firstItem ) );
  assertEquals( 1, tabSet.indexOf( secondItem ) );
  assertEquals( 2, tabSet.indexOf( thirdItem ) );

  wireDisposalSelection( cTabFolder, tabSet, cTabItem1, cTabItem2 );
  tabSet.setSelected( firstItem );
  assertEquals( 0, tabSet.getSelectedIndex() );

  firstItem.dispose();
  assertEquals( "should select second", secondItem, tabSet.getSelected() );
}
 
Example #9
Source File: CTabFolderStackPresentation.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
/** 
 * {@inheritDoc}
 */
@Override
public void addPart(final IPresentablePart newPart, Object cookie)
{
    ignoreSelection = true;
    final CTabItem item = new CTabItem(tabFolder,SWT.NONE);
    ignoreSelection = false;
    item.setData(DATAKEY_PART,newPart);
    
    updateItem(newPart);
    
    newPart.addPropertyListener(new IPropertyListener()
    {        
        public void propertyChanged(Object source, int propId)
        {
            updateItem(newPart);
        }        
    });
}
 
Example #10
Source File: ConstraintDropper.java    From Rel with Apache License 2.0 6 votes vote down vote up
@Override
public void go(DbTreeItem item, String imageName) {
	CTabItem tab = relPanel.getTab(item.getTabName());
	if (tab != null) {
		relPanel.getTabFolder().setSelection(tab);
		MessageDialog.openInformation(relPanel.getShell(), "Note", "You must close the '" + item.getTabName() + "' tab first.");
	} else {
		if (!MessageDialog.openConfirm(relPanel.getShell(), "Confirm DROP", "Are you sure you wish to drop constraint " + item.getName() + "?"))
			return;
		ExecuteResult result = relPanel.getConnection().execute("DROP CONSTRAINT " + item.getName() + ";");
		if (result.failed())
			MessageDialog.openError(relPanel.getShell(), "Error", "Unable to drop constraint " + item.getName() + ": " + result.getErrorMessage());
		else
			relPanel.redisplayed();
	}
}
 
Example #11
Source File: TabbedEntry.java    From BiglyBT with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void destroyEntry( boolean userInitiated ) {
	if (Utils.runIfNotSWTThread(()->destroyEntry(userInitiated))) {
		return;
	}

	if (swtItem == null) {
		return;
	}

	// Must make a copy of swtItem because swtItem.dispose will end up in
	// this method again, with swtItem.isDisposed() still false.
	CTabItem item = swtItem;
	swtItem = null;

	super.destroyEntry( userInitiated );

	try {
		if (!item.isDisposed()) {
			item.dispose();
		}
	}catch( SWTException e ){
		// getting internal 'Widget it disposed' here, ignore
	}
}
 
Example #12
Source File: RotatedTextPageGenerator.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
protected void buildItemContent( CTabItem item )
{
	if ( itemMap.containsKey( item ) && itemMap.get( item ) == null )
	{
		String title = tabFolder.getSelection( ).getText( );

		if ( CUSTOM_PAGE_TITLE.equals( title ) )
		{
			TabPage page = new RotatedTextCustomPage( ).getPage( );

			if ( page != null )
			{
				setPageInput( page );
				refresh( tabFolder, page, true );
				item.setControl( page.getControl( ) );
				itemMap.put( item, page );
			}
		}
	}
	else if ( itemMap.get( item ) != null )
	{
		setPageInput( itemMap.get( item ) );
		refresh( tabFolder, itemMap.get( item ), false );
	}
}
 
Example #13
Source File: JobGraph.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public void addAllTabs() {

    CTabItem tabItemSelection = null;
    if ( extraViewTabFolder != null && !extraViewTabFolder.isDisposed() ) {
      tabItemSelection = extraViewTabFolder.getSelection();
    }

    jobHistoryDelegate.addJobHistory();
    jobLogDelegate.addJobLog();
    jobGridDelegate.addJobGrid();
    jobMetricsDelegate.addJobMetrics();

    if ( tabItemSelection != null ) {
      extraViewTabFolder.setSelection( tabItemSelection );
    } else {
      extraViewTabFolder.setSelection( jobGridDelegate.getJobGridTab() );
    }

    XulToolbarbutton button = (XulToolbarbutton) toolbar.getElementById( "job-show-results" );
    button.setTooltiptext( BaseMessages.getString( PKG, "Spoon.Tooltip.HideExecutionResults" ) );
    ToolItem swtToolItem = (ToolItem) button.getManagedObject();
    swtToolItem.setImage( GUIResource.getInstance().getImageHideResults() );
  }
 
Example #14
Source File: MQTTConsumerDialog.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private void buildFieldsTab() {
  CTabItem wFieldsTab = new CTabItem( wTabFolder, SWT.NONE, 3 );
  wFieldsTab.setText( BaseMessages.getString( PKG, "MQTTConsumerDialog.FieldsTab" ) );

  Composite wFieldsComp = new Composite( wTabFolder, SWT.NONE );
  props.setLook( wFieldsComp );
  FormLayout fieldsLayout = new FormLayout();
  fieldsLayout.marginHeight = 15;
  fieldsLayout.marginWidth = 15;
  wFieldsComp.setLayout( fieldsLayout );

  FormData fieldsFormData = new FormData();
  fieldsFormData.left = new FormAttachment( 0, 0 );
  fieldsFormData.top = new FormAttachment( wFieldsComp, 0 );
  fieldsFormData.right = new FormAttachment( 100, 0 );
  fieldsFormData.bottom = new FormAttachment( 100, 0 );
  wFieldsComp.setLayoutData( fieldsFormData );

  buildFieldTable( wFieldsComp, wFieldsComp );

  wFieldsComp.layout();
  wFieldsTab.setControl( wFieldsComp );
}
 
Example #15
Source File: CTabFolderExample.java    From codeexamples-eclipse with Eclipse Public License 1.0 5 votes vote down vote up
public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);

    shell.setLayout(new GridLayout());
    // SWT.BOTTOM to show at the bottom
    CTabFolder folder = new CTabFolder(shell, SWT.TOP);
    GridData data = new GridData(SWT.FILL, 
            SWT.FILL, true, true,
            2, 1);
    folder.setLayoutData(data);
    CTabItem cTabItem1 = new CTabItem(folder, SWT.NONE);
    cTabItem1.setText("Tab1");
    CTabItem cTabItem2 = new CTabItem(folder, SWT.NONE);
    cTabItem2.setText("Tab2");
    CTabItem cTabItem3 = new CTabItem(folder, SWT.NONE);
    cTabItem3.setText("Tab3");
    CTabItem cTabItem4 = new CTabItem(folder, SWT.NONE);
    cTabItem4.setText("Tab4");

    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
}
 
Example #16
Source File: ArtikelView.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
/** Vom ActivationListener */
public void activation(boolean mode){
	CTabItem selected = ctab.getSelection();
	if(selected instanceof FavoritenCTabItem) return;
	if (selected != null) {
		MasterDetailsPage page = (MasterDetailsPage) selected.getControl();
		ViewerConfigurer vc = page.cv.getConfigurer();
		if (mode == true) {
			vc.getControlFieldProvider().setFocus();
		} else {
			vc.getControlFieldProvider().clearValues();
		}
	}
}
 
Example #17
Source File: Importer.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Run the import method of the topmost plugin
 */
@Override
protected void okPressed(){
	CTabItem top = ctab.getSelection();
	if (top != null) {
		ImporterPage page = (ImporterPage) top.getData();
		page.collect();
		page.run(false);
	}
	super.okPressed();
}
 
Example #18
Source File: ScriptValuesModDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private CTabItem getCTabItemByName( String strTabName ) {
  CTabItem[] cItems = folder.getItems();
  for ( int i = 0; i < cItems.length; i++ ) {
    if ( cItems[i].getText().equals( strTabName ) ) {
      return cItems[i];
    }
  }
  return null;
}
 
Example #19
Source File: DiskInfoTab.java    From AppleCommander with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create the DISK INFO tab.
 */
public DiskInfoTab(CTabFolder tabFolder, FormattedDisk[] disks) {
	this.formattedDisks = disks;
	
	CTabItem ctabitem = new CTabItem(tabFolder, SWT.NULL);
	ctabitem.setText(textBundle.get("DiskInfoTab.Title")); //$NON-NLS-1$
	
	tabFolder.addSelectionListener(new SelectionAdapter() {
		public void widgetSelected(SelectionEvent event) {
			getInfoTable().removeAll();
			buildDiskInfoTable(getFormattedDisk(0));	// FIXME!
		}
	});
	
	ScrolledComposite scrolledComposite = new ScrolledComposite(
		tabFolder, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
	scrolledComposite.setExpandHorizontal(true);
	scrolledComposite.setExpandVertical(true);
	ctabitem.setControl(scrolledComposite);
	
	composite = new Composite(scrolledComposite, SWT.NONE);
	createDiskInfoTable();
	if (disks.length > 1) {
		RowLayout layout = new RowLayout(SWT.VERTICAL);
		layout.wrap = false;
		composite.setLayout(layout);
		for (int i=0; i<disks.length; i++) {
			Label label = new Label(composite, SWT.NULL);
			label.setText(disks[i].getDiskName());
			buildDiskInfoTable(disks[i]);
		}
	} else {
		composite.setLayout(new FillLayout());
		buildDiskInfoTable(disks[0]);
	}
	composite.pack();
	scrolledComposite.setContent(composite);
	scrolledComposite.setMinSize(
		composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
}
 
Example #20
Source File: ScriptDialog.java    From hop with Apache License 2.0 5 votes vote down vote up
private void refreshScripts() {
  CTabItem[] cTabs = folder.getItems();
  for ( int i = 0; i < cTabs.length; i++ ) {
    if ( cTabs[ i ].getImage().equals( imageActiveStartScript ) ) {
      strActiveStartScript = cTabs[ i ].getText();
    } else if ( cTabs[ i ].getImage().equals( imageActiveEndScript ) ) {
      strActiveEndScript = cTabs[ i ].getText();
    }
  }
}
 
Example #21
Source File: ScriptValuesModDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private StyledTextComp getStyledTextComp() {
  CTabItem item = folder.getSelection();
  if ( item.getControl().isDisposed() ) {
    return null;
  } else {
    return (StyledTextComp) item.getControl();
  }
}
 
Example #22
Source File: BriefAuswahl.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
public void refreshSelectedViewer(){
	CTabItem sel = ctab.getSelection();
	if ((sel != null)) {
		CommonViewer cv = (CommonViewer) sel.getData();
		cv.notify(CommonViewer.Message.update);
	}
}
 
Example #23
Source File: TemplatePrintView.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Drukt Dokument anhand einer Vorlage
 * 
 * @param pat
 *            der Patient
 * @param templateName
 *            Name der Vorlage
 * @param printer
 *            Printer
 * @param tray
 *            Tray
 * @param monitor
 * @return
 */

public boolean doPrint(Patient pat, String templateName, String printer, String tray,
	IProgressMonitor monitor){
	monitor.subTask(pat.getLabel());
	
	// TODO ?
	// GlobalEvents.getInstance().fireSelectionEvent(rn,getViewSite());
	
	existing = ctab.getItems().length;
	CTabItem ct;
	TextContainer text;
	
	if (--existing < 0) {
		ct = addItem(templateName, templateName, pat);
	} else {
		ct = ctab.getItem(0);
		useItem(0, templateName, pat);
	}
	
	text = (TextContainer) ct.getData(KEY_TEXT);
	
	text.getPlugin().setFont("Serif", SWT.NORMAL, 9); //$NON-NLS-1$
	if (text.getPlugin().print(printer, tray, false) == false) {
		return false;
	}
	monitor.worked(1);
	return true;
}
 
Example #24
Source File: ChartPageGenerator.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @param item
 * @since 2.3
 */
private void setFilterPage( CTabItem item )
{
	AbstractFilterHandleProvider providerDelegate = getFilterProviderDelegate( );
	
	filterPage = new FilterPage( FormPropertyDescriptor.FULL_FUNCTION,
			providerDelegate,
			true,
			true );
	setPageInput( filterPage );
	refresh( tabFolder, filterPage, true );
	item.setControl( filterPage.getControl( ) );
	itemMap.put( item, filterPage );
}
 
Example #25
Source File: BriefAuswahl.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
public void refreshCV(Message updateKeeplabels){
	if (ctab != null && !ctab.isDisposed()) {
		CTabItem sel = ctab.getSelection();
		if (sel != null) {
			CommonViewer cv = (CommonViewer) sel.getData();
			cv.notify(updateKeeplabels);
		}
	}
}
 
Example #26
Source File: ScriptDialog.java    From hop with Apache License 2.0 5 votes vote down vote up
private CTabItem getCTabItemByName( String strTabName ) {
  CTabItem[] cItems = folder.getItems();
  for ( int i = 0; i < cItems.length; i++ ) {
    if ( cItems[ i ].getText().equals( strTabName ) ) {
      return cItems[ i ];
    }
  }
  return null;
}
 
Example #27
Source File: ScriptDialog.java    From hop with Apache License 2.0 5 votes vote down vote up
private void modifyScriptTree( CTabItem ctabitem, int iModType ) {

    switch ( iModType ) {
      case DELETE_ITEM:
        TreeItem dItem = getTreeItemByName( ctabitem.getText() );
        if ( dItem != null ) {
          dItem.dispose();
          input.setChanged();
        }
        break;
      case ADD_ITEM:
        TreeItem item = new TreeItem( wTreeScriptsItem, SWT.NULL );
        item.setImage( imageActiveScript );
        item.setText( ctabitem.getText() );
        input.setChanged();
        break;

      case RENAME_ITEM:
        input.setChanged();
        break;
      case SET_ACTIVE_ITEM:
        input.setChanged();
        break;
      default:
        break;
    }
  }
 
Example #28
Source File: HopDataOrchestrationPerspective.java    From hop with Apache License 2.0 5 votes vote down vote up
private void handTabSelectionEvent( Event event ) {
  CTabItem tabItem = (CTabItem) event.item;
  activeItem = findTabItemHandler( tabItem );
  if ( activeItem != null ) {
    activeItem.getTypeHandler().redraw();
    activeItem.getTypeHandler().updateGui();
  }
  int tabIndex = tabFolder.indexOf( tabItem );
  Integer lastIndex = tabSelectionHistory.isEmpty() ? null : tabSelectionHistory.peek();
  if ( lastIndex == null || lastIndex != tabIndex ) {
    tabSelectionHistory.push( tabIndex );
    tabSelectionIndex = tabSelectionHistory.size() - 1;
  }
}
 
Example #29
Source File: VarViewPlayer.java    From Rel with Apache License 2.0 5 votes vote down vote up
@Override
public void go(DbTreeItem item, String imageName) {
	CTabItem tab = relPanel.getTab(item);
	if (tab != null) {
		if (tab instanceof ExpressionResultViewerTab) {
			relPanel.setTab(tab);
			return;
		} else
			tab.dispose();
	}
	ExpressionResultViewerTab viewer = new ExpressionResultViewerTab(relPanel, item, null);
	relPanel.setTab(viewer, imageName);
}
 
Example #30
Source File: ScriptValuesModDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void modifyScriptTree( CTabItem ctabitem, int iModType ) {

    switch ( iModType ) {
      case DELETE_ITEM:
        TreeItem dItem = getTreeItemByName( ctabitem.getText() );
        if ( dItem != null ) {
          dItem.dispose();
          input.setChanged();
        }
        break;
      case ADD_ITEM:
        TreeItem item = new TreeItem( wTreeScriptsItem, SWT.NULL );
        item.setImage( imageActiveScript );
        item.setText( ctabitem.getText() );
        input.setChanged();
        break;

      case RENAME_ITEM:
        input.setChanged();
        break;
      case SET_ACTIVE_ITEM:
        input.setChanged();
        break;
      default:
        break;
    }
  }