List of usage examples for org.apache.commons.lang ArrayUtils indexOf
public static int indexOf(boolean[] array, boolean valueToFind)
Finds the index of the given value in the array.
From source file:org.talend.designer.core.ui.projectsetting.ElementParameter2ParameterType.java
/** * * load the Element's parameters to EMF Model * * @param elemParam/*from www. j a va 2s . com*/ * @param paType */ public static void loadElementParameters(Element elemParam, ParametersType paType, String repParamName) { if (paType == null || elemParam == null) { return; } EList listParamType = paType.getElementParameter(); ElementParameterType repositoryParam = null; if (repParamName != null && !repParamName.equals("")) { repositoryParam = findElementParameterType(paType, repParamName); } else { repositoryParam = findElementParameterType(paType, EParameterName.PROPERTY_TYPE.getName() + ":" + EParameterName.PROPERTY_TYPE.getName()); } IElementParameter statsDBType = null; IElementParameter implicitDBType = null; IElementParameter statsDBVersion = null; IElementParameter implicitDBVersion = null; Element defaultElement = getDefaultElement(paType); for (int j = 0; j < listParamType.size(); j++) { ElementParameterType pType = (ElementParameterType) listParamType.get(j); if (pType != null) { String pTypeName = pType.getName(); if (pTypeName != null && !"".equals(pTypeName)) { IElementParameter param = elemParam.getElementParameter(pTypeName); IElementParameter defalutParam = defaultElement.getElementParameter(pTypeName); if (defalutParam == null) { continue; } if (pTypeName.equals("DB_TYPE")) { //$NON-NLS-1$ statsDBType = param; } else if (pTypeName.equals("DB_VERSION")) { //$NON-NLS-1$ statsDBVersion = param; } else if (pTypeName.equals("DB_TYPE_IMPLICIT_CONTEXT")) { //$NON-NLS-1$ implicitDBType = param; } else if (pTypeName.equals("DB_VERSION_IMPLICIT_CONTEXT")) { //$NON-NLS-1$ implicitDBVersion = param; } if (param != null) { String name = param.getName(); param.setContextMode(pType.isContextMode()); if (param.isReadOnly() && !(EParameterName.UNIQUE_NAME.getName().equals(name) || EParameterName.VERSION.getName().equals(name))) { continue; // if the parameter is read only, don't load // it (this will prevent to overwrite the // value) } String value = null; if ("STATANDLOG_USE_PROJECT_SETTINGS".equals(name) //$NON-NLS-1$ || "IMPLICITCONTEXT_USE_PROJECT_SETTINGS".equals(name)) { //$NON-NLS-1$ Object value2 = param.getValue(); if (value2 != null) { value = value2.toString(); } } else { value = pType.getValue(); } if (param.getFieldType().equals(EParameterFieldType.CHECK) || param.getFieldType().equals(EParameterFieldType.RADIO)) { if (Boolean.FALSE.toString().equalsIgnoreCase(value) || Boolean.TRUE.toString().equalsIgnoreCase(value) || !pType.isContextMode()) { Boolean boolean1 = new Boolean(value); elemParam.setPropertyValue(pTypeName, boolean1); } else { elemParam.setPropertyValue(pTypeName, value); } // if (EParameterName.ACTIVATE.getName().equals(param.getName())) { // if ((elemParam instanceof Node) && !boolean1) { // ((Node) elemParam).setDummy(!boolean1); // } // } } else if (param.getFieldType().equals(EParameterFieldType.CLOSED_LIST)) { boolean valueSet = false; if (!ArrayUtils.contains(param.getListItemsValue(), value)) { if (ArrayUtils.contains(param.getListItemsDisplayName(), value)) { valueSet = true; int index = ArrayUtils.indexOf(param.getListItemsDisplayName(), value); if (index > -1) { elemParam.setPropertyValue(pTypeName, param.getListItemsValue()[index]); } } else if (value.equals("") && name != null && (name.equals("LOAD_NEW_VARIABLE") || name.equals("NOT_LOAD_OLD_VARIABLE"))) { valueSet = true; elemParam.setPropertyValue(pTypeName, param.getListItemsValue()[1]); } } if (!valueSet) { elemParam.setPropertyValue(pTypeName, value); } } else if (param.getFieldType().equals(EParameterFieldType.TABLE)) { List<Map<String, Object>> tableValues = new ArrayList<Map<String, Object>>(); String[] codeList = param.getListItemsDisplayCodeName(); Map<String, Object> lineValues = null; for (ElementValueType elementValue : (List<ElementValueType>) pType.getElementValue()) { boolean found = false; int length = codeList.length; if (length > 0) { for (int i = 0; i < length && !found; i++) { if (codeList[i].equals(elementValue.getElementRef())) { found = true; } } } IElementParameter tmpParam = null; for (Object o : param.getListItemsValue()) { if (o instanceof IElementParameter) { IElementParameter tableParam = (IElementParameter) o; if (tableParam.getName().equals(elementValue.getElementRef())) { tmpParam = tableParam; break; } } } if (found) { if ((lineValues == null) || (lineValues.get(elementValue.getElementRef()) != null)) { lineValues = new HashMap<String, Object>(); tableValues.add(lineValues); } String elemValue = elementValue.getValue(); if (tmpParam != null && EParameterFieldType.PASSWORD.equals(tmpParam.getFieldType())) { elemValue = elementValue.getRawValue(); } lineValues.put(elementValue.getElementRef(), elemValue); if (elementValue.getType() != null) { lineValues.put(elementValue.getElementRef() + IEbcdicConstant.REF_TYPE, elementValue.getType()); } } } elemParam.setPropertyValue(pTypeName, tableValues); } else if (param.getFieldType().equals(EParameterFieldType.PASSWORD)) { param.setValue(pType.getRawValue()); } else if (param.getFieldType().equals(EParameterFieldType.ENCODING_TYPE)) { // fix for bug 2193 boolean setToCustom = false; if (EmfComponent.REPOSITORY .equals(elemParam.getPropertyValue(EParameterName.PROPERTY_TYPE.getName())) && param.getRepositoryValue() != null && param.getRepositoryValue().equals("ENCODING")) { //$NON-NLS-1$ setToCustom = true; } String tempValue = null; IElementParameter iElementParameter = null; Map<String, IElementParameter> childParameters = param.getChildParameters(); if (childParameters != null) { iElementParameter = childParameters.get(EParameterName.ENCODING_TYPE.getName()); if (iElementParameter != null) { tempValue = (String) iElementParameter.getValue(); } } if (tempValue != null && !tempValue.equals(EmfComponent.ENCODING_TYPE_CUSTOM)) { tempValue = tempValue.replaceAll("'", ""); //$NON-NLS-1$ //$NON-NLS-2$ tempValue = tempValue.replaceAll("\"", ""); //$NON-NLS-1$ //$NON-NLS-2$ tempValue = TalendTextUtils.addQuotes(tempValue); if (!tempValue.equals(value)) { setToCustom = true; } } if (iElementParameter != null && setToCustom) { iElementParameter.setValue(EmfComponent.ENCODING_TYPE_CUSTOM); } elemParam.setPropertyValue(pTypeName, value); // end of fix for bug 2193 } else if (!param.getFieldType().equals(EParameterFieldType.SCHEMA_TYPE)) { if (param.getRepositoryValue() != null && !param.getFieldType().equals(EParameterFieldType.PROPERTY_TYPE)) { if (repositoryParam != null && EmfComponent.REPOSITORY.equals(repositoryParam.getValue())) { param.setRepositoryValueUsed(true); } else { param.setRepositoryValueUsed(false); } } elemParam.setPropertyValue(pTypeName, value); } } else if (UpdateTheJobsActionsOnTable.isClear && "CLEAR_TABLE".equals(pTypeName) //$NON-NLS-1$ && "true".equals(pType.getValue()) //$NON-NLS-1$ && "NONE".equals(elemParam.getElementParameter(Process.TABLE_ACTION).getValue())) { //$NON-NLS-1$ elemParam.setPropertyValue(Process.TABLE_ACTION, "CLEAR"); //$NON-NLS-1$ UpdateTheJobsActionsOnTable.isClear = false; } } } } // update combo list for dbversion if (statsDBType != null && statsDBVersion != null) { JobSettingVersionUtil.setDbVersion(statsDBVersion, String.valueOf(statsDBType.getValue()), String.valueOf(statsDBVersion.getValue())); } if (implicitDBType != null && implicitDBVersion != null) { JobSettingVersionUtil.setDbVersion(implicitDBVersion, String.valueOf(implicitDBType.getValue()), String.valueOf(implicitDBVersion.getValue())); } }
From source file:org.talend.designer.runprocess.bigdata.BigDataJavaProcessor.java
@Override protected void setValuesFromCommandline(String tp, String[] cmds) { super.setValuesFromCommandline(tp, cmds); String libJarStr = null;//from w w w. j ava 2s. c o m int libJarIndex = ArrayUtils.indexOf(cmds, ProcessorConstants.CMD_KEY_WORD_LIBJAR); if (libJarIndex > -1) { // found // return the cp values in the next index. libJarStr = cmds[libJarIndex + 1]; } if (Platform.OS_WIN32.equals(tp)) { this.windowsAddition = libJarStr; } else { String oldTargetPlatform = this.getTargetPlatform(); try { // because the cmds are from another processor, so must set the target platform same. setTargetPlatform(tp); // reuse the same api String unixRootPath = getRootWorkingDir(true); this.unixAddition = libJarStr.replace(unixRootPath, ""); // remove the Path root string } finally { setTargetPlatform(oldTargetPlatform); } } }
From source file:org.talend.designer.runprocess.java.AbstractJavaProcessor.java
protected String[] checkExecutingCommandsForRootPath(String path, String[] cmds, String argName) { if (isRunAsExport()) { // replace the variables like $ROOT_PATH int cpIndex = ArrayUtils.indexOf(cmds, argName); if (cpIndex > -1 && cmds.length > cpIndex + 1) { // found String cpStr = cmds[cpIndex + 1]; Path runDir = null;/*from w ww .j ava 2 s.com*/ // current path by default String userDir = System.getProperty("user.dir"); if (userDir != null) { runDir = new Path(userDir); //$NON-NLS-1$ } if (path != null && new File(path).exists()) { runDir = new Path(path); // unify via Path } if (runDir != null) { cpStr = cpStr.replace(ProcessorConstants.CMD_KEY_WORD_ROOTPATH, runDir.toString()); cmds[cpIndex + 1] = cpStr; // set back } } } return cmds; }
From source file:org.talend.designer.runprocess.java.JavaProcessorUtilities.java
private static void sortClasspath(Set<String> jobModuleList, IProcess process) throws CoreException, BusinessException { IClasspathEntry[] entries = javaProject.getRawClasspath(); IClasspathEntry jreClasspathEntry = JavaCore .newContainerEntry(new Path("org.eclipse.jdt.launching.JRE_CONTAINER")); //$NON-NLS-1$ IClasspathEntry classpathEntry = JavaCore .newSourceEntry(javaProject.getPath().append(JavaUtils.JAVA_SRC_DIRECTORY)); boolean changesDone = false; if (!ArrayUtils.contains(entries, jreClasspathEntry)) { entries = (IClasspathEntry[]) ArrayUtils.add(entries, jreClasspathEntry); changesDone = true;//from w ww . ja va 2 s .c o m } if (!ArrayUtils.contains(entries, classpathEntry)) { IClasspathEntry source = null; for (IClasspathEntry entry : entries) { if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) { source = entry; break; } } if (source != null) { entries = (IClasspathEntry[]) ArrayUtils.remove(entries, ArrayUtils.indexOf(entries, source)); } entries = (IClasspathEntry[]) ArrayUtils.add(entries, classpathEntry); changesDone = true; } // Added by Marvin Wang on Nov. 8, 2012. Maybe some modules are in the list with a directory, so cut the // directory only file name remaining. Set<String> listModulesReallyNeeded = ModuleNameExtractor.extractFileName(jobModuleList); Set<String> listModulesNeededByProcess = new HashSet<String>(); if (listModulesReallyNeeded != null && listModulesReallyNeeded.size() > 0) { for (String jobModule : listModulesReallyNeeded) { listModulesNeededByProcess.add(jobModule); } } Set<String> optionalJarsOnlyForRoutines = new HashSet<String>(); if (listModulesReallyNeeded == null) { listModulesReallyNeeded = new HashSet<String>(); } // only for wizards or additional jars only to make the java project compile without any error. for (ModuleNeeded moduleNeeded : ModulesNeededProvider .getModulesNeededForRoutines(ERepositoryObjectType.ROUTINES)) { optionalJarsOnlyForRoutines.add(moduleNeeded.getModuleName()); } if (ERepositoryObjectType.getType("BEANS") != null) { for (ModuleNeeded moduleNeeded : ModulesNeededProvider .getModulesNeededForRoutines(ERepositoryObjectType.getType("BEANS"))) { optionalJarsOnlyForRoutines.add(moduleNeeded.getModuleName()); } } for (ModuleNeeded moduleNeeded : ModulesNeededProvider .getModulesNeededForRoutines(ERepositoryObjectType.PIG_UDF)) { optionalJarsOnlyForRoutines.add(moduleNeeded.getModuleName()); } // list contains all routines linked to job as well as routines not used in the job // rebuild the list to have only the libs linked to routines "not used". optionalJarsOnlyForRoutines.removeAll(listModulesReallyNeeded); // at this point, the Set for optional jars really only contains optional jars for routines // only to be able to compile java project without error. for (String jar : optionalJarsOnlyForRoutines) { listModulesReallyNeeded.add(jar); } addLog4jToJarList(listModulesReallyNeeded); File libDir = getJavaProjectLibFolder(); if ((libDir != null) && (libDir.isDirectory())) { Set<String> jarsNeedRetrieve = new HashSet<String>(listModulesReallyNeeded); for (File externalLib : libDir.listFiles(FilesUtils.getAcceptJARFilesFilter())) { jarsNeedRetrieve.remove(externalLib.getName()); } List<IClasspathEntry> entriesToRemove = new ArrayList<IClasspathEntry>(); for (IClasspathEntry entry : entries) { if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) { boolean found = false; for (File externalLib : libDir.listFiles(FilesUtils.getAcceptJARFilesFilter())) { if (entry.getPath().toPortableString().endsWith(externalLib.getName())) { found = true; break; } } if (!found) { // jar not anymore in the lib path, need to update the classpath entriesToRemove.add(entry); } } } for (IClasspathEntry entry : entriesToRemove) { entries = (IClasspathEntry[]) ArrayUtils.remove(entries, ArrayUtils.indexOf(entries, entry)); changesDone = true; } if (!jarsNeedRetrieve.isEmpty()) { // get original context value Set<String> originalConexts = new HashSet<String>(); Iterator<String> iterator = jarsNeedRetrieve.iterator(); while (iterator.hasNext()) { String jarNeedRetrieve = iterator.next(); if (ContextParameterUtils.isContainContextParam(jarNeedRetrieve) && process instanceof IProcess2) { iterator.remove(); // remove the context one. IContext lastRunContext = ((IProcess2) process).getLastRunContext(); if (lastRunContext != null) { String contextValue = ContextParameterUtils.parseScriptContextCode(jarNeedRetrieve, lastRunContext); if (contextValue != null) { originalConexts.add(new File(contextValue).getName()); } } else { IContextManager contextManager = process.getContextManager(); if (contextManager != null) { String contextValue = ContextParameterUtils.parseScriptContextCode(jarNeedRetrieve, contextManager.getDefaultContext()); if (contextValue != null) { originalConexts.add(new File(contextValue).getName()); } } } } } jarsNeedRetrieve.addAll(originalConexts); ILibraryManagerService repositoryBundleService = CorePlugin.getDefault() .getRepositoryBundleService(); repositoryBundleService.retrieve(jarsNeedRetrieve, libDir.getAbsolutePath()); if (process instanceof IProcess2) { ((IProcess2) process).checkProcess(); } } for (File externalLib : libDir.listFiles(FilesUtils.getAcceptJARFilesFilter())) { if (externalLib.isFile() && listModulesReallyNeeded.contains(externalLib.getName())) { IClasspathEntry newEntry = JavaCore.newLibraryEntry(new Path(externalLib.getAbsolutePath()), null, null); if (!ArrayUtils.contains(entries, newEntry)) { entries = (IClasspathEntry[]) ArrayUtils.add(entries, newEntry); changesDone = true; } } } } String missingJars = null; // String missingJarsForRoutinesOnly = null; Set<String> missingJarsForRoutinesOnly = new HashSet<String>(); Set<String> missingJarsForProcessOnly = new HashSet<String>(); // sort int exchange = 2; // The first,second library is JVM and SRC. for (String jar : listModulesReallyNeeded) { int index = indexOfEntry(entries, jar); if (index < 0) { if (ContextParameterUtils.isContainContextParam(jar)) { continue; } if (listModulesNeededByProcess.contains(jar)) { missingJarsForProcessOnly.add(jar); } else { missingJarsForRoutinesOnly.add(jar); } if (missingJars == null) { missingJars = Messages.getString("JavaProcessorUtilities.msg.missingjar.forProcess") + jar; //$NON-NLS-1$ } else { missingJars = missingJars + ", " + jar; //$NON-NLS-1$ } } else { if (index != exchange) { // exchange IClasspathEntry entry = entries[index]; IClasspathEntry first = entries[exchange]; entries[index] = first; entries[exchange] = entry; changesDone = true; } exchange++; } } if (changesDone) { javaProject.setRawClasspath(entries, null); javaProject.setOutputLocation(javaProject.getPath().append(JavaUtils.JAVA_CLASSES_DIRECTORY), null); } if (missingJars != null) { handleMissingJarsForProcess(missingJarsForRoutinesOnly, missingJarsForProcessOnly, missingJars); } }
From source file:org.talend.designer.runprocess.maven.MavenJavaProcessor.java
protected void setValuesFromCommandline(String tp, String[] cmds) { if (cmds == null || cmds.length == 0) { return;//w w w . j ava 2 s .c o m } String cpStr = null; int cpIndex = ArrayUtils.indexOf(cmds, JavaUtils.JAVA_CP); if (cpIndex > -1) { // found // return the cp values in the next index. cpStr = cmds[cpIndex + 1]; } if (Platform.OS_WIN32.equals(tp)) { this.windowsClasspath = cpStr; } else { this.unixClasspath = cpStr; } }
From source file:org.talend.designer.runprocess.ui.views.ProcessView.java
private EComponentCategory[] getCategories() { EComponentCategory[] categories = EElementType.RUN_PROCESS.getCategories(); if (processContext != null && processContext.getProcess() != null) { if (processContext.getProcess().getComponentsType() .equals(ComponentCategory.CATEGORY_4_MAPREDUCE.getName())) { categories = (EComponentCategory[]) ArrayUtils.remove(categories, ArrayUtils.indexOf(categories, EComponentCategory.DEBUGRUN)); categories = (EComponentCategory[]) ArrayUtils.add(categories, 1, EComponentCategory.MAPREDUCE_JOB_CONFIG_FOR_HADOOP); }/*from w w w. ja v a2 s. c om*/ if (processContext.getProcess().getComponentsType() .equals(ComponentCategory.CATEGORY_4_STORM.getName())) { categories = (EComponentCategory[]) ArrayUtils.add(categories, 1, EComponentCategory.STORM_JOB_CONFIG); } if (processContext.getProcess().getComponentsType().equals(ComponentCategory.CATEGORY_4_SPARK.getName()) || processContext.getProcess().getComponentsType() .equals(ComponentCategory.CATEGORY_4_SPARKSTREAMING.getName())) { categories = (EComponentCategory[]) ArrayUtils.add(categories, 1, EComponentCategory.SPARK_JOB_CONFIG); } } return categories; }
From source file:org.talend.rcp.intro.linksbar.TalendCoolBarManager.java
@Override public void refresh() { IContributionItem linksCoolItem = find(TalendActionBarPresentationFactory.COOLITEM_LINKS_ID); int index = ArrayUtils.indexOf(getItems(), linksCoolItem); if (index != (getItems().length - 1)) { // if the coolbar is not the latest, just force to move to last one again. // don't deal with the case index = 0 and only have this one, since it's impossible ! if (linksCoolItem != null) { remove(linksCoolItem);/*www . j a va 2 s. c o m*/ add(linksCoolItem); } } super.refresh(); }
From source file:org.wandora.application.tools.server.HTTPServerTool.java
@Override public void execute(Wandora wandora, Context context) throws TopicMapException { if ((mode & CONFIGURE) != 0) { WandoraModulesServer server = wandora.getHTTPServer(); String u = null; //s.getLoginUser(); String p = null; //s.getLoginPassword(); if (u == null) u = ""; if (p == null) p = ""; String[] logLevels = { "trace", "debug", "info", "warn", "error", "fatal", "none" }; GenericOptionsDialog god = new GenericOptionsDialog(wandora, "Wandora HTTP server settings", "Wandora HTTP server settings", true, new String[][] { new String[] { "Auto start", "boolean", "" + server.isAutoStart(), "Start server automatically when you start Wandora" }, new String[] { "Port", "string", "" + server.getPort(), "Port the server is listening to" }, new String[] { "Local only", "boolean", "" + server.isLocalOnly(), "Allow only local connections" }, new String[] { "Use SSL", "boolean", "" + server.isUseSSL(), "Should server use SSL" }, new String[] { "Keystore location", "string", "" + server.getKeystoreFile(), "Where SSL keystore file locates? Keystore is used only if you have selected to use SLL." }, new String[] { "Keystore password", "string", "" + server.getKeystorePassword(), "Keystore's password. Keystore is used only if you have selected to use SLL." }, // new String[]{"User name","string",u,"User name. Leave empty for anonymous login"}, // new String[]{"Password","password",p,"Password for the user if user name field is used"}, new String[] { "Server path", "string", server.getServerPath(), "Path where Wandora web apps are deployed" }, // new String[]{"Static content path","string",s.getStaticPath(),"Path where static files are located"}, // new String[]{"Template path","string",s.getTemplatePath(),"Path where Velocity templates are located"}, // new String[]{"Template","string",s.getTemplateFile(),"Template file used to create a topic page"}, new String[] { "Log level", "combo:" + StringUtils.join(logLevels, ";"), logLevels[server.getLogLevel()], "Lowest level of log messages that are printed" }, }, wandora);// w ww. jav a 2 s .co m god.setSize(800, 400); if (wandora != null) wandora.centerWindow(god); god.setVisible(true); if (god.wasCancelled()) return; boolean running = server.isRunning(); if (running) server.stopServer(); Map<String, String> values = god.getValues(); server.setAutoStart(Boolean.parseBoolean(values.get("Auto start"))); server.setPort(Integer.parseInt(values.get("Port"))); server.setLocalOnly(Boolean.parseBoolean(values.get("Local only"))); server.setUseSSL(Boolean.parseBoolean(values.get("Use SSL"))); server.setKeystoreFile(values.get("Keystore location")); server.setKeystorePassword(values.get("Keystore password")); // server.setLogin(values.get("User name"),values.get("Password")); // server.setStaticPath(values.get("Static content path")); // server.setTemplatePath(values.get("Template path")); // server.setTemplateFile(values.get("Template")); server.setServerPath(values.get("Server path")); server.setLogLevel(ArrayUtils.indexOf(logLevels, values.get("Log level"))); server.writeOptions(wandora.getOptions()); server.initModuleManager(); server.readBundleDirectories(); if (running) server.start(); wandora.menuManager.refreshServerMenu(); } if ((mode & START) != 0) { wandora.startHTTPServer(); } else if ((mode & STOP) != 0) { wandora.stopHTTPServer(); } if ((mode & UPDATE_MENU) != 0) { wandora.menuManager.refreshServerMenu(); } if ((mode & OPEN_PAGE) != 0) { try { if (!wandora.getHTTPServer().isRunning()) { int a = WandoraOptionPane.showConfirmDialog(wandora, "HTTP server is not running at the moment. Would you like to start the server first?", "Start HTTP server?", WandoraOptionPane.OK_CANCEL_OPTION); if (a == WandoraOptionPane.OK_OPTION) { wandora.startHTTPServer(); wandora.menuManager.refreshServerMenu(); } else if (a == WandoraOptionPane.CANCEL_OPTION) { return; } } WandoraModulesServer s = wandora.getHTTPServer(); String uri = (s.isUseSSL() ? "https" : "http") + "://127.0.0.1:" + s.getPort() + "/topic"; if (forceUrl != null) uri = forceUrl; else if (webApp != null) { uri = webApp.getAppStartPage(); if (uri == null) { WandoraOptionPane.showMessageDialog(wandora, "Can't launch selected webapp. Webapp says it's URI is null."); return; } } try { Desktop desktop = Desktop.getDesktop(); desktop.browse(new URI(uri)); } catch (Exception e) { log(e); } } catch (Exception e) { wandora.handleError(e); } } if ((mode & OPEN_PAGE_IN_BROWSER_TOPIC_PANEL) != 0) { try { if (!wandora.getHTTPServer().isRunning()) { int a = WandoraOptionPane.showConfirmDialog(wandora, "HTTP server is not running at the moment. Would you like to start the server first?", "Start HTTP server?", WandoraOptionPane.OK_CANCEL_OPTION); if (a == WandoraOptionPane.OK_OPTION) { wandora.startHTTPServer(); wandora.menuManager.refreshServerMenu(); } } WandoraModulesServer s = wandora.getHTTPServer(); String uri = (s.isUseSSL() ? "https" : "http") + "://127.0.0.1:" + s.getPort() + "/topic"; if (forceUrl != null) uri = forceUrl; else if (webApp != null) { uri = webApp.getAppStartPage(); if (uri == null) { WandoraOptionPane.showMessageDialog(wandora, "Can't launch selected webapp. Webapp says it's URI is null."); return; } } try { if (param2 != null) { if (param2 instanceof WebViewPanel) { WebViewPanel browserTopicPanel = (WebViewPanel) param2; browserTopicPanel.browse(uri); } } } catch (Exception e) { log(e); } } catch (Exception e) { wandora.handleError(e); } } }
From source file:org.zaproxy.zap.extension.accessControl.view.AccessControlScanOptionsDialog.java
@Override public void save() { // In this case, the 'Save' action corresponds to starting a scan with the specified options AccessControlScanStartOptions startOptions = new AccessControlScanStartOptions(); startOptions.targetContext = ((ContextSelectComboBox) getField(FIELD_CONTEXT)).getSelectedContext(); startOptions.targetUsers = usersSelectTable.getSelectedUsers(); // If the un-authenticated user was selected, replace it with a 'null' user if (startOptions.targetUsers.remove(unauthenticatedUser)) { startOptions.targetUsers.add(null); }//from w w w .ja v a 2 s .co m startOptions.raiseAlerts = ((JCheckBox) getField(FIELD_RAISE_ALERTS)).isSelected(); // Just to make sure we have a reference here to MSG_RISK for taking care when refactoring // and that this still works if somehow the connection between index and value is lost, we // perform a quick search @SuppressWarnings("unchecked") String selectedAlertRisk = (String) ((JComboBox<String>) getField(FIELD_ALERTS_RISK)).getSelectedItem(); startOptions.alertRiskLevel = ArrayUtils.indexOf(Alert.MSG_RISK, selectedAlertRisk); extension.startScan(startOptions); }
From source file:org.zaproxy.zap.view.widgets.UsersListModel.java
/** * Returns the index of the specified element in the model's item list. * //from w w w . java 2s . c o m * @param object the element. * @return The index of the specified element in the model's item list, or -1 if it wasn't * found */ public int getIndexOf(Object object) { int index = tableModel.getUsers().indexOf(object); if (index < 0 && customUsers != null) return tableModel.getUsers().size() + ArrayUtils.indexOf(customUsers, object); return index; }