/** * Adds a tab to diagram * * @param diagram */ protected void addTab(Diagram diagram) { // do not add if tab already exists if (getTab(diagram) != null) { return; } // if the diagram key is null, and the exercise does not allow switching to the diagram type, // do not create a tab for this diagram. if (diagram.getKey() == null && !Exercise.getExercise().canSwitchToNullKeyDiagramType(diagram.getType())) { return; } // no existing tab was found, so add a new one. MainTab tab = new MainTab(diagram); tabContainer.add(tab); Dimension tabPreferredSize = tab.getPreferredSize(-1, -1); tab.setSize(tabPreferredSize.width, tabPreferredSize.height); tabs.add(tab); viewport.layout(); BoundedRangeModel hModel = viewport.getHModel(); // if there are more tabs than will fit in the viewport, add the buttons for scrolling. if (hModel.getRange() != hModel.getExtent() && !scrollButtonsAdded && hModel.getExtent() > 0) { addScrollButtons(); viewport.layout(); } }
public static MainTab valueOf(int i) { for (MainTab mainTab : values()) { if (mainTab.ordinal() == i) { return mainTab; } } return null; }
/** * Called when the tab bar switches to the tab designated by this diagram. * * @param newDiagram */ protected void activateTab(Diagram newDiagram) { diagramLabel.setText(newDiagram.getDescriptionText()); diagramLabel.setColor(getTextColor(newDiagram)); diagramLabel.setBackground(new TintedBackground(getTabColor(newDiagram))); // deactivate old tab if (activeTab != null) { activeTab.onDeactivated(); } // grab new tab activeTab = getTab(newDiagram); // activate it if (activeTab != null) { activeTab.onActivated(); activeTab.updateLabel(newDiagram); } }
public void onEvent(Event ev) { // Preferences have been changed by // PreferencesScreen if (pref.dirty == true) { mTab.getTablePanel().myMod.setColumnNamesAndWidths(); mTab.getTablePanel().refreshControl(); // mTab.getTablePanel().refreshTable(); pref.dirty = false; } super.onEvent(ev); }
/** * attempts to find a tab for the given diagram in the list. * * @param diagram * @return */ private MainTab getTab(Diagram diagram) { // first, check to see if we really need this tab. // only do this for diagrams whose key is not null. Do not add the tab if the key already // exists. if (diagram.getKey() != null) { for (MainTab tab : tabs) { if (tab.getDiagramKey() == diagram.getKey()) { // key was found, we have a match return tab; } } } else { for (MainTab tab : tabs) { if (tab.getDiagramType() == diagram.getType()) { // type was found, and key is null return tab; } } } return null; }
@Override public Fragment getItem(int position) { Fragment fragment = null; switch (MainTab.valueOf(position)) { case Github: fragment = GithubFragment.newInstance(); break; case Pixabay: fragment = PixabayFragment.newInstance(); break; case Qiita: fragment = QiitaFragment.newInstance(); break; } return fragment; }
private void initTabs() { MainTab[] tabs = MainTab.values(); final int size = tabs.length; for (int i = 0; i < size; i++) { MainTab mainTab = tabs[i]; TabSpec tab = mTabHost.newTabSpec(getString(mainTab.getResName())); View indicator = LayoutInflater.from(getApplicationContext()).inflate(R.layout.tab_indicator, null); TextView title = (TextView) indicator.findViewById(R.id.tab_title); Drawable drawable = this.getResources().getDrawable(mainTab.getResIcon()); title.setCompoundDrawablesWithIntrinsicBounds(null, drawable, null, null); if (i == 2) { indicator.setVisibility(View.INVISIBLE); mTabHost.setNoTabChangedTag(getString(mainTab.getResName())); } title.setText(getString(mainTab.getResName())); tab.setIndicator(indicator); tab.setContent( new TabContentFactory() { @Override public View createTabContent(String tag) { return new View(MainActivity.this); } }); mTabHost.addTab(tab, mainTab.getClz(), null); if (mainTab.equals(MainTab.ME)) { View cn = indicator.findViewById(R.id.tab_mes); mBvNotice = new BadgeView(MainActivity.this, cn); mBvNotice.setBadgePosition(BadgeView.POSITION_TOP_RIGHT); mBvNotice.setTextSize(TypedValue.COMPLEX_UNIT_SP, 10); mBvNotice.setBackgroundResource(R.drawable.notification_bg); mBvNotice.setGravity(Gravity.CENTER); } mTabHost.getTabWidget().getChildAt(i).setOnTouchListener(this); } }
@Override public CharSequence getPageTitle(int position) { return MainTab.valueOf(position).name(); }
@Override public int getCount() { return MainTab.values().length; }
public void doIt() { // CellPanel [] p = addToolbar(); Global.mainForm = this; // this.title = "CacheWolf " + Version.getRelease(); this.exitSystemOnClose = true; this.resizable = true; this.moveable = true; this.windowFlagsToSet = WindowConstants.FLAG_MAXIMIZE_ON_PDA; // Rect screen = ((ewe.fx.Rect) // (Window.getGuiInfo(WindowConstants.INFO_SCREEN_RECT,null,new // ewe.fx.Rect(),0))); // if ( screen.height >= 600 && screen.width >= 800) // this.setPreferredSize(800, 600); this.resizeOnSIP = true; InfoBox infB = null; try { pref.readPrefFile(); if (MyLocale.initErrors.length() != 0) { new MessageBox("Error", MyLocale.initErrors, FormBase.OKB).execute(); } if (Vm.isMobile() == true) { // this.windowFlagsToSet |=Window.FLAG_FULL_SCREEN; this.resizable = false; this.moveable = false; } else { int h, w; h = pref.myAppHeight; if (h > MyLocale.getScreenHeight()) h = MyLocale.getScreenHeight(); w = pref.myAppWidth; if (w > MyLocale.getScreenWidth()) w = MyLocale.getScreenWidth(); this.setPreferredSize(w, h); } addGuiFont(); if (!pref.selectProfile(profile, Preferences.PROFILE_SELECTOR_ONOROFF, true)) ewe.sys.Vm.exit(0); // User MUST select or create a profile Vm.showWait(true); // Replace buildt-in symbols with customized images GuiImageBroker.customizedSymbols(); // Load CacheList infB = new InfoBox("CacheHound", MyLocale.getMsg(5000, "Loading Cache-List")); infB.exec(); infB.waitUntilPainted(100); profile.readIndex(infB); pref.setCurCenter(new CWPoint(profile.getCenter())); profile.updateBearingDistance(); setTitle("CacheHound " + Version.getRelease() + " - " + profile.name); } catch (Exception e) { if (pref.debug == true) Vm.debug("MainForm:: Exception:: " + e.toString()); } if (pref.showStatus) statBar = new StatusBar(pref, profile.cacheDB); mMenu = new MainMenu(this); mTab = new MainTab(mMenu, statBar); split = new SplittablePanel(PanelSplitter.HORIZONTAL); split.theSplitter.thickness = 0; split.theSplitter.modify(Invisible, 0); CellPanel pnlCacheList = split.getNextPanel(); CellPanel pnlMainTab = split.getNextPanel(); split.setSplitter( PanelSplitter.MIN_SIZE | PanelSplitter.BEFORE, PanelSplitter.HIDDEN | PanelSplitter.BEFORE, PanelSplitter.CLOSED); pnlCacheList.addLast(cacheList = new CacheList(), STRETCH, FILL); pnlMainTab.addLast(mTab, STRETCH, FILL); mTab.dontAutoScroll = true; this.addLast(split, STRETCH, FILL); /* * if (pref.menuAtTop) { this.addLast(mMenu,CellConstants.DONTSTRETCH, * CellConstants.FILL); this.addLast(split,STRETCH,FILL); } else { * this.addLast(split,STRETCH,FILL); * this.addLast(mMenu,CellConstants.DONTSTRETCH, CellConstants.FILL); } */ mMenu.setTablePanel(mTab.getTablePanel()); if (infB != null) infB.close(0); mTab.tbP.refreshTable(); mTab.tbP.selectFirstRow(); // mTab.tbP.tc.paintSelection(); Vm.showWait(false); }
protected boolean canExit(int exitCode) { mTab.saveUnsavedChanges(true); return true; }