protected void createServerSelectionControl(Composite parent) { Group group = new Group(parent, SWT.NONE); group.setText(PHPServerUIMessages.getString("ServerTab.server")); // $NON-NLS-1$ GridLayout ly = new GridLayout(1, false); ly.marginHeight = 0; ly.marginWidth = 0; group.setLayout(ly); group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); Composite phpServerComp = new Composite(group, SWT.NONE); phpServerComp.setLayout(new GridLayout(4, false)); phpServerComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); phpServerComp.setFont(parent.getFont()); Label label = new Label(phpServerComp, SWT.WRAP); GridData data = new GridData(GridData.BEGINNING); data.widthHint = 100; label.setLayoutData(data); label.setFont(parent.getFont()); label.setText(PHPServerUIMessages.getString("ServerLaunchConfigurationTab.0")); // $NON-NLS-1$ serverCombo = new Combo(phpServerComp, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY); serverCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); serverCombo.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { handleServerSelection(); } }); createNewServer = createPushButton( phpServerComp, PHPServerUIMessages.getString("ServerTab.new"), null); // $NON-NLS-1$ createNewServer.addSelectionListener(fListener); configureServers = createPushButton( phpServerComp, PHPServerUIMessages.getString("ServerTab.configure"), null); //$NON-NLS-1$ configureServers.addSelectionListener(fListener); servers = new ArrayList<Server>(); populateServerList(servers); // initialize the servers list if (!servers.isEmpty()) { for (int i = 0; i < servers.size(); i++) { Server svr = servers.get(i); serverCombo.add(svr.getName()); } } // select first item in list if (serverCombo.getItemCount() > 0) { serverCombo.select(0); } serverCombo.forceFocus(); }
/** * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(ILaunchConfigurationWorkingCopy) */ public void performApply(ILaunchConfigurationWorkingCopy configuration) { if (server != null) { configuration.setAttribute(Server.NAME, server.getName()); } else { configuration.setAttribute(Server.NAME, (String) null); } String fileName = fFile.getText(); String urlPath = fURLPath.getText().replace('\\', '/'); if (urlPath.startsWith("/")) { // $NON-NLS-1$ urlPath = urlPath.substring(1); } String url = fURLHost.getText() + urlPath; configuration.setAttribute(Server.FILE_NAME, fileName); configuration.setAttribute(Server.BASE_URL, url); configuration.setAttribute(AUTO_GENERATED_URL, autoGeneratedURL.getSelection()); try { updateURLEnabled(configuration); } catch (CoreException e) { PHPDebugPlugin.log(e); } applyExtension(configuration); if (saveWorkingCopy) { try { configuration.doSave(); } catch (CoreException e) { } saveWorkingCopy = false; } applyLaunchDelegateConfiguration(configuration); }
protected void initializeServerControl(ILaunchConfiguration configuration) { try { String serverName = configuration.getAttribute(Server.NAME, ""); // $NON-NLS-1$ if (serverName != null && !serverName.equals("")) { // $NON-NLS-1$ server = ServersManager.getServer(serverName); if (server == null) { // server no longer exists setErrorMessage( PHPServerUIMessages.getString("ServerTab.invalidServerError")); // $NON-NLS-1$ selectDefaultServer(configuration); } else { serverCombo.setText(server.getName()); } } else { selectDefaultServer(configuration); } // flag should only be set if launch has been attempted on the // config if (configuration.getAttribute(READ_ONLY, false)) { serverCombo.setEnabled(false); } boolean enabled = configuration.getAttribute(SERVER_ENABLED, true); serverCombo.setEnabled(enabled); createNewServer.setEnabled(enabled); } catch (Exception e) { } }
/* * Select the default server. */ private void selectDefaultServer(ILaunchConfiguration configuration) throws CoreException { if (serverCombo != null && serverCombo.getItemCount() > 0) { // Select the default server String projectName = configuration.getAttribute(IPHPDebugConstants.PHP_Project, (String) null); IProject project = null; if (projectName != null) { project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); } Server defaultServer = ServersManager.getDefaultServer(project); int nameIndex = serverCombo.indexOf(defaultServer.getName()); if (nameIndex > -1) { serverCombo.select(nameIndex); } else { serverCombo.select(0); } server = ServersManager.getServer(serverCombo.getText()); } }
protected void handleConfigureButtonSelected() { int selectionIndex = serverCombo.getSelectionIndex(); Server server = servers.get(selectionIndex); String serverName = server.getName(); Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); NullProgressMonitor monitor = new NullProgressMonitor(); ServerEditDialog dialog = new ServerEditDialog(shell, server); if (dialog.open() == Window.CANCEL) { monitor.setCanceled(true); return; } ServersManager.save(); String newName = server.getName(); if (!newName.equals(serverName)) { serverCombo.remove(selectionIndex); serverCombo.add(newName, selectionIndex); serverCombo.select(selectionIndex); } saveWorkingCopy = true; handleServerSelection(); }
/** * Constructs the URL string according to the given context root and the file name. * * @param fileName * @return */ protected String computeURL(String fileName) { if (server == null) { return ""; //$NON-NLS-1$ } String urlString = server.getBaseURL(); if (urlString.equals("")) { // $NON-NLS-1$ urlString = "http://localhost"; // $NON-NLS-1$ } StringBuffer url = new StringBuffer(urlString); if (!fileName.equals("")) { // $NON-NLS-1$ url.append(fileName); } return url.toString(); }
/* * (non-Javadoc) * * @seeorg.eclipse.php.internal.debug.core.debugger.parameters. * IDebugParametersInitializer * #generateQueryParameters(org.eclipse.debug.core.ILaunch) */ public Hashtable<String, String> getDebugParameters(ILaunch launch) { Hashtable<String, String> parameters = new Hashtable<String, String>(); ILaunchConfiguration launchConfiguration = launch.getLaunchConfiguration(); parameters.put(START_DEBUG, "1"); // $NON-NLS-1$ String port = launch.getAttribute(IDebugParametersKeys.PORT); if (port != null) { parameters.put(DEBUG_PORT, port); } else { PHPDebugPlugin.logErrorMessage( "A port was not defined for the DefaultDebugParametersInitializer."); //$NON-NLS-1$ } if (getBooleanValue(launch.getAttribute(IDebugParametersKeys.PASSIVE_DEBUG))) { parameters.put(DEBUG_PASSIVE, "1"); // $NON-NLS-1$ } parameters.put(SEND_SESS_END, "1"); // $NON-NLS-1$ if (getBooleanValue(launch.getAttribute(IDebugParametersKeys.WEB_SERVER_DEBUGGER))) { String debugHosts = PHPDebugPlugin.getDebugHosts(); // Set up custom server debug hosts if any if (launchConfiguration != null) { try { Server server = ServersManager.getServer( launchConfiguration.getAttribute(Server.NAME, "")); // $NON-NLS-1$ String customHosts = ZendDebuggerSettingsUtil.getDebugHosts(server.getUniqueId()); if (!customHosts.isEmpty()) debugHosts = customHosts; } catch (CoreException ce) { Logger.logException(ce); } } parameters.put(DEBUG_HOST, debugHosts); parameters.put(DEBUG_NO_CACHE, Long.toString(System.currentTimeMillis())); } if (ILaunchManager.DEBUG_MODE.equals(launch.getLaunchMode()) && getBooleanValue(launch.getAttribute(IDebugParametersKeys.FIRST_LINE_BREAKPOINT))) { parameters.put(DEBUG_STOP, "1"); // $NON-NLS-1$ } String url = launch.getAttribute(IDebugParametersKeys.ORIGINAL_URL); if (url != null) { parameters.put(ORIGINAL_URL, url); } if (launchConfiguration != null) { try { String sessionSetting = launchConfiguration.getAttribute( IPHPDebugConstants.DEBUGGING_PAGES, IPHPDebugConstants.DEBUGGING_ALL_PAGES); if (IPHPDebugConstants.DEBUGGING_ALL_PAGES.equals(sessionSetting)) { parameters.put(DEBUG_ALL_PAGES, "1"); // $NON-NLS-1$ } else if (IPHPDebugConstants.DEBUGGING_FIRST_PAGE.equals(sessionSetting)) { parameters.put(DEBUG_FIRST_PAGE, "1"); // $NON-NLS-1$ } else if (IPHPDebugConstants.DEBUGGING_START_FROM.equals(sessionSetting)) { parameters.put( DEBUG_START_URL, launchConfiguration.getAttribute( IPHPDebugConstants.DEBUGGING_START_FROM_URL, "")); // $NON-NLS-1$ if (launchConfiguration.getAttribute( IPHPDebugConstants.DEBUGGING_SHOULD_CONTINUE, false)) { parameters.put(DEBUG_CONTINUE, "1"); // $NON-NLS-1$ } } } catch (CoreException ce) { Logger.logException(ce); } } String sessID = launch.getAttribute(IDebugParametersKeys.SESSION_ID); if (sessID != null) { parameters.put(DEBUG_SESSION_ID, sessID); } return parameters; }
/** * Finds and returns the type that corresponds to provided server. * * @param server * @return type that corresponds to provided server */ public IServerType getType(Server server) { return getType(server.getAttribute(IServerType.TYPE, null)); }