/** Default constructor. */ public WAProjectWizard() { setWindowTitle(Messages.pWizWindowTitle); String zipFile = ""; try { zipFile = String.format( "%s%s%s%s%s", PluginUtil.pluginFolder, File.separator, Messages.pluginId, File.separator, Messages.starterKitFileName); // Extract the WAStarterKitForJava.zip to temp dir waProjMgr = WindowsAzureProjectManager.create(zipFile); // By deafult - disabling remote access // when creating new project waProjMgr.setRemoteAccessAllRoles(false); waProjMgr.setClassPathInPackage("azure.lib.dir", PluginUtil.getAzureLibLocation()); waRole = waProjMgr.getRoles().get(0); // remove http endpoint WindowsAzureEndpoint endpoint = waRole.getEndpoint(Messages.httpEp); if (endpoint != null) { endpoint.delete(); } } catch (IOException e) { PluginUtil.displayErrorDialogAndLog( this.getShell(), Messages.pWizErrTitle, Messages.pWizErrMsg, e); } catch (Exception e) { errorTitle = Messages.adRolErrTitle; errorMessage = Messages.pWizErrMsgBox1 + Messages.pWizErrMsgBox2; PluginUtil.displayErrorDialogAndLog(this.getShell(), errorTitle, errorMessage, e); } }
/** * This method gets called when wizard's finish button is clicked. * * @return True, if project gets created successfully; else false. */ @Override public boolean performFinish() { final String projName = waProjWizPage.getTextProjName(); final String projLocation = waProjWizPage.getTextLocation(); final boolean isDefault = waProjWizPage.isDefaultLocation(); final WorkingSetGroup workingSetGroup = waProjWizPage.getWorkingSetGroup(); final IWorkingSet[] selWorkingSets = workingSetGroup.getSelectedWorkingSets(); final IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager(); final Map<String, String> depParams = getDeployPageValues(); final Map<String, Boolean> keyFtr = getKeyFtrPageValues(); final IProject proj = getSelectProject(); boolean retVal = true; IRunnableWithProgress runnable = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException { try { doFinish( projName, projLocation, isDefault, selWorkingSets, workingSetManager, depParams, keyFtr, proj); } finally { monitor.done(); } } }; try { /* * Check if third party JDK and server is selected * then license is accepted or not. */ boolean tempAccepted = true; if (WATabPage.isThirdPartyJdkChecked() && !WATabPage.isAccepted()) { tempAccepted = JdkSrvConfig.createAccLicenseAggDlg(getShell(), true); } if (WATabPage.isThirdPartySrvChecked() && !WATabPage.isServerAccepted()) { tempAccepted = JdkSrvConfig.createAccLicenseAggDlg(getShell(), false); } if (tempAccepted) { getContainer().run(true, false, runnable); } else { return false; } } catch (InterruptedException e) { PluginUtil.displayErrorDialog(this.getShell(), Messages.pWizErrTitle, Messages.pWizErrMsg); retVal = false; } catch (InvocationTargetException e) { PluginUtil.displayErrorDialogAndLog( this.getShell(), Messages.pWizErrTitle, Messages.pWizErrMsg, e); retVal = false; } // re-initializing context menu to default option : false Activator.getDefault().setContextMenu(false); return retVal; }
/** * This method will refresh the workspace.If any changes are made in any configuration files * through UI in that case it will refresh the workspace so that user can see the correct/modified * files. * * @param errorTitle * @param errorMessage */ public static void refreshWorkspace(String errorTitle, String errorMessage) { try { IWorkspace workspace = ResourcesPlugin.getWorkspace(); IWorkspaceRoot root = workspace.getRoot(); root.refreshLocal(IResource.DEPTH_INFINITE, null); } catch (CoreException e) { PluginUtil.displayErrorDialogAndLog(new Shell(), errorTitle, errorMessage, e); } }
private PublishData[] loadOldPrefs() { Preferences prefs = PluginUtil.getPrefs(waeclipseplugin.Activator.PLUGIN_ID); PublishData[] publishDatas = null; try { byte[] data = prefs.getByteArray(PREF_KEY, null); if (data != null) { ByteArrayInputStream buffer = new ByteArrayInputStream(data); ObjectInput input = new ObjectInputStream(buffer); publishDatas = (PublishData[]) input.readObject(); } } catch (IOException e) { e.printStackTrace(); Activator.getDefault().log(Messages.error, e); } catch (ClassNotFoundException e) { e.printStackTrace(); Activator.getDefault().log(Messages.error, e); } return publishDatas; }
/** * Method returns array of project names which are open and has windows azure nature. * * @return String[] */ private String[] getProjects() { IWorkspace workspace = ResourcesPlugin.getWorkspace(); IWorkspaceRoot root = workspace.getRoot(); String[] projects = null; ArrayList<String> projList = new ArrayList<String>(); try { for (IProject wRoot : root.getProjects()) { if (wRoot.isOpen() && !wRoot.hasNature(Messages.waProjNature)) { projList.add(wRoot.getProject().getName()); } } projects = new String[projList.size()]; projects = projList.toArray(projects); } catch (Exception e) { PluginUtil.displayErrorDialogAndLog( this.getShell(), Messages.projSelTtl, Messages.projSelMsg, e); } return projects; }
/** * This method finds the project in workspace. * * @param path : import path * @return : matched project */ public static IProject findProjectFromWorkSpace(String path) { IWorkspace workspace = ResourcesPlugin.getWorkspace(); IWorkspaceRoot root = workspace.getRoot(); IProject project = null; ArrayList<IProject> projList = new ArrayList<IProject>(); try { for (IProject wRoot : root.getProjects()) { if (wRoot.isOpen() && !wRoot.hasNature(Messages.stUpProjNature)) { projList.add(wRoot); } } IProject[] arr = new IProject[projList.size()]; arr = projList.toArray(arr); for (int i = 0; i < arr.length; i++) { if (arr[i].getLocation().toOSString().equalsIgnoreCase(path)) { project = arr[i]; } } } catch (Exception e) { PluginUtil.displayErrorDialogAndLog(new Shell(), Messages.prjSelErr, Messages.prjSelMsg, e); } return project; }
@Override protected void okPressed() { boolean isValid = true; if ((fileRadioBtn.getSelection() && !fileTxt.getText().isEmpty())) { File file = new File(fileTxt.getText()); if (!file.exists()) { isValid = false; PluginUtil.displayErrorDialog( this.getShell(), Messages.appDlgInvFileTtl, Messages.appDlgInvFileMsg); } } else if (projRadioBtn.getSelection() && !asNameTxt.getText().isEmpty() && !projCombo.getText().isEmpty()) { boolean isValidName = true; try { isValidName = windowsAzureRole.isValidDeployName(asNameTxt.getText()); } catch (Exception e) { isValidName = false; } if (!isValidName) { isValid = false; PluginUtil.displayErrorDialog( this.getShell(), Messages.appDlgInvNmeTtl, Messages.appDlgInvNmeMsg); } } if (isValid) { ArrayList<String> cmpList = null; if (depPage == null) { cmpList = serverConf.getAppsAsNames(); } else { cmpList = depPage.getAppsAsNames(); } if (fileRadioBtn.getSelection()) { if (cmpList.contains(new File(fileTxt.getText()).getName())) { PluginUtil.displayErrorDialog( this.getShell(), Messages.appDlgDupNmeTtl, Messages.appDlgDupNmeMsg); return; } try { List<WindowsAzureRoleComponent> components = windowsAzureRole.getComponents(); for (int i = 0; i < components.size(); i++) { if (components .get(i) .getDeployName() .equalsIgnoreCase(new File(fileTxt.getText()).getName())) { PluginUtil.displayErrorDialog( this.getShell(), Messages.appDlgDupNmeTtl, Messages.appDlgDupNmeMsg); return; } } } catch (WindowsAzureInvalidProjectOperationException e) { PluginUtil.displayErrorDialogAndLog( this.getShell(), Messages.addAppErrTtl, Messages.addAppErrMsg, e); } if (depPage == null) { serverConf.addToAppList( fileTxt.getText(), new File(fileTxt.getText()).getName(), Messages.methodCopy); } else { depPage.addToAppList( fileTxt.getText(), new File(fileTxt.getText()).getName(), Messages.methodCopy); } } else if (projRadioBtn.getSelection()) { IWorkspace workspace = ResourcesPlugin.getWorkspace(); IWorkspaceRoot root = workspace.getRoot(); IProject proj = root.getProject(projCombo.getText()); if (cmpList.contains(new File(asNameTxt.getText()).getName())) { PluginUtil.displayErrorDialog( this.getShell(), Messages.appDlgDupNmeTtl, Messages.appDlgDupNmeMsg); return; } if (depPage == null) { serverConf.addToAppList( proj.getLocation().toOSString(), asNameTxt.getText(), Messages.methodAuto); } else { depPage.addToAppList( proj.getLocation().toOSString(), asNameTxt.getText(), Messages.methodAuto); } } super.okPressed(); } }
/** * Method creates tree structure of windows azure property pages. and opens property dialog with * desired property page selected & active. * * @param windowsAzureRole : worker role * @param pageToDisplay : property page Id which should be active after opening dialog * @return integer */ public static int openRolePropertyDialog( WindowsAzureRole windowsAzureRole, String pageToDisplay) { int retVal = Window.CANCEL; // value corresponding to cancel try { // Node creation PreferenceNode nodeGeneral = new PreferenceNode( Messages.cmhIdGeneral, Messages.cmhLblGeneral, null, WARGeneral.class.toString()); nodeGeneral.setPage(new WARGeneral()); nodeGeneral.getPage().setTitle(Messages.cmhLblGeneral); PreferenceNode nodeCache = new PreferenceNode( Messages.cmhIdCach, Messages.cmhLblCach, null, WARCaching.class.toString()); nodeCache.setPage(new WARCaching()); nodeCache.getPage().setTitle(Messages.cmhLblCach); PreferenceNode nodeCmpnts = new PreferenceNode( Messages.cmhIdCmpnts, Messages.cmhLblCmpnts, null, WARComponents.class.toString()); nodeCmpnts.setPage(new WARComponents()); nodeCmpnts.getPage().setTitle(Messages.cmhLblCmpnts); PreferenceNode nodeDebugging = new PreferenceNode( Messages.cmhIdDbg, Messages.cmhLblDbg, null, WARDebugging.class.toString()); nodeDebugging.setPage(new WARDebugging()); nodeDebugging.getPage().setTitle(Messages.cmhLblDbg); PreferenceNode nodeEndPts = new PreferenceNode( Messages.cmhIdEndPts, Messages.cmhLblEndPts, null, WAREndpoints.class.toString()); nodeEndPts.setPage(new WAREndpoints()); nodeEndPts.getPage().setTitle(Messages.cmhLblEndPts); PreferenceNode nodeEnvVars = new PreferenceNode( Messages.cmhIdEnvVars, Messages.cmhLblEnvVars, null, WAREnvVars.class.toString()); nodeEnvVars.setPage(new WAREnvVars()); nodeEnvVars.getPage().setTitle(Messages.cmhLblEnvVars); PreferenceNode nodeLdBlnc = new PreferenceNode( Messages.cmhIdLdBlnc, Messages.cmhLblLdBlnc, null, WARLoadBalance.class.toString()); nodeLdBlnc.setPage(new WARLoadBalance()); nodeLdBlnc.getPage().setTitle(Messages.cmhLblLdBlnc); PreferenceNode nodeLclStg = new PreferenceNode( Messages.cmhIdLclStg, Messages.cmhLblLclStg, null, WARLocalStorage.class.toString()); nodeLclStg.setPage(new WARLocalStorage()); nodeLclStg.getPage().setTitle(Messages.cmhLblLclStg); PreferenceNode nodeSrvCnfg = new PreferenceNode( Messages.cmhIdSrvCnfg, Messages.cmhLblSrvCnfg, null, WAServerConfiguration.class.toString()); nodeSrvCnfg.setPage(new WAServerConfiguration()); nodeSrvCnfg.getPage().setTitle(Messages.cmhLblSrvCnfg); /* * Tree structure creation. * Don't change order while adding nodes. * Its the default alphabetical order given by eclipse. */ nodeGeneral.add(nodeCache); nodeGeneral.add(nodeCmpnts); nodeGeneral.add(nodeDebugging); nodeGeneral.add(nodeEndPts); nodeGeneral.add(nodeEnvVars); nodeGeneral.add(nodeLdBlnc); nodeGeneral.add(nodeLclStg); nodeGeneral.add(nodeSrvCnfg); PreferenceManager mgr = new PreferenceManager(); mgr.addToRoot(nodeGeneral); // Dialog creation PreferenceDialog dialog = new PreferenceDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), mgr); // make desired property page active. dialog.setSelectedNode(pageToDisplay); dialog.create(); String dlgTitle = String.format(Messages.cmhPropFor, windowsAzureRole.getName()); dialog.getShell().setText(dlgTitle); dialog.open(); // return whether user has pressed OK or Cancel button retVal = dialog.getReturnCode(); } catch (Exception ex) { PluginUtil.displayErrorDialogAndLog( new Shell(), Messages.rolsDlgErr, Messages.rolsDlgErrMsg, ex); } return retVal; }