org.eclipse.swt.widgets.Composite#getShell ( )源码实例Demo

下面列出了org.eclipse.swt.widgets.Composite#getShell ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: tlaplus   文件: ExecutionStatisticsDialog.java
protected Button createButton(Composite parent, int id, String label, boolean defaultButton) {
	// increment the number of columns in the button bar
	((GridLayout) parent.getLayout()).numColumns++;
	Button button = new Button(parent, SWT.PUSH | SWT.WRAP); // Need wrap here contrary to Dialog#createButton to wrap button label on Windows and macOS(?).
	button.setText(label);
	button.setFont(JFaceResources.getDialogFont());
	button.setData(Integer.valueOf(id));
	button.addSelectionListener(widgetSelectedAdapter(event -> buttonPressed(((Integer) event.widget.getData()).intValue())));
	if (defaultButton) {
		Shell shell = parent.getShell();
		if (shell != null) {
			shell.setDefaultButton(button);
		}
	}
	setButtonLayoutData(button);
	return button;
}
 
源代码2 项目: nebula   文件: XYGraphConfigDialog.java
@Override
protected void createButtonsForButtonBar(Composite parent) {
	((GridLayout) parent.getLayout()).numColumns++;
	Button button = new Button(parent, SWT.PUSH);
	button.setText("Apply");
	GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
	int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
	Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
	data.widthHint = Math.max(widthHint, minSize.x);
	button.setLayoutData(data);
	button.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			applyChanges();
		}
	});
	super.createButtonsForButtonBar(parent);
	Shell shell = parent.getShell();
	if (shell != null) {
		shell.setDefaultButton(button);
	}
}
 
源代码3 项目: neoscada   文件: AbstractChartView.java
@Override
public void createPartControl ( final Composite parent )
{
    parent.setLayout ( new FillLayout () );

    this.wrapper = new Composite ( parent, SWT.NONE );
    this.wrapper.setLayout ( GridLayoutFactory.slimStack () );

    this.shell = parent.getShell ();

    PlatformUI.getWorkbench ().getHelpSystem ().setHelp ( this.wrapper, "org.eclipse.scada.ui.chart.view.chartView" ); //$NON-NLS-1$

    fillMenu ( getViewSite ().getActionBars ().getMenuManager () );
    fillToolbar ( getViewSite ().getActionBars ().getToolBarManager () );

    createChartControl ( parent );
}
 
源代码4 项目: elexis-3-core   文件: FindingsUiUtil.java
/**
 * Returns all actions from the main toolbar
 * 
 * @param c
 * @param iObservation
 * @param horizontalGrap
 * @return
 */
public static List<Action> createToolbarMainComponent(Composite c, IObservation iObservation,
	int horizontalGrap){
	
	Composite toolbarComposite = new Composite(c, SWT.NONE);
	toolbarComposite.setLayout(SWTHelper.createGridLayout(true, 2));
	toolbarComposite.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, true, false));
	
	List<Action> actions = new ArrayList<>();
	LocalDateTime currentDate = iObservation.getEffectiveTime().orElse(LocalDateTime.now());
	
	ToolBarManager menuManager = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL);
	
	Action action = new DateAction(c.getShell(), currentDate, toolbarComposite);
	menuManager.add(action);
	menuManager.createControl(toolbarComposite)
		.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false, horizontalGrap, 1));
	actions.add(action);
	
	return actions;
}
 
public void doFillIntoGrid(Composite parent, int columns) {
  // Cache this for later
  this.shell = parent.getShell();

  resourcesField.doFillIntoGrid(parent, columns);

  GridData modulesFieldGridData = (GridData) resourcesField.getListControl(
      parent).getLayoutData();
  modulesFieldGridData.grabExcessHorizontalSpace = true;
  modulesFieldGridData.grabExcessVerticalSpace = true;
  resourcesField.getListControl(parent).setLayoutData(modulesFieldGridData);
}
 
源代码6 项目: slr-toolkit   文件: PageSupport.java
protected static RGB openAndGetColor(Composite parent, Label label) {
	
	ColorDialog dlg = new ColorDialog(parent.getShell());
	dlg.setRGB(label.getBackground().getRGB());
	dlg.setText("Choose a Color");
	RGB rgb = dlg.open();
       label.setBackground(new Color(parent.getShell().getDisplay(), rgb));
       
	return rgb;
}
 
源代码7 项目: uima-uimaj   文件: INSDComponentPage.java
/**
 * Creates a new button
 * <p>
 * The <code>Dialog</code> implementation of this framework method creates a standard push
 * button, registers for selection events including button presses and registers default buttons
 * with its shell. The button id is stored as the buttons client data. Note that the parent's
 * layout is assumed to be a GridLayout and the number of columns in this layout is incremented.
 * Subclasses may override.
 * </p>
 *
 * @param parent          the parent composite
 * @param label          the label from the button
 * @param defaultButton          <code>true</code> if the button is to be the default button, and <code>false</code>
 *          otherwise
 * @param text the text
 * @return the button
 */
protected Button addButton(Composite parent, String label, boolean defaultButton, final Text text) {

  Button button = new Button(parent, SWT.PUSH);
  button.setText(label);

  if (defaultButton) {
    Shell shell = parent.getShell();
    if (shell != null) {
      shell.setDefaultButton(button);
    }
    button.setFocus();
  }
  button.setFont(parent.getFont());

  SelectionListener listener = new SelectionAdapter() {
    @Override
    public void widgetSelected(SelectionEvent e) {

      ResourceSelectionDialog dialog = new ResourceSelectionDialog(getShell(), currentContainer,
              "Selection Dialog");
      dialog.setTitle("Selection Dialog");
      dialog.setMessage("Please select a file:");
      dialog.open();
      Object[] result = dialog.getResult();
      if (result[0] != null) {
        IResource res = (IResource) result[0];
        text.setText(res.getProjectRelativePath().toOSString());
      }

    }
  };
  button.addSelectionListener(listener);

  return button;
}
 
源代码8 项目: birt   文件: BaseDialog.java
/**
 * @return
 */
private IDialogSettings loadDialogSettings( )
{
	if ( !needRememberLastSize( ) )
	{
		return null;
	}
	IDialogSettings dialogSettings = ReportPlugin.getDefault( )
			.getDialogSettings( );
	StringBuffer buf = new StringBuffer( );
	Shell curShell = getShell( );
	while ( curShell != null )
	{
		buf.append( curShell.toString( ) + '/' );
		Composite parent = curShell.getParent( );
		if ( parent != null )
		{
			curShell = parent.getShell( );
		}
		else
		{
			curShell = null;
		}
	}
	if ( buf.length( ) > 0 )
	{
		buf.deleteCharAt( buf.length( ) - 1 );
		String sectionName = buf.toString( );
		IDialogSettings setting = dialogSettings.getSection( sectionName );
		if ( setting == null )
		{
			setting = dialogSettings.addNewSection( sectionName );
		}
		return setting;
	}
	else
	{
		return dialogSettings;
	}
}
 
源代码9 项目: buffer_bci   文件: ChartPrintJob.java
/** 
 * Prints the specified element.
 * 
 * @param elementToPrint  the {@link Composite} to be printed.
 */
public void print(Composite elementToPrint) {
    PrintDialog dialog = new PrintDialog(elementToPrint.getShell());
    PrinterData printerData = dialog.open();
    if (printerData == null) {
        return; // Anwender hat abgebrochen.
    }
    startPrintJob(elementToPrint, printerData);
}
 
源代码10 项目: mappwidget   文件: MainView.java
protected void getTiles(final Composite parent, final Composite banner, final String imgPath, final String saveDirPath, final String name, final Combo combo,
		final Cutter cutter, final PointVO pointTopLeft, final PointVO pointBottomRight)
{
	MessageBox dialog = new MessageBox(parent.getShell());

	if (name == null || name.contentEquals(""))
	{
		dialog.setMessage(ENTER_NAME_FIRST);
		dialog.open();
		return;
	}

	else if (imgPath == null || imgPath.contentEquals(""))
	{
		dialog.setMessage(CHOOSE_IMAGE_FIRST);
		dialog.open();
		return;
	}

	else if (saveDirPath == null || saveDirPath.contentEquals(""))
	{
		dialog.setMessage(CHOOSE_SAVE_DIR_FIRST);
		dialog.open();
		return;
	}

	File f = new File(imgPath);

	if (f.exists())
	{
		cutter.startCuttingAndroid(imgPath, saveDirPath, name, Integer.parseInt(combo.getItem(combo.getSelectionIndex())), pointTopLeft, pointBottomRight);
	}
	else
	{
		dialog.setMessage(INCORECT_FILE_NAME);
		dialog.open();
		return;
	}

}
 
源代码11 项目: ccu-historian   文件: ChartPrintJob.java
/** 
 * Prints the specified element.
 * 
 * @param elementToPrint  the {@link Composite} to be printed.
 */
public void print(Composite elementToPrint) {
    PrintDialog dialog = new PrintDialog(elementToPrint.getShell());
    PrinterData printerData = dialog.open();
    if (printerData == null) {
        return; // Anwender hat abgebrochen.
    }
    startPrintJob(elementToPrint, printerData);
}
 
public void createControl(Composite parent, int nOfColumns, int textWidth) {
	fShell= parent.getShell();
	PixelConverter converter= new PixelConverter(parent);
	fSourceFolderSelection.doFillIntoGrid(parent, nOfColumns, textWidth);
	LayoutUtil.setWidthHint(fSourceFolderSelection.getTextControl(null), converter.convertWidthInCharsToPixels(60));

	fPackageSelection.doFillIntoGrid(parent, nOfColumns, textWidth);
	LayoutUtil.setWidthHint(fPackageSelection.getTextControl(null), converter.convertWidthInCharsToPixels(60));
}
 
源代码13 项目: JAADAS   文件: SootConfigManagerDialog.java
protected Button createSpecialButton(
	Composite parent,
	int id,
	String label,
	boolean defaultButton, boolean enabled) {


	Button button = new Button(parent, SWT.PUSH);
	button.setText(label);

	button.setData(new Integer(id));
	button.addSelectionListener(new SelectionAdapter() {
	public void widgetSelected(SelectionEvent event) {
		buttonPressed(((Integer) event.widget.getData()).intValue());
	}
	});
	if (defaultButton) {
		Shell shell = parent.getShell();
		if (shell != null) {
			shell.setDefaultButton(button);
		}
	}
	button.setFont(parent.getFont());
	if (!enabled){
		button.setEnabled(false);
	}

	setButtonLayoutData(button);
	specialButtonList.add(button);
	return button;
}
 
源代码14 项目: pentaho-kettle   文件: CopyTableWizardPage2.java
public void createControl( Composite parent ) {
  shell = parent.getShell();

  // create the composite to hold the widgets
  Composite composite = new Composite( parent, SWT.NONE );
  props.setLook( composite );

  FormLayout compLayout = new FormLayout();
  compLayout.marginHeight = Const.FORM_MARGIN;
  compLayout.marginWidth = Const.FORM_MARGIN;
  composite.setLayout( compLayout );

  // Source list to the left...
  wlListSource = new Label( composite, SWT.NONE );
  wlListSource.setText( BaseMessages.getString( PKG, "CopyTableWizardPage2.Dialog.TableList.Label" ) );
  props.setLook( wlListSource );
  FormData fdlListSource = new FormData();
  fdlListSource.left = new FormAttachment( 0, 0 );
  fdlListSource.top = new FormAttachment( 0, 0 );
  wlListSource.setLayoutData( fdlListSource );

  wListSource = new List( composite, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL | SWT.H_SCROLL );
  props.setLook( wListSource );
  wListSource.addSelectionListener( new SelectionAdapter() {
    public void widgetSelected( SelectionEvent arg0 ) {
      setPageComplete( canFlipToNextPage() );
    }
  } );

  FormData fdListSource = new FormData();
  fdListSource.left = new FormAttachment( 0, 0 );
  fdListSource.top = new FormAttachment( wlListSource, 0 );
  fdListSource.right = new FormAttachment( 100, 0 );
  fdListSource.bottom = new FormAttachment( 100, 0 );
  wListSource.setLayoutData( fdListSource );

  // Double click adds to destination.
  wListSource.addSelectionListener( new SelectionAdapter() {
    public void widgetDefaultSelected( SelectionEvent e ) {
      if ( canFinish() ) {
        getWizard().performFinish();
        shell.dispose();
      }
    }
  } );

  // set the composite as the control for this page
  setControl( composite );
}
 
源代码15 项目: elexis-3-core   文件: LaborView.java
@Override
public void createPartControl(final Composite parent){
	setTitleImage(Images.IMG_VIEW_LABORATORY.getImage());
	
	tabFolder = new CTabFolder(parent, SWT.TOP);
	tabFolder.setLayout(new FillLayout());
	
	final CTabItem resultsTabItem = new CTabItem(tabFolder, SWT.NULL);
	resultsTabItem.setText("Resultate");
	resultsComposite = new LaborResultsComposite(tabFolder, SWT.NONE);
	resultsTabItem.setControl(resultsComposite);
	
	final CTabItem ordersTabItem = new CTabItem(tabFolder, SWT.NULL);
	ordersTabItem.setText("Verordnungen");
	ordersComposite = new LaborOrdersComposite(tabFolder, SWT.NONE);
	ordersTabItem.setControl(ordersComposite);
	
	tabFolder.setSelection(0);
	tabFolder.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e){
			resultsComposite.reload();
			ordersComposite.reload();
		}
	});
	makeActions();
	menu = new ViewMenus(getViewSite());
	menu.createMenu(newAction, backAction, fwdAction, printAction, importAction, xmlAction);
	// Orders
	final LaborOrderPulldownMenuCreator menuCreator =
		new LaborOrderPulldownMenuCreator(parent.getShell());
	if (menuCreator.getSelected() != null) {
		IAction dropDownAction = menuCreator.getAction();
		
		IActionBars actionBars = getViewSite().getActionBars();
		IToolBarManager toolbar = actionBars.getToolBarManager();
		
		toolbar.add(dropDownAction);
		
		// Set data
		dropDownAction.setText(menuCreator.getSelected().getText());
		dropDownAction.setToolTipText(menuCreator.getSelected().getToolTipText());
		dropDownAction.setImageDescriptor(menuCreator.getSelected().getImageDescriptor());
	}
	// Importers
	IToolBarManager tm = getViewSite().getActionBars().getToolBarManager();
	List<IAction> importers =
		Extensions.getClasses(
			Extensions.getExtensions(ExtensionPointConstantsUi.LABORDATENIMPORT),
			"ToolbarAction", //$NON-NLS-1$ //$NON-NLS-2$
			false);
	for (IAction ac : importers) {
		tm.add(ac);
	}
	if (importers.size() > 0) {
		tm.add(new Separator());
	}
	tm.add(refreshAction);
	tm.add(newColumnAction);
	tm.add(newAction);
	tm.add(backAction);
	tm.add(fwdAction);
	tm.add(expandAllAction);
	tm.add(collapseAllAction);
	tm.add(printAction);
	
	// register event listeners
	ElexisEventDispatcher.getInstance().addListeners(eeli_labitem, eeli_laborder,
		eeli_labresult, eeli_pat);
	Patient act = (Patient) ElexisEventDispatcher.getSelected(Patient.class);
	if ((act != null && act != resultsComposite.getPatient())) {
		resultsComposite.selectPatient(act);
	}
	getSite().getPage().addPartListener(udpateOnVisible);
}
 
源代码16 项目: birt   文件: ExcelFileSelectionWizardPage.java
public void createControl( Composite parent )
{
	shell = parent.getShell( );
	super.createControl( parent );
}
 
源代码17 项目: CogniCrypt   文件: QuestionsPage.java
@Override
public void createControl(final Composite parent) {
	final Composite container = new Composite(parent, SWT.NONE);
	setControl(container);

	// make the page layout two-column
	container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
	container.setLayout(new GridLayout(2, false));

	setCompositeToHoldGranularUIElements(new CompositeToHoldGranularUIElements(container, getName()));
	// fill the available space on the with the big composite
	getCompositeToHoldGranularUIElements().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

	TaskIntegrationWizard tiWizard = null;

	if (TaskIntegrationWizard.class.isInstance(getWizard())) {
		tiWizard = (TaskIntegrationWizard) getWizard();
	} else {
		Activator.getDefault().logError("PageForTaskIntegratorWizard was instantiated by a wizard other than TaskIntegrationWizard");
	}

	final PageForTaskIntegratorWizard claferPage = tiWizard.getTIPageByName(Constants.PAGE_NAME_FOR_CLAFER_FILE_CREATION);
	final CompositeToHoldGranularUIElements claferPageComposite = claferPage.getCompositeToHoldGranularUIElements();

	final QuestionDialog questionDialog = new QuestionDialog(parent.getShell());
	final Button qstnDialog = new Button(container, SWT.NONE);
	qstnDialog.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false));
	qstnDialog.setText("Add Question");

	qstnDialog.addSelectionListener(new SelectionAdapter() {

		@Override
		public void widgetSelected(final SelectionEvent e) {
			final int response = questionDialog.open();
			final int qID = QuestionsPage.this.compositeToHoldGranularUIElements.getListOfAllQuestions().size();
			if (response == Window.OK) {
				QuestionsPage.this.counter++;
				// Question questionDetails = getDummyQuestion(questionDialog.getQuestionText(),questionDialog.getquestionType(),questionDialog.getAnswerValue());
				final Question questionDetails = questionDialog.getQuestionDetails();
				questionDetails.setId(qID);

				// Update the array list.
				QuestionsPage.this.compositeToHoldGranularUIElements.getListOfAllQuestions().add(questionDetails);
				QuestionsPage.this.compositeToHoldGranularUIElements.addQuestionUIElements(questionDetails, claferPageComposite.getClaferModel(), false);
				// rebuild the UI
				QuestionsPage.this.compositeToHoldGranularUIElements.updateQuestionContainer();
			}
		}
	});
}
 
源代码18 项目: pentaho-kettle   文件: BaseStepDialog.java
public static final void positionBottomButtons( Composite composite, Button[] buttons, int margin, int alignment,
                                                 Control lastControl ) {
  // Determine the largest button in the array
  Rectangle largest = null;
  for ( int i = 0; i < buttons.length; i++ ) {
    buttons[ i ].pack( true );
    Rectangle r = buttons[ i ].getBounds();
    if ( largest == null || r.width > largest.width ) {
      largest = r;
    }

    // Also, set the tooltip the same as the name if we don't have one...
    if ( buttons[ i ].getToolTipText() == null ) {
      buttons[ i ].setToolTipText( Const.replace( buttons[ i ].getText(), "&", "" ) );
    }
  }

  // Make buttons a bit larger... (nicer)
  largest.width += 10;
  if ( ( largest.width % 2 ) == 1 ) {
    largest.width++;
  }

  // Compute the left side of the 1st button
  switch ( alignment ) {
    case BUTTON_ALIGNMENT_CENTER:
      centerButtons( buttons, largest.width, margin, lastControl );
      break;
    case BUTTON_ALIGNMENT_LEFT:
      leftAlignButtons( buttons, largest.width, margin, lastControl );
      break;
    case BUTTON_ALIGNMENT_RIGHT:
      rightAlignButtons( buttons, largest.width, margin, lastControl );
      break;
    default:
      break;
  }
  if ( Const.isOSX() ) {
    Shell parentShell = composite.getShell();
    final List<TableView> tableViews = new ArrayList<TableView>();
    getTableViews( parentShell, tableViews );
    for ( final Button button : buttons ) {
      // We know the table views
      // We also know that if a button is hit, the table loses focus
      // In that case, we can apply the content of an open text editor...
      //
      button.addSelectionListener( new SelectionAdapter() {

        public void widgetSelected( SelectionEvent e ) {
          for ( TableView view : tableViews ) {
            view.applyOSXChanges();
          }
        }
      } );
    }
  }
}
 
源代码19 项目: BiglyBT   文件: ConfigSectionSecuritySWT.java
@Override
public void configSectionCreate(Composite parent, Map<ParameterImpl, BaseSwtParameter> mapParamToSwtParam) {
	shell = parent.getShell();
}
 
源代码20 项目: ice   文件: NewItemWizardPage.java
/**
 * This operation creates the view that shows the list of Items that can be
 * created by the user.
 */
@Override
public void createControl(Composite parent) {

	// Set the parent reference
	parentComposite = parent;

	// Create the composite for file selection pieces
	Composite itemSelectionComposite = new Composite(parentComposite,
			SWT.NONE);
	// Set its layout
	GridLayout layout = new GridLayout(1, true);
	itemSelectionComposite.setLayout(layout);
	// Set its layout data
	GridData data = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
	itemSelectionComposite.setLayoutData(data);

	// Get the extension registry and retrieve the client.
	IExtensionRegistry registry = Platform.getExtensionRegistry();
	IExtensionPoint point = registry
			.getExtensionPoint("org.eclipse.ice.client.clientInstance");
	IExtension[] extensions = point.getExtensions();
	// Get the configuration element. The extension point can only have one
	// extension by default, so no need for a loop or check.
	IConfigurationElement[] elements = extensions[0]
			.getConfigurationElements();
	IConfigurationElement element = elements[0];

	// Get the client
	try {
		IClient client = (IClient) element
				.createExecutableExtension("class");
		// Draw the list of Items and present the selection wizard.
		drawWizard(itemSelectionComposite, client);
	} catch (CoreException e) {
		// Otherwise throw an error
		MessageBox errorMessage = new MessageBox(parent.getShell(), ERROR);
		errorMessage.setMessage("The ICE Client is not available. "
				+ "Please file a bug report.");
		errorMessage.open();
		// Log the error
		logger.error("ICEClient Extension not found.",e);
	}

	// Set the control
	setControl(itemSelectionComposite);
	// Disable the finished condition to start
	setPageComplete(false);

	return;

}