public void creatComponentProj(String directory) { ComponentProjectManager manager = ComponentProjectManager.getInstance(); Shell shell = PlatformUI.getWorkbench().getDisplay().getActiveShell(); IProject project = manager.createNewProject(directory, PluginConstant.COMPONENT_PROJECT, shell); manager.configProject(project, shell); ComponentDesigenerPlugin.getDefault().setUsed(true); }
public void creatComponentProj() { ComponentProjectManager manager = ComponentProjectManager.getInstance(); Shell shell = PlatformUI.getWorkbench().getDisplay().getActiveShell(); manager.createNewProject( this.getPreferenceStore().getString(PluginConstant.PROJECT_URL), PluginConstant.COMPONENT_PROJECT, shell); ComponentDesigenerPlugin.getDefault().setUsed(true); }
/* * (non-Javadoc) Method declared on IAction. */ @Override public void run() { String path = null; if (GlobalServiceRegister.getDefault() .isServiceRegistered(IComponentsLocalProviderService.class)) { IComponentsLocalProviderService service = (IComponentsLocalProviderService) GlobalServiceRegister.getDefault() .getService(IComponentsLocalProviderService.class); if (service != null) { path = service.getPreferenceStore().getString("USER_COMPONENTS_FOLDER"); // $NON-NLS-1$ } } if (path == null || path.length() == 0) { new MessageDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.getString("PushToPaletteActionProvider.Error"), null, //$NON-NLS-1$ Messages.getString("PushToPaletteActionProvider.ErrorMSG"), MessageDialog.ERROR, new String[] {Messages.getString("PushToPaletteActionProvider.OK")}, 0) .open(); //$NON-NLS-1$ //$NON-NLS-2$ return; } File targetFile = new File(path); if (!targetFile.exists()) { new MessageDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.getString("PushToPaletteActionProvider.Error2"), null, //$NON-NLS-1$ Messages.getString("PushToPaletteActionProvider.ErrorMSG2"), MessageDialog.ERROR, new String[] {Messages.getString("PushToPaletteActionProvider.OK2")}, 0) .open(); //$NON-NLS-1$ //$NON-NLS-2$ return; } // fix issue 7636: Don't need to copy if component project URL and // user components folder are the same. String projectURL = ComponentDesigenerPlugin.getDefault() .getPreferenceStore() .getString(PluginConstant.PROJECT_URL); File source = new File(projectURL); List<String> invalidXMLs = new ArrayList(); for (IFolder selectedFolder : selectedFolderList) { List<String> result = checkComponentXMLinFolder(selectedFolder.getRawLocation().toString()); invalidXMLs.addAll(result); } // all XML are OK if (invalidXMLs.size() == 0) { if (!targetFile.equals(source)) { for (IFolder selectedFolder : selectedFolderList) { File sourceFile = selectedFolder.getRawLocation().toFile(); String sourceComponentFolder = sourceFile.getAbsolutePath(); String targetComponentFolder = targetFile.getAbsolutePath() + File.separator + sourceFile.getName(); FileCopy.copyComponentFolder(sourceComponentFolder, targetComponentFolder, true); } } // add for bug TDI-26719, clear image cash from EmfComponent IComponentsFactory components = ComponentsFactoryProvider.getInstance(); List<IComponent> comList = components.getCustomComponents(); for (IComponent com : comList) { if (com.getImageRegistry() != null) { com.getImageRegistry().clear(); } } MessageDialog warningMessageDialog = new MessageDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.getString("PushToPaletteActionProvider.Information"), null, Messages.getString("PushToPaletteActionProvider.InformationMSG"), MessageDialog.INFORMATION, // $NON-NLS-1$ //$NON-NLS-2$ new String[] {Messages.getString("PushToPaletteActionProvider.OK3")}, 0); //$NON-NLS-1$ warningMessageDialog.open(); CorePlugin.getDefault().getCodeGeneratorService().refreshTemplates(); } else { StringBuffer sbuffer = new StringBuffer(); for (String invalidXML : invalidXMLs) { sbuffer.append(invalidXML).append("\n"); // $NON-NLS-1$ } String waringInfo = Messages.getString("PushToPaletteActionProvider.PushToPaletteActionProvider.failed") + sbuffer.toString(); // $NON-NLS-1$ MessageDialog warningMessageDialog = new MessageDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.getString( "PushToPaletteActionProvider.PushToPaletteActionProvider.result"), null, waringInfo, //$NON-NLS-1$ MessageDialog.WARNING, new String[] {Messages.getString("PushToPaletteActionProvider.OK3")}, 0); //$NON-NLS-1$ warningMessageDialog.open(); } }
public void checkProject() { if (!ComponentDesigenerPlugin.getDefault().isUsed()) { this.creatComponentProj(); } }