Java Code Examples for org.eclipse.swt.custom.SashForm#setLayoutData()

The following examples show how to use org.eclipse.swt.custom.SashForm#setLayoutData() . 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: GroovyEditorDocumentationDialogTray.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected Control createContents(final Composite parent) {

    final Composite mainComposite = new Composite(parent, SWT.NONE);
    mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    mainComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).margins(0, 0).create());

    createFunctionCategories(mainComposite);

    final SashForm sashForm = new SashForm(mainComposite, SWT.VERTICAL);
    sashForm.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(250, 250).minSize(100, SWT.DEFAULT).create());
    final GridLayout gridLaout = GridLayoutFactory.fillDefaults().numColumns(1).margins(0, 2).create();
    sashForm.setLayout(gridLaout);
    createFunctionsList(sashForm);
    createFunctionDocumentaion(sashForm);

    sashForm.setWeights(new int[] { 1, 1 });

    return mainComposite;
}
 
Example 2
Source File: SQLDataSetEditorPage.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * create page control for sql edit page
 * 
 * @param parent
 * @return
 */
private Control createPageControl( Composite parent )
{
	SashForm pageContainer = new SashForm( parent, SWT.NONE );

	GridLayout layout = new GridLayout( );
	layout.numColumns = 3;
	layout.marginWidth = 0;
	layout.marginHeight = 0;
	layout.horizontalSpacing = 2;
	pageContainer.setLayout( layout );
	pageContainer.setLayoutData( new GridData( GridData.FILL_BOTH ) );

	pageContainer.setSashWidth( 3 );

	Control left = createDBMetaDataSelectionComposite( pageContainer );
	Control right = createTextualQueryComposite( pageContainer );
	setWidthHints( pageContainer, left, right );
	
	return pageContainer;
}
 
Example 3
Source File: TaskSelectType.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
protected void placeComponents( )
{
	foSashForm = new SashForm( topControl, SWT.VERTICAL );
	{
		GridLayout layout = new GridLayout( );
		foSashForm.setLayout( layout );
		GridData gridData = new GridData( GridData.FILL_BOTH );
		// TODO verify Bug 194391 in Linux
		gridData.heightHint = 680;
		foSashForm.setLayoutData( gridData );
	}
	createTopPreviewArea( foSashForm );
	createBottomTypeArea( foSashForm );
	
	initUIPropertiesAndData( );
}
 
Example 4
Source File: PullUpMethodPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void createTreeAndSourceViewer(final Composite superComposite) {
	final SashForm composite= new SashForm(superComposite, SWT.HORIZONTAL);
	initializeDialogUnits(superComposite);
	final GridData gd= new GridData(GridData.FILL_BOTH);
	gd.heightHint= convertHeightInCharsToPixels(20);
	gd.widthHint= convertWidthInCharsToPixels(10);
	composite.setLayoutData(gd);
	final GridLayout layout= new GridLayout();
	layout.numColumns= 2;
	layout.marginWidth= 0;
	layout.marginHeight= 0;
	layout.horizontalSpacing= 1;
	layout.verticalSpacing= 1;
	composite.setLayout(layout);

	createHierarchyTreeComposite(composite);
	createSourceViewerComposite(composite);
	composite.setWeights(new int[] { 50, 50});
}
 
Example 5
Source File: RenameTypeWizardSimilarElementsPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void createTreeAndSourceViewer(Composite superComposite) {
	SashForm composite= new SashForm(superComposite, SWT.HORIZONTAL);
	initializeDialogUnits(superComposite);
	GridData gd= new GridData(GridData.FILL_BOTH);
	gd.heightHint= convertHeightInCharsToPixels(20);
	gd.widthHint= convertWidthInCharsToPixels(10);
	composite.setLayoutData(gd);
	GridLayout layout= new GridLayout();
	layout.numColumns= 2;
	layout.marginWidth= 0;
	layout.marginHeight= 0;
	composite.setLayout(layout);

	createSimilarElementTreeComposite(composite);
	createSourceViewerComposite(composite);
	composite.setWeights(new int[] { 50, 50 });
}
 
Example 6
Source File: SvnWizardLockPage.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public void createControls(Composite composite) {
       SashForm sashForm = new SashForm(composite, SWT.VERTICAL);
       GridLayout gridLayout = new GridLayout();
       gridLayout.marginHeight = 0;
       gridLayout.marginWidth = 0;
       sashForm.setLayout(gridLayout);
       sashForm.setLayoutData(new GridData(GridData.FILL_BOTH));
               
       Composite cTop = new Composite(sashForm, SWT.NULL);
       GridLayout topLayout = new GridLayout();
       topLayout.marginHeight = 0;
       topLayout.marginWidth = 0;
       cTop.setLayout(topLayout);
       cTop.setLayoutData(new GridData(GridData.FILL_BOTH));
               
       Composite cBottom1 = new Composite(sashForm, SWT.NULL);
       GridLayout bottom1Layout = new GridLayout();
       bottom1Layout.marginHeight = 0;
       bottom1Layout.marginWidth = 0;
       cBottom1.setLayout(bottom1Layout);
       cBottom1.setLayoutData(new GridData(GridData.FILL_BOTH));
       
       Composite cBottom2 = new Composite(cBottom1, SWT.NULL);
       GridLayout bottom2Layout = new GridLayout();
       bottom2Layout.marginHeight = 0;
       bottom2Layout.marginWidth = 0;	        
       cBottom2.setLayout(bottom2Layout);
       cBottom2.setLayoutData(new GridData(GridData.FILL_BOTH));
	
	commitCommentArea.createArea(cTop);
       
       addResourcesArea(cBottom2);
       
       setPageComplete(canFinish());

	// set F1 help
	PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.LOCK_DIALOG);	
}
 
Example 7
Source File: ImpactNwPage.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private SashForm createSash(Composite client) {
	SashForm sash = new SashForm(client, SWT.NONE);
	GridData sashGD = new GridData(SWT.FILL, SWT.FILL, true, true);
	sashGD.widthHint = 400;
	sash.setLayoutData(sashGD);
	sash.setLayout(new GridLayout(2, false));
	return sash;
}
 
Example 8
Source File: HeaderPage.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Setup 2 column layout.
 *
 * @param managedForm the managed form
 * @param w1 the w 1
 * @param w2 the w 2
 * @return the form 2 panel
 */
public Form2Panel setup2ColumnLayout(IManagedForm managedForm, int w1, int w2) {
  final ScrolledForm sform = managedForm.getForm();
  final Composite form = sform.getBody();
  form.setLayout(new GridLayout(1, false)); // this is required !
  Composite xtra = toolkit.createComposite(form);
  xtra.setLayout(new GridLayout(1, false));
  xtra.setLayoutData(new GridData(GridData.FILL_BOTH));
  Control c = xtra.getParent();
  while (!(c instanceof ScrolledComposite))
    c = c.getParent();
  ((GridData) xtra.getLayoutData()).widthHint = c.getSize().x;
  ((GridData) xtra.getLayoutData()).heightHint = c.getSize().y;
  sashForm = new SashForm(xtra, SWT.HORIZONTAL);

  sashForm.setLayoutData(new GridData(GridData.FILL_BOTH)); // needed

  leftPanel = newComposite(sashForm);
  ((GridLayout) leftPanel.getLayout()).marginHeight = 5;
  ((GridLayout) leftPanel.getLayout()).marginWidth = 5;
  rightPanel = newComposite(sashForm);
  ((GridLayout) rightPanel.getLayout()).marginHeight = 5;
  ((GridLayout) rightPanel.getLayout()).marginWidth = 5;
  sashForm.setWeights(new int[] { w1, w2 });
  leftPanelPercent = (float) w1 / (float) (w1 + w2);
  rightPanelPercent = (float) w2 / (float) (w1 + w2);

  rightPanel.addControlListener(new ControlAdapter() {
    @Override
    public void controlResized(ControlEvent e) {
      setSashFormWidths();
    }
  });

  return new Form2Panel(form, leftPanel, rightPanel);
}
 
Example 9
Source File: ExternalizeWizardPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public void createControl(Composite parent) {
	initializeDialogUnits(parent);

	Composite supercomposite= new Composite(parent, SWT.NONE);
	supercomposite.setFont(parent.getFont());
	supercomposite.setLayout(new GridLayout());

	createIsEclipseNLSCheckbox(supercomposite);

	createKeyPrefixField(supercomposite);

	SashForm composite= new SashForm(supercomposite, SWT.VERTICAL);
	composite.setFont(supercomposite.getFont());

	GridData data= new GridData(GridData.FILL_BOTH);
	composite.setLayoutData(data);

	createTableViewer(composite);
	createSourceViewer(composite);

	createAccessorInfoComposite(supercomposite);

	composite.setWeights(new int[]{65, 45});

	validateKeys(false);
	updateButtonStates(StructuredSelection.EMPTY);

	// promote control
	setControl(supercomposite);
	Dialog.applyDialogFont(supercomposite);
	PlatformUI.getWorkbench().getHelpSystem().setHelp(supercomposite, IJavaHelpContextIds.EXTERNALIZE_WIZARD_KEYVALUE_PAGE);
}
 
Example 10
Source File: FileSetEditDialog.java    From eclipse-cs with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * @see org.eclipse.swt.widgets.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
 */
@Override
protected Control createDialogArea(Composite parent) {

  Composite composite = (Composite) super.createDialogArea(parent);
  composite.setLayoutData(new GridData(GridData.FILL_BOTH));
  Composite dialog = new Composite(composite, SWT.NONE);
  dialog.setLayout(new GridLayout(1, false));
  dialog.setLayoutData(new GridData(GridData.FILL_BOTH));

  Control commonArea = createCommonArea(dialog);
  commonArea.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

  SashForm sashForm = new SashForm(dialog, SWT.VERTICAL);
  GridData gd = new GridData(GridData.FILL_BOTH);
  gd.widthHint = 500;
  gd.heightHint = 400;
  sashForm.setLayoutData(gd);
  sashForm.setLayout(new GridLayout());

  Control patternArea = createFileMatchPatternPart(sashForm);
  patternArea.setLayoutData(new GridData(GridData.FILL_BOTH));

  Control matchArea = createTestArea(sashForm);
  matchArea.setLayoutData(new GridData(GridData.FILL_BOTH));

  sashForm.setWeights(new int[] { 50, 50 });

  // init the data
  initializeControls();

  return composite;
}
 
Example 11
Source File: SvnPropertiesView.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
 */
public void createPartControl(Composite parent) {
	GridLayout layout = new GridLayout();
	layout.marginWidth = 0;
	layout.marginHeight = 0;
	layout.numColumns = 1;
	parent.setLayout(layout);		
	statusLabel = new Label(parent,SWT.LEFT);
	GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
	gridData.grabExcessHorizontalSpace = true;
	statusLabel.setLayoutData(gridData);

	SashForm sashForm = new SashForm(parent, SWT.VERTICAL);
	sashForm.setLayoutData(new GridData(GridData.FILL_BOTH));
	tableViewer = createTable(sashForm);
	textViewer = createText(sashForm);
	sashForm.setWeights(new int[] { 70, 30 });

	contributeActions();        
       
       pageSelectionListener = new ISelectionListener() {
		public void selectionChanged(IWorkbenchPart part, ISelection selection) {
       		handlePartSelectionChanged(part,selection);
       	}
       };
       
       getSite().getPage().addPostSelectionListener(pageSelectionListener);
	resourceStateChangeListener = new ResourceStateChangeListener();
	SVNProviderPlugin.addResourceStateChangeListener(resourceStateChangeListener);
}
 
Example 12
Source File: LayeredDisplayView.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void ownCreatePartControl(final Composite c) {
	if (getOutput() == null) { return; }
	c.setLayout(emptyLayout());

	// First create the sashform

	form = new SashForm(c, SWT.HORIZONTAL);
	form.setLayoutData(fullData());
	form.setBackground(IGamaColors.WHITE.color());
	form.setSashWidth(8);
	decorator.createSidePanel(form);
	final Composite centralPanel = new Composite(form, CORE_DISPLAY_BORDER.getValue() ? SWT.BORDER : SWT.NONE);

	centralPanel.setLayout(emptyLayout());
	setParentComposite(new Composite(centralPanel, SWT.NONE) {

		@Override
		public boolean setFocus() {
			// decorator.keyAndMouseListener.focusGained(null);
			return forceFocus();
		}

	});

	getParentComposite().setLayoutData(fullData());
	getParentComposite().setLayout(emptyLayout());
	createSurfaceComposite(getParentComposite());
	surfaceComposite.setLayoutData(fullData());
	getOutput().setSynchronized(getOutput().isSynchronized() || CORE_SYNC.getValue());
	form.setMaximizedControl(centralPanel);
	decorator.createDecorations(form);
	c.layout();

}
 
Example 13
Source File: LogAnalysis.java    From AndroidRobot with Apache License 2.0 5 votes vote down vote up
public void createSashForm() {
    sashFormLog = new SashForm(shell, SWT.HORIZONTAL);
    //sashFormLog.setBounds(10, 27, 672, 529);
    FormData formData = new FormData();
    formData.left = new FormAttachment(0, 3);
    formData.right = new FormAttachment(100, -3);
    formData.top = new FormAttachment(0, 25);
    formData.bottom = new FormAttachment(100, -25);
    sashFormLog.setLayoutData(formData);

    createLogList();
    createLogDetail();
    sashFormLog.setWeights(new int[] { 1, 2 });
}
 
Example 14
Source File: CustomTxtParserOutputWizardPage.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void createControl(final Composite parent) {
    container = new Composite(parent, SWT.NULL);
    container.setLayout(new GridLayout());

    sash = new SashForm(container, SWT.VERTICAL);
    sash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    sash.setBackground(sash.getDisplay().getSystemColor(SWT.COLOR_GRAY));

    outputsScrolledComposite = new ScrolledComposite(sash, SWT.V_SCROLL);
    outputsScrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    outputsContainer = new Composite(outputsScrolledComposite, SWT.NONE);
    final GridLayout outputsLayout = new GridLayout(4, false);
    outputsLayout.marginHeight = 10;
    outputsLayout.marginWidth = 0;
    outputsContainer.setLayout(outputsLayout);
    outputsScrolledComposite.setContent(outputsContainer);
    outputsScrolledComposite.setExpandHorizontal(true);
    outputsScrolledComposite.setExpandVertical(true);

    outputsContainer.layout();

    outputsScrolledComposite.setMinSize(outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y-5);

    tableContainer = new Composite(sash, SWT.NONE);
    final GridLayout tableLayout = new GridLayout();
    tableLayout.marginHeight = 0;
    tableLayout.marginWidth = 0;
    tableContainer.setLayout(tableLayout);
    previewTable = new TmfEventsTable(tableContainer, 0, CustomEventAspects.generateAspects(new CustomTxtTraceDefinition()));
    previewTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    if (wizard.definition != null) {
        loadDefinition(wizard.definition);
    }
    setControl(container);

}
 
Example 15
Source File: CustomXmlParserOutputWizardPage.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void createControl(final Composite parent) {
    container = new Composite(parent, SWT.NULL);
    container.setLayout(new GridLayout());

    sash = new SashForm(container, SWT.VERTICAL);
    sash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    sash.setBackground(sash.getDisplay().getSystemColor(SWT.COLOR_GRAY));

    outputsScrolledComposite = new ScrolledComposite(sash, SWT.V_SCROLL);
    outputsScrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    outputsContainer = new Composite(outputsScrolledComposite, SWT.NONE);
    final GridLayout outputsLayout = new GridLayout(4, false);
    outputsLayout.marginHeight = 10;
    outputsLayout.marginWidth = 0;
    outputsContainer.setLayout(outputsLayout);
    outputsScrolledComposite.setContent(outputsContainer);
    outputsScrolledComposite.setExpandHorizontal(true);
    outputsScrolledComposite.setExpandVertical(true);

    outputsContainer.layout();

    outputsScrolledComposite.setMinSize(outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y-5);

    tableContainer = new Composite(sash, SWT.NONE);
    final GridLayout tableLayout = new GridLayout();
    tableLayout.marginHeight = 0;
    tableLayout.marginWidth = 0;
    tableContainer.setLayout(tableLayout);
    previewTable = new TmfEventsTable(tableContainer, 0, CustomEventAspects.generateAspects(new CustomXmlTraceDefinition()));
    previewTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    if (wizard.definition != null) {
        loadDefinition(wizard.definition);
    }
    setControl(container);

}
 
Example 16
Source File: CodeRecommendationView.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Create contents of the view part.
 * 
 * @param parent
 */
@Override
public void createPartControl(Composite parent) {
	super.createPartControl(parent);

	Composite container = new Composite(parent, SWT.NONE);
	container.setBackgroundMode(SWT.INHERIT_FORCE);
	container.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
	container.setLayout(new GridLayout(1, false));
	{
		SashForm sashForm = new SashForm(container, SWT.NONE);
		sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
		{
			resultsComposite = new Composite(sashForm, SWT.NONE);
			resultsComposite.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
			resultsComposite.setLayout(new FillLayout(SWT.HORIZONTAL));
			{
				Label lblInitiateACode = new Label(resultsComposite, SWT.NONE);
				lblInitiateACode.setText("Initiate a code recommendation request first, to see the results here");
			}
		}
		{
			previewComposite = new Composite(sashForm, SWT.NONE);
			StackLayout layout = new StackLayout();
			previewComposite.setLayout(layout);
			lblSelectAPattern = new Label(previewComposite, SWT.CENTER);
			lblSelectAPattern.setEnabled(false);
			lblSelectAPattern.setText("Select a pattern to open in preview");
			layout.topControl = lblSelectAPattern;
		}
		sashForm.setWeights(new int[] { 1, 1 });
	}

	createActions();
	initializeToolBar();
	initializeMenu();
}
 
Example 17
Source File: JobHistoryDelegate.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
public JobHistoryLogTab( CTabFolder tabFolder, LogTableInterface logTable ) {
  super( tabFolder, SWT.NONE );
  setLogTable( logTable );

  setText( logTable.getLogTableType() );

  Composite logTableComposite = new Composite( tabFolder, SWT.NONE );
  logTableComposite.setLayout( new FormLayout() );
  spoon.props.setLook( logTableComposite );

  setControl( logTableComposite );

  SashForm sash = new SashForm( logTableComposite, SWT.VERTICAL );
  sash.setLayout( new FillLayout() );
  FormData fdSash = new FormData();
  fdSash.left = new FormAttachment( 0, 0 ); // First one in the left top corner
  fdSash.top = new FormAttachment( 0, 0 );
  fdSash.right = new FormAttachment( 100, 0 );
  fdSash.bottom = new FormAttachment( 100, 0 );
  sash.setLayoutData( fdSash );

  logDisplayTableView = createJobLogTableView( sash );

  if ( logTable.getLogField() != null ) {
    logDisplayText = new Text( sash, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.READ_ONLY );
    spoon.props.setLook( logDisplayText );
    logDisplayText.setVisible( true );

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

    sash.setWeights( new int[] { 70, 30, } );
  } else {
    logDisplayText = null;
    sash.setWeights( new int[] { 100, } );
  }
}
 
Example 18
Source File: TLAFilteredItemsSelectionDialog.java    From tlaplus with MIT License 4 votes vote down vote up
protected Composite createContentComposite(final Composite parent) {
	sashForm = new SashForm(parent, SWT.VERTICAL);
	sashForm.setLayoutData(new GridData(GridData.FILL_BOTH));
	return sashForm;
}
 
Example 19
Source File: NewProjectWizardTemplateSelectionPage.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void createControl(Composite parent) {
	Composite main = new Composite(parent, SWT.NONE);
	main.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
	main.setLayout(new GridLayout(1, false));

	Label availableTemplatesLabel = new Label(main, SWT.NONE);
	availableTemplatesLabel.setText(Messages.NewProjectWizardTemplateSelectionPage_available_templates);
	availableTemplatesLabel.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, true, false));

	SashForm sash = new SashForm(main, SWT.HORIZONTAL);
	GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
	data.widthHint = 400;
	sash.setLayoutData(data);

	TableViewer templateTable = new TableViewer(sash, SWT.BORDER);
	templateTable.setContentProvider(new ArrayContentProvider());
	templateTable.setLabelProvider(labelProvider);
	AbstractProjectTemplate[] templates = loadTemplatesFromExtensionPoint();
	templateTable.setInput(templates);

	FormText text = new FormText(sash, SWT.BORDER);
	text.setText("", false, false); //$NON-NLS-1$
	text.setBackground(templateTable.getTable().getBackground());

	// register images
	for (AbstractProjectTemplate template : templates) {
		for (Pair<String, Image> image : template.getImages()) {
			text.setImage(image.getKey(), image.getValue());
		}
	}

	templateTable.addSelectionChangedListener(new ISelectionChangedListener() {
		@Override
		public void selectionChanged(SelectionChangedEvent event) {
			ISelection selection = event.getSelection();
			if (selection instanceof IStructuredSelection) {
				IStructuredSelection structuredSelection = (IStructuredSelection) selection;
				Object element = structuredSelection.getFirstElement();
				if (element instanceof AbstractProjectTemplate) {
					selectedTemplate = (AbstractProjectTemplate) element;
					setPageComplete(true);
					String content = "<form>" + selectedTemplate.getDescription() + "</form>"; //$NON-NLS-1$ //$NON-NLS-2$
					try {
						text.setText(content, true, true);
					} catch (Exception e) {
						text.setText(e.getMessage(), false, false);
					}
				} else {
					selectedTemplate = null;
					text.setText("", false, false); //$NON-NLS-1$
					setPageComplete(false);
				}
			} else {
				selectedTemplate = null;
				text.setText("", false, false); //$NON-NLS-1$
				setPageComplete(false);
			}
		}
	});

	templateTable.setSelection(new StructuredSelection(templateTable.getElementAt(0)));

	setControl(main);
}
 
Example 20
Source File: MakrosComposite.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Create the composite.
 * 
 * @param parent
 * @param style
 */
public MakrosComposite(Composite parent, int style){
	super(parent, style);
	setLayout(new GridLayout(1, false));
	
	CLabel lblHeader = new CLabel(this, SWT.NONE);
	lblHeader.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
	lblHeader.setText("Makros des Anwender " + CoreHub.getLoggedInContact().getLabel());

	
	SashForm sash = new SashForm(this, SWT.HORIZONTAL);
	sash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
	
	Composite selectionComposite = new Composite(sash, SWT.NONE);
	selectionComposite.setLayout(new GridLayout(1, true));
	ToolBarManager toolbar = new ToolBarManager();
	ToolBar toolbarControl = toolbar.createControl(selectionComposite);
	toolbarControl.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false));
	
	viewer = new TableViewer(selectionComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
	viewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
	viewer.setContentProvider(new ArrayContentProvider());
	viewer.setLabelProvider(new DefaultLabelProvider());
	viewer.setInput(getUserMakros(CoreHub.getLoggedInContact()));
	viewer.addSelectionChangedListener(new ISelectionChangedListener() {
		@Override
		public void selectionChanged(SelectionChangedEvent event){
			StructuredSelection selection = (StructuredSelection) viewer.getSelection();
			if (selection != null && !selection.isEmpty()) {
				detailComposite.setMakro((MakroDTO) selection.getFirstElement());
			} else {
				detailComposite.setMakro(null);
			}
		}
	});
	viewer.setComparator(new ViewerComparator());
	
	MenuManager menuManager = new MenuManager();
	menuManager.add(new RemoveMakroAction(viewer));
	MenuManager subMenu = new MenuManager("Marko zu Anwender kopieren");
	subMenu.setRemoveAllWhenShown(true);
	subMenu.addMenuListener(new IMenuListener() {
		@Override
		public void menuAboutToShow(IMenuManager manager){
			addCopyToUserActions(manager);
		}
	});
	menuManager.add(subMenu);
	
	Menu menu = menuManager.createContextMenu(viewer.getTable());
	viewer.getTable().setMenu(menu);
	
	toolbar.add(new AddMakroAction(viewer));
	toolbar.add(new RemoveMakroAction(viewer));
	toolbar.add(new RefreshMakrosAction(viewer));
	toolbar.update(true);
	
	detailComposite = new MakroDetailComposite(sash, SWT.NONE);
	
	// can only be set after child components are available
	sash.setWeights(new int[] {
		1, 4
	});
}