public String send(String host, final String port, String username, String password) { try { connector.setURL(SWProtocol.HTTP + host + ":" + port); int ping = connector.ping(username, password); ClientRM resources = new ClientRM("Connector"); if (ping < -2) { return resources.getLabel("cannotConnect"); } else if (ping == -2) { return resources.getLabel("incorrectUser"); } else if (ping == -1) { return resources.getLabel("incorrectPassword"); } else if (ping == 0) { return resources.getLabel("incorrectMode"); } StringBuilder builder = new StringBuilder(); String key = group + "." + category + "." + names[0]; HomepagesClientHandler client = new HomepagesClientHandler(); int total = client.loadTotalHomepages(group, category, names[0]); for (int i = 0; i < total; i++) { builder.setLength(0); String homepage = client.loadHomepages(group, category, names[0], i + 1); builder.append(key).append('\n').append(homepage); client.saveHomepages(connector, builder.toString()); } } catch (Exception e) { if (e.getMessage() != null && e.getMessage().trim().length() > 0) { return e.getMessage(); } return e.toString(); } return null; }
public DeleteContentsDialog(Browser _browser, String domain, String[] _ids, String[] titles) { this.domain = domain; this.browser = _browser; this.ids = _ids; shell = new Shell(browser.getShell(), SWT.CLOSE | SWT.RESIZE | SWT.APPLICATION_MODAL); ClientRM clientRM = DeleteDomainPlugin.getResources(); ApplicationFactory factory = new ApplicationFactory(shell, clientRM, getClass().getName()); shell.setText(factory.getLabel("title")); factory.setComposite(shell); shell.setLayout(new GridLayout(1, false)); shell.addShellListener( new ShellAdapter() { public void shellClosed(ShellEvent e) { new ShellSetter(DeleteContentsDialog.class, shell); shell.dispose(); } }); factory.setComposite(shell); RefsDecoder decoder = new RefsDecoder(); butTitles = new Button[titles.length]; // selectors = new DeleteSingleArticleSelector[10]; for (int i = 0; i < butTitles.length; i++) { titles[i] = new String(decoder.decode(titles[i].toCharArray())); butTitles[i] = new Button(shell, SWT.CHECK); butTitles[i].setSelection(true); butTitles[i].setToolTipText(clientRM.getLabel("itemDeleteTooltip")); butTitles[i].setText(titles[i]); butTitles[i].setLayoutData(new GridData()); } Composite bottom = new Composite(shell, SWT.NONE); GridData gridData = new GridData(GridData.FILL_HORIZONTAL); // gridData.horizontalSpan = 2; bottom.setLayoutData(gridData); RowLayout rowLayout = new RowLayout(); bottom.setLayout(rowLayout); rowLayout.justify = true; factory.setComposite(bottom); factory.createButton( "butDeletDomain", new SelectionAdapter() { public void widgetSelected(SelectionEvent evt) { deleteDomain(); } }); SelectionAdapter syncListener = new SelectionAdapter() { public void widgetSelected(SelectionEvent evt) { StringBuilder builder = new StringBuilder(); for (int i = 0; i < ids.length; i++) { if (!butTitles[i].getSelection()) continue; if (builder.length() > 0) builder.append('\n'); builder.append(ids[i]); } DeleteContentPlugin.delete(browser, builder.toString()); shell.dispose(); } }; factory.createButton("butOk", syncListener); factory.createButton( "butClose", new SelectionAdapter() { public void widgetSelected(SelectionEvent evt) { new ShellSetter(DeleteContentsDialog.class, shell); shell.dispose(); } }); Rectangle displayRect = UIDATA.DISPLAY.getBounds(); int x = (displayRect.width - 350) / 2; int y = (displayRect.height - 300) / 2; shell.setImage(browser.getShell().getImage()); new ShellGetter(DeleteContentsDialog.class, shell, 550, 350, x, y); shell.open(); }
public SynchronizedContentFilterPlugin() { filter = "/filter:2"; ClientRM resources = new ClientRM("Plugin"); Class<?> clazz = SynchronizedContentFilterPlugin.class; label = resources.getLabel(clazz.getName() + ".label"); }