use of org.eclipse.swt.custom.CTabFolder in project GT by Tencent.
the class APTStubAnalysisCTabItem method createAPTStubAnalysisCTablItemUI.
/**
* 初始化页面中的所有UI
* @param parent
*/
private void createAPTStubAnalysisCTablItemUI(Composite parent) {
int margin = 5;
/**
* 三种展示视图的CTabFolder
*/
FormData showViewTabFolderFD = new FormData();
showViewTabFolderFD.left = new FormAttachment(0, margin);
showViewTabFolderFD.top = new FormAttachment(0, 25);
showViewTabFolderFD.right = new FormAttachment(100, -margin);
showViewTabFolderFD.bottom = new FormAttachment(100, -margin);
showViewTF = new CTabFolder(parent, SWT.TOP | SWT.CLOSE | SWT.BORDER);
showViewTF.setTabHeight(20);
showViewTF.setLayoutData(showViewTabFolderFD);
showViewTF.marginHeight = 10;
showViewTF.marginWidth = 10;
showViewTF.setSelectionBackground(parent.getDisplay().getSystemColor(SWT.COLOR_GRAY));
showViewTF.setSelectionForeground(parent.getDisplay().getSystemColor(SWT.COLOR_BLACK));
showViewTF.setUnselectedCloseVisible(true);
showViewTF.pack();
/**
* 详细视图按钮初始化
*/
FormData detailBtnFD = new FormData();
detailBtnFD.left = new FormAttachment(0, margin);
detailBtnFD.top = new FormAttachment(0, margin);
detailBtnFD.height = 16;
detailBtnFD.width = 16;
detailBtn = new Button(parent, SWT.NONE);
detailBtn.setToolTipText(StubAnalysisUtil.DETAIL_TAB_NAME);
detailBtn.setImage(AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/detail.png").createImage());
detailBtn.setLayoutData(detailBtnFD);
detailBtn.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
CTabItem[] openedTabItems = showViewTF.getItems();
CTabItem targetTabItem = CTabFolderItemUtil.getTabItem(openedTabItems, StubAnalysisUtil.DETAIL_TAB_NAME);
if (openedTabItems == null || openedTabItems.length == 0 || targetTabItem == null) {
detailTabItem = createDetailCTabItem(showViewTF);
detailTabItem.updateData(detailData);
} else {
if (!showViewTF.getSelection().getText().equals(targetTabItem.getText()))
;
{
showViewTF.setSelection(targetTabItem);
}
}
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
CTabItem[] openedTabItems = showViewTF.getItems();
CTabItem targetTabItem = CTabFolderItemUtil.getTabItem(openedTabItems, StubAnalysisUtil.DETAIL_TAB_NAME);
if (openedTabItems == null || openedTabItems.length == 0 || targetTabItem == null) {
detailTabItem = createDetailCTabItem(showViewTF);
detailTabItem.updateData(detailData);
} else {
if (!showViewTF.getSelection().getText().equals(targetTabItem.getText()))
;
{
showViewTF.setSelection(targetTabItem);
}
}
}
});
/**
* 统计视图按钮初始化
*/
FormData topBtnFD = new FormData();
topBtnFD.left = new FormAttachment(detailBtn, margin);
topBtnFD.top = new FormAttachment(0, margin);
topBtnFD.height = 16;
topBtnFD.width = 16;
topBtn = new Button(parent, SWT.NONE);
topBtn.setToolTipText(StubAnalysisUtil.TOP_TAB_NAME);
topBtn.setImage(AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/stat.png").createImage());
topBtn.setLayoutData(topBtnFD);
topBtn.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
CTabItem[] openedTabItems = showViewTF.getItems();
CTabItem targetTabItem = CTabFolderItemUtil.getTabItem(openedTabItems, StubAnalysisUtil.TOP_TAB_NAME);
if (openedTabItems == null || openedTabItems.length == 0 || targetTabItem == null) {
topTabItem = createTopCTabItem(showViewTF);
topTabItem.updateData(topData);
} else {
if (!showViewTF.getSelection().getText().equals(targetTabItem.getText()))
;
{
showViewTF.setSelection(targetTabItem);
}
}
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
CTabItem[] openedTabItems = showViewTF.getItems();
CTabItem targetTabItem = CTabFolderItemUtil.getTabItem(openedTabItems, StubAnalysisUtil.TOP_TAB_NAME);
if (openedTabItems == null || openedTabItems.length == 0 || targetTabItem == null) {
topTabItem = createTopCTabItem(showViewTF);
topTabItem.updateData(topData);
} else {
if (!showViewTF.getSelection().getText().equals(targetTabItem.getText()))
;
{
showViewTF.setSelection(targetTabItem);
}
}
}
});
/**
* 树形视图按钮初始化
*/
FormData treeBtnFD = new FormData();
treeBtnFD.left = new FormAttachment(topBtn, margin);
treeBtnFD.top = new FormAttachment(0, margin);
treeBtnFD.height = 16;
treeBtnFD.width = 16;
treeBtn = new Button(parent, SWT.NONE);
treeBtn.setToolTipText(StubAnalysisUtil.TREE_TAB_NAME);
treeBtn.setImage(AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/tree.png").createImage());
treeBtn.setLayoutData(treeBtnFD);
treeBtn.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
CTabItem[] openedTabItems = showViewTF.getItems();
CTabItem targetTabItem = CTabFolderItemUtil.getTabItem(openedTabItems, StubAnalysisUtil.TREE_TAB_NAME);
if (openedTabItems == null || openedTabItems.length == 0 || targetTabItem == null) {
treeTabItem = createTreeCTabItem(showViewTF);
treeTabItem.updateData(treeData);
} else {
if (!showViewTF.getSelection().getText().equals(targetTabItem.getText()))
;
{
showViewTF.setSelection(targetTabItem);
}
}
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
CTabItem[] openedTabItems = showViewTF.getItems();
CTabItem targetTabItem = CTabFolderItemUtil.getTabItem(openedTabItems, StubAnalysisUtil.TREE_TAB_NAME);
if (openedTabItems == null || openedTabItems.length == 0 || targetTabItem == null) {
treeTabItem = createTreeCTabItem(showViewTF);
} else {
if (!showViewTF.getSelection().getText().equals(targetTabItem.getText()))
;
{
showViewTF.setSelection(targetTabItem);
}
}
}
});
/**
* 打开三个视图
*/
detailTabItem = createDetailCTabItem(showViewTF);
topTabItem = createTopCTabItem(showViewTF);
treeTabItem = createTreeCTabItem(showViewTF);
}
use of org.eclipse.swt.custom.CTabFolder in project GT by Tencent.
the class StubAnalysisView method createRootTabFolder.
/**
* 初始化根CTablFolder
* @param parent
*/
private void createRootTabFolder(Composite parent) {
rootTabFolder = new CTabFolder(parent, SWT.TOP | SWT.CLOSE | SWT.BORDER);
rootTabFolder.setTabHeight(20);
//TODO 是否需要进行修改
rootTabFolder.setLayout(new FillLayout());
rootTabFolder.marginHeight = 10;
rootTabFolder.marginWidth = 10;
rootTabFolder.setSelectionBackground(parent.getDisplay().getSystemColor(SWT.COLOR_GRAY));
rootTabFolder.setSelectionForeground(parent.getDisplay().getSystemColor(SWT.COLOR_BLACK));
rootTabFolder.setUnselectedCloseVisible(true);
rootTabFolder.pack();
}
use of org.eclipse.swt.custom.CTabFolder in project GT by Tencent.
the class PMAPView method createRootTabFolder.
/**
* 初始化tab页的根
* @param parent
*/
private void createRootTabFolder(Composite parent) {
rootTabFolder = new CTabFolder(parent, SWT.TOP | SWT.CLOSE | SWT.BORDER);
rootTabFolder.setTabHeight(20);
rootTabFolder.setLayout(new FillLayout());
rootTabFolder.marginHeight = 10;
rootTabFolder.marginWidth = 10;
// 显示“最大化、最小化”按钮
rootTabFolder.setMaximizeVisible(true);
rootTabFolder.setMinimizeVisible(true);
rootTabFolder.setSelectionBackground(parent.getDisplay().getSystemColor(SWT.COLOR_GRAY));
rootTabFolder.setSelectionForeground(parent.getDisplay().getSystemColor(SWT.COLOR_BLACK));
rootTabFolder.setUnselectedCloseVisible(true);
rootTabFolder.pack();
FormData rootTabFormData = new FormData();
rootTabFormData.left = new FormAttachment(0, 5);
rootTabFormData.right = new FormAttachment(100, -5);
rootTabFormData.top = new FormAttachment(toolGroup, 5);
rootTabFormData.bottom = new FormAttachment(100, -5);
rootTabFolder.setLayoutData(rootTabFormData);
}
use of org.eclipse.swt.custom.CTabFolder in project dbeaver by serge-rider.
the class TextViewDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite dialogGroup = (Composite) super.createDialogArea(parent);
ReferenceValueEditor referenceValueEditor = new ReferenceValueEditor(getValueController(), this);
boolean isForeignKey = referenceValueEditor.isReferenceValue();
Label label = new Label(dialogGroup, SWT.NONE);
label.setText(CoreMessages.dialog_data_label_value);
boolean readOnly = getValueController().isReadOnly();
boolean useHex = !isForeignKey;
final DBSTypedObject valueType = getValueController().getValueType();
long maxSize = valueType.getMaxLength();
if (useHex) {
editorContainer = new CTabFolder(dialogGroup, SWT.FLAT | SWT.TOP);
editorContainer.setLayoutData(new GridData(GridData.FILL_BOTH));
lengthLabel = new Label(editorContainer, SWT.RIGHT);
lengthLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
editorContainer.setTopRight(lengthLabel, SWT.FILL);
}
int selectedType = 0;
if (getDialogSettings().get(VALUE_TYPE_SELECTOR) != null) {
selectedType = getDialogSettings().getInt(VALUE_TYPE_SELECTOR);
}
{
int style = SWT.NONE;
if (readOnly) {
style |= SWT.READ_ONLY;
}
if (useHex) {
style |= SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.WRAP;
} else {
// Use border only for plain text editor, otherwise tab folder's border will be used
style |= SWT.BORDER;
}
textEdit = new StyledText(useHex ? editorContainer : dialogGroup, style);
textEdit.setMargins(3, 3, 3, 3);
if (maxSize > 0 && valueType.getDataKind() == DBPDataKind.STRING) {
textEdit.setTextLimit((int) maxSize);
}
if (readOnly) {
//textEdit.setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
}
GridData gd = new GridData(isForeignKey ? GridData.FILL_HORIZONTAL : GridData.FILL_BOTH);
gd.widthHint = 300;
if (!isForeignKey) {
gd.heightHint = 200;
gd.grabExcessVerticalSpace = true;
}
textEdit.setLayoutData(gd);
textEdit.setFocus();
textEdit.setEditable(!readOnly);
textEdit.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
dirty = true;
updateValueLength();
}
});
UIUtils.fillDefaultStyledTextContextMenu(textEdit);
if (useHex) {
CTabItem item = new CTabItem(editorContainer, SWT.NO_FOCUS);
item.setText("Text");
item.setImage(DBeaverIcons.getImage(DBIcon.TYPE_TEXT));
item.setControl(textEdit);
}
}
Point minSize = null;
if (useHex) {
hexEditControl = new HexEditControl(editorContainer, readOnly ? SWT.READ_ONLY : SWT.NONE, 6, 8);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 200;
gd.minimumWidth = hexEditControl.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
hexEditControl.setLayoutData(gd);
minSize = hexEditControl.computeSize(SWT.DEFAULT, SWT.DEFAULT);
minSize.x += 50;
minSize.y += 50;
CTabItem item = new CTabItem(editorContainer, SWT.NO_FOCUS);
item.setText("Hex");
item.setImage(DBeaverIcons.getImage(DBIcon.TYPE_BINARY));
item.setControl(hexEditControl);
if (selectedType >= editorContainer.getItemCount()) {
selectedType = 0;
}
editorContainer.setSelection(selectedType);
editorContainer.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
getDialogSettings().put(VALUE_TYPE_SELECTOR, editorContainer.getSelectionIndex());
}
});
hexEditControl.addListener(SWT.Modify, new Listener() {
@Override
public void handleEvent(Event event) {
dirty = true;
}
});
updateValueLength();
}
primeEditorValue(getValueController().getValue());
if (isForeignKey) {
referenceValueEditor.createEditorSelector(dialogGroup);
}
if (minSize != null) {
// Set default size as minimum
getShell().setMinimumSize(minSize);
}
return dialogGroup;
}
use of org.eclipse.swt.custom.CTabFolder in project dbeaver by serge-rider.
the class MultiPageAbstractEditor method setContainerStyles.
protected void setContainerStyles() {
Composite pageContainer = getContainer();
if (pageContainer instanceof CTabFolder) {
CTabFolder tabFolder = (CTabFolder) pageContainer;
tabFolder.setSimple(false);
tabFolder.setMRUVisible(true);
tabFolder.setTabPosition(SWT.TOP);
Control topRight = createTopRightControl(tabFolder);
if (topRight != null) {
Point trSize = topRight.computeSize(SWT.DEFAULT, SWT.DEFAULT);
tabFolder.setTabHeight(trSize.y);
tabFolder.setTopRight(topRight, SWT.RIGHT | SWT.WRAP);
}
// tabFolder.setSimple(false);
//tabFolder.setBorderVisible(true);
Layout parentLayout = tabFolder.getParent().getLayout();
if (parentLayout instanceof FillLayout) {
((FillLayout) parentLayout).marginHeight = 0;
// ((FillLayout)parentLayout).marginWidth = 5;
}
}
}
Aggregations