List of usage examples for org.eclipse.jface.viewers TableViewer getControl
@Override
public Control getControl()
From source file:eu.geclipse.jsdl.ui.adapters.jsdl.DataStageTypeAdapter.java
License:Open Source License
/** * Add's a new DataStaging element in the JSDL model. The new DataStaging element * is added as a child of the JobDescription element. The new DataStaging element * can be a Stage-In element (containing a Source URI) or a Stage-Out element * (containing a Target URI). /* w w w . j a va2 s. c o m*/ * * @param tableViewer The {@link TableViewer} to add the new DataStaging element. * If the new DataStaging element is a Stage-In element, then the table viewer * responsible for such elements should be passed here. The opposite is valid * for Stage-Out elements. * * @param dataStageList The list containing the new DataStaqe elements which were * retrieved from the respective Stage-In or Stage-Out dialogs * */ @SuppressWarnings({ "boxing", "unchecked" }) public void performAdd(final TableViewer tableViewer, final ArrayList<DataStagingType> dataStageList) { TableViewer stageInViewer = null; /* Assume that the table viewer is the one responsible for the Stage-In * elements. */ stageInViewer = this.tableFeaturesMap.get(Integer.valueOf(JsdlPackage.DATA_STAGING_TYPE__SOURCE)); /* Check if the values from the dialog are null. */ if (dataStageList.isEmpty()) { return; } EList<DataStagingType> newInputList = (EList<DataStagingType>) tableViewer.getInput(); if (newInputList == null) { newInputList = new BasicEList<DataStagingType>(); } /* Check if the new Data Stage element is not already in the table viewer's * input */ for (int i = 0; i < dataStageList.size(); i++) { boolean exists = doesElementExists(this.dataStagingType, dataStageList.get(i), newInputList); if (!exists) { newInputList.add(dataStageList.get(i)); /* Get the EStructural Feature of the DataStaging Type */ /* Change the table viewers input. */ try { this.jobDescriptionType.getDataStaging().addAll(newInputList); tableViewer.setInput(this.jobDescriptionType.getDataStaging()); } catch (Exception e) { Activator.logException(e); } /* Refresh the table viewer and notify the editor that * the page content has changed. */ tableViewer.refresh(); this.contentChanged(); } else { /* * Show the Error Dialog, this means that the new values that are to be added * are already contained in the table viewer Input. */ MessageDialog.openError(tableViewer.getControl().getShell(), Messages.getString("DataStagingPage_DuplicateEntryDialog_Title"), //$NON-NLS-1$ Messages.getString("DataStagingPage_New_DuplicateEntryDialog_Message")); //$NON-NLS-1$ } } newInputList = null; }
From source file:eu.geclipse.jsdl.ui.adapters.jsdl.DataStageTypeAdapter.java
License:Open Source License
/** * Edit the attributes of the selected object in the TableViewer. * //from w w w . ja v a2s . c om * @param tableViewer The SWT TableViewer that contains the Structural Features * @param dataStageList The list containing the selected DataStage elements. * */ @SuppressWarnings({ "unchecked", "boxing" }) public void performEdit(final TableViewer tableViewer, final ArrayList<DataStagingType> dataStageList) { TableViewer stageInViewer = null; /* Assume that the table viewer is the one responsible for the Stage-In * elements. */ stageInViewer = this.tableFeaturesMap.get(Integer.valueOf(JsdlPackage.DATA_STAGING_TYPE__SOURCE)); /* Check if the values from the dialog are null. */ if (dataStageList.isEmpty()) { return; } //Get the table viewer's input. EList<DataStagingType> newInputList = (EList<DataStagingType>) tableViewer.getInput(); EStructuralFeature eStructuralFeature; int featureID = JsdlPackage.JOB_DESCRIPTION_TYPE__DATA_STAGING; /* * Get the TableViewer Selection */ IStructuredSelection structSelection = (IStructuredSelection) tableViewer.getSelection(); /* If the selection is not null then Change the selected element */ if (structSelection != null) { for (int i = 0; i < dataStageList.size(); i++) { eStructuralFeature = this.jobDescriptionType.eClass().getEStructuralFeature(featureID); Object oldDataStageElement = structSelection.getFirstElement(); /* Get the Index of the Element that needs to be changed */ int index = ((java.util.List<Object>) this.jobDescriptionType.eGet(eStructuralFeature)) .indexOf(oldDataStageElement); /* Instantiate new DataStage and SourceTarge objects */ this.dataStagingType = JsdlFactory.eINSTANCE.createDataStagingType(); this.sourceTargetType = JsdlFactory.eINSTANCE.createSourceTargetType(); this.dataStagingType = dataStageList.get(i); /* Check if the new Data Stage element is not already in the table viewer's * input */ if (!doesElementExists((DataStagingType) oldDataStageElement, this.dataStagingType, newInputList)) { /* Change the element. The element is located through it's index position * in the list. */ ((java.util.List<Object>) this.jobDescriptionType.eGet(eStructuralFeature)).set(index, this.dataStagingType); /* Refresh the table viewer and notify the editor that * the page content has changed. */ tableViewer.refresh(); contentChanged(); } // end_if doesElementExits() else { /* * Show the Error Dialog, this means that the new values that are edited * are already contained in the table viewer Input. */ MessageDialog.openError(tableViewer.getControl().getShell(), Messages.getString("DataStagingPage_DuplicateEntryDialog_Title"), //$NON-NLS-1$ Messages.getString("DataStagingPage_Edit_DuplicateEntryDialog_Message")); //$NON-NLS-1$ } // End else } } // end_if structSelection }
From source file:eu.geclipse.jsdl.ui.internal.pages.sections.DataStageInSection.java
License:Open Source License
/** * Add's a new DataStaging element in the JSDL model. The new DataStaging element * is added as a child of the JobDescription element. The new DataStaging element * is a Stage-In element (containing a Source URI). * // w w w . ja v a2s . c o m * @param tableViewer The {@link TableViewer} to add the new DataStaging element. * If the new DataStaging element is a Stage-In element, then the table viewer * responsible for such elements should be passed here. * * @param innerDataStageList The list containing the new DataStaqe elements which were * retrieved from the respective Stage-In dialog * */ @SuppressWarnings({ "unchecked" }) public void performAdd(final TableViewer tableViewer, final ArrayList<DataStagingType> innerDataStageList) { /* Check if the values from the dialog are null. */ if (innerDataStageList.isEmpty()) { return; } EList<DataStagingType> newInputList = (EList<DataStagingType>) tableViewer.getInput(); if (newInputList == null) { newInputList = new BasicEList<DataStagingType>(); } /* Check if the new Data Stage element is not already in the table viewer's * input */ for (int i = 0; i < innerDataStageList.size(); i++) { boolean exists = doesElementExists(this.dataStagingType, innerDataStageList.get(i), newInputList); if (!exists) { newInputList.add(innerDataStageList.get(i)); /* Get the EStructural Feature of the DataStaging Type */ /* Change the table viewers input. */ try { this.jobDescriptionType.getDataStaging().addAll(newInputList); tableViewer.setInput(this.jobDescriptionType.getDataStaging()); } catch (Exception e) { Activator.logException(e); } /* Refresh the table viewer and notify the editor that * the page content has changed. */ tableViewer.refresh(); contentChanged(); } else { /* * Show the Error Dialog, this means that the new values that are to be added * are already contained in the table viewer Input. */ MessageDialog.openError(tableViewer.getControl().getShell(), Messages.getString("DataStagingPage_DuplicateEntryDialog_Title"), //$NON-NLS-1$ Messages.getString("DataStagingPage_New_DuplicateEntryDialog_Message")); //$NON-NLS-1$ } } newInputList = null; }
From source file:eu.geclipse.jsdl.ui.internal.pages.sections.DataStageInSection.java
License:Open Source License
/** * Edit the attribute values of the selected object in the TableViewer. * /*from w ww. j av a 2 s . co m*/ * @param tableViewer The SWT TableViewer that contains the Structural Features * @param innerDataStageList The list containing the selected DataStage elements. * */ @SuppressWarnings({ "unchecked" }) public void performEdit(final TableViewer tableViewer, final ArrayList<DataStagingType> innerDataStageList) { /* Check if the values from the dialog are null. */ if (innerDataStageList.isEmpty()) { return; } //Get the table viewer's input. EList<DataStagingType> newInputList = (EList<DataStagingType>) tableViewer.getInput(); EStructuralFeature eStructuralFeature; int featureID = JsdlPackage.JOB_DESCRIPTION_TYPE__DATA_STAGING; /* * Get the TableViewer Selection */ IStructuredSelection structSelection = (IStructuredSelection) tableViewer.getSelection(); /* If the selection is not null then Change the selected element */ if (structSelection != null) { for (int i = 0; i < innerDataStageList.size(); i++) { eStructuralFeature = this.jobDescriptionType.eClass().getEStructuralFeature(featureID); Object oldDataStageElement = structSelection.getFirstElement(); /* Get the Index of the Element that needs to be changed */ int index = ((java.util.List<Object>) this.jobDescriptionType.eGet(eStructuralFeature)) .indexOf(oldDataStageElement); /* Instantiate new DataStage and SourceTarge objects */ this.dataStagingType = JsdlFactory.eINSTANCE.createDataStagingType(); this.dataStagingType = innerDataStageList.get(i); /* Check if the new Data Stage element is not already in the table viewer's * input */ if (!doesElementExists((DataStagingType) oldDataStageElement, this.dataStagingType, newInputList)) { /* Change the element. The element is located through it's index position * in the list. */ ((java.util.List<Object>) this.jobDescriptionType.eGet(eStructuralFeature)).set(index, this.dataStagingType); /* Refresh the table viewer and notify the editor that * the page content has changed. */ tableViewer.refresh(); contentChanged(); } // end_if doesElementExits() else { /* * Show the Error Dialog, this means that the new values that are edited * are already contained in the table viewer Input. */ MessageDialog.openError(tableViewer.getControl().getShell(), Messages.getString("DataStagingPage_DuplicateEntryDialog_Title"), //$NON-NLS-1$ Messages.getString("DataStagingPage_Edit_DuplicateEntryDialog_Message")); //$NON-NLS-1$ } // End else } } // end_if structSelection }
From source file:eu.geclipse.jsdl.ui.internal.pages.sections.FileSystemSection.java
License:Open Source License
/** * /* w ww . ja va2s . co m*/ * Method that adds a list of File Systems. * * @param tableViewer The {@link TableViewer} that will hold the File Systems. * @param innerValue The list of File Systems. */ @SuppressWarnings("unchecked") public void addFileSystem(final TableViewer tableViewer, final Object innerValue) { boolean elementExists = false; String newElement; if (innerValue == null) { return; } EList<FileSystemType> newInputList = (EList<FileSystemType>) tableViewer.getInput(); if (newInputList == null) { newInputList = new BasicEList<FileSystemType>(); } this.fileSystemType = JsdlFactory.eINSTANCE.createFileSystemType(); this.fileSystemType = (FileSystemType) innerValue; newElement = this.fileSystemType.getName(); Iterator<FileSystemType> iter = newInputList.iterator(); while (iter.hasNext() && !elementExists) { elementExists = iter.next().getName().equals(newElement); } if (!elementExists) { newInputList.add(this.fileSystemType); /* Add the Argument to PosixApplication */ this.resourcesType.getFileSystem().addAll(newInputList); tableViewer.setInput(this.resourcesType.getFileSystem()); tableViewer.refresh(); contentChanged(); } else { MessageDialog.openError(tableViewer.getControl().getShell(), Messages.getString("FileSystem_DuplicateEntryDialog_Title"), //$NON-NLS-1$ Messages.getString("FileSystem_New_DuplicateEntryDialog_Message")); //$NON-NLS-1$ } }
From source file:eu.geclipse.jsdl.ui.internal.pages.sections.FileSystemSection.java
License:Open Source License
/** * Edit an element that appears in a Table Viewers. * /*from w w w . ja v a 2s .co m*/ * @param tableViewer The {@link TableViewer} in which the new element appears. * @param innerValue The new value of the element. */ @SuppressWarnings("unchecked") public void performEdit(final TableViewer tableViewer, final Object innerValue) { boolean elementExists = false; String newElement; int featureID; if (innerValue == null) { return; } EStructuralFeature eStructuralFeature; /* * Get the TableViewer Selection */ IStructuredSelection structSelection = (IStructuredSelection) tableViewer.getSelection(); /* If the selection is not null then Change the selected element */ if (structSelection != null) { EList<FileSystemType> newInputList = (EList<FileSystemType>) tableViewer.getInput(); if (newInputList == null) { newInputList = new BasicEList<FileSystemType>(); } Object feature = structSelection.getFirstElement(); featureID = JsdlPackage.RESOURCES_TYPE__FILE_SYSTEM; eStructuralFeature = this.resourcesType.eClass().getEStructuralFeature(featureID); /* Get the Index of the Element that needs to be changed */ int index = ((java.util.List<Object>) this.resourcesType.eGet(eStructuralFeature)).indexOf(feature); /* * Create a new Argument Type EObject with the new values that will * substitute the old EObject. */ this.fileSystemType = JsdlFactory.eINSTANCE.createFileSystemType(); this.fileSystemType = (FileSystemType) innerValue; newElement = this.fileSystemType.getName(); Iterator<FileSystemType> iter = newInputList.iterator(); while (iter.hasNext() && !elementExists) { FileSystemType tempFileSystemType = iter.next(); if ((tempFileSystemType.getName().equals(newElement)) && (!tempFileSystemType.equals(feature))) { elementExists = true; } } /* Change the element. The element is located through it's index position * in the list. * * If an element with the same name exists then an appropriate warning is * shown. */ if (!elementExists) { ((java.util.List<Object>) this.resourcesType.eGet(eStructuralFeature)).set(index, this.fileSystemType); tableViewer.refresh(); contentChanged(); } else { MessageDialog.openError(tableViewer.getControl().getShell(), Messages.getString("FileSystem_DuplicateEntryDialog_Title"), //$NON-NLS-1$ Messages.getString("FileSystem_New_DuplicateEntryDialog_Message")); //$NON-NLS-1$ } eStructuralFeature = null; } }
From source file:eu.geclipse.jsdl.ui.internal.pages.sections.JobIdentificationSection.java
License:Open Source License
/** * Method that adds a list of Candidate Hosts . * //from ww w . j a v a 2 s .c o m * @param tableViewer The {@link TableViewer} that will hold the Candidate * Hosts. * @param innerValue The list of Candidate Hosts. */ @SuppressWarnings("unchecked") public void performAdd(final TableViewer tableViewer, final Object[] innerValue) { boolean elementExists = false; String newElement; for (int i = 0; i < innerValue.length; i++) { if (null == innerValue[i]) { return; } } Collection<String> collection = new ArrayList<String>(); EList<String> newInputList = (EList<String>) tableViewer.getInput(); if (newInputList == null) { newInputList = new BasicEList<String>(); } for (int i = 0; ((i < innerValue.length) && (!elementExists)); i++) { newElement = (String) innerValue[i]; elementExists = newInputList.contains(newElement); if (!elementExists) { newInputList.add(newElement); } } if (!elementExists) { for (int i = 0; i < newInputList.size(); i++) { collection.add(newInputList.get(i)); } if (tableViewer == this.annotationsViewer) { this.jobIdentificationType.getJobAnnotation().clear(); this.jobIdentificationType.getJobAnnotation().addAll(collection); tableViewer.setInput(this.jobIdentificationType.getJobAnnotation()); } else { this.jobIdentificationType.getJobProject().clear(); this.jobIdentificationType.getJobProject().addAll(collection); tableViewer.setInput(this.jobIdentificationType.getJobProject()); } this.contentChanged(); } else { MessageDialog.openError(tableViewer.getControl().getShell(), Messages.getString("GenericDialog_DuplicateEntryDialog_Title"), //$NON-NLS-1$ Messages.getString("GenericDialog_New_DuplicateEntryDialog_Message")); //$NON-NLS-1$ } collection = null; }
From source file:eu.geclipse.jsdl.ui.internal.pages.sections.PosixApplicationSection.java
License:Open Source License
/** * Add a new Argument element to the associated Table Viewers input. * /*from ww w . j av a2 s . c o m*/ * @param tableViewer The {@link TableViewer} in which the new element will be added. * @param innerValue The new element that will be added. */ @SuppressWarnings("unchecked") protected void addNewArgument(final TableViewer tableViewer, final Object innerValue) { boolean elementExists = false; String newElement; if (innerValue == null) { return; } EList<ArgumentType> newInputList = (EList<ArgumentType>) tableViewer.getInput(); if (newInputList == null) { newInputList = new BasicEList<ArgumentType>(); } /* Check if PosixApplication Element Exists */ checkPosixApplicationElement(); this.argumentType = PosixFactory.eINSTANCE.createArgumentType(); this.argumentType = (ArgumentType) innerValue; newElement = this.argumentType.getValue(); Iterator<ArgumentType> iter = newInputList.iterator(); while (iter.hasNext() && !elementExists) { elementExists = iter.next().getValue().equals(newElement); } if (!elementExists) { newInputList.add(this.argumentType); /* Add the Argument to PosixApplication */ this.applicationType = (ApplicationType) checkProxy(this.applicationType); this.posixApplicationType = (POSIXApplicationType) checkProxy(this.posixApplicationType); this.argumentType = (ArgumentType) checkProxy(this.argumentType); this.posixApplicationType.getArgument().addAll(newInputList); tableViewer.setInput(this.posixApplicationType.getArgument()); tableViewer.refresh(); contentChanged(); } else { MessageDialog.openError(tableViewer.getControl().getShell(), Messages.getString("Arguments_DuplicateEntryDialog_Title"), //$NON-NLS-1$ Messages.getString("Arguments_New_DuplicateEntryDialog_Message")); //$NON-NLS-1$ } }
From source file:eu.geclipse.jsdl.ui.internal.pages.sections.PosixApplicationSection.java
License:Open Source License
/** * Add a new Argument element to the associated Table Viewers input. * /*www .j av a 2 s . c o m*/ * @param tableViewer The {@link TableViewer} in which the new element will be added. * @param innerValue The new element that will be added. */ @SuppressWarnings("unchecked") protected void addNewEnvVariable(final TableViewer tableViewer, final Object innerValue) { boolean elementExists = false; String newElement; if (innerValue == null) { return; } EList<EnvironmentType> newInputList = (EList<EnvironmentType>) tableViewer.getInput(); if (newInputList == null) { newInputList = new BasicEList<EnvironmentType>(); } /* Check if PosixApplication Element Exists */ checkPosixApplicationElement(); this.environmentType = PosixFactory.eINSTANCE.createEnvironmentType(); this.environmentType = (EnvironmentType) innerValue; newElement = this.environmentType.getValue(); Iterator<EnvironmentType> iter = newInputList.iterator(); while (iter.hasNext() && !elementExists) { elementExists = iter.next().getValue().equals(newElement); } if (!elementExists) { newInputList.add(this.environmentType); /* Add the Argument to PosixApplication */ this.posixApplicationType.getEnvironment().addAll(newInputList); tableViewer.setInput(this.posixApplicationType.getEnvironment()); tableViewer.refresh(); contentChanged(); } else { MessageDialog.openError(tableViewer.getControl().getShell(), Messages.getString("EnvironmentalVar_DuplicateEntryDialog_Title"), //$NON-NLS-1$ Messages.getString("EnvironmentalVar_New_DuplicateEntryDialog_Message")); //$NON-NLS-1$ } newInputList = null; }
From source file:eu.geclipse.jsdl.ui.internal.pages.sections.PosixApplicationSection.java
License:Open Source License
/** * Edit an element that appears in a Table Viewers. * //w w w. j a v a 2 s . c o m * @param tableViewer The {@link TableViewer} in which the new element appears. * @param innerValue The new value of the element. */ @SuppressWarnings("unchecked") public void performEdit(final TableViewer tableViewer, final Object innerValue) { boolean elementExists = false; String newElement; int featureID; if (innerValue == null) { return; } EStructuralFeature eStructuralFeature; /* * Get the TableViewer Selection */ IStructuredSelection structSelection = (IStructuredSelection) tableViewer.getSelection(); /* If the selection is not null then Change the selected element */ if (structSelection != null) { Object feature = structSelection.getFirstElement(); if (tableViewer == this.argumentViewer) { EList<ArgumentType> newInputList = (EList<ArgumentType>) tableViewer.getInput(); if (newInputList == null) { newInputList = new BasicEList<ArgumentType>(); } Iterator<ArgumentType> iter = newInputList.iterator(); featureID = PosixPackage.POSIX_APPLICATION_TYPE__ARGUMENT; eStructuralFeature = this.posixApplicationType.eClass().getEStructuralFeature(featureID); /* Get the Index of the Element that needs to be changed */ int index = ((java.util.List<Object>) this.posixApplicationType.eGet(eStructuralFeature)) .indexOf(feature); /* * Create a new Argument Type EObject with the new values that will * substitute the old EObject. */ this.argumentType = PosixFactory.eINSTANCE.createArgumentType(); this.argumentType = (ArgumentType) innerValue; newElement = this.argumentType.getValue(); /* Change the element. The element is located through it's index position * in the list. */ while (iter.hasNext() && !elementExists) { ArgumentType tempArgumentType = iter.next(); if ((tempArgumentType.getValue().equals(newElement)) && (!tempArgumentType.equals(feature))) { elementExists = true; } } if (!elementExists) { ((java.util.List<Object>) this.posixApplicationType.eGet(eStructuralFeature)).set(index, this.argumentType); contentChanged(); } else { MessageDialog.openError(tableViewer.getControl().getShell(), Messages.getString("Arguments_DuplicateEntryDialog_Title"), //$NON-NLS-1$ Messages.getString("Arguments_New_DuplicateEntryDialog_Message")); //$NON-NLS-1$ } } else { EList<EnvironmentType> newInputList = (EList<EnvironmentType>) tableViewer.getInput(); if (newInputList == null) { newInputList = new BasicEList<EnvironmentType>(); } Iterator<EnvironmentType> iter = newInputList.iterator(); featureID = PosixPackage.POSIX_APPLICATION_TYPE__ENVIRONMENT; eStructuralFeature = this.posixApplicationType.eClass().getEStructuralFeature(featureID); /* Get the Index of the Element that needs to be changed */ int index = ((java.util.List<Object>) this.posixApplicationType.eGet(eStructuralFeature)) .indexOf(feature); /* * Create a new Environment Type EObject with the new values that will * substitute the old EObject. */ this.environmentType = PosixFactory.eINSTANCE.createEnvironmentType(); this.environmentType = (EnvironmentType) innerValue; newElement = this.environmentType.getName(); /* Change the element. The element is located through it's index position * in the list. */ while (iter.hasNext() && !elementExists) { EnvironmentType tempEnvironmentType = iter.next(); if ((tempEnvironmentType.getName().equals(newElement)) && (!tempEnvironmentType.equals(feature))) { elementExists = true; } } if (!elementExists) { ((java.util.List<Object>) this.posixApplicationType.eGet(eStructuralFeature)).set(index, this.environmentType); contentChanged(); } else { MessageDialog.openError(tableViewer.getControl().getShell(), Messages.getString("EnvironmentalVar_DuplicateEntryDialog_Title"), //$NON-NLS-1$ Messages.getString("EnvironmentalVar_New_DuplicateEntryDialog_Message")); //$NON-NLS-1$ } } feature = null; eStructuralFeature = null; tableViewer.refresh(); } }