Java Code Examples for org.eclipse.swt.custom.CTabItem#getData()
The following examples show how to use
org.eclipse.swt.custom.CTabItem#getData() .
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: MainShell.java From RepDev with GNU General Public License v3.0 | 6 votes |
private void handleRenameItem(TreeItem item, String newName) { if (item.getData() instanceof SymitarFile) { // Set SymitarFile name if (((SymitarFile) item.getData()).saveName(newName)) item.setText(newName); // Set name in tree // Now, set name in any open tabs for (CTabItem c : mainfolder.getItems()) if (c.getData("file") == item.getData()) // Be sure it's the // exact same // instance, like it // should be { c.setText(newName); if (c.getControl() instanceof EditorComposite) { c.setData("modified", false); ((EditorComposite) c.getControl()).updateModified(); } } } if (item.getData() instanceof Project) { ((Project) item.getData()).setName(newName); item.setText(newName); } }
Example 2
Source File: EditorComposite.java From RepDev with GNU General Public License v3.0 | 6 votes |
public void updateModified(){ CTabFolder folder = (CTabFolder)getParent(); Object loc; if( file.isLocal()) loc = file.getDir(); else loc = file.getSym(); for( CTabItem cur : folder.getItems()) if( cur.getData("file") != null && ((SymitarFile)cur.getData("file")).equals(file) && cur.getData("loc").equals(loc) ) if( modified && ( cur.getData("modified") == null || !((Boolean)cur.getData("modified")))){ cur.setData("modified", true); cur.setText(cur.getText() + " *"); } else if( !modified && ( cur.getData("modified") == null || ((Boolean)cur.getData("modified")))){ cur.setData("modified", false); cur.setText(cur.getText().substring(0,cur.getText().length() - 2)); } }
Example 3
Source File: RezepteView.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
private void doAddLine(){ try { LeistungenView lv1 = (LeistungenView) getViewSite().getPage().showView(LeistungenView.ID); CodeSelectorHandler.getInstance().setCodeSelectorTarget(dropTarget); CTabItem[] tabItems = lv1.ctab.getItems(); for (CTabItem tab : tabItems) { ICodeElement ics = (ICodeElement) tab.getData(); if (ics instanceof Artikel) { lv1.ctab.setSelection(tab); break; } } } catch (PartInitException ex) { ExHandler.handle(ex); } }
Example 4
Source File: KGPrintView.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
public void useItem(int idx, String template, Kontakt adressat){ CTabItem item = ctab.getItem(idx); Brief brief = (Brief) item.getData("brief"); //$NON-NLS-1$ TextContainer text = (TextContainer) item.getData("text"); //$NON-NLS-1$ text.saveBrief(brief, Brief.UNKNOWN); String betreff = brief.getBetreff(); brief.delete(); if (template != null) { Brief actBrief = text.createFromTemplateName(Konsultation.getAktuelleKons(), template, Brief.UNKNOWN, adressat, betreff); item.setData("brief", actBrief); //$NON-NLS-1$ } }
Example 5
Source File: Importer.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
/** * Run the import method of the topmost plugin */ @Override protected void okPressed(){ CTabItem top = ctab.getSelection(); if (top != null) { ImporterPage page = (ImporterPage) top.getData(); page.collect(); page.run(false); } super.okPressed(); }
Example 6
Source File: LeistungenView.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
private void initCTabItemControl(CTabItem tabItem){ CodeSystemDescription systemDescription = (CodeSystemDescription) tabItem.getData(); if (systemDescription != null) { cPage page = new cPage(tabItem, systemDescription); selected.setControl(page); } }
Example 7
Source File: BriefAuswahl.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
public void refreshCV(Message updateKeeplabels){ if (ctab != null && !ctab.isDisposed()) { CTabItem sel = ctab.getSelection(); if (sel != null) { CommonViewer cv = (CommonViewer) sel.getData(); cv.notify(updateKeeplabels); } } }
Example 8
Source File: BriefAuswahl.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
public void refreshSelectedViewer(){ CTabItem sel = ctab.getSelection(); if ((sel != null)) { CommonViewer cv = (CommonViewer) sel.getData(); cv.notify(CommonViewer.Message.update); } }
Example 9
Source File: BriefAuswahl.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
public Brief getSelectedBrief(){ CTabItem sel = ctab.getSelection(); if ((sel != null)) { CommonViewer cv = (CommonViewer) sel.getData(); Object[] o = cv.getSelection(); if ((o != null) && (o.length > 0)) { if (o[0] instanceof Brief) { return (Brief) o[0]; } } } return null; }
Example 10
Source File: TemplatePrintView.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
/** * Drukt Dokument anhand einer Vorlage * * @param pat * der Patient * @param templateName * Name der Vorlage * @param printer * Printer * @param tray * Tray * @param monitor * @return */ public boolean doPrint(Patient pat, String templateName, String printer, String tray, IProgressMonitor monitor){ monitor.subTask(pat.getLabel()); // TODO ? // GlobalEvents.getInstance().fireSelectionEvent(rn,getViewSite()); existing = ctab.getItems().length; CTabItem ct; TextContainer text; if (--existing < 0) { ct = addItem(templateName, templateName, pat); } else { ct = ctab.getItem(0); useItem(0, templateName, pat); } text = (TextContainer) ct.getData(KEY_TEXT); text.getPlugin().setFont("Serif", SWT.NORMAL, 9); //$NON-NLS-1$ if (text.getPlugin().print(printer, tray, false) == false) { return false; } monitor.worked(1); return true; }
Example 11
Source File: TemplatePrintView.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
public void useItem(int idx, String template, Kontakt adressat){ CTabItem item = ctab.getItem(idx); if (!item.isDisposed()) { Brief brief = (Brief) item.getData(KEY_BRIEF); TextContainer text = (TextContainer) item.getData(KEY_TEXT); text.saveBrief(brief, Brief.UNKNOWN); String betreff = brief.getBetreff(); brief.delete(); if (template != null) { Brief actBrief = text.createFromTemplateName(Konsultation.getAktuelleKons(), template, Brief.UNKNOWN, adressat, betreff); item.setData(KEY_BRIEF, actBrief); } } }
Example 12
Source File: KGPrintView.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
/** * Drukt die KG-Huelle anhand der Vorlage "KG" * * @param pat * der Patient * @param monitor * @return */ public boolean doPrint(Patient pat, IProgressMonitor monitor){ monitor.subTask(pat.getLabel()); // TODO ? // GlobalEvents.getInstance().fireSelectionEvent(rn,getViewSite()); existing = ctab.getItems().length; String printer = null; String tray = null; CTabItem ctKG; TextContainer text; if (--existing < 0) { ctKG = addItem(TT_KG_COVER_SHEET, Messages.KGPrintView_EMR, null); //$NON-NLS-1$ } else { ctKG = ctab.getItem(0); useItem(0, TT_KG_COVER_SHEET, null); } text = (TextContainer) ctKG.getData("text"); //$NON-NLS-1$ text.getPlugin().setFont("Serif", SWT.NORMAL, 9); //$NON-NLS-1$ text.replace("\\[Elexis\\]", new ReplaceCallback() { //$NON-NLS-1$ public String replace(String in){ return "ELEXIS"; //$NON-NLS-1$ } }); printer = CoreHub.localCfg.get("Drucker/A4/Name", null); //$NON-NLS-1$ tray = CoreHub.localCfg.get("Drucker/A4/Schacht", null); //$NON-NLS-1$ if (text.getPlugin().print(printer, tray, false) == false) { return false; } monitor.worked(1); return true; }
Example 13
Source File: EclipseTabProvider.java From neoscada with Eclipse Public License 1.0 | 5 votes |
private int findIndex ( final int index ) { final CTabItem[] items = this.folder.getItems (); for ( int i = 0; i < items.length; i++ ) { final CTabItem item = items[i]; final int order = (Integer)item.getData ( "order" ); if ( order > index ) { return i; } } return -1; }
Example 14
Source File: ChatRoomsComposite.java From saros with GNU General Public License v2.0 | 5 votes |
/** * Update title and history for chats. A chat is updated if its participants contains any of the * given {@link JID}s. * * @param jids JIDs whom the chats should be updated for */ private void updateChatTabs(Collection<JID> jids) { for (CTabItem tab : chatRooms.getItems()) { if (!(tab.getControl() instanceof ChatControl)) continue; ChatControl control = (ChatControl) tab.getControl(); IChat chat = (IChat) tab.getData(); if (!Collections.disjoint(jids, chat.getParticipants())) { control.updateDisplayNames(); tab.setText(getChatTabName(chat)); } } }
Example 15
Source File: ChatRoomsComposite.java From saros with GNU General Public License v2.0 | 5 votes |
public CTabItem getChatTab(IChat chat) { for (CTabItem tab : this.chatRooms.getItems()) { IChat data = (IChat) tab.getData(); // do the equal check this way to allow null values in the tab data if (chat.equals(data)) return tab; } return null; }
Example 16
Source File: MainShell.java From RepDev with GNU General Public License v3.0 | 5 votes |
public void saveAllRepgens() { if (mainfolder.getItems().length >= 1) { for (CTabItem item : mainfolder.getItems()) { if ((item.getControl() instanceof EditorComposite) && item.getData("modified") != null && (Boolean) item.getData("modified")) { System.out.println("Saving file: " + item.getData("file")); ((EditorComposite) item.getControl()).saveFile(true); } } } }
Example 17
Source File: MainShell.java From RepDev with GNU General Public License v3.0 | 5 votes |
private boolean confirmClose(CTabItem item) { if (item != null && item.getData("modified") != null && ((Boolean) item.getData("modified"))) { MessageBox dialog = new MessageBox(shell, SWT.ICON_QUESTION | SWT.YES | SWT.NO | SWT.CANCEL); dialog.setText("Confirm File Close"); if (item.getData("loc") instanceof Integer) dialog.setMessage("The file '" + item.getData("file") + "' on Sym " + item.getData("loc") + " has been modified, do you want to save it before closing it?"); else dialog.setMessage("The file '" + item.getData("file") + "' in directory " + item.getData("loc") + " has been modified, do you want to save it before closing it?"); int result = dialog.open(); if (result == SWT.CANCEL) return false; else if (result == SWT.YES) { ((EditorComposite) item.getControl()).saveFile(false); } } if (mainfolder.getSelection().getControl() instanceof EditorComposite) for (TableItem tItem : tblErrors.getItems()) if (tItem.getData("file").equals(mainfolder.getSelection().getData("file")) && tItem.getData("sym").equals(mainfolder.getSelection().getData("sym"))){ tItem.dispose(); //EditorCompositeList.remove(mainfolder.getSelection().getControl()); } // Remove entries matching this tab from the tabHistory stack since we are closing the file List<CTabItem> closingTab = Arrays.asList(item); tabHistory.removeAll(closingTab); if(!tabHistory.isEmpty()) setMainFolderSelection(tabHistory.get(tabHistory.size()-1)); return true; }
Example 18
Source File: MainShell.java From RepDev with GNU General Public License v3.0 | 5 votes |
private int removeFile(TreeItem cur, int lastResult) { if (!(cur.getData() instanceof SymitarFile)) return 0; SymitarFile file = (SymitarFile) cur.getData(); Project proj = (Project) cur.getParentItem().getData(); int result = lastResult; if ((lastResult & RemFileShell.REPEAT) == 0) result = RemFileShell.confirm(display, shell, proj, file); if ((result & RemFileShell.OK) > 0 && (result & RemFileShell.DELETE) == 0) { proj.removeFile(file, false); cur.dispose(); } else if ((result & RemFileShell.OK) > 0 && (result & RemFileShell.DELETE) > 0) { proj.removeFile(file, true); cur.dispose(); } if (!proj.isLocal()) ProjectManager.saveProjects(proj.getSym()); else ProjectManager.saveProjects(proj.getDir()); tree.notifyListeners(SWT.Selection, null); for (CTabItem c : mainfolder.getItems()) { if (c.getData("file") != null && c.getData("file").equals(file)) { c.dispose(); } } return result; }
Example 19
Source File: MainShell.java From RepDev with GNU General Public License v3.0 | 4 votes |
public Object openFile(final SymitarFile file) { boolean found = false; Composite editor; Object loc; if (file.isLocal()) loc = file.getDir(); else loc = file.getSym(); for (CTabItem c : mainfolder.getItems()) { if (c.getData("file") != null && c.getData("file").equals(file) && c.getData("loc") != null && c.getData("loc").equals(loc)) { setMainFolderSelection(c); found = true; return c.getControl(); } } if (!found) { CTabItem item = new CTabItem(mainfolder, SWT.CLOSE); item.setText(file.getName()); // item.setToolTipText(file.getName()); // only use this if we are shrinking tabs item.setImage(getFileImage(file)); item.setData("file", file); item.setData("loc", loc); if (file.getType() == FileType.REPORT) editor = new ReportComposite(mainfolder, item, file); else { editor = new EditorComposite(mainfolder, item, file /* * ,save, * install, * print, * run */); //EditorCompositeList.add((EditorComposite)editor); } // If anything goes wrong creating the Editor, we want to fail here // It will dispose of the item to indicate this fault. if (item.isDisposed()) { MessageBox dialog = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); dialog.setMessage("There has been an error loading this file, the filename is probably too long"); dialog.setText("Error"); dialog.open(); return null; } mainfolder.setSelection(item); item.setControl(editor); setMainFolderSelection(item); mainfolder.notifyListeners(SWT.Selection, new Event()); //When we are closing, we must dispose the control in the CTabItem, otherwise we leak swt objects item.addDisposeListener(new DisposeListener(){ public void widgetDisposed(DisposeEvent e) { if(((CTabItem)e.widget).getControl() != null) ((CTabItem)e.widget).getControl().dispose(); } }); if (file.getType() != FileType.REPGEN || file.isLocal()) install.setEnabled(false); else install.setEnabled(true); if (file.getType() != FileType.REPGEN || file.isLocal()) run.setEnabled(false); else run.setEnabled(true); savetb.setEnabled(true); if ((file.getType() == FileType.REPGEN)||(file.getType() == FileType.LETTER)||(file.getType() == FileType.HELP)) hltoggle.setEnabled(true); if (mainfolder.getSelection().getControl() instanceof EditorComposite){ if(((EditorComposite)mainfolder.getSelection().getControl()).getHighlight()){ hltoggle.setImage(RepDevMain.smallHighlight); }else{ hltoggle.setImage(RepDevMain.smallHighlightGrey); } } // Attach find/replace shell here as well (in addition to folder // listener) findReplaceShell.attach(((EditorComposite) mainfolder.getSelection().getControl()).getStyledText(), true); if (!Config.getRecentFiles().contains(file)) Config.getRecentFiles().add(0, file); if (Config.getRecentFiles().size() > MAX_RECENTS) Config.getRecentFiles().remove(Config.getRecentFiles().size() - 1); return editor; } return null; }