private MethodTree m(TreeMaker make) { // create method modifiers ModifiersTree parMods = make.Modifiers(Collections.<Modifier>emptySet(), Collections.<AnnotationTree>emptyList()); // create parameters VariableTree par1 = make.Variable(parMods, "a", make.PrimitiveType(TypeKind.INT), null); VariableTree par2 = make.Variable(parMods, "b", make.PrimitiveType(TypeKind.FLOAT), null); List<VariableTree> parList = new ArrayList<VariableTree>(2); parList.add(par1); parList.add(par2); // create method MethodTree newMethod = make.Method( make.Modifiers( Collections.singleton(Modifier.PUBLIC), // modifiers Collections.<AnnotationTree>emptyList() // annotations ), // modifiers and annotations "newlyCreatedMethod", // name make.PrimitiveType(TypeKind.VOID), // return type Collections.<TypeParameterTree>emptyList(), // type parameters for parameters parList, // parameters Collections.singletonList(make.Identifier("java.io.IOException")), // throws make.Block(Collections.<StatementTree>emptyList(), false), // empty statement block null // default value - not applicable here, used by annotations ); return newMethod; }
@SuppressWarnings({ "deprecation", "unchecked" }) public SNSUserInfo getUserInfo(String accessToken,String openId){ logger.info("getUserInfo accessToken : {} , openId : {} ", accessToken, openId); SNSUserInfo user = null; String requestUrl = userinfo_url.replace("OPENID", openId).replace("ACCESS_TOKEN", accessToken); JSONObject jsonObject = CommonUtil.httpsRequest(requestUrl, "GET", null); if(null != jsonObject){ // logger.info("授权返回JSONObject 数据 : " + com.meidusa.fastjson.JSONObject.toJSONString(jsonObject)); logger.info("授权返回JSONObject 数据 : Key : {}, values : {} " ,com.alibaba.fastjson.JSONObject.toJSONString(jsonObject.keySet()), com.alibaba.fastjson.JSONObject.toJSONString(jsonObject.values())); try{ user = new SNSUserInfo(); user.setOpenId(jsonObject.getString("openid")); user.setNickname(jsonObject.getString("nickname")); user.setSex(jsonObject.getInt("sex")); user.setProvince(jsonObject.getString("province")); user.setCity(jsonObject.getString("city")); user.setCountry(jsonObject.getString("country")); user.setHeadimgurl(jsonObject.getString("headimgurl")); user.setPrivilegeList(JSONArray.toList(jsonObject.getJSONArray("privilege"), List.class)); }catch(Exception e){ logger.error("网页授权获取用户信息失败 " + e.getMessage()); user = null; int errCode = jsonObject.getInt("errcode"); String errMsg = jsonObject.getString("errmsg"); logger.error("网页授权获取用户信息失败 errCode : {} , errmsg : {} ", errCode,errMsg); } } logger.info("getUserInfo => 返回 : " + com.alibaba.fastjson.JSONObject.toJSONString(user)); return user; }
private Panel layoutWhoPanel() { Panel panel = new Panel(); panel.setLayout(new BorderLayout()); panel.add("North", new Label("Who's On:")); panel.add("Center", zPeersList = new List(25, false)); zPeersList.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { String lineRest = e.getActionCommand(); int spaceAt = lineRest.indexOf(' '); if (spaceAt != -1) handlePrivateMessageWindowRequest(lineRest.substring(0, spaceAt)); zChatText.requestFocus(); } } ); return panel; }
public static void main(final String[] args) throws HeadlessException { final Frame frame = new Frame("Test Frame"); final List list = new List(); frame.setSize(300, 200); list.add(ITEM_NAME); list.select(0); frame.add(list); frame.validate(); frame.setVisible(true); sleep(); if (!ITEM_NAME.equals(list.getSelectedItem())) { throw new RuntimeException("List item not selected item."); } list.removeAll(); frame.dispose(); }
public ActionEventTest() { try { robot = new Robot(); robot.setAutoDelay(100); robot.setAutoWaitForIdle(true); } catch(AWTException e) { throw new RuntimeException(e.getMessage()); } list = new List(1, false); list.add("0"); add(list); setSize(400,400); setLayout(new FlowLayout()); pack(); setVisible(true); }
public ItemEventTest() { try { robot = new Robot(); } catch(AWTException e) { throw new RuntimeException(e.getMessage()); } expectedSelectionOrder = "01230123"; list = new List(4, true); list.add("0"); list.add("1"); list.add("2"); list.add("3"); add(list); setSize(400,400); setLayout(new FlowLayout()); pack(); setVisible(true); robot.waitForIdle(); }
@Override public boolean checkComponent(Component comp) { if (comp instanceof List) { if (label == null) { return true; } if (((List) comp).getItemCount() > itemIndex) { int ii = itemIndex; if (ii == -1) { ii = ((List) comp).getSelectedIndex(); if (ii == -1) { return false; } } return (comparator.equals(((List) comp).getItem(ii), label)); } } return false; }
public ActionEventTest() { try { robot = new Robot(); } catch(AWTException e) { throw new RuntimeException(e.getMessage()); } list = new List(1, false); list.add("0"); add(list); setSize(400,400); setLayout(new FlowLayout()); pack(); setVisible(true); robot.waitForIdle(); }
public void init () { initted = true; Panel p = new Panel (); p.setLayout (new GridLayout (3, 1)); List l = new List (5, true); for (int i = 0; i < 10; i++) l.add ("List item " + i); p.add (l); add (p, "Center"); Button cb = new Button ("Close"); cb.addActionListener(new ActionListener () { public void actionPerformed (ActionEvent e) { dispose(); } }); add (cb, "South"); setTitle ("List"); pack(); }
protected void setup() { super.setup(); List o = (List)owner; // Multiple selection setMultipleMode(o.isMultipleMode()); // Add initial list items. String[] items = o.getItems(); for (int i = 0; i < items.length; i++) add(items[i], i); // Initial selections. int[] selected = o.getSelectedIndexes(); for (int i = 0; i < selected.length; i++) select(selected[i]); // If no initial selection, use 0. if(selected.length == 0 && items.length > 0) select( 0 ); }
/** * Called back when a row is selected. -1 if no row is selected. */ private void fireChoice( int index ) { ignoreNextSelect = true; if( index == -1) ((List)owner).deselect( ((List)owner).getSelectedIndex() ); else { ((List)owner).select( index ); ItemEvent e = new ItemEvent((List)owner, ItemEvent.ITEM_STATE_CHANGED, ""+index, ItemEvent.SELECTED); QtToolkit.eventQueue.postEvent(e); } }
public void testDocSynchronizerPrefersLineBoundaryChanges() throws Exception { String text = "import java.awt.List;\n" + "[import java.util.ArrayList;\n]" + "import java.util.HashMap;\n" + "import java.util.Map;"; RangeMarker marker = createMarker(text); synchronizer.startTransaction(getProject(), document, psiFile); String newText = StringUtil.replaceSubstring(document.getText(), TextRange.create(marker), ""); synchronizer.replaceString(document, 0, document.getTextLength(), newText); final List<DocumentEvent> events = new ArrayList<DocumentEvent>(); document.addDocumentListener(new DocumentAdapter() { @Override public void documentChanged(DocumentEvent e) { events.add(e); } }); synchronizer.commitTransaction(document); assertEquals(newText, document.getText()); DocumentEvent event = assertOneElement(events); assertEquals("DocumentEventImpl[myOffset=22, myOldLength=28, myNewLength=0, myOldString='import java.util.ArrayList;\n', myNewString=''].", event.toString()); }
public void testRangeHighlighterLinesInRangeForLongLinePerformance() throws Exception { final int N = 50000; Document document = EditorFactory.getInstance().createDocument(StringUtil.repeatSymbol('x', 2 * N)); final MarkupModelEx markupModel = (MarkupModelEx)DocumentMarkupModel.forDocument(document, ourProject, true); for (int i=0; i<N-1;i++) { markupModel.addRangeHighlighter(2*i, 2*i+1, 0, null, HighlighterTargetArea.EXACT_RANGE); } markupModel.addRangeHighlighter(N / 2, N / 2 + 1, 0, null, HighlighterTargetArea.LINES_IN_RANGE); PlatformTestUtil.startPerformanceTest("slow highlighters lookup", (int)(N*Math.log(N)/1000), new ThrowableRunnable() { @Override public void run() { List<RangeHighlighterEx> list = new ArrayList<RangeHighlighterEx>(); CommonProcessors.CollectProcessor<RangeHighlighterEx> coll = new CommonProcessors.CollectProcessor<RangeHighlighterEx>(list); for (int i=0; i<N-1;i++) { list.clear(); markupModel.processRangeHighlightersOverlappingWith(2*i, 2*i+1, coll); assertEquals(2, list.size()); // 1 line plus one exact range marker } } }).assertTiming(); }
/** @return Propertydescriptors */ @Override protected PropertyDescriptor[] createPDs() throws IntrospectionException { return new PropertyDescriptor[] { new PropertyDescriptor("multipleMode", List.class), // NOI18N }; }
@Override public final ListPeer createList(List target) { PlatformComponent platformComponent = createPlatformComponent(); LWListPeer peer = new LWListPeer(target, platformComponent); targetCreatedPeer(target, peer); peer.initialize(); return peer; }
public static void main(String[] args) throws IntrospectionException { if (getLength(com.foo.test.Component.class) == getLength(Component.class)) { throw new Error("test failed for Component"); } if (getLength(java.util.List.class) == getLength(List.class)) { throw new Error("test failed for List"); } }
public static void main(String[] args) { // ensure that 4168475 does not regress test4168475(Component.class); // AWT classes (com.sun.beans.infos.ComponentBeanInfo) test(null, Button.class, Component.class, List.class, Menu.class, Panel.class); // Swing classes (dt.jar) test(null, JApplet.class, JButton.class, JCheckBox.class); // user defined classes test(Boolean.TRUE, Wombat.class, Foo.class, FooBar.class); }
@Override public boolean handleEvent(Event e) { if (e.target instanceof List) { if (e.id == Event.LIST_DESELECT || e.id == Event.LIST_SELECT) { actualSelectionOrder.append(e.arg); } } return true; }
@Override public Hashtable<String, Object> getDump() { Hashtable<String, Object> result = super.getDump(); addToDump(result, ITEM_PREFIX_DPROP, ((List) getSource()).getItems()); addToDump(result, SELECTED_ITEM_PREFIX_DPROP, ((List) getSource()).getSelectedItems()); return result; }
/** * Maps {@code List.addActionListener(ActionListener)} through queue */ public void addActionListener(final ActionListener actionListener) { runMapping(new MapVoidAction("addActionListener") { @Override public void map() { ((List) getSource()).addActionListener(actionListener); } }); }
/** * Maps {@code List.addItemListener(ItemListener)} through queue */ public void addItemListener(final ItemListener itemListener) { runMapping(new MapVoidAction("addItemListener") { @Override public void map() { ((List) getSource()).addItemListener(itemListener); } }); }
/** * Maps {@code List.deselect(int)} through queue */ public void deselect(final int i) { runMapping(new MapVoidAction("deselect") { @Override public void map() { ((List) getSource()).deselect(i); } }); }
/** * Maps {@code List.getItem(int)} through queue */ public String getItem(final int i) { return (runMapping(new MapAction<String>("getItem") { @Override public String map() { return ((List) getSource()).getItem(i); } })); }
/** * Maps {@code List.getItemCount()} through queue */ public int getItemCount() { return (runMapping(new MapIntegerAction("getItemCount") { @Override public int map() { return ((List) getSource()).getItemCount(); } })); }
/** * Maps {@code List.getItems()} through queue */ public String[] getItems() { return ((String[]) runMapping(new MapAction<Object>("getItems") { @Override public Object map() { return ((List) getSource()).getItems(); } })); }
/** * Maps {@code List.getMinimumSize(int)} through queue */ public Dimension getMinimumSize(final int i) { return (runMapping(new MapAction<Dimension>("getMinimumSize") { @Override public Dimension map() { return ((List) getSource()).getMinimumSize(i); } })); }
/** * Maps {@code List.getPreferredSize(int)} through queue */ public Dimension getPreferredSize(final int i) { return (runMapping(new MapAction<Dimension>("getPreferredSize") { @Override public Dimension map() { return ((List) getSource()).getPreferredSize(i); } })); }
/** * Maps {@code List.getRows()} through queue */ public int getRows() { return (runMapping(new MapIntegerAction("getRows") { @Override public int map() { return ((List) getSource()).getRows(); } })); }
/** * Maps {@code List.getSelectedIndex()} through queue */ public int getSelectedIndex() { return (runMapping(new MapIntegerAction("getSelectedIndex") { @Override public int map() { return ((List) getSource()).getSelectedIndex(); } })); }
/** * Maps {@code List.getSelectedIndexes()} through queue */ public int[] getSelectedIndexes() { return ((int[]) runMapping(new MapAction<Object>("getSelectedIndexes") { @Override public Object map() { return ((List) getSource()).getSelectedIndexes(); } })); }