Java Code Examples for org.eclipse.swt.widgets.Composite#getParent()

The following examples show how to use org.eclipse.swt.widgets.Composite#getParent() . 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: HopGuiPipelineGraph.java    From hop with Apache License 2.0 6 votes vote down vote up
public Point getRealPosition( Composite canvas, int x, int y ) {
  Point p = new Point( 0, 0 );
  Composite follow = canvas;
  while ( follow != null ) {
    org.eclipse.swt.graphics.Point loc = follow.getLocation();
    Point xy = new Point( loc.x, loc.y );
    p.x += xy.x;
    p.y += xy.y;
    follow = follow.getParent();
  }

  int offsetX = -16;
  int offsetY = -64;
  if ( Const.isOSX() ) {
    offsetX = -2;
    offsetY = -24;
  }
  p.x = x - p.x + offsetX;
  p.y = y - p.y + offsetY;

  return screen2real( p.x, p.y );
}
 
Example 2
Source File: PipelineArgumentsTab.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
@VisibleForTesting
void handleLayoutChange() {
  if (internalComposite != null && !internalComposite.isDisposed()) {
    Composite parent = internalComposite.getParent();
    while (parent != null) {
      if (parent instanceof ScrolledComposite) {
        ((ScrolledComposite) parent)
            .setMinSize(internalComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
        parent.layout();
        return;
      }
      parent = parent.getParent();
    }
  }
  updateLaunchConfigurationDialog();
}
 
Example 3
Source File: HopGuiWorkflowGraph.java    From hop with Apache License 2.0 5 votes vote down vote up
public Point getRealPosition( Composite canvas, int x, int y ) {
  Point p = new Point( 0, 0 );
  Composite follow = canvas;
  while ( follow != null ) {
    Point xy = new Point( follow.getLocation().x, follow.getLocation().y );
    p.x += xy.x;
    p.y += xy.y;
    follow = follow.getParent();
  }

  p.x = x - p.x - 8;
  p.y = y - p.y - 48;

  return screen2real( p.x, p.y );
}
 
Example 4
Source File: ExtensibleGridPropertySection.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public static Control getLabelCompositeOf(final Composite composite) {
Control[] children = null;
if (composite.getParent() != null) {
    children = composite.getParent().getChildren();
    for (int i = 1; i < children.length; i++) {
	if (children[i].equals(composite)) {
	    return children[i - 1];
	}
    }
}
return null;
   }
 
Example 5
Source File: Composite3DModifier.java    From ldparteditor with MIT License 5 votes vote down vote up
/**
 * Spins the {@link SashForm} content clockwise
 */
public void spinView() {
    NLogger.debug(Composite3DModifier.class, "[Spin view]"); //$NON-NLS-1$
    // Spin only, if it is not the last opened view
    if (isSashFormChild(c3d.getSashForm())) {
        int newStyle = SWT.NONE;
        if ((c3d.getSashForm().getStyle() & SWT.HORIZONTAL) != 0) {
            newStyle = SWT.VERTICAL;
        } else {
            newStyle = SWT.HORIZONTAL;
        }
        int[] sashWeights = c3d.getSashForm().getWeights();
        int[] mainSashWeights = Editor3DWindow.getSashForm().getWeights();
        int[] superSashWeights = ((SashForm) c3d.getSashForm().getParent()).getWeights();
        Composite oldParentSashForm = c3d.getSashForm();
        Composite oldGrandpaSashForm = oldParentSashForm.getParent();
        boolean isUpperComposite = oldParentSashForm.getChildren()[0].equals(c3d.getCompositeContainer());

        if (isUpperComposite) {
            if (newStyle == SWT.HORIZONTAL) {
                reverseChilds(c3d.getSashForm());
            }
        } else {
            if (newStyle == SWT.HORIZONTAL) {
                reverseChilds(c3d.getSashForm());
            }
        }

        oldParentSashForm.setOrientation(newStyle);
        oldGrandpaSashForm.layout();
        ((SashForm) oldParentSashForm).setWeights(sashWeights);
        ((SashForm) oldGrandpaSashForm).setWeights(superSashWeights);
        Editor3DWindow.getSashForm().setWeights(mainSashWeights);
    }
}
 
Example 6
Source File: WSO2UIToolkit.java    From developer-studio with Apache License 2.0 5 votes vote down vote up
public static void layout(final Composite container) {
	Composite parentLayout = container;
	while (parentLayout != null) {
		parentLayout.layout();
		parentLayout = parentLayout.getParent();
	}
}
 
Example 7
Source File: ImageSection.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
void update() {
	for (Control c : controls) {
		c.dispose();
	}
	controls.clear();
	ProcessDocumentation doc = editor.getModel().documentation;
	if (doc == null)
		return;

	List<File> files = new ArrayList<>();
	for (Source s : doc.sources) {
		if (!isImage(s.externalFile))
			continue;
		File dir = new FileStore(
				Database.get()).getFolder(s);
		File file = new File(dir, s.externalFile);
		if (!file.exists())
			continue;
		files.add(file);
	}
	if (files.isEmpty())
		return;

	if (comp == null) {
		comp = UI.formSection(body, tk, "Attached images");
	}
	files.forEach(this::createControls);

	comp.pack();
	Composite container = comp;
	while (container != null) {
		container = container.getParent();
		if (container instanceof ScrolledForm) {
			((ScrolledForm) container).reflow(true);
			break;
		}
	}
}
 
Example 8
Source File: ConcordanceSearchDialog.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
protected void createButtonsForButtonBar(Composite parent) {
	// getShell().setDefaultButton(btnSearch);
	Composite content = parent.getParent();
	// parent.dispose();
	content.layout();
}
 
Example 9
Source File: TableCombo.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Handles Popup Events
 * @param event
 */
private void popupEvent(Event event) {
	switch (event.type) {
	case SWT.Paint:
		// draw rectangle around table
		Rectangle tableRect = table.getBounds();
		event.gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION));
		event.gc.drawRectangle(0, 0, tableRect.width + 1, tableRect.height + 1);
		break;
	case SWT.Close:
		event.doit = false;
		dropDown(false);
		break;
	case SWT.Deactivate:
		/*
		 * Bug in GTK. When the arrow button is pressed the popup control receives a deactivate event and then the
		 * arrow button receives a selection event. If we hide the popup in the deactivate event, the selection
		 * event will show it again. To prevent the popup from showing again, we will let the selection event of the
		 * arrow button hide the popup. In Windows, hiding the popup during the deactivate causes the deactivate to
		 * be called twice and the selection event to be disappear.
		 */
		if (!"carbon".equals(SWT.getPlatform())) {
			Point point = arrow.toControl(getDisplay().getCursorLocation());
			Point size = arrow.getSize();
			Rectangle rect = new Rectangle(0, 0, size.x, size.y);
			if (!rect.contains(point))
				dropDown(false);
		} else {
			dropDown(false);
		}
		break;

	case SWT.Help:
		if (isDropped()) {
			dropDown(false);
		}
		Composite comp = TableCombo.this;
		do {
			if (comp.getListeners(event.type) != null && comp.getListeners(event.type).length > 0) {
				comp.notifyListeners(event.type, event);
				break;
			}
			comp = comp.getParent();
		} while (null != comp);
		break;
	}
}
 
Example 10
Source File: TBXMakerDialog.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void createButtonsForButtonBar(Composite parent) {
	Composite cmpTemp = parent.getParent();
	parent.dispose();
	cmpTemp.layout();
}
 
Example 11
Source File: TableCombo.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Handles Popup Events
 * @param event
 */
private void popupEvent(Event event) {
	switch (event.type) {
	case SWT.Paint:
		// draw rectangle around table
		Rectangle tableRect = table.getBounds();
		event.gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION));
		event.gc.drawRectangle(0, 0, tableRect.width + 1, tableRect.height + 1);
		break;
	case SWT.Close:
		event.doit = false;
		dropDown(false);
		break;
	case SWT.Deactivate:
		/*
		 * Bug in GTK. When the arrow button is pressed the popup control receives a deactivate event and then the
		 * arrow button receives a selection event. If we hide the popup in the deactivate event, the selection
		 * event will show it again. To prevent the popup from showing again, we will let the selection event of the
		 * arrow button hide the popup. In Windows, hiding the popup during the deactivate causes the deactivate to
		 * be called twice and the selection event to be disappear.
		 */
		if (!"carbon".equals(SWT.getPlatform())) {
			Point point = arrow.toControl(getDisplay().getCursorLocation());
			Point size = arrow.getSize();
			Rectangle rect = new Rectangle(0, 0, size.x, size.y);
			if (!rect.contains(point))
				dropDown(false);
		} else {
			dropDown(false);
		}
		break;

	case SWT.Help:
		if (isDropped()) {
			dropDown(false);
		}
		Composite comp = TableCombo.this;
		do {
			if (comp.getListeners(event.type) != null && comp.getListeners(event.type).length > 0) {
				comp.notifyListeners(event.type, event);
				break;
			}
			comp = comp.getParent();
		} while (null != comp);
		break;
	}
}
 
Example 12
Source File: SWTStrategyPanelHelper.java    From atdl4j with MIT License 4 votes vote down vote up
public static void relayoutExpandBar(ExpandBar expandBar, boolean relayoutParents)
{
	Composite c = expandBar;
	int tempMaxControlX = 0;
	
	logger.debug( "----- relayoutExpandBar (relayoutParents: " + relayoutParents + " expandBar: " + expandBar + " -----" );
	
	do
	{
		logger.debug( "c: " + c.getClass() + " c.getParent(): " + c.getParent().getClass() );
		
		if ( c instanceof ExpandBar )
		{
			ExpandBar eb = (ExpandBar) c;
			
			logger.debug( "ExpandBar.getSize(): " + eb.getSize() );
			
			for ( ExpandItem expandItem : eb.getItems() )
			{
				logger.debug( "expandItem: " + expandItem + " text: " + expandItem.getText() + " control: " + expandItem.getControl() + " controlLocation: " + expandItem.getControl().getLocation());					
				logger.debug( "before pack(): expandItem.getControl().getSize(): " + expandItem.getControl().getSize() );

				expandItem.getControl().pack();
				
				if ( expandItem.getControl().getSize().x > tempMaxControlX )
				{
					tempMaxControlX = expandItem.getControl().getSize().x;
				}

				logger.debug( "before: expandItem.getHeight(): " + expandItem.getHeight() + " expandItem.getControl().getSize(): " + expandItem.getControl().getSize() );

				expandItem.setHeight( expandItem.getControl().computeSize( eb.getSize().x, SWT.DEFAULT, true ).y );
			}

			// -- Need to set ExpandBar's GridData.widthHint to the width of the widest control within it -- 
			GridData tempGridData2 = (GridData) expandBar.getLayoutData();
			tempGridData2.widthHint = tempMaxControlX;
			// do not set height as ExpandBar handles this tempGridData2.heightHint = expandBar.getSize().y;
			expandBar.setLayoutData( tempGridData2 );
			
				
			if ( relayoutParents )
			{
				Control p = c.getParent();
				
				if ( p instanceof ScrolledComposite )
				{
					ScrolledComposite scrolledComposite = (ScrolledComposite) p;
					if ( scrolledComposite.getExpandHorizontal() || scrolledComposite.getExpandVertical() )
					{
						scrolledComposite.setMinSize( scrolledComposite.getContent().computeSize( SWT.DEFAULT, SWT.DEFAULT, true ) );
					}
					else
					{
						scrolledComposite.getContent().pack( true );
					}
				}

				if ( p instanceof Composite )
				{
					Composite composite = (Composite) p;
					composite.layout();
				}
			}
			else
			{
				// -- this (or relayoutParents=true) is needed (otherwise ExampleStrategyPanelTests2.xml with 2 "columns" of StrategyPanels may not draw all of the ExpandBars initially) --
				expandBar.getParent().layout();
			}

		}
		c = c.getParent();
	}
	while ( c != null && c.getParent() != null && !( c instanceof ScrolledComposite ) );


	// -- Needed to ensure that strategy panel is expanded vertically as panels go from collapsed to expanded
	expandBar.getShell().layout();
	expandBar.getShell().pack();
}
 
Example 13
Source File: RTFCleanerDialog.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void createButtonsForButtonBar(Composite parent) {
	Composite cmp = parent.getParent();
	parent.dispose();
	cmp.layout();
}
 
Example 14
Source File: UpdateNoteDialog.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void createButtonsForButtonBar(Composite parent) {
	Composite cmp = parent.getParent();
	parent.dispose();
	cmp.layout();
}
 
Example 15
Source File: PluginHelpDialog.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void createButtonsForButtonBar(Composite parent) {
	Composite cmp = parent.getParent();
	parent.dispose();
	cmp.layout();
}
 
Example 16
Source File: AboutDialog.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void createButtonsForButtonBar(Composite parent) {
	Composite cmp = parent.getParent();
	parent.dispose();
	cmp.layout();
}
 
Example 17
Source File: PluginHelpDialog.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void createButtonsForButtonBar(Composite parent) {
	Composite cmp = parent.getParent();
	parent.dispose();
	cmp.layout();
}
 
Example 18
Source File: TermBaseSearchDialog.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
protected void createButtonsForButtonBar(Composite parent) {
	getShell().setDefaultButton(btnSearch);
	Composite content = parent.getParent();
	// parent.dispose();
	content.layout();
}
 
Example 19
Source File: CSV2TMXConverterDialog.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void createButtonsForButtonBar(Composite parent) {
	Composite cmpTemp = parent.getParent();
	parent.dispose();
	cmpTemp.layout();
}
 
Example 20
Source File: AboutDialog.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void createButtonsForButtonBar(Composite parent) {
	Composite cmp = parent.getParent();
	parent.dispose();
	cmp.layout();
}