public void init(Composite parent) { this.tabFolder = new CTabFolder(parent, SWT.TOP); this.tabFolder.setTabHeight(TAB_HEIGHT); this.tabFolder.setLayout(new FillLayout()); this.tabFolder.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { TGTabFolder.this.onTabItemSelected(); } }); this.tabFolder.addCTabFolder2Listener(new CTabFolder2Adapter() { public void close(CTabFolderEvent event) { TGDocument document = (TGDocument) event.item.getData(); if( document != null ) { closeDocument(document); event.doit = false; } } }); this.updateDocument(); }
private void doConnectionResultConversion(String message, String dbURL) { setImage(IconLoader.loadIcon("DatabaseIcon")); setStatus("Requires conversion to the current database format."); showConversion(message, dbURL.substring("db:".length())); DBrowser.getTabFolder().addCTabFolder2Listener(new CTabFolder2Adapter() { public void close(CTabFolderEvent event) { if (event.item == DbTab.this) DbTab.this.close(); } }); DBrowser.createNewTabIfNeeded(); }
/** * Creates a new instance. * * @param parent * @param controller * @param title * @param id */ public ComponentTitledBorder(Composite parent, Controller controller, String title, String id){ folder = new CTabFolder(parent, SWT.TOP | SWT.BORDER | SWT.FLAT); folder.setUnselectedCloseVisible(false); folder.setSimple(false); // Create help button if (controller != null) SWTUtil.createHelpButton(controller, folder, id); // Prevent closing folder.addCTabFolder2Listener(new CTabFolder2Adapter() { @Override public void close(final CTabFolderEvent event) { event.doit = false; } }); // Create general tab tab = new CTabItem(folder, SWT.NULL); tab.setText(title); tab.setShowClose(false); folder.setSelection(tab); }
private void doConnectionResultSuccess(DbConnection client, String dbURL, boolean permanent) { setImage(IconLoader.loadIcon("DatabaseIcon")); setStatus("Ok"); toolBarMode.setEnabled(true); refresh(); if (tltmModeRel.getSelection()) showRel(); else if (tltmModeRev.getSelection()) showRev(); else if (tltmModeCmd.getSelection()) showCmd(); else { // default mode if (Preferences.getPreferenceBoolean(PreferencePageGeneral.DEFAULT_CMD_MODE)) { tltmModeCmd.setSelection(true); showCmd(); } else { tltmModeRel.setSelection(true); showRel(); } } DBrowser.getTabFolder().addCTabFolder2Listener(new CTabFolder2Adapter() { public void close(CTabFolderEvent event) { if (event.item == DbTab.this) DbTab.this.close(); } }); DBrowser.createNewTabIfNeeded(); DBrowser.updateRecentlyUsedDatabaseList(dbURL); }
/** * @param content */ private void createTabFolder(Composite content) { CTabFolder folder = new CTabFolder(content, SWT.BORDER | SWT.BOTTOM); // folder.setSimple(false); // folder.setUnselectedImageVisible(false); // folder.setUnselectedCloseVisible(false); // folder.setMinimizeVisible(true); // folder.setMaximizeVisible(true); // configuration CTabItem startTab = new CTabItem(folder, SWT.NONE); startTab.setText("TAB1"); Composite config = createMonitorConfig(folder); startTab.setControl(config); // monitor info CTabItem item = new CTabItem(folder, SWT.NONE); item.setText("TAB2"); Text text = new Text(folder, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); text.setEditable(false); showRecvMsg(text); item.setControl(text); folder.addCTabFolder2Listener(new CTabFolder2Adapter() { @Override public void close(CTabFolderEvent event) { // if (event.item.equals(specialItem)) { // event.doit = false; // } } }); folder.setSelection(item); }
/** * Creates a new instance. * * @param parent * @param controller * @param bar * @param id * @param bottom * @param hasHidingMenu */ public ComponentTitledFolder(Composite parent, Controller controller, ComponentTitledFolderButtonBar bar, String id, Map<Composite, String> helpids, boolean bottom, boolean hasHidingMenu){ int flags = SWT.BORDER | SWT.FLAT; if (bottom) flags |= SWT.BOTTOM; else flags |= SWT.TOP; this.hasHidingMenu = hasHidingMenu; this.folder = new CTabFolder(parent, flags); this.folder.setUnselectedCloseVisible(false); this.folder.setSimple(false); // Create help button if (bar == null) SWTUtil.createHelpButton(controller, folder, id, helpids); else createBar(controller, folder, bar); // Prevent closing this.folder.addCTabFolder2Listener(new CTabFolder2Adapter() { @Override public void close(final CTabFolderEvent event) { event.doit = false; } }); }
private void createTabItem() { tabItem = new CTabItem(tabFolder, commandPage.important ? SWT.NONE : SWT.CLOSE); Color bgc = tabFolder.getDisplay().getSystemColor(SWT.COLOR_TITLE_BACKGROUND_GRADIENT); tabFolder.setBackground(bgc); if (commandPage.important) { tabItem.setImage(Scripts.getImage(Scripts.IMG_PAGE_REQUIRED)); if (pageFont == null) { FontData[] data = tabItem.getFont().getFontData(); data[0].setStyle(SWT.BOLD); pageFont = new Font(tabFolder.getDisplay(), data[0]); } tabItem.setFont(pageFont); } else { tabItem.setImage(Scripts.getImage(Scripts.IMG_PAGE_OPTIONAL)); tabFolder.addCTabFolder2Listener(new CTabFolder2Adapter() { @Override public void close(CTabFolderEvent event) { if (commandPage.lines.size() > 1) { event.doit = (showCloseMessage() == SWT.YES); } } }); } tabItem.setText(commandPage.name + ' '); }
private void createTabItem() { tabItem = new CTabItem(tabFolder, commandPage.important ? SWT.NONE : SWT.CLOSE); Color bgc = tabFolder.getDisplay().getSystemColor(SWT.COLOR_TITLE_BACKGROUND_GRADIENT); tabFolder.setBackground(bgc); if (commandPage.important) { tabItem.setImage(Scripts.getImage(Scripts.IMG_PAGE_REQUIRED)); if (pageFont == null) { FontData[] data = tabItem.getFont().getFontData(); data[0].setStyle(SWT.BOLD); pageFont = new Font(tabFolder.getDisplay(), data[0]); } tabItem.setFont(pageFont); } else { tabItem.setImage(Scripts.getImage(Scripts.IMG_PAGE_OPTIONAL)); tabFolder.addCTabFolder2Listener(new CTabFolder2Adapter() { @Override public void close(CTabFolderEvent event) { if (event.data != null) return; event.doit = deletePage(); event.data = new Boolean(event.doit); // if (commandPage.lines.size() > 1) // { // event.doit = (showCloseMessage() == SWT.YES); // } } }); } tabItem.setText(commandPage.name + ' '); }