/** * Update the visibility of the CASA window group * * @param preferredId */ public static void updateGroupVisibility(String preferredId) { WindowManager wm = WindowManager.getDefault(); TopComponentGroup group = wm.findTopComponentGroup("casa_ui"); // NOI18N if (group == null) { return; // group not found (should not happen) } // boolean isDesignViewSelected = false; for (Mode mode : wm.getModes()) { TopComponent selected = mode.getSelectedTopComponent(); if (selected != null) { MultiViewHandler mvh = MultiViews.findMultiViewHandler(selected); if (mvh != null) { MultiViewPerspective mvp = mvh.getSelectedPerspective(); if (mvp != null) { String id = mvp.preferredID(); if (preferredId.equals(id)) { isDesignViewSelected = true; break; } } } } } synchronized (groupVisible) { if (isDesignViewSelected && !groupVisible) { group.open(); groupVisible = Boolean.TRUE; } else if (!isDesignViewSelected && groupVisible) { group.close(); groupVisible = Boolean.FALSE; } } }
/** * Updates the View State when the mode has been set. This does not do any checking that the mode * is different to current state so always updates. */ protected void updateUIForMode() { // We need to use the correct LayoutParam values, based on scroll // direction final LayoutParams lp = getLoadingLayoutLayoutParams(); // Remove Header, and then add Header Loading View again if needed if (this == mHeaderLayout.getParent()) { removeView(mHeaderLayout); } if (mMode.showHeaderLoadingLayout()) { addViewInternal(mHeaderLayout, 0, lp); } // Remove Footer, and then add Footer Loading View again if needed if (this == mFooterLayout.getParent()) { removeView(mFooterLayout); } if (mMode.showFooterLoadingLayout()) { addViewInternal(mFooterLayout, lp); } // Hide Loading Views refreshLoadingViewsSize(); // If we're not using Mode.BOTH, set mCurrentMode to mMode, otherwise // set it to pull down mCurrentMode = (mMode != Mode.BOTH) ? mMode : Mode.PULL_FROM_START; }
@Override protected final void onRestoreInstanceState(Parcelable state) { if (state instanceof Bundle) { Bundle bundle = (Bundle) state; setMode(Mode.mapIntToValue(bundle.getInt(STATE_MODE, 0))); mCurrentMode = Mode.mapIntToValue(bundle.getInt(STATE_CURRENT_MODE, 0)); mScrollingWhileRefreshingEnabled = bundle.getBoolean(STATE_SCROLLING_REFRESHING_ENABLED, false); mShowViewWhileRefreshing = bundle.getBoolean(STATE_SHOW_REFRESHING_VIEW, true); // Let super Restore Itself super.onRestoreInstanceState(bundle.getParcelable(STATE_SUPER)); State viewState = State.mapIntToValue(bundle.getInt(STATE_STATE, 0)); if (viewState == State.REFRESHING || viewState == State.MANUAL_REFRESHING) { setState(viewState, true); } // Now let derivative classes restore their state onPtrRestoreInstanceState(bundle); return; } super.onRestoreInstanceState(state); }
private int buildModeMask() { int mask = 0; for (Mode mode : modes) { mask |= mode.value(); } return mask; }
private static List<SuggestedItem> find(Mode m, SearchIndex index, String tokenList) { TokenList tokens = new TokenList(tokenList); if (tokens.length() == 0) return Collections.emptyList(); // no tokens given List<SuggestedItem>[] paths = new List[tokens.length() + 1]; // we won't use [0]. for (int i = 1; i <= tokens.length(); i++) paths[i] = new ArrayList<SuggestedItem>(); List<SearchItem> items = new ArrayList<SearchItem>(); // items found in 1 step // first token int w = 1; // width of token for (String token : tokens.subSequence(0)) { items.clear(); m.find(index, token, items); for (SearchItem si : items) paths[w].add(new SuggestedItem(si)); w++; } // successive tokens for (int j = 1; j < tokens.length(); j++) { // for each length w = 1; for (String token : tokens.subSequence(j)) { // for each candidate for (SuggestedItem r : paths[j]) { items.clear(); m.find(r.item.getSearchIndex(), token, items); for (SearchItem i : items) paths[j + w].add(new SuggestedItem(r, i)); } w++; } } return paths[tokens.length()]; }
private void addIndicatorViews() { final Mode mode = getMode(); if (mode.canPullDown() && null == mIndicatorIvTop) { // If the mode can pull down, and we don't have one set already mIndicatorIvTop = new IndicatorLayout(getContext(), Mode.PULL_DOWN_TO_REFRESH); final FrameLayout.LayoutParams params = new FrameLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.rightMargin = getResources().getDimensionPixelSize(R.dimen.indicator_right_padding); params.gravity = Gravity.TOP | Gravity.RIGHT; mRefreshableViewHolder.addView(mIndicatorIvTop, params); } else if (!mode.canPullDown() && null != mIndicatorIvTop) { // If we can't pull down, but have a View then remove it mRefreshableViewHolder.removeView(mIndicatorIvTop); mIndicatorIvTop = null; } if (mode.canPullUp() && null == mIndicatorIvBottom) { // If the mode can pull down, and we don't have one set already mIndicatorIvBottom = new IndicatorLayout(getContext(), Mode.PULL_UP_TO_REFRESH); final FrameLayout.LayoutParams params = new FrameLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.rightMargin = getResources().getDimensionPixelSize(R.dimen.indicator_right_padding); params.gravity = Gravity.BOTTOM | Gravity.RIGHT; mRefreshableViewHolder.addView(mIndicatorIvBottom, params); } else if (!mode.canPullUp() && null != mIndicatorIvBottom) { // If we can't pull down, but have a View then remove it mRefreshableViewHolder.removeView(mIndicatorIvBottom); mIndicatorIvBottom = null; } }
@Override protected void onRestoreInstanceState(Parcelable state) { if (state instanceof Bundle) { Bundle bundle = (Bundle) state; mMode = Mode.mapIntToMode(bundle.getInt(STATE_MODE, 0)); mCurrentMode = Mode.mapIntToMode(bundle.getInt(STATE_CURRENT_MODE, 0)); mDisableScrollingWhileRefreshing = bundle.getBoolean(STATE_DISABLE_SCROLLING_REFRESHING, true); mShowViewWhileRefreshing = bundle.getBoolean(STATE_SHOW_REFRESHING_VIEW, true); // Let super Restore Itself super.onRestoreInstanceState(bundle.getParcelable(STATE_SUPER)); final int viewState = bundle.getInt(STATE_STATE, PULL_TO_REFRESH); if (viewState == REFRESHING) { setRefreshingInternal(true); mState = viewState; } return; } super.onRestoreInstanceState(state); }
private void actionButtonActionPerformed() { if (userMode) { addUserPanel.inviteUsers(); } else { /* * Phone Mode */ String name = addPhoneUserPanel.getPhoneName(); PresenceInfo[] info = pm.getAllUsers(); for (int i = 0; i < info.length; i++) { if (info[i].getUsernameAlias().equals(name) || info[i].getUserID().getUsername().equals(name)) { addPhoneUserPanel.setStatusMessage(BUNDLE.getString("Name_Used")); return; } } addUserPanel.callUser(name, addPhoneUserPanel.getPhoneNumber()); if (mode.equals(Mode.ADD)) { addHUDComponent.setVisible(false); addHUDComponent.setClosed(); } } if (mode.equals(Mode.INITIATE)) { setMode(Mode.IN_PROGRESS); } }
/** * Updates the View State when the mode has been set. This does not do any checking that the mode * is different to current state so always updates. */ protected void updateUIForMode() { // Remove Header, and then add Header Loading View again if needed if (this == mHeaderLayout.getParent()) { removeView(mHeaderLayout); } if (mMode.canPullDown()) { LinearLayout.LayoutParams llp = new LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); llp.setMargins(mMargin, 0, mMargin, 0); addViewInternal(mHeaderLayout, 0, llp); } // Remove Footer, and then add Footer Loading View again if needed if (this == mFooterLayout.getParent()) { removeView(mFooterLayout); } if (mMode.canPullUp()) { LinearLayout.LayoutParams llp = new LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); llp.setMargins(mMargin, 0, mMargin, 0); addViewInternal(mFooterLayout, 0, llp); } // Hide Loading Views refreshLoadingViewsHeight(); // If we're not using Mode.BOTH, set mCurrentMode to mMode, otherwise // set it to pull down mCurrentMode = (mMode != Mode.BOTH) ? mMode : Mode.PULL_DOWN_TO_REFRESH; }
/** Parse XJC-specific options. */ public int parseArgument(String[] args, int i) throws BadCommandLineException { if (args[i].equals("-noNS")) { noNS = true; return 1; } if (args[i].equals("-mode")) { i++; if (i == args.length) throw new BadCommandLineException( Messages.format(Messages.MISSING_MODE_OPERAND)); String mstr = args[i].toLowerCase(); for( Mode m : Mode.values() ) { if(m.name().toLowerCase().startsWith(mstr) && mstr.length()>2) { mode = m; return 2; } } throw new BadCommandLineException( Messages.format(Messages.UNRECOGNIZED_MODE, args[i])); } if (args[i].equals("-help")) { usage(this,false); throw new WeAreDone(); } if (args[i].equals("-private")) { usage(this,true); throw new WeAreDone(); } return super.parseArgument(args, i); }
public static ProfileGroup fromXml(XmlPullParser xpp) throws XmlPullParserException, IOException { String defaultGroup = xpp.getAttributeValue(null, "default"); defaultGroup = defaultGroup == null ? "false" : defaultGroup; ProfileGroup profileGroup = new ProfileGroup(xpp.getAttributeValue(null, "name"), defaultGroup.equals("true")); int event = xpp.next(); while (event != XmlPullParser.END_TAG || !xpp.getName().equals("profileGroup")) { if (event == XmlPullParser.START_TAG) { String name = xpp.getName(); if (name.equals("sound")) { profileGroup.setSoundOverride(Uri.parse(xpp.nextText())); } else if (name.equals("ringer")) { profileGroup.setRingerOverride(Uri.parse(xpp.nextText())); } else if (name.equals("soundMode")) { profileGroup.setSoundMode(Mode.valueOf(xpp.nextText())); } else if (name.equals("ringerMode")) { profileGroup.setRingerMode(Mode.valueOf(xpp.nextText())); } else if (name.equals("vibrateMode")) { profileGroup.setVibrateMode(Mode.valueOf(xpp.nextText())); } else if (name.equals("lightsMode")) { profileGroup.setLightsMode(Mode.valueOf(xpp.nextText())); } } event = xpp.next(); } return profileGroup; }
/** Re-measure the Loading Views height, and adjust internal padding as necessary */ private void refreshLoadingViewsHeight() { if (mMode.canPullDown()) { measureView(mHeaderLayout); mHeaderHeight = mHeaderLayout.getMeasuredHeight(); } else if (mMode.canPullUp()) { measureView(mFooterLayout); mHeaderHeight = mFooterLayout.getMeasuredHeight(); } else { mHeaderHeight = 0; } // Hide Loading Views switch (mMode) { case DISABLED: setPadding(0, 0, 0, 0); case BOTH: setPadding(0, -mHeaderHeight, 0, -mHeaderHeight); break; case PULL_UP_TO_REFRESH: setPadding(0, 0, 0, -mHeaderHeight); break; case PULL_DOWN_TO_REFRESH: default: setPadding(0, -mHeaderHeight, 0, 0); break; } }
private void compileModes(ClassGenerator classGen) { _defaultMode.compileApplyTemplates(classGen); final Enumeration modes = _modes.elements(); while (modes.hasMoreElements()) { final Mode mode = (Mode) modes.nextElement(); mode.compileApplyTemplates(classGen); } }
/** * Set Text to show when the Widget is being pulled, and will refresh when released * * @param releaseLabel - String to display * @param mode - Controls which Header/Footer Views will be updated. <code>Mode.BOTH</code> will * update all available, other values will update the relevant View. */ public void setReleaseLabel(String releaseLabel, Mode mode) { if (null != mHeaderLayout && mode.canPullDown()) { mHeaderLayout.setReleaseLabel(releaseLabel); } if (null != mFooterLayout && mode.canPullUp()) { mFooterLayout.setReleaseLabel(releaseLabel); } }
@Override public Effects getAllEffects() { Effects allEffects = new Effects(); for (Mode mode : getModes().values()) { allEffects.addAll(mode.getEffects()); } return allEffects; }
protected void loadCatalog() { CatalogReader reader = new CatalogReader(); modeList = reader.read("modes/catalog"); // $NON-NLS-1$ for (int i = 0; i < modeList.length; i++) { Mode mode = modeList[i]; modes.put(mode.getFilename(), mode); } }
/* * Answer the Rule set this delegate/rule resolves to. This may require loading more modes. */ public static Rule resolveDelegate(Mode mode, String delegateName) { int index = delegateName.indexOf("::"); // $NON-NLS-1$ if (index == -1) { // Local delegate/rule set return mode.getRule(delegateName); } Mode loadedMode = getMode(delegateName.substring(0, index) + XmlUtil.FILE_XML_SUFFIX); return loadedMode.getRule(delegateName.substring(index + 2)); }
public void processModes() { if (_defaultMode == null) _defaultMode = new Mode(null, this, Constants.EMPTYSTRING); _defaultMode.processPatterns(_keys); final Enumeration modes = _modes.elements(); while (modes.hasMoreElements()) { final Mode mode = (Mode) modes.nextElement(); mode.processPatterns(_keys); } }
@Override public void setRefreshingLabel(String refreshingLabel, Mode mode) { if (null != mHeaderLayout && mode.canPullDown()) { mHeaderLayout.setRefreshingLabel(refreshingLabel); } if (null != mFooterLayout && mode.canPullUp()) { mFooterLayout.setRefreshingLabel(refreshingLabel); } }
private Mode getUseMode(Attributes attributes) { String modeName = attributes.getValue("", "useMode"); if (modeName == null) modeName = DEFAULT_MODE_NAME; Mode mode = lookupCreateMode(modeName); if (mode.whereDefined == null && locator != null) mode.whereDefined = new LocatorImpl(locator); return mode; }
private boolean checkSupportedModes(Mode[] supportedMode) { boolean supported = false; for (Mode mode : supportedMode) { if (mode.equals(getMode())) { supported = true; break; } } return supported; }
/** * Maps an int to a specific mode. This is needed when saving state, or inflating the view from * XML where the mode is given through a attr int. * * @param modeInt - int to map a Mode to * @return Mode that modeInt maps to, or PULL_FROM_START by default. */ static Mode mapIntToValue(final int modeInt) { for (Mode value : Mode.values()) { if (modeInt == value.getIntValue()) { return value; } } // If not, return default return getDefault(); }
public void setReleaseLabel(String releaseLabel, Mode mode) { super.setReleaseLabel(releaseLabel, mode); if (null != mHeaderLoadingView && mode.canPullDown()) { mHeaderLoadingView.setReleaseLabel(releaseLabel); } if (null != mFooterLoadingView && mode.canPullUp()) { mFooterLoadingView.setReleaseLabel(releaseLabel); } }
@Override protected Parcelable onSaveInstanceState() { Bundle bundle = new Bundle(); bundle.putInt(STATE_STATE, mState); bundle.putInt(STATE_MODE, mMode.getIntValue()); bundle.putInt(STATE_CURRENT_MODE, mCurrentMode.getIntValue()); bundle.putBoolean(STATE_DISABLE_SCROLLING_REFRESHING, mDisableScrollingWhileRefreshing); bundle.putBoolean(STATE_SHOW_REFRESHING_VIEW, mShowViewWhileRefreshing); bundle.putParcelable(STATE_SUPER, super.onSaveInstanceState()); return bundle; }
/** * Set the drawable used in the loading layout. * * @param drawable - Drawable to display * @param mode - Controls which Header/Footer Views will be updated. <code>Mode.BOTH</code> will * update all available, other values will update the relevant View. */ public void setLoadingDrawable(Drawable drawable, Mode mode) { if (null != mHeaderLayout && mode.canPullDown()) { mHeaderLayout.setLoadingDrawable(drawable); } if (null != mFooterLayout && mode.canPullUp()) { mFooterLayout.setLoadingDrawable(drawable); } // The Loading Height may have changed, so refresh refreshLoadingViewsHeight(); }
/** * Performs an XSLT processing model match for the rule which matches the given Node the best. * * @param modeName is the name of the mode associated with the rule if any * @param node is the DOM4J Node to match against * @return the matching Rule or no rule if none matched */ public Rule getMatchingRule(String modeName, Node node) { Mode mode = modes.get(modeName); if (mode != null) { return mode.getMatchingRule(node); } else { System.out.println("Warning: No Mode for mode: " + mode); return null; } }
public void readFromParcel(Parcel in) { mName = in.readString(); mDefaultGroup = (Boolean) in.readValue(null); mSoundOverride = in.readParcelable(null); mRingerOverride = in.readParcelable(null); mSoundMode = Mode.valueOf(Mode.class, in.readString()); mRingerMode = Mode.valueOf(Mode.class, in.readString()); mVibrateMode = Mode.valueOf(Mode.class, in.readString()); mLightsMode = Mode.valueOf(Mode.class, in.readString()); }
@Override public void writeToParcel(Parcel dest, int flags) { dest.writeString(mName); dest.writeValue(mDefaultGroup); dest.writeParcelable(mSoundOverride, flags); dest.writeParcelable(mRingerOverride, flags); dest.writeString(mSoundMode.name()); dest.writeString(mRingerMode.name()); dest.writeString(mVibrateMode.name()); dest.writeString(mLightsMode.name()); }
@Override public final boolean demo() { if (mMode.showHeaderLoadingLayout() && isReadyForPullStart()) { smoothScrollToAndBack(-getHeaderSize() * 2); return true; } else if (mMode.showFooterLoadingLayout() && isReadyForPullEnd()) { smoothScrollToAndBack(getFooterSize() * 2); return true; } return false; }
public void removeRule(Rule rule) { Mode mode = getMode(rule.getMode()); Rule[] childRules = rule.getUnionRules(); if (childRules != null) { for (Rule childRule : childRules) { mode.removeRule(childRule); } } else { mode.removeRule(rule); } }