List of usage examples for org.eclipse.jface.databinding.swt WidgetProperties selection
public static IWidgetValueProperty selection()
From source file:org.eclipse.e4.internal.tools.wizards.classes.NewToolControlClassWizard.java
License:Open Source License
@Override public void addPages() { addPage(new AbstractNewClassPage("Classinformation", "New Tool Control", "Create a new tool control class", root, ResourcesPlugin.getWorkspace().getRoot(), initialString) { @Override//from ww w .j ava 2 s . co m protected JavaClass createInstance() { return new ToolControlClass(root); } @Override protected void createFields(Composite parent, DataBindingContext dbc) { IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify); { Label l = new Label(parent, SWT.NONE); l.setText("Create GUI Method"); Text t = new Text(parent, SWT.BORDER); t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); dbc.bindValue(textProp.observe(t), BeanProperties.value("createGuiMethodName").observe(getClazz())); l = new Label(parent, SWT.NONE); } { Label l = new Label(parent, SWT.NONE); l.setText("Create Default Constructor"); // Text t = new Text(parent, SWT.BORDER); // t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); // dbc.bindValue(textProp.observe(t), // BeanProperties.value("defaultConstructorName") // .observe(getClazz())); // dbc.bindValue( // WidgetProperties.enabled().observe(t), // BeanProperties.value("useDefaultConstructor").observe( // getClazz())); Button b = new Button(parent, SWT.CHECK); dbc.bindValue(WidgetProperties.selection().observe(b), BeanProperties.value("createDefaultConstructor").observe(getClazz())); } } }); }
From source file:org.eclipse.e4.tools.emf.ui.internal.common.component.ApplicationEditor.java
License:Open Source License
protected Composite createForm(Composite parent, EMFDataBindingContext context) { CTabFolder folder = new CTabFolder(parent, SWT.BOTTOM); CTabItem item = new CTabItem(folder, SWT.NONE); item.setText(Messages.ModelTooling_Common_TabDefault); parent = createScrollableContainer(folder); item.setControl(parent.getParent()); IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify); if (getEditor().isShowXMIId() || getEditor().isLiveModel()) { ControlFactory.createXMIId(parent, this); }/* ww w . jav a 2 s . c o m*/ ControlFactory.createTextField(parent, Messages.ModelTooling_Common_Id, getMaster(), context, textProp, EMFEditProperties.value(getEditingDomain(), ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__ELEMENT_ID)); ControlFactory.createBindingContextWiget(parent, Messages, this, Messages.ApplicationEditor_BindingContexts); ControlFactory.createCheckBox(parent, Messages.ModelTooling_UIElement_ToBeRendered, getMaster(), context, WidgetProperties.selection(), EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_ELEMENT__TO_BE_RENDERED)); ControlFactory.createCheckBox(parent, Messages.ModelTooling_UIElement_Visible, getMaster(), context, WidgetProperties.selection(), EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_ELEMENT__VISIBLE)); item = new CTabItem(folder, SWT.NONE); item.setText(Messages.ModelTooling_Common_TabSupplementary); parent = createScrollableContainer(folder); item.setControl(parent.getParent()); ControlFactory.createTextField(parent, Messages.ModelTooling_UIElement_AccessibilityPhrase, getMaster(), context, textProp, EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_ELEMENT__ACCESSIBILITY_PHRASE)); ControlFactory.createStringListWidget(parent, Messages, this, Messages.ModelTooling_Context_Variables, UiPackageImpl.Literals.CONTEXT__VARIABLES, VERTICAL_LIST_WIDGET_INDENT); ControlFactory.createStringListWidget(parent, Messages, this, Messages.AddonsEditor_Tags, ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__TAGS, VERTICAL_LIST_WIDGET_INDENT); ControlFactory.createMapProperties(parent, Messages, this, Messages.ModelTooling_Contribution_PersistedState, ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__PERSISTED_STATE, VERTICAL_LIST_WIDGET_INDENT); if (project == null) { createUITreeInspection(folder); } createContributedEditorTabs(folder, context, getMaster(), MApplication.class); folder.setSelection(0); return folder; }
From source file:org.eclipse.e4.tools.emf.ui.internal.common.component.AreaEditor.java
License:Open Source License
private Composite createForm(Composite parent, final EMFDataBindingContext context, WritableValue master, boolean isImport) { CTabFolder folder = new CTabFolder(parent, SWT.BOTTOM); CTabItem item = new CTabItem(folder, SWT.NONE); item.setText(Messages.ModelTooling_Common_TabDefault); parent = createScrollableContainer(folder); item.setControl(parent.getParent()); if (getEditor().isShowXMIId() || getEditor().isLiveModel()) { ControlFactory.createXMIId(parent, this); }//from w w w .j a va2 s . com IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify); if (isImport) { ControlFactory.createFindImport(parent, Messages, this, context); folder.setSelection(0); return folder; } ControlFactory.createTextField(parent, Messages.ModelTooling_Common_Id, getMaster(), context, textProp, EMFEditProperties.value(getEditingDomain(), ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__ELEMENT_ID)); ControlFactory.createTextField(parent, Messages.AreaEditor_LabelLabel, master, context, textProp, EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_LABEL__LABEL)); ControlFactory.createTextField(parent, Messages.AreaEditor_Tooltip, master, context, textProp, EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_LABEL__TOOLTIP)); // ------------------------------------------------------------ { Label l = new Label(parent, SWT.NONE); l.setText(Messages.AreaEditor_IconURI); l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); final Text t = new Text(parent, SWT.BORDER); TextPasteHandler.createFor(t); t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); context.bindValue(textProp.observeDelayed(200, t), EMFEditProperties .value(getEditingDomain(), UiPackageImpl.Literals.UI_LABEL__ICON_URI).observeDetail(master)); new ImageTooltip(t, Messages) { @Override protected URI getImageURI() { MUILabel part = (MUILabel) getMaster().getValue(); String uri = part.getIconURI(); if (uri == null || uri.trim().length() == 0) { return null; } return URI.createURI(part.getIconURI()); } }; final Button b = new Button(parent, SWT.PUSH | SWT.FLAT); b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false)); b.setImage(createImage(ResourceProvider.IMG_Obj16_zoom)); b.setText(Messages.ModelTooling_Common_FindEllipsis); b.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { AreaIconDialogEditor dialog = new AreaIconDialogEditor(b.getShell(), eclipseContext, project, getEditingDomain(), (MApplicationElement) getMaster().getValue(), Messages); dialog.open(); } }); } // ------------------------------------------------------------ { Label l = new Label(parent, SWT.NONE); l.setText(Messages.AreaEditor_Orientation); l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); ComboViewer viewer = new ComboViewer(parent); GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 2; viewer.getControl().setLayoutData(gd); viewer.setContentProvider(new ArrayContentProvider()); viewer.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { return ((Boolean) element).booleanValue() ? Messages.AreaEditor_Horizontal : Messages.AreaEditor_Vertical; } }); viewer.setInput(new Boolean[] { Boolean.TRUE, Boolean.FALSE }); IViewerValueProperty vProp = ViewerProperties.singleSelection(); context.bindValue(vProp.observe(viewer), EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.GENERIC_TILE__HORIZONTAL) .observeDetail(getMaster())); } ControlFactory.createSelectedElement(parent, this, context, Messages.AreaEditor_SelectedElement); ControlFactory.createTextField(parent, Messages.AreaEditor_ContainerData, getMaster(), context, textProp, EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_ELEMENT__CONTAINER_DATA)); { Label l = new Label(parent, SWT.NONE); l.setText(Messages.AreaEditor_Controls); l.setLayoutData(new GridData(GridData.END, GridData.BEGINNING, false, false)); final TableViewer viewer = new TableViewer(parent); GridData gd = new GridData(GridData.FILL_BOTH); viewer.getControl().setLayoutData(gd); ObservableListContentProvider cp = new ObservableListContentProvider(); viewer.setContentProvider(cp); viewer.setLabelProvider(new ComponentLabelProvider(getEditor(), Messages)); IEMFListProperty prop = EMFProperties.list(UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN); viewer.setInput(prop.observeDetail(getMaster())); Composite buttonComp = new Composite(parent, SWT.NONE); buttonComp.setLayoutData(new GridData(GridData.FILL, GridData.END, false, false)); GridLayout gl = new GridLayout(2, false); gl.marginLeft = 0; gl.marginRight = 0; gl.marginWidth = 0; gl.marginHeight = 0; buttonComp.setLayout(gl); Button b = new Button(buttonComp, SWT.PUSH | SWT.FLAT); b.setText(Messages.ModelTooling_Common_Up); b.setImage(createImage(ResourceProvider.IMG_Obj16_arrow_up)); b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 2, 1)); b.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (!viewer.getSelection().isEmpty()) { IStructuredSelection s = (IStructuredSelection) viewer.getSelection(); if (s.size() == 1) { Object obj = s.getFirstElement(); MElementContainer<?> container = (MElementContainer<?>) getMaster().getValue(); int idx = container.getChildren().indexOf(obj) - 1; if (idx >= 0) { if (Util.moveElementByIndex(getEditingDomain(), (MUIElement) obj, getEditor().isLiveModel(), idx)) { viewer.setSelection(new StructuredSelection(obj)); } } } } } }); b = new Button(buttonComp, SWT.PUSH | SWT.FLAT); b.setText(Messages.ModelTooling_Common_Down); b.setImage(createImage(ResourceProvider.IMG_Obj16_arrow_down)); b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 2, 1)); b.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (!viewer.getSelection().isEmpty()) { IStructuredSelection s = (IStructuredSelection) viewer.getSelection(); if (s.size() == 1) { Object obj = s.getFirstElement(); MElementContainer<?> container = (MElementContainer<?>) getMaster().getValue(); int idx = container.getChildren().indexOf(obj) + 1; if (idx < container.getChildren().size()) { if (Util.moveElementByIndex(getEditingDomain(), (MUIElement) obj, getEditor().isLiveModel(), idx)) { viewer.setSelection(new StructuredSelection(obj)); } } } } } }); final ComboViewer childrenDropDown = new ComboViewer(buttonComp); childrenDropDown.getControl().setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false)); childrenDropDown.setContentProvider(new ArrayContentProvider()); childrenDropDown.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { EClass eclass = (EClass) element; return eclass.getName(); } }); childrenDropDown.setInput(new EClass[] { BasicPackageImpl.Literals.PART_SASH_CONTAINER, BasicPackageImpl.Literals.PART_STACK, BasicPackageImpl.Literals.PART, BasicPackageImpl.Literals.INPUT_PART, AdvancedPackageImpl.Literals.AREA, AdvancedPackageImpl.Literals.PLACEHOLDER }); childrenDropDown.setSelection(new StructuredSelection(BasicPackageImpl.Literals.PART_SASH_CONTAINER)); b = new Button(buttonComp, SWT.PUSH | SWT.FLAT); b.setImage(createImage(ResourceProvider.IMG_Obj16_table_add)); b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false)); b.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (!childrenDropDown.getSelection().isEmpty()) { EClass eClass = (EClass) ((IStructuredSelection) childrenDropDown.getSelection()) .getFirstElement(); handleAddChild(eClass); } } }); b = new Button(buttonComp, SWT.PUSH | SWT.FLAT); b.setText(Messages.ModelTooling_Common_Remove); b.setImage(createImage(ResourceProvider.IMG_Obj16_table_delete)); b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 2, 1)); b.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (!viewer.getSelection().isEmpty()) { List<?> elements = ((IStructuredSelection) viewer.getSelection()).toList(); Command cmd = RemoveCommand.create(getEditingDomain(), getMaster().getValue(), UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN, elements); if (cmd.canExecute()) { getEditingDomain().getCommandStack().execute(cmd); } } } }); } ControlFactory.createCheckBox(parent, Messages.ModelTooling_UIElement_ToBeRendered, getMaster(), context, WidgetProperties.selection(), EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_ELEMENT__TO_BE_RENDERED)); ControlFactory.createCheckBox(parent, Messages.ModelTooling_UIElement_Visible, getMaster(), context, WidgetProperties.selection(), EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_ELEMENT__VISIBLE)); item = new CTabItem(folder, SWT.NONE); item.setText(Messages.ModelTooling_Common_TabSupplementary); parent = createScrollableContainer(folder); item.setControl(parent.getParent()); ControlFactory.createTextField(parent, Messages.ModelTooling_UIElement_AccessibilityPhrase, getMaster(), context, textProp, EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_ELEMENT__ACCESSIBILITY_PHRASE)); ControlFactory.createStringListWidget(parent, Messages, this, Messages.ModelTooling_ApplicationElement_Tags, ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__TAGS, VERTICAL_LIST_WIDGET_INDENT); ControlFactory.createMapProperties(parent, Messages, this, Messages.ModelTooling_Contribution_PersistedState, ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__PERSISTED_STATE, VERTICAL_LIST_WIDGET_INDENT); if (project == null) { createUITreeInspection(folder); } createContributedEditorTabs(folder, context, getMaster(), MArea.class); folder.setSelection(0); return folder; }
From source file:org.eclipse.e4.tools.emf.ui.internal.common.component.CommandParameterEditor.java
License:Open Source License
private Composite createForm(Composite parent, EMFDataBindingContext context, WritableValue master, boolean isImport) { CTabFolder folder = new CTabFolder(parent, SWT.BOTTOM); CTabItem item = new CTabItem(folder, SWT.NONE); item.setText(Messages.ModelTooling_Common_TabDefault); parent = createScrollableContainer(folder); item.setControl(parent.getParent()); IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify); if (getEditor().isShowXMIId() || getEditor().isLiveModel()) { ControlFactory.createXMIId(parent, this); }/*ww w . j a v a 2 s. c o m*/ if (isImport) { ControlFactory.createFindImport(parent, Messages, this, context); folder.setSelection(0); return folder; } ControlFactory.createTextField(parent, Messages.ModelTooling_Common_Id, master, context, textProp, EMFEditProperties.value(getEditingDomain(), ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__ELEMENT_ID), Messages.ModelTooling_Empty_Warning); ControlFactory.createTextField(parent, Messages.CommandParameterEditor_Name, master, context, textProp, EMFEditProperties.value(getEditingDomain(), CommandsPackageImpl.Literals.COMMAND_PARAMETER__NAME), Messages.ModelTooling_Empty_Warning); ControlFactory.createTextField(parent, Messages.CommandParameterEditor_TypeId, master, context, textProp, EMFEditProperties.value(getEditingDomain(), CommandsPackageImpl.Literals.COMMAND_PARAMETER__TYPE_ID)); { Label l = new Label(parent, SWT.NONE); l.setText(Messages.CommandParameterEditor_Optional); l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Button checkbox = new Button(parent, SWT.CHECK); checkbox.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false, 2, 1)); IEMFEditValueProperty mprop = EMFEditProperties.value(getEditingDomain(), CommandsPackageImpl.Literals.COMMAND_PARAMETER__OPTIONAL); IWidgetValueProperty uiProp = WidgetProperties.selection(); context.bindValue(uiProp.observe(checkbox), mprop.observeDetail(master)); } item = new CTabItem(folder, SWT.NONE); item.setText(Messages.ModelTooling_Common_TabSupplementary); parent = createScrollableContainer(folder); item.setControl(parent.getParent()); ControlFactory.createStringListWidget(parent, Messages, this, Messages.CategoryEditor_Tags, ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__TAGS, VERTICAL_LIST_WIDGET_INDENT); ControlFactory.createMapProperties(parent, Messages, this, Messages.ModelTooling_Contribution_PersistedState, ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__PERSISTED_STATE, VERTICAL_LIST_WIDGET_INDENT); createContributedEditorTabs(folder, context, getMaster(), MCommandParameter.class); folder.setSelection(0); return folder; }
From source file:org.eclipse.e4.tools.emf.ui.internal.common.component.MenuContributionEditor.java
License:Open Source License
private Composite createForm(Composite parent, EMFDataBindingContext context, WritableValue master, boolean isImport) { CTabFolder folder = new CTabFolder(parent, SWT.BOTTOM); CTabItem item = new CTabItem(folder, SWT.NONE); item.setText(Messages.ModelTooling_Common_TabDefault); parent = createScrollableContainer(folder); item.setControl(parent.getParent()); if (getEditor().isShowXMIId() || getEditor().isLiveModel()) { ControlFactory.createXMIId(parent, this); }//from w w w .j av a2s . c om IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify); if (isImport) { ControlFactory.createFindImport(parent, Messages, this, context); folder.setSelection(0); return folder; } ControlFactory.createTextField(parent, Messages.ModelTooling_Common_Id, master, context, textProp, EMFEditProperties.value(getEditingDomain(), ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__ELEMENT_ID)); ControlFactory.createTextField(parent, Messages.ModelTooling_UIElement_AccessibilityPhrase, getMaster(), context, textProp, EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_ELEMENT__ACCESSIBILITY_PHRASE)); { Label l = new Label(parent, SWT.NONE); l.setText(Messages.MenuContributionEditor_ParentId); l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); final Text t = new Text(parent, SWT.BORDER); TextPasteHandler.createFor(t); GridData gd = new GridData(GridData.FILL_HORIZONTAL); t.setLayoutData(gd); context.bindValue(textProp.observeDelayed(200, t), EMFEditProperties .value(getEditingDomain(), MenuPackageImpl.Literals.MENU_CONTRIBUTION__PARENT_ID) .observeDetail(getMaster())); Button b = new Button(parent, SWT.PUSH | SWT.FLAT); b.setText(Messages.ModelTooling_Common_FindEllipsis); b.setImage(createImage(ResourceProvider.IMG_Obj16_zoom)); b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false)); b.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { MenuIdDialog dialog = new MenuIdDialog(t.getShell(), resource, (MMenuContribution) getMaster().getValue(), getEditingDomain(), modelService, Messages); dialog.open(); } }); } ControlFactory.createTextField(parent, Messages.MenuContributionEditor_Position, master, context, textProp, EMFEditProperties.value(getEditingDomain(), MenuPackageImpl.Literals.MENU_CONTRIBUTION__POSITION_IN_PARENT)); // ------------------------------------------------------------ { Label l = new Label(parent, SWT.NONE); l.setText(Messages.MenuContributionEditor_MenuItems); l.setLayoutData(new GridData(GridData.END, GridData.BEGINNING, false, false)); final TableViewer viewer = new TableViewer(parent); ObservableListContentProvider cp = new ObservableListContentProvider(); viewer.setContentProvider(cp); viewer.setLabelProvider(new ComponentLabelProvider(getEditor(), Messages)); GridData gd = new GridData(GridData.FILL_BOTH); viewer.getControl().setLayoutData(gd); IEMFListProperty prop = EMFEditProperties.list(getEditingDomain(), UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN); viewer.setInput(prop.observeDetail(master)); Composite buttonComp = new Composite(parent, SWT.NONE); buttonComp.setLayoutData(new GridData(GridData.FILL, GridData.END, false, false)); GridLayout gl = new GridLayout(2, false); gl.marginLeft = 0; gl.marginRight = 0; gl.marginWidth = 0; gl.marginHeight = 0; buttonComp.setLayout(gl); Button b = new Button(buttonComp, SWT.PUSH | SWT.FLAT); b.setText(Messages.ModelTooling_Common_Up); b.setImage(createImage(ResourceProvider.IMG_Obj16_arrow_up)); b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 2, 1)); b.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (!viewer.getSelection().isEmpty()) { IStructuredSelection s = (IStructuredSelection) viewer.getSelection(); if (s.size() == 1) { Object obj = s.getFirstElement(); MElementContainer<?> container = (MElementContainer<?>) getMaster().getValue(); int idx = container.getChildren().indexOf(obj) - 1; if (idx >= 0) { if (Util.moveElementByIndex(getEditingDomain(), (MUIElement) obj, getEditor().isLiveModel(), idx)) { viewer.setSelection(new StructuredSelection(obj)); } } } } } }); b = new Button(buttonComp, SWT.PUSH | SWT.FLAT); b.setText(Messages.ModelTooling_Common_Down); b.setImage(createImage(ResourceProvider.IMG_Obj16_arrow_down)); b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 2, 1)); b.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (!viewer.getSelection().isEmpty()) { IStructuredSelection s = (IStructuredSelection) viewer.getSelection(); if (s.size() == 1) { Object obj = s.getFirstElement(); MElementContainer<?> container = (MElementContainer<?>) getMaster().getValue(); int idx = container.getChildren().indexOf(obj) + 1; if (idx < container.getChildren().size()) { if (Util.moveElementByIndex(getEditingDomain(), (MUIElement) obj, getEditor().isLiveModel(), idx)) { viewer.setSelection(new StructuredSelection(obj)); } } } } } }); final ComboViewer childrenDropDown = new ComboViewer(buttonComp); childrenDropDown.getControl().setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false)); childrenDropDown.setContentProvider(new ArrayContentProvider()); childrenDropDown.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { Struct struct = (Struct) element; return struct.label; } }); Struct defaultStruct = new Struct(Messages.MenuContributionEditor_HandledMenuItem, MenuPackageImpl.Literals.HANDLED_MENU_ITEM, false); childrenDropDown.setInput(new Struct[] { new Struct(Messages.MenuContributionEditor_Separator, MenuPackageImpl.Literals.MENU_SEPARATOR, true), new Struct(Messages.MenuContributionEditor_Menu, MenuPackageImpl.Literals.MENU, false), defaultStruct, new Struct(Messages.MenuContributionEditor_DirectMenuItem, MenuPackageImpl.Literals.DIRECT_MENU_ITEM, false), new Struct(Messages.MenuContributionEditor_DynamicMenuContribution, MenuPackageImpl.Literals.DYNAMIC_MENU_CONTRIBUTION, false) }); childrenDropDown.setSelection(new StructuredSelection(defaultStruct)); b = new Button(buttonComp, SWT.PUSH | SWT.FLAT); b.setImage(createImage(ResourceProvider.IMG_Obj16_table_add)); b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false)); b.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (!childrenDropDown.getSelection().isEmpty()) { Struct struct = (Struct) ((IStructuredSelection) childrenDropDown.getSelection()) .getFirstElement(); EClass eClass = struct.eClass; MMenuElement eObject = (MMenuElement) EcoreUtil.create(eClass); Command cmd = AddCommand.create(getEditingDomain(), getMaster().getValue(), UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN, eObject); if (cmd.canExecute()) { getEditingDomain().getCommandStack().execute(cmd); if (!struct.separator) { getEditor().setSelection(eObject); } } } } }); b = new Button(buttonComp, SWT.PUSH | SWT.FLAT); b.setText(Messages.ModelTooling_Common_Remove); b.setImage(createImage(ResourceProvider.IMG_Obj16_table_delete)); b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 2, 1)); b.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (!viewer.getSelection().isEmpty()) { List<?> keybinding = ((IStructuredSelection) viewer.getSelection()).toList(); Command cmd = RemoveCommand.create(getEditingDomain(), getMaster().getValue(), UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN, keybinding); if (cmd.canExecute()) { getEditingDomain().getCommandStack().execute(cmd); } } } }); } ControlFactory.createCheckBox(parent, "To Be Rendered", getMaster(), context, WidgetProperties.selection(), //$NON-NLS-1$ EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_ELEMENT__TO_BE_RENDERED)); ControlFactory.createCheckBox(parent, "Visible", getMaster(), context, WidgetProperties.selection(), //$NON-NLS-1$ EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_ELEMENT__VISIBLE)); item = new CTabItem(folder, SWT.NONE); item.setText(Messages.ModelTooling_Common_TabSupplementary); parent = createScrollableContainer(folder); item.setControl(parent.getParent()); ControlFactory.createStringListWidget(parent, Messages, this, Messages.CategoryEditor_Tags, ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__TAGS, VERTICAL_LIST_WIDGET_INDENT); ControlFactory.createMapProperties(parent, Messages, this, Messages.ModelTooling_Contribution_PersistedState, ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__PERSISTED_STATE, VERTICAL_LIST_WIDGET_INDENT); createContributedEditorTabs(folder, context, getMaster(), MMenuContribution.class); folder.setSelection(0); return folder; }
From source file:org.eclipse.e4.tools.emf.ui.internal.common.component.MenuEditor.java
License:Open Source License
protected Composite createForm(Composite parent, EMFDataBindingContext context, WritableValue master, boolean rootMenu, boolean isImport) { CTabFolder folder = new CTabFolder(parent, SWT.BOTTOM); CTabItem item = new CTabItem(folder, SWT.NONE); item.setText(Messages.ModelTooling_Common_TabDefault); parent = createScrollableContainer(folder); item.setControl(parent.getParent()); if (getEditor().isShowXMIId() || getEditor().isLiveModel()) { ControlFactory.createXMIId(parent, this); }/* www .j av a 2s . c om*/ IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify); if (isImport) { ControlFactory.createFindImport(parent, Messages, this, context); folder.setSelection(0); return folder; } ControlFactory.createTextField(parent, Messages.ModelTooling_Common_Id, master, context, textProp, EMFEditProperties.value(getEditingDomain(), ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__ELEMENT_ID)); // ------------------------------------------------------------ if (!rootMenu) { ControlFactory.createTranslatedTextField(parent, Messages.MenuEditor_LabelLabel, master, context, textProp, EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_LABEL__LABEL), resourcePool, project); } ControlFactory.createTextField(parent, Messages.MenuEditor_Mnemonics, master, context, textProp, EMFEditProperties.value(getEditingDomain(), MenuPackageImpl.Literals.MENU_ELEMENT__MNEMONICS)); { Label l = new Label(parent, SWT.NONE); l.setText(Messages.MenuEditor_Children); l.setLayoutData(new GridData(GridData.END, GridData.BEGINNING, false, false)); Composite buttonComp = new Composite(parent, SWT.NONE); GridData span2 = new GridData(GridData.FILL, GridData.BEGINNING, false, false, 2, 1); buttonComp.setLayoutData(span2); GridLayout gl = new GridLayout(2, false); gl.marginLeft = 0; gl.marginRight = 0; gl.marginWidth = 0; gl.marginHeight = 0; buttonComp.setLayout(gl); final ComboViewer childrenDropDown = new ComboViewer(buttonComp); childrenDropDown.getControl().setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false)); childrenDropDown.setContentProvider(new ArrayContentProvider()); childrenDropDown.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { Struct struct = (Struct) element; return struct.label; } }); Struct defaultStruct = new Struct(Messages.MenuEditor_HandledMenuItem, MenuPackageImpl.Literals.HANDLED_MENU_ITEM, false); childrenDropDown.setInput(new Struct[] { new Struct(Messages.MenuEditor_Separator, MenuPackageImpl.Literals.MENU_SEPARATOR, true), new Struct(Messages.MenuEditor_Menu, MenuPackageImpl.Literals.MENU, false), defaultStruct, new Struct(Messages.MenuEditor_DirectMenuItem, MenuPackageImpl.Literals.DIRECT_MENU_ITEM, false), new Struct(Messages.MenuEditor_DynamicMenuContribution, MenuPackageImpl.Literals.DYNAMIC_MENU_CONTRIBUTION, false) }); childrenDropDown.setSelection(new StructuredSelection(defaultStruct)); Button b = new Button(buttonComp, SWT.PUSH | SWT.FLAT); b.setText(Messages.ModelTooling_Common_AddEllipsis); b.setImage(createImage(ResourceProvider.IMG_Obj16_table_add)); b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false)); b.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (!childrenDropDown.getSelection().isEmpty()) { Struct struct = (Struct) ((IStructuredSelection) childrenDropDown.getSelection()) .getFirstElement(); EClass eClass = struct.eClass; handleAdd(eClass, struct.separator); } } }); new Label(parent, SWT.None); final TableViewer viewer = new TableViewer(parent); ObservableListContentProvider cp = new ObservableListContentProvider(); viewer.setContentProvider(cp); GridData gd = new GridData(GridData.FILL, GridData.FILL, true, true, 2, 1); viewer.getControl().setLayoutData(gd); viewer.setLabelProvider(new ComponentLabelProvider(getEditor(), Messages)); IEMFListProperty prop = EMFEditProperties.list(getEditingDomain(), UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN); viewer.setInput(prop.observeDetail(master)); new Label(parent, SWT.None); Composite buttonComp2 = new Composite(parent, SWT.NONE); buttonComp2.setLayoutData(span2); buttonComp2.setLayout(new FillLayout()); b = new Button(buttonComp2, SWT.PUSH | SWT.FLAT); b.setText(Messages.ModelTooling_Common_Up); b.setImage(createImage(ResourceProvider.IMG_Obj16_arrow_up)); b.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (!viewer.getSelection().isEmpty()) { IStructuredSelection s = (IStructuredSelection) viewer.getSelection(); if (s.size() == 1) { Object obj = s.getFirstElement(); MElementContainer<?> container = (MElementContainer<?>) getMaster().getValue(); int idx = container.getChildren().indexOf(obj) - 1; if (idx >= 0) { if (Util.moveElementByIndex(getEditingDomain(), (MUIElement) obj, getEditor().isLiveModel(), idx)) { viewer.setSelection(new StructuredSelection(obj)); } } } } } }); b = new Button(buttonComp2, SWT.PUSH | SWT.FLAT); b.setText(Messages.ModelTooling_Common_Down); b.setImage(createImage(ResourceProvider.IMG_Obj16_arrow_down)); b.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (!viewer.getSelection().isEmpty()) { IStructuredSelection s = (IStructuredSelection) viewer.getSelection(); if (s.size() == 1) { Object obj = s.getFirstElement(); MElementContainer<?> container = (MElementContainer<?>) getMaster().getValue(); int idx = container.getChildren().indexOf(obj) + 1; if (idx < container.getChildren().size()) { if (Util.moveElementByIndex(getEditingDomain(), (MUIElement) obj, getEditor().isLiveModel(), idx)) { viewer.setSelection(new StructuredSelection(obj)); } } } } } }); b = new Button(buttonComp2, SWT.PUSH | SWT.FLAT); b.setText(Messages.ModelTooling_Common_Remove); b.setImage(createImage(ResourceProvider.IMG_Obj16_table_delete)); b.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (!viewer.getSelection().isEmpty()) { List<?> keybinding = ((IStructuredSelection) viewer.getSelection()).toList(); Command cmd = RemoveCommand.create(getEditingDomain(), getMaster().getValue(), UiPackageImpl.Literals.ELEMENT_CONTAINER__CHILDREN, keybinding); if (cmd.canExecute()) { getEditingDomain().getCommandStack().execute(cmd); } } } }); } // ------------------------------------------------------------ if (!rootMenu) { ControlFactory.createTranslatedTextField(parent, Messages.MenuEditor_Tooltip, master, context, textProp, EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_LABEL__TOOLTIP), resourcePool, project); } // ------------------------------------------------------------ if (!rootMenu) { Label l = new Label(parent, SWT.NONE); l.setText(Messages.MenuEditor_IconURI); l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); TextPasteHandler.createFor(t); t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); context.bindValue(textProp.observeDelayed(200, t), EMFEditProperties .value(getEditingDomain(), UiPackageImpl.Literals.UI_LABEL__ICON_URI).observeDetail(master)); new ImageTooltip(t, Messages) { @Override protected URI getImageURI() { MUILabel part = (MUILabel) getMaster().getValue(); String uri = part.getIconURI(); if (uri == null || uri.trim().length() == 0) { return null; } return URI.createURI(part.getIconURI()); } }; final Button b = new Button(parent, SWT.PUSH | SWT.FLAT); b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false)); b.setImage(createImage(ResourceProvider.IMG_Obj16_zoom)); b.setText(Messages.ModelTooling_Common_FindEllipsis); b.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { MenuIconDialogEditor dialog = new MenuIconDialogEditor(b.getShell(), eclipseContext, project, getEditingDomain(), (MMenu) getMaster().getValue(), Messages); dialog.open(); } }); } { Label l = new Label(parent, SWT.NONE); l.setText(Messages.ModelTooling_UIElement_VisibleWhen); l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); ComboViewer combo = new ComboViewer(parent); combo.getControl().setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 2, 1)); combo.setContentProvider(new ArrayContentProvider()); combo.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { if (element instanceof EClass) { EClass eClass = (EClass) element; return eClass.getName(); } return super.getText(element); } }); List<Object> list = new ArrayList<Object>(); list.add(Messages.MenuItemEditor_NoExpression); list.add(UiPackageImpl.Literals.CORE_EXPRESSION); list.addAll(getEditor().getFeatureClasses(UiPackageImpl.Literals.EXPRESSION, UiPackageImpl.Literals.UI_ELEMENT__VISIBLE_WHEN)); combo.setInput(list); context.bindValue(ViewerProperties.singleSelection().observe(combo), EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_ELEMENT__VISIBLE_WHEN) .observeDetail(getMaster()), new UpdateValueStrategy().setConverter(new EClass2EObject(Messages)), new UpdateValueStrategy().setConverter(new EObject2EClass(Messages))); } ControlFactory.createCheckBox(parent, Messages.ModelTooling_UIElement_ToBeRendered, getMaster(), context, WidgetProperties.selection(), EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_ELEMENT__TO_BE_RENDERED)); ControlFactory.createCheckBox(parent, Messages.ModelTooling_UIElement_Visible, getMaster(), context, WidgetProperties.selection(), EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_ELEMENT__VISIBLE)); item = new CTabItem(folder, SWT.NONE); item.setText(Messages.ModelTooling_Common_TabSupplementary); parent = createScrollableContainer(folder); item.setControl(parent.getParent()); ControlFactory.createTextField(parent, Messages.ModelTooling_UIElement_AccessibilityPhrase, getMaster(), context, textProp, EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_ELEMENT__ACCESSIBILITY_PHRASE)); ControlFactory.createStringListWidget(parent, Messages, this, Messages.CategoryEditor_Tags, ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__TAGS, VERTICAL_LIST_WIDGET_INDENT); ControlFactory.createMapProperties(parent, Messages, this, Messages.ModelTooling_Contribution_PersistedState, ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__PERSISTED_STATE, VERTICAL_LIST_WIDGET_INDENT); if (project == null) { createUITreeInspection(folder); } createContributedEditorTabs(folder, context, getMaster(), MMenu.class); folder.setSelection(0); return folder; }
From source file:org.eclipse.e4.tools.emf.ui.internal.common.component.MenuItemEditor.java
License:Open Source License
protected CTabFolder createForm(Composite parent, EMFDataBindingContext context, WritableValue master, boolean isImport) { CTabFolder folder = new CTabFolder(parent, SWT.BOTTOM); CTabItem item = new CTabItem(folder, SWT.NONE); item.setText(Messages.ModelTooling_Common_TabDefault); parent = createScrollableContainer(folder); item.setControl(parent.getParent()); IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify); IWidgetValueProperty checkProp = WidgetProperties.selection(); IWidgetValueProperty enabled = WidgetProperties.enabled(); if (getEditor().isShowXMIId() || getEditor().isLiveModel()) { ControlFactory.createXMIId(parent, this); }/*from ww w . j a va 2s. com*/ if (isImport) { ControlFactory.createFindImport(parent, Messages, this, context); folder.setSelection(0); return folder; } ControlFactory.createTextField(parent, Messages.ModelTooling_Common_Id, master, context, textProp, EMFEditProperties.value(getEditingDomain(), ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__ELEMENT_ID)); if (this.getClass() != MenuItemEditor.class) { // ------------------------------------------------------------ { Label l = new Label(parent, SWT.NONE); l.setText(Messages.MenuItemEditor_Type); l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); ComboViewer viewer = new ComboViewer(parent); viewer.setContentProvider(new ArrayContentProvider()); viewer.setInput(new ItemType[] { ItemType.CHECK, ItemType.PUSH, ItemType.RADIO }); GridData gd = new GridData(); gd.horizontalSpan = 2; viewer.getControl().setLayoutData(gd); IObservableValue itemTypeObs = EMFEditProperties .value(getEditingDomain(), MenuPackageImpl.Literals.ITEM__TYPE).observeDetail(master); context.bindValue(ViewerProperties.singleSelection().observe(viewer), itemTypeObs); } } ControlFactory.createTranslatedTextField(parent, Messages.MenuItemEditor_Label, master, context, textProp, EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_LABEL__LABEL), resourcePool, project); ControlFactory.createTextField(parent, Messages.MenuItemEditor_Mnemonics, getMaster(), context, textProp, EMFEditProperties.value(getEditingDomain(), MenuPackageImpl.Literals.MENU_ELEMENT__MNEMONICS)); ControlFactory.createTranslatedTextField(parent, Messages.MenuItemEditor_Tooltip, master, context, textProp, EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_LABEL__TOOLTIP), resourcePool, project); // ------------------------------------------------------------ { Label l = new Label(parent, SWT.NONE); l.setText(Messages.MenuItemEditor_IconURI); l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); TextPasteHandler.createFor(t); t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); context.bindValue(textProp.observeDelayed(200, t), EMFEditProperties .value(getEditingDomain(), UiPackageImpl.Literals.UI_LABEL__ICON_URI).observeDetail(master)); new ImageTooltip(t, Messages) { @Override protected URI getImageURI() { MUILabel part = (MUILabel) getMaster().getValue(); String uri = part.getIconURI(); if (uri == null || uri.trim().length() == 0) { return null; } return URI.createURI(part.getIconURI()); } }; final Button b = new Button(parent, SWT.PUSH | SWT.FLAT); b.setImage(createImage(ResourceProvider.IMG_Obj16_zoom)); b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false)); b.setText(Messages.ModelTooling_Common_FindEllipsis); b.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { MenuItemIconDialogEditor dialog = new MenuItemIconDialogEditor(b.getShell(), eclipseContext, project, getEditingDomain(), (MMenuItem) getMaster().getValue(), Messages); dialog.open(); } }); } { Label l = new Label(parent, SWT.NONE); l.setText(Messages.MenuItemEditor_Enabled); l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Button b = new Button(parent, SWT.CHECK); b.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false, 2, 1)); context.bindValue(checkProp.observe(b), EMFEditProperties .value(getEditingDomain(), MenuPackageImpl.Literals.ITEM__ENABLED).observeDetail(getMaster())); } { Label l = new Label(parent, SWT.NONE); l.setText(Messages.MenuItemEditor_Selected); l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Button b = new Button(parent, SWT.CHECK); b.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false, 2, 1)); context.bindValue(checkProp.observe(b), EMFEditProperties .value(getEditingDomain(), MenuPackageImpl.Literals.ITEM__SELECTED).observeDetail(getMaster())); UpdateValueStrategy t2m = new UpdateValueStrategy(); t2m.setConverter(new Converter(boolean.class, ItemType.class) { @Override public Object convert(Object fromObject) { return null; } }); UpdateValueStrategy m2t = new UpdateValueStrategy(); m2t.setConverter(new Converter(ItemType.class, boolean.class) { @Override public Object convert(Object fromObject) { return fromObject == ItemType.CHECK || fromObject == ItemType.RADIO; } }); context.bindValue(enabled.observe(b), EMFEditProperties .value(getEditingDomain(), MenuPackageImpl.Literals.ITEM__TYPE).observeDetail(getMaster()), t2m, m2t); } { Label l = new Label(parent, SWT.NONE); l.setText(Messages.ModelTooling_UIElement_VisibleWhen); l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); ComboViewer combo = new ComboViewer(parent); combo.getControl().setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 2, 1)); combo.setContentProvider(new ArrayContentProvider()); combo.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { if (element instanceof EClass) { EClass eClass = (EClass) element; return eClass.getName(); } return super.getText(element); } }); List<Object> list = new ArrayList<Object>(); list.add(Messages.MenuItemEditor_NoExpression); list.add(UiPackageImpl.Literals.CORE_EXPRESSION); list.addAll(getEditor().getFeatureClasses(UiPackageImpl.Literals.EXPRESSION, UiPackageImpl.Literals.UI_ELEMENT__VISIBLE_WHEN)); combo.setInput(list); context.bindValue(ViewerProperties.singleSelection().observe(combo), EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_ELEMENT__VISIBLE_WHEN) .observeDetail(getMaster()), new UpdateValueStrategy().setConverter(new EClass2EObject(Messages)), new UpdateValueStrategy().setConverter(new EObject2EClass(Messages))); } createFormSubTypeForm(parent, context, master); ControlFactory.createCheckBox(parent, Messages.ModelTooling_UIElement_ToBeRendered, getMaster(), context, WidgetProperties.selection(), EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_ELEMENT__TO_BE_RENDERED)); ControlFactory.createCheckBox(parent, Messages.ModelTooling_UIElement_Visible, getMaster(), context, WidgetProperties.selection(), EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_ELEMENT__VISIBLE)); item = new CTabItem(folder, SWT.NONE); item.setText(Messages.ModelTooling_Common_TabSupplementary); parent = createScrollableContainer(folder); item.setControl(parent.getParent()); ControlFactory.createTextField(parent, Messages.ModelTooling_UIElement_AccessibilityPhrase, getMaster(), context, textProp, EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_ELEMENT__ACCESSIBILITY_PHRASE)); ControlFactory.createStringListWidget(parent, Messages, this, Messages.CategoryEditor_Tags, ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__TAGS, VERTICAL_LIST_WIDGET_INDENT); ControlFactory.createMapProperties(parent, Messages, this, Messages.ModelTooling_Contribution_PersistedState, ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__PERSISTED_STATE, VERTICAL_LIST_WIDGET_INDENT); if (project == null) { createUITreeInspection(folder); } createContributedEditorTabs(folder, context, getMaster(), MMenuItem.class); folder.setSelection(0); return folder; }
From source file:org.eclipse.e4.tools.emf.ui.internal.common.component.MenuSeparatorEditor.java
License:Open Source License
private Composite createForm(Composite parent, EMFDataBindingContext context, WritableValue master, boolean isImport) { CTabFolder folder = new CTabFolder(parent, SWT.BOTTOM); CTabItem item = new CTabItem(folder, SWT.NONE); item.setText(Messages.ModelTooling_Common_TabDefault); parent = createScrollableContainer(folder); item.setControl(parent.getParent()); if (getEditor().isShowXMIId() || getEditor().isLiveModel()) { ControlFactory.createXMIId(parent, this); }/*from w w w .j a v a 2s. c om*/ IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify); if (isImport) { ControlFactory.createFindImport(parent, Messages, this, context); folder.setSelection(0); return folder; } ControlFactory.createTextField(parent, Messages.ModelTooling_Common_Id, master, context, textProp, EMFEditProperties.value(getEditingDomain(), ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__ELEMENT_ID)); ControlFactory.createTextField(parent, Messages.ModelTooling_UIElement_AccessibilityPhrase, getMaster(), context, textProp, EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_ELEMENT__ACCESSIBILITY_PHRASE)); ControlFactory.createCheckBox(parent, Messages.ModelTooling_UIElement_ToBeRendered, getMaster(), context, WidgetProperties.selection(), EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_ELEMENT__TO_BE_RENDERED)); ControlFactory.createCheckBox(parent, Messages.ModelTooling_UIElement_Visible, getMaster(), context, WidgetProperties.selection(), EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_ELEMENT__VISIBLE)); item = new CTabItem(folder, SWT.NONE); item.setText(Messages.ModelTooling_Common_TabSupplementary); parent = createScrollableContainer(folder); item.setControl(parent.getParent()); ControlFactory.createStringListWidget(parent, Messages, this, Messages.CategoryEditor_Tags, ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__TAGS, VERTICAL_LIST_WIDGET_INDENT); ControlFactory.createMapProperties(parent, Messages, this, Messages.ModelTooling_Contribution_PersistedState, ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__PERSISTED_STATE, VERTICAL_LIST_WIDGET_INDENT); if (project == null) { createUITreeInspection(folder); } createContributedEditorTabs(folder, context, getMaster(), MMenuSeparator.class); folder.setSelection(0); return folder; }
From source file:org.eclipse.e4.tools.emf.ui.internal.common.component.PartDescriptorEditor.java
License:Open Source License
protected Composite createForm(Composite parent, EMFDataBindingContext context, IObservableValue master, boolean isImport) { CTabFolder folder = new CTabFolder(parent, SWT.BOTTOM); CTabItem item = new CTabItem(folder, SWT.NONE); item.setText(Messages.ModelTooling_Common_TabDefault); parent = createScrollableContainer(folder); item.setControl(parent.getParent()); if (getEditor().isShowXMIId() || getEditor().isLiveModel()) { ControlFactory.createXMIId(parent, this); }/*from w w w . j a va2 s. c o m*/ IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify); if (isImport) { ControlFactory.createFindImport(parent, Messages, this, context); folder.setSelection(0); return folder; } ControlFactory.createTextField(parent, Messages.ModelTooling_Common_Id, master, context, textProp, EMFEditProperties.value(getEditingDomain(), ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__ELEMENT_ID)); ControlFactory.createTranslatedTextField(parent, Messages.PartDescriptorEditor_LabelLabel, master, context, textProp, EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_LABEL__LABEL), resourcePool, project); ControlFactory.createTranslatedTextField(parent, Messages.PartDescriptorEditor_Tooltip, master, context, textProp, EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_LABEL__TOOLTIP), resourcePool, project); // ------------------------------------------------------------ { Label l = new Label(parent, SWT.NONE); l.setText(Messages.PartDescriptorEditor_IconURI); l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); TextPasteHandler.createFor(t); t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); context.bindValue(textProp.observeDelayed(200, t), EMFEditProperties .value(getEditingDomain(), UiPackageImpl.Literals.UI_LABEL__ICON_URI).observeDetail(master)); new ImageTooltip(t, Messages) { @Override protected URI getImageURI() { MUILabel part = (MUILabel) getMaster().getValue(); String uri = part.getIconURI(); if (uri == null || uri.trim().length() == 0) { return null; } return URI.createURI(part.getIconURI()); } }; final Button b = new Button(parent, SWT.PUSH | SWT.FLAT); b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false)); b.setImage(createImage(ResourceProvider.IMG_Obj16_zoom)); b.setText(Messages.ModelTooling_Common_FindEllipsis); b.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { PartDescriptorIconDialogEditor dialog = new PartDescriptorIconDialogEditor(b.getShell(), eclipseContext, project, getEditingDomain(), (MPartDescriptor) getMaster().getValue(), Messages); dialog.open(); } }); } // ------------------------------------------------------------ final Link lnk; { /* * IContributionClassCreator accepts MContribitions but * MPartDescriptor does not implement, so we need to be a bit * creative here */ // final IContributionClassCreator c = getEditor().getContributionCreator( org.eclipse.e4.ui.model.application.ui.basic.impl.BasicPackageImpl.Literals.PART); if (project != null && c != null) { lnk = new Link(parent, SWT.NONE); lnk.setText("<A>" + Messages.PartEditor_ClassURI + "</A>"); //$NON-NLS-1$//$NON-NLS-2$ lnk.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); final IObservableValue masterFinal = master; lnk.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { MPart dummyPart = MBasicFactory.INSTANCE.createPart(); String contributionURI = ((MPartDescriptor) getMaster().getValue()).getContributionURI(); dummyPart.setContributionURI(contributionURI); c.createOpen(dummyPart, getEditingDomain(), project, lnk.getShell()); ((MPartDescriptor) masterFinal.getValue()) .setContributionURI(dummyPart.getContributionURI()); } }); } else { // Dispose the lnk widget, which is unused in this else branch // and screws up the layout: see https://bugs.eclipse.org/421369 lnk = null; Label l = new Label(parent, SWT.NONE); l.setText(Messages.PartDescriptorEditor_ClassURI); l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); } Text t = new Text(parent, SWT.BORDER); t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); context.bindValue(textProp.observeDelayed(200, t), EMFEditProperties .value(getEditingDomain(), BasicPackageImpl.Literals.PART_DESCRIPTOR__CONTRIBUTION_URI) .observeDetail(master)); TextPasteHandler.createFor(t); final Button b = new Button(parent, SWT.PUSH | SWT.FLAT); b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false)); b.setImage(createImage(ResourceProvider.IMG_Obj16_zoom)); b.setText(Messages.ModelTooling_Common_FindEllipsis); b.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { ContributionClassDialog dialog = new ContributionClassDialog(b.getShell(), eclipseContext, project, getEditingDomain(), (MPartDescriptor) getMaster().getValue(), BasicPackageImpl.Literals.PART_DESCRIPTOR__CONTRIBUTION_URI, Messages); dialog.open(); } }); } // ------------------------------------------------------------ { Label l = new Label(parent, SWT.NONE); l.setText(Messages.PartEditor_ToolBar); l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); createRemoveToolBar = new Button(parent, SWT.CHECK); createRemoveToolBar.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { MPartDescriptor window = (MPartDescriptor) getMaster().getValue(); if (window.getToolbar() == null) { addToolBar(); } else { removeToolBar(); } } }); createRemoveToolBar .setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false, 2, 1)); } // ------------------------------------------------------------ { Label l = new Label(parent, SWT.NONE); l.setText(Messages.PartDescriptorEditor_ContainerData); l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 2; t.setLayoutData(gd); context.bindValue(textProp.observeDelayed(200, t), EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_ELEMENT__CONTAINER_DATA) .observeDetail(master)); } // ------------------------------------------------------------ { Label l = new Label(parent, SWT.NONE); l.setText(Messages.PartDescriptorEditor_Dirtyable); l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Button checkbox = new Button(parent, SWT.CHECK); checkbox.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false, 2, 1)); IEMFEditValueProperty mprop = EMFEditProperties.value(getEditingDomain(), BasicPackageImpl.Literals.PART_DESCRIPTOR__DIRTYABLE); IWidgetValueProperty uiProp = WidgetProperties.selection(); context.bindValue(uiProp.observe(checkbox), mprop.observeDetail(master)); } // ------------------------------------------------------------ { Label l = new Label(parent, SWT.NONE); l.setText(Messages.PartDescriptorEditor_Closeable); l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Button checkbox = new Button(parent, SWT.CHECK); checkbox.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false, 2, 1)); IEMFEditValueProperty mprop = EMFEditProperties.value(getEditingDomain(), BasicPackageImpl.Literals.PART_DESCRIPTOR__CLOSEABLE); IWidgetValueProperty uiProp = WidgetProperties.selection(); context.bindValue(uiProp.observe(checkbox), mprop.observeDetail(master)); } // ------------------------------------------------------------ { Label l = new Label(parent, SWT.NONE); l.setText(Messages.PartDescriptorEditor_Multiple); l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Button checkbox = new Button(parent, SWT.CHECK); checkbox.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false, 2, 1)); IEMFEditValueProperty mprop = EMFEditProperties.value(getEditingDomain(), BasicPackageImpl.Literals.PART_DESCRIPTOR__ALLOW_MULTIPLE); IWidgetValueProperty uiProp = WidgetProperties.selection(); context.bindValue(uiProp.observe(checkbox), mprop.observeDetail(master)); } // ------------------------------------------------------------ { Label l = new Label(parent, SWT.NONE); l.setText(Messages.PartDescriptorEditor_Category); l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Text t = new Text(parent, SWT.BORDER); t.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false, 2, 1)); context.bindValue(textProp.observeDelayed(200, t), EMFEditProperties.value(getEditingDomain(), BasicPackageImpl.Literals.PART_DESCRIPTOR__CATEGORY) .observeDetail(master)); } ControlFactory.createBindingContextWiget(parent, Messages, this, Messages.PartEditor_BindingContexts); item = new CTabItem(folder, SWT.NONE); item.setText(Messages.ModelTooling_Common_TabSupplementary); parent = createScrollableContainer(folder); item.setControl(parent.getParent()); ControlFactory.createStringListWidget(parent, Messages, this, Messages.CategoryEditor_Tags, ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__TAGS, VERTICAL_LIST_WIDGET_INDENT); ControlFactory.createMapProperties(parent, Messages, this, Messages.ModelTooling_Contribution_PersistedState, ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__PERSISTED_STATE, VERTICAL_LIST_WIDGET_INDENT); createContributedEditorTabs(folder, context, getMaster(), MPartDescriptor.class); folder.setSelection(0); return folder; }
From source file:org.eclipse.e4.tools.emf.ui.internal.common.component.PartEditor.java
License:Open Source License
protected Composite createForm(Composite parent, EMFDataBindingContext context, IObservableValue master, boolean isImport) { CTabFolder folder = new CTabFolder(parent, SWT.BOTTOM); CTabItem item = new CTabItem(folder, SWT.BORDER); item.setText(Messages.ModelTooling_Common_TabDefault); parent = createScrollableContainer(folder); item.setControl(parent.getParent()); if (getEditor().isShowXMIId() || getEditor().isLiveModel()) { ControlFactory.createXMIId(parent, this); }/* ww w. j a v a2 s . com*/ IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify); if (isImport) { ControlFactory.createFindImport(parent, Messages, this, context); folder.setSelection(0); return folder; } ControlFactory.createTextField(parent, Messages.ModelTooling_Common_Id, master, context, textProp, EMFEditProperties.value(getEditingDomain(), ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__ELEMENT_ID)); ControlFactory.createTextField(parent, Messages.PartEditor_LabelLabel, master, context, textProp, EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_LABEL__LABEL)); ControlFactory.createTextField(parent, Messages.ModelTooling_UIElement_AccessibilityPhrase, master, context, textProp, EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_ELEMENT__ACCESSIBILITY_PHRASE)); ControlFactory.createTextField(parent, Messages.PartEditor_Tooltip, master, context, textProp, EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_LABEL__TOOLTIP)); // ------------------------------------------------------------ { Label l = new Label(parent, SWT.NONE); l.setText(Messages.PartEditor_IconURI); l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); l.setToolTipText(Messages.PartEditor_IconURI_Tooltip); final Text t = new Text(parent, SWT.BORDER); TextPasteHandler.createFor(t); t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); context.bindValue(textProp.observeDelayed(200, t), EMFEditProperties .value(getEditingDomain(), UiPackageImpl.Literals.UI_LABEL__ICON_URI).observeDetail(master)); new ImageTooltip(t, Messages) { @Override protected URI getImageURI() { MUILabel part = (MUILabel) getMaster().getValue(); String uri = part.getIconURI(); if (uri == null || uri.trim().length() == 0) { return null; } return URI.createURI(part.getIconURI()); } }; final Button b = new Button(parent, SWT.PUSH | SWT.FLAT); b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false)); b.setImage(createImage(ResourceProvider.IMG_Obj16_zoom)); b.setText(Messages.ModelTooling_Common_FindEllipsis); b.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { PartIconDialogEditor dialog = new PartIconDialogEditor(b.getShell(), eclipseContext, project, getEditingDomain(), (MPart) getMaster().getValue(), Messages); dialog.open(); } }); } // ------------------------------------------------------------ final Link lnk; { final IContributionClassCreator c = getEditor().getContributionCreator(BasicPackageImpl.Literals.PART); if (project != null && c != null) { lnk = new Link(parent, SWT.NONE); lnk.setText("<A>" + Messages.PartEditor_ClassURI + "</A>"); //$NON-NLS-1$//$NON-NLS-2$ lnk.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); lnk.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { c.createOpen((MContribution) getMaster().getValue(), getEditingDomain(), project, lnk.getShell()); } }); } else { // Dispose the lnk widget, which is unused in this else branch // and screws up the layout: see https://bugs.eclipse.org/421369 lnk = null; Label l = new Label(parent, SWT.NONE); l.setText(Messages.PartEditor_ClassURI); l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); } Text t = new Text(parent, SWT.BORDER); TextPasteHandler.createFor(t); t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); t.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { // lnk might be disposed if else branch above taken if (lnk != null) { lnk.setToolTipText(((Text) (e.getSource())).getText()); } } }); Binding binding = context.bindValue(textProp.observeDelayed(200, t), EMFEditProperties .value(getEditingDomain(), ApplicationPackageImpl.Literals.CONTRIBUTION__CONTRIBUTION_URI) .observeDetail(master), new UpdateValueStrategy().setAfterConvertValidator(new ContributionURIValidator()), new UpdateValueStrategy()); Util.addDecoration(t, binding); final Button b = new Button(parent, SWT.PUSH | SWT.FLAT); b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false)); b.setImage(createImage(ResourceProvider.IMG_Obj16_zoom)); b.setText(Messages.ModelTooling_Common_FindEllipsis); b.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { ContributionClassDialog dialog = new ContributionClassDialog(b.getShell(), eclipseContext, project, getEditingDomain(), (MContribution) getMaster().getValue(), ApplicationPackageImpl.Literals.CONTRIBUTION__CONTRIBUTION_URI, Messages); dialog.open(); } }); } // ------------------------------------------------------------ ControlFactory.createTextField(parent, Messages.PartEditor_ContainerData, master, context, textProp, EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_ELEMENT__CONTAINER_DATA)); createSubformElements(parent, context, master); { Label l = new Label(parent, SWT.NONE); l.setText(Messages.PartEditor_ToolBar); l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); createRemoveToolBar = new Button(parent, SWT.CHECK); createRemoveToolBar.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { MPart window = (MPart) getMaster().getValue(); if (window.getToolbar() == null) { addToolBar(); } else { removeToolBar(); } } }); createRemoveToolBar .setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false, 2, 1)); } ControlFactory.createCheckBox(parent, Messages.PartEditor_Closeable, Messages.PartEditor_Closeable_Tooltip, getMaster(), context, WidgetProperties.selection(), EMFEditProperties.value(getEditingDomain(), BasicPackageImpl.Literals.PART__CLOSEABLE)); // ------------------------------------------------------------ ControlFactory.createCheckBox(parent, Messages.ModelTooling_UIElement_ToBeRendered, getMaster(), context, WidgetProperties.selection(), EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_ELEMENT__TO_BE_RENDERED)); ControlFactory.createCheckBox(parent, Messages.ModelTooling_UIElement_Visible, getMaster(), context, WidgetProperties.selection(), EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_ELEMENT__VISIBLE)); ControlFactory.createBindingContextWiget(parent, Messages, this, Messages.PartEditor_BindingContexts); ControlFactory.createMapProperties(parent, Messages, this, Messages.ModelTooling_Contribution_PersistedState, ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__PERSISTED_STATE, VERTICAL_LIST_WIDGET_INDENT); ControlFactory.createMapProperties(parent, Messages, this, Messages.ModelTooling_Context_Properties, UiPackageImpl.Literals.CONTEXT__PROPERTIES, VERTICAL_LIST_WIDGET_INDENT); item = new CTabItem(folder, SWT.NONE); item.setText(Messages.ModelTooling_Common_TabSupplementary); parent = createScrollableContainer(folder); item.setControl(parent.getParent()); ControlFactory.createStringListWidget(parent, Messages, this, Messages.ModelTooling_Context_Variables, Messages.ModelTooling_Context_Variables_Tooltip, UiPackageImpl.Literals.CONTEXT__VARIABLES, VERTICAL_LIST_WIDGET_INDENT); ControlFactory.createStringListWidget(parent, Messages, this, Messages.CategoryEditor_Tags, ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__TAGS, VERTICAL_LIST_WIDGET_INDENT); if (project == null) { createInstanceInspection(folder); createUITreeInspection(folder); } createContributedEditorTabs(folder, context, getMaster(), MPart.class); folder.setSelection(0); return folder; }