public void setInput(IWorkbenchPart part, ISelection selection) { super.setInput(part, selection); Assert.isTrue(selection instanceof IStructuredSelection); Object input = ((IStructuredSelection) selection).getFirstElement(); Assert.isTrue(input instanceof ButtonElement); this.buttonElement = (ButtonElement) input; }
/** * Disposes of the {@link #section} and its contained Widgets and clears references to any class * variables. */ @Override public void dispose() { super.dispose(); // Clear the references to the selected Tree and selected property // Entry. tree = null; selectedEntry = null; // Clear the references to the Property View's ScrolledComposite and its // client. scrollComposite = null; scrollCompositeClient = null; // Dispose the section and clear references to all widgets. (Disposing // the section should dispose of its child widgets recursively.) section.dispose(); section = null; tableViewer = null; nameColumn = null; valueColumn = null; add = null; delete = null; return; }
@Override public void aboutToBeHidden() { super.aboutToBeHidden(); if (test != null) { test.getAllLanguages().removePropertyChangeListener(this); } }
@Override public void refresh() { super.refresh(); updateLanguageCombo(); AllLanguages allLanguages = test.getAllLanguages(); if (allLanguages.isEmpty()) { removeButton.setVisible(false); refreshButton.setVisible(false); openI18nFileButton.setVisible(false); selectLabel.setVisible(false); languageCombo.setVisible(false); } else { removeButton.setVisible(true); refreshButton.setVisible(true); openI18nFileButton.setVisible(true); selectLabel.setVisible(true); languageCombo.setVisible(true); } Language currentLanguage = allLanguages.getCurrentLanguage(); if (currentLanguage != null) { if (currentLanguage.isEmpty()) { noI18nValuesLabel.setVisible(true); noObserversLabel.setVisible(false); } else if (!allLanguages.hasObservers()) { noI18nValuesLabel.setVisible(false); noObserversLabel.setVisible(true); } else { noI18nValuesLabel.setVisible(false); noObserversLabel.setVisible(false); } } }
/** * {@inheritDoc} * * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#dispose() */ @Override public void dispose() { super.dispose(); if (getDiagram() != null) { removeSemanticListener(getDiagram()); } }
@SuppressWarnings({"unchecked", "rawtypes"}) @Override public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) { super.createControls(parent, aTabbedPropertySheetPage); Composite composite = getWidgetFactory().createFlatFormComposite(parent); TableColumnLayout tableColumnLayout = new TableColumnLayout(); composite.setLayout(tableColumnLayout); FormData data; table = getWidgetFactory().createTable(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION); table.setHeaderVisible(true); table.setLinesVisible(true); columns = new ArrayList(); String[] titles = UserGroupPropertySource.getPropertiesDisplayValuesTable(); int[] weights = {30, 30, 30}; for (int i = 0; i < titles.length; i++) { TableColumn column = new TableColumn(table, SWT.NONE); column.setText(titles[i]); tableColumnLayout.setColumnData(column, new ColumnWeightData(weights[i])); columns.add(column); } data = new FormData(); data.left = new FormAttachment(0, 0); data.right = new FormAttachment(100, 0); data.top = new FormAttachment(0, 0); data.bottom = new FormAttachment(100, 0); table.setLayoutData(data); }
@Override public void setInput(IWorkbenchPart part, ISelection selection) { super.setInput(part, selection); Assert.isTrue(selection instanceof IStructuredSelection); Object input = ((IStructuredSelection) selection).getFirstElement(); Assert.isTrue(input instanceof UserGroup); this.userGroup = (UserGroup) input; }
@Override public void createControls(Composite parent, TabbedPropertySheetPage tabbedPropertySheetPage) { super.createControls(parent, tabbedPropertySheetPage); TabbedPropertySheetWidgetFactory factory = getWidgetFactory(); Composite composite = factory.createComposite(parent); }
@Override public void dispose() { if (page != null) { aboutToBeHidden(); page.dispose(); page = null; } super.dispose(); }
/** * Because this <code>Section</code> must alter the layout behavior of the containing Eclipse RCP * View in order to properly lay out the {@link #tableViewer} and related <code>Controls</code>, * this method must store any layout properties for parent <code>Composites</code> (e.g., {@link * #scrollComposite} and {@link #scrollCompositeClient}) that will be changed in {@link * #resizePropertyView()}. These layout properties must be restored in {@link #aboutToBeHidden()}. */ @Override public void aboutToBeShown() { super.aboutToBeShown(); // Store some of the default properties of the ScrolledComposite. scrollMinWidth = scrollComposite.getMinWidth(); scrollMinHeight = scrollComposite.getMinHeight(); return; }
public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) { super.createControls(parent, aTabbedPropertySheetPage); Composite composite = getWidgetFactory().createFlatFormComposite(parent); CLabel nameLabel = getWidgetFactory().createCLabel(composite, label); FormData data = new FormData(); data.left = new FormAttachment(0, 0); data.right = new FormAttachment(100, 0); data.top = new FormAttachment(0, 0); nameLabel.setLayoutData(data); }
public void setInput(IWorkbenchPart part, ISelection selection) { super.setInput(part, selection); if (selection instanceof IStructuredSelection) { Object input = ((IStructuredSelection) selection).getFirstElement(); if (input instanceof ElementEditPart) { input = ((ElementEditPart) input).getModel(); } if (input instanceof ElementWrapper) { this.elementWrapper = (ElementWrapper) input; } } }
@Override public void createControls( Composite parent, final TabbedPropertySheetPage atabbedPropertySheetPage) { super.createControls(parent, atabbedPropertySheetPage); parentPage = atabbedPropertySheetPage; container = getWidgetFactory().createFlatFormComposite(parent); controlListener = new ControlAdapter() { public void controlResized(ControlEvent e) { atabbedPropertySheetPage.resizeScrolledComposite(); } }; }
@Override public void setInput(IWorkbenchPart part, ISelection selection) { super.setInput(part, selection); if (test != null) { test.getAllLanguages().removePropertyChangeListener(this); } Assert.isTrue(selection instanceof IStructuredSelection); Object input = ((IStructuredSelection) selection).getFirstElement(); Assert.isTrue(input instanceof TestEditPart); test = (Test) ((TestEditPart) input).getModel(); AllLanguages langs = test.getAllLanguages(); langs.addPropertyChangeListener(this); }
/** * {@inheritDoc} * * @see * org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#setInput(org.eclipse.ui.IWorkbenchPart, * org.eclipse.jface.viewers.ISelection) */ @Override public void setInput(final IWorkbenchPart part, final ISelection selection) { super.setInput(part, selection); if (selection instanceof IStructuredSelection) { final Object input = ((IStructuredSelection) selection).getFirstElement(); if (input instanceof DDiagramEditPart) { final EObject vp = ((DDiagramEditPart) input).resolveSemanticElement(); editPart = ((DDiagramEditPart) input).getRoot(); if (vp instanceof DDiagram) { setSirius((DDiagram) vp); this.domain = ((DDiagramEditPart) input).getEditingDomain(); } } } refresh(); }
public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) { super.createControls(parent, aTabbedPropertySheetPage); Composite composite = getWidgetFactory().createFlatFormComposite(parent); nameText = getWidgetFactory().createText(composite, ""); FormData data = new FormData(); data.left = new FormAttachment(0, STANDARD_LABEL_WIDTH); data.right = new FormAttachment(100, 0); data.top = new FormAttachment(0, ITabbedPropertyConstants.VSPACE); nameText.setLayoutData(data); nameText.addModifyListener(this); CLabel labelLabel = getWidgetFactory().createCLabel(composite, "Name:"); data = new FormData(); data.left = new FormAttachment(0, 0); data.right = new FormAttachment(nameText, -ITabbedPropertyConstants.HSPACE); data.top = new FormAttachment(nameText, 0, SWT.CENTER); labelLabel.setLayoutData(data); }
/** * {@inheritDoc} * * @see * org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#createControls(org.eclipse.swt.widgets.Composite, * org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage) */ @Override public void createControls( final Composite parent, final TabbedPropertySheetPage aTabbedPropertySheetPage) { super.createControls(parent, aTabbedPropertySheetPage); final Composite composite = getWidgetFactory().createFlatFormComposite(parent); composite.setLayout(new GridLayout(3, false)); final Composite choiceComposite = createChoiceComposite(composite); choiceTable = getWidgetFactory().createTable(choiceComposite, SWT.MULTI | SWT.BORDER); choiceTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); availableElementsTableViewer = new TableViewer(choiceTable); final Composite controlButtons = getWidgetFactory().createComposite(composite, SWT.NONE); controlButtons.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); final GridLayout controlsButtonGridLayout = new GridLayout(); controlButtons.setLayout(controlsButtonGridLayout); new Label(controlButtons, SWT.NONE); addButton = getWidgetFactory().createButton(controlButtons, "Add >", SWT.PUSH); addButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); removeButton = getWidgetFactory().createButton(controlButtons, "< Remove", SWT.PUSH); removeButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); final Label spaceLabel = new Label(controlButtons, SWT.NONE); final GridData spaceLabelGridData = new GridData(); spaceLabelGridData.verticalSpan = 2; spaceLabel.setLayoutData(spaceLabelGridData); final Composite featureComposite = createFeatureComposite(composite); featureTable = getWidgetFactory().createTable(featureComposite, SWT.MULTI | SWT.BORDER); featureTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); selectedElementsTableViewer = new TableViewer(featureTable); }
/** Refreshes any widgets required for the current input for this property section. */ @Override public void refresh() { if (tree != null) { // Set the contents of the TableViewer. tableViewer.setInput(tree); // Automatically adjust the widths of the name and value columns. nameColumn.getColumn().pack(); valueColumn.getColumn().pack(); // Refresh the type Combo widget. refreshTypeWidgets(); } // Refresh the size of the contents of the section. resizePropertyView(); // Now perform the usual refresh operation. super.refresh(); return; }
@Override public void setInput(IWorkbenchPart part, ISelection selection) { if (part == getPart() && selection == getSelection()) { return; } super.setInput(part, selection); if (page != null) { page.getControl().removeControlListener(controlListener); aboutToBeHidden(); page.dispose(); page.getControl().dispose(); page = null; } Object first = Selections.getFirstSelection(selection); if (first == null) { return; } page = createPage(first); if (page != null) { if (page instanceof IPageBookViewPage) { try { ((IPageBookViewPage) page).init(parentPage.getSite()); } catch (PartInitException e) { Activator.getDefault().getLog().log(e.getStatus()); } } page.createControl(container); FormData data = new FormData(); data.left = new FormAttachment(0, 0); data.right = new FormAttachment(100, 0); data.top = new FormAttachment(0, 0); data.bottom = new FormAttachment(100, 0); page.getControl().setLayoutData(data); page.getControl().addControlListener(controlListener); } container.layout(true, true); parentPage.resizeScrolledComposite(); }
/** * Restores the layout properties stored in {@link #aboutToBeShown()} and changed in {@link * #resizePropertyView()}. */ @Override public void aboutToBeHidden() { super.aboutToBeHidden(); // If possible, we need to restore the settings clobbered in // resizeProperties(); if (!scrollComposite.isDisposed()) { // Restore the GridData of the Section's parent. GridData gridData = (GridData) section.getParent().getLayoutData(); gridData.heightHint = SWT.DEFAULT; // Restore the default size of the ScrolledComposite's client. Point size = scrollCompositeClient.computeSize(SWT.DEFAULT, SWT.DEFAULT); scrollCompositeClient.setSize(size); // Restore the min size of the ScrolledComposite. scrollComposite.setMinSize(scrollMinWidth, scrollMinHeight); // Re-layout the ScrolledComposite. scrollComposite.layout(); } return; }
/** * @see * org.eclipse.ui.views.properties.tabbed.ITabbedPropertySection#createControls(org.eclipse.swt.widgets.Composite, * org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage) */ public void createControls(Composite parent, TabbedPropertySheetPage tabbedPropertySheetPage) { super.createControls(parent, tabbedPropertySheetPage); Composite composite = getWidgetFactory().createFlatFormComposite(parent); FormData data; Shell shell = new Shell(); GC gc = new GC(shell); gc.setFont(shell.getFont()); Point point = gc.textExtent(""); // $NON-NLS-1$ int buttonHeight = point.y + 5; gc.dispose(); shell.dispose(); CLabel fontLabel = getWidgetFactory().createCLabel(composite, "Font:"); // $NON-NLS-1$ fontText = getWidgetFactory().createText(composite, ""); // $NON-NLS-1$ fontText.setEditable(false); Button fontButton = getWidgetFactory().createButton(composite, "Change...", SWT.PUSH); // $NON-NLS-1$ fontButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { FontDialog ftDialog = new FontDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); FontData fontdata = buttonElement.getControl().getFont().getFontData()[0]; String value = fontdata.toString(); if ((value != null) && (value.length() > 0)) { ftDialog.setFontList(new FontData[] {new FontData(value)}); } FontData fData = ftDialog.open(); if (fData != null) { value = fData.toString(); ButtonElementProperties properties = (ButtonElementProperties) Adapters.adapt(buttonElement, IPropertySource.class); properties.setPropertyValue(ButtonElementProperties.PROPERTY_FONT, value); fontText.setText(StringConverter.asString(fData)); } } }); data = new FormData(); data.left = new FormAttachment(0, 0); data.right = new FormAttachment(fontText, -ITabbedPropertyConstants.HSPACE); data.top = new FormAttachment(0, 0); fontLabel.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(0, STANDARD_LABEL_WIDTH); data.right = new FormAttachment(fontButton, -ITabbedPropertyConstants.HSPACE); data.top = new FormAttachment(0, 0); fontText.setLayoutData(data); data = new FormData(); data.right = new FormAttachment(100, 0); data.top = new FormAttachment(0, 0); data.height = buttonHeight; fontButton.setLayoutData(data); }
/** * This operation sets the current input displayed in the table of properties. It also sets {@link * #isAdaptive} if the input is an {@link AdaptiveTreeComposite}. */ @Override public void setInput(IWorkbenchPart part, ISelection selection) { // Since the tree's DataComponent will still have its properties shown, // continue with the default setInput() operation. super.setInput(part, selection); // Get and check the selection. Assert.isTrue(selection instanceof IStructuredSelection); Object input = ((IStructuredSelection) selection).getFirstElement(); // Try to get the input TreeComposite from the selection. if (input != null && input instanceof Component) { IComponentVisitor visitor = new SelectiveComponentVisitor() { @Override public void visit(TreeComposite component) { // If the visited tree is new, we need to replace the // current tree with the new one. if (tree != component) { // If possible, unregister from the current tree. if (tree != null) { tree.unregister(TreePropertySection.this); } // Set the reference to the new tree and register for // updates. We need the updates for keeping the type // ComboViewer updated. tree = component; tree.register(TreePropertySection.this); // Unset the isAdaptive flag. isAdaptive = false; logger.info( "TreePropertySection message: " + "Setting the input to tree " + tree.getName() + "."); } return; } @Override public void visit(AdaptiveTreeComposite component) { visit((TreeComposite) component); isAdaptive = true; } }; ((Component) input).accept(visitor); } // Enable or disable the add button depending on whether the input is // valid. if (add != null) { boolean canAdd = (canAdd(tree) != null); add.setEnabled(canAdd); } // Try to find the associated ICEFormEditor. It will be marked as dirty // if the properties change. if (part instanceof TreeCompositeViewer) { editor = ((TreeCompositeViewer) part).getFormEditor(); } else { editor = null; } // Refresh the type Combo widget. refreshTypeWidgets(); return; }
@Override public void notifyChanged(final Notification msg) { super.notifyChanged(msg); viewpointChanged(); }
/** * This operation draws the (initial) controls in the properties view based on the input. In this * case, there are initially no widgets to prepare. */ @Override public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) { super.createControls(parent, aTabbedPropertySheetPage); // Get the default background color. Color backgroundColor = parent.getBackground(); // Create a section for the data composites. section = getWidgetFactory() .createSection(parent, ExpandableComposite.SHORT_TITLE_BAR | Section.DESCRIPTION); section.setText("Node properties"); section.setDescription("All properties available for " + "this node can be modified here."); section.setBackground(backgroundColor); // Create the Composite that contains all DataComponentComposites. final Composite client = new Composite(section, SWT.NONE); GridLayout clientLayout = new GridLayout(2, false); // Set the margins and spacing based on the tabbed property constants. clientLayout.marginLeft = ITabbedPropertyConstants.HMARGIN; clientLayout.marginRight = ITabbedPropertyConstants.HMARGIN; clientLayout.marginTop = ITabbedPropertyConstants.VMARGIN; clientLayout.marginBottom = ITabbedPropertyConstants.VMARGIN; clientLayout.horizontalSpacing = ITabbedPropertyConstants.HSPACE; clientLayout.verticalSpacing = ITabbedPropertyConstants.VSPACE; client.setLayout(clientLayout); // Make the background of the section client white unless ICE is in // debug mode. if (System.getProperty("DebugICE") == null) { client.setBackground(backgroundColor); } else { client.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_RED)); } // Set the client area for the section. section.setClient(client); // Get the property viewer's ScrolledComposite and its first Composite // (its "client" Composite). scrollCompositeClient = section.getParent().getParent().getParent().getParent(); scrollComposite = (ScrolledComposite) scrollCompositeClient.getParent(); // Add a listener to resize the Section's properties and update the // ScrollComposite's minimum bounds correctly based on the displayed // properties. scrollComposite.addControlListener( new ControlAdapter() { @Override public void controlResized(ControlEvent e) { resizePropertyView(); } }); // Create the type Combo Composite. typeComposite = createTypeComposite(client); GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false); gridData.horizontalSpan = 2; typeComposite.setLayoutData(gridData); // Refresh the contents of the type Combo and its containing Composite. refreshTypeWidgets(); // Create the table of properties. tableViewer = createTableViewer(client); // Set the table's layout data so it occupies all spare space in the // property section client. tableViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); // Create the add/delete buttons. Composite buttonComposite = createButtons(client); // The button Composite shouldn't grab any space. Align it along the // center and top of the space to the right of the table. buttonComposite.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false)); return; }
@Override public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) { super.createControls(parent, aTabbedPropertySheetPage); Composite composite = getWidgetFactory().createComposite(parent); GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 3; composite.setLayout(gridLayout); GridData labelData = new GridData(); labelData.widthHint = STANDARD_LABEL_WIDTH + 30; GridData languageSelectData = new GridData(); languageSelectData.widthHint = 400; GridData buttonData = new GridData(); buttonData.widthHint = 150; selectLabel = getWidgetFactory().createLabel(composite, "Set language: "); selectLabel.setLayoutData(labelData); languageCombo = getWidgetFactory().createCCombo(composite, SWT.READ_ONLY | SWT.BORDER); languageCombo.setLayoutData(languageSelectData); languageCombo.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { int index = languageCombo.getSelectionIndex(); Language lang = test.getAllLanguages().getLanguages().get(index); ChangeCurrentLanguageCommand command = new ChangeCurrentLanguageCommand(); command.setAllLanguages(test.getAllLanguages()); command.setCurrentLanguage(lang); command.setTest(test); executeCommand(command); refresh(); } }); updateLanguageCombo(); openI18nFileButton = getWidgetFactory().createButton(composite, "Open file", SWT.PUSH); openI18nFileButton.setLayoutData(buttonData); openI18nFileButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent se) { IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IResource resource = root.findMember( new Path(test.getAllLanguages().getCurrentLanguage().getFileName())); IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); try { IDE.openEditor(page, ResourceUtil.getFile(resource), true); } catch (PartInitException e) { ErrorHandler.logAndShowErrorDialogAndRethrow( "Error opening internationalisation file", e); } } }); addLanguageButton = getWidgetFactory().createButton(composite, "Add language...", SWT.PUSH); addLanguageButton.addSelectionListener(addListener); addLanguageButton.setLayoutData(buttonData); refreshButton = getWidgetFactory().createButton(composite, "Refresh languages", SWT.PUSH); refreshButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { UpdateLangagesCommand command = new UpdateLangagesCommand(); command.addTest(test); // if (MessageDialog.openConfirm(new Shell(), "Confirm refreshing languages", // "\"Undo\" is not supported for this operation. Do you want to continue?")) executeCommand(command); refresh(); } }); refreshButton.setLayoutData(buttonData); removeButton = getWidgetFactory().createButton(composite, "Remove language", SWT.PUSH); removeButton.setLayoutData(buttonData); removeButton.addSelectionListener(removeListener); GridData statusData = new GridData(); statusData.horizontalSpan = 3; noI18nValuesLabel = getWidgetFactory() .createLabel( composite, "Status: No text values in internationalisation file. Add content, save file and press \"Refresh languages\""); noI18nValuesLabel.setLayoutData(statusData); noI18nValuesLabel.setVisible(false); noObserversLabel = getWidgetFactory() .createLabel( composite, "Status: No page elements has internationalisation enabled. " + "To enable, check \"Use internationalisation\" on page element identifiers."); noObserversLabel.setLayoutData(statusData); noObserversLabel.setVisible(false); }