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

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

源代码1 项目: hop   文件: HopGuiPipelineGraph.java
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 );
}
 
@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();
}
 
源代码3 项目: hop   文件: HopGuiWorkflowGraph.java
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 );
}
 
源代码4 项目: olca-app   文件: ImageSection.java
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;
		}
	}
}
 
源代码5 项目: developer-studio   文件: WSO2UIToolkit.java
public static void layout(final Composite container) {
	Composite parentLayout = container;
	while (parentLayout != null) {
		parentLayout.layout();
		parentLayout = parentLayout.getParent();
	}
}
 
源代码6 项目: ldparteditor   文件: Composite3DModifier.java
/**
 * 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);
    }
}
 
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;
   }
 
源代码8 项目: tmxeditor8   文件: TableCombo.java
/**
 * 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;
	}
}
 
源代码9 项目: translationstudio8   文件: TableCombo.java
/**
 * 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;
	}
}
 
protected void createButtonsForButtonBar(Composite parent) {
	// getShell().setDefaultButton(btnSearch);
	Composite content = parent.getParent();
	// parent.dispose();
	content.layout();
}
 
源代码11 项目: tmxeditor8   文件: TBXMakerDialog.java
@Override
protected void createButtonsForButtonBar(Composite parent) {
	Composite cmpTemp = parent.getParent();
	parent.dispose();
	cmpTemp.layout();
}
 
源代码12 项目: atdl4j   文件: SWTStrategyPanelHelper.java
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();
}
 
源代码13 项目: tmxeditor8   文件: RTFCleanerDialog.java
@Override
protected void createButtonsForButtonBar(Composite parent) {
	Composite cmp = parent.getParent();
	parent.dispose();
	cmp.layout();
}
 
源代码14 项目: tmxeditor8   文件: UpdateNoteDialog.java
@Override
protected void createButtonsForButtonBar(Composite parent) {
	Composite cmp = parent.getParent();
	parent.dispose();
	cmp.layout();
}
 
源代码15 项目: tmxeditor8   文件: PluginHelpDialog.java
@Override
protected void createButtonsForButtonBar(Composite parent) {
	Composite cmp = parent.getParent();
	parent.dispose();
	cmp.layout();
}
 
源代码16 项目: translationstudio8   文件: AboutDialog.java
@Override
protected void createButtonsForButtonBar(Composite parent) {
	Composite cmp = parent.getParent();
	parent.dispose();
	cmp.layout();
}
 
源代码17 项目: tmxeditor8   文件: PluginHelpDialog.java
@Override
protected void createButtonsForButtonBar(Composite parent) {
	Composite cmp = parent.getParent();
	parent.dispose();
	cmp.layout();
}
 
源代码18 项目: tmxeditor8   文件: TermBaseSearchDialog.java
protected void createButtonsForButtonBar(Composite parent) {
	getShell().setDefaultButton(btnSearch);
	Composite content = parent.getParent();
	// parent.dispose();
	content.layout();
}
 
源代码19 项目: tmxeditor8   文件: CSV2TMXConverterDialog.java
@Override
protected void createButtonsForButtonBar(Composite parent) {
	Composite cmpTemp = parent.getParent();
	parent.dispose();
	cmpTemp.layout();
}
 
源代码20 项目: tmxeditor8   文件: AboutDialog.java
@Override
protected void createButtonsForButtonBar(Composite parent) {
	Composite cmp = parent.getParent();
	parent.dispose();
	cmp.layout();
}