/** * Returns true for: - non-hidden projects - non-RDT projects - projects that does not have remote * systems temporary nature - projects that are located remotely */ public boolean isCandidate(IProject project) { boolean a = false; boolean b = false; boolean c = false; boolean d = false; a = !project.isHidden(); try { // b = !project.hasNature(RemoteNature.REMOTE_NATURE_ID); try { ServiceModelManager.getInstance().getConfigurations(project); } catch (ProjectNotConfiguredException e) { b = true; } c = !project.hasNature("org.eclipse.rse.ui.remoteSystemsTempNature"); // $NON-NLS-1$ IHost host = RSEUtils.getConnection(project.getLocationURI()); if (host != null) { d = !host.getSystemType().isLocal(); } else { IFileStore fileStore = EFS.getStore(project.getLocationURI()); if (fileStore != null) { if (!(fileStore instanceof LocalFile)) { d = true; } } } } catch (CoreException e) { RDTLog.logError(e); } return a && b && c && d; }
/** @since 2.0 */ protected IServiceConfiguration getConfig(IProject project) { IServiceConfiguration config = projectConfigs.get(project); IHost host = RSEUtils.getConnection(project.getLocationURI()); if (config == null && host != null) { config = ServiceModelManager.getInstance().newServiceConfiguration(project.getName()); projectConfigs.put(project, config); } return config; }
@Override public void doRun(IProgressMonitor monitor, String projectID, String bsId) throws CoreException { monitor.beginTask(Messages.getString("ConvertToRemoteWizardPage.0"), 2); // $NON-NLS-1$ fServiceModelWidget.applyChangesToConfiguration(); super.doRun(new SubProgressMonitor(monitor, 1), projectID, bsId); try { ServiceModelManager.getInstance().saveModelConfiguration(); } catch (IOException e) { UIPlugin.log(e); } finally { monitor.done(); } }
public void run(IAction action) { ElementSelectionDialog dialog = new ElementSelectionDialog(getShell()); configureDialog(dialog); int result = dialog.open(); if (result != IDialogConstants.OK_ID) return; ITypeInfo info = (ITypeInfo) dialog.getFirstResult(); if (info == null) return; ICElement[] elements = null; ITypeReference location = info.getResolvedReference(); if (location != null) { elements = location.getCElements(); } if (elements == null || elements.length == 0) { String title = Messages.OpenTypeInHierarchyAction_errorTitle; String message = NLS.bind( Messages.OpenTypeInHierarchyAction_errorNoDefinition, info.getQualifiedTypeName().toString()); MessageDialog.openError(getShell(), title, message); } else { IProject project = elements[0].getCProject().getProject(); IServiceModelManager smm = ServiceModelManager.getInstance(); IServiceConfiguration serviceConfig = smm.getActiveConfiguration(project); IService indexingService = smm.getService(IRDTServiceConstants.SERVICE_C_INDEX); IServiceProvider serviceProvider = serviceConfig.getServiceProvider(indexingService); if (serviceProvider instanceof IIndexServiceProvider) { ITypeHierarchyService service = ((IIndexServiceProvider) serviceProvider).getTypeHierarchyService(); TypeHierarchyUtil.open(service, elements[0], fWorkbenchWindow); } } }
public class ServiceConfigurationImportWizard extends Wizard implements IImportWizard { private class SelectFilePage extends WizardPage { private String file = ""; // $NON-NLS-1$ private Combo fileCombo; private Button browseButton; private ServiceConfigurationSelectionWidget fServiceWidget; private int messageType = NONE; public SelectFilePage(String pageName, String title, ImageDescriptor titleImage) { super(pageName, title, titleImage); setDescription(Messages.ServiceConfigurationImportWizard_1); } public void createControl(Composite parent) { Composite workArea = new Composite(parent, SWT.NONE); setControl(workArea); workArea.setFont(parent.getFont()); workArea.setLayout(new GridLayout()); workArea.setLayoutData( new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL)); createFileSelectionArea(workArea); createConfigurationsArea(workArea); updateEnablement(); Dialog.applyDialogFont(parent); messageType = ERROR; } private void createFileSelectionArea(Composite workArea) { Composite composite = new Composite(workArea, SWT.NULL); composite.setLayout(new GridLayout()); composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); GridLayout layout = new GridLayout(); layout.numColumns = 3; layout.marginHeight = 0; layout.marginWidth = 0; composite.setLayout(layout); Label label = new Label(composite, SWT.NONE); label.setText(Messages.ServiceConfigurationImportWizard_2); fileCombo = new Combo(composite, SWT.DROP_DOWN); GridData comboData = new GridData(GridData.FILL_HORIZONTAL); comboData.verticalAlignment = GridData.CENTER; comboData.grabExcessVerticalSpace = false; comboData.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH; fileCombo.setLayoutData(comboData); file = FilenameStore.getSuggestedDefault(); fileCombo.setItems(FilenameStore.getHistory()); fileCombo.setText(file); fileCombo.addListener( SWT.Modify, new Listener() { public void handleEvent(Event event) { file = fileCombo.getText(); updateEnablement(); } }); browseButton = new Button(composite, SWT.PUSH); browseButton.setText(Messages.ServiceConfigurationImportWizard_3); GridData data = new GridData(); data.horizontalAlignment = GridData.FILL; int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); data.widthHint = Math.max(widthHint, browseButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); browseButton.setLayoutData(data); browseButton.addListener( SWT.Selection, new Listener() { public void handleEvent(Event event) { FileDialog d = new FileDialog(getShell(), SWT.OPEN); d.setFilterExtensions(new String[] {"*.cfg", "*"}); // $NON-NLS-1$ //$NON-NLS-2$ d.setFilterNames( new String[] { Messages.ServiceConfigurationImportWizard_4, Messages.ServiceConfigurationImportWizard_5 }); String fileName = getFileName(); if (fileName != null && fileName.length() > 0) { int separator = fileName.lastIndexOf( System.getProperty("file.separator").charAt(0)); // $NON-NLS-1$ if (separator != -1) { fileName = fileName.substring(0, separator); } } else { fileName = ResourcesPlugin.getWorkspace().getRoot().getLocation().toString(); } d.setFilterPath(fileName); String f = d.open(); if (f != null) { fileCombo.setText(f); file = f; updateConfigurations(file); } } }); } private void updateConfigurations(String file) { try { final String filename = file; getContainer() .run( true, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask(Messages.ServiceConfigurationImportWizard_0, 100); fServiceConfigurations = fModelManager.importConfigurations(filename); monitor.worked(100); monitor.done(); } }); } catch (InvocationTargetException e) { } catch (InterruptedException e) { // Do nothing } fServiceWidget.setConfigurations(fServiceConfigurations); fServiceWidget.setAllChecked(true); } private void createConfigurationsArea(Composite workArea) { Composite composite = new Composite(workArea, SWT.NONE); composite.setLayout(new GridLayout()); composite.setLayoutData( new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH)); Label label = new Label(composite, SWT.NONE); label.setText(Messages.ServiceConfigurationImportWizard_12); fServiceWidget = new ServiceConfigurationSelectionWidget(composite, SWT.CHECK, null, null, true); fServiceWidget.setConfigurations(new IServiceConfiguration[0]); } public String getFileName() { return file; } public IServiceConfiguration[] getServiceConfigurations() { return fServiceWidget.getCheckedServiceConfigurations(); } private void updateEnablement() { boolean complete = false; setMessage(null); if (file.length() == 0) { setMessage(Messages.ServiceConfigurationImportWizard_6, messageType); setPageComplete(false); return; } else { // See if the file exists File f = new File(file); if (!f.exists()) { setMessage(Messages.ServiceConfigurationImportWizard_7, messageType); setPageComplete(false); return; } else if (f.isDirectory()) { setMessage(Messages.ServiceConfigurationImportWizard_8, messageType); setPageComplete(false); return; } else if (!fModelManager.isValidConfigurationFile(file)) { setMessage(Messages.ServiceConfigurationImportWizard_13, messageType); setPageComplete(false); return; } complete = true; } if (complete) { setErrorMessage(null); setDescription(Messages.ServiceConfigurationImportWizard_9); } setPageComplete(complete); } public void setVisible(boolean visible) { super.setVisible(visible); if (visible) { fileCombo.setFocus(); } } } private SelectFilePage mainPage; private IServiceConfiguration[] fServiceConfigurations; private IServiceModelManager fModelManager = ServiceModelManager.getInstance(); public ServiceConfigurationImportWizard() { setNeedsProgressMonitor(true); setWindowTitle(Messages.ServiceConfigurationImportWizard_10); } public void addPages() { mainPage = new SelectFilePage( "importMainPage", Messages.ServiceConfigurationImportWizard_11, null); // $NON-NLS-1$ addPage(mainPage); } /* (non-Javadoc) * @see org.eclipse.jface.wizard.Wizard#performFinish() */ @Override public boolean performFinish() { for (IServiceConfiguration config : mainPage.getServiceConfigurations()) { fModelManager.addConfiguration(config); } return true; } /* (non-Javadoc) * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection) */ public void init(IWorkbench workbench, IStructuredSelection selection) { FilenameStore.setDefaultFromSelection(workbench); } }
/** @since 2.0 */ protected void configureServicesForRemoteProject(IProject project) { ServiceModelManager.getInstance().addConfiguration(project, getConfig(project)); }