/** Creates content Composite. */ Composite eswtConstructContent(int style) { Composite comp = super.eswtConstructContent(SWT.VERTICAL); FormLayout layout = new FormLayout(); layout.marginBottom = Style.pixelMetric(Style.QSTYLE_PM_LAYOUTBOTTOMMARGIN); layout.marginTop = Style.pixelMetric(Style.QSTYLE_PM_LAYOUTTOPMARGIN); layout.marginLeft = Style.pixelMetric(Style.QSTYLE_PM_LAYOUTLEFTMARGIN); layout.marginRight = Style.pixelMetric(Style.QSTYLE_PM_LAYOUTRIGHTMARGIN); layout.spacing = Style.pixelMetric(Style.QSTYLE_PM_LAYOUTVERTICALSPACING); comp.setLayout(layout); eswtScrolledText = new ScrolledTextComposite(comp, comp.getVerticalBar()); eswtImgLabel = new LabelExtension(comp, SWT.NONE); FormData imageLD = new FormData(); imageLD.right = new FormAttachment(100); imageLD.top = new FormAttachment(0); eswtImgLabel.setLayoutData(imageLD); FormData scrolledTextLD = new FormData(); scrolledTextLD.left = new FormAttachment(0); scrolledTextLD.top = new FormAttachment(0); scrolledTextLD.right = new FormAttachment(eswtImgLabel); eswtScrolledText.setLayoutData(scrolledTextLD); eswtProgbarLD = new FormData(); eswtProgbarLD.left = new FormAttachment(0); eswtProgbarLD.right = new FormAttachment(100); eswtProgbarLD.bottom = new FormAttachment(100); eswtUpdateProgressbar(comp, false, false); return comp; }
@Override public Control contribute(Composite parent) { Composite result = new Composite(parent, SWT.INHERIT_DEFAULT); result.setLayout(new FormLayout()); Label separator = new Label(result, SWT.NONE); separator.setData(WidgetUtil.CUSTOM_VARIANT, "footer_separator"); FormData separatorData = new FormData(); separator.setLayoutData(separatorData); separatorData.top = new FormAttachment(0, 0); separatorData.left = new FormAttachment(0, 0); separatorData.right = new FormAttachment(100, 0); separatorData.height = SEPARATOR_HEIGHT; Label versionInfo = new Label(result, SWT.NONE); versionInfo.setText(getVersionInfo()); versionInfo.pack(); FormData versionInfoData = new FormData(); versionInfo.setLayoutData(versionInfoData); Point size = versionInfo.getSize(); versionInfoData.top = new FormAttachment(50, -(size.y / 2) + (SEPARATOR_HEIGHT / 2)); versionInfoData.left = new FormAttachment(50, -(size.x / 2)); return result; }
public Composite createSashForm(final Composite composite) { if (!tv.isTabViewsEnabled()) { tableComposite = tv.createMainPanel(composite); return tableComposite; } ConfigurationManager configMan = ConfigurationManager.getInstance(); int iNumViews = 0; UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT(); UISWTViewEventListenerWrapper[] pluginViews = null; if (uiFunctions != null) { UISWTInstance pluginUI = uiFunctions.getUISWTInstance(); if (pluginUI != null) { pluginViews = pluginUI.getViewListeners(tv.getTableID()); iNumViews += pluginViews.length; } } if (iNumViews == 0) { tableComposite = tv.createMainPanel(composite); return tableComposite; } FormData formData; final Composite form = new Composite(composite, SWT.NONE); FormLayout flayout = new FormLayout(); flayout.marginHeight = 0; flayout.marginWidth = 0; form.setLayout(flayout); GridData gridData; gridData = new GridData(GridData.FILL_BOTH); form.setLayoutData(gridData); // Create them in reverse order, so we can have the table auto-grow, and // set the tabFolder's height manually final int TABHEIGHT = 20; tabFolder = new CTabFolder(form, SWT.TOP | SWT.BORDER); tabFolder.setMinimizeVisible(true); tabFolder.setTabHeight(TABHEIGHT); final int iFolderHeightAdj = tabFolder.computeSize(SWT.DEFAULT, 0).y; final Sash sash = new Sash(form, SWT.HORIZONTAL); tableComposite = tv.createMainPanel(form); Composite cFixLayout = tableComposite; while (cFixLayout != null && cFixLayout.getParent() != form) { cFixLayout = cFixLayout.getParent(); } if (cFixLayout == null) { cFixLayout = tableComposite; } GridLayout layout = new GridLayout(); layout.numColumns = 1; layout.horizontalSpacing = 0; layout.verticalSpacing = 0; layout.marginHeight = 0; layout.marginWidth = 0; cFixLayout.setLayout(layout); // FormData for Folder formData = new FormData(); formData.left = new FormAttachment(0, 0); formData.right = new FormAttachment(100, 0); formData.bottom = new FormAttachment(100, 0); int iSplitAt = configMan.getIntParameter(tv.getPropertiesPrefix() + ".SplitAt", 3000); // Was stored at whole if (iSplitAt < 100) { iSplitAt *= 100; } double pct = iSplitAt / 10000.0; if (pct < 0.03) { pct = 0.03; } else if (pct > 0.97) { pct = 0.97; } // height will be set on first resize call sash.setData("PCT", new Double(pct)); tabFolder.setLayoutData(formData); final FormData tabFolderData = formData; // FormData for Sash formData = new FormData(); formData.left = new FormAttachment(0, 0); formData.right = new FormAttachment(100, 0); formData.bottom = new FormAttachment(tabFolder); formData.height = 5; sash.setLayoutData(formData); // FormData for table Composite formData = new FormData(); formData.left = new FormAttachment(0, 0); formData.right = new FormAttachment(100, 0); formData.top = new FormAttachment(0, 0); formData.bottom = new FormAttachment(sash); cFixLayout.setLayoutData(formData); // Listeners to size the folder sash.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { final boolean FASTDRAG = true; if (FASTDRAG && e.detail == SWT.DRAG) { return; } if (tabFolder.getMinimized()) { tabFolder.setMinimized(false); refreshSelectedSubView(); ConfigurationManager configMan = ConfigurationManager.getInstance(); configMan.setParameter(tv.getPropertiesPrefix() + ".subViews.minimized", false); } Rectangle area = form.getClientArea(); tabFolderData.height = area.height - e.y - e.height - iFolderHeightAdj; form.layout(); Double l = new Double((double) tabFolder.getBounds().height / form.getBounds().height); sash.setData("PCT", l); if (e.detail != SWT.DRAG) { ConfigurationManager configMan = ConfigurationManager.getInstance(); configMan.setParameter( tv.getPropertiesPrefix() + ".SplitAt", (int) (l.doubleValue() * 10000)); } } }); final CTabFolder2Adapter folderListener = new CTabFolder2Adapter() { public void minimize(CTabFolderEvent event) { tabFolder.setMinimized(true); tabFolderData.height = iFolderHeightAdj; CTabItem[] items = tabFolder.getItems(); for (int i = 0; i < items.length; i++) { CTabItem tabItem = items[i]; tabItem.getControl().setVisible(false); } form.layout(); UISWTViewCore view = getActiveSubView(); if (view != null) { view.triggerEvent(UISWTViewEvent.TYPE_FOCUSLOST, null); } ConfigurationManager configMan = ConfigurationManager.getInstance(); configMan.setParameter(tv.getPropertiesPrefix() + ".subViews.minimized", true); } public void restore(CTabFolderEvent event) { tabFolder.setMinimized(false); CTabItem selection = tabFolder.getSelection(); if (selection != null) { selection.getControl().setVisible(true); } form.notifyListeners(SWT.Resize, null); UISWTViewCore view = getActiveSubView(); if (view != null) { view.triggerEvent(UISWTViewEvent.TYPE_FOCUSGAINED, null); } refreshSelectedSubView(); ConfigurationManager configMan = ConfigurationManager.getInstance(); configMan.setParameter(tv.getPropertiesPrefix() + ".subViews.minimized", false); } }; tabFolder.addCTabFolder2Listener(folderListener); tabFolder.addSelectionListener( new SelectionListener() { public void widgetSelected(SelectionEvent e) { // make sure its above try { ((CTabItem) e.item).getControl().setVisible(true); ((CTabItem) e.item).getControl().moveAbove(null); // TODO: Need to viewDeactivated old one UISWTViewCore view = getActiveSubView(); if (view != null) { view.triggerEvent(UISWTViewEvent.TYPE_FOCUSGAINED, null); } } catch (Exception t) { } } public void widgetDefaultSelected(SelectionEvent e) {} }); tabFolder.addMouseListener( new MouseAdapter() { public void mouseDown(MouseEvent e) { if (tabFolder.getMinimized()) { folderListener.restore(null); // If the user clicked down on the restore button, and we restore // before the CTabFolder does, CTabFolder will minimize us again // There's no way that I know of to determine if the mouse is // on that button! // one of these will tell tabFolder to cancel e.button = 0; tabFolder.notifyListeners(SWT.MouseExit, null); } } }); form.addListener( SWT.Resize, new Listener() { public void handleEvent(Event e) { if (tabFolder.getMinimized()) { return; } Double l = (Double) sash.getData("PCT"); if (l != null) { tabFolderData.height = (int) (form.getBounds().height * l.doubleValue()) - iFolderHeightAdj; form.layout(); } } }); // Call plugin listeners if (pluginViews != null) { for (UISWTViewEventListenerWrapper l : pluginViews) { if (l != null) { try { UISWTViewImpl view = new UISWTViewImpl(tv.getTableID(), l.getViewID(), l, null); addTabView(view); } catch (Exception e) { // skip, plugin probably specifically asked to not be added } } } } if (configMan.getBooleanParameter(tv.getPropertiesPrefix() + ".subViews.minimized", false)) { tabFolder.setMinimized(true); tabFolderData.height = iFolderHeightAdj; } else { tabFolder.setMinimized(false); } tabFolder.setSelection(0); return form; }
public Object skinObjectInitialShow(SWTSkinObject skinObject, Object params) { skin = skinObject.getSkin(); SWTSkinProperties properties = skin.getSkinProperties(); colorFileDragBorder = properties.getColor("color.buddy.filedrag.bg.border"); colorFileDragBG = properties.getColor("color.buddy.filedrag.bg"); soNoBuddies = skin.getSkinObject("buddies-viewer-nobuddies-panel"); SWTSkinObject viewer = skin.getSkinObject(SkinConstants.VIEWID_BUDDIES_VIEWER); if (null != viewer) { parent = (Composite) skinObject.getControl(); parent.setBackgroundMode(SWT.INHERIT_FORCE); scrollable = new ScrolledComposite(parent, SWT.V_SCROLL); scrollable.setExpandHorizontal(true); scrollable.setExpandVertical(true); scrollable.setBackgroundMode(SWT.INHERIT_FORCE); scrollable.getVerticalBar().setIncrement(10); scrollable.getVerticalBar().setPageIncrement(65); FormData fd = new FormData(); fd.top = new FormAttachment(0, 0); fd.bottom = new FormAttachment(100, 0); fd.left = new FormAttachment(0, 0); fd.right = new FormAttachment(100, 0); scrollable.setLayoutData(fd); avatarsPanel = new Composite(scrollable, SWT.NONE); avatarsPanel.setBackgroundMode(SWT.INHERIT_FORCE); scrollable.setContent(avatarsPanel); scrollable.addListener( SWT.Resize, new Listener() { public void handleEvent(Event event) { Rectangle r = scrollable.getClientArea(); scrollable.setMinHeight(avatarsPanel.computeSize(r.width, SWT.DEFAULT).y); } }); /* * Specify avatar dimensions and attributes before creating the avatars */ textColor = parent.getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND); selectedTextColor = parent.getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT); textLinkColor = properties.getColor("color.links.hover"); imageBorderColor = properties.getColor("color.buddy.bg.border"); selectedColor = parent.getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION); highlightedColor = parent.getDisplay().getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW); avatarHightLightBorder = 0; avatarImageBorder = 1; hSpacing = 1; avatarImageSize = new Point(40, 40); avatarNameSize = new Point(60, 30); avatarSize = new Point(0, 0); avatarSize.x = Math.max(avatarNameSize.x, avatarImageSize.x) + (2 * (avatarHightLightBorder + avatarImageBorder)); avatarSize.y = avatarNameSize.y + avatarImageSize.y + (2 * (avatarHightLightBorder + avatarImageBorder) + 6); fillBuddies(avatarsPanel); /* UNCOMMENT THIS SECTION TO REVERT TO A ROW LAYOUT*/ // RowLayout rLayout = new RowLayout(SWT.HORIZONTAL); // rLayout.wrap = true; // rLayout.spacing = hSpacing; // avatarsPanel.setLayout(rLayout); // COMMENT THIS SECTION TO REVERT TO A ROW LAYOUT SimpleReorderableListLayout rLayout = new SimpleReorderableListLayout(); rLayout.margin = hSpacing; rLayout.wrap = true; rLayout.center = true; avatarsPanel.setLayout(rLayout); avatarsPanel.pack(); avatarsPanel.addMouseListener( new MouseAdapter() { public void mouseDown(MouseEvent e) { select(null, false, false); } }); avatarsPanel.addMouseListener( new MouseAdapter() { public void mouseDown(MouseEvent e) { select(null, false, false); } }); parent.layout(); hookFAQLink(); hookImageAction(); } return null; }