use of org.eclipse.jface.viewers.IStructuredContentProvider in project liferay-ide by liferay.
the class WorkingSetGroup method _createControl.
private void _createControl(Composite container) {
addToWorkingSetButton = new Button(container, SWT.CHECK);
GridData gd_addToWorkingSetButton = new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1);
gd_addToWorkingSetButton.verticalIndent = 12;
addToWorkingSetButton.setLayoutData(gd_addToWorkingSetButton);
addToWorkingSetButton.setSelection(true);
addToWorkingSetButton.setData("name", "addToWorkingSetButton");
addToWorkingSetButton.setText("Add project to working set");
addToWorkingSetButton.setSelection(false);
final Label workingsetLabel = new Label(container, SWT.NONE);
GridData gd_workingsetLabel = new GridData();
gd_workingsetLabel.horizontalIndent = 10;
workingsetLabel.setLayoutData(gd_workingsetLabel);
workingsetLabel.setEnabled(false);
workingsetLabel.setData("name", "workingsetLabel");
workingsetLabel.setText("Working set:");
Combo workingsetCombo = new Combo(container, SWT.READ_ONLY);
workingsetCombo.setEnabled(false);
workingsetCombo.setData("name", "workingsetCombo");
workingsetCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
_workingsetComboViewer = new ComboViewer(workingsetCombo);
_workingsetComboViewer.setContentProvider(new IStructuredContentProvider() {
public void dispose() {
}
public Object[] getElements(Object input) {
if (input instanceof IWorkingSet[]) {
return (IWorkingSet[]) input;
} else if (input instanceof List<?>) {
return new Object[] { input };
} else if (input instanceof Set<?>) {
return ((Set<?>) input).toArray();
}
return new IWorkingSet[0];
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
_workingsetComboViewer.setLabelProvider(new LabelProvider() {
public void dispose() {
_images.dispose();
super.dispose();
}
@SuppressWarnings("deprecation")
public Image getImage(Object element) {
if (element instanceof IWorkingSet) {
ImageDescriptor imageDescriptor = ((IWorkingSet) element).getImage();
if (imageDescriptor != null) {
try {
return (Image) _images.create(imageDescriptor);
} catch (DeviceResourceException dre) {
return null;
}
}
}
return super.getImage(element);
}
public String getText(Object element) {
if (element instanceof IWorkingSet) {
return ((IWorkingSet) element).getLabel();
} else if (element instanceof List<?>) {
StringBuffer sb = new StringBuffer();
for (Object o : (List<?>) element) {
if (o instanceof IWorkingSet) {
if (sb.length() > 0) {
sb.append(", ");
}
sb.append(((IWorkingSet) o).getLabel());
}
}
return sb.toString();
}
return super.getText(element);
}
private ResourceManager _images = new LocalResourceManager(JFaceResources.getResources());
});
_workingsetComboViewer.setComparator(new ViewerComparator());
final Button newWorkingSetButton = new Button(container, SWT.NONE);
newWorkingSetButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
newWorkingSetButton.setData("name", "configureButton");
newWorkingSetButton.setText("More...");
newWorkingSetButton.setEnabled(false);
newWorkingSetButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent e) {
IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager();
IWorkingSetSelectionDialog dialog = workingSetManager.createWorkingSetSelectionDialog(_shell, true, _working_set_ids.toArray(new String[0]));
if (dialog.open() == Window.OK) {
IWorkingSet[] workingSets = dialog.getSelection();
selectWorkingSets(Arrays.asList(workingSets));
}
}
});
if (selectWorkingSets(_workingSets)) {
addToWorkingSetButton.setSelection(true);
workingsetLabel.setEnabled(true);
_workingsetComboViewer.getCombo().setEnabled(true);
newWorkingSetButton.setEnabled(true);
}
addToWorkingSetButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
boolean addToWorkingingSet = addToWorkingSetButton.getSelection();
workingsetLabel.setEnabled(addToWorkingingSet);
_workingsetComboViewer.getCombo().setEnabled(addToWorkingingSet);
newWorkingSetButton.setEnabled(addToWorkingingSet);
if (addToWorkingingSet) {
updateConfiguration();
} else {
_workingSets.clear();
}
}
});
_workingsetComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
updateConfiguration();
}
});
}
use of org.eclipse.jface.viewers.IStructuredContentProvider in project mdw-designer by CenturyLinkCloud.
the class ProcessExplorerActionGroup method createFilterToolbarAction.
private IAction createFilterToolbarAction() {
IAction action = new Action() {
@Override
public void run() {
IPreferenceStore prefsStore = MdwPlugin.getDefault().getPreferenceStore();
List<String> options = new ArrayList<>();
options.add(PreferenceConstants.PREFS_FILTER_PROCESSES_IN_PEX);
options.add(PreferenceConstants.PREFS_FILTER_WORKFLOW_ASSETS_IN_PEX);
options.add(PreferenceConstants.PREFS_FILTER_EVENT_HANDLERS_IN_PEX);
options.add(PreferenceConstants.PREFS_SHOW_ACTIVITY_IMPLEMENTORS_IN_PEX);
options.add(PreferenceConstants.PREFS_FILTER_TASK_TEMPLATES_IN_PEX);
options.add(PreferenceConstants.PREFS_FILTER_ARCHIVED_ITEMS_IN_PEX);
List<String> selected = new ArrayList<>();
for (String option : options) {
boolean show = !prefsStore.getBoolean(option);
if (option.startsWith("Show"))
// means default is filtered
show = !show;
if (show)
selected.add(option);
}
ListSelectionDialog lsd = new ListSelectionDialog(view.getSite().getShell(), options, new IStructuredContentProvider() {
public Object[] getElements(Object inputElement) {
return ((List<?>) inputElement).toArray(new String[0]);
}
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
// do nothing
}
@Override
public void dispose() {
// do nothing
}
}, new ILabelProvider() {
public void addListener(ILabelProviderListener listener) {
// do nothing
}
public void removeListener(ILabelProviderListener listener) {
// do nothing
}
public boolean isLabelProperty(Object element, String property) {
return false;
}
public void dispose() {
// do nothing
}
public Image getImage(Object element) {
return null;
}
public String getText(Object element) {
if (PreferenceConstants.PREFS_FILTER_PROCESSES_IN_PEX.equals(element))
return "Processes";
else if (PreferenceConstants.PREFS_FILTER_WORKFLOW_ASSETS_IN_PEX.equals(element))
return "Assets";
else if (PreferenceConstants.PREFS_FILTER_EVENT_HANDLERS_IN_PEX.equals(element))
return "Event Handlers";
else if (PreferenceConstants.PREFS_SHOW_ACTIVITY_IMPLEMENTORS_IN_PEX.equals(element))
return "Activity Implementors";
else if (PreferenceConstants.PREFS_FILTER_TASK_TEMPLATES_IN_PEX.equals(element))
return "Task Templates";
else if (PreferenceConstants.PREFS_FILTER_ARCHIVED_ITEMS_IN_PEX.equals(element))
return "Archived Items";
else
return null;
}
}, "Workflow elements to display in Process Explorer");
lsd.setTitle("Show Package Contents");
lsd.setInitialSelections(selected.toArray(new String[0]));
int res = lsd.open();
if (res != Dialog.CANCEL) {
Object[] results = lsd.getResult();
for (String option : options) {
boolean show = false;
for (Object result : results) {
if (option.equals(result))
show = true;
}
if (option.startsWith("Filter"))
// default is to show
show = !show;
prefsStore.setValue(option, show);
}
view.handleApply();
}
}
};
action.setText("Filter Package Contents");
action.setId(MdwMenuManager.MDW_MENU_PREFIX + "filter.package.contents");
ImageDescriptor sortImageDesc = MdwPlugin.getImageDescriptor("icons/filter.gif");
action.setImageDescriptor(sortImageDesc);
return action;
}
use of org.eclipse.jface.viewers.IStructuredContentProvider in project tmdm-studio-se by Talend.
the class XSDEditElementAction method doAction.
@Override
public IStatus doAction() {
try {
ISelection selection = page.getTreeViewer().getSelection();
XSDElementDeclaration decl = (XSDElementDeclaration) ((IStructuredSelection) selection).getFirstElement();
ArrayList<Object> objList = new ArrayList<Object>();
IStructuredContentProvider provider = (IStructuredContentProvider) page.getTreeViewer().getContentProvider();
String oldName = decl.getName();
InputDialog id = new InputDialog(page.getSite().getShell(), Messages.XSDEditElementAction_EditElement, Messages.XSDEditElementAction_EnterNameForElement, oldName, new EditXSDEleDecNameValidator(schema));
id.setBlockOnOpen(true);
int ret = id.open();
if (ret == Window.CANCEL) {
return Status.CANCEL_STATUS;
}
Object[] objs = Util.getAllObject(page.getSite(), objList, provider);
Object[] allForeignKeyRelatedInfos = Util.getAllForeignKeyRelatedInfos(page.getSite(), new ArrayList<Object>(), provider, new HashSet<Object>());
decl.setName(id.getValue());
decl.updateElement();
Util.updateReference(decl, objs, allForeignKeyRelatedInfos, oldName, id.getValue());
// change unique key with new name of concept
EList list = decl.getIdentityConstraintDefinitions();
XSDIdentityConstraintDefinition toUpdate = null;
for (Iterator iter = list.iterator(); iter.hasNext(); ) {
XSDIdentityConstraintDefinition icd = (XSDIdentityConstraintDefinition) iter.next();
if (icd.getName().equals(oldName)) {
toUpdate = icd;
break;
}
}
if (toUpdate != null) {
toUpdate.setName(id.getValue());
toUpdate.updateElement();
}
page.refresh();
page.markDirty();
} catch (Exception e) {
log.error(e.getMessage(), e);
MessageDialog.openError(page.getSite().getShell(), Messages._Error, Messages.bind(Messages.XSDEditElementAction_ErrorEditElement, e.getLocalizedMessage()));
return Status.CANCEL_STATUS;
}
return Status.OK_STATUS;
}
use of org.eclipse.jface.viewers.IStructuredContentProvider in project tmdm-studio-se by Talend.
the class XSDEditParticleAction method updateReference.
private void updateReference(String originalXpath) {
XSDElementDeclaration decl = (XSDElementDeclaration) selParticle.getContent();
// $NON-NLS-1$
int lastIndex = originalXpath.lastIndexOf("/");
String newXpath = decl.getName();
newXpath = originalXpath.substring(0, lastIndex + 1) + newXpath;
IStructuredContentProvider provider = (IStructuredContentProvider) page.getTreeViewer().getContentProvider();
Object[] allForeignKeyRelatedInfos = Util.getAllForeignKeyRelatedInfos(page.getSite(), new ArrayList<Object>(), provider, new HashSet<Object>());
Util.updateForeignKeyRelatedInfo(originalXpath, newXpath, allForeignKeyRelatedInfos);
}
use of org.eclipse.jface.viewers.IStructuredContentProvider in project tmdm-studio-se by Talend.
the class XSDDeleteConceptAction method isCommonReferedBy.
private boolean isCommonReferedBy(XSDElementDeclaration decl) {
List<Object> objList = new ArrayList<Object>();
IStructuredContentProvider elementContentProvider = (IStructuredContentProvider) page.getTreeViewer().getContentProvider();
Object[] objs = Util.getAllObject(page.getSite(), objList, elementContentProvider);
objList.clear();
IStructuredContentProvider typeContentProvider = (IStructuredContentProvider) page.getTypesViewer().getContentProvider();
Object[] typeElems = Util.getAllObject(page.getSite(), objList, typeContentProvider);
boolean referencedBy = Util.isReferencedBy(decl, objs) || Util.isReferencedBy(decl, typeElems);
return referencedBy;
}
Aggregations