@Override protected void createDestinationGroup(Composite parent) { UIPlugin plugin = UIPlugin.getInstance(); Group destinationGroup = new Group(parent, SWT.NONE); GridLayout layout = new GridLayout(); destinationGroup.setLayout(layout); destinationGroup.setLayoutData( new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL)); destinationGroup.setText(plugin.getString("_UI_Forge_Credentials_label")); destinationGroup.setFont(parent.getFont()); Font font = destinationGroup.getFont(); Label loginLabel = new Label(destinationGroup, SWT.NONE); loginLabel.setText(plugin.getString("_UI_Login_label")); loginLabel.setFont(font); loginField = new Text(destinationGroup, SWT.BORDER | SWT.READ_ONLY); GridData data = new GridData(GridData.FILL_HORIZONTAL); data.widthHint = SIZING_TEXT_FIELD_WIDTH; loginField.setLayoutData(data); loginField.setFont(font); Label passwordLabel = new Label(destinationGroup, SWT.NONE); passwordLabel.setText(plugin.getString("_UI_Password_label")); passwordLabel.setFont(font); passwordField = new Text(destinationGroup, SWT.BORDER | SWT.PASSWORD); data = new GridData(GridData.FILL_HORIZONTAL); data.widthHint = SIZING_TEXT_FIELD_WIDTH; passwordField.setLayoutData(data); passwordField.setFont(font); passwordField.addListener(SWT.Modify, this); }
@Override public void addPages() { WizardPage newProjectCreationPage = newProjectCreationPage("NewProjectCreationPage"); // $NON-NLS-1$ newProjectCreationPage.setTitle(UIPlugin.getLocalString(getWizardPageTitleKey())); newProjectCreationPage.setDescription(UIPlugin.getLocalString(getWizardPageDescriptionKey())); addPage(newProjectCreationPage); }
@Override public boolean validateSourceGroup() { if (!super.validateSourceGroup()) return false; try { @SuppressWarnings("unchecked") List<IResource> whiteCheckedResources = getWhiteCheckedResources(); UIPlugin plugin = UIPlugin.getInstance(); String owner = null; Diagnostic diag = new Diagnostic(); for (ExportSpec spec : getExportSpecs(whiteCheckedResources)) { try { Metadata md = getForge() .createFromModuleDirectory( spec.getModuleRoot(), false, spec.getFileFilter(), null, diag); if (md != null) { ModuleName name = md.getName(); if (owner == null) owner = name.getOwner(); else if (!owner.equals(name.getOwner())) { setErrorMessage(plugin.getString("_UI_MultipleModuleOwners")); return false; } } } catch (IOException e) { } } if (owner == null) { setErrorMessage(plugin.getString("_UI_NoModulesSelected")); return false; } if (!owner.equals(loginField.getText())) { // Owner changed validationChange = true; try { loginField.setText(owner); String password = null; if (saveInSecureStoreButton.getSelection()) password = loadSecurePassword(owner); if (password == null) password = ""; passwordField.setText(password); } finally { validationChange = false; } } return true; } catch (CoreException e) { setErrorMessage(e.getMessage()); return false; } }
@Override protected void createOptionsGroupButtons(Group optionsGroup) { UIPlugin plugin = UIPlugin.getInstance(); Font font = optionsGroup.getFont(); saveInSecureStoreButton = new Button(optionsGroup, SWT.CHECK); saveInSecureStoreButton.setText(plugin.getString("_UI_SaveInSecureStorage_label")); saveInSecureStoreButton.addListener(SWT.Selection, this); saveInSecureStoreButton.setFont(font); dryRunButton = new Button(optionsGroup, SWT.CHECK); dryRunButton.setText(plugin.getString("_UI_DryRun_label")); dryRunButton.setFont(font); dryRunButton.setSelection(false); }
@Override protected void initializeDefaultPageImageDescriptor() { ImageDescriptor desc = UIPlugin.getImageDesc("full/wizban/NewPuppetManifest.png"); if (desc == null) desc = IDEWorkbenchPlugin.getIDEImageDescriptor("wizban/newfile_wiz.png"); // $NON-NLS-1$ setDefaultPageImageDescriptor(desc); }
@Override public boolean validateDestinationGroup() { if ("".equals(passwordField.getText())) { setErrorMessage(UIPlugin.getLocalString("_UI_EnterPassword")); return false; } return super.validateDestinationGroup(); }
public ModuleExportToForgeWizardPage(IStructuredSelection selection) { this("moduleExportToForge", selection); // $NON-NLS-1$ setTitle(UIPlugin.getLocalString("_UI_ExportModulesToForge")); setDescription(UIPlugin.getLocalString("_UI_ExportModulesToForge_desc")); }
@Override public boolean finish() { // about to invoke the operation so save our state saveWidgetValues(); if (!saveDirtyEditors()) // User clicked on cancel when being asked to save dirty editors. return false; final Injector injector = UIPlugin.getInstance() .createInjector( new OAuthModule( FORGE_CLIENT_ID, FORGE_CLIENT_SECRET, loginField.getText(), passwordField.getText())); try { @SuppressWarnings("unchecked") List<IResource> whiteCheckedResources = getWhiteCheckedResources(); File tmpDir = new File(System.getProperty("java.io.tmpdir")); File destinationDir = File.createTempFile("forge-", ".tarballs", tmpDir); destinationDir.delete(); destinationDir.mkdir(); ModuleExportToForgeOperation exportOp = new ModuleExportToForgeOperation( getExportSpecs(whiteCheckedResources), destinationDir, dryRunButton.getSelection()) { @Override protected Forge getForge() { return injector.getInstance(Forge.class); } @Override protected ForgeService getForgeService() { return injector.getInstance(ForgeService.class); } }; boolean result = executeExport(exportOp); Diagnostic diag = exportOp.getDiagnostic(); if (diag.getSeverity() == Diagnostic.ERROR) { Exception e = diag.getException(); ErrorDialog.openError( getContainer().getShell(), DataTransferMessages.DataTransfer_exportProblems, null, // no special message UIPlugin.createStatus(IStatus.ERROR, diag.toString(), e)); } else MessageDialog.openInformation( getContainer().getShell(), DataTransferMessages.DataTransfer_information, diag.toString()); return result; } catch (CoreException e) { ErrorDialog.openError( getContainer().getShell(), DataTransferMessages.DataTransfer_exportProblems, null, // no special message e.getStatus()); } catch (Exception e) { ErrorDialog.openError( getContainer().getShell(), DataTransferMessages.DataTransfer_exportProblems, null, UIPlugin.createStatus(IStatus.ERROR, e.getMessage(), e)); } return false; }
@Override public void init(IWorkbench workbench, IStructuredSelection selection) { setDefaultPageImageDescriptor( UIPlugin.getImageDesc("full/wizban/NewPuppetProject.png")); // $NON-NLS-1$ setWindowTitle(UIPlugin.getLocalString(getWizardWindowTitleKey())); }
@Override public boolean performFinish() { try { project = null; getContainer() .run( false, false, new WorkspaceModifyOperation() { @Override protected void execute(IProgressMonitor progressMonitor) throws InvocationTargetException { SubMonitor monitor = SubMonitor.convert(progressMonitor, 100); try { String projectName = projectContainer.segment(0); if (projectLocation == null) projectLocation = ResourcesPlugin.getWorkspace() .getRoot() .getLocation() .append(projectName); File projectDir = projectLocation.toFile(); if (projectDir.exists() && !mayHaveExistingContents()) { if (!MessageDialog.openConfirm( getShell(), UIPlugin.getLocalString("_UI_Confirm_Overwrite"), UIPlugin.getLocalString( "_UI_Directory_not_empty", projectDir.getAbsolutePath()))) // User don't want us to overwrite return; FileUtils.rmR(projectDir); } project = ResourceUtil.createProject( projectContainer, URI.createFileURI(projectDir.getAbsolutePath()), Collections.<IProject>emptyList(), monitor.newChild(1)); initializeProjectContents(monitor.newChild(80)); } catch (Exception exception) { throw new InvocationTargetException(exception); } finally { progressMonitor.done(); } } }); return project != null; } catch (InvocationTargetException e) { Throwable t = e.getTargetException(); String title = UIPlugin.getLocalString("_UI_CreateProject_title"); if (t instanceof PartInitException) DialogUtil.openError(getShell(), title, t.getMessage(), (PartInitException) t); else if (t instanceof CoreException) ErrorDialog.openError(getShell(), title, t.getMessage(), ((CoreException) t).getStatus()); else MessageDialog.openError(getShell(), title, t.getMessage()); } catch (InterruptedException e) { } return false; }